1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 23:47:45 +00:00

Meta: Implement proper checks for sudo alternatives

This introduces support for building with doas.
This commit is contained in:
Dominique Liberda 2023-07-08 06:31:05 +02:00 committed by Linus Groh
parent af5eaf5edf
commit fddbd11baa
6 changed files with 21 additions and 11 deletions

View file

@ -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 "$*"