This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Improper symlink resolution


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:
# #######################################################
524 $ rm -r wombat
525 $ '/home/paulgilm/Desktop/sf_Shared'/badsyml
badsyml + uname -a
Linux Ubuntu-Lenovo-1 3.2.0-59-generic-pae #90-Ubuntu SMP Tue Jan 7 23:07:06 UTC 2014 i686 i686 i386 GNU/Linux
badsyml + mkdir -p wombat/foo1/foo2
badsyml + cd wombat
badsyml + ln -s foo1/foo2 .
badsyml + date
badsyml + find . -ls
1450073    4 drwxrwxr-x   3 paulgilm paulgilm     4096 Mar  3 11:21 .
1450074    4 drwxrwxr-x   3 paulgilm paulgilm     4096 Mar  3 11:21 ./foo1
1450075    4 drwxrwxr-x   2 paulgilm paulgilm     4096 Mar  3 11:21 ./foo1/foo2
1450077    4 -rw-rw-r--   1 paulgilm paulgilm       29 Mar  3 11:21 ./foo1/xyzzy
1450076    0 lrwxrwxrwx   1 paulgilm paulgilm        9 Mar  3 11:21 ./foo2 -> foo1/foo2
badsyml + cat foo2/../xyzzy
Mon Mar  3 11:21:22 MST 2014
526 $
# #######################################################

Thanks,
gil








Attachment: cygcheck.out
Description: Text document

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]