PEAR Forum :: PHP Extension and Application Repository

PEAR Forum Forum Index
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
Pear has suddenly has stopped working

 
Post new topic   Reply to topic    PEAR Forum Forum Index -> Installation, Upgrading & Configuration
View previous topic :: View next topic  
Author Message
pixelterra



Joined: 29 Feb 2008
Posts: 9

PostPosted: Mon Jul 21, 2008 7:49 pm    Post subject: Pear has suddenly has stopped working Reply with quote

I installed PEAR and used it in an application several months ago. Today, the website is reporting these errors:

Quote:

Warning: main() [function.main]: open_basedir restriction in effect. File(/usr/lib/php/PEAR.php) is not within the allowed path(s): ('.:/proc/uptime:/tmp:/home:/usr/local/lib/php:/usr/home:/usr/local/bin/') in /home/ncaha3/public_html/lib/pear/PEAR/MDB2.php on line 55


Warning: main(PEAR.php) [function.main]: failed to open stream: Operation not permitted in /home/ncaha3/public_html/lib/pear/PEAR/MDB2.php on line 55


Fatal error: main() [function.require]: Failed opening required 'PEAR.php' (include_path='.:/usr/lib/php:/usr/local/lib/php:/home/ncaha3/public_html/lib/pear/PEAR') in /home/ncaha3/public_html/lib/pear/PEAR/MDB2.php on line 55


I have tried to find the problem, fiddling with permissions and whatnot, but I just can't figure it out. I have set the include path as required and the PEAR.php file is sitting where it should be, where it should be found, and was until today.

Any recommendations? Is there some setting my host company could have changed to produce this error? It doesn't make sense for it to be a path issue, since MDB2 is being found with no problem. This is the code that brings in the libs:

Code:
require_once 'MDB2.php';
require_once 'DB/Table.php';


Please...
Back to top
View user's profile Send private message
mark



Joined: 07 Jan 2007
Posts: 1048

PostPosted: Mon Jul 21, 2008 8:13 pm    Post subject: Reply with quote

Your host has added an open_basedir restriction, i.e. you can only access several paths on the server (those mentioned in the first message).

I assume that you have your own PEAR installation in /home/ncaha3/public_html/lib/pear/PEAR? As you may not access /usr/lib/php (first path in the include_path, but not within the open_basedir restriction), you'll need to modify the include_path. Your own PEAR directory needs to be at the beginning or at least before /usr/lib/php.

Using .:/home/ncaha3/public_html/lib/pear/PEAR as the include_path should work.
Back to top
View user's profile Send private message
pixelterra



Joined: 29 Feb 2008
Posts: 9

PostPosted: Mon Jul 21, 2008 9:41 pm    Post subject: Reply with quote

Thank You Mark!

Changing this:

Code:
set_include_path(get_include_path(). PATH_SEPARATOR . '/home/ncaha3/public_html/lib/pear/PEAR' );


To this:

Code:
set_include_path('/home/ncaha3/public_html/lib/pear/PEAR' . PATH_SEPARATOR . get_include_path());


Seems to have fixed the problem, though I must say I still don't understand the purpose of the open_basedir if it can be circumvented so easily.
Back to top
View user's profile Send private message
mark



Joined: 07 Jan 2007
Posts: 1048

PostPosted: Mon Jul 21, 2008 9:50 pm    Post subject: Reply with quote

You don't circumvent it (and you can't do that). The old include_path was referring to a directory for that you don't have access anymore. By removing this directory from the include_path you just made your code working again.

Actually, I also see a benefit: The old setting caused PHP to look first in the global PEAR installation on the server. If a file wasn't found there, PHP looked into your own installation. If the global installation contained old versions of one or more packages, while your own installation was more up-to-date, PHP had used the older files. With the new setting, PHP will always use your installation. (Of course, you could have changed this yourself earlier, but the open_basedir restriction forced you to change the path.)
Back to top
View user's profile Send private message
pixelterra



Joined: 29 Feb 2008
Posts: 9

PostPosted: Mon Jul 21, 2008 10:20 pm    Post subject: Reply with quote

I definitely see your point about looking in my install of PEAR first being a benefit.

However, I don't see that the include path contains different directories, just a different order. I think what you're saying is the path(s) in get_include_path () produce errors because of the open_basedir restriction? I can understand this, but since I hadn't modified the include_path before, the path(s) coming from get_include_path are default. So, if I'm not mistaken the default server configuration is biting it's own heels by defining an include_path, and then barking at the user for trying to look in those directories.

Since I'm still using get_include_path() in my code, I guess the script locates my files before an error would happen. If this is the case, perhaps I should change

this
Code:
set_include_path('/home/ncaha3/public_html/lib/pear/PEAR' . PATH_SEPARATOR . get_include_path());


to this?

Code:
set_include_path('/home/ncaha3/public_html/lib/pear/PEAR' );


Since I assume otherwise that any required file that is not found would first produce a open_basedir error before a not found error. Is this right?

Thanks for your help on this BTW.
Back to top
View user's profile Send private message
mark



Joined: 07 Jan 2007
Posts: 1048

PostPosted: Mon Jul 21, 2008 10:37 pm    Post subject: Reply with quote

Your assumption is right. If e.g. MDB2.php wouldn't be found in /home/ncaha3/public_html/lib/pear/PEAR, PHP would also look into the next directory of the include_path. If it isn't found there, if would check the next directory etc.

/usr/lib/php/ would indeed generate an open_basedir error if PHP needs to (try to) look into this directory.

Therefore, using
Code:
set_include_path('/home/ncaha3/public_html/lib/pear/PEAR');
or
Code:
set_include_path('.:/home/ncaha3/public_html/lib/pear/PEAR');
like I mentioned it before would be a good idea. This avoids both the possible open_basedir error and also makes your script a little bit faster because of less operations PHP needs to do.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    PEAR Forum Forum Index -> Installation, Upgrading & Configuration All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



PEAR Forum topic RSS feed 
Powered by phpBB © 2001, 2005 phpBB Group

Provided by Ministry of Web developement

'Actiemonitor' online projectmanagement software