Koha/debian/docs
Tomas Cohen Arazi f312f83dbc Bug 17717: Add a --chdir option switch for koha-foreach
Until Perl 5.26, the current directory is added to @INC when running a
Perl script [1]. Having the current directory in @INC means it can be
tried to be traversed when performing a lib lookup. Since version 5.18,
Perl dies when it finds an unreadable directory (permissions) in @INC
that needs to be traversed. This behaviour won't change because Perl
devs consider it an enhancement to security. [2]

Because of this, we need to make sure our scripts are ran **from** a
directory in which they have read permissions.

Ths patch adds a --chdir option switch to the **koha-foreach** wrapper
script, that makes the inner shells/scripts to be ran within the Koha
instance's user home directory.

The change is trivial and should be QAed easily. I tested this on a prod
server:

- Create a /tmp/test.pl file containing:

use Modern::Perl;

use Cwd;
my $dir = getcwd;

warn $dir;

1;

A) then create a cronjob entry to run it using koha-foreach:
(in /etc/cron.d/test):
1/* * * * * root koha-foreach perl /tmp/test.pl
- Once I noticed the cronjob ran, I used mutt to read the emails in the
root user.
=> FAIL:
...
Subject: Cron <root@koha> koha-foreach --enabled perl /tmp/test.pl

"/root"
"/root"
"/root"
"/root"
"/root"
...

B) I then used the patched koha-foreach with different results:
=> SUCCESS:
...
Subject: Cron <root@koha> /root/koha-foreach --chdir --enabled perl /tmp/test.pl

"/var/lib/koha/acaderc"
"/var/lib/koha/agro"
"/var/lib/koha/anc"
"/var/lib/koha/arico"
"/var/lib/koha/artes"
...

So this patch's approach works. But...

C) master's koha-foreach seems to work just the same... I think it is
because of my previous attempt to fix this by using sudo in koha-shell.
So I think environmental conditions affect the behaviour (which shell is
configured for cron, sudo configuration, etc).

====

In conclusion, I think we should go ahead with this patch as it will solve
peoples issues, and it is a right solution (option #5 on the list) to
this Perl behaviour change. It doesn't cover other commands, but
followup patches could do.

I avoided /tmp as it is writable by any user... so it is an easy path
for both exploiting by replacing some lib, and also because the
existence of an unreadable dir that the interpreter could try to
traverse (unreadable /tmp/Authen or /tmp/Koha will trigger the same
error, and I assume people know what they are putting on the instance's
dir, at least it will be easier to track).

A followup patch takes care of making the cronjobs use --chdir when
calling koha-foreach

[1] https://lists.debian.org/debian-devel-announce/2016/08/msg00013.html
[2] https://rt.perl.org/Public/Bug/Display.html?id=123795

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
2018-03-15 08:22:04 +00:00
..
koha-common.xml Bug 19462: Add koha-elasticsearch documentation 2017-10-27 14:10:31 -03:00
koha-create-dirs.xml Bug 10042 - Minor typo ("Communnity") in packages docs 2013-04-18 08:36:11 -04:00
koha-create.xml Bug 17951: Make koha-create set template_cache_dir correctly 2017-12-22 13:15:39 -03:00
koha-disable.xml Bug 10104 - make koha-disable more robust 2013-05-01 21:58:38 -04:00
koha-dump-defaults.xml Bug 10042 - Minor typo ("Communnity") in packages docs 2013-04-18 08:36:11 -04:00
koha-dump.xml Bug 14532: Add --exclude-indexes switch to koha-dump 2016-03-02 04:39:51 +00:00
koha-elasticsearch.xml Bug 19462: Add koha-elasticsearch documentation 2017-10-27 14:10:31 -03:00
koha-email-disable.xml Bug 10150 - koha-email-disable error handling 2013-05-02 15:04:57 -07:00
koha-email-enable.xml Bug 10157 - koha-email-enable error handling 2013-05-15 08:13:17 -04:00
koha-enable-sip.xml Bug 9250 - [SIGNED-OFF] provide commands to manage the SIP server 2013-05-01 22:03:13 -04:00
koha-enable.xml Bug 10101 - make koha-enable more robust 2013-05-01 22:00:13 -04:00
koha-foreach.xml Bug 17717: Add a --chdir option switch for koha-foreach 2018-03-15 08:22:04 +00:00
koha-indexer.xml Bug 8773 - Start per-instance koha-index-daemon in .deb setup 2014-07-14 09:15:22 -03:00
koha-list.xml Bug 10622: (follow-up) uppercase "SIP" in documentation and help text 2013-09-21 17:47:54 +00:00
koha-mysql.xml Bug 12372: Updated man pages for koha-mysql 2015-08-24 13:18:12 -03:00
koha-mysqlcheck.xml Bug 10782 - Add a koha-mysqlcheck script 2014-04-23 12:30:06 +00:00
koha-plack.xml Bug 13791: koha-plack documentation 2015-08-24 13:00:40 -03:00
koha-rebuild-zebra.xml [SIGNED-OFF] Bug 15113: koha-rebuild-zebra should check USE_INDEXER_DAEMON and skip if enabled 2016-04-19 17:47:42 +00:00
koha-remove.xml Bug 17266 - Update man page for koha-remove with -p 2016-09-15 13:46:10 +00:00
koha-reset-passwd.xml Bug 10042 - Minor typo ("Communnity") in packages docs 2013-04-18 08:36:11 -04:00
koha-restart-zebra.xml Bug 10042 - Minor typo ("Communnity") in packages docs 2013-04-18 08:36:11 -04:00
koha-restore.xml Bug 10042 - Minor typo ("Communnity") in packages docs 2013-04-18 08:36:11 -04:00
koha-run-backups.xml Bug 10042 - Minor typo ("Communnity") in packages docs 2013-04-18 08:36:11 -04:00
koha-shell.xml Bug 8878 - a command to provide a shell with the koha environment 2012-12-20 08:01:46 -05:00
koha-sitemap.xml Bug 16016: Sitemap handling scripts for packages 2016-05-04 13:34:21 +00:00
koha-start-sip.xml Bug 9250 - [SIGNED-OFF] provide commands to manage the SIP server 2013-05-01 22:03:13 -04:00
koha-start-zebra.xml Bug 10042 - Minor typo ("Communnity") in packages docs 2013-04-18 08:36:11 -04:00
koha-stop-sip.xml Bug 9250 - [SIGNED-OFF] provide commands to manage the SIP server 2013-05-01 22:03:13 -04:00
koha-stop-zebra.xml Bug 10042 - Minor typo ("Communnity") in packages docs 2013-04-18 08:36:11 -04:00
koha-translate.xml Bug 16749: Update debian docs for koha-translate 2017-02-17 13:20:57 +00:00
koha-upgrade-schema.xml Bug 10042 - Minor typo ("Communnity") in packages docs 2013-04-18 08:36:11 -04:00
koha-upgrade-to-3.4.xml Bug 10042 - Minor typo ("Communnity") in packages docs 2013-04-18 08:36:11 -04:00
koha-zebra.xml Bug 17467: Add koha-zebra documentation 2017-10-27 14:10:30 -03:00
LEEME.Debian Bug 7197 - add a Spanish readme file to the packages 2011-12-14 15:38:04 +01:00