aboutsummaryrefslogtreecommitdiff
path: root/kiss
diff options
context:
space:
mode:
authordylan.araps@gmail.com <dylan.araps@gmail.com>2020-01-30 15:24:57 +0000
committerdylan.araps@gmail.com <dylan.araps@gmail.com>2020-01-30 15:24:57 +0000
commit82f5735ece844f3f876886a0cb2bdfea22a36b1a (patch)
treebb8d42ccc7462d41c94d4ac199fe8218fa01e210 /kiss
parent98679c45adc4137c96219cbf382fcc1873e3e1fc (diff)
downloadcpt-82f5735ece844f3f876886a0cb2bdfea22a36b1a.tar.gz
kiss: Don't pull as git if unneeded
FossilOrigin-Name: 24c0f1f5d26fe41946eff9b46dfc53ac36b96e8d5576060823cadf24d92a99fc
Diffstat (limited to 'kiss')
-rwxr-xr-xkiss21
1 files changed, 17 insertions, 4 deletions
diff --git a/kiss b/kiss
index c9979e5..5605bae 100755
--- a/kiss
+++ b/kiss
@@ -54,9 +54,9 @@ as_root() {
log "Using '${su:-su}'"
case $su in
- *sudo) sudo -E -- "$@" ;;
- *doas) doas -- "$@" ;;
- *) su -pc "$* <&3" 3<&0 </dev/tty ;;
+ *sudo) sudo -Eu "${user:-root}" -- "$@" ;;
+ *doas) doas -u "${user:-root}" -- "$@" ;;
+ *) su -pc "$* <&3" "${user:-root}" 3<&0 </dev/tty ;;
esac
}
@@ -1025,7 +1025,20 @@ pkg_updates() {
else
log "$PWD" "Need root to update"
- as_root git pull
+ # Find out the owner of the repository and spawn
+ # git as this user below.
+ #
+ # This prevents 'git' from changing the original
+ # ownership of files and directories in the rare
+ # case that the repository is owned by a 3rd user.
+ (
+ user=$(stat -c %U "$PWD")
+
+ [ "$user" = root ] ||
+ log "Dropping permissions to $user for pull"
+
+ as_root git pull
+ )
fi
}
done