Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Hell0

We (our company) has been using one CMS for several websites that we have created. We have encountered this particular problem several times now and we cant think of a fix for it.

Here's the description of the problem: In this cms there is possible to create picture galleries. When you create folder for gallery via CMS then folder is beeing created by www user and its permissions are set to 0666. When user uploads pictures to this gallery using its editor view, then the pictures are uploaded to previously created folder and cut into necessary sizes. .thumbnails and other folders are created to hold pictures of different sizes.

If you create folder for gallery via ftp, then the owner of the gallery is ftp user. If you manually set permissions to 0666 and upload the files with correct permissions, everything seems to be fine. Now in the public view, if you choose this previously created folder as your gallery folder, the cms fails to create .thumbnail subdirectory (and other required subdirectories also). The only difference between the folders is the owner of the folders.

Right now i am trying to get my hands on this hosting accounts php log. I guess i will have more information then.

Alan

share|improve this question

migrated from stackoverflow.com Aug 21 '09 at 0:50

This question came from our site for professional and enthusiast programmers.

add comment

5 Answers

up vote 2 down vote accepted

You need execute permission to enter a directory in Linux. So you need to set the permission to 7 (rwx) for the web user to enable it to create subdirectories.

Actually, to create subdirs, a user only needs wx privileges on a directory. To be able to fully list the content of the directory, a user needs rx priviliges. To cd into a directory, you definitely need x.

share|improve this answer
    
In one case going from 0666 to 0777 it helped indeed. In another case, i think, the problem lies elsewhere and deeper investiagtion is required. Thank you everybody! –  Zayatzz Aug 19 '09 at 12:56
add comment

I would try adding apache and the ftp user to same group (usually www-data), this would probably solve this

share|improve this answer
add comment

To make this work, you'll have to share a group between the WWW user and the FTP user something like contentusers. Then you'll have to change the group of the folder to the new contentusers group and set the "SetGID" bit on the directory to (see more http://www.greenend.org.uk/rjk/2004/perms.html ). New files will be created with the proper group.

share|improve this answer
    
So what you are telling me is that, it does not matter what permissions are given to the 'other' user. Be it r, rw, rwx or so on. If the users are not in the same group, then php(www user) cannot create subdirectories there, because they will be owned by that user, and they are from different group? –  Zayatzz Aug 19 '09 at 12:36
add comment

0666 are pretty bad permissions for directories as you need the --x--x--x bit to let somebody change into that directory. 0777 would be more appropriate (apart from the fact that 0777 is only appropriate for a temporary directory and even then it should rather by 2777 for that sticky bit).

share|improve this answer
add comment

i fixed similar problem with collabtive project management software, you just need to find the class with a method that creates the folders... this could be easy if the code is well commented...

bool mkdir  ( string $pathname  [, int $mode= 0777  [, bool $recursive= false  [, resource $context  ]]] )

As you can see in this simple explanation of the make dir method (found at www.php.net), when you find it, you'll just need to change the $mode var in your desired value...

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.