kiss: Don't spawn sh with sudo/doas

This commit is contained in:
Dylan Araps 2020-01-30 15:25:46 +02:00
parent 5c601bd695
commit 26a20c9738
No known key found for this signature in database
GPG Key ID: 46D62DD9F1DE636E
1 changed files with 5 additions and 10 deletions

15
kiss
View File

@ -53,13 +53,9 @@ as_root() {
# 'doas' or 'su'. This also handles KISS' environment variables. # 'doas' or 'su'. This also handles KISS' environment variables.
log "Using '${su:-su}'" 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 case $su in
*sudo) sudo -E sh -c "$*" ;; *sudo) sudo -E "$@" ;;
*doas) doas -- sh -c "$env $*" ;; *doas) doas -- "$@" ;;
*) su -pc "$* <&3" 3<&0 </dev/tty ;; *) su -pc "$* <&3" 3<&0 </dev/tty ;;
esac esac
} }
@ -1024,13 +1020,12 @@ pkg_updates() {
log "$PWD" "$signed " log "$PWD" "$signed "
if [ -w "$PWD" ]; then if [ -w "$PWD" ]; then
git fetch git pull
git merge
else else
log "$PWD" "Need root to update" log "$PWD" "Need root to update"
as_root 'git fetch && git merge' as_root git pull
fi fi
} }
done done
@ -1264,7 +1259,7 @@ args() {
;; ;;
v|version|-v|--version) v|version|-v|--version)
log kiss 1.1.4 log kiss 1.1.5
;; ;;
h|help|-h|--help|'') h|help|-h|--help|'')