From 7e28073bd9fc7c718a5dde63caa180be53cc27d4 Mon Sep 17 00:00:00 2001 From: Saiful Amin Date: Tue, 16 Jun 2026 17:00:57 +0000 Subject: [PATCH] Bug 42861: System warning about missing encryption_key on a fresh instance MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This patch updates the koha-create command to generate the random encryption key using pwgen with the number of characters set to 32. Test plan: 1. In ktd, create a new instance: - sudo koha-create --create-db test1 - Check the /etc/koha/sites/test1/koha-conf.xml file and verify that the encryption_key is having the placeholder text '__ENCRYPTION_KEY__' 2. Apply the patch and copy the new koha-create command - git bz apply 42861 - sudo cp /kohadevbox/koha/debian/scripts/koha-create /usr/sbin/koha-create 3. In ktd, create a new instance: - sudo koha-create --create-db test2 - Check the /etc/koha/sites/test2/koha-conf.xml file and verify that the encryption_key is generated and has 32 characters random string. 4. Sign-off Signed-off-by: David Nind Signed-off-by: Tomás Cohen Arazi Signed-off-by: Lucas Gass --- debian/scripts/koha-create | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/debian/scripts/koha-create b/debian/scripts/koha-create index 3e3b2e4f03..38f3707830 100755 --- a/debian/scripts/koha-create +++ b/debian/scripts/koha-create @@ -138,6 +138,7 @@ generate_config_file() { -e "s#__TEMPLATE_CACHE_DIR__#$TEMPLATE_CACHE_DIR#g" \ -e "s#__TIMEZONE__#$TIMEZONE#g" \ -e "s#__BCRYPT_SETTINGS__#$BCRYPT_SETTINGS#g" \ + -e "s#__ENCRYPTION_KEY__#$ENCRYPTION_KEY#g" \ -e "s#__UPLOAD_PATH__#$UPLOAD_PATH#g" \ -e "s#__TMP_PATH__#$TMP_PATH#g" \ -e "s/__LOG_DIR__/\/var\/log\/koha\/$name/g" \ @@ -650,7 +651,7 @@ if [ "${CLO_ELASTICSEARCH_SERVER}" != "" ]; then fi BCRYPT_SETTINGS=$(htpasswd -bnBC 10 "" password | tr -d ':\n' | sed 's/$2y/$2a/'); - +ENCRYPTION_KEY="$(pwgen -s 32 1)" if [ "$ENABLE_SRU" != "no" ]; then enable_sru_server