ID:               44608
 Updated by:       [EMAIL PROTECTED]
 Reported By:      adrian dot stannard at icps2007 dot org
-Status:           Open
+Status:           Feedback
 Bug Type:         Safe Mode/open_basedir
 Operating System: FreeBSD
 PHP Version:      5.2.5
 New Comment:

Please try using this CVS snapshot:

  http://snaps.php.net/php5.3-latest.tar.gz

There are some fixes done in PHP_5_3 which most likely fix this
problem. Note: Those fixes will NOT be backported to 5.2 branch!


Previous Comments:
------------------------------------------------------------------------

[2008-04-02 12:15:00] adrian dot stannard at icps2007 dot org

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 this bug report at http://bugs.php.net/?id=44608&edit=1

Reply via email to