From efc28dfeff625dffdc3e08de3cff980bd9b109a9 Mon Sep 17 00:00:00 2001 From: Jacek Ablewicz Date: Thu, 11 Dec 2014 14:11:44 +0100 Subject: [PATCH] [SIGNED OFF] Bug 13431 - Shared FastMmap file causes issues Koha::Cache package does not take into account that, when using fastmmap caching variant, mmaped cache file created in /tmp (typically: /tmp/sharefile-koha-koha), would only be further accessible to the one given OS user - the one which created it. In many Koha setups, in the circumstances when various system scripts are executed by 2+ users with diffrent UIDs (like multi-tenant servers, for example) this may cause many kinds of issues. Observable symptom is usually the appearance of the below error when searching, or looking at MARC Framework pages and a few other places: Open of share file /tmp/sharefile-koha-koha failed: Permission denied at /usr/lib/perl5/Cache/FastMmap.pm line 640. This patch adds the ID of the OS user to the mmaped file name created in /tmp, to prevent such kinds of conflicts and/or permission problems from happening. To test: 1) remove the /tmp/sharefile-koha-* file[s] (if any) 2) do something which would lead to its re-creation (e.g., performing any search in OPAC should be sufficient to cause that) 3) observe that /tmp/sharefile-koha-koha got created 4) remove it 5) apply patch 6) redo step 2) 7) observe that file created in /tmp now does have the OS user id included in it's name (e.g. it would be named like that 'sharefile-koha-koha-www-data' - depending on the particular test setup) 8) add some additional user to the /etc/passwd, with the same UID www-data has, but with different name (e.g. 'www-data2'); redo the tests; ensure that it still works fine in such unusual case Signed-off-by: Tomas Cohen Arazi --- Koha/Cache.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Koha/Cache.pm b/Koha/Cache.pm index 1638324..a8efc31 100644 --- a/Koha/Cache.pm +++ b/Koha/Cache.pm @@ -161,7 +161,7 @@ sub _initialize_fastmmap { my ($self) = @_; $self->{'fastmmap_cache'} = Cache::FastMmap->new( - 'share_file' => "/tmp/sharefile-koha-$self->{'namespace'}", + 'share_file' => "/tmp/sharefile-koha-".$self->{'namespace'}."-".getpwuid($>), 'expire_time' => $self->{'timeout'}, 'unlink_on_exit' => 0, ); -- 1.9.1