#33639 [NEW]: docs for chmod re safe_mode
| From: | crescentfreshpot at yahoo dot com | Date: | Mon, 11 Jul 2005 02:09:31 +0000 |
| Subject: | #33639 [NEW]: docs for chmod re safe_mode | ||
| Groups: | php.doc | ||
| Request: | Send a blank email to phpdoc+get-969369041@lists.php.net to get a copy of this message | ||
From: crescentfreshpot at yahoo dot com
Operating system: SunOS
PHP version: Irrelevant
PHP Bug Type: Documentation problem
Bug description: docs for chmod re safe_mode
Description:
------------
Docs for chmod state:
"When safe mode is enabled, PHP checks whether the files ... you are about
to operate on have the same UID (owner) as the script that is being
executed"
On a shared user server with php installed as an apache module and
safe_mode on, php is running as 'www'. My script script.php (owner uid =
8612) operates on myfile.txt (owner uid = 8612) with fopen() and chmod().
Only fopen works, chmod triggers a "Not owner" warning:
ls -al:
-rwxrwxrwx 1 user1 users 4427 Jul 11 02:38 script.php
-rwxrwxrwx 1 user1 users 282 Jul 8 05:13 myfile.txt
(directory holding these is:
drwxrwxrwx+ 2 user1 users 512 Jul 11 02:38 public_html)
Clearly both the script and the file the script operates on have the same
owner.
I know (or suspect) this is not a bug in php but rather a side effect of
the apache user (www) chmod'ing a file it doesn't own. If so perhaps the
docs could be updated to mention this behaviour? chmod in particular spits
out a "Not owner" warning and clearly this can cause needless confusion
with the above ls -al output.
Reproduce code:
---------------
script.php:
<?php
error_reporting(E_ALL);
$file = "myfile.txt";
echo "fileowner($file) = ".fileowner($file)."\n";
echo "fileowner(".basename(__FILE__).") = ".fileowner(__FILE__)."\n";
$fp = fopen($file,'r');
if(is_resource($fp)) {
echo "fopen($file) successful\n";
fclose($fp);
} else {
echo "fopen($file) failed\n";
}
chmod($file,0755);
?>
Expected result:
----------------
fileowner(myfile.txt) = 8612
fileowner(script.php) = 8612
fopen(myfile.txt) successful
Actual result:
--------------
fileowner(myfile.txt) = 8612
fileowner(script.php) = 8612
fopen(myfile.txt) successful
Warning: chmod(): Not owner in /home/user1/public_html/script.php on line
15
--
Edit bug report at http://bugs.php.net/?id=33639&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=33639&r=trysnapshot4
Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=33639&r=trysnapshot50
Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=33639&r=trysnapshot51
Fixed in CVS: http://bugs.php.net/fix.php?id=33639&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=33639&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=33639&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=33639&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=33639&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=33639&r=support
Expected behavior: http://bugs.php.net/fix.php?id=33639&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=33639&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=33639&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=33639&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=33639&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=33639&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=33639&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=33639&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=33639&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=33639&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=33639&r=mysqlcfg