Minor refactor of secure_session() and easyrsa_mktemp()
Squashed commit of the following:
commit b93c8e60649d835b66fc4ab2c1d6050e6b1ca231
Merge: 17cbf07 130c161
Author: Richard T Bonhomme <tincantech@protonmail.com>
Date: Wed Oct 26 21:08:00 2022 +0100
Merge branch 'easyrsa-mktemp' of ssh://github.com/TinCanTech/easy-rsa into TinCanTech-easyrsa-mktemp
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
commit 130c161746d8e7885c7c3a86b8d29d28476b3890
Author: Richard T Bonhomme <tincantech@protonmail.com>
Date: Wed Oct 26 20:00:56 2022 +0100
Minor refactor of secure_session() and easyrsa_mktemp()
Return without error on successful completion of final command.
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
This commit is contained in:
parent
17cbf07b29
commit
ab7c4804fb
@ -608,10 +608,8 @@ secure_session() {
|
|||||||
"$EASYRSA_OPENSSL" rand -hex 4
|
"$EASYRSA_OPENSSL" rand -hex 4
|
||||||
)" || die "secure_session - rand '$rand'"
|
)" || die "secure_session - rand '$rand'"
|
||||||
|
|
||||||
mkdir "${EASYRSA_TEMP_DIR}/${rand}" || continue
|
|
||||||
EASYRSA_TEMP_DIR_session="${EASYRSA_TEMP_DIR}/${rand}"
|
EASYRSA_TEMP_DIR_session="${EASYRSA_TEMP_DIR}/${rand}"
|
||||||
#EASYRSA_TEMP_DIR_session_rand="${rand}"
|
mkdir "$EASYRSA_TEMP_DIR_session" && return
|
||||||
return
|
|
||||||
done
|
done
|
||||||
return 1
|
return 1
|
||||||
} # => secure_session()
|
} # => secure_session()
|
||||||
@ -619,10 +617,14 @@ secure_session() {
|
|||||||
# Create tempfile atomically or fail
|
# Create tempfile atomically or fail
|
||||||
easyrsa_mktemp() {
|
easyrsa_mktemp() {
|
||||||
# session directory must exist
|
# session directory must exist
|
||||||
if [ "$EASYRSA_TEMP_DIR_session" ] && [ -d "$EASYRSA_TEMP_DIR_session" ]; then
|
if [ "$EASYRSA_TEMP_DIR_session" ] && \
|
||||||
|
[ -d "$EASYRSA_TEMP_DIR_session" ]
|
||||||
|
then
|
||||||
: # ok
|
: # ok
|
||||||
else
|
else
|
||||||
die "Non-existant temporary session: $EASYRSA_TEMP_DIR_session"
|
die "\
|
||||||
|
Non-existant temporary session:
|
||||||
|
* $EASYRSA_TEMP_DIR_session"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
for i in 1 2 3; do
|
for i in 1 2 3; do
|
||||||
@ -640,8 +642,8 @@ easyrsa_mktemp() {
|
|||||||
|
|
||||||
tempfile="${EASYRSA_TEMP_DIR_session}/temp.$rand"
|
tempfile="${EASYRSA_TEMP_DIR_session}/temp.$rand"
|
||||||
mv "$shotfile" "$tempfile" || continue
|
mv "$shotfile" "$tempfile" || continue
|
||||||
printf '%s\n' "$tempfile" || die "easyrsa_mktemp - write temp"
|
# Print the new temporary file-name for the caller
|
||||||
return
|
printf '%s\n' "$tempfile" && return
|
||||||
done
|
done
|
||||||
return 1
|
return 1
|
||||||
} # => easyrsa_mktemp()
|
} # => easyrsa_mktemp()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user