Link to home
Start Free TrialLog in
Avatar of andy7789
andy7789

asked on

dir permission problem when creating new dirs

Hi All,

I am having the problem with new created dir from the php code. The problem is caused by the owner settings when creating new dirs. What happens here is as follows:

1) it creates a new dir with owner apache and cmod 666

2) next, when I try to upload images to the created, nothing is uploaded

3) if I change the owner of new directories to my ftp owner (let's say "cinema" as all the directories in the root), everything works fine

My php settings in the conf file: Safe mode Off, RegGlobals Off.

chmod 666 should allow accessing the dir by anyone, but it does not happen

What is wrong here? How can I fix this?

Thanks
Avatar of hielo
hielo
Flag of Wallis and Futuna image

6 => Read and Write. You need to be able to execute the script:
777
Avatar of andy7789
andy7789

ASKER

Why? there are no executables here. this is just a dir for image iploading
The execute permission is necessary to be able to traverse the directory.

http://www.zzee.com/solutions/linux-permissions.shtml#zzee_link_9_1077830297
>>Why? there are no executables here
Basically the web server need to be able to "read/access" the directory. For that you need execute permissions.
If you were to set up an html file  with 744 permisssions, it would not be viewable by the public because you do not have execute permission for the "Other" group. You would need at least a 5 =>(755).
thank you. Is there any way to set the default cmod for new dirs in .htaccess (to override any other settings)?
SOLUTION
Avatar of hielo
hielo
Flag of Wallis and Futuna image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
i do not know why, but I could never managed to make it like

mkdir('dir', 0777)

Usually, i used exec("chmod..."), which does not run on all servers.

Any ideas as why the direct execution of mkdir with chmod param does not work?

What permissions did it receive after you created the directory?  Remember that you have to account for PHP's umask when assigning the permissions.  The actual permissions assigned are (supplied - umask).
i am getting 666, even though it should be 777 as specified in mkdir
What does PHP's umask() return?
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
That was my suggestion, too.  :)  It does seem to be easier, but there is a point in the user comments about a vulnerability inherent in that strategy.
yes, adding chmod() after each mkdir() works fine. I still do not understand, why mkdir dies not set it directly.