[Templates] permission-problems with cache : dir-mod wrong !

Andrew Ford A.Ford@ford-mason.co.uk
Tue, 30 May 2006 13:38:26 +0100


I had a related problem.  Cache files are created readable only by the
user the process is running as.  This is a consequence of the use of
File::Temp to create the cache files, but it means that cache
directories cannot be shared between different users, even if they are
in the same group and set umask appropriately.  I was bitten by this
when running the perl debugger on a web application that used Template
Toolkit: I had created a new template and TT2 cached the compiled
template, but the web application then could not read the cached file.
I get round this now by specifying the cache directory as something like
"/tmp/tt2-cache-$<".  This means that each user gets their own cache and
avoids any interactions between processes using TT2 running as different
users.

Regards
Andrew

peter pilsl wrote:
>
> Since Saturday I suddenly face massive problems with my on-disk-cache.
>
> -------
> file error - cache failed to write index.tt2.ttc: Error in tempfile() 
> using 
> /tmp/tt2/data/apache/knowledge/sandbox/templates/literatur/wienermoderne/XXXXXXXXXX: 
> Could not create temp file 
> /tmp/tt2/data/apache/knowledge/sandbox/templates/literatur/wienermoderne/D0wMRP4DtC: 
> Permission denied at 
> /usr/local/lib/perl5/site_perl/5.8.0/i686-linux/Template/Document.pm 
> line 280 path : literatur/wienermoderne/index.tt2
> -------
>
> compile_dir is '/tmp/tt2'
>
> the funny thing is that, when I completely empty the cache-dir, 
> everything is working fine and suddenly on a random (to me) subfolder 
> the above error occures. When I look at the cache-dir into the 
> problematic folder I can see that there are different permissions set:
>
> # ls -l /tmp/tt2/data/apache/knowledge/sandbox/templates
> total 11
> drwx------    2 httpd139 httpd         224 May 30 10:52 historiografie/
> -rw-------    1 httpd139 httpd        5755 Feb  7 09:34 index.tt2.ttc
> drw-rw-rw-    2 httpd139 httpd          48 May 30 11:00 literatur/
> drwx------    3 httpd139 httpd         416 May 30 10:59 medienpreise/
> drwx------    2 httpd139 httpd         424 May 30 10:59 navigation/
> drwx------    2 httpd139 httpd         312 May 30 10:47 startseite/
>
> for some wicked reason the folder literatur has a complete different 
> mod set. It lacks the X-permission and so the toolkit cannon create 
> subfolders.  When I perform a chmod -R 700 * on the whole cache 
> everything is working fine for a while again.  (and I dont want to 
> chmod 700 the compiled files themselves :)
>
> I dont have any clue what causes this problem. And I didnt find any 
> config-option that allows me to fix the creation-mode.
>
> Any idea?
> thnx,
> peter
>
> ps: using Template-Toolkit 2.08
>
>
>
>
>
>
>

-- 
Andrew Ford,  Director    Pauntley Prints / Ford & Mason Ltd
A.Ford@ford-mason.co.uk   South Wing Compton House
pauntley-prints.co.uk     Compton Green, Redmarley  Tel: +44 1531 829900
ford-mason.co.uk          Gloucester GL19 3JB       Fax: +44 1531 829901
refcards.com cronolog.org Great Britain          Mobile: +44 7785 258278