Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

How to make smarty compile templates with groupwritableperms

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Installation and Setup
View previous topic :: View next topic  
Author Message
ben@bias-inc.com
Smarty n00b


Joined: 14 May 2010
Posts: 2

PostPosted: Fri May 14, 2010 10:49 pm    Post subject: How to make smarty compile templates with groupwritableperms Reply with quote

Hello! I've got my server set up like so (on linux):

drwxr-xr-x 2 www-admin www-data 4096 2007-01-22 10:25 cache
drwxr-xr-x 2 www-admin www-data 4096 2007-01-22 10:25 configs
drwxr-xr-x 2 www-admin www-data 4096 2010-05-14 15:29 templates
drwxrwxr-x 2 www-admin www-data 4096 2010-05-14 15:29 templates_c


I want the file permissions like this, apache runs as www-data. Only www-admin can write files, and I selectively apply write perms to www-data as necessary. The problem is that smarty is outputting templates like this:

ls -l templates_c

-rwxr--r-- 1 www-admin www-data 123 2008-06-18 10:15 %%0E^0E4^0E407559%%footer.tpl.php
-rwxr--r-- 1 www-admin www-data 4292 2008-08-12 17:02 %%41^416^416864CF%%help.tpl.php
-rwxr--r-- 1 www-admin www-data 13780 2009-09-22 11:15 %%45^45E^45E480CD%%index.tpl.php
-rwxr--r-- 1 www-admin www-data 2139 2008-08-06 10:02 %%51^510^510D3403%%testing-index.tpl.php
-rwxr--r-- 1 www-admin www-data 4767 2008-09-17 15:42 %%F7^F7F^F7F34188%%header.tpl.php

And thusly, when I edit one of my templates, smarty is unable to recompile it and overwrite the old compiled template.

Is there any way to configure smarty to set the compiled templates to be group-writable?

While I'm here I have to say smarty is an amazing product, NICE WORK!!!!!!!
Back to top
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Fri May 14, 2010 11:16 pm    Post subject: Reply with quote

in linux:

Code:
chmod g+w <dirname>


will give group write access.
Back to top
View user's profile Send private message Visit poster's website
ben@bias-inc.com
Smarty n00b


Joined: 14 May 2010
Posts: 2

PostPosted: Fri May 14, 2010 11:45 pm    Post subject: Reply with quote

well i do understand that and the 'templates_c' directory is already chmodded that way but the individual ".tpl.php" files within that directory are being created by smarty as "-rwxr--r--" . I'd prefer that they get written as "-rwxrw-r--", because they way it is now I have to manually delete the compiled templates when I change a template.
Back to top
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Fri May 14, 2010 11:58 pm    Post subject: Reply with quote

gotcha. Smarty has these properties on its class:

Code:
    // default file permissions
    public $_file_perms = 0644;
    // default dir permissions
    public $_dir_perms = 0771;


You probably want 0664 on the files.
Back to top
View user's profile Send private message Visit poster's website
giotto
Smarty n00b


Joined: 05 Dec 2006
Posts: 2
Location: Bremen, Germany

PostPosted: Tue Sep 13, 2011 8:24 am    Post subject: Reply with quote

mohrt wrote:
gotcha. Smarty has these properties on its class:

Code:
    // default file permissions
    public $_file_perms = 0644;
    // default dir permissions
    public $_dir_perms = 0771;


You probably want 0664 on the files.


While fiddling with $_file_perms will work, changing $_dir_perms doesn't work as I'd expect, at least with smarty 2.6.26 it doesn't. The directories created in the $compile_dir are not group-writable no matter how $_dir_perms is set.

I would really like to customize the directory permissions for when smarty is writing to $compile_dir, to make the directories group-writable. Is this perhaps possible with smarty 3.x?

For those wondering why I am asking for this, I would like to execute $smarty->clear_compiled_tpl('xxxxx.tpl') as a different user as the one who wrote the compiled template to file, both users are in the same group however. How did this happen you ask? The user writing the compiled template is a webserver with $compile_check set to FALSE and the user running clear_compiled_tpl() would be me through a git hook script for deployment purposes.
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Installation and Setup All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP