php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #29170 problem with open_basedir and include
Submitted: 2004-07-15 00:39 UTC Modified: 2005-01-31 23:07 UTC
Votes:2
Avg. Score:5.0 ± 0.0
Reproduced:2 of 2 (100.0%)
Same Version:1 (50.0%)
Same OS:1 (50.0%)
From: phynias at camphreaks dot com Assigned:
Status: Not a bug Package: Safe Mode/open_basedir
PHP Version: 5.0.0 OS: Redhat 9
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: phynias at camphreaks dot com
New email:
PHP Version: OS:

 

 [2004-07-15 00:39 UTC] phynias at camphreaks dot com
Description:
------------
When open_basedir options or set on a a set within apache.
Such as:
php_admin_value open_basedir"/home/httpd/vhosts/mysite.com/httpdocs"

If I do an include form 1 page and then in that page inlcude another page it errors out with 
open_basedir restriction in effect.

Easiest way to test it is to do the following.
in your docroot create a file called test.php inside test.php put <? include('inc/include1.php');?>
then inside include1.php put
<? include('inc2/include2.php'); ?>
and inside include2.php put
<? print "hello world"; ?>

So if yer vase was /httpd/docroot you would have

/httpd/docroot/test.php
/httpd/docroot/inc/include1.php
/httpd/docroot/inc/inc2/include2.php

Then bring up test.php in your browser.


Of course u must have the dirs /inc and inc/inc2 created
This will include the first file but error on the second one.

Actual result:
--------------
Warning: main() [function.main]: open_basedir restriction in effect. File(/usr/share/pear/include/inc2.php) is not within the allowed path(s): (/home/httpd/vhosts/mysite.com/httpdocs:/tmp) in /home/httpd/vhosts/mysite.com/httpdocs/test/inc.php on line 2

Warning: main(include/inc2.php) [function.main]: failed to open stream: Operation not permitted in /home/httpd/vhosts/mysite.com/httpdocs/test/inc.php on line 2

Warning: main() [function.include]: Failed opening 'include/inc2.php' for inclusion (include_path='.:./:/usr/share/pear:/php/includes:') in /home/httpd/vhosts/mysite.com/httpdocs/test/inc.php on line 2

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-08-03 16:42 UTC] kuba at 3net dot pl
the same story....
when this issue will be solved?
do i have to change my software, install old php 4.3.7,
or wait for you to solve it?
 [2004-08-03 16:49 UTC] tony2001@php.net
use absolute path with include() and all other functions.
define('ROOT_PATH','/home/httpd/vhosts/mysite.com/httpdocs');
include (ROOT_PATH.'/inc/include1.php');
it will work perfectly at all hostings, all platforms, all versions etc. etc.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 22 12:01:30 2024 UTC