From ca2607068357cfc55be576fcf126d36727f2ea4f Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Thu, 30 Jan 2020 14:32:57 +0200 Subject: [PATCH] kiss: Fix update bug --- kiss | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/kiss b/kiss index c335a9b..3b474f5 100755 --- a/kiss +++ b/kiss @@ -49,16 +49,23 @@ prompt() { } as_root() { + # Simple function to run a command as root using either 'sudo', + # 'doas' or 'su'. This also handles KISS' environment variables. [ "$(id -u)" = 0 ] || { log "Using '${su:-su}'" + # doas requires these environment variables to be set as they + # aren't brought over from the calling user. + env="HOME='$HOME' KISS_FORCE='$KISS_FORCE' KISS_PATH='$KISS_PATH'" + case $su in *sudo) sudo -E sh -c "$*" ;; - *doas) doas -- sh -c "HOME='$HOME' KISS_PATH='$KISS_PATH' $*" ;; + *doas) doas -- sh -c "$env $*" ;; *) su -pc "$* <&3" 3<&0