mirror of
https://github.com/pi-hole/pi-hole.git
synced 2025-07-30 17:14:16 +02:00
Fix gravity user permission checking and fix error on pihole-FTL --config failures (#6352)
This commit is contained in:
commit
29b6252935
@ -86,9 +86,17 @@ getFTLConfigValue(){
|
|||||||
# setFTLConfigValue dns.upstreams '[ "8.8.8.8" , "8.8.4.4" ]'
|
# setFTLConfigValue dns.upstreams '[ "8.8.8.8" , "8.8.4.4" ]'
|
||||||
#######################
|
#######################
|
||||||
setFTLConfigValue(){
|
setFTLConfigValue(){
|
||||||
pihole-FTL --config "${1}" "${2}" >/dev/null
|
local err
|
||||||
if [ $? -eq 5 ]; then
|
{ pihole-FTL --config "${1}" "${2}" >/dev/null; err="$?"; } || true
|
||||||
printf " %s %s set by environment variable. Please unset it to use this function\n" "${CROSS}" "${1}"
|
|
||||||
exit 5
|
case $err in
|
||||||
fi
|
0) ;;
|
||||||
|
5)
|
||||||
|
# FTL returns 5 if the value was set by an environment variable and is therefore read-only
|
||||||
|
printf " %s %s set by environment variable. Please unset it to use this function\n" "${CROSS}" "${1}";
|
||||||
|
exit 5;;
|
||||||
|
*)
|
||||||
|
printf " %s Failed to set %s. Try with sudo power\n" "${CROSS}" "${1}"
|
||||||
|
exit 1
|
||||||
|
esac
|
||||||
}
|
}
|
||||||
|
5
pihole
5
pihole
@ -566,7 +566,7 @@ case "${1}" in
|
|||||||
"enable" ) need_root=0;;
|
"enable" ) need_root=0;;
|
||||||
"disable" ) need_root=0;;
|
"disable" ) need_root=0;;
|
||||||
"-d" | "debug" ) ;;
|
"-d" | "debug" ) ;;
|
||||||
"-g" | "updateGravity" ) need_root=0;;
|
"-g" | "updateGravity" ) ;;
|
||||||
"reloaddns" ) ;;
|
"reloaddns" ) ;;
|
||||||
"reloadlists" ) ;;
|
"reloadlists" ) ;;
|
||||||
"setpassword" ) ;;
|
"setpassword" ) ;;
|
||||||
@ -587,7 +587,8 @@ fi
|
|||||||
|
|
||||||
# Check if the current user is not root and if the command
|
# Check if the current user is not root and if the command
|
||||||
# requires root. If so, exit with an error message.
|
# 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 " ${CROSS} The Pi-hole command requires root privileges, try:"
|
||||||
echo -e " ${COL_GREEN}sudo pihole $*${COL_NC}"
|
echo -e " ${COL_GREEN}sudo pihole $*${COL_NC}"
|
||||||
exit 1
|
exit 1
|
||||||
|
Loading…
x
Reference in New Issue
Block a user