php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #65796 mkdir creates folders with wrong permissions
Submitted: 2013-10-01 09:44 UTC Modified: 2013-10-01 09:53 UTC
From: cmfcmf dot flach at gmail dot com Assigned:
Status: Not a bug Package: Directory function related
PHP Version: Irrelevant OS: Linux/Ubuntu 13.4
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 you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: cmfcmf dot flach at gmail dot com
New email:
PHP Version: OS:

 

 [2013-10-01 09:44 UTC] cmfcmf dot flach at gmail dot com
Description:
------------
Creating a directory using mkdir() does not respect the permissions given.

Test script:
---------------
<?php

// Create a folder with 0777 permissions.
mkdir('test', 0777);

// Should be 0777, but is 0755.
echo substr(sprintf('%o', fileperms('test')), -4);

Expected result:
----------------
I expect the folder to be created with 0777 permission.

Actual result:
--------------
The folder is created with 0755 permission.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-10-01 09:48 UTC] drak@php.net
I get the same on PHP 5.5.3. chmod('test', 0777) then transforms the directory to 
the right chmod.
 [2013-10-01 09:53 UTC] mike@php.net
-Status: Open +Status: Not a bug
 [2013-10-01 09:53 UTC] mike@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

Check your umask.
 [2013-10-02 08:06 UTC] leight+bugs dot php at gmail dot com
I suspect your umask is 022. The manual states that the mode is modified by your current umask. Try a umask(0) and see if it is still an issue.
 [2013-10-05 08:37 UTC] cmfcmf dot flach at gmail dot com
> I suspect your umask is 022. The manual states that the mode is modified by your current umask. Try a umask(0) and see if it is still an issue.

It works. Thank you.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 15:01:29 2024 UTC