This is an automated email from the ASF dual-hosted git repository. vatamane pushed a commit to branch improve-dev-random-usage in repository https://gitbox.apache.org/repos/asf/couchdb-pkg.git
commit 5465eb8a3280c26afd3a83321a5d4566e8f11e33 Author: Nick Vatamaniuc <[email protected]> AuthorDate: Mon Jun 13 15:13:05 2022 -0400 Improve /dev/random usage when generating cookies for RPM distros In a low entropy environments, /dev/random will block so we want to make sure we use only as many bytes as we'll need instead of reading and discarding byte as we did previously. --- rpm/SPECS/couchdb.spec.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rpm/SPECS/couchdb.spec.in b/rpm/SPECS/couchdb.spec.in index cfec522..e77f949 100644 --- a/rpm/SPECS/couchdb.spec.in +++ b/rpm/SPECS/couchdb.spec.in @@ -151,7 +151,7 @@ if %{__grep} -q "^-setcookie monster$" /opt/%{name}/etc/vm.args; then cookie=${COUCHDB_COOKIE} else echo "Generating random cookie value." - cookie=$(cat /dev/random | tr -dc 'a-zA-Z0-9' | head --bytes 48) + cookie=$(dd if=/dev/random bs=1 count=38 status=none | base64 | tr -cd [:alnum:]) fi %{__sed} -i "s/^-setcookie monster.*$/-setcookie ${cookie}/" /opt/%{name}/etc/vm.args elif %{__grep} -q "^[# ]*-setcookie$" /opt/%{name}/etc/vm.args; then @@ -161,7 +161,7 @@ elif %{__grep} -q "^[# ]*-setcookie$" /opt/%{name}/etc/vm.args; then cookie=${COUCHDB_COOKIE} else echo "Generating random cookie value." - cookie=$(cat /dev/random | tr -dc 'a-zA-Z0-9' | head --bytes 48) + cookie=$(dd if=/dev/random bs=1 count=38 status=none | base64 | tr -cd [:alnum:]) fi %{__sed} -i "s/^[# ]*-setcookie.*$/-setcookie ${cookie}/" /opt/%{name}/etc/vm.args fi
