File permissions
|
tonysab
Joined: 2004-11-03
Posts: 44 |
Posted: Wed, 2008-10-29 15:27
|
|
Can somebody please confirm what file permissions should be set at folder and file level within g2data? |
|

Posts: 16503
Depends on how your server is setup. Does Apache or PHP run as your user account? If so, you can set directories to 700 and files to 600. If not, then g2data should be 777 and then Apache/PHP will create the other directories and files as 755/644 (respectively)
http://codex.gallery2.org/Gallery2:Security
____________________________________________
Like Gallery? Like the support? Donate now!!! See G2 live here
Posts: 44
Thanks, is it a security risk though having g2data as 777, even though it is outside of the web root?
Posts: 16503
If Apache or PHP don't run as your user account, it's the only way for Gallery to write to that directory. Any file or directory it creates will be set to 644 (files) or 755 (directories) by default and only the webserver user will be able to change them.
It's not a huge risk, but if on a shared server, then depending on how the server is configured, someone malicious could at least read and copy what's there and if the files are owned by the webserver, then again depending how the server is configured, someone could possibly run a script from their site and modify/delete files there.
If Apache or PHP run as your user account then you can secure things pretty tightly:
http://codex.gallery2.org/Gallery2:Security#Learn_the_Basics_about_your_Webserver
http://codex.gallery2.org/Gallery2:Security#Restricting_Read_.26_Write_Access_to_Gallery_2_Files_and_Directories
On my server, PHP can be ran in a php-cgiwrap mode, making it run under your user account. I'm a bit overly paranoid, so on my production site I have the permissions set pretty tight. Absolutely nothing can change any files, even myself, without opening up some permissions. Basically the gallery portion of the site is set in stone until I deliberately make a change. Which makes it a total pain when/if I want to modify anything (like themes, adding plugins, etc) but prevents any script, or even the server itself from modifying any files. Only an exploit that was able to run arbitrary code and change file permissions would be able to make changes.
My g2data and all directories are set to 700, all files are set to 600. g2data is also outside of the webroot.
Here is how I have my gallery install set, which is probably a bigger pain than most want to deal with:
____________________________________________
Like Gallery? Like the support? Donate now!!! See G2 live here