#30784 [NEW]: is_writable fails with apache user/group set
| From: | max at warped dot org | Date: | Sun, 14 Nov 2004 19:13:08 +0000 |
| Subject: | #30784 [NEW]: is_writable fails with apache user/group set | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-69050@lists.php.net to get a copy of this message | ||
From: max at warped dot org
Operating system: Linux - Redhat ES3
PHP version: 4.3.9
PHP Bug Type: Filesystem function related
Bug description: is_writable fails with apache user/group set
Description:
------------
is_writable() only returns one for files that are writable by the apache
user, not by the current UID.
Apache is running as user/group nobody, but is setup with virtual hosts.
Each virtual host uses its own user/group. The current UID as returned by
getmyuid() verifies that my PHP scripts are running as "me" and not as
"nobody".
test_file is permission 0644.
If I chmod test_file to user "me" is_writable() returns nothing.
If I chmod test_file to user "nobody" is_writable() returns 1.
PHP needs to check the current uid an use that to verify if something is
writable, or it needs to defer to the operating system.
I imagine this is mod_php specific.
Reproduce code:
---------------
httpd.conf :
User nobody
Group nobody
<VirtualHost ...>
User me
Group me
</VirtualHost>
$ touch test_file
$ chmod 0644 test_file
$ chown nobody test_file
<? print getmyuid() ?>
<? print is_writable('test_file') ?>
514
1
$ chown me test_file
<? print getmyuid() ?>
<? print is_writable('test_file') ?>
514
(nothing)
Expected result:
----------------
I expect is_writable() to return 1 if PHP fully has permission to write
the file.
As a result, I have to chmod sensitive data to 0666 on a shared server,
which is bad.
--
Edit bug report at http://bugs.php.net/?id=30784&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=30784&r=trysnapshot4
Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=30784&r=trysnapshot50
Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=30784&r=trysnapshot51
Fixed in CVS: http://bugs.php.net/fix.php?id=30784&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=30784&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=30784&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=30784&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=30784&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=30784&r=support
Expected behavior: http://bugs.php.net/fix.php?id=30784&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=30784&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=30784&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=30784&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=30784&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=30784&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=30784&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=30784&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=30784&r=float
MySQL Configuration Error: http://bugs.php.net/fix.php?id=30784&r=mysqlcfg