workaround win32 mktemp bug
win32 mktemp shipped by easyrsa does not work. It returns unmodified template as the "temporary file". This results in file conflicts when two temporary files are in use. However win32 mktemp -d does work as expected. So, we can use mktemp -du to generate a correct temporary file name. Signed-off-by: Luiz Angelo Daros de Luca <luizluca@gmail.com>
This commit is contained in:
parent
12ee30a802
commit
e2a8b78d9a
@ -311,7 +311,18 @@ easyrsa_mktemp() {
|
||||
[ -n "$EASYRSA_TEMP_DIR_session" ] || die "EASYRSA_TEMP_DIR_session not initialized!"
|
||||
[ -d "$EASYRSA_TEMP_DIR_session" ] || mkdir -p "$EASYRSA_TEMP_DIR_session" ||
|
||||
die "Could not create temporary directory '$EASYRSA_TEMP_DIR_session'. Permission or concurrency problem?"
|
||||
mktemp "$EASYRSA_TEMP_DIR_session/tmp.XXXXXX"
|
||||
[ -d "$EASYRSA_TEMP_DIR_session" ] || die "Temporary directory '$EASYRSA_TEMP_DIR_session' does not exist"
|
||||
|
||||
template="$EASYRSA_TEMP_DIR_session/tmp.XXXXXX"
|
||||
tempfile=$(mktemp "$template") || return
|
||||
|
||||
# win32 mktemp shipped by easyrsa returns template as file!
|
||||
if [ "$template" = "$tempfile" ]; then
|
||||
# but win32 mktemp -d does work
|
||||
tempfile=$(mktemp -du "$tempfile") || return
|
||||
printf "" > "$tempfile" || return
|
||||
fi
|
||||
echo "$tempfile"
|
||||
} # => easyrsa_mktemp
|
||||
|
||||
# remove temp files and do terminal cleanups
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user