mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-25 09:00:22 +00:00
Meta: Implement proper checks for sudo alternatives
This introduces support for building with doas.
This commit is contained in:
parent
af5eaf5edf
commit
fddbd11baa
Notes:
sideshowbarker
2024-07-17 17:38:29 +09:00
Author: https://github.com/sdomi Commit: https://github.com/SerenityOS/serenity/commit/fddbd11baa Pull-request: https://github.com/SerenityOS/serenity/pull/19877 Reviewed-by: https://github.com/alimpfard Reviewed-by: https://github.com/fdellwing Reviewed-by: https://github.com/linusg ✅
6 changed files with 21 additions and 11 deletions
|
@ -8,7 +8,7 @@ script_path=$(cd -P -- "$(dirname -- "$0")" && pwd -P)
|
|||
|
||||
if [ "$(id -u)" != 0 ]; then
|
||||
set +e
|
||||
${SUDO} -- sh -c "\"$0\" $* || exit 42"
|
||||
${SUDO} "${SHELL}" -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} -- sh -c "\"$0\" $* || exit 42"
|
||||
${SUDO} "${SHELL}" -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} -- sh -c "\"$0\" $* || exit 42"
|
||||
${SUDO} "${SHELL}" -c -- "\"$0\" $* || exit 42"
|
||||
case $? in
|
||||
1)
|
||||
die "this script needs to run as root"
|
||||
|
|
|
@ -12,7 +12,7 @@ if [ "$(id -u)" != 0 ]; then
|
|||
USE_FUSE2FS=1
|
||||
else
|
||||
set +e
|
||||
${SUDO} -- sh -c "\"$0\" $* || exit 42"
|
||||
${SUDO} "${SHELL}" -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} -- sh -c "\"$0\" $* || exit 42"
|
||||
${SUDO} "${SHELL}" -c -- "\"$0\" $* || exit 42"
|
||||
case $? in
|
||||
1)
|
||||
die "this script needs to run as root"
|
||||
|
|
|
@ -6,17 +6,27 @@
|
|||
# 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 -E"
|
||||
fi
|
||||
|
||||
die() {
|
||||
echo "die: $*"
|
||||
exit 1
|
||||
}
|
||||
|
||||
if [ "$(uname -s)" = "SerenityOS" ]; then
|
||||
SUDO="pls -E"
|
||||
elif command -v sudo >/dev/null; then
|
||||
SUDO="sudo -E"
|
||||
elif command -v doas >/dev/null; then
|
||||
if [ "$SUDO_UID" = '' ]; then
|
||||
SUDO_UID=$(id -u)
|
||||
SUDO_GID=$(id -g)
|
||||
export SUDO_UID SUDO_GID
|
||||
fi
|
||||
# To make doas work, you have to make sure you use the "keepenv" flag in doas.conf
|
||||
SUDO="doas"
|
||||
else
|
||||
die "You need sudo, doas or pls to build Serenity..."
|
||||
fi
|
||||
|
||||
exit_if_running_as_root() {
|
||||
if [ "$(id -u)" -eq 0 ]; then
|
||||
die "$*"
|
||||
|
|
Loading…
Reference in a new issue