1
0
mirror of https://github.com/pi-hole/pi-hole synced 2024-12-22 23:08:07 +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="" API_PORT=""
else else
# API is available at this URL combination # API is available at this URL combination
if [ "${availabilityResonse}" = 200 ]; then
# API is available without authentication
needAuth=false
fi
break break
fi fi
@ -75,10 +81,16 @@ TestAPIAvailability() {
} }
LoginAPI() { LoginAPI() {
# If the API URL is not set, test the availability
if [ -z "${API_URL}" ]; then if [ -z "${API_URL}" ]; then
TestAPIAvailability TestAPIAvailability
fi 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) # Try to read the CLI password (if enabled and readable by the current user)
if [ -r /etc/pihole/cli_pw ]; then if [ -r /etc/pihole/cli_pw ]; then
password=$(cat /etc/pihole/cli_pw) password=$(cat /etc/pihole/cli_pw)
@ -87,6 +99,8 @@ LoginAPI() {
Authentication Authentication
fi fi
# If this did not work, ask the user for the password # If this did not work, ask the user for the password
while [ "${validSession}" = false ] || [ -z "${validSession}" ] ; do while [ "${validSession}" = false ] || [ -z "${validSession}" ] ; do
echo "Authentication failed. Please enter your Pi-hole password" echo "Authentication failed. Please enter your Pi-hole password"