|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2010-05-19 16:46 UTC] stephan dot suerken at 1und1 dot de
Description: ------------ Tarball: http://stephan-suerken.de/tmp/php53include.tar.gz Hi, with a certain directory setup (symlink pointing to /, see file tree in php53include.tar.gz) plus script call syntax (see scripts "ok" and "fail" scripts in tarball), including a file meekly fails. I have not completely debugged it, but afaics "php_resolve_path" fails were it should not; I suspect some of the "canonize path" functions wrongly give an error here. Thanks, Stephan Test script: --------------- Steps to reproduce: 1. Download: http://stephan-suerken.de/tmp/php53include.tar.gz [as root] 2. cd / 3. tar xfz php53include.tar.gz 4. /phptest/fail Expected result: ---------------- # manwe(CHROOT:sid-ui): /phptest # root? ./ok /phpinclude/inc123.php: OK, INCLUDED Actual result: -------------- # manwe(CHROOT:sid-ui): /phptest # root? ./fail PHP Warning: require(/phplink/phpinclude/inc123.php): failed to open stream: No such file or directory in /phptest/test.php on line 2 PHP Fatal error: require(): Failed opening required '/phplink/phpinclude/inc123.php' (include_path='.:/usr/share/php:/usr/share/pear') in /phptest/test.php on line 2 PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Oct 27 09:00:02 2025 UTC |
1) Create a symlink in / to / root@thekid:/ > ln -s / phptest root@thekid:/ > ls -al /phptest lrwxr-xr-x 1 root wheel 1 May 21 10:40 /phptest -> / 2) Verify root@thekid:/ > echo "OK" > /phpfile root@thekid:/ > php -r 'include("/phptest/phpfile");' Expected result: "OK" 3) Clean up root@thekid:/ > rm /phptest /phpfile You need to be root because you're working in /, that's it:)Wait: # /opt/php/php-5.3.2/sapi/cli/php -r 'var_dump(realpath("/phplink/phpinclude/inc123.php"));' string(22) "/phpinclude/inc123.php" ...and: # echo '<?php var_dump(realpath("/phplink/phpinclude/inc123.php"));' > test.php # /opt/php/php-5.3.2/sapi/cli/php test.php string(22) "/phpinclude/inc123.php" But: # echo '<?php var_dump(realpath("/phplink/phpinclude/inc123.php"));' > /phplink/phptest/test.php # /opt/php/php-5.3.2/sapi/cli/php /phplink/phptest/test.php bool(false) So if the executed script itself is inside the symlink'd directory, VCWD_REALPATH() does not correctly work (used by both include / require and realpath(), that's why I'm using the latter here) This does not occur with PHP 5.2.X (or PHP4, btw)Here's the simplest way to reproduce: xpsrv / # ln -s / phptest xpsrv / # echo "OK" > /phpfile xpsrv / # echo '<?php include("/phptest/phpfile");' > /phpinc Works: xpsrv / # php532 /phpinc OK Breaks: xpsrv / # php532 /phptest/phpinc Warning: include(/phptest/phpfile): failed to open stream: No such file or directory in /phpinc on line 1 Warning: include(): Failed opening '/phptest/phpfile' for inclusion (include_path='.:') in /phpinc on line 1 xpsrv / # php532 -v | head -1 PHP 5.3.2 (cli) (built: May 21 2010 12:18:37)