Bug 22143 - Fix permission and owner of configuration backups
Summary: Fix permission and owner of configuration backups
Status: RESOLVED DUPLICATE of bug 14564
Alias: None
Product: Koha
Classification: Unclassified
Component: Packaging (show other bugs)
Version: Main
Hardware: All All
: P5 - low normal (vote)
Assignee: Dobrica Pavlinusic
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-01-16 17:01 UTC by Magnus Enger
Modified: 2019-01-17 08:37 UTC (History)
2 users (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:


Attachments
Patch from Bug 8437 (805 bytes, patch)
2019-01-16 17:03 UTC, Magnus Enger
Details | Diff | Splinter Review
Bug 22143 - Fix permission and owner of configuration backups (1.78 KB, patch)
2019-01-16 17:40 UTC, Magnus Enger
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Magnus Enger 2019-01-16 17:01:23 UTC
If you install Koha with the Debian packages you get backups in /var/spool/koha/<instance>/ that look like this:

-rw------- 1 root root            6616261 jan.  12 03:11 xxxxxxxx-2019-01-12.tar.gz
-rw-r----- 1 root xxxxxxxx-koha 109473282 jan.  13 03:10 xxxxxxxx-2019-01-13.sql.gz
-rw------- 1 root root            6677496 jan.  13 03:10 xxxxxxxx-2019-01-13.tar.gz
-rw-r----- 1 root xxxxxxxx-koha 109473283 jan.  14 03:20 xxxxxxxx-2019-01-14.sql.gz
-rw------- 1 root root            6721580 jan.  14 03:20 xxxxxxxx-2019-01-14.tar.gz
-rw-r----- 1 root xxxxxxxx-koha 109473282 jan.  15 03:16 xxxxxxxx-2019-01-15.sql.gz
-rw------- 1 root root            6723809 jan.  15 03:16 xxxxxxxx-2019-01-15.tar.gz
-rw-r----- 1 root xxxxxxxx-koha 109473283 jan.  16 03:17 xxxxxxxx-2019-01-16.sql.gz
-rw------- 1 root root            6770890 jan.  16 03:17 xxxxxxxx-2019-01-16.tar.gz

Notice the difference in the permissions and the ownership of the files. 

Recently, I tried to turn on download of backups from the "Export" tool, with these settings in koha-conf.xml: 

 <backup_db_via_tools>1</backup_db_via_tools>
 <backup_conf_via_tools>1</backup_conf_via_tools>

This worked nicely for the db files, but not for the conf files, where the page just said "Unfortunately, no backups are available."

I found a workaround was to do the following: 

  $ sudo chmod 0640 /var/spool/koha/<instance>/*
  $ sudo chown root:<instance>-koha /var/spool/koha/<instance>/*

After this, the files showed up as expected. This is due to the check on line 342 of /usr/share/koha/intranet/cgi-bin/tools/export.pl:

  return unless ( -f $filename && -r $filename );

The -r mens "File is readable by effective uid/gid."

Looking around in Bugzilla, I found a patch for this problem, by Dobrica Pavlinusic, on bug 8437. That bug is mainly about downloading large files with Plack, and the permissions issue described here is fixed in a followup patch. I will try and move that patch to this bug, so the discussion about Plack does not block fixing the permissions.
Comment 1 Magnus Enger 2019-01-16 17:03:18 UTC Comment hidden (obsolete)
Comment 2 Magnus Enger 2019-01-16 17:40:07 UTC
Created attachment 84075 [details] [review]
Bug 22143 - Fix permission and owner of configuration backups

This allows backups created using Debian package to show up
automatically in web interface and makes permissions of backup
files consistent.

Signed-off-by: Magnus Enger <magnus@libriotech.no>

Original patch by Dobrica Pavlinusic. Moved from Bug 8437 by me.
Tested thusly:
- Look at backup files in /var/spool/koha/<instance>/
- Notice that permissions for .tar.gz files are -rw-------
- Notice ownership of .tar.gz files are root:root
- Apply this patch
- Make sure the changes in the patch are applied to the script
  you run when you run "sudo koha-dump". This might include
  copying debian/scripts/koha-dump to /usr/sbin/koha-dump, if
  you are on a gitified setup.
- Run the modified koha-dump
- Notice that both backup files dated today are now -rw-r-----
  and ownership is root:<instance>-koha

For extra testing credit:
Set <backup_conf_via_tools>1</backup_conf_via_tools> in koha-conf.xml
and verify that no files are listed under Tools > Export > Export
configuration initially. After patching and running koha-dump the
.tar.gz with the current date should show up.
Comment 3 Mirko Tietgen 2019-01-17 08:31:26 UTC
Hi Magnus, this is a duplicate of bug 14564. I won't duplicate-link to it so I don't close your bug, but please take a look and see if you agree with the discussion. :)
Comment 4 Magnus Enger 2019-01-17 08:36:33 UTC

*** This bug has been marked as a duplicate of bug 14564 ***
Comment 5 Magnus Enger 2019-01-17 08:37:07 UTC
(In reply to Mirko Tietgen from comment #3)
> Hi Magnus, this is a duplicate of bug 14564. I won't duplicate-link to it so
> I don't close your bug, but please take a look and see if you agree with the
> discussion. :)

Thanks for pointing it out, bad searching on my part.