#32920 [NEW]: File creation permissions broken
| From: | ben at skiddle dot com | Date: | Mon, 02 May 2005 23:40:42 +0000 |
| Subject: | #32920 [NEW]: File creation permissions broken | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-78538@lists.php.net to get a copy of this message | ||
From: ben at skiddle dot com
Operating system: FreeBSD 5.3
PHP version: 4.3.11
PHP Bug Type: Filesystem function related
Bug description: File creation permissions broken
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
--
Edit bug report at http://bugs.php.net/?id=32920&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=32920&r=trysnapshot4
Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=32920&r=trysnapshot50
Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=32920&r=trysnapshot51
Fixed in CVS: http://bugs.php.net/fix.php?id=32920&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=32920&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=32920&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=32920&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=32920&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=32920&r=support
Expected behavior: http://bugs.php.net/fix.php?id=32920&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=32920&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=32920&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=32920&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=32920&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=32920&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=32920&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=32920&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=32920&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=32920&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=32920&r=mysqlcfg