Skip to content

Commit 93ab012

Browse files
committed
Change the ownership of the pid folder when using a sub-folder
This is an alternative to the fix made in 3b52909 which removed the chown call entirely. Prior to 3b52909, the ownership of $PID_FOLDER was always changed even when its value was /var/run. This was problematic as it could prevent other services from creating their pid folder or file. When a sub-folder is used, changing its ownership so that it’s owned by the user that will run the app is desirable as it limits access to the folder. Rather than removing the chown call entirely, this commit ensures that it only happens when a sub-folder is being used to hold the pid file. Closes gh-6532
1 parent 5a539ce commit 93ab012

File tree

1 file changed

+4
-0
lines changed
  • spring-boot-tools/spring-boot-loader-tools/src/main/resources/org/springframework/boot/loader/tools

1 file changed

+4
-0
lines changed

spring-boot-tools/spring-boot-loader-tools/src/main/resources/org/springframework/boot/loader/tools/launch.script

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ fi
106106
# Build the pid and log filenames
107107
if [[ "$identity" == "$init_script" ]] || [[ "$identity" == "$APP_NAME" ]]; then
108108
PID_FOLDER="$PID_FOLDER/${identity}"
109+
pid_subfolder=$PID_FOLDER
109110
fi
110111
pid_file="$PID_FOLDER/${identity}.pid"
111112
log_file="$LOG_FOLDER/$LOG_FILENAME"
@@ -143,6 +144,9 @@ do_start() {
143144
mkdir "$PID_FOLDER" &> /dev/null
144145
if [[ -n "$run_user" ]]; then
145146
checkPermissions || return $?
147+
if [[ -z "$pid_subfolder" ]]; then
148+
chown "$run_user" "$pid_subfolder"
149+
fi
146150
chown "$run_user" "$pid_file"
147151
chown "$run_user" "$log_file"
148152
if [ $USE_START_STOP_DAEMON = true ] && type start-stop-daemon > /dev/null 2>&1; then

0 commit comments

Comments
 (0)