Body: <p>I always set my file permissions under the templates_c folder like in the <a href="https://civicrm.stackexchange.com/questions/168/are-there-recommended-directory-ownership-and-permission-settings-for-civicrm-fi">Question</a> to username:www-data and the permissions to 770. It runs fine on other systems, but I have a system which is only runs fine until there appear more cached stuff in the folder. The new files have strange combinations of ownership like username:username or www-data:www-data. Also they have the wrong permissions set. The username:username get 664 the www-data:www-data 644.</p>
  <p>Now i tried to set the ownership of my folder to username:www-data with 770. Then webinterface of civicrm doesnt work. If i set the folder to www-data:www-data the system works, but the civicrm related cronjobs from username doesnt work.</p>
  <p>Is there a superior file permission i dont see here, but is correct on my other systems? I always do the same stuff like in the link suggested when i set my permissions. I cant get to the point why the system has this strange behavior, all because of a template cache.</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-10-15T12:07:57.620Z
Comments.Text: You might have a cron script that runs as `username`. If possible set the cron script to run as `www-data`.
Comments.UserDisplayName: Demerit
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-10-16T10:06:45.697Z
Comments.Text: But isnt the `www-data` the apache-"user"? The `username` is the "owner" and "manager" of the crm. Why cant i logically divide the roles like that?
Comments.UserDisplayName: gzwg
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-10-16T18:02:24.150Z
Comments.Text: The `www-data` apache "user" needs write access to everything in templates_c. If `username` creates a file/folder in there and `www-data` doesn't also have write access to it, you get fails.
Comments.UserDisplayName: Demerit
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-10-17T07:36:14.443Z
Comments.Text: Yes, but thats the reason why i set the whole folder to `username:www-data` and the permissions to 770 so that when there is a new folder or file, it doesnt have to be a problem, or do i understand you wrong?
Comments.UserDisplayName: gzwg
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-10-17T12:33:56.340Z
Comments.Text: For that to work though you would need to put the two users in the same group, or start messing with umask and setuid bits. Currently and NEW subfolders/files created by one user will not be writable by the other.
Comments.UserDisplayName: Demerit
Tags: <permissions><cron><templates><cache><webserver>
Title: Problems with file permission and ownership at civicrm/templates_c
ThreadText: # Problems with file permission and ownership at civicrm/templates_c
  
  (Asked by: username_0 on 2022-10-15)
  
  I always set my file permissions under the templates\_c folder like in the [Question](https://civicrm.stackexchange.com/questions/168/are-there-recommended-directory-ownership-and-permission-settings-for-civicrm-fi) to username:www-data and the permissions to 770. It runs fine on other systems, but I have a system which is only runs fine until there appear more cached stuff in the folder. The new files have strange combinations of ownership like username:username or www-data:www-data. Also they have the wrong permissions set. The username:username get 664 the www-data:www-data 644.
  
  Now i tried to set the ownership of my folder to username:www-data with 770. Then webinterface of civicrm doesnt work. If i set the folder to www-data:www-data the system works, but the civicrm related cronjobs from username doesnt work.
  
  Is there a superior file permission i dont see here, but is correct on my other systems? I always do the same stuff like in the link suggested when i set my permissions. I cant get to the point why the system has this strange behavior, all because of a template cache.
  
  **Tags:** permissions, cron, templates, cache, webserver
  
  > **Comments:**
  > **username_1**: You might have a cron script that runs as `username`. If possible set the cron script to run as `www-data`.  
  > **username_0**: But isnt the `www-data` the apache-"user"? The `username` is the "owner" and "manager" of the crm. Why cant i logically divide the roles like that?  
  > **username_1**: The `www-data` apache "user" needs write access to everything in templates_c. If `username` creates a file/folder in there and `www-data` doesn't also have write access to it, you get fails.  
  > **username_0**: Yes, but thats the reason why i set the whole folder to `username:www-data` and the permissions to 770 so that when there is a new folder or file, it doesnt have to be a problem, or do i understand you wrong?  
  > **username_1**: For that to work though you would need to put the two users in the same group, or start messing with umask and setuid bits. Currently and NEW subfolders/files created by one user will not be writable by the other.  
  
  ---
  
  ## 0 answers
  
  