1
0
mirror of https://codeberg.org/kiss-community/kiss synced 2024-12-24 16:10:05 -07:00

kiss: Don't run user hook as root when sudo/doas are set to keep environment. Closes #157

This commit is contained in:
Dylan Araps 2020-05-18 09:08:04 +03:00
parent 51a839e120
commit e711f76296
No known key found for this signature in database
GPG Key ID: 46D62DD9F1DE636E

11
kiss
View File

@ -49,7 +49,10 @@ prompt() {
as_root() {
# Simple function to run a command as root using either 'sudo',
# 'doas' or 'su'. Hurrah for choice.
[ "$uid" = 0 ] || log "Using '${su:-su}' (to become ${user:=root})"
[ "$uid" = 0 ] || {
log "Using '${su:-su}' (to become ${user:=root})"
export KISS_AS_ROOT=1
}
case $su in
*sudo) sudo -E -u "$user" -- "$@" ;;
@ -69,11 +72,15 @@ _tar() {
}
run_hook() {
# If we have elevated permissions from non-root to
# root, don't run the non-root user's KISS_HOOK.
[ "$KISS_AS_ROOT" != 1 ] || KISS_HOOK=/etc/kiss-hook
# Provide a default post-build hook to remove files
# and directories for things we don't support out of
# the box. One can simply define their own hook to
# override this behavior.
[ "${KISS_HOOK:-}" ] || {
[ -f "${KISS_HOOK:-}" ] || {
case $1 in post-build)
rm -rf "$3/usr/share/gettext"
rm -rf "$3/usr/share/polkit-1"