Bug #53658 [Opn->Fbk]: is_writable returns always false
| From: | rasmus@php.net | Date: | Thu, 06 Jan 2011 22:27:07 +0000 |
| Subject: | Bug #53658 [Opn->Fbk]: is_writable returns always false | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-157715@lists.php.net to get a copy of this message | ||
Edit report at http://bugs.php.net/bug.php?id=53658&edit=1
ID: 53658
Updated by: rasmus@php.net
Reported by: pierregobin at free dot fr
Summary: is_writable returns always false
-Status: Open
+Status: Feedback
Type: Bug
Package: Filesystem function related
Operating System: Linux 2.6.35
PHP Version: 5.3SVN-2011-01-05 (SVN)
Block user comment: N
Private report: N
New Comment:
Nah, this is pure Unix permissions. You are missing a piece somewhere.
PHP
doesn't do anything magical here. selinux perhaps. Dunno. strace a
request and
see which low-level syscall is failing here.
Previous Comments:
------------------------------------------------------------------------
[2011-01-06 23:21:10] pierregobin at free dot fr
Hi -
1) apache is the user as shown by ps aux | grep httpd.
apache 1724 0.0 0.8 33996 4248 ? S 18:00 0:00
/usr/sbin/httpd
apache 1726 0.0 0.6 32972 3292 ? S 18:00 0:00
/usr/sbin/httpd
2) when I run php on command line using my own account :
php -f is_writable.php - result is correct;
3) when I run php on command line sudoed by apache - it works also (echo
is_writable).
sudo -u apache php -f is_writable.php
this echos the right result :
is_writable<br>
Seems like httpd is disturbing php...
------------------------------------------------------------------------
[2011-01-05 23:44:23] rasmus@php.net
Are you absolutely sure your web server is running as user apache? Do a
"ps -aux
| grep httpd" or "ps aux | grep apache" and see which user it is running
as.
is_writable works fine everywhere as far as I know.
------------------------------------------------------------------------
[2011-01-05 22:38:05] pierregobin at free dot fr
Description:
------------
When php script is run via apache is_writable always returns false :
'is_writable()' always returns 'false' whatever :
- the permission write sets or not.
- safe_mode on or off
- the owner of the file being root:root or apache:apache
on the other side, 'is_readable()' returns the correct value (either
'true' when the file is made readable or 'false' when the file is made
unreadable).
But, when the same script is run by the php command line (under root) -
is_writable returns the correct value.
Test script:
---------------
<?php
if (is_writable("toto")) {
echo "is_writable<br>";
} else {
echo "is not writable!!!<br>";
}
?>
Expected result:
----------------
is_writable in case 'toto' is writable
is not writable in case 'toto' is not writable
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/bug.php?id=53658&edit=1