Tomás Cohen Arazi <tomasco...@gmail.com> changed:
What |Removed |Added
Attachment #63677|0 |1
is obsolete| |
--- Comment #53 from Tomás Cohen Arazi <tomasco...@gmail.com> ---
Created attachment 72368
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 . 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. 
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
- Create a /tmp/test.pl file containing:
my $dir = getcwd;
A) then create a cronjob entry to run it using koha-foreach:
1/* * * * * root koha-foreach perl /tmp/test.pl
- Once I noticed the cronjob ran, I used mutt to read the emails in the
Subject: Cron <root@koha> koha-foreach --enabled perl /tmp/test.pl
B) I then used the patched koha-foreach with different results:
Subject: Cron <root@koha> /root/koha-foreach --chdir --enabled perl
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
You are receiving this mail because:
You are watching all bug changes.
Koha-bugs mailing list
website : http://www.koha-community.org/
git : http://git.koha-community.org/
bugs : http://bugs.koha-community.org/