Implement possibility to remove password using "pihole -web -p"

This commit is contained in:
DL6ER 2016-11-19 21:50:15 +01:00
parent 88c161769d
commit 733919be4a

View file

@ -43,11 +43,17 @@ SetWebPassword(){
# Remove password from file (create backup setupVars.conf.bak)
sed -i.bak '/WEBPASSWORD/d' /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
}