I manage a web server with many hosted virtual servers. I am experiencing problems with includes in PHP 4.3.0 under Solaris, and I can't upgrade my server. I think it has something to do with getcwd() not working on Solaris if a component of the path is not readable by the server, which is the case for most virtual server document roots.
Most errors are with PHP codes which include things from the parent directory (..), which is in 'include_path'.
Look at this test:
tests/ |- inc |- inc.txt include OK |- mydir/ |- testinclude.php <? echo 'getcwd:', getcwd(), '<BR>'; include ('inc/inc.txt'); ?>
I have two httpd working, with the same config file except the port number (the server on 8088 loads the 4.3.0 version of libphp.so).
safe_mode is off. Include_path is '.:../:../../' for 4.2.1.
With PHP 4.2.1, <http//my.server.com/tests/mydir/testinclude.php> works OK. With 4.3.0, <http//my.server.com:8088/tests/mydir/testinclude.php> gives: Failed opening 'inc/inc.txt' for inclusion (include_path='.:../:/usr/local/php-4.3.0/lib/php') in /usr/local/www/docs/www/tests/mydir/testinclude.php on line 2
getcwd() returns nothing in both cases, since a directory is -rwx--x--x
On Solaris, getcwd() needs "r" access to _all_ directories of the path, otherwise you get (from "man getcwd"):
EACCES A parent directory cannot be read to get its name.
(It's not a bug, but a feature; seems strange to me).
include '../inc/inc.txt' does not work either. The only way I found to get it work in PHP 4.3.0 is "chmod o+r" on every component of the dir path (this way, getcwd() returns the right value, and include works). It looks like PHP resolves the pathname itself, using getcwd(). Due to this feature of Solaris, in my opinion, it's not a good idea to rely on this function to get a real pathname.
I can't tell the webmasters to "chmod o+r" their directories. What else can I do to be able to upgrade my server?
-- PHP Install Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php