From: Andrei Borzenkov <arvidjaar@gmail.com>
To: The development of GNU GRUB <grub-devel@gnu.org>
Subject: Re: Behavior of file test operations on symlinks
Date: Wed, 17 Feb 2016 19:42:45 +0300 [thread overview]
Message-ID: <56C4A305.8010206@gmail.com> (raw)
In-Reply-To: <CALKzxMRzdJuZj6vkTOJ_kh=M5dqTrQ2ocufx4kGaJsec573gTA@mail.gmail.com>
17.02.2016 03:34, Alan Dunn пишет:
> Hi folks,
>
> Apologies if the following has already come up on this list; I looked for
> it and could not find any mention of it.
>
> I noticed that in a GRUB script "[ -f <dangling symlink path> ]" evaluates
> to true. This is unlike the behavior of the "test" binary, in which it
> returns false: most file test operations dereference their symlinks
> recursively (i.e., strace on Linux reveals they use stat, which does
> this). By contrast, "[ -s <dangling symlink path> ]" evaluates to false,
> which seems inconsistent since if the file exists by -f, then it seems like
> -f is referring to the symlink itself, which has non-zero file size.
>
It looks rather side effect of implementation which looks for directory
entry.
It is straightforward to fix it by just trying to grub_file_open() which
fails in this case. But the interesting question is semantic of both
tests with mandatory signature checking in place. I.e. if signature for
a file is invalid, should "test -s" and "test -f" still report true? I
suppose yes, because file still exists.
> I was curious whether there is some motivation with respect to any
> deviations that GRUB has in interpreting file test operations in comparison
> to the "test" binary, or whether this is considered a bug/thing that should
> be improved in the documentation. The GRUB manual (
> http://git.savannah.gnu.org/cgit/grub.git/tree/docs/grub.texi) only
> indicates that -f tests whether the "file exists and is not a directory"
Well, current behavior is compliant with this description (symlink does
exist and it is not directory), it is just not very useful in practice.
Actually implementing "test -h" is pretty trivial.
> without specifying the symlink behavior (unlike "man test").
>
I vote for changing it to follow symlink. Anyone has argument to keep
current behavior?
next prev parent reply other threads:[~2016-02-17 16:42 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-17 0:34 Behavior of file test operations on symlinks Alan Dunn
2016-02-17 16:42 ` Andrei Borzenkov [this message]
2016-02-17 20:19 ` Alan Dunn
2016-02-18 3:46 ` Andrei Borzenkov
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=56C4A305.8010206@gmail.com \
--to=arvidjaar@gmail.com \
--cc=grub-devel@gnu.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.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.