Improper symlink resolution
Corinna Vinschen
corinna-cygwin@cygwin.com
Wed Mar 5 13:52:00 GMT 2014
On Mar 4 14:48, Paul Gilmartin wrote:
> On Windows 7, Cygwin 1.7.28(0.271/5/3), the script:
>
> 603 $ cat badsyml
> # #######################################################
> #! /bin/sh -x
>
> uname -a
>
> mkdir -p wombat/foo1/foo2
> cd wombat
> ln -s foo1/foo2 .
> date >foo1/xyzzy
>
> find . -ls
> cat foo2/../xyzzy
> # #######################################################
>
> Fails with:
> # #######################################################
> 604 $ rm -r wombat
> 605 $ ./badsyml
> badsyml 3+ uname -a
> CYGWIN_NT-6.1-WOW64 PGILMART-US 1.7.28(0.271/5/3) 2014-02-04 16:18 i686 Cygwin
> badsyml 5+ mkdir -p wombat/foo1/foo2
> badsyml 6+ cd wombat
> badsyml 7+ ln -s foo1/foo2 .
> badsyml 8+ date
> badsyml 10+ find . -ls
> 33495522228574359 0 drwxr-xr-x 1 PGILMART None 0 Mar 3 11:22 .
> 104427216359660155 0 drwxr-xr-x 1 PGILMART None 0 Mar 3 11:22 ./foo1
> 310185424335151883 0 drwxr-xr-x 1 PGILMART None 0 Mar 3 11:22 ./foo1/foo2
> 90916417477552943 1 -rw-r--r-- 1 PGILMART None 27 Mar 3 11:22 ./foo1/xyzzy
> 12103423998567573 1 lrwxrwxrwx 1 PGILMART None 9 Mar 3 11:22 ./foo2 -> foo1/foo2
> badsyml 11+ cat foo2/../xyzzy
> cat: foo2/../xyzzy: No such file or directory
> 606 $
> # #######################################################
>
> I believe, rather, that the PWD environment variable is a
> feature of the POSIX shell (implemented by bash) and should
> not affect the operation of utilities such as "cat" or the
> underlying system calls. The symbolic link to ".." (parent
> directory) should be resolved, not relative to the logical
> path that reached it, but to the directory physically containing
> it, as Linux, Solaris, z/OS, and OS X do:
This is a known problem and nothing we can easily change without a
complete rewrite of the core path handling code. We described this in
great length on this list already, so, please search the archives. But,
basically, the code is performing a few non-POSIXy shortcuts to speed up
path conversion from POSIX to Windows paths, mainly:
- checking the path backwards rather than forward as mandated by POSIX,
- and folding ".." path components from the path before checking the
parent path component for being a symlink.
Corinna
--
Corinna Vinschen Please, send mails regarding Cygwin to
Cygwin Maintainer cygwin AT cygwin DOT com
Red Hat
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin/attachments/20140305/86bbb32f/attachment.sig>
More information about the Cygwin
mailing list