cleanup and support sup,sud,pkexec

This commit is contained in:
Jaromil 2022-02-20 21:23:01 +01:00
parent 7ef9499160
commit 612404bdce

34
tomb
View File

@ -114,11 +114,12 @@ export TEXTDOMAIN=tomb
# Wrap sudo with a more visible message or apply user-supplied alternative to sudo # Wrap sudo with a more visible message or apply user-supplied alternative to sudo
_sudo() { _sudo() {
if option_is_set --sudo; then if option_is_set --sudo; then
case `basename $(option_value --sudo)` in pescmd=`option_value --sudo`
"doas") case `basename $pescmd` in
command -v doas >/dev/null || _failure "Doas executable not found in PATH" "doas"|"sup"|"sud"|"pkexec")
_verbose "Super user execution using doas" command -v $pescmd > /dev/null || _failure "$pescmd executable not found"
doas ${@} _verbose "Super user execution using $pescmd"
${pescmd} ${@}
return $? return $?
;; ;;
"skip"|"none") "skip"|"none")
@ -3290,27 +3291,8 @@ main() {
option_is_set --tmp && TMPDIR=$(option_value --tmp) option_is_set --tmp && TMPDIR=$(option_value --tmp)
option_is_set --sudo && { option_is_set --sudo && {
local _opt=`option_value --sudo` local _opt=`basename $(option_value --sudo)`
case $_opt in _message "Privilege escalation tool configured: ::1 exec::" $_opt
"sudo") # the worst default ever
SUDO=sudo
;;
"doas") # openbsd
SUDO=doas
;;
"pkexec") # policykit
SUDO=pkexec
;;
"sup") # https://sup.dyne.org
SUDO=sup
;;
"sud") # https://sud.dyne.org
SUDO=sud
;;
*)
_failure "Invalid privilege escalation tool: ::1 exec::" $_opt
;;
esac
} }
# When we run as root, we remember the original uid:gid to set # When we run as root, we remember the original uid:gid to set