Github user pwendell commented on a diff in the pull request:
https://github.com/apache/spark/pull/1845#discussion_r16323472
--- Diff: bin/utils.sh ---
@@ -17,9 +16,53 @@
# limitations under the License.
#
+# * ---------------------------------------------------- *
+# | Utility functions for launching Spark applications |
+# * ---------------------------------------------------- *
+
+# Parse the value of a config from a java properties file according to the
specifications in
+#
http://docs.oracle.com/javase/7/docs/api/java/util/Properties.html#load(java.io.Reader),
+# with the exception of the support for multi-line arguments. This accepts
the name of the
+# config as an argument, and expects the path of the property file to be
found in
+# PROPERTIES_FILE. The value is returned through JAVA_PROPERTY_VALUE.
+function parse_java_property() {
+ JAVA_PROPERTY_VALUE=$(\
+ grep "^[[:space:]]*$1" "$PROPERTIES_FILE" | \
+ head -n 1 | \
+ sed "s/^[[:space:]]*$1//g" | \
+ sed "s/^[[:space:]]*[:=]\{0,1\}//g" | \
+ sed "s/^[[:space:]]*//g" | \
+ sed "s/[[:space:]]*$//g"
+ )
+ export JAVA_PROPERTY_VALUE
+}
+
+# Properly split java options, dealing with whitespace, double quotes and
backslashes.
+# This accepts a string and returns the resulting list through
SPLIT_JAVA_OPTS.
+# For security reasons, this is isolated in its own function.
+function split_java_options() {
+ eval set -- "$1"
--- End diff --
Do we need to document the security concerns with this function? Basically,
we can't call this on user input except a script directly called by the user.
It might make sense to actually name this `split_java_options_insecure` or even
just `split_command_string_insecure` (similar to the naming in spark).
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]