Summary: | Plack restart should clear orphaned cgi_compile directories on restart | ||
---|---|---|---|
Product: | Koha | Reporter: | Nick Clemens (kidclamp) <nick> |
Component: | Architecture, internals, and plumbing | Assignee: | Bugs List <koha-bugs> |
Status: | NEW --- | QA Contact: | Testopia <testopia> |
Severity: | normal | ||
Priority: | P5 - low | CC: | dcook, JBoyer, jonathan.druart, kyle, m.de.rooy, martin.renvoize, tomascohen |
Version: | Main | ||
Hardware: | All | ||
OS: | All | ||
Change sponsored?: | --- | Patch complexity: | --- |
Documentation contact: | Documentation submission: | ||
Text to go in the release notes: | Version(s) released in: | ||
Circulation function: | |||
Attachments: | Bug 24749: Attempt to use tmp_path from koha-conf for TMPDIR for starman |
Description
Nick Clemens (kidclamp)
2020-02-27 18:16:06 UTC
Related error code: Error in tempfile() using template /tmp/cgi_compile_2076/cgi_compile_XXXXX.pm: Could not create temp file /tmp/cgi_compile_2076/cgi_compile_gNjo5.pm: Permission denied at /usr/share/perl5/CGI/Compile.pm line 181. Created attachment 109826 [details] [review] Bug 24749: Attempt to use tmp_path from koha-conf for TMPDIR for starman The issue described on this bug is triggered when a process ID is reused, but the directory belongs to another koha instance on the same server To mitigate this issue we attemtped to force plack to use an instance specific TMPDIR as CGI::Compile simply uses File::Spec::tmpdir to decide where to compile files If the folder belongs to the instance then we shouldn't have permissions issues Sadly these patches, while brilliant, do not work Attaching in the hopes someone even more brilliant can complete the work Time for containers, Nick ? That's an interesting one. I would say that's a CGI::Compile bug/issue. Looking at https://metacpan.org/release/CGI-Compile/source/lib/CGI/Compile.pm, it's sad that they use File::Temp for the temporary file but not for the temporary directory. Bizarre. It looks like you're setting TMPDIR in the Plack middleware, but that's probably only going to be relevant to the PSGI application rather than the Plack code around it. I'd suggest setting TMPDIR in /etc/koha/plack.psgi. You should be able to call C4::Context->temporary_directory there. Comment on attachment 109826 [details] [review] Bug 24749: Attempt to use tmp_path from koha-conf for TMPDIR for starman Review of attachment 109826 [details] [review]: ----------------------------------------------------------------- ::: Koha/Middleware/SetEnv.pm @@ +96,5 @@ > } @setenv_headers; > > + $setenvs{TMPDIR} = C4::Context->temporary_directory; > + # See bug 24749 > + I don't think CGI::Compile will see this, as this'll be set in the PSGI application I think. ::: debian/scripts/koha-plack @@ +84,5 @@ > [ -z $PLACK_MAX_REQUESTS ] && PLACK_MAX_REQUESTS="50" > PLACK_WORKERS=$(run_safe_xmlstarlet $instancename plack_workers) > [ -z $PLACK_WORKERS ] && PLACK_WORKERS="2" > + KOHATMPDIR=$(run_safe_xmlstarlet $instancename tmp_path) > + [ -z $KOHATMPDIR ] || TMPDIR=$KOHATMPDIR You need to export TMPDIR here. Otherwise, it's just going to be localized to this script. (But really you could just define it in plack.psgi instead, which would be a more robust solution for different deployments.) You can see this by how KOHA_CONF and PERL5LIB are exported in koha-plack. |