Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: glob qualifier '-' doesn't work correctly on dangling symlinks



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



Messages sorted by: Reverse Date, Date, Thread, Author