mirror of
https://github.com/pi-hole/pi-hole.git
synced 2024-11-15 02:42:58 +00:00
mask password input on command line
This commit is contained in:
parent
0acf70f836
commit
ee296f36c1
2 changed files with 9 additions and 7 deletions
|
@ -81,19 +81,21 @@ SetWebPassword(){
|
|||
exit 1
|
||||
fi
|
||||
|
||||
# Set password only if there is one to be set
|
||||
if (( ${#args[2]} > 0 )) ; then
|
||||
read -s -p "Enter New Password: " PASSWORD
|
||||
echo ""
|
||||
read -s -p "Confirm Password: " CONFIRM
|
||||
echo ""
|
||||
if [ "${PASSWORD}" == "${CONFIRM}" ] ; then
|
||||
# Compute password hash twice to avoid rainbow table vulnerability
|
||||
hash=$(echo -n ${args[2]} | sha256sum | sed 's/\s.*$//')
|
||||
hash=$(echo -n ${PASSWORD} | sha256sum | sed 's/\s.*$//')
|
||||
hash=$(echo -n ${hash} | sha256sum | sed 's/\s.*$//')
|
||||
# Save hash to file
|
||||
change_setting "WEBPASSWORD" "${hash}"
|
||||
echo "New password set"
|
||||
else
|
||||
change_setting "WEBPASSWORD" ""
|
||||
echo "Password removed"
|
||||
echo "Passwords don't match. Your password has not been changed"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
ProcessDNSSettings() {
|
||||
|
|
|
@ -1460,7 +1460,7 @@ main() {
|
|||
echo "::: ${pw}"
|
||||
echo ":::"
|
||||
echo "::: You can always change it using"
|
||||
echo "::: pihole -a -p new_password"
|
||||
echo "::: pihole -a -p"
|
||||
fi
|
||||
fi
|
||||
|
||||
|
|
Loading…
Reference in a new issue