public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
From: Corinna Vinschen <corinna-cygwin@cygwin.com>
To: cygwin@cygwin.com
Subject: Re: Issue with resolving symlinks (realpath, readlink, etc)
Date: Tue, 12 Dec 2017 14:14:00 -0000	[thread overview]
Message-ID: <20171212091642.GS18791@calimero.vinschen.de> (raw)
In-Reply-To: <CAJ+sA07Ek0oFmmXJHqgsiciOJ2=fH3QNFPA0rAfnmev-TMU++A@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1446 bytes --]

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

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

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

      reply	other threads:[~2017-12-12  9:17 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-11 19:58 João Eiras
2017-12-12 14:14 ` Corinna Vinschen [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171212091642.GS18791@calimero.vinschen.de \
    --to=corinna-cygwin@cygwin.com \
    --cc=cygwin@cygwin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).