mirror of
https://github.com/pi-hole/pi-hole.git
synced 2024-11-22 06:03:43 +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:
parent
bfc18f8329
commit
25f384a923
1 changed files with 14 additions and 0 deletions
|
@ -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"
|
||||
|
|
Loading…
Reference in a new issue