|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2005-01-19 23:05 UTC] kpederson at mail dot ewu dot edu
Description:
------------
is_readable($myfilename) in the repro code returns true if
the script calling it is owned by root, but false if it is
owned by someone else.
Permissions are:
-rw-r--r-- 1 root root 5452 Jan 13
13:02 /var/lib/php_packages/test_templ2.php
drwxr-xr-x 4 root root 4096 Jan 19
08:19 /var/lib/php_packages
drwxr-xr-x 27 root root 4096 Jan 12
09:27 /var/lib
drwxr-xr-x 24 root root 4096 Sep 22
13:06 /var
drwxr-xr-x 20 root root 4096 Oct 29 09:48 /
Relevant Settings:
include_path =
".:/var/lib/php_packages:/var/lib/php_packages/pear"
safe_mode = On
safe_mode_gid = On
safe_mode_include_dir = /var/lib/php_packages
Reproduce code:
---------------
#### test.php ###
$myfilename = '/var/lib/php_packages/test_templ2.php';
if (is_readable($myfilename)) {
echo "is_readable: $myfilename (true)<br>";
} else {
echo "is_readable: $myfilename (false)<br>";
}
include($myfilename);
### test_templ2.php ###
TESTING!
Expected result:
----------------
I would expect is_readable() to return true in both
instances. The uid/gid check shouldn't matter despite
safe mode, as the file is in safe_mode_include_dir, and
even if it wasn't, the is_readable documentation says that
it does NOT take into account safe_mode restrictions.
Actual result:
--------------
// When test.php has the following ownership:
$ ls -l test.php
-rw-rw-r-- 1 root root 278 Jan 19 13:16
test.php
// I get the following output:
is_readable: /var/lib/php_packages/test_templ2.php (true)
TESTING!
// When test.php has the following permissions:
$ ls -l test.php
-rw-rw-r-- 1 dschlegel79 undergradadmiss 278 Jan
19 13:16 test.php
// I get the following output:
is_readable: /var/lib/php_packages/test_templ2.php (false)
TESTING!
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Nov 03 18:00:01 2025 UTC |
Hmm... I can understand that logic. The docs say: "UID/GID checks are bypassed when including files from this directory and its subdirectories" which also seems to fit. It's going to make it really hard for me (and I would guess many others) as a developer to support a given use case. The use case that doesn't seem to be satisfied by this is when the files in the safe_mode_include_dir (smarty for example) needs to fopen() other files in that directory. Smarty tries is_readable, which now succeeds, but there is no way for smarty, when running under safe mode, to actually read common templates... <sigh>. I don't know if this use case can be satisfied without that functionality.... I have hundreds of users, but no apparent way, (other than includes which now work) to do any type of complex templating. In most commercial environments, this wouldn't seem like a problem, but in the university setting, they all need access to a common template. Ok. I'm ranting and a bit frustrated -- although I do admit that you're right per all the docs. Feel free to delete this message and close the bug report. I appreciate you leaving it open a bit longer. If you're open for any discussion, you can e-mail me. Thanks.