1
0
mirror of https://github.com/pi-hole/pi-hole synced 2025-03-11 06:46:15 +00:00

Fix empty password detection

The CLI skips double quotes in config output, hence the output is completely empty, if no password was applied yet, e.g. on a fresh install. This leads to an unprotected web interface. The check is corrected, to have a random password applied as intended.

Additionally, the logic to show an unchanged or unset password on the completion dialog is inverted to correctly show "unchanged" resp. "NOT SET" if the password has not been changed resp. is empty.

Signed-off-by: MichaIng <micha@dietpi.com>
This commit is contained in:
MichaIng 2025-02-20 18:05:00 +01:00
parent 99bd142dd5
commit cd4efc3141
No known key found for this signature in database
GPG Key ID: CE6E5D0C45CE1624

View File

@ -1766,7 +1766,7 @@ displayFinalMessage() {
if [[ "${#1}" -gt 0 ]]; then if [[ "${#1}" -gt 0 ]]; then
# set the password to the first argument. # set the password to the first argument.
pwstring="$1" pwstring="$1"
elif [[ $(pihole-FTL --config webserver.api.pwhash) == '""' ]]; then elif [[ -n $(pihole-FTL --config webserver.api.pwhash) ]]; then
# Else if the password exists from previous setup, we'll load it later # Else if the password exists from previous setup, we'll load it later
pwstring="unchanged" pwstring="unchanged"
else else
@ -2518,7 +2518,7 @@ main() {
# Add password to web UI if there is none # Add password to web UI if there is none
pw="" pw=""
# If no password is set, # If no password is set,
if [[ $(pihole-FTL --config webserver.api.pwhash) == '""' ]]; then if [[ -z $(pihole-FTL --config webserver.api.pwhash) ]]; then
# generate a random password # generate a random password
pw=$(tr -dc _A-Z-a-z-0-9 </dev/urandom | head -c 8) pw=$(tr -dc _A-Z-a-z-0-9 </dev/urandom | head -c 8)
pihole setpassword "${pw}" pihole setpassword "${pw}"