php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #23190 Debugging output of file_exists is misleading
Submitted: 2003-04-13 19:44 UTC Modified: 2005-01-31 23:22 UTC
From: d dot tonhofer at m-plify dot com Assigned:
Status: Not a bug Package: Safe Mode/open_basedir
PHP Version: 4.3.1 OS: Linux 2.4.18
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
15 + 17 = ?
Subscribe to this entry?

 
 [2003-04-13 19:44 UTC] d dot tonhofer at m-plify dot com
file_exists gives a misleading error message if
open_basedir is in effect.

Example:

<?php
error_reporting(E_ALL);

# We have:
# open_basedir = /var/www/htdocs/site-com-prod:/var/www/htdocs/site-com-test:/usr/local/phpwiki

// get $filename from parameters

if (file_exists($filename)) {
    print "The file $filename exists";
} else {
    print "The file $filename does not exist";
}

?>

Results:

The following give no problem, just the 'does not exist' result:

$filename = '/var/www/htdocs/site-com-prod/i_dont_exist.txt';
$filename = '/var/www/htdocs/site-com-test/i_dont_exist.txt';
$filename = '/usr/local/phpwiki-1.3.4';

Now we try something outsid of the open_basedir path set:

$filename = '/etc/passwd';

We get:

PHP Warning:  file_exists() [<a href='http://www.php.net/function.file-exists'>function.file-exists</a>]: open_basedir restriction in effect. File(/etc/passwd) is not within the allowed path(s): (/var/www/htdocs/site-com-prod) in /usr/local/phpwiki-1.3.4/test.php on line 12


Clearly, the open_basedir path indicated by file_exists() in this error message is wrong & confusing.






Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-04-13 23:19 UTC] pollita@php.net
This bug was already reported in this bug system and was fixed.  The fix will appear in PHP 4.3.2
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Mar 19 03:01:29 2024 UTC