|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #44284 mkdir will not apply group sticky from supplied mode
Submitted: 2008-02-28 18:16 UTC Modified: 2008-03-03 14:46 UTC
From: php at displague dot com Assigned:
Status: Not a bug Package: Directory function related
PHP Version: 5.2.5 OS: linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: php at displague dot com
New email:
PHP Version: OS:


 [2008-02-28 18:16 UTC] php at displague dot com
The php function mkdir() does not apply the group sticky bit on folders created.  The php function chmod() is capable of doing this.

Previous, closed, bug reports show that mkdir() premitted sticky bits in the past when chmod() did not.

All of my safe_ variables are off:

[mjohansson@host tmp]$ php -r 'phpinfo();' | grep ^safe
safe_mode => Off => Off
safe_mode_exec_dir => no value => no value
safe_mode_gid => Off => Off
safe_mode_include_dir => no value => no value
safe_mode_allowed_env_vars => PHP_ => PHP_
safe_mode_protected_env_vars => LD_LIBRARY_PATH => LD_LIBRARY_PATH

Reproduce code:
rm -rf test2 test3;
php -r '
  mkdir("test2", 02770);
ls -lad test2 test3

Expected result:
drwxrws--- 2 mjohansson mjohansson 4096 Feb 28 13:05 test2
drwxrws--- 2 mjohansson mjohansson 4096 Feb 28 13:05 test3

Actual result:
drwxrwx--- 2 mjohansson mjohansson 4096 Feb 28 13:05 test2
drwxrws--- 2 mjohansson mjohansson 4096 Feb 28 13:05 test3


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2008-03-03 14:46 UTC]
From 'man 2 mkdir':

Under Linux apart from the permission bits, only the S_ISVTX mode bit is honored. That is, under Linux the created directory actually gets mode (mode & ~umask & 01777).  See also stat(2).

PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Sun May 28 00:03:40 2023 UTC