Web lists-archives.com

Re: Issue with resolving symlinks (realpath, readlink, etc)

On Dec 11 18:18, João Eiras wrote:
> Hi.
> Programs and functions that rely in realpath() are broken.
> Example:
> $ cd
> $ ln -s /var symlink
> $ cd symlink
> $ readlink -m .
> /var
> $ mkdir subfolder
> $ cd subfolder
> $ readlink -m .
> /home/user/symlink/subfolder
> # should be /var/subfolder
> This is the block I think is causing problems, as it breaks the loop
> as soon as a real file is found, instead of iterating further upwards
> resolving ancestors.
> https://cygwin.com/git/gitweb.cgi?p=newlib-cygwin.git;a=blob;f=winsup/cygwin/path.cc#l994
> There also a comment at line 736 that says:
> "Scan path_copy from right to left looking either for a symlink or an
> actual existing file. If an existing file is found, just return. If a
> symlink is found, exit the for loop."

This is an old problem in the path_conv class, given that POSIX
mandates scanning the patch from left to right.

However, changing this isn't simple.  For one thing the path conversion
POSIX<->Windows is already slower than desired, and scanning from left
to right would make it probably worse.  But the real problem is that
this would basically mean a re-write of the path_conv class.  Given how
much this is a core component it's quite the task.


Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Maintainer                 cygwin AT cygwin DOT com
Red Hat

Attachment: signature.asc
Description: PGP signature