From 06ddcea6af7947dae0512b13ac9e03a62744655a Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Fri, 2 Mar 2018 10:36:34 -0300 Subject: [PATCH] Bug 19546: Run starman from the instance's home dir This patch makes koha-plack jump into the instance's home directory to run. It is required because Perl 5.18 introduced a breaking change that makes perl die if @INC includes directories for which the user doesn't have read permission, and need to be traversed when querying for a lib. This is the case of '.', which is introduced automatically into @INC until Perl 5.26 (which removes the 'feature'). The Mojolicious::Plugins lib prefixes the plugin names with 'Mojolicious::Plugin' so it first looks (for example) for Mojolicious::Plugin::Koha::REST::Plugin::Pagination (Pagination is just the first one on the list). When it looks for it at '.' it dies (because of Perl's behaviour) so it doesn't query for the right namespace (the following to try). I only reproduced it in koha-testing-docker. To test, you just need to try this patched koha-plack and make sure it doesn't break due to this permissions issue. To test: - In your koha-testing-docker clone, run: $ docker-compose up -p test - Open a shell inside the container (on a separate terminal): $ docker exec -it test_koha_1 bash - From within the /root directory, restart plack: $ cd /root $ koha-plack --restart kohadev => FAIL: Logs show plack is broken due to permissions problems trying to find Mojolicious::Plugin::Koha::REST::Plugin::Pagination - Use the patched script from this patch: $ /kohadevbox/koha/debian/scripts/koha-plack --restart kohadev => SUCCESS: Plack runs fine, no error in the logs - Sign off :-D Note: people who has environments in which the problems is reproducible, please test this version of koha-plack and stamp your sign-off, PLEASE. --- debian/scripts/koha-plack | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/debian/scripts/koha-plack b/debian/scripts/koha-plack index 186c162de1..f31dadbabd 100755 --- a/debian/scripts/koha-plack +++ b/debian/scripts/koha-plack @@ -85,6 +85,8 @@ start_plack() PLACK_WORKERS=$(run_safe_xmlstarlet $instancename plack_workers) [ -z $PLACK_WORKERS ] && PLACK_WORKERS="2" + instance_user="${instancename}-koha" + environment="deployment" daemonize="--daemonize" logging="--access-log /var/log/koha/${instancename}/plack.log \ @@ -100,7 +102,7 @@ start_plack() fi STARMANOPTS="-M FindBin ${max_requests_and_workers} \ - --user=${instancename}-koha --group ${instancename}-koha \ + --user=${instance_user} --group ${instancename}-koha \ --pid ${PIDFILE} ${daemonize} ${logging} \ -E ${environment} --socket ${PLACKSOCKET} ${PSGIFILE}" @@ -109,11 +111,18 @@ start_plack() log_daemon_msg "Starting Plack daemon for ${instancename}" + # Change to the instance's user dir + current_dir=$(pwd) + eval cd ~$instance_user + if ${STARMAN} ${STARMANOPTS}; then log_end_msg 0 else log_end_msg 1 fi + # Go back to the original dir + cd $current_dir + else log_daemon_msg "Error: Plack already running for ${instancename}" log_end_msg 1 -- 2.16.2