Re: Migration from php4 to php 5 open_basedir directive.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Craig Lewis wrote:
Hello,

I have just attempted to migrate for the first time from php4 to php5. The problem i am having is some sort of change in how the open_basedir directive works in php 5. I don't see much discussion about this, so I must be doing something stupid, otherwise, I would think there would be a lot of people bumping into this.

On both servers I have safe mode on and open_basedir directive set for the virtual host in apache. The offending php code from the top level file calls another php file with require_once ('path/file.php') and then file.php in turn calls another php file require_once ('path/file2'). Its this second require_once that causes the fatal error, in otherwords, I can call the first file with require_once, and put just about any sort of reasonable php code in this file, and it works, i.e. its included in the origional file. When the called file, calls another file, in php 5, I get an error,

==========================================
Warning: main() [function.main]: open_basedir restriction in effect. File(/usr/local/pkg/php/php-5.0.2//lib/php/config/_config.inc.php) is not within the allowed path(s): (/www/htdocs/midwifefinder.com/site) in /www/htdocs/midwifefinder.com/site/includes/app.php on line 3

the way I read it your config only allows you to open files inside of: /www/htdocs/midwifefinder.com/site

looks to me like php5 is doing what its supposed to, maybe php4
was actually broken which allowed the require to work when it
wasn't supposed to.

why not just add the necessary directories to the open_basedir setting
(I'm guessing it can take multiple dirs because the error says 'allowed path(s)')?
e.g.:
/usr/local/pkg/php/php-5.0.2//lib/php/config/_config.inc.php
			     ^--- ? 	

Warning: main(config/_config.inc.php) [function.main]: failed to open stream: Operation not permitted in /www/htdocs/midwifefinder.com/site/includes/app.php on line 3


Fatal error: main() [function.require]: Failed opening required 'config/_config.inc.php' (include_path='.:/usr/local/pkg/php/php-5.0.2//lib/php') in /www/htdocs/midwifefinder.com/site/includes/app.php on line 3
============================================


The code and paths are unchanged, works on php4, not on php5, apache version unchanged. (1.3.x). I have tried various php.ini files, of course turning open_basedir off will make the error go away. The file being called is clearly within the scope of the open_basedir restriction, and thus it works just fine in php4.

/usr/local/pkg/php/php-5.0.2//lib/php/config/_config.inc.php is not the correct path to the file, I guess because it doesn't find the file in the . (dot) part of the include path, then it blows up when it tries to find the file in (what is basically) /usr/local/lib/php.

This kind of sounds like a TRANSPATH related problem, and its certainly a path problem (where is dot), but as I read the docs, TRANSPATH is something that changed for apache 2.

Any advice would be appreciated.

CL


-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux