From:             adrian dot stannard at icps2007 dot org
Operating system: FreeBSD
PHP version:      5.2.5
PHP Bug Type:     Safe Mode/open_basedir
Bug description:  Use of rmdir() and relative directory scope / open_basedir 
restriction

Description:
------------
Use of rmdir() and relative directory scope / open_basedir restriction.

I cannot find mention of this anywhere, but the following is observed if
you are on a server with open_basedir restriction and you use relative
links in your script, for e.g. you define a root directory as $root='./';

If you use rmdir($dir), where $dir is some dir relative to your $root,
rmdir removes this directory successfully, but later if you perform another
file calling function dependent relative to $root - for example if you do a
file include you get the following error:

open_basedir restriction in effect
File(./includes/page_header.php) is not within the allowed path(s):
/home/[account_name]:/usr/lib/php:/usr/local/lib/php:/tmp

the $root variable itself is unchanged (I've checked this), but its scope
changes. So far I've only seen this happen immediately after using rmdir.

The only way around this seems to be to drop relative assignments and
redefine the root as something like:

$root=$_SERVER['DOCUMENT_ROOT']. dirname($_SERVER["PHP_SELF"]).'/';


**Note on server configuration: SAFE MODE is off, but open_basedir
restriction has been set **

Reproduce code:
---------------
$selected_dir='some_user_created_directory';

rmdir($root.$selected_dir);

include($root.'some_file.php');

Expected result:
----------------
$selected_dir is deleted.
Would then expect to see some_file.php included.

Actual result:
--------------
open_basedir restriction in effect
File(./includes/page_header.php) is not within the allowed path(s):
/home/[account_name]:/usr/lib/php:/usr/local/lib/php:/tmp

-- 
Edit bug report at http://bugs.php.net/?id=44608&edit=1
-- 
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=44608&r=trysnapshot52
Try a CVS snapshot (PHP 5.3): 
http://bugs.php.net/fix.php?id=44608&r=trysnapshot53
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=44608&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=44608&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=44608&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=44608&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=44608&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=44608&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=44608&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=44608&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=44608&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=44608&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=44608&r=globals
PHP 4 support discontinued:   http://bugs.php.net/fix.php?id=44608&r=php4
Daylight Savings:             http://bugs.php.net/fix.php?id=44608&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=44608&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=44608&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=44608&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=44608&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=44608&r=mysqlcfg

Reply via email to