From 4c65e5e704cfab3160ea7276304f307c993bddf9 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Fri, 13 May 2016 09:43:08 +0100 Subject: [PATCH] Always handle quoted arguments correctly in the launch script MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously, arguments passed to the script were handled in one way if a service was being started using start-stop-daemon and in another way if start-stop-daemon wasn’t available or the application is being launched in run mode. This meant that quoted arguments were only handled correctly when the application was being started using start-stop-daemon. This commit updates the launch script so that argument handling is the same across all three different way that the application can be launched. Closes gh-5942 --- .../springframework/boot/loader/tools/launch.script | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/spring-boot-tools/spring-boot-loader-tools/src/main/resources/org/springframework/boot/loader/tools/launch.script b/spring-boot-tools/spring-boot-loader-tools/src/main/resources/org/springframework/boot/loader/tools/launch.script index a35438499d..fd4465f136 100755 --- a/spring-boot-tools/spring-boot-loader-tools/src/main/resources/org/springframework/boot/loader/tools/launch.script +++ b/spring-boot-tools/spring-boot-loader-tools/src/main/resources/org/springframework/boot/loader/tools/launch.script @@ -126,8 +126,7 @@ else exit 1 fi -# Build actual command to execute -command="$javaexe -Dsun.misc.URLClassPath.disableJarChecking=true $JAVA_OPTS -jar $jarfile $RUN_ARGS $*" +arguments=(-Dsun.misc.URLClassPath.disableJarChecking=true $JAVA_OPTS -jar $jarfile $RUN_ARGS "$@") # Action functions start() { @@ -148,7 +147,6 @@ do_start() { chown "$run_user" "$pid_file" chown "$run_user" "$log_file" if [ $USE_START_STOP_DAEMON = true ] && type start-stop-daemon > /dev/null 2>&1; then - arguments=(-Dsun.misc.URLClassPath.disableJarChecking=true $JAVA_OPTS -jar $jarfile $RUN_ARGS "$@") start-stop-daemon --start --quiet \ --chuid "$run_user" \ --name "$identity" \ @@ -160,12 +158,12 @@ do_start() { >> "$log_file" 2>&1 await_file "$pid_file" else - su -s /bin/sh -c "$command >> \"$log_file\" 2>&1 & echo \$!" "$run_user" > "$pid_file" + su -s /bin/sh -c "$javaexe $(printf "\"%s\" " "${arguments[@]}") >> \"$log_file\" 2>&1 & echo \$!" "$run_user" > "$pid_file" fi pid=$(cat "$pid_file") else checkPermissions || return $? - $command >> "$log_file" 2>&1 & + "$javaexe" "${arguments[@]}" >> "$log_file" 2>&1 & pid=$! disown $pid echo "$pid" > "$pid_file" @@ -215,7 +213,7 @@ status() { run() { pushd "$(dirname "$jarfile")" > /dev/null - $command + "$javaexe" "${arguments[@]}" result=$? popd > /dev/null return "$result"