-
Notifications
You must be signed in to change notification settings - Fork 14k
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
MINOR: Double Quote CLASSPATH to prevent shell glob expansion. #8191
Conversation
In the event that the CLASSPATH does not have an ending ":", the shell can expand the CLASSPATH globs to be space-separated list of paths/jars, which is not how the JVM CLI accepts arguments to -cp switch. So double quote the variable to prevent pattern expansion, and pass the glob pattern directly to the JVM.
Thanks for the PR. Can you include a description of how this was validated? |
I'll attempt to highlight the problem, and the fix, and provide a further justification on the fix. First I added an echo before the exec to highlight what the issue is:
Now we run it:
It comes down to the fact that
Any of these blocks may be appending class paths. Which is me trying to address the reason why this isn't an issue currently on AK-kafka. The main point is, there can be cases/deployments where there the path is no longer appending paths, and just contains I now make the change by quoting
Class path is now no longer expanded (
The JVM does the glob expansion itself from Further justification: This is a common shell scripting bug folks run into, and hence why the shellcheck tool has an entire lint/page about this very thing: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the explanation. LGTM.
Verified that kafka-server-start and zookeeper-server-start still work with this change, merged to trunk. |
In the event that the CLASSPATH does not have an ending ":", the shell
can expand the CLASSPATH globs to be space-separated list of paths/jars,
which is not how the JVM CLI accepts arguments to -cp switch. So
double quote the variable to prevent pattern expansion, and pass the
glob pattern directly to the JVM.
Committer Checklist (excluded from commit message)