diff options
author | Will Holley <willholley@gmail.com> | 2019-12-11 12:43:41 +0000 |
---|---|---|
committer | Will Holley <willholley@gmail.com> | 2019-12-16 07:51:41 +0000 |
commit | 4fd0f2644a1d755bae8b8f8b85bae0e8e13cddc4 (patch) | |
tree | 907f1d0077027700533cb7c0d0b2b7cdcc27f2a1 | |
parent | 18b97f7c44d8143ea6231f2547ae20d480becdb5 (diff) | |
download | couchdb-4fd0f2644a1d755bae8b8f8b85bae0e8e13cddc4.tar.gz |
Sanitize `ERL_FLAGS` in remsh
If an environment uses `ERL_FLAGS` to configure CouchDB it can
conflict with the parameters passed to `erl` in `remsh`. This was
observed in a containerized CouchDB cluster, as the CouchDB
Dockerfile uses `ERL_FLAGS` to set the node name and cookie, as does
the Helm chart.
When running `remsh` in these containers, additional
`-name` and `-setcookie` parameters were silently added to
the `erl` invocation, preventing the shell from connecting to the
CouchDB node.
This commit scrubs any `-name` or `-setcookie` flags from ERL_FLAGS
before invoking erl.
-rwxr-xr-x | rel/overlay/bin/remsh | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/rel/overlay/bin/remsh b/rel/overlay/bin/remsh index 963c16a10..2d28a8c85 100755 --- a/rel/overlay/bin/remsh +++ b/rel/overlay/bin/remsh @@ -71,6 +71,10 @@ if [ ! -z "$VERBOSE" ]; then set -x fi -exec "$BINDIR/erl" -boot "$ROOTDIR/releases/$APP_VSN/start_clean" \ +# If present, strip -name or -setcookie from ERL_FLAGS +# to avoid conflicts with the cli parameters +ERL_FLAGS_CLEAN=$(echo "$ERL_FLAGS" | sed 's/-setcookie \([^ ][^ ]*\)//g' | sed 's/-name \([^ ][^ ]*\)//g') + +exec env ERL_FLAGS="$ERL_FLAGS_CLEAN" "$BINDIR/erl" -boot "$ROOTDIR/releases/$APP_VSN/start_clean" \ -name remsh$$@$LHOST -remsh $NODE -hidden -setcookie $COOKIE \ "$@" |