php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #32920 File creation permissions broken
Submitted: 2005-05-03 01:40 UTC Modified: 2005-05-16 01:00 UTC
Votes:4
Avg. Score:3.5 ± 0.9
Reproduced:3 of 3 (100.0%)
Same Version:2 (66.7%)
Same OS:2 (66.7%)
From: ben at skiddle dot com Assigned:
Status: No Feedback Package: Filesystem function related
PHP Version: 4.3.11 OS: FreeBSD 5.3
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: ben at skiddle dot com
New email:
PHP Version: OS:

 

 [2005-05-03 01:40 UTC] ben at skiddle dot com
Description:
------------
I am running PHP as a CGI module with Apache 2.0.52

Apache runs as user 'apache'
PHP cgi runs as vhost user 'myuser' (for example)
Both users are in groupa

I have the following folder:

drwxr-wr-w  articles   myuser groupa

When I create a new file in this folder, it is being given permissions

 rw------- mynewfile.shtml  myuser groupa

Because of this apache cannot read the file. This file should inherit the parent folders permissions?

I am using simple fopen, fwrite, fclose

This is either a problem with inheriting permissions, or the system umask has been altered. This has only happened since upgrading from 4.3.10 to 4.3.11 and has broken several script, some using move_uploaded_file also.



Reproduce code:
---------------
if (!$handle = fopen($longfilename, 'w')) {
					 print "<BR>Cannot open file ($filename)";
					 return false;
				}
			
				// Write $somecontent to our opened file.
				if (!@fwrite($handle, $somecontent)) {
					print "<BR>Cannot write to file ($filename)";
					
					 return false;
				}

fclose($handle);

Expected result:
----------------
File created with same permissions as parent folder. (no umask or chmod settings are applied in the php code, or have been altered anywhere)

Actual result:
--------------
File created with less permissions

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-05-03 02:17 UTC] ben at skiddle dot com
If I echo umask() from php I get '18'
 [2005-05-03 02:20 UTC] ben at skiddle dot com
Having run 'echo umask();' again (just refreshing the page) the umask is now 63, and this randomly changes from 18 to 63 and back again when i refresh
 [2005-05-06 12:34 UTC] ben at skiddle dot com
any luck yet?
 [2005-05-06 13:39 UTC] tony2001@php.net
Any info on how to reproduce it?
 [2005-05-06 13:51 UTC] ben at skiddle dot com
<? echo umask(); ?>

On my setup, refresh this page and the result will toggle between 18 and 63. (http://skiddle.com/test.php)
 [2005-05-06 14:58 UTC] tony2001@php.net
Can't reproduce with Apache1 & Apache2 and mod_php/CGI/FastCGI.
 [2005-05-06 15:17 UTC] ben at skiddle dot com
This only occurs when using php as a cgi-module with SuExec
 [2005-05-08 04:36 UTC] sniper@php.net
And you're 100% sure it's not SuExec bug?

 [2005-05-16 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Fri Dec 13 13:01:25 2019 UTC