Bug #69351 [NEW]: recursive mkdir fails with parent (dot dot) directory in path and symlink
| From: | dave2008 at buchananville dot net | Date: | Wed, 01 Apr 2015 22:18:55 +0000 |
| Subject: | Bug #69351 [NEW]: recursive mkdir fails with parent (dot dot) directory in path and symlink | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-191773@lists.php.net to get a copy of this message | ||
From: dave2008 at buchananville dot net
Operating system:
PHP version: 5.4.39
Package: Directory function related
Bug Type: Bug
Bug description:recursive mkdir fails with parent (dot dot) directory in path and symlink
Description:
------------
Running recursive mkdir fails when there is a ".." directory in the
path, and a symbolic link is present:
mkdir('a/d/../e',0755,true);
The problem is that it is is expanding the path string in place instead
of following the physical filesystem. After it traverses into a/d, the
".." directory actually takes you somewhere else. Not to "a". In bash
this is like
cd -P.
It worked like this in previous versions (at least on PHP 5.3.3 and
before).
Where previous versions of PHP have acted this way, I think it is best
for backwards compatibility for this to work.
It looks like this was broken when the fix for bug #55124 was applied:
it made it use expand_filepath_with_mode() with the CWD_EXPAND. Maybe
it should have used CWD_REALPATH instead? Just a guess...
Test script:
---------------
<?php
mkdir('a/b/c',0755,true);
symlink('b/c','a/d');
chmod('a',0555);
mkdir('a/d/../e',0755,true);
Expected result:
----------------
On PHP 5.3.3 it runs with no output
Actual result:
--------------
PHP Warning: mkdir(): Permission denied in
/var/autofs/home/dave/test-recursive-mkdir.php on line 7
--
Edit bug report at https://bugs.php.net/bug.php?id=69351&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=69351&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=69351&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=69351&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=69351&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=69351&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=69351&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=69351&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=69351&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=69351&r=support
Expected behavior: https://bugs.php.net/fix.php?id=69351&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=69351&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=69351&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=69351&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=69351&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=69351&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=69351&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=69351&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=69351&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=69351&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=69351&r=mysqlcfg