Bug #69473 [Asn]: bug in symlink() prevents relative symlinks on Windows

From: Date: Mon, 20 Apr 2015 07:50:54 +0000
Subject: Bug #69473 [Asn]: bug in symlink() prevents relative symlinks on Windows
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-192229@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=69473&edit=1 ID: 69473 Updated by: ab@php.net Reported by: email at spikx dot net Summary: bug in symlink() prevents relative symlinks on Windows Status: Assigned Type: Bug Package: Filesystem function related Operating System: Windows 7 PHP Version: 5.6.8 Assigned To: pajoye Block user comment: N Private report: N New Comment: see also bug #68167 Previous Comments: ------------------------------------------------------------------------ [2015-04-20 07:45:48] ab@php.net The main concern I'd like to express about this is the thread safety. A robust solution should include CWD magic when relative paths are used. Otherwise it might make sense to rework this for CLI or NTS only. What @spikx means about chdir in PHP looks like confused with _chdir in CRT. Two completely unrelated things, so chdir() in PHP can't affect anything in the symlink behavior. Thanks. ------------------------------------------------------------------------ [2015-04-18 14:44:12] cmb@php.net I've submitted the PR <https://github.com/php/php-src/pull/1243>. Pierre, can you please have a look at it. ------------------------------------------------------------------------ [2015-04-18 12:44:46] cmb@php.net > it's just the $target check Apparently, dest_p has to be checked there instead of topath. I'm working on a respective PR. ------------------------------------------------------------------------ [2015-04-18 11:53:26] email at spikx dot net cmb@php.net: exactly - it's just the $target check [1] right before the pCreateSymbolicLinkA call that prevents using relative symlinks, since the GetFileAttributes expects the path to be either absolute or relative to the CWD, not relative to the parent directories of that in which the link to the target resides. [1] <https://github.com/php/php-src/blob/master/ext/standard/link_win32.c#L169> ------------------------------------------------------------------------ [2015-04-18 10:16:20] cmb@php.net From the symlink(2) man page[1]: | Symbolic links may contain .. path components, which (if used at | the start of the link) refer to the parent directories of that in | which the link resides. This is even acknowledged by a comment in the code[2]: | The target is relative to the link itself, not to the CWD. However, it doesn't behave that way. [1] <http://man7.org/linux/man-pages/man2/symlink.2.html> [2] <https://github.com/php/php-src/blob/master/ext/standard/link_win32.c#L176> ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at https://bugs.php.net/bug.php?id=69473 -- Edit this bug report at https://bugs.php.net/bug.php?id=69473&edit=1

« previous php.bugs (#192229) next »