Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JAVA_OPTS needs to be escaped #73

Closed
ash211 opened this issue May 20, 2016 · 6 comments
Closed

JAVA_OPTS needs to be escaped #73

ash211 opened this issue May 20, 2016 · 6 comments

Comments

@ash211
Copy link
Contributor

ash211 commented May 20, 2016

Especially important because Java convention for separating http.nonProxyHosts parameters is with pipes.

Setting JAVA_OPTS to this would cause you very bad times: -Dhttp.nonProxyHosts=127.0.0.1|sudo\ rm\ -rf\ /opt

I think https://github.com/palantir/gradle-java-distribution/blob/8242c733c6f0ea5361bf9d6a4c59195d2073806e/gradlew#L161 needs to quote those parameters with double-quotes

@markelliot
Copy link
Contributor

gradlew doesn't run in the target environment, it's part of the gradlew distribution.

@ash211
Copy link
Contributor Author

ash211 commented May 24, 2016

Then the bug must be elsewhere. Repro steps:

  1. Set JAVA_OPTS to -Dhello=hi|touch my-file-here
  2. Restart the service
  3. Observe that my-file-here is created in the Java service's working directory

I have a service named alchemist-foundry that has a shell script located at service/bin/alchemist-foundry that looks rather similar to the gradlew script here, though with a different header:

##############################################################################
##
##  alchemist-foundry start up script for UN*X
##
##############################################################################

At the bottom that script contains these lines which seem to be where the bug is:

# Split up the JVM_OPTS And ALCHEMIST_FOUNDRY_OPTS values into an array, following the shell quoting and substitution rules
function splitJvmOpts() {
    JVM_OPTS=("$@")
}
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $ALCHEMIST_FOUNDRY_OPTS

This must be used as part of the Gradle default start script task defined at https://github.com/palantir/gradle-java-distribution#packaging

@markelliot
Copy link
Contributor

Ok, so it’s a bug in Gradle’s generated shell script. We could look at moving away from Gradle’s generated shell script, we probably want to do some things differently than it does anyway.

@ash211
Copy link
Contributor Author

ash211 commented May 24, 2016

@markelliot
Copy link
Contributor

@uschi2000 is tracking this one

@markelliot
Copy link
Contributor

Resolved in #85. We have another couple of updates to make before releasing, but this has now been addressed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants