|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2008-01-22 13:37 UTC] sergio at gruposinternet dot com dot br
Description:
------------
mkdir function ignore permission mask for "group" and "others" bits.
safe_mode off
Reproduce code:
---------------
<?php
// recursive
mkdir("foo/bar/1/2/3/4/5", 0777, true);
// not recursive
mkdir("bar", 0777);
// setting only the first bit works.
mkdir("foo2/bar/1/2/3/4/5", 0700, true);
mkdir("bar2", 0700);
?>
Expected result:
----------------
$ ls -lh
total 4
drwxrwxrwx 2 grupos grupos 512B Jan 22 11:15 bar
drwx------ 2 grupos grupos 512B Jan 22 11:21 bar2
drwxrwxrwx 3 grupos grupos 512B Jan 22 11:12 foo
drwx------ 3 grupos grupos 512B Jan 22 11:21 foo2
Actual result:
--------------
$ ls -lh
total 4
drwxr-xr-x 2 grupos grupos 512B Jan 22 11:15 bar
drwx------ 2 grupos grupos 512B Jan 22 11:21 bar2
drwxr-xr-x 3 grupos grupos 512B Jan 22 11:12 foo
drwx------ 3 grupos grupos 512B Jan 22 11:21 foo2
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Oct 28 19:00:01 2025 UTC |
Default system umask is set to 0022, setting it to 0000 works fine, but if I hard set the permission on (PHP) function mkdir it shouldn't overwrite the system umask? It shouldn't work like call (C) function mkdir(2) followed by a call to (C) function chmod(2) for every directory setting the right permission? It seems that PHP just underlays to (C) function mkdir(2) with permission set as second parameter, so that function is realy restricted to the process umask. Example that works with system umask set to 0022: <?php mkdir("foo3"); chmod("foo3", 0777); ?>