From 733919be4a0d22cfb4f93dbaaf3f30e03ed4ce84 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Sat, 19 Nov 2016 21:50:15 +0100 Subject: [PATCH] Implement possibility to remove password using "pihole -web -p" --- advanced/Scripts/webpage.sh | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/advanced/Scripts/webpage.sh b/advanced/Scripts/webpage.sh index 6d2975ba..0a66bc62 100755 --- a/advanced/Scripts/webpage.sh +++ b/advanced/Scripts/webpage.sh @@ -43,11 +43,17 @@ SetWebPassword(){ # Remove password from file (create backup setupVars.conf.bak) sed -i.bak '/WEBPASSWORD/d' /etc/pihole/setupVars.conf - # Compute password hash twice to avoid rainbow table vulnerability - hash=$(echo -n ${args[2]} | sha256sum | sed 's/\s.*$//') - hash=$(echo -n ${hash} | sha256sum | sed 's/\s.*$//') - # Save hash to file - echo "WEBPASSWORD=${hash}" >> /etc/pihole/setupVars.conf + # Set password only if there is one to be set + if (( ${#args[2]} > 0 )) ; then + # Compute password hash twice to avoid rainbow table vulnerability + hash=$(echo -n ${args[2]} | sha256sum | sed 's/\s.*$//') + hash=$(echo -n ${hash} | sha256sum | sed 's/\s.*$//') + # Save hash to file + echo "WEBPASSWORD=${hash}" >> /etc/pihole/setupVars.conf + echo "New password set" + else + echo "Password removed" + fi }