Use sudo is available, fall back to su.
This commit is contained in:
parent
3e5a3e0e85
commit
95b204be05
1 changed files with 10 additions and 2 deletions
12
lumberjack
12
lumberjack
|
|
@ -541,8 +541,16 @@ TEMPLATE="$2"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Apply user and setting.
|
# Apply user and setting.
|
||||||
# shellcheck disable=SC2093
|
[[ -n "$RUNAS_USER" ]] && {
|
||||||
[[ -n "$RUNAS_USER" ]] && { exec -a "su" /bin/su - "$RUNAS_USER" -- "$0" "${ORIG_ARGS[@]}" "$BASEDIR" "$TEMPLATE" || die "failed to exec to change user"; }
|
SUDO="$(command -v sudo)"
|
||||||
|
SU="$(command -v su)"
|
||||||
|
if [[ -n "$SUDO" ]]; then
|
||||||
|
exec "$SUDO" -b -u "$RUNAS_USER" -- "$0" "${ORIG_ARGS[@]}" "$BASEDIR" "$TEMPLATE"
|
||||||
|
else
|
||||||
|
exec -a "su" "$SU" - "$RUNAS_USER" -- "$0" "${ORIG_ARGS[@]}" "$BASEDIR" "$TEMPLATE"
|
||||||
|
fi
|
||||||
|
die "failed to exec to change user"
|
||||||
|
}
|
||||||
|
|
||||||
# If input is to be a pipe/FIFO, open it.
|
# If input is to be a pipe/FIFO, open it.
|
||||||
# Note: The fifo must be opened in read-write mode in order to avoid blocking.
|
# Note: The fifo must be opened in read-write mode in order to avoid blocking.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue