Ensure run user actually exists

Update `launch.script` so that the `run_user` variable is only set when
the user actually exists. Prior to this commit, if the jar file was
owned by a non-existing user the startup script could fail.

Fixes gh-29370
pull/29441/head
Phillip Webb 3 years ago
parent 7c16668bf3
commit 9cf55808fb

@ -128,6 +128,9 @@ log_file="$LOG_FOLDER/$LOG_FILENAME"
# shellcheck disable=SC2012
[[ $(id -u) == "0" ]] && run_user=$(ls -ld "$jarfile" | awk '{print $3}')
# Ensure the user actually exists
id -u "$run_user" &> /dev/null || unset run_user
# Run as user specified in RUN_AS_USER
if [[ -n "$RUN_AS_USER" ]]; then
if ! [[ "$action" =~ ^(status|run)$ ]]; then

Loading…
Cancel
Save