bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: readlink(1) behavior


From: Dmitry V. Levin
Subject: Re: readlink(1) behavior
Date: Sat, 19 Sep 2009 17:25:37 +0400

On Fri, Sep 18, 2009 at 02:27:32PM +0200, Jim Meyering wrote:
> Eric Blake wrote:
> > According to Jim Meyering on 9/18/2009 4:47 AM:
> >> Assuming ln -s /nowhere dangling-symlink,
> >> New behavior:
> >>
> >>     $ ./readlink -fv dangling-symlink/
> >>     /nowhere
> >>
> >> Previous:
> >>
> >>     $ readlink -fv dangling-symlink/
> >>     readlink: dangling-symlink/: No such file or directory
> >>     [Exit 1]
> >
> > On one hand:
> >
> > ln -s dangling link => 0
> > stat dangling/ => ENOENT
> > stat link/ => ENOENT
> > mkdir link/ => 0
> >
> > the behavior is consistent - a single mkdir can create the lone missing
> > element in the (expanded) pathname.  If we really claim that -f implies
> > that a missing last element is acceptable if it can be created by the same
> > name, then that explains the new behavior.
> 
> That sounds reasonable.
> Of course, non-creatable dangling links still induce failure:
> 
>     $ rm -rf non-dir; touch non-dir
>     $ ln -s non-dir/file dangling
>     $ ./readlink -fv dangling
>     ./readlink: dangling: Not a directory
> 
> It comes down to weighing the cost of a new option[*]
> and the risk that this change would break someone's script.
> 
> Since changing our ability to detect a dangling symlink might be
> a security-related issue, I'm leaning towards keeping the existing
> semantics, just in case.  However, it's still nearly a toss-up.
> 
> Dmitry, what do you think, now?

I did a brief research; looks like "readlink -f path/" is very rarely
used at all, so chances to trigger a difference in "readlink -f dangling/"
behavior are low, and either of two possible decisions would probably
remain unnoticed by users.

Up to now, if given path does not exist, readlink does not distinguish
causes of the absence.  That is, since readlink was changed to
"$(readlink -fv dir/missing)" == "$(readlink -fv dir/missing/)",
"$(readlink -fv dir/dangling)" == "$(readlink -fv dir/dangling/)"
would look more consistent.


-- 
ldv

Attachment: pgpd0BEMcanep.pgp
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]