Skip to content

Commit 886b392

Browse files
committed
Merge branch '1.5.x'
2 parents 187c4d7 + 9b8cb9a commit 886b392

File tree

5 files changed

+78
-4
lines changed

5 files changed

+78
-4
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
source ./test-functions.sh
2+
install_service
3+
4+
chmod o+w /var/log
5+
6+
useradd phil
7+
mkdir /phil-files
8+
chown phil /phil-files
9+
10+
useradd andy
11+
chown andy /test-service/spring-boot-app.jar
12+
13+
start_service
14+
stop_service
15+
16+
su - andy -c "ln -s -f /phil-files /var/log/spring-boot-app.log"
17+
18+
start_service
19+
20+
ls -ld /phil-files
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
source ./test-functions.sh
2+
install_service
3+
4+
useradd phil
5+
mkdir /phil-files
6+
chown phil /phil-files
7+
8+
useradd andy
9+
chown andy /test-service/spring-boot-app.jar
10+
11+
start_service
12+
stop_service
13+
14+
su - andy -c "ln -s /phil-files /var/run/spring-boot-app/spring-boot-app.pid"
15+
16+
start_service
17+
18+
ls -ld /phil-files
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
source ./test-functions.sh
2+
install_service
3+
4+
chmod o+w /var/run
5+
6+
useradd phil
7+
mkdir /phil-files
8+
chown phil /phil-files
9+
10+
useradd andy
11+
chown andy /test-service/spring-boot-app.jar
12+
13+
su - andy -c "ln -s -f /phil-files /var/run/spring-boot-app"
14+
15+
start_service
16+
17+
ls -ld /phil-files

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -154,12 +154,12 @@ start() {
154154
do_start() {
155155
working_dir=$(dirname "$jarfile")
156156
pushd "$working_dir" > /dev/null
157-
mkdir -p "$PID_FOLDER" &> /dev/null
157+
if [[ ! -e "$PID_FOLDER" ]]; then
158+
mkdir -p "$PID_FOLDER" &> /dev/null
159+
chown "$run_user" "$PID_FOLDER"
160+
fi
158161
if [[ -n "$run_user" ]]; then
159162
checkPermissions || return $?
160-
chown "$run_user" "$PID_FOLDER"
161-
chown "$run_user" "$pid_file"
162-
chown "$run_user" "$log_file"
163163
if [ $USE_START_STOP_DAEMON = true ] && type start-stop-daemon > /dev/null 2>&1; then
164164
start-stop-daemon --start --quiet \
165165
--chuid "$run_user" \

spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/java/org/springframework/boot/launchscript/SysVinitLaunchScriptIT.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,25 @@ public void launchWithRelativePidFolder() throws Exception {
226226
coloredString(AnsiColor.GREEN, "Stopped [" + extractPid(output) + "]"));
227227
}
228228

229+
@Test
230+
public void pidFolderOwnership() throws Exception {
231+
String output = doTest("pid-folder-ownership.sh");
232+
System.err.println(output);
233+
assertThat(output).contains("phil root");
234+
}
235+
236+
@Test
237+
public void pidFileOwnership() throws Exception {
238+
String output = doTest("pid-file-ownership.sh");
239+
assertThat(output).contains("phil root");
240+
}
241+
242+
@Test
243+
public void logFileOwnership() throws Exception {
244+
String output = doTest("log-file-ownership.sh");
245+
assertThat(output).contains("phil root");
246+
}
247+
229248
@Test
230249
public void launchWithRelativeLogFolder() throws Exception {
231250
String output = doTest("launch-with-relative-log-folder.sh");

0 commit comments

Comments
 (0)