note 82228 rejected from function.rmdir by betz
| From: | betz@php.net | Date: | Tue, 01 Apr 2008 22:23:49 +0000 |
| Subject: | note 82228 rejected from function.rmdir by betz | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-137838@lists.php.net to get a copy of this message | ||
Note Submitter: adrian dot stannard at icps2007 dot org
----
Possible bug (but never been able to get the bug report page to load):
Use of rmdir() and relative directory scope / open_basedir restriction.
I cannot find much mention of this, but 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 function dependent relative to $root (for e.g. a file
include) you get an 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"]).'/';