#33639 [Opn->Ver]: docs for chmod re safe_mode

From: Date: Sun, 17 Jul 2005 09:43:50 +0000
Subject: #33639 [Opn->Ver]: docs for chmod re safe_mode
References: 1  Groups: php.doc 
Request: Send a blank email to phpdoc+get-969369175@lists.php.net to get a copy of this message
ID: 33639 Updated by: dmytton@php.net Reported By: crescentfreshpot at yahoo dot com -Status: Open +Status: Verified Bug Type: Documentation problem Operating System: SunOS PHP Version: Irrelevant New Comment: Confirmed on Fedora/Apache1/PHP5.0.4: fileowner(myfile.txt) = 32021 fileowner(chmod.php) = 32021 fopen(myfile.txt) successful Warning: chmod() [function.chmod]: Operation not permitted in /home/expanse/public_html/chmod.php on line 16 This sounds more like a chmod() bug than a doc bug to me. Previous Comments: ------------------------------------------------------------------------ [2005-07-11 04:09:28] crescentfreshpot at yahoo dot com 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 this bug report at http://bugs.php.net/?id=33639&edit=1

« previous php.doc (#969369175) next »