Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

write to cache with 775/664 permission (not images) #1013

Closed
simonhaenisch opened this issue Aug 30, 2016 · 16 comments
Closed

write to cache with 775/664 permission (not images) #1013

simonhaenisch opened this issue Aug 30, 2016 · 16 comments

Comments

@simonhaenisch
Copy link

Is it possible to setup Grav so that the files created in the cache folder have 775/664 permissions instead of 755/644? I know it's possible to set it for images, but I haven't found an option for normal file cache.

I use a setup where PHP runs as www-data user and my user (for ssh) is in the www-data group. All folders have 775 and files have 664. That way I can use GPM from either the admin panel or command line.

But when Grav writes some files to cache with 755/644 permissions, I can't use bin/gpm via command line until I fix the permissions of the cache directory. (I can use it, but I get permission errors when trying to install something)

@rhukster
Copy link
Member

Have you set the 'sticky bit' (+s) and umask as per? https://learn.getgrav.org/troubleshooting/permissions#different-accounts-fix-permissions-manually

@mahagr
Copy link
Member

mahagr commented Aug 31, 2016

I think we could add configuration setting for umask? Generally I would do this in PHP configuration, though.

@simonhaenisch
Copy link
Author

simonhaenisch commented Aug 31, 2016

I think I did the +s but not the umask. I'll try it, thanks. But isn't umask just for the current session & user?

@simonhaenisch
Copy link
Author

I just got into this again and I don't think that the sticky bit or umask will solve my issue here.

The sticky bit makes sure that only the owner (me) can delete/rename files in a folder. I don't really see a reason to use it in this case as I'm not in a multi-user environment and don't have to worry about anyone messing with my files.

umask is only valid for the current session. To make it permanent I would have to set it in my .bashrc (which I already have). Could be useful to mention that in the docs. Anyway that is only for the files that I create with my user, but not for the files created by Grav/PHP.

I can set umask 002 in my PHP config like @mahagr suggested, that makes sense.

@pascalrobert
Copy link

We have a similar issue, but with the images folder. Even if I have set the umask to 002 at the file system level, and in Apache, new directories in images are created with 755 instead of 775.

@Perlkonig
Copy link
Contributor

Ditto, @pascalrobert. I haven't figured out whether it's a problem with my hosting setup or with Grav itself. No matter how I set umask, the contents of my images folder are always 755.

@pascalrobert
Copy link

Even with ACLs, when the folders are recreated, the effective rights don't have write permissions.

@rhukster
Copy link
Member

rhukster commented Nov 1, 2016

Can you try somethign for me:

Create a file called setup.php in the root of your Grav install (alongside index.php) and put this:

<?php
umask(0002);

if you already have a setup.php, just add it to the top. This file should get picked up and used for every Grav call.

@rhukster
Copy link
Member

rhukster commented Nov 1, 2016

BTW, i'm assuming you have already tried the optional user/config/system.yaml setting:

images:
  cache_perms: '0775' 

@pascalrobert
Copy link

cache_perms: '0775' was already set. Tried the trick with setup.php, didn't work.

I do notice something strange:

images/0# umask -S
u=rwx,g=rwx,o=rx

So umask is right, but:

images# ls -l
drwxr-xr-x 3 www-data www-data 4096 nov 2 09:40 0

Permissions are not what umask says it should be. This is on Ubuntu 12.04, the site is running under a LXC container.

@Perlkonig
Copy link
Contributor

Doh! How did I not know about cache_perms? That appears to have fixed it! The umask in setup.php didn't work. Thanks!

@axelf
Copy link

axelf commented Apr 8, 2017

HI,

is there any solution with the cache files? I have the same issue like @simonhaenisch and all solutions from the docs do not work (except running apache under the same user like the ssh user, but thats not an option for me). Cache files created by grav have only 644 and 755 permissions

@rhukster
Copy link
Member

rhukster commented Apr 8, 2017

Did you try the setup.php solution i posted above?? How about the cache_perms option in system.yaml??

@axelf
Copy link

axelf commented Apr 8, 2017

@rhukster thank you, now it is working. I thought the setup.php was for the images :-) I searched 2 days for a solution, but now problem solved. Thank you again for the hint.

Could this be added to the documentation? In my opinion simple and nice solution

@rhukster
Copy link
Member

rhukster commented Apr 9, 2017

I have it i the list of topics to document: getgrav/grav-learn#356

@flaviocopes
Copy link
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants