Issue #824 - Don't log password (#825)

When setting the password, explicitly disable bash logging. Leave the
re-enable code so that other functions work as expected. Additionally,
do not remove the print in generate_password so randomly generated
passwords are still logged for user consistency.

Signed-off-by: Kyle Kurz <kyle@doublekaudio.com>
This commit is contained in:
Kyle Kurz 2021-04-14 12:13:01 -04:00 committed by GitHub
parent 190844d0b0
commit f53015157d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 6 deletions

View File

@ -230,17 +230,14 @@ setup_web_password() {
setup_var_exists "WEBPASSWORD" && return
PASS="$1"
# Turn bash debug on while setting up password (to print it)
# Explicitly turn off bash printing when working with secrets
{ set +x; } 2>/dev/null
if [[ "$PASS" == "" ]] ; then
echo "" | pihole -a -p
else
echo "Setting password: ${PASS}"
set -x
pihole -a -p "$PASS" "$PASS"
fi
# Turn bash debug back off after print password setup
# (subshell to null hides printing output)
{ set +x; } 2>/dev/null
# To avoid printing this if conditional in bash debug, turn off debug above..
# then re-enable debug if necessary (more code but cleaner printed output)