mirror of
https://github.com/Llewellynvdm/Tomb.git
synced 2024-11-22 04:25:12 +00:00
improve support of non-sudo setup, by default support doas
aldo better support when launched from root
This commit is contained in:
parent
2082198b36
commit
bae8af351b
26
tomb
26
tomb
@ -48,8 +48,6 @@ for arg in "${(@)argv}"; do OLDARGS+=("$arg"); done
|
||||
typeset -a DD WIPE PINENTRY SUDO
|
||||
DD=(dd)
|
||||
WIPE=(rm -f)
|
||||
PINENTRY=(pinentry)
|
||||
SUDO=(sudo)
|
||||
|
||||
# load zsh regex module
|
||||
zmodload zsh/mapfile
|
||||
@ -133,6 +131,11 @@ _sudo() {
|
||||
esac
|
||||
|
||||
else
|
||||
if [[ "`id -u`" = "0" ]]; then
|
||||
_verbose "Super user execution skipped (SUID caller)"
|
||||
${@}
|
||||
return $?
|
||||
elif command -v sudo 1>/dev/null 2>/dev/null; then
|
||||
local msg="[sudo] Enter password for user ::1 user:: to gain superuser privileges"
|
||||
command -v gettext 1>/dev/null 2>/dev/null && msg="$(gettext -s "$msg")"
|
||||
msg=${(S)msg//::1*::/$USER}
|
||||
@ -142,6 +145,15 @@ $msg
|
||||
|
||||
" ${@}
|
||||
return $?
|
||||
elif command -v doas 1>/dev/null 2>/dev/null; then
|
||||
local msg="Enter password for user ::1 user:: to gain superuser privileges"
|
||||
command -v gettext 1>/dev/null 2>/dev/null && msg="$(gettext -s "$msg")"
|
||||
msg=${(S)msg//::1*::/$USER}
|
||||
doas ${@}
|
||||
return $?
|
||||
else
|
||||
_failure "No way found to escalate privileges to super user."
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
@ -994,7 +1006,7 @@ _list_optional_tools() {
|
||||
_ensure_dependencies() {
|
||||
|
||||
# Check for required programs
|
||||
for req in cryptsetup sudo gpg mkfs.ext4 e2fsck; do
|
||||
for req in cryptsetup gpg mkfs.ext4 e2fsck; do
|
||||
command -v $req 1>/dev/null 2>/dev/null || {
|
||||
_failure "Missing required dependency ::1 command::. Please install it." $req; }
|
||||
done
|
||||
@ -1011,10 +1023,10 @@ _ensure_dependencies() {
|
||||
# command -v pkexec 1>/dev/null 2>/dev/null
|
||||
# [[ $? == 0 ]] && ps ax | grep '[p]olkitd' 1>/dev/null 2>/dev/null && {
|
||||
# SUDO=(pkexec) }
|
||||
[[ "$SUDO" == "sudo" ]] && {
|
||||
command -v sudo 1>/dev/null 2>/dev/null ||
|
||||
_failure "No privilege escalation tool found, not even sudo"
|
||||
}
|
||||
# [[ "$SUDO" == "sudo" ]] && {
|
||||
# command -v sudo 1>/dev/null 2>/dev/null ||
|
||||
# _failure "No privilege escalation tool found, not even sudo"
|
||||
# }
|
||||
|
||||
# Which dd command to use
|
||||
command -v dcfldd 1>/dev/null 2>/dev/null && DD=(dcfldd statusinterval=1)
|
||||
|
Loading…
Reference in New Issue
Block a user