Files uploaded through File Manager create folders with 750 permissions (not readable)

Permalink 1 user found helpful
I am having some trouble with folder permissions. I am on a sharing hosting environment with Network Solutions. When I upload files through the file manager, those files get inserted into dynamically generated folders with the permissions set to 750. NS claims that there is no way to change this due to the shared hosting environment. I can reset the folder permissions through their file manager, but of course, that's a bit of a hassle. I ran across another issue with NS when I was trying to use the opti-MISER plugin and the creator of that bit of awesome scripting was able to write some code into a function to chmod the folder permissions but I would have no idea on how to apply this to this situation. If anyone have some ideas let me know!

shondy
 
jero replied on at Permalink Reply
jero
I'd guess it's not a case of "can't", more a case of "won't". I'd guess that they're running the Apache suPHP module in its default state, with the umask too tight.

This is a bit of a bodge, but it seems to work.
Edit your config/site.php and append the following line:

umask(022);


More details on how to use this function:
http://php.net/manual/en/function.umask.php...

This should ensure that your uploaded files, and indeed **all files and folders created by c5** end up being 644/rw-r--r-- or 755/rwx-r-x-r-x (folders) and therefore readable by the world - which in the case of files served by Apache is what your want.

It may not be ultimately desirable to do this if you're paranoid about security - caveat emptor and all that, but it works, or at least it did when I just tried it.
shondy replied on at Permalink Reply
shondy
Not particularly worried about security on this particular site, and by the looks of things that seems to have worked. I don't suppose upgrading to 5.5 will change anything? Since it appears to be the server and not C5.

I really appreciate the help!
jero replied on at Permalink Reply
jero
I wouldn't expect 5.5 would be any different, unless its got its own umask setting somewhere, which would override the one in site.php.
site.php is a handy place to stick umask, since it gets referenced pretty early on (like before the db connection is opened!).