aboutsummaryrefslogtreecommitdiffstats
path: root/priv/templates/extended_bin
diff options
context:
space:
mode:
authorLuis Rascão <[email protected]>2017-10-17 21:50:48 +0100
committerGitHub <[email protected]>2017-10-17 21:50:48 +0100
commit2aba0053cb0241c04fad73e42fb903b95a0581ec (patch)
tree89db5287f1e9f7af5ccc87b3b4d2bda83ec32109 /priv/templates/extended_bin
parent1f857cb42df8211178066aa3047a9087757732de (diff)
parent42d06d64a55c6385c45dde7dc7c1ce959862df46 (diff)
downloadrelx-2aba0053cb0241c04fad73e42fb903b95a0581ec.tar.gz
relx-2aba0053cb0241c04fad73e42fb903b95a0581ec.tar.bz2
relx-2aba0053cb0241c04fad73e42fb903b95a0581ec.zip
Merge pull request #610 from juhlig/patch-1
vm.args check for name/sname parameter
Diffstat (limited to 'priv/templates/extended_bin')
-rwxr-xr-xpriv/templates/extended_bin75
1 files changed, 68 insertions, 7 deletions
diff --git a/priv/templates/extended_bin b/priv/templates/extended_bin
index cce1c25..0abf38b 100755
--- a/priv/templates/extended_bin
+++ b/priv/templates/extended_bin
@@ -294,16 +294,77 @@ 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 node.args
-NAME_ARG=$(egrep '^-s?name' "$VMARGS_PATH" || true)
+
+# 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" not found"
+ exit 3
+ }
+ if (system("test -r "file)) {
+ print file" not readable"
+ exit 3
+ }
+ while ((getline line<file)>0) {
+ if (line~/^-args_file +/) {
+ gsub(/^-args_file +| *$/, "", line)
+ if (!(line~/^\//)) {
+ print "relative path "line" encountered in "file
+ exit 4
+ }
+ if (line in files) {
+ print "circular reference to "line" encountered in "file
+ exit 5
+ }
+ files[line]=line
+ check_name(line)
+ }
+ else if (line~/^-s?name +/) {
+ if (name!="") {
+ print "\""line"\" parameter found in "file" but already specified as \""name"\""
+ exit 2
+ }
+ name=line
+ }
+ }
+}
+
+BEGIN {
+ split("", files)
+ name=""
+}
+
+{
+ files[FILENAME]=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")
+TMP_NAME_ARG_RC=$?
+case $TMP_NAME_ARG_RC in
+ 0) NAME_ARG="$TMP_NAME_ARG";;
+ *) echo "$TMP_NAME_ARG"
+ exit $TMP_NAME_ARG_RC;;
+esac
+unset TMP_NAME_ARG
+unset TMP_NAME_ARG_RC
+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}')"