Go to file
Tomas Cohen Arazi 67cecb7f75 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>
(cherry picked from commit 3db7e1a63a)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
2018-04-10 09:15:50 +02:00
C4 Bug 20145: Do not insert 0000-00-00 in patron tests (and more) 2018-03-27 10:43:21 +02:00
Koha Bug 20229: Explicitly list the SQL modes we support 2018-04-10 08:53:40 +02:00
OpenILS Bug 9239 QA follow-up: remove stray debug code 2013-03-16 21:32:34 -04:00
acqui Bug 19596: Don't try to get hold or items count for non-existent biblios 2018-02-05 11:34:25 +01:00
admin Bug 19977: Open only .pref files in Local Use tab (sysprefs) 2018-01-31 08:55:27 +01:00
api/v1 Bug 18763: Fix swagger/definitions.t 2017-06-20 10:19:55 +02:00
authorities Bug 19987: If no z39.50/SRU servers the button should not show 2018-01-31 08:57:05 +01:00
basket Bug 18124: Change the calls to generate and check CSRF tokens 2017-03-30 09:07:09 +00:00
catalogue Bug 20083 - Information disclosure when (mis)using the MARC Preview feature 2018-03-27 13:58:22 +02:00
cataloguing Bug 19987: If no z39.50/SRU servers the button should not show 2018-01-31 08:57:05 +01:00
circ Bug 19921: Fix update child when only one adult patron category exist 2018-01-30 09:09:39 +01:00
clubs Bug 18632: Remove 'CGI::param called in list context' warnings 2017-05-28 22:25:22 -04:00
course_reserves Bug 20276: Fix GetCourseItem call to get itemnumber 2018-02-26 13:41:21 +01:00
debian Bug 17717: Add a --chdir option switch for koha-foreach 2018-04-10 09:15:50 +02:00
docs Bug 7143: Add Patricio Marrone to history.txt 2017-03-31 13:45:33 +00:00
errors Bug 15288: Error pages: Code duplication removal and better translatability 2016-01-27 05:57:34 +00:00
etc Bug 18669 - RewriteCond affecting wrong rule in koha-httpd.conf 2017-05-28 22:30:11 -04:00
installer Increment version for 17.05.10 release 2018-03-27 14:09:23 +02:00
koha-tmpl Bug 20286: Fix filter for BakerTaylor* prefs 2018-04-10 09:06:33 +02:00
labels Bug 19681: Correct result count formatting 2017-12-20 09:30:46 +01:00
members Bug 20367: Avoid resetting userid when BorrowerUnwantedField contains userid 2018-03-27 13:46:10 +02:00
misc Merge remote-tracking branch 'translate/17.05.10-translate-20180327' into 17.05.x 2018-03-27 14:10:41 +02:00
offline_circ Bug 17501: Remove Koha::Upload::get from Koha::Upload 2017-01-20 14:20:05 +00:00
opac Bug 20083: Follow up - use same logic in opac-showmarc 2018-03-27 13:59:19 +02:00
patron_lists Bug 16154: CGI->multi_param - Force scalar context 2016-04-26 23:16:43 +00:00
patroncards Bug 18246: Patron card creator: Unit not always displays properly in layouts 2017-03-22 20:58:10 +00:00
plugins Bug 19088: plugins-upload causes error log noise 2017-09-29 15:34:42 +02:00
reports Revert "Bug 19669: (QA follow-up) Remove itemstypes.plugin" 2018-02-05 11:25:11 +01:00
reserve Bug 19533: Hold pulldown for itemtype is empty if hold placement needs override 2017-12-20 09:25:48 +01:00
reviews Bug 15839: Koha::Reviews - Remove C4::Review residue 2016-09-09 10:31:00 +00:00
rotating_collections Bug 15758: Koha::Libraries - Remove GetBranches 2016-09-08 14:36:03 +00:00
serials Bug 19315: [QA Follow-up] Trivial edits 2017-10-27 12:36:44 +02:00
services Bug 9978: Replace license header with the correct license (GPLv3+) 2015-04-20 09:59:38 -03:00
skel Bug 11078: Add locking to rebuild_zebra 2014-02-28 22:21:41 +00:00
sms Bug 15258: Fix Perl scripts declaring unused variables 2015-12-30 17:24:45 -07:00
suggestion Bug 18839: Suggestion.pl spelling mistake 2017-07-27 16:30:17 +02:00
svc Bug 17898: Automagically convert SQL reports 2017-05-19 18:48:26 +00:00
t Bug 20311: Prevent get_age tests to fail on Feb 28th 2018-04-10 09:04:09 +02:00
tags Bug 5471: Use uri_escape_utf8 to handle utf8 chars correctly 2017-09-29 11:17:17 +02:00
test Bug 9819 - 'stopwords'-related code removed 2015-12-30 15:49:35 +00:00
tmp/modified_authorities changing DO_NOT_REMOVE to README.txt 2007-10-21 19:14:41 -05:00
tools Bug 20098: Inventory tool: CVS export: fix itemlost column 2018-03-12 16:16:54 +01:00
virtualshelves Bug 7663: Fix bad merge conflict with bug 15584 2017-03-03 18:18:14 +00:00
xt Bug 19262: Remove xt/author/pod_spell.t 2017-10-23 15:29:50 +02:00
.editorconfig Bug 12545: Add EditorConfig.org file to the source tree 2014-08-22 11:07:45 -03:00
.htaccess Fix file permissions: if it is not a script, it should not be executable. 2010-04-16 00:40:34 -04:00
.mailmap Update mailmap - Jonathan Druart 2017-06-29 09:33:25 +02:00
INSTALL Bug 17626: Remove existing install instructions and link to the wiki pages instead 2016-11-22 11:29:07 +00:00
Koha.pm Increment version for 17.05.10 release 2018-03-27 14:09:23 +02:00
LICENSE Bug 9440 - update Koha's LICENSE file from GPL2 to GPL3 2013-02-12 08:52:10 -05:00
MANIFEST.SKIP Bug 9546 : Updating make manifest tardist 2013-02-06 23:54:46 -05:00
Makefile.PL Bug 19067: Map clubs/ into INTRANET_CGI_DIR in Makefile.PL 2017-09-12 16:04:02 +02:00
README Bug 9440 - update Koha's LICENSE file from GPL2 to GPL3 2013-02-12 08:52:10 -05:00
README.md Bug 15465: Fix typo in bugs.k-c.org 2017-05-26 11:45:31 -03:00
README.robots Bug 6411 add another example to README.robots 2011-07-05 14:48:05 +12:00
about.pl Bug 18931 - Follow up - Typo fix in SQL statement 2017-07-27 10:25:20 +02:00
changelanguage.pl Bug 16776: Do not forget external language choice in language switcher 2016-08-10 13:51:33 +00:00
edithelp.pl Bug 16447: Remove occurrence of the borrow permission which does no longer exist 2016-05-05 21:28:14 +00:00
fix-perl-path.PL Bug 9978: (followup) Replace license header with the correct license (GPLv3+) 2015-04-20 09:59:43 -03:00
help.pl Bug 16724: Fix link to the online documentation links 2016-06-24 12:00:42 +00:00
install-CPAN.pl Bug 9978: Replace license header with the correct license (GPLv3+) 2015-04-20 09:59:38 -03:00
koha_perl_deps.pl Bug 17990: Refactor Perl module versions check 2017-02-17 12:13:44 +00:00
kohaversion.pl Bug 13758: Move the Koha version from kohaversion.pl 2015-05-07 11:39:04 -03:00
mainpage.pl Bug 18432 : Follow up - Updating to use they/them 2017-04-21 10:56:43 -04:00
rewrite-config.PL Bug 15427 : Enable TLS support for MySQL 2017-03-03 18:33:07 +00:00

README.md

Koha is a free software integrated library system (ILS).

Koha is distributed under the GNU GPL version 3 or later.

Note: This is a synced mirror of the official Koha repo.

Note: Koha does not accept pull requests from git hosting sites.

Note: This project has its own bug tracker, to report a bug or submit a patch visit http://bugs.koha-community.org.

For guidelines on submitting patches for Koha please visit https://wiki.koha-community.org/wiki/SubmitingAPatch

The developers handbook can be found at https://wiki.koha-community.org/wiki/Developer_handbook

http://koha-community.org/

Koha Logo