You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ji...@apache.org on 2025/05/12 16:38:57 UTC
(couchdb) branch fix-remsh-cookie-reading updated (1b1191f21 -> 2e8616131)
This is an automated email from the ASF dual-hosted git repository.
jiahuili430 pushed a change to branch fix-remsh-cookie-reading
in repository https://gitbox.apache.org/repos/asf/couchdb.git
discard 1b1191f21 Extend `remsh` to read cookie from various sources
new 2e8616131 Extend `remsh` to read cookie from various sources
This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version. This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:
* -- * -- B -- O -- O -- O (1b1191f21)
\
N -- N -- N refs/heads/fix-remsh-cookie-reading (2e8616131)
You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.
Any revisions marked "omit" are not gone; other references still
refer to them. Any revisions marked "discard" are gone forever.
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
(couchdb) 01/01: Extend `remsh` to read cookie from various sources
Posted by ji...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
jiahuili430 pushed a commit to branch fix-remsh-cookie-reading
in repository https://gitbox.apache.org/repos/asf/couchdb.git
commit 2e861613116e09a7b4c9b66ae47cc0778c56eaf8
Author: Jiahui Li <li...@gmail.com>
AuthorDate: Sun May 11 23:42:24 2025 -0500
Extend `remsh` to read cookie from various sources
We can set cookies using `./dev/run --erlang-cookie=crumbles` or
`vm.args`: `-setcookie crumbles`.
If neither of them is set or we set the cookie in both places, then
the Erlang node will read the cookie from `~/.erlang.cookie`.
Add this mechanism to the `remsh` script to extend flexibility.
Related PR: https://github.com/apache/couchdb/pull/5531
---
dev/remsh | 48 ++++++++++++++++++++++++++++++++++++++----------
1 file changed, 38 insertions(+), 10 deletions(-)
diff --git a/dev/remsh b/dev/remsh
index 347a799d0..2630bdb96 100755
--- a/dev/remsh
+++ b/dev/remsh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
@@ -11,18 +11,46 @@
# License for the specific language governing permissions and limitations under
# the License.
-if [ -z $NODE ]; then
- if [ -z $1 ]; then
- NODE=1
- else
- NODE=$1
- fi
+# Cookies can be set in 3 different ways:
+# - Use `dev/run` script to pass cookies:
+# `dev/run --erlang-cookie=crumbles`
+# - Use `vm.args` config file in rel/overlay/etc to set cookies:
+# `-setcookie crumbles`
+# - Use cookies from the `.erlang.cookie` file in the user's home directory.
+
+# NOTE: If more than 2 cookies are passed to node, node will ignore them
+# and use the default cookies from `~/.erlang.cookie`.
+
+if [ -z "$NODE" ]; then
+ if [ -z "$1" ]; then
+ NODE=1
+ else
+ NODE=$1
+ fi
fi
-if [ -z $HOST ]; then
- HOST="127.0.0.1"
+if [ -z "$HOST" ]; then
+ HOST="127.0.0.1"
fi
NAME="remsh$$@$HOST"
NODE="node$NODE@$HOST"
-erl -name $NAME -remsh $NODE -hidden
+
+COOKIE_PY=$(ps ax |
+ grep -E "dev/run .* --erlang-cookie=" |
+ sed -n "s/.*--erlang-cookie=\([a-zA-Z0-9!@$%^&*()_+-=(){}<>,;.:?/|]*\).*/\1/p")
+
+DIR="$(
+ cd "${0%/*}" 2>/dev/null || exit
+ echo "$PWD"/../rel/overlay/etc/
+)"
+COOKIE_VM=$(grep "^-setcookie" "$DIR"/vm.args |
+ sed -n "s/-setcookie *\([a-zA-Z0-9!@$%^&*()_+-=(){}<>,;.:?/|]*\).*/\1/p")
+
+if [[ -n "$COOKIE_PY" && -z "$COOKIE_VM" ]]; then
+ erl -name "$NAME" -remsh "$NODE" -hidden -setcookie "$COOKIE_PY"
+elif [[ -z "$COOKIE_PY" && $(echo "$COOKIE_VM" | wc -l) -eq 1 ]]; then
+ erl -name "$NAME" -remsh "$NODE" -hidden -setcookie "$COOKIE_VM"
+else
+ erl -name "$NAME" -remsh "$NODE" -hidden
+fi