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

safe mode or chmod errors

 
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
arlind
Smarty Rookie


Joined: 12 Apr 2008
Posts: 8

PostPosted: Thu Apr 24, 2008 9:44 am    Post subject: safe mode or chmod errors Reply with quote

Hi,

I get this error when I have installed civiCRM with Smarty included:
Code:
# user warning: Smarty error: problem writing temporary file '/hsphere/local/home/####.dk/civicrm/files/civicrm/templates_c/en_US/en_US/wrt4800bf35b1244' in /hsphere/local/home/####.dk/civicrm/sites/all/modules/civicrm/packages/Smarty/Smarty.class.php on line 1097.
# warning: Smarty::include(): Unable to access /hsphere/local/home/####.dk/civicrm/files/civicrm/templates_c/en_US/en_US//%%06^069^0693F89E%%drupal.tpl.php in /hsphere/local/home/####.dk/civicrm/sites/all/modules/civicrm/packages/Smarty/Smarty.class.php on line 1267.

continues...


I have read a lot of the support topics, and I have tried most of them but still I get the same error.

My problem seems to be that my directories need to be chmod 777, but smarty changes the chmod to 755 and owner to httpd (php). When chmod changes smarty can not write temp files any more.

my php settings:
open_basedir is off
safe_mode is on
wsb11 .surftown .dk/phpinfo.php

I have tried this:

define('SMARTY_DIR', absolute path)
var $compile_dir = absolute path
var $use_sub_dirs = false;

Changing these settings has no effect:
* default file permissions
var $_file_perms = 0600;

* default dir permissions
var $_dir_perms = 0755;

for more errors see forum .civicrm .org/index.php/topic,2821.0.html

How can I stop smarty from changing chmod?

thanks Smile
Bo
Back to top
View user's profile Send private message
messju
Administrator


Joined: 16 Apr 2003
Posts: 3336
Location: Oldenburg, Germany

PostPosted: Thu Apr 24, 2008 1:13 pm    Post subject: Reply with quote

Smarty does not "change the owner", but Smarty may create directories and if so, these directories inherit the ownership of the running Process (httpd in your case). If you are running safe_mode Smarty must not create any directories so you have to turn use_sub_dirs off and chown templates_c to the same owner as your index.php (or whatever php file the client requests) and make templates_c writable for the httpd-user (via chmod 777 or via group-owenerships and -rights).

I'm pretty sure Smarty's chmodding of the files is not the source of your problems.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
arlind
Smarty Rookie


Joined: 12 Apr 2008
Posts: 8

PostPosted: Thu Apr 24, 2008 2:12 pm    Post subject: Reply with quote

Hi,

This is what I have done several times when trying new settings (see my first post).

Owner and chmod do change - not at first but later.

These files are created without any changes, and later deleted - changes first occur when I visit "Payment Processors" or other pages:

Code:
-rw-r--r--   1 httpd    httpd        4513 Apr 10 22:01 %%02^029^029CEF80%%footer.tpl.php
-rw-r--r--   1 httpd    httpd        4350 Apr 10 22:01 %%06^069^0693F89E%%drupal.tpl.php
-rw-r--r--   1 httpd    httpd        4370 Apr 10 22:01 %%7A^7A5^7A517D90%%DashBoard.tpl.php
-rw-r--r--   1 httpd    httpd         817 Apr 10 22:01 %%91^919^91975F02%%Menu.tpl.php
-rw-r--r--   1 httpd    httpd         193 Apr 10 22:01 %%93^938^938D45F8%%Subject.tpl.php
-rw-r--r--   1 httpd    httpd        1315 Apr 10 22:01 %%93^93A^93AD3FA7%%recentlyViewed.tpl.php
-rw-r--r--   1 httpd    httpd         546 Apr 10 22:01 %%A6^A67^A6754B0A%%Shortcuts.tpl.php
-rw-r--r--   1 httpd    httpd        3380 Apr 10 22:01 %%B7^B75^B75FFEFA%%Add.tpl.php
-rw-r--r--   1 httpd    httpd         311 Apr 10 22:01 %%B7^B79^B79FF491%%dojo.tpl.php
-rw-r--r--   1 httpd    httpd        2128 Apr 10 22:01 %%C6^C6B^C6B24099%%status.tpl.php
-rw-r--r--   1 httpd    httpd        2794 Apr 10 22:01 %%E9^E9D^E9D18D1B%%Search.tpl.php
-rw-r--r--   1 httpd    httpd        8079 Apr 10 22:01 %%F0^F04^F047BD97%%Activity.tpl.php
-rw-r--r--   1 httpd    httpd         120 Apr 10 22:01 %%F0^F0F^F0F71C33%%version.tpl.php


Maybe Smarty deletes the directory, and creates a new one?

thanks for looking into this problem Smile
Bo
Back to top
View user's profile Send private message
messju
Administrator


Joined: 16 Apr 2003
Posts: 3336
Location: Oldenburg, Germany

PostPosted: Thu Apr 24, 2008 2:42 pm    Post subject: Reply with quote

The files look ok to me. But more relevant (regarding safe_mode restrictions) is the directory containing these files.

http://php.net/manual/en/features.safe-mode.functions.php
"fopen() - Checks whether the directory in which the script is operating has the same UID (owner) as the script that is being executed."
Back to top
View user's profile Send private message Send e-mail Visit poster's website
arlind
Smarty Rookie


Joined: 12 Apr 2008
Posts: 8

PostPosted: Fri May 02, 2008 1:48 pm    Post subject: Reply with quote

messju wrote:
"fopen() - Checks whether the directory in which the script is operating has the same UID (owner) as the script that is being executed."


Hi,

Thanks for the tip Smile

I have changed the owner to httpd and chmod to 777 via php, but I still get the same errors...

Code:
# user warning: Smarty error: problem writing temporary file '/civicrm/files/civicrm/templates_c/en_US/en_US/wrt481b102a63e03' in /civicrm/sites/all/modules/civicrm/packages/Smarty/Smarty.class.php on line 1097.
# warning: Smarty::include(): Unable to access /civicrm/files/civicrm/templates_c/en_US/en_US//%%93^938^938D45F8%%Subject.tpl.php in /civicrm/sites/all/modules/civicrm/packages/Smarty/Smarty.class.php on line 1267.


The 0 kb files smarty creates are set to chmod 600 - should it not be 777 as I have set it to?

* default file permissions
var $_file_perms = 0777;

* default dir permissions
var $_dir_perms = 0777;

Smile Bo
Back to top
View user's profile Send private message
arlind
Smarty Rookie


Joined: 12 Apr 2008
Posts: 8

PostPosted: Tue May 06, 2008 11:32 am    Post subject: Reply with quote

arlind wrote:
The 0 kb files smarty creates are set to chmod 600 - should it not be 777 as I have set it to?

* default file permissions
var $_file_perms = 0777;

* default dir permissions
var $_dir_perms = 0777;


mkdir seems to ignore chmod 777 - if I make my own php, I have to add a chmod:

Code:
mkdir ( $dircreate , 0777 );
chmod ( $dircreate , 0777 );


I think this is the same with files - that smartys $_file_perms is ignored unless there is an extra chmod.

Where should I add the extra chmod in smarty?

Thanks Smile Bo
Back to top
View user's profile Send private message
messju
Administrator


Joined: 16 Apr 2003
Posts: 3336
Location: Oldenburg, Germany

PostPosted: Tue May 06, 2008 12:13 pm    Post subject: Reply with quote

arlind wrote:
mkdir seems to ignore chmod 777 - if I make my own php, I have to add a chmod:


see http://php.net/manual/en/function.mkdir.php and http://php.net/manual/en/function.umask.php
Back to top
View user's profile Send private message Send e-mail Visit poster's website
messju
Administrator


Joined: 16 Apr 2003
Posts: 3336
Location: Oldenburg, Germany

PostPosted: Tue May 06, 2008 12:23 pm    Post subject: Reply with quote

additionally: smarty uses http://php.net/tempnam to create files. you should make this work to make wrtiting files work.

and also '/civicrm/files/civicrm/templates_c/en_US/en_US/wrt481b102a63e03'
makes me wonder if the "en_US/en_US/" is the compile_id and the cache_id. if so you don't seem to have use_sub_dirs disabled which is a must to run in safe_mode.

and also:
you still didn't understand safe_mode restrictions. you must not own the templates_c to the user httpd, but to the same owner of the php-file you are requesting. in safe_moce php is only allowed to write into directories that have the same owner as the running script. (in addition to the restrictions the underlying operating system gives to read- and write-permissions)
Back to top
View user's profile Send private message Send e-mail Visit poster's website
arlind
Smarty Rookie


Joined: 12 Apr 2008
Posts: 8

PostPosted: Tue May 06, 2008 2:43 pm    Post subject: Reply with quote

hmm...

Maybe we are focusing on the wrong problem. I tested once more with the normal settings and smarty writes and runs php files without any problems (as I wrote before).

But suddenly the owner and chmod of en_US changes, and the errors begins.

It looks as if en_US is deleted and created once more with the wrong settings.

Smarty.class.php:
var $use_sub_dirs = false; (it is set by default with CiviCRM)
var $compile_dir = '###.dk/civicrm/files/civicrm/templates_c';

Thanks
Bo
Back to top
View user's profile Send private message
arlind
Smarty Rookie


Joined: 12 Apr 2008
Posts: 8

PostPosted: Tue May 06, 2008 8:26 pm    Post subject: Reply with quote

arlind wrote:
It looks as if en_US is deleted and created once more with the wrong settings.


drwxrwxrwx 2 arlind arlind 6 May 6 19:54 en_US

changes to

drwxr-xr-x 2 httpd httpd 150 May 6 20:06 en_US

only when I visit a page under Global Settings in CiviCRM on a Drupal installation. Everything else seems to work perfect Smile

Can CiviCRM trigger Smarty to replace the directory? Or is it smarty acting alone?

thanks for Your time and help Very Happy
Bo
Back to top
View user's profile Send private message
messju
Administrator


Joined: 16 Apr 2003
Posts: 3336
Location: Oldenburg, Germany

PostPosted: Wed May 07, 2008 7:15 am    Post subject: Reply with quote

Smarty doesn't replace any directories.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
arlind
Smarty Rookie


Joined: 12 Apr 2008
Posts: 8

PostPosted: Sat May 10, 2008 6:38 pm    Post subject: Reply with quote

Strange, but it looks like CiviCRM replaces Smartys directory:
http://forum.civicrm.org/index.php/topic,3318.0.html

Thanks for Your help and effort Very Happy

Bo
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