Bug #46498 [Com]: is_writable() returns invalid result
| From: | nick at all-it dot ru | Date: | Wed, 07 Nov 2012 22:46:27 +0000 |
| Subject: | Bug #46498 [Com]: is_writable() returns invalid result | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-174569@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=46498&edit=1
ID: 46498
Comment by: nick at all-it dot ru
Reported by: registrace at koren dot cz
Summary: is_writable() returns invalid result
Status: No Feedback
Type: Bug
Package: Filesystem function related
Operating System: Linux
PHP Version: 5.2.6
Block user comment: N
Private report: N
New Comment:
This bug is 4 years old but nothing done to fix it and use proper functions to check effective
access right instead of real... I'm using 5.3 version. Does anybody like to fix it? It is
awfully difficult to recompile PHP each time I update it. I can provide patch but not sure whether
somebody like to have this bug fixed.
Previous Comments:
------------------------------------------------------------------------
[2009-02-20 01:00:00] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
------------------------------------------------------------------------
[2009-02-13 00:13:49] jani@php.net
Please try using this CVS snapshot:
http://snaps.php.net/php5.2-latest.tar.gz
For Windows:
http://windows.php.net/snapshots/
------------------------------------------------------------------------
[2008-11-05 21:01:31] registrace at koren dot cz
Description:
------------
PHP Function is_writable() sometimes reports false results.
Requirements: Linux - getuid() != geteuid()
After inspection of PHP source, I realized, that is_writable() internally uses syscall access(2). In
turn, access(2) man page (on Linux) says:
The check is done with the calling processâs real UID and GID, rather
than with the effective IDs as is done when actually attempting an
operation. This is to allow set-user-ID programs to easily determine
the invoking userâs authority.
Reproduce code:
---------------
<?
$file = "testfile.txt";
echo "GetUID: " . posix_getuid() . "/" . posix_geteuid() . "<br
/>";
echo "file is writable " . (is_writable($file)?"TRUE":"FALSE") .
"<br />";
fopen("testfile.txt", 'wt');
echo ("file created");
?>
Expected result:
----------------
Expected result:
either:
file is writable TRUE
file created
or
file is writable FALSE
ERROR
Actual result:
--------------
GetUID: 933/10099
file is writable FALSE
file created
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=46498&edit=1