Include fails with toplevel symlink to /
| Bug #51860 | Include fails with toplevel symlink to / | |||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Submitted: | 2010-05-19 16:46 UTC | Modified: | 2012-01-30 10:52 UTC |
|
||||||||||
| From: | stephan dot suerken at 1und1 dot de | Assigned: | dmitry (profile) | |||||||||||
| Status: | Closed | Package: | Scripting Engine problem | |||||||||||
| PHP Version: | 5.3.2 | OS: | ||||||||||||
| Private report: | No | CVE-ID: | None | |||||||||||
[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
Patches
Pull Requests
History
AllCommentsChangesGit/SVN commits
[2010-05-20 14:14 UTC] mike@php.net
[2010-05-20 14:14 UTC] mike@php.net
-Status: Open +Status: Feedback
[2010-05-21 12:06 UTC] thekid@php.net
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:)[2010-05-21 13:05 UTC] stephan dot suerken at 1und1 dot de
-Status: Feedback +Status: Open
[2010-05-21 13:05 UTC] stephan dot suerken at 1und1 dot de
[2010-05-21 13:12 UTC] thekid@php.net
[2010-05-21 13:37 UTC] thekid@php.net
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)[2010-05-21 13:44 UTC] stephan dot suerken at 1und1 dot de
[2010-05-21 13:58 UTC] thekid@php.net
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)[2010-05-21 14:04 UTC] stephan dot suerken at 1und1 dot de
-Status: Analyzed +Status: Open
[2010-05-21 14:04 UTC] stephan dot suerken at 1und1 dot de
[2010-05-30 01:05 UTC] felipe@php.net
-Package: Reproducible crash +Package: Scripting Engine problem
[2010-06-27 12:26 UTC] rainer at hosting-ist-mein-leben dot de
[2010-08-13 17:08 UTC] rainer at hosting-ist-mein-leben dot de
[2011-01-12 17:46 UTC] rainer at hosting-ist-mein-leben dot de
[2011-01-12 17:47 UTC] rainer at hosting-ist-mein-leben dot de
[2011-01-21 10:34 UTC] plubber at gmx dot ch
[2011-07-06 10:36 UTC] rainer at hosting-ist-mein-leben dot de
[2012-01-17 14:51 UTC] startup09 at web dot de
[2012-01-28 13:39 UTC] grobmeier at gmail dot com
[2012-01-28 18:44 UTC] rasmus@php.net
[2012-01-28 18:48 UTC] rasmus@php.net
[2012-01-28 21:11 UTC] rasmus@php.net
[2012-01-30 08:05 UTC] dmitry@php.net
-Assigned To: +Assigned To: dmitry
[2012-01-30 10:52 UTC] dmitry@php.net
-Status: Assigned +Status: Closed