| Summary: | koha-create --request-db and --populate-db creates log files owned by root (intranet-error.log, opac-error.log) | ||
|---|---|---|---|
| Product: | Koha | Reporter: | Saiful Amin <saiful> |
| Component: | Installation and upgrade (command-line installer) | Assignee: | Andreas Roussos <a.roussos> |
| Status: | Pushed to main --- | QA Contact: | Jan Kissig <bibliothek> |
| Severity: | major | ||
| Priority: | P1 - high | CC: | a.roussos, bibliothek, tomascohen |
| Version: | Main | ||
| Hardware: | All | ||
| OS: | Linux | ||
| See Also: | https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=25284 | ||
| GIT URL: | Initiative type: | --- | |
| Sponsorship status: | --- | Comma delimited list of Sponsors: | |
| Crowdfunding goal: | 0 | Patch complexity: | Small patch |
| Documentation contact: | Documentation submission: | ||
| Text to go in the release notes: |
This fixes the UNIX user/group ownership of the log files `intranet-error.log` and `opac-error.log` inside `/var/log/koha/<instance>/`.
Previously, running `koha-create --request-db` followed by `koha-create --populate-db` would result in the two log files being owned by root/root.
The correct ownership is now applied, meaning the log files will be owned by the <instance>-koha/<instance>-koha UNIX user/group.
|
Version(s) released in: |
26.05.00
|
| Circulation function: | |||
| Attachments: |
Bug 41337: Add missing Bash variable to `koha-create`
Bug 41337: Add missing Bash variable to `koha-create` Bug 41337: Add missing Bash variable to `koha-create` Bug 41337: Add missing Bash variable to `koha-create` |
||
|
Description
Saiful Amin
2025-12-01 14:12:41 UTC
(In reply to Saiful Amin from comment #0) > [...] > Expected Result: > All log files under /var/log/koha/<instance>/ should be owned by > <instance>-koha:<instance>-koha, identical to a normal koha-create run > without the request/populate split. > [...] Thank you, Saiful, for the detailed Bug Description and the steps to reproduce. I can confirm this is still an issue, which relates to this line in the script: https://git.koha-community.org/Koha-community/Koha/src/commit/c58989fc51bf41fc92fd568875f304c03aa075f6/debian/scripts/koha-create#L924 924 chown $username:$username /var/log/koha/$name/*.log At this point in the script the $username variable is empty, so the `chown` command becomes: chown : /var/log/koha/test/*.log The chown(1) man page states: "If only a colon is given, or if the entire operand is empty, neither the owner nor the group is changed." Created attachment 192809 [details] [review] Bug 41337: Add missing Bash variable to `koha-create` When creating a new Koha instance using the two-step workflow (`koha-create --request-db <instance>`, followed by `koha-create --populate-db <instance>`), some log files under /var/log/koha/<instance>/ end up with incorrect ownership. Specifically, intranet-error.log and opac-error.log are owned by root:root instead of <instance>-koha:<instance>-koha. This patch fixes that. Test plan (tailored for KTD): 1) Before applying this patch, run the following commands inside your KTD Koha container: $ sudo koha-create --request-db test1 $ SQLPASS=`sudo grep password: test1-db-request.txt | cut -c 16-` $ mysql -hdb -uroot -ppassword -e "CREATE DATABASE koha_test1;" $ mysql -hdb -uroot -ppassword -e "GRANT ALL PRIVILEGES ON koha_test1.* TO 'koha_test1'@'%' IDENTIFIED BY '${SQLPASS}';" $ mysql -hdb -uroot -ppassword -e "FLUSH PRIVILEGES;" $ sudo koha-create --populate-db test1 $ ls -l /var/log/koha/test1/ total 8 -rw-r--r-- 1 test1-koha test1-koha 0 Feb 9 15:35 indexer-error.log -rw-r--r-- 1 test1-koha test1-koha 1278 Feb 9 15:35 indexer-output.log -rw-r--r-- 1 root root 0 Feb 9 15:35 intranet-error.log -rw-r--r-- 1 root root 0 Feb 9 15:35 opac-error.log -rw-r--r-- 1 test1-koha test1-koha 0 Feb 9 15:35 worker-error.log -rw-r--r-- 1 test1-koha test1-koha 1828 Feb 9 15:35 worker-output.log -rw-r--r-- 1 test1-koha test1-koha 0 Feb 9 15:35 zebra-error.log -rw-r--r-- 1 test1-koha test1-koha 0 Feb 9 15:35 zebra-output.log Notice the incorrect user/group ownership on two files: `intranet-error.log` and `opac-error.log`. 2) Apply this patch, and remove the `test1` instance along with the database request text file: $ sudo koha-remove test1 $ sudo rm test1-db-request.txt 3) Repeat the commands in Step 1. This time, the output of the last command should resemble the following: total 8 -rw-r--r-- 1 test1-koha test1-koha 0 Feb 9 15:42 indexer-error.log -rw-r--r-- 1 test1-koha test1-koha 1520 Feb 9 15:42 indexer-output.log -rw-r--r-- 1 test1-koha test1-koha 0 Feb 9 15:42 intranet-error.log -rw-r--r-- 1 test1-koha test1-koha 0 Feb 9 15:42 opac-error.log -rw-r--r-- 1 test1-koha test1-koha 0 Feb 9 15:42 worker-error.log -rw-r--r-- 1 test1-koha test1-koha 1828 Feb 9 15:42 worker-output.log -rw-r--r-- 1 test1-koha test1-koha 0 Feb 9 15:42 zebra-error.log -rw-r--r-- 1 test1-koha test1-koha 0 Feb 9 15:42 zebra-output.log All files should now have the correct user/group ownership. Created attachment 192822 [details] [review] Bug 41337: Add missing Bash variable to `koha-create` When creating a new Koha instance using the two-step workflow (`koha-create --request-db <instance>`, followed by `koha-create --populate-db <instance>`), some log files under /var/log/koha/<instance>/ end up with incorrect ownership. Specifically, intranet-error.log and opac-error.log are owned by root:root instead of <instance>-koha:<instance>-koha. This patch fixes that. Test plan (tailored for KTD): 1) Before applying this patch, run the following commands inside your KTD Koha container: $ sudo koha-create --request-db test1 $ SQLPASS=`sudo grep password: test1-db-request.txt | cut -c 16-` $ mysql -hdb -uroot -ppassword -e "CREATE DATABASE koha_test1;" $ mysql -hdb -uroot -ppassword -e "GRANT ALL PRIVILEGES ON koha_test1.* TO 'koha_test1'@'%' IDENTIFIED BY '${SQLPASS}';" $ mysql -hdb -uroot -ppassword -e "FLUSH PRIVILEGES;" $ sudo koha-create --populate-db test1 $ ls -l /var/log/koha/test1/ total 8 -rw-r--r-- 1 test1-koha test1-koha 0 Feb 9 15:35 indexer-error.log -rw-r--r-- 1 test1-koha test1-koha 1278 Feb 9 15:35 indexer-output.log -rw-r--r-- 1 root root 0 Feb 9 15:35 intranet-error.log -rw-r--r-- 1 root root 0 Feb 9 15:35 opac-error.log -rw-r--r-- 1 test1-koha test1-koha 0 Feb 9 15:35 worker-error.log -rw-r--r-- 1 test1-koha test1-koha 1828 Feb 9 15:35 worker-output.log -rw-r--r-- 1 test1-koha test1-koha 0 Feb 9 15:35 zebra-error.log -rw-r--r-- 1 test1-koha test1-koha 0 Feb 9 15:35 zebra-output.log Notice the incorrect user/group ownership on two files: `intranet-error.log` and `opac-error.log`. 2) Apply this patch, remove the `test1` instance along with the database request text file, and copy the modified script to its system-wide location: $ sudo koha-remove test1 $ sudo rm test1-db-request.txt $ sudo cp debian/scripts/koha-create /usr/sbin/koha-create 3) Repeat the commands in Step 1. This time, the output of the last command should resemble the following: total 8 -rw-r--r-- 1 test1-koha test1-koha 0 Feb 9 15:42 indexer-error.log -rw-r--r-- 1 test1-koha test1-koha 1520 Feb 9 15:42 indexer-output.log -rw-r--r-- 1 test1-koha test1-koha 0 Feb 9 15:42 intranet-error.log -rw-r--r-- 1 test1-koha test1-koha 0 Feb 9 15:42 opac-error.log -rw-r--r-- 1 test1-koha test1-koha 0 Feb 9 15:42 worker-error.log -rw-r--r-- 1 test1-koha test1-koha 1828 Feb 9 15:42 worker-output.log -rw-r--r-- 1 test1-koha test1-koha 0 Feb 9 15:42 zebra-error.log -rw-r--r-- 1 test1-koha test1-koha 0 Feb 9 15:42 zebra-output.log All files should now have the correct user/group ownership. Created attachment 193015 [details] [review] Bug 41337: Add missing Bash variable to `koha-create` When creating a new Koha instance using the two-step workflow (`koha-create --request-db <instance>`, followed by `koha-create --populate-db <instance>`), some log files under /var/log/koha/<instance>/ end up with incorrect ownership. Specifically, intranet-error.log and opac-error.log are owned by root:root instead of <instance>-koha:<instance>-koha. This patch fixes that. Test plan (tailored for KTD): 1) Before applying this patch, run the following commands inside your KTD Koha container: $ sudo koha-create --request-db test1 $ SQLPASS=`sudo grep password: test1-db-request.txt | cut -c 16-` $ mysql -hdb -uroot -ppassword -e "CREATE DATABASE koha_test1;" $ mysql -hdb -uroot -ppassword -e "GRANT ALL PRIVILEGES ON koha_test1.* TO 'koha_test1'@'%' IDENTIFIED BY '${SQLPASS}';" $ mysql -hdb -uroot -ppassword -e "FLUSH PRIVILEGES;" $ sudo koha-create --populate-db test1 $ ls -l /var/log/koha/test1/ total 8 -rw-r--r-- 1 test1-koha test1-koha 0 Feb 9 15:35 indexer-error.log -rw-r--r-- 1 test1-koha test1-koha 1278 Feb 9 15:35 indexer-output.log -rw-r--r-- 1 root root 0 Feb 9 15:35 intranet-error.log -rw-r--r-- 1 root root 0 Feb 9 15:35 opac-error.log -rw-r--r-- 1 test1-koha test1-koha 0 Feb 9 15:35 worker-error.log -rw-r--r-- 1 test1-koha test1-koha 1828 Feb 9 15:35 worker-output.log -rw-r--r-- 1 test1-koha test1-koha 0 Feb 9 15:35 zebra-error.log -rw-r--r-- 1 test1-koha test1-koha 0 Feb 9 15:35 zebra-output.log Notice the incorrect user/group ownership on two files: `intranet-error.log` and `opac-error.log`. 2) Apply this patch, remove the `test1` instance along with the database request text file, and copy the modified script to its system-wide location: $ sudo koha-remove test1 $ sudo rm test1-db-request.txt $ sudo cp debian/scripts/koha-create /usr/sbin/koha-create 3) Repeat the commands in Step 1. This time, the output of the last command should resemble the following: total 8 -rw-r--r-- 1 test1-koha test1-koha 0 Feb 9 15:42 indexer-error.log -rw-r--r-- 1 test1-koha test1-koha 1520 Feb 9 15:42 indexer-output.log -rw-r--r-- 1 test1-koha test1-koha 0 Feb 9 15:42 intranet-error.log -rw-r--r-- 1 test1-koha test1-koha 0 Feb 9 15:42 opac-error.log -rw-r--r-- 1 test1-koha test1-koha 0 Feb 9 15:42 worker-error.log -rw-r--r-- 1 test1-koha test1-koha 1828 Feb 9 15:42 worker-output.log -rw-r--r-- 1 test1-koha test1-koha 0 Feb 9 15:42 zebra-error.log -rw-r--r-- 1 test1-koha test1-koha 0 Feb 9 15:42 zebra-output.log All files should now have the correct user/group ownership. Signed-off-by: Brendan Lawlor <blawlor@clamsnet.org> Created attachment 193247 [details] [review] Bug 41337: Add missing Bash variable to `koha-create` When creating a new Koha instance using the two-step workflow (`koha-create --request-db <instance>`, followed by `koha-create --populate-db <instance>`), some log files under /var/log/koha/<instance>/ end up with incorrect ownership. Specifically, intranet-error.log and opac-error.log are owned by root:root instead of <instance>-koha:<instance>-koha. This patch fixes that. Test plan (tailored for KTD): 1) Before applying this patch, run the following commands inside your KTD Koha container: $ sudo koha-create --request-db test1 $ SQLPASS=`sudo grep password: test1-db-request.txt | cut -c 16-` $ mysql -hdb -uroot -ppassword -e "CREATE DATABASE koha_test1;" $ mysql -hdb -uroot -ppassword -e "GRANT ALL PRIVILEGES ON koha_test1.* TO 'koha_test1'@'%' IDENTIFIED BY '${SQLPASS}';" $ mysql -hdb -uroot -ppassword -e "FLUSH PRIVILEGES;" $ sudo koha-create --populate-db test1 $ ls -l /var/log/koha/test1/ total 8 -rw-r--r-- 1 test1-koha test1-koha 0 Feb 9 15:35 indexer-error.log -rw-r--r-- 1 test1-koha test1-koha 1278 Feb 9 15:35 indexer-output.log -rw-r--r-- 1 root root 0 Feb 9 15:35 intranet-error.log -rw-r--r-- 1 root root 0 Feb 9 15:35 opac-error.log -rw-r--r-- 1 test1-koha test1-koha 0 Feb 9 15:35 worker-error.log -rw-r--r-- 1 test1-koha test1-koha 1828 Feb 9 15:35 worker-output.log -rw-r--r-- 1 test1-koha test1-koha 0 Feb 9 15:35 zebra-error.log -rw-r--r-- 1 test1-koha test1-koha 0 Feb 9 15:35 zebra-output.log Notice the incorrect user/group ownership on two files: `intranet-error.log` and `opac-error.log`. 2) Apply this patch, remove the `test1` instance along with the database request text file, and copy the modified script to its system-wide location: $ sudo koha-remove test1 $ sudo rm test1-db-request.txt $ sudo cp debian/scripts/koha-create /usr/sbin/koha-create 3) Repeat the commands in Step 1. This time, the output of the last command should resemble the following: total 8 -rw-r--r-- 1 test1-koha test1-koha 0 Feb 9 15:42 indexer-error.log -rw-r--r-- 1 test1-koha test1-koha 1520 Feb 9 15:42 indexer-output.log -rw-r--r-- 1 test1-koha test1-koha 0 Feb 9 15:42 intranet-error.log -rw-r--r-- 1 test1-koha test1-koha 0 Feb 9 15:42 opac-error.log -rw-r--r-- 1 test1-koha test1-koha 0 Feb 9 15:42 worker-error.log -rw-r--r-- 1 test1-koha test1-koha 1828 Feb 9 15:42 worker-output.log -rw-r--r-- 1 test1-koha test1-koha 0 Feb 9 15:42 zebra-error.log -rw-r--r-- 1 test1-koha test1-koha 0 Feb 9 15:42 zebra-output.log All files should now have the correct user/group ownership. Signed-off-by: Brendan Lawlor <blawlor@clamsnet.org> Signed-off-by: Jan Kissig <bibliothek@th-wildau.de> Nice work everyone! Pushed to main for 26.05 |