[Catalyst] Cached TT w/mod_perl issue? Or just a Toby-bug?

Toby Corkindale tjc at wintrmute.net
Fri Sep 23 16:46:17 CEST 2005


Hi, I just wondered if anyone had any thoughts on the below problem?
It basically just comes down to this issue:
1) apache w/mod_perl starts up, running as root, and initialises some parts of
the Catalyst system.
2) TT's cache directory is created as root, and a tree is created underneath
it, also owned by root.
3) Apache setuid()s to the apache user
4) Catalyst can no-longer write to the TT cache directory, as it has
insufficient permissions.


I can work around this by doing a chown apache of the Catalyst cache dir
during startup, but this seems poor form.. Plus requires to know what the
apache user's name is in advance, which potentially varies between
distributions.

Is there a more sensible way to do this?

Note that using $> doesn't work, as you have already set the TT cache dir in
the config during the initialisation as root (euid=0), before the setuid
occurs.

thanks,
Toby

On Tue, Sep 06, 2005 at 11:33:55AM +0100, Toby Corkindale wrote:
> Hi,
> I followed the instructions at
> http://dev.catalyst.perl.org/wiki/IncreaseTTPerformance
> to enable TTs caching of templates with the XS stash module.
> (I also added a line to create the directory if it doesn't exist.)
> 
> I'm running Catalyst under mod_perl. After restarting apache, I see it has
> created the directory (in /tmp/) as *root*, not Apache.
> 
> When I try to view any TT templates via my Catalyst app, it fails - the
> relevant error being:
> [catalyst] [error] Couldn't render template "mkdir /tmp/diesel_cache//home/tobyc/svn/DieselCatalyst/templates/cult: Permission denied at /usr/lib/perl5/vendor_perl/5.8.6/i686-linux/Template/Provider.pm line 844
> 
> However it has managed to build a small tree under that directory, namely:
> /tmp/diesel_cache/home/tobyc/svn/DieselCatalyst/templates/base/
> These directories are also owned by root.
> 
> I ran "chown -R apache:apache /tmp/diesel_cache" to make everything owned by
> apache, and this solved the problem. Templates render.
> 
> I am guessing this is related to Apache running some initial startup stuff as
> root, before it swaps over to the apache user. Is there a way around this to
> provide a more elegant solution than just chown-ing the cache structure after
> the first failure?
> (I tried creating the /tmp/diesel_cache directory as owned by Apache, but the
> subtree was still created as being owned by root)
> 
> Thanks,
> Toby
> 

-- 
Turning and turning in the widening gyre/The falcon cannot hear the falconer;
Things fall apart, the centre cannot hold/Mere anarchy is loosed upon the world
(gpg --keyserver www.co.uk.pgp.net --recv-key B1CCF88E)



More information about the Catalyst mailing list