All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Theodore Ts'o" <tytso@mit.edu>
To: Eric Biggers <ebiggers@kernel.org>
Cc: fstests@vger.kernel.org
Subject: Re: [PATCH] common/filter: add _filter_bash()
Date: Sat, 18 Dec 2021 12:10:20 -0500	[thread overview]
Message-ID: <Yb4V/GBZDjcXK9qo@mit.edu> (raw)
In-Reply-To: <YbqOO74Lfer5h33Y@sol.localdomain>

On Wed, Dec 15, 2021 at 04:54:19PM -0800, Eric Biggers wrote:
> 
> Doesn't this happen with any shell command passed to -c, not just commands that
> run an executable?  In the commands below which are causing the problem, it is
> actually the 'echo' built-in being used, not an executable.

Well.... it happens with all executables and *some* built-in commands
which returns an error.  (See the postscript for a case where the line
number is printed.)  In the case of an error opening the redirected
standard output, such as permission denied, the difference does occur:

Compare:

% schroot -c buster-amd64 -- bash -c "echo foo >> /bin/bash"
bash: /bin/bash: Permission denied
% schroot -c buster-amd64 -- bash --version
GNU bash, version 5.0.3(1)-release (x86_64-pc-linux-gnu)
Copyright (C) 2019 Free Software Foundation, Inc.
...

with

% schroot -c bullseye-amd64 -- bash -c "echo foo >> /bin/bash"
bash: line 1: /bin/bash: Permission denied
% schroot -c bullseye-amd64 -- bash --version
GNU bash, version 5.1.4(1)-release (x86_64-pc-linux-gnu)
...

I just used the example of "bash -c /etc/passwd" because it was
simpler, and because it would be easy to verify regardless of whether
the command was executed as root or not.  For example:

% schroot -c bullseye-amd64 -u root -- bash -c "echo foo >> /bin/bash"

would have succeeded (and corrupted /bin/bash in my chroot :-).

I suppose I could have used the "schroot -c ..." example in the commit
description, but that's a debian-specific command, and I chose to err
on the side of something simpler and easier to replicate.

If Eryu would prefer, I can resend with a modified commit description,
or he can feel free to edit the commit description with the above
example if he thinks it's clearer.

Cheers,

				- Ted

P.S. The 5.1 behavior is actually a bit more consistent, since other
errors involving built-ins do actualy print a line number (although
not a *consistent* line number between bash 5.0 and 5.1:

% schroot -c buster-amd64 -- bash -c "jobs --bad-option"
bash: line 0: jobs: --: invalid option
...

vs

% schroot -c bullseye-amd64 -- bash -c "jobs --bad-option"
bash: line 1: jobs: --: invalid option
...

So the changes in Bash 5.1 error reporting does have something to
recommend itself in terms of self-consistency, but it is a bit of pain
for xfstests, where any changes in output requires extra filter
hacking!

  reply	other threads:[~2021-12-18 17:10 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-14 17:04 [PATCH] common/filter: add _filter_bash() Theodore Ts'o
2021-12-16  0:54 ` Eric Biggers
2021-12-18 17:10   ` Theodore Ts'o [this message]
2021-12-19  2:34     ` Eric Biggers
2021-12-19  4:16       ` [PATCH -v2] " Theodore Ts'o
2021-12-19  5:24         ` Eric Biggers
  -- strict thread matches above, loose matches on Subject: below --
2021-08-30 11:41 [PATCH] " Theodore Ts'o
2021-08-31 23:53 ` Dave Chinner

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=Yb4V/GBZDjcXK9qo@mit.edu \
    --to=tytso@mit.edu \
    --cc=ebiggers@kernel.org \
    --cc=fstests@vger.kernel.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.