-
Notifications
You must be signed in to change notification settings - Fork 1k
Make remsh work with quoted cookie #4509
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
Conversation
1bcf5b8
to
263cfcf
Compare
rel/overlay/bin/remsh
Outdated
@@ -49,10 +49,10 @@ NODE="${NODE:-$DEFAULT_NODE}" | |||
|
|||
# If present, extract cookie from ERL_FLAGS | |||
# This is used by the CouchDB Dockerfile and Helm chart | |||
COOKIE=$(echo "$ERL_FLAGS" | sed 's/^.*setcookie \([^ ][^ ]*\).*$/\1/g') | |||
COOKIE=$(echo "$ERL_FLAGS" | sed 's/^.*setcookie[ ]*\(['\''"]\)*\([^'\''"]*\)\1*.*$/\2/') |
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.
I was testing this before the code was updated.
#!/bin/bash
COOKIE=$(echo "$ERL_FLAGS" | sed -E '
s/.*-setcookie[ ]*["]([^"]*)["].*/\1/;
s/.*-setcookie[ ]*([^ ]*).*/\1/;
')
echo "COOKIE='${COOKIE}'"
ERL_FLAGS_CLEAN=$(echo "$ERL_FLAGS" | sed -E '
s/-setcookie[ ]*[^"]*.*["]//
s/-setcookie[ ]*[^ ]*//
s/-name[ ]*[^ ]*//
')
echo "ERL_FLAGS_CLEAN='${ERL_FLAGS_CLEAN}'"
bash-3.2$ ERL_FLAGS='ddd -setcookie "secret 123" -name node1@mydomain.com hello' ./test
COOKIE='secret 123'
ERL_FLAGS_CLEAN='ddd secret 123" hello'
bash-3.2$ micro test
bash-3.2$ ERL_FLAGS='ddd -setcookie "secret 123" -name node1@mydomain.com hello' ./test
COOKIE='secret 123'
ERL_FLAGS_CLEAN='ddd secret 123" hello'
bash-3.2$ ERL_FLAGS='ddd -setcookie "secret 123" -name node1@mydomain.com hello' ./test
COOKIE='secret 123'
ERL_FLAGS_CLEAN='ddd secret 123" hello'
bash-3.2$ micro test
bash-3.2$ ERL_FLAGS='ddd -setcookie "secret 123" -name node1@mydomain.com hello' ./test
COOKIE='secret 123'
ERL_FLAGS_CLEAN='ddd hello'
bash-3.2$ ERL_FLAGS='ddd -setcookie "secret 123"' ./test
COOKIE='secret 123'
ERL_FLAGS_CLEAN='ddd '
bash-3.2$ ERL_FLAGS='ddd -setcookie "secret" -name node1@mydomain.com hello' ./test
COOKIE='secret'
ERL_FLAGS_CLEAN='ddd hello'
bash-3.2$ ERL_FLAGS='ddd -setcookie "secret"' ./test
COOKIE='secret'
ERL_FLAGS_CLEAN='ddd '
bash-3.2$ ERL_FLAGS='ddd -setcookie secret -name node1@mydomain.com hello' ./test
COOKIE='secret'
ERL_FLAGS_CLEAN='ddd hello'
bash-3.2$ ERL_FLAGS='ddd -setcookie secret' ./test
COOKIE='secret'
ERL_FLAGS_CLEAN='ddd '
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.
sed -E
/ sed -r
is very powerful and helped me remove the if statement. Thank you!
f6be3b4
to
4b7c090
Compare
Is there a difference between
|
It looks like our oldest Linux CentOS 7 doesn't support
|
Allow space and other special characters in cookies. Test: First set the cookie in `vm.args`, then run the script below e.g.: `-setcookie 'a b\n\t\xd#{}()[]$&^!-=+?|//c\\d\\\e\\\\f'` or `-setcookie "a b\n\t\xd#{}()[]$&^!-=+?|//c\\d\\\e\\\\f"` ``` make release cd rel/couchdb ./bin/couchdb ./bin/remsh ```
4b7c090
to
81f2125
Compare
Changed them to |
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.
+1
ERL_FLAGS:
% export COUCHDB_COOKIE='a\t{}()[]$&^!-=+?|//c\\d\\\e\\\\f'
% export ERL_FLAGS="-setcookie ${COUCHDB_COOKIE}"
% ./bin/remsh
(remsh34975@127.0.0.1)1> erlang:get_cookie().
'a\t{}()[]$&^!-=+?|//c\\d\\\\e\\\\f'
vm.args:
-setcookie 'x b\n\t\xd#{}()[]$&^!-=+?|//c\\d\\\e\\\\f'
./bin/remsh
Erlang/OTP 24 [erts-12.3.2.9] [source] [64-bit] [smp:12:12] [ds:12:12:10] [async-threads:1] [jit]
Eshell V12.3.2.9 (abort with ^G)
(couchdb@127.0.0.1)1> erlang:get_cookie().
'x b\\n\\t\\xd#{}()[]$&^!-=+?|//c\\\\d\\\\\\e\\\\\\\\f'
Well done @jiahuili430. Thanks for nice tip about -r
@iilyak !
Overview
Allow space and other special characters in cookies.
Testing recommendations
First set the cookie in
vm.args
, then run the script below:e.g.:
-setcookie 'a b\n\t\xd#{}()[]$&^!-=+?|//c\\d\\\e\\\\f'
or
-setcookie "a b\n\t\xd#{}()[]$&^!-=+?|//c\\d\\\e\\\\f"
make release cd rel/couchdb ./bin/couchdb ./bin/remsh
Related Issues or Pull Requests
fix #4405
Checklist
rel/overlay/etc/default.ini
src/docs
folder