Page 1 of 1
mkdir and umask
Posted: Thu Sep 26, 2002 1:34 pm
by nielsene
I'm running with safemode off
Code: Select all
<?php
umask(000);
mkdir("/usr/local/compinabox/var/newTEMP",0740);
?>
but the resulting directory has 0311 for its permissions...
Can anyone spot what I'm doing wrong?
Posted: Thu Sep 26, 2002 4:19 pm
by Takuma
umask affects permissions when files and directories are created.
umask is short for "Un-Mask".
So umask is "and"ed with the permissions of mkdir, fopen, etc.
In a sense, the umask setting is "subtracted" from the permissions given to mkdir.
Example:
<PRE>
umask(011);
mkdir('foo', 0777);
</PRE>
will actually make a directory with permissions 0766.
Does this mean your code is not doing anything...??
Posted: Fri Sep 27, 2002 8:25 am
by nielsene
yes a umask of 000 should mean that what I ask for in mkdir is what I get. If I changed mkdir to asking for 0700 it works properly, if I change the umask to 077 and specify 0777 for mkdir it fails, etc. I managed to find a pair of settings that acheive what I wanted, but it was wierd to have to search through the possible permutations when any of them should have worked