1
0
mirror of https://github.com/pi-hole/pi-hole synced 2024-12-22 14:58:08 +00:00

Do not use CLI password when no password is set at all

Signed-off-by: DL6ER <dl6er@dl6er.de>
This commit is contained in:
DL6ER 2024-06-20 19:41:47 +02:00
parent bfc18f8329
commit 25f384a923
No known key found for this signature in database
GPG Key ID: 00135ACBD90B28DD

View File

@ -51,6 +51,12 @@ TestAPIAvailability() {
API_PORT=""
else
# API is available at this URL combination
if [ "${availabilityResonse}" = 200 ]; then
# API is available without authentication
needAuth=false
fi
break
fi
@ -75,10 +81,16 @@ TestAPIAvailability() {
}
LoginAPI() {
# If the API URL is not set, test the availability
if [ -z "${API_URL}" ]; then
TestAPIAvailability
fi
# Exit early if authentication is not needed
if [ "${needAuth}" = false ]; then
return
fi
# Try to read the CLI password (if enabled and readable by the current user)
if [ -r /etc/pihole/cli_pw ]; then
password=$(cat /etc/pihole/cli_pw)
@ -87,6 +99,8 @@ LoginAPI() {
Authentication
fi
# If this did not work, ask the user for the password
while [ "${validSession}" = false ] || [ -z "${validSession}" ] ; do
echo "Authentication failed. Please enter your Pi-hole password"