Fix gravity user permission checking and fix error on pihole-FTL --config failures (#6352)

This commit is contained in:
Dan Schaper
2025-07-22 15:27:07 -07:00
committed by GitHub
2 changed files with 16 additions and 7 deletions

5
pihole
View File

@@ -566,7 +566,7 @@ case "${1}" in
"enable" ) need_root=0;;
"disable" ) need_root=0;;
"-d" | "debug" ) ;;
"-g" | "updateGravity" ) need_root=0;;
"-g" | "updateGravity" ) ;;
"reloaddns" ) ;;
"reloadlists" ) ;;
"setpassword" ) ;;
@@ -587,7 +587,8 @@ fi
# Check if the current user is not root and if the command
# requires root. If so, exit with an error message.
if [[ $EUID -ne 0 && need_root -eq 1 ]];then
# Add an exception for the user "pihole" to allow the webserver running gravity
if [[ ( $EUID -ne 0 && ${USER} != "pihole" ) && need_root -eq 1 ]]; then
echo -e " ${CROSS} The Pi-hole command requires root privileges, try:"
echo -e " ${COL_GREEN}sudo pihole $*${COL_NC}"
exit 1