From cf7923c21f309ba70766f0c7bbc8be97ae523e43 Mon Sep 17 00:00:00 2001 From: JohnTheCoolingFan Date: Sat, 11 May 2024 15:57:10 +0300 Subject: [PATCH] Add doas support to is_root_or_sudo_prefix doas is not compatible with sudo flags. The codebase was checked for sudo-specific uses of this function, but none were found, all cases were in the form of `sudo `. Replacing it with `doas ` yields the same result. --- lib/functions/host/host-utils.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/functions/host/host-utils.sh b/lib/functions/host/host-utils.sh index fd20f63720..2abed9066c 100644 --- a/lib/functions/host/host-utils.sh +++ b/lib/functions/host/host-utils.sh @@ -96,6 +96,10 @@ function is_root_or_sudo_prefix() { # sudo binary found in path, use it. display_alert "EUID is not 0" "sudo binary found, using it" "debug" __my_sudo_prefix="sudo" + elif [[ -n "$(command -v doas)" ]]; then + # doas binary found in path, use it. + display_alert "EUID is not 0" "doas binary found, using it" "debug" + __my_sudo_prefix="doas" else # No root and no sudo binary. Bail out exit_with_error "EUID is not 0 and no sudo binary found - Please install sudo or run as root"