Bug #44901 [Com]: open_basedir as prefix complains on attempts to access non-existant files

From: Date: Wed, 25 May 2011 16:07:24 +0000
Subject: Bug #44901 [Com]: open_basedir as prefix complains on attempts to access non-existant files
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-160959@lists.php.net to get a copy of this message
Edit report at http://bugs.php.net/bug.php?id=44901&edit=1

 ID:                 44901
 Comment by:         softwareelves at gmail dot com
 Reported by:        jake at yahoo-inc dot com
 Summary:            open_basedir as prefix complains on attempts to
                     access non-existant files
 Status:             Verified
 Type:               Bug
 Package:            Safe Mode/open_basedir
 Operating System:   *
 PHP Version:        5.*, 6CVS (2009-03-16)
 Block user comment: N
 Private report:     N

 New Comment:

This bug doesn't seem to exist in 5.2.x.

I found it's not just a trailing slash but anything after an existing
file path.

I found an easy way to show this bug:

error_reporting( E_ALL | E_STRICT );

var_dump( file_exists( __FILE__ ) );
var_dump( file_exists( __FILE__."/something_that_doesnt_exists" ) );

ini_set( "open_basedir", dirname( __FILE__ ) );

var_dump( file_exists( __FILE__ ) );
var_dump( file_exists( __FILE__."/something_that_doesnt_exists" ) );


Previous Comments:
------------------------------------------------------------------------
[2008-05-03 00:41:11] jake at yahoo-inc dot com

Description:
------------
When using open_basedir as a prefix, attempting to access files or
directories which match the prefix but are not present on the filesystem
raise open_basedir restriction warnings.



Reproduce code:
---------------
// create files or directories on the file system "/foo1", "/foo2"
// add "/foo" (not "/foo/") to the open basedir restriction, then:

var_dump(file_exists('/foo1'));
var_dump(file_exists('/foo2'));
var_dump(file_exists('/foo3'));



Expected result:
----------------
this is the output returned:
bool(true)
bool(true)
bool(false)

which is expected, however, the "false" returned by the third call is
disingenuous... it is false because the call is being blocked by
open_basedir, and the following warning is triggered:

[Fri May  2 17:33:05 2008] [error] PHP Warning:  file_exists():
open_basedir restriction in effect. File(/foo3) is not within the
allowed path(s)




------------------------------------------------------------------------



-- 
Edit this bug report at http://bugs.php.net/bug.php?id=44901&edit=1


Thread (6 messages)

« previous php.bugs (#160959) next »