zsh-workers
 help / color / mirror / code / Atom feed
From: Stephane Chazelas <stephane@chazelas.org>
To: Daniel Shahaf <d.s@daniel.shahaf.name>
Cc: zsh-workers@zsh.org
Subject: Re: glob qualifier '-' doesn't work correctly on dangling symlinks
Date: Tue, 14 Apr 2020 13:38:03 +0100	[thread overview]
Message-ID: <20200414123803.2ps5p475l4kiyfmp@chazelas.org> (raw)
In-Reply-To: <20200414120241.3d8d7246@tarpaulin.shahaf.local2>

2020-04-14 12:02:41 +0000, Daniel Shahaf:
[...]
> Counter-argument: since an ENOMEM during symlink resolution causes
> «(-@)» to presume the symlink is broken, the zsh language is
> non-deterministic: what «intact-symlink(N-@)» will expand to will
> depend on whether there is enough memory at runtime.
> 
> Shouldn't an ENOMEM during expansion of «intact-symlink(N-@)» result in
> an error?  "In the face of ambiguity, refuse the temptation to guess."
> 
> That is: I think there's a qualitative difference between ENOENT and ENOMEM.
[...]

ENOMEM/EFAULT/EINVAL are the kind of pathological errors for
which I'd say you can't do much more than best effort.

If you run out of kernel memory to the point that stat() in your
shell fails, or if bits start to randomly flip causing
EFAULT/EINVAL, more things are going to fail and an inaccurate
glob expansion is probably the least of your concerns.

And what can you do? Check errno after each and every system
call? And what's the list of errno values we should consider?
And how should we handle them? How likely is it to happen?
What's the worst that can happen if it's not handled "properly"?
Can that be exploited?

Say you're the sysadmin that needs to fix that low kernel memory
situation, it's probably better to keep your shell running as
long as possible. That's a narrow ridge to walk on there. I
agree that letting the user know of that pathological condition
is useful, but we need to be careful the cure be not worse than
the disease.

In any case, I would imagine this kind of consideration has
already been discussed at length here and elsewhere. In anycase,
I'm no expert at all on that.

-- 
Stephane

  reply	other threads:[~2020-04-14 12:38 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-11 15:15 Vincent Lefevre
2020-04-11 17:34 ` Stephane Chazelas
2020-04-11 19:17   ` Vincent Lefevre
2020-04-11 20:37     ` Stephane Chazelas
2020-04-11 23:48       ` Vincent Lefevre
2020-04-12  1:21         ` Daniel Shahaf
2020-04-12  2:17           ` Vincent Lefevre
2020-04-12  7:09             ` Stephane Chazelas
2020-04-12 14:25               ` Vincent Lefevre
2020-04-12 17:34                 ` Stephane Chazelas
2020-04-12 23:38                   ` Vincent Lefevre
2020-04-13 14:22                     ` Stephane Chazelas
2020-04-13 15:00                       ` Bart Schaefer
2020-04-13 21:41                       ` Vincent Lefevre
2020-04-14  6:18                         ` Stephane Chazelas
2020-04-14 12:02                           ` Daniel Shahaf
2020-04-14 12:38                             ` Stephane Chazelas [this message]
2020-04-15  0:44                               ` Daniel Shahaf
2020-04-15  9:17                                 ` Vincent Lefevre
2020-04-14 17:59                           ` Vincent Lefevre
2020-04-12 12:48   ` Peter Stephenson
2020-04-12 14:31     ` Vincent Lefevre
2020-04-12 15:49       ` Peter Stephenson
2020-04-12 23:07         ` Vincent Lefevre

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=20200414123803.2ps5p475l4kiyfmp@chazelas.org \
    --to=stephane@chazelas.org \
    --cc=d.s@daniel.shahaf.name \
    --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).