kiss: drop root when running git if needed

This commit is contained in:
Dylan Araps 2020-01-27 11:29:20 +02:00
parent 7493ccb17b
commit d61986721d
No known key found for this signature in database
GPG Key ID: 46D62DD9F1DE636E

11
kiss
View File

@ -71,7 +71,7 @@ dosu() {
# command allows you to input a password via stdin. To hide
# the prompt, the command's output is sent to '/dev/tty'
# and the output of 'su' is sent to '/dev/null'.
echo "$pass" | su -c "$* >/dev/tty" >/dev/null
echo "$pass" | su "${drop_to:-root}" -c "$* >/dev/tty" >/dev/null
}
pkg_lint() {
@ -912,9 +912,16 @@ pkg_updates() {
if [ -w "$PWD" ]; then
git fetch
git merge
else
log "$PWD" "Need root to update"
# Find out the owner of the repository and spawn
# git as this user below.
(drop_to=$(stat -c %U "$PWD")
dosu git fetch
dosu git merge
dosu git merge)
fi
}
done