only exec if calling user is root

This commit is contained in:
Lance Vick 2023-05-03 18:30:07 -07:00
parent c80a7dc018
commit 7b178a53ef
Signed by: lrvick
GPG Key ID: 8E47A1EC35A1551D
1 changed files with 4 additions and 6 deletions

View File

@ -7,7 +7,7 @@ user=${USER:-"build"}
export HOME="/home/${user}" export HOME="/home/${user}"
# If running user is not root, pivot to custom user/group # If running user is not root, pivot to custom user/group
[ "$uid" != "0" ] && { if [ "$uid" != "0" ]; then
getent group "$gid" \ getent group "$gid" \
&& groupdel "$(awk -v i="$gid" -F: '$3 == i' /etc/group | cut -d: -f1)" && groupdel "$(awk -v i="$gid" -F: '$3 == i' /etc/group | cut -d: -f1)"
getent passwd "$uid" \ getent passwd "$uid" \
@ -21,8 +21,6 @@ export HOME="/home/${user}"
-s /bin/bash \ -s /bin/bash \
"${user}" "${user}"
setpriv --reuid="$uid" --regid="$gid" --init-groups "$@" setpriv --reuid="$uid" --regid="$gid" --init-groups "$@"
} else
exec "$@" exec "$@"
fi