From 6292e65b376ce1d5ad350da2a0b951fc1480f744 Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Sat, 28 Oct 2023 17:56:37 +0100 Subject: [PATCH 1/2] When setting a blank password, use `webserver.api.password` instead of `webserver.api.pwhash` (fixed in https://github.com/pi-hole/FTL/pull/1702) This prevents the password from being blanked out on the command line when it has been set by an environment variable --- pihole | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pihole b/pihole index 9cc1069f..8e3f1f98 100755 --- a/pihole +++ b/pihole @@ -43,7 +43,7 @@ SetWebPassword() { echo "" if [ "${PASSWORD}" == "" ]; then - setFTLConfigValue "webserver.api.pwhash" "" >/dev/null + setFTLConfigValue "webserver.api.password" "" >/dev/null echo -e " ${TICK} Password Removed" exit 0 fi From ab3b6dfa67b0699a0fa895f2318a7a28f78ddca7 Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Sat, 28 Oct 2023 19:46:45 +0100 Subject: [PATCH 2/2] No need to >/dev/null because setFTLConfigValue already does this adjust output of setFTLConfigValue to test for the exit code of `pihole-FTL --config` --- advanced/Scripts/utils.sh | 4 ++++ pihole | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/advanced/Scripts/utils.sh b/advanced/Scripts/utils.sh index 3f9b7031..2fe419e8 100755 --- a/advanced/Scripts/utils.sh +++ b/advanced/Scripts/utils.sh @@ -145,4 +145,8 @@ getFTLConfigValue(){ ####################### setFTLConfigValue(){ pihole-FTL --config "${1}" "${2}" >/dev/null + if [[ $? -eq 5 ]]; then + echo -e " ${CROSS} ${1} set by environment variable. Please unset it to use this function" + exit 5 + fi } diff --git a/pihole b/pihole index 8e3f1f98..279977e4 100755 --- a/pihole +++ b/pihole @@ -43,7 +43,7 @@ SetWebPassword() { echo "" if [ "${PASSWORD}" == "" ]; then - setFTLConfigValue "webserver.api.password" "" >/dev/null + setFTLConfigValue "webserver.api.password" "" echo -e " ${TICK} Password Removed" exit 0 fi @@ -54,7 +54,7 @@ SetWebPassword() { if [ "${PASSWORD}" == "${CONFIRM}" ] ; then # pihole-FTL will automatically hash the password - setFTLConfigValue "webserver.api.password" "${PASSWORD}" >/dev/null + setFTLConfigValue "webserver.api.password" "${PASSWORD}" echo -e " ${TICK} New password set" else echo -e " ${CROSS} Passwords don't match. Your password has not been changed"