mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-21 23:20:20 +00:00
Meta: Don't depend on sudo for privileged operations
We previously depended on sudo's specific -E flag to keep all the environment variables when performing a privilege escalation. We now incorporate the -E flag into the $SUDO variable, allowing for other privilege escalation binaries (such as doas) to be used (as long as they preserve the current environment variables).
This commit is contained in:
parent
7a51e846b2
commit
88c9e4f3b0
Notes:
sideshowbarker
2024-07-17 03:14:44 +09:00
Author: https://github.com/Baitinq Commit: https://github.com/SerenityOS/serenity/commit/88c9e4f3b0 Pull-request: https://github.com/SerenityOS/serenity/pull/16162 Reviewed-by: https://github.com/ADKaster Reviewed-by: https://github.com/linusg Reviewed-by: https://github.com/timschumi ✅
6 changed files with 10 additions and 7 deletions
|
@ -3,10 +3,13 @@
|
|||
# SC2034: "Variable appears unused. Verify it or export it."
|
||||
# Those are intentional here, as the file is meant to be included elsewhere.
|
||||
|
||||
SUDO="sudo"
|
||||
# NOTE: If using another privilege escalation binary make sure it is configured or has the appropiate flag
|
||||
# to keep the current environment variables in the launched process (in sudo's case this is achieved
|
||||
# through the -E flag described in sudo(8).
|
||||
SUDO="sudo -E"
|
||||
|
||||
if [ "$(uname -s)" = "SerenityOS" ]; then
|
||||
SUDO="pls"
|
||||
SUDO="pls -E"
|
||||
fi
|
||||
|
||||
die() {
|
||||
|
|
|
@ -8,7 +8,7 @@ script_path=$(cd -P -- "$(dirname -- "$0")" && pwd -P)
|
|||
|
||||
if [ "$(id -u)" != 0 ]; then
|
||||
set +e
|
||||
${SUDO} -E -- sh -c "\"$0\" $* || exit 42"
|
||||
${SUDO} -- sh -c "\"$0\" $* || exit 42"
|
||||
case $? in
|
||||
1)
|
||||
die "this script needs to run as root"
|
||||
|
|
|
@ -8,7 +8,7 @@ script_path=$(cd -P -- "$(dirname -- "$0")" && pwd -P)
|
|||
|
||||
if [ "$(id -u)" != 0 ]; then
|
||||
set +e
|
||||
${SUDO} -E -- sh -c "\"$0\" $* || exit 42"
|
||||
${SUDO} -- sh -c "\"$0\" $* || exit 42"
|
||||
case $? in
|
||||
1)
|
||||
die "this script needs to run as root"
|
||||
|
|
|
@ -17,7 +17,7 @@ fi
|
|||
|
||||
if [ "$(id -u)" != 0 ]; then
|
||||
set +e
|
||||
${SUDO} -E -- sh -c "\"$0\" $* || exit 42"
|
||||
${SUDO} -- sh -c "\"$0\" $* || exit 42"
|
||||
case $? in
|
||||
1)
|
||||
die "this script needs to run as root"
|
||||
|
|
|
@ -25,7 +25,7 @@ if [ "$(id -u)" != 0 ]; then
|
|||
USE_FUSE2FS=1
|
||||
else
|
||||
set +e
|
||||
${SUDO} -E -- sh -c "\"$0\" $* || exit 42"
|
||||
${SUDO} -- sh -c "\"$0\" $* || exit 42"
|
||||
case $? in
|
||||
1)
|
||||
die "this script needs to run as root"
|
||||
|
|
|
@ -16,7 +16,7 @@ cleanup() {
|
|||
|
||||
if [ "$(id -u)" != 0 ]; then
|
||||
set +e
|
||||
${SUDO} -E -- sh -c "\"$0\" $* || exit 42"
|
||||
${SUDO} -- sh -c "\"$0\" $* || exit 42"
|
||||
case $? in
|
||||
1)
|
||||
die "this script needs to run as root"
|
||||
|
|
Loading…
Reference in a new issue