You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by va...@apache.org on 2022/04/27 20:43:11 UTC

[couchdb-pkg] branch monstermunch created (now cb9c142)

This is an automated email from the ASF dual-hosted git repository.

vatamane pushed a change to branch monstermunch
in repository https://gitbox.apache.org/repos/asf/couchdb-pkg.git


      at cb9c142  Fix cookie preseeding

This branch includes the following new commits:

     new ec2f705  Bind epmd and distribution port to loopback interface only for standalone
     new ac7b530  Don't allow 'monster' as cookie value in debconf
     new 9be16cc  tighten file permissions for vm.args
     new bf96939  feat: patch rpmspec to prompt for cookie value
     new b8570f8  Merge pull request #1 from rnewson/rpm-cookie-nom
     new c230bc9  On RPM upgrade prompt for cookie only if previously set "monster"
     new cb9c142  Fix cookie preseeding

The 7 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.



[couchdb-pkg] 01/07: Bind epmd and distribution port to loopback interface only for standalone

Posted by va...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

vatamane pushed a commit to branch monstermunch
in repository https://gitbox.apache.org/repos/asf/couchdb-pkg.git

commit ec2f705626fbb48ac6f87f8dfcbb8b40324f2102
Author: Robert Newson <rn...@apache.org>
AuthorDate: Tue Feb 8 16:19:40 2022 +0000

    Bind epmd and distribution port to loopback interface only for standalone
---
 debian/couchdb.default  | 14 ++++++++++++++
 debian/couchdb.init     |  4 ++++
 debian/couchdb.postinst | 17 +++++++++++++++++
 debian/couchdb.service  |  1 +
 4 files changed, 36 insertions(+)

diff --git a/debian/couchdb.default b/debian/couchdb.default
new file mode 100644
index 0000000..6deb316
--- /dev/null
+++ b/debian/couchdb.default
@@ -0,0 +1,14 @@
+#!/bin/sh
+# 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
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations under
+# the License.
+
+ERL_EPMD_ADDRESS=127.0.0.1
diff --git a/debian/couchdb.init b/debian/couchdb.init
index 34aa47f..2eedb91 100644
--- a/debian/couchdb.init
+++ b/debian/couchdb.init
@@ -39,6 +39,10 @@ DAEMON=/opt/couchdb/bin/couchdb
 START_ARGS="--chuid couchdb:couchdb --chdir /opt/couchdb --background"
 STOP_ARGS="--pid $PID"
 
+if [ -r /etc/default/${NAME} ]; then
+    . /etc/default/${NAME}
+fi
+
 do_usage() {
     echo "Usage: couchdb {start|stop|status|restart|try-restart|force-reload}" >&2
 }
diff --git a/debian/couchdb.postinst b/debian/couchdb.postinst
index b9facfd..8ee939b 100644
--- a/debian/couchdb.postinst
+++ b/debian/couchdb.postinst
@@ -157,6 +157,11 @@ case $1 in
       false
     fi
 
+    # set inet_dist_use_interface default if not present
+    if ! grep -q '^-kernel inet_dist_use_interface' /opt/couchdb/etc/vm.args; then
+        echo "-kernel inet_dist_use_interface '{127,0,0,1}'" >> /opt/couchdb/etc/vm.args
+    fi
+
     case $mode in
       none)
       ;;
@@ -166,6 +171,12 @@ case $1 in
         if ! setadminpass; then
           password_error="yes"
         fi
+
+        # Bind distribution port to loopback interface only
+        sed -i "s/^-kernel inet_dist_use_interface '{0,0,0,0}'$/-kernel inet_dist_use_interface '{127,0,0,1}'/" /opt/couchdb/etc/vm.args
+
+        # Bind EPMD to loopback interface
+        sed -i "s/^ERL_EPMD_ADDRESS=$/ERL_EPMD_ADDRESS=127.0.0.1/" /etc/default/couchdb
       ;;
       clustered)
         db_get couchdb/nodename && nodename="$RET"
@@ -179,6 +190,12 @@ case $1 in
         if ! setadminpass; then
           password_error="yes"
         fi
+
+        # Unbind distribution port from lookback interface only
+        sed -i "s/^-kernel inet_dist_use_interface '{127,0,0,1}'$/-kernel inet_dist_use_interface '{0,0,0,0}'/" /opt/couchdb/etc/vm.args
+
+        # Unbind EPMD from loopback interface
+        sed -i "s/^ERL_EPMD_ADDRESS=127.0.0.1$/ERL_EPMD_ADDRESS=/" /etc/default/couchdb
       ;;
       *)
         echo "incomprehensible couchdb mode '$mode'!" 1>&2
diff --git a/debian/couchdb.service b/debian/couchdb.service
index beb1c85..52cbd8c 100644
--- a/debian/couchdb.service
+++ b/debian/couchdb.service
@@ -4,6 +4,7 @@ Wants=network-online.target
 After=network-online.target
 
 [Service]
+EnvironmentFile=-/etc/default/couchdb
 RuntimeDirectory=couchdb
 User=couchdb
 Group=couchdb


[couchdb-pkg] 02/07: Don't allow 'monster' as cookie value in debconf

Posted by va...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

vatamane pushed a commit to branch monstermunch
in repository https://gitbox.apache.org/repos/asf/couchdb-pkg.git

commit ac7b530a4759aaf44ada904776b651d4ba0aa6f4
Author: Robert Newson <rn...@apache.org>
AuthorDate: Thu Feb 24 14:01:36 2022 +0000

    Don't allow 'monster' as cookie value in debconf
---
 README-SNAP.md           |  2 +-
 debian/couchdb.config    | 27 +++++++++++++++++++++------
 debian/couchdb.postinst  | 13 +++++++++++--
 debian/couchdb.templates | 11 ++++++++++-
 4 files changed, 43 insertions(+), 10 deletions(-)

diff --git a/README-SNAP.md b/README-SNAP.md
index 0eed800..3ee137c 100644
--- a/README-SNAP.md
+++ b/README-SNAP.md
@@ -249,7 +249,7 @@ In the very rare case you need to connect to the couchdb server, a remsh script
 provided. You need to specify both the name of the server and the cookie, even if
 you are using the default. 
 ```bash
-/snap/bin/couchdb.remsh -n couchdb@localhost -c monster
+/snap/bin/couchdb.remsh -n couchdb@localhost -c $COOKIE
 ```
 # Building this snap <a name="building"></a>
 
diff --git a/debian/couchdb.config b/debian/couchdb.config
index 7eb301d..df9518c 100755
--- a/debian/couchdb.config
+++ b/debian/couchdb.config
@@ -62,13 +62,29 @@ promptbind() {
   done
 }
 
+promptcookie() {
+    while :; do
+        RET=""
+        db_input high couchdb/cookie || true
+        db_go
+        db_get couchdb/cookie
+        if [ -z "$RET" ]; then
+            db_input critical couchdb/no_cookie
+            db_fset couchdb/cookie seen false
+        elif [ "$RET" = "monster" ]; then
+            db_input critical couchdb/no_cookie_monsters
+            db_fset couchdb/cookie seen false
+        else
+            break
+        fi
+    done
+}
+
 # if they exist, make current settings debconf's defaults
 if [ -e /opt/couchdb/etc/vm.args ] ; then
   cookie="$(grep '^-setcookie' /opt/couchdb/etc/vm.args | cut -d ' ' -f 2 | stripwhitespace)"
   nodename="$(grep '^-name' /opt/couchdb/etc/vm.args | cut -d ' ' -f 2 | stripwhitespace)"
-  if [ "${cookie}" != "monster" ]; then 
-    db_set couchdb/cookie "${cookie}"
-  fi
+  db_set couchdb/cookie "${cookie}"
   if [ "${nodename}" != "couchdb@127.0.0.1" ]; then
     db_set couchdb/nodename "${nodename}"
   fi
@@ -102,7 +118,7 @@ none)
   ;;
 standalone)
   db_fset couchdb/nodename seen false
-  db_fset couchdb/cookie seen false
+  promptcookie
   promptbind w.x.y.z
   # still prompt for password
   promptpass
@@ -113,8 +129,7 @@ clustered)
   fi
   db_input high couchdb/nodename || true
   db_go
-  db_input high couchdb/cookie || true
-  db_go
+  promptcookie
   # do not allow binding to loopback in clustered mode
   promptbind 127.0.0.1
   promptpass
diff --git a/debian/couchdb.postinst b/debian/couchdb.postinst
index 8ee939b..efc4659 100644
--- a/debian/couchdb.postinst
+++ b/debian/couchdb.postinst
@@ -157,6 +157,17 @@ case $1 in
       false
     fi
 
+    # Set the cookie
+    db_get couchdb/cookie && cookie="$RET"
+
+    # change existing setcookie line if present
+    sed -i "s/^[# ]*-setcookie.*$/-setcookie ${cookie}/" /opt/couchdb/etc/vm.args
+
+    # add setcookie line if not present
+    if ! grep -q '^-setcookie' /opt/couchdb/etc/vm.args; then
+        echo "-setcookie ${cookie}" >> /opt/couchdb/etc/vm.args
+    fi
+
     # set inet_dist_use_interface default if not present
     if ! grep -q '^-kernel inet_dist_use_interface' /opt/couchdb/etc/vm.args; then
         echo "-kernel inet_dist_use_interface '{127,0,0,1}'" >> /opt/couchdb/etc/vm.args
@@ -180,10 +191,8 @@ case $1 in
       ;;
       clustered)
         db_get couchdb/nodename && nodename="$RET"
-        db_get couchdb/cookie && cookie="$RET"
 
         sed -i "s/^-name .*$/-name ${nodename}/" /opt/couchdb/etc/vm.args
-        sed -i "s/^-setcookie .*$/-setcookie ${cookie}/" /opt/couchdb/etc/vm.args
 
         setbindaddress
 
diff --git a/debian/couchdb.templates b/debian/couchdb.templates
index 3acdccd..336df16 100644
--- a/debian/couchdb.templates
+++ b/debian/couchdb.templates
@@ -37,7 +37,6 @@ _Description: CouchDB Erlang node name:
 
 Template: couchdb/cookie
 Type: string
-Default: monster
 _Description: CouchDB Erlang magic cookie:
  A CouchDB node has an Erlang magic cookie value set at startup.
  .
@@ -104,3 +103,13 @@ _Description: Remove all CouchDB databases?
  The /var/lib/couchdb directory containing all CouchDB databases will
  be removed. This will also clear the stored node name for this machine,
  and remove the couchdb user and group.
+
+Template: couchdb/no_cookie_monsters
+Type: error
+_Description: Cookie input error
+ The Erlang cookie cannot be set to 'monster'. Please try again.
+
+Template: couchdb/no_cookie
+Type: error
+_Description: Cookie input error
+ The Erlang cookie cannot be empty. Please try again.


[couchdb-pkg] 04/07: feat: patch rpmspec to prompt for cookie value

Posted by va...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

vatamane pushed a commit to branch monstermunch
in repository https://gitbox.apache.org/repos/asf/couchdb-pkg.git

commit bf969393fb1758f35ac5c2d96faa3913a8b9767c
Author: diannasoreil <mo...@fastmail.com>
AuthorDate: Wed Apr 13 17:24:59 2022 +0200

    feat: patch rpmspec to prompt for cookie value
---
 rpm/SPECS/couchdb.spec.in | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/rpm/SPECS/couchdb.spec.in b/rpm/SPECS/couchdb.spec.in
index 990d8b8..bdaa4f7 100644
--- a/rpm/SPECS/couchdb.spec.in
+++ b/rpm/SPECS/couchdb.spec.in
@@ -144,6 +144,12 @@ if ! /usr/bin/getent passwd couchdb > /dev/null; then /usr/sbin/adduser \
 %{__ln_s} -f -T /var/log/%{name} %{buildroot}/opt/%{name}/var/log/%{name}
 
 %post
+echo "Please enter a cookie value for this installation: " >/dev/tty
+if exec </dev/tty; then
+  read cookie;
+fi
+echo "Writing $cookie to vm.args..."
+%{__sed} -i "s/^[# ]*-setcookie.*$/-setcookie ${cookie}/" /opt/%{name}/etc/vm.args
 %{__chown} -R couchdb:couchdb /opt/%{name}
 %{__chmod} a+x /opt/%{name}/bin/*
 %if 0%{?fedora} || 0%{?rhel} >= 7


[couchdb-pkg] 06/07: On RPM upgrade prompt for cookie only if previously set "monster"

Posted by va...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

vatamane pushed a commit to branch monstermunch
in repository https://gitbox.apache.org/repos/asf/couchdb-pkg.git

commit c230bc9eadbf510b2e8b97ab5dbb22e55b9d80f4
Author: Nick Vatamaniuc <va...@gmail.com>
AuthorDate: Mon Apr 18 14:56:18 2022 -0400

    On RPM upgrade prompt for cookie only if previously set "monster"
---
 rpm/SPECS/couchdb.spec.in | 19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/rpm/SPECS/couchdb.spec.in b/rpm/SPECS/couchdb.spec.in
index bdaa4f7..9a3749f 100644
--- a/rpm/SPECS/couchdb.spec.in
+++ b/rpm/SPECS/couchdb.spec.in
@@ -144,12 +144,21 @@ if ! /usr/bin/getent passwd couchdb > /dev/null; then /usr/sbin/adduser \
 %{__ln_s} -f -T /var/log/%{name} %{buildroot}/opt/%{name}/var/log/%{name}
 
 %post
-echo "Please enter a cookie value for this installation: " >/dev/tty
-if exec </dev/tty; then
-  read cookie;
+if %{__grep} -q "^-setcookie monster$" /opt/%{name}/etc/vm.args; then
+  echo "Please enter a cookie value for this installation: " >/dev/tty
+  if exec </dev/tty; then
+    read cookie;
+  fi
+  echo "Writing $cookie to vm.args..."
+  %{__sed} -i "s/^-setcookie monster.*$/-setcookie ${cookie}/" /opt/%{name}/etc/vm.args
+elif %{__grep} -q "^[# ]*-setcookie$" /opt/%{name}/etc/vm.args; then
+  echo "Please enter a cookie value for this installation: " >/dev/tty
+  if exec </dev/tty; then
+    read cookie;
+  fi
+  echo "Writing $cookie to vm.args..."
+  %{__sed} -i "s/^[# ]*-setcookie.*$/-setcookie ${cookie}/" /opt/%{name}/etc/vm.args
 fi
-echo "Writing $cookie to vm.args..."
-%{__sed} -i "s/^[# ]*-setcookie.*$/-setcookie ${cookie}/" /opt/%{name}/etc/vm.args
 %{__chown} -R couchdb:couchdb /opt/%{name}
 %{__chmod} a+x /opt/%{name}/bin/*
 %if 0%{?fedora} || 0%{?rhel} >= 7


[couchdb-pkg] 03/07: tighten file permissions for vm.args

Posted by va...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

vatamane pushed a commit to branch monstermunch
in repository https://gitbox.apache.org/repos/asf/couchdb-pkg.git

commit 9be16cc0f5991054767de430cf9de5850e6bc4af
Author: Robert Newson <rn...@apache.org>
AuthorDate: Thu Feb 24 15:12:05 2022 +0000

    tighten file permissions for vm.args
---
 debian/couchdb.postinst | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/debian/couchdb.postinst b/debian/couchdb.postinst
index efc4659..84d7455 100644
--- a/debian/couchdb.postinst
+++ b/debian/couchdb.postinst
@@ -230,7 +230,7 @@ case $1 in
     done
       
     # These should also not be world readable or writable:
-    find /opt/couchdb/etc -name *.ini -exec chmod 0640 {} \;
+    find /opt/couchdb/etc -name '*.ini' -o -name vm.args -exec chmod 0640 {} \;
     chmod 0750 /var/log/couchdb
     chmod 0750 /var/lib/couchdb
 


[couchdb-pkg] 07/07: Fix cookie preseeding

Posted by va...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

vatamane pushed a commit to branch monstermunch
in repository https://gitbox.apache.org/repos/asf/couchdb-pkg.git

commit cb9c142a965f2bd72e7ea4149fa67489f077b1ca
Author: Robert Newson <rn...@apache.org>
AuthorDate: Wed Apr 20 20:43:29 2022 +0100

    Fix cookie preseeding
---
 debian/couchdb.config | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/debian/couchdb.config b/debian/couchdb.config
index df9518c..e21d9e7 100755
--- a/debian/couchdb.config
+++ b/debian/couchdb.config
@@ -84,7 +84,9 @@ promptcookie() {
 if [ -e /opt/couchdb/etc/vm.args ] ; then
   cookie="$(grep '^-setcookie' /opt/couchdb/etc/vm.args | cut -d ' ' -f 2 | stripwhitespace)"
   nodename="$(grep '^-name' /opt/couchdb/etc/vm.args | cut -d ' ' -f 2 | stripwhitespace)"
-  db_set couchdb/cookie "${cookie}"
+  if [ -n "$cookie" ]; then
+      db_set couchdb/cookie "${cookie}"
+  fi
   if [ "${nodename}" != "couchdb@127.0.0.1" ]; then
     db_set couchdb/nodename "${nodename}"
   fi


[couchdb-pkg] 05/07: Merge pull request #1 from rnewson/rpm-cookie-nom

Posted by va...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

vatamane pushed a commit to branch monstermunch
in repository https://gitbox.apache.org/repos/asf/couchdb-pkg.git

commit b8570f8f93da58a2da441ccc19b8e3ee7b44c1fa
Merge: 9be16cc bf96939
Author: Robert Newson <rn...@apache.org>
AuthorDate: Wed Apr 13 16:26:38 2022 +0100

    Merge pull request #1 from rnewson/rpm-cookie-nom
    
    feat: patch rpmspec to prompt for cookie value

 rpm/SPECS/couchdb.spec.in | 6 ++++++
 1 file changed, 6 insertions(+)