You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by rn...@apache.org on 2023/01/22 17:14:58 UTC
[couchdb-pkg] 01/01: Use control character in sed lines with variables
This is an automated email from the ASF dual-hosted git repository.
rnewson pushed a commit to branch allow-forwardslash-in-cookie-etc
in repository https://gitbox.apache.org/repos/asf/couchdb-pkg.git
commit 3bc1118ba7da596bb8180a26e22cc391e91d9b32
Author: Robert Newson <rn...@apache.org>
AuthorDate: Sun Jan 22 17:11:14 2023 +0000
Use control character in sed lines with variables
A cookie value with a '/' in it caused a sed error during postinst;
```
sed: -e expression #1, char 53: unknown option to `s'
```
We use a control character (RS - record separator) instead of / to
reduce the chances of a collision with a valid cookie string.
I applied the same change to nodename even though a / in node name
would be an error, for consistency.
---
debian/couchdb.postinst | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/debian/couchdb.postinst b/debian/couchdb.postinst
index bd02d5c..d76c832 100644
--- a/debian/couchdb.postinst
+++ b/debian/couchdb.postinst
@@ -161,7 +161,7 @@ case $1 in
db_get couchdb/cookie && cookie="$RET"
# change existing setcookie line if present
- sed -i "s/^[# ]*-setcookie.*$/-setcookie ${cookie}/" /opt/couchdb/etc/vm.args
+ sed -i "$(printf 's\30^[# ]*-setcookie.*$\30-setcookie %s\30' ${cookie})" /opt/couchdb/etc/vm.args
# add setcookie line if not present
if ! grep -q '^-setcookie' /opt/couchdb/etc/vm.args; then
@@ -192,7 +192,7 @@ case $1 in
clustered)
db_get couchdb/nodename && nodename="$RET"
- sed -i "s/^-name .*$/-name ${nodename}/" /opt/couchdb/etc/vm.args
+ sed -i "$(printf 's\30^-name .*$\30-name %s\30' ${nodename})" /opt/couchdb/etc/vm.args
setbindaddress