From: Daniel Shahaf <d.s@daniel.shahaf.name>
To: Stephane Chazelas <stephane.chazelas@gmail.com>
Cc: Zsh hackers list <zsh-workers@zsh.org>
Subject: Re: [bug] :P modifier and symlink loops
Date: Mon, 3 Feb 2020 05:19:24 +0000 [thread overview]
Message-ID: <20200203051924.05bc9773@tarpaulin.shahaf.local2> (raw)
In-Reply-To: <20200202170357.imwazvlz5eeudn6g@chazelas.org>
Stephane Chazelas wrote on Sun, 02 Feb 2020 17:03 +0000:
> 2020-02-02 08:10:21 +0000, Daniel Shahaf:
> [...]
> > However, in ${${:-"/tmp/loop/../foo"}} we can't meet the postcondition.
> > I think our options are either to throw an exception, like a glob with
> > no matches does, or to keep the additional components verbatim, as you
> > suggest.
> >
> > Intuitively I lean towards the first option. We aren't a CGI script,
> > where PATH_INFO is to be expected. If we can't return a path without
> > dot and dot-dot components and without symlinks, we should raise an
> > error rather than continue silently. However, I'm open to alternatives.
>
> That works for me, I agree it's a pathological condition that
> may be worth reporting to the user, and to do that, there's
> probably no other alternative than to exit the current shell
> process.
>
> > I think the first option could be implemented along the lines of:
> >
> > 1. Call realpath($arg).
> > 2. If it returns ELOOP,
>
> ... and doesn't end in /..
I assume you mean "ends in slash-dot-dot".
> the . path components would have to be removed first as well.
Good point, but I'd expect slightly different behaviour. Dot and
dot-dot components before the last, may-be-loop components don't need
special handling; they'll get resolved in the ordinary way. However,
if [[ $arg == (*/|*/.|*/..) ]], the ELOOP special case shouldn't be
applied.
The cases that $arg is "", ".", or ".." are not going to report ELOOP,
are they?
> > call realpath(${arg:h}) and append "/${arg:t}".
>
> And what if *that* realpath() fails with ELOOP? Do we carry on
> with $arg:h:h?
No; we'll call zerr() [which sets errflag] and bail out, just like the
NO_MATCH option does. Only the last path component (after the last slash,
or the entire string if it has no slashes) will be allowed to be a loop.
> > 3. Otherwise, throw an exception (i.e., set errflag).
> [...]
>
Cheers,
Daniel
next prev parent reply other threads:[~2020-02-03 5:20 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-11 17:00 Stephane Chazelas
2020-02-01 17:57 ` Stephane Chazelas
2020-02-02 8:10 ` Daniel Shahaf
2020-02-02 17:03 ` Stephane Chazelas
2020-02-03 5:19 ` Daniel Shahaf [this message]
2020-03-21 19:50 ` Daniel Shahaf
2020-03-26 0:38 ` Daniel Shahaf
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=20200203051924.05bc9773@tarpaulin.shahaf.local2 \
--to=d.s@daniel.shahaf.name \
--cc=stephane.chazelas@gmail.com \
--cc=zsh-workers@zsh.org \
/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.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
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 NNTP newsgroup(s).