Use 'setpriv' instead of 'sudo' for UID change.

This commit is contained in:
Darren 'Tadgy' Austin 2022-08-23 23:21:07 +01:00
commit 417dbc80cb

View file

@ -552,11 +552,11 @@ TEMPLATE="$2"
# Apply user and setting. # Apply user and setting.
[[ -n "$RUNAS_USER" ]] && { [[ -n "$RUNAS_USER" ]] && {
SUDO="$(command -v sudo)" SETPRIV="$(command -v setpriv)"
if [[ -n "$SUDO" ]]; then if [[ -n "$SETPRIV" ]]; then
exec "$SUDO" -u "$RUNAS_USER" -- "$0" "${ORIG_ARGS[@]}" "$BASEDIR" "$TEMPLATE" || die "failed to exec to change user" exec "$SETPRIV" --keep-groups --reuid "$RUNAS_USER" --regid "$RUNAS_USER" -- "$0" "${ORIG_ARGS[@]}" "$BASEDIR" "$TEMPLATE" || die "failed to exec to change user"
else else
die "cannot exec to change user: sudo not found" die "cannot exec to change user: setpriv not found"
fi fi
} }