aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Uhlig <[email protected]>2017-10-16 13:39:44 +0200
committerGitHub <[email protected]>2017-10-16 13:39:44 +0200
commitc0e3e93a01da2d8659bb87e80b695cc24ccd40c2 (patch)
tree4e60ae97a8a425a5279c5c215bc301fc1fc12f80
parente85edb20ee6badf512b7b311da401e8fa6b618f8 (diff)
downloadrelx-c0e3e93a01da2d8659bb87e80b695cc24ccd40c2.tar.gz
relx-c0e3e93a01da2d8659bb87e80b695cc24ccd40c2.tar.bz2
relx-c0e3e93a01da2d8659bb87e80b695cc24ccd40c2.zip
Augmented vm.args checks
vm.args and referenced args_files will now be checked for: - non-existing -args_files - circular dependencies between -args_files - relative paths in -args_files - multiple/mixed occurences of -name and -sname parameters - missing -name or -sname parameters
-rwxr-xr-xpriv/templates/extended_bin64
1 files changed, 52 insertions, 12 deletions
diff --git a/priv/templates/extended_bin b/priv/templates/extended_bin
index ac9f0a5..3822205 100755
--- a/priv/templates/extended_bin
+++ b/priv/templates/extended_bin
@@ -294,30 +294,70 @@ export LD_LIBRARY_PATH="$ERTS_DIR/lib:$LD_LIBRARY_PATH"
ERTS_LIB_DIR="$(dirname "$ERTS_DIR")/lib"
VMARGS_PATH=$(add_path vm.args $VMARGS_PATH)
-# Extract the target node name from vm.args or referenced args_files
-NAME_ARG=$(awk 'function find_name(file) {
+
+# Check vm.args and other files referenced via -args_file parameters for:
+# - nonexisting -args_files
+# - circular dependencies of -args_files
+# - relative paths in -args_file parameters
+# - multiple/mixed occurences of -name and -sname parameters
+# - missing -name or -sname parameters
+# If all checks pass, extract the target node name
+set +e
+TMP_NAME_ARG=$(awk 'function check_name(file)
+{
+ if (system("test -f "file)) {
+ print "File \""file"\" not found"
+ exit 1
+ }
while ((getline line<file)>0) {
if (line~/^-args_file +/) {
- gsub(/^-args_file +/, "", line)
- find_name(line)
+ gsub(/^-args_file +| *$/, "", line)
+ if (!(line~/^\//)) {
+ print "Relative path \""line"\" encountered in "file
+ exit 1
+ }
+ if (line in files) {
+ print "Circular reference to \""line"\" encountered in "file
+ exit 1
+ }
+ files[line]=line
+ check_name(line)
}
else if (line~/^-s?name +/) {
- print line
- exit
+ if (name!="") {
+ print "\""line"\" found in "file" but specified before as \""name"\""
+ exit 1
+ }
+ name=line
}
}
}
+
+BEGIN {
+ split("", files)
+ name=""
+}
+
{
- find_name(FILENAME)
+ check_name(FILENAME)
+ if (name=="") {
+ print "Need to have exactly one of either -name or -sname parameters but none found"
+ exit 1
+ }
+ print name
+ exit 0
}' "$VMARGS_PATH")
+case $? in
+ 0) NAME_ARG="$TMP_NAME_ARG";;
+ *) echo "$TMP_NAME_ARG"
+ exit 1;;
+esac
+unset TMP_NAME_ARG
+set -e
+
# Perform replacement of variables in ${NAME_ARG}
NAME_ARG=$(eval echo "${NAME_ARG}")
-if [ -z "$NAME_ARG" ]; then
- echo "vm.args needs to have either -name or -sname parameter."
- exit 1
-fi
-
# Extract the name type and name from the NAME_ARG for REMSH
NAME_TYPE="$(echo "$NAME_ARG" | awk '{print $1}')"
NAME="$(echo "$NAME_ARG" | awk '{print $2}')"