aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormerakor <cem@ckyln.com>2020-06-20 14:29:40 +0000
committermerakor <cem@ckyln.com>2020-06-20 14:29:40 +0000
commit6c043469284ce2ffed111c2e90b3b2f25262cd14 (patch)
tree7c3110bbd5c7ac6fb64ccb031e20c8b734c63955
parent0b825ed89ef224bbbbf3870ca814b41b0ff3174a (diff)
downloadcpt-6c043469284ce2ffed111c2e90b3b2f25262cd14.tar.gz
kiss: explicitly set USER variable when using 'su'
This had caused packages to be installed using the wrong priviliges since the root requirement for package installation had been removed. FossilOrigin-Name: ac797c1ecc29542930363d025aef4ddb397245f60036d47706263060efdc92aa
-rwxr-xr-xkiss9
1 files changed, 5 insertions, 4 deletions
diff --git a/kiss b/kiss
index b4fecfe..c0b41a6 100755
--- a/kiss
+++ b/kiss
@@ -71,10 +71,11 @@ as_root() {
# 'doas' or 'su'. Hurrah for choice.
[ "$uid" = 0 ] || log "Using '${su:-su}' (to become ${user:=root})"
- case $su in
- *sudo) sudo -E -u "$user" -- "$@" ;;
- *doas) doas -u "$user" -- "$@" ;;
- *) su -pc "$* <&3" "$user" 3<&0 </dev/tty ;;
+ case ${su##*/} in
+ sudo) sudo -E -u "$user" -- "$@" ;;
+ doas) doas -u "$user" -- "$@" ;;
+ su) su -pc "env USER=$user $* <&3" "$user" 3<&0 </dev/tty ;;
+ *) die "Invalid KISS_SU value: $su" ;;
esac
}