#43907 [Opn->Fbk]: mkdir function ignore permission mask.

From: Date: Sat, 02 Feb 2008 20:27:21 +0000
Subject: #43907 [Opn->Fbk]: mkdir function ignore permission mask.
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-121911@lists.php.net to get a copy of this message
ID: 43907 Updated by: jani@php.net Reported By: sergio at gruposinternet dot com dot br -Status: Open +Status: Feedback Bug Type: Directory function related Operating System: Freebsd 6.2 PHP Version: 5.2.5 New Comment: 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? Previous Comments: ------------------------------------------------------------------------ [2008-01-26 16:13:12] 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-01-26 01:22:27] jani@php.net And you're sure system umask() is not forcing something else here? ------------------------------------------------------------------------ [2008-01-22 13:37:41] 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 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=43907&edit=1

« previous php.bugs (#121911) next »