Bug #65211 [Opn->Dup]: file_exists() warns of open_basedir on existing file mis-used as directory
Edit report at https://bugs.php.net/bug.php?id=65211&edit=1
ID: 65211
Updated by: cmb@php.net
Reported by: paolo at schiro dot it
Summary: file_exists() warns of open_basedir on existing file
mis-used as directory
-Status: Open
+Status: Duplicate
Type: Bug
Package: Safe Mode/open_basedir
Operating System: Linux
PHP Version: Irrelevant
-Assigned To:
+Assigned To: cmb
Block user comment: N
Private report: N
New Comment:
This is a duplicate of bug #52065.
Previous Comments:
------------------------------------------------------------------------
[2014-06-04 07:17:06] requinix@php.net
Related To: Bug #67378
------------------------------------------------------------------------
[2014-05-07 19:28:39] info at ihead dot ru
File functions produce warning if argument is a path which starts with existing file.
<?
touch('./index.php');
ini_set('open_basedir', '.');
var_dump(file_exists('./index.php/.section.php'));
?>
Expected result:
bool(false)
Actual result:
Warning: file_exists(): open_basedir restriction in effect. File(./index.php/.section.php) is not
within the allowed path(s): (.) in ***/1.php on line 4
bool(false)
OS FreeBSD.
PHP 5.3, 5.4 affected.
PHP 5.2 not affected.
------------------------------------------------------------------------
[2013-07-19 18:05:50] mail+php at requinix dot net
Duplicate of
- bug 52065 "Warning about open_basedir restriction while accessing a file as
directory"
- bug 53041 "is_file() and open_basedir" closed to due no feedback (@pajoye: yes)
tl;dr: bug is not about open_basedir itself but rather some code being unable to
access the file (rightly so) and the calling code assuming the failure is because
of open_basedir.
------------------------------------------------------------------------
[2013-07-05 17:05:45] paolo at schiro dot it
Description:
------------
When open_basedir set file_exists() raise an open_basedir warning
when checking a path which permitted by open_basedir but includes
an existent file misused as directory.
Test script:
---------------
//create a file
$fhandle = fopen('existing-file-which-is-not-dir.txt', 'w');
//throw your mind away and use it as a directory
if (is_file('existing-file-which-is-not-dir.txt/test.html')) {
print "File exists";
} else {
print "File does not exist";
}
//show the error
print_r(error_get_last());
Expected result:
----------------
is_file should return a FALSE and you should read "File does not exist".
Actual result:
--------------
In addition to "File does not exist", you'll get a warning that
open_basedir restriction is in effect:
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=65211&edit=1
Thread (4 messages)