kiss: Clean up as_root()

This commit is contained in:
Dylan Araps 2020-06-11 08:51:35 +03:00
parent b0a460fcf6
commit a39e9d2410
No known key found for this signature in database
GPG Key ID: 46D62DD9F1DE636E

7
kiss
View File

@ -56,10 +56,9 @@ as_root() {
[ "$uid" = 0 ] || log "Using '${su:-su}' (to become ${user:=root})" [ "$uid" = 0 ] || log "Using '${su:-su}' (to become ${user:=root})"
case ${su##*/} in case ${su##*/} in
sudo) sudo -u "$user" -- env "$@" ;; doas|sudo) "$su" -u "$user" -- env "$@" ;;
doas) doas -u "$user" -- env "$@" ;; su) "$su" -c "env $* <&3" "$user" 3<&0 </dev/tty ;;
su) su -c "env $* <&3" "$user" 3<&0 </dev/tty ;; *) die "Invalid KISS_SU value: $su (valid: doas, sudo, su)"
*) die "Invalid KISS_SU value: $su (valid: doas, sudo, su)"
esac esac
} }