Merge branch 'luizluca-fix_read_s'

Should "fix" errors related to ash and potentially other non-POSIX
shells that don't handle set -o or related options.

http://www.austingroupbugs.net/view.php?id=1207

Signed-off-by: Eric F Crist <ecrist@secure-computing.net>
This commit is contained in:
Eric F Crist 2019-06-07 07:24:48 -05:00
commit 5340fb2dfc
No known key found for this signature in database
GPG Key ID: 72964219390D0D0E

View File

@ -317,7 +317,7 @@ easyrsa_mktemp() {
# remove temp files and do terminal cleanups
cleanup() {
[ -z "$EASYRSA_TEMP_DIR_session" ] || rm -rf "$EASYRSA_TEMP_DIR_session"
(stty echo 2>/dev/null) || set -o echo
(stty echo 2>/dev/null) || { (set -o echo 2>/dev/null) && set -o echo; }
echo "" # just to get a clean line
} # => cleanup()
@ -514,9 +514,20 @@ Your newly created PKI dir is: $EASYRSA_PKI
hide_read_pass()
{
(stty -echo 2>/dev/null) || set +o echo
read -r "$@"
(stty echo 2>/dev/null) || set -o echo
# shellcheck disable=SC2039
if stty -echo 2>/dev/null; then
read -r "$@"
stty echo
elif (set +o echo 2>/dev/null); then
set +o echo
read -r "$@"
set -o echo
elif (echo | read -r -s 2>/dev/null) ; then
read -r -s "$@"
else
warn "Could not disable echo. Password will be shown on screen!"
read -r "$@"
fi
} # => hide_read_pass()
# build-ca backend: