php.ini include_path and open_basedir

  • rjmthezonenet
  • Expert
  • Expert
  • User avatar
  • Posts: 526
  • Loc: St. John's, Newfoundland, Canada

Post 3+ Months Ago

This is driving me mad...

Does the php.ini include_path directive work exactly like a shell PATH, or does it mean a specific directory as well as all sub-directories?

Does the php.ini open_basedir mean a specific directory or a specific directory as well as all sub-directories?

http://host.tld/phpBB2/install/install.php dies with several errors similar to:

Code: [ Select ]
Warning: open_basedir restriction in effect. File is in wrong directory in USER:/Apache2/htdocs/phpBB2/install/install.php on line 297

Warning: Failed opening './../extension.inc' for inclusion (include_path='.;sys:/php/includes;user:/Apache2/includes') in USER:/Apache2/htdocs/phpBB2/install/install.php on line 297
  1. Warning: open_basedir restriction in effect. File is in wrong directory in USER:/Apache2/htdocs/phpBB2/install/install.php on line 297
  2. Warning: Failed opening './../extension.inc' for inclusion (include_path='.;sys:/php/includes;user:/Apache2/includes') in USER:/Apache2/htdocs/phpBB2/install/install.php on line 297


<?php phpinfo (); ?> reports:

Code: [ Select ]
include_path .;sys:/php/includes;user:/Apache2/includes
open_basedir .;sys:/tmp;user:/Apache2/htdocs
  1. include_path .;sys:/php/includes;user:/Apache2/includes
  2. open_basedir .;sys:/tmp;user:/Apache2/htdocs


I thought this meant that install.php could back out of it's current directory (./../) and include other files because user:/Apache2/htdocs was in the open_basedir. Apparently not!

Another oddity. If I edit line 297 from:

Code: [ Select ]
include($phpbb_root_path.'extension.inc');


to:

Code: [ Select ]
include('extension.inc');


and copy extension.inc to the ./install directory, the error doesn't change (which makes absolutely NO sense to me).

Help greatly appreciated!

P.S. This is PHP 4.2.4-dev with Apache 2.0.45 running on NetWare 6.5.
  • _Leo_
  • Proficient
  • Proficient
  • User avatar
  • Posts: 279
  • Loc: Buenos Aires, Argentina

Post 3+ Months Ago

I think I can't help you. I can tell you, the include path works (on unix at least) just like a PATH environment variable. Which means If you have include_path = ".:/home/myuser/phpinclude/:/usr/serverwide/phpinclude/"

You will be able to include the file 'incfile.php' using include('incfile.php'); from a script if the file 'incfile.php' is placed on:

. (the same directory of the script)
/home/myuser/phpinclude/ (an imaginary directory)
/usr/serverwide/phpinclude/ (an imaginary directory)

If you use include('../../file.php'); you need the file just there, two directory levels up from the script directory.

Since you are using NetWare, I can't tell if some of these behaviors will be different in Unix. Hope it helps anyway.
  • rjmthezonenet
  • Expert
  • Expert
  • User avatar
  • Posts: 526
  • Loc: St. John's, Newfoundland, Canada

Post 3+ Months Ago

_Leo_ wrote:
...the include path works (on unix at least) just like a PATH environment variable... ...you need the file just there, two directory levels up from the script directory.


Hi Leo,

Thanks for writing. Just to clarify for all those reading. I have tried calling the file without a path ('file.php') and the file located in a directory identified by include_path. I have also tried leaving the file as-is with both include_path and open_basedir referencing the exact location.

The language used to document these two directives could use a touch more clarification just to rule out any cause for confusion...

Should I know consider this a bug?
  • _Leo_
  • Proficient
  • Proficient
  • User avatar
  • Posts: 279
  • Loc: Buenos Aires, Argentina

Post 3+ Months Ago

mmmmm... may be a bug in the NetWare port.

Has the user running the apache process read permissions for the file to be included?

Check the permissions of the directories in the include path as well.

Try opening the file to be included right from the web browser. This way you will be sure you don't have an access problem. PHP can't tell the difference between an unexisting file and a file unaccessable for its user.
  • rjmthezonenet
  • Expert
  • Expert
  • User avatar
  • Posts: 526
  • Loc: St. John's, Newfoundland, Canada

Post 3+ Months Ago

volume:/dir/dir/dir works in other sections of the php.ini file. But, I will test /volume/dir/dir/dir just for fun.

I wish I had console access to this computer. Its getting annoying bugging a sysadm to restart ever few minutes while I test.

Quote:
Check the permissions of the directories in the include path as well.


Believe it or not, I can find next to nothing on file permissions and Apache/PHP! I have a feeling Apache/PHP run as a process above and beyond file permissions (entirely unsure about that statement). :-(

Quote:
Try opening the file to be included right from the web browser.


Good idea. I just tested and the .inc file is opened by the web browser (mental note to me: prevent user-agents from requesting .inc files).
  • _Leo_
  • Proficient
  • Proficient
  • User avatar
  • Posts: 279
  • Loc: Buenos Aires, Argentina

Post 3+ Months Ago

I saw you path semicolon (;) separated. The unix PHP uses colon (:) for separating paths. You may test using a : just to see what happens.
  • rjmthezonenet
  • Expert
  • Expert
  • User avatar
  • Posts: 526
  • Loc: St. John's, Newfoundland, Canada

Post 3+ Months Ago

Yeah, the php.ini comments say to use a semi-colon (like Windows). It appears to work in other locations, but I may try just for the heck of it. (Maybe my include_path is just a string that PHP can't deal with...)

Post Information

  • Total Posts in this topic: 7 posts
  • Users browsing this forum: No registered users and 146 guests
  • 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 post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.