php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #43907 mkdir function ignore permission mask.
Submitted: 2008-01-22 13:37 UTC Modified: 2008-02-06 13:20 UTC
From: sergio at gruposinternet dot com dot br Assigned:
Status: Closed Package: Directory function related
PHP Version: 5.2.5 OS: Freebsd 6.2
Private report: No CVE-ID: None
 [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


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-01-26 01:22 UTC] jani@php.net
And you're sure system umask() is not forcing something else here?

 [2008-01-26 16:13 UTC] sergio at gruposinternet dot com dot br
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);
?>
 [2008-02-02 20:27 UTC] jani@php.net
Yes, PHP just wraps around the libc mkdir() function, no news there. And as it works like it's supposed to, where's the bug?
 [2008-02-06 13:20 UTC] sergio at gruposinternet dot com dot br
Closing the bug. Its bogus.
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Sun May 09 08:01:23 2021 UTC