From: Dave Chinner <david@fromorbit.com>
To: David Sterba <dsterba@suse.cz>
Cc: fstests@vger.kernel.org, zlang@redhat.com
Subject: Re: Dangerous commands (was:[ANNOUNCE] fstests: for-next branch updated to v2024.02.04)
Date: Fri, 23 Feb 2024 14:53:27 +1100 [thread overview]
Message-ID: <ZdgWt8gz4815Nr/F@dread.disaster.area> (raw)
In-Reply-To: <20240221140951.GJ355@suse.cz>
On Wed, Feb 21, 2024 at 03:09:51PM +0100, David Sterba wrote:
> Hi,
>
> reading [1] and how late it was found that effectively a "rm -rf /" can
> happen makes me worried about what I can expect from fstests after git
> pull. Many people contribute and the number for custom _cleanup()
> functions with unquoted 'rm' commands is just asking for more problems.
>
> [1] https://lore.kernel.org/all/20240205060016.7fgiyafbnrvf5chj@dell-per750-06-vm-08.rhts.eng.pek2.redhat.com/
I started down the _cleanup() path a couple of years ago and one of
the reasons for that was getting rid of all the open coded rm
commands that were often just plain wrong. That start was here:
https://lore.kernel.org/fstests/20220524073411.1943480-1-david@fromorbit.com/
But I got little interest except for one person picking at
irrelevant details and wanting unnecessary API and naming changes
that did nothing to really further the cleanup work.
It did seem like anyone was interested in having this code cleaned
up and so I basically couldn't find the motivation to slog through
hundreds of tests trying do stuff that nobody really seemed to care
about....
Shame, this whole problem would have not existed if that work sort
of infrastructure technical debt reduction was encouraged, and if it
did there'd only be one line of code to change... :/
> Unquoted arguments in shell scripts is IMO a big anti-pattern,
> unfortunately present everywhere in xfstests since the beginning.
> Rewriting all scripts would be quite a lot of work, could you at least
> provide safe versions of the cleanup helpers?
>
> For example:
>
> _rm_tmp() {
> rm -rf -- $tmp
> }
>
> and used as
>
> _cleanup() {
> _rm_tmp
> }
>
> I can send patches at least for btrfs and generic as this affects
> me but first I'd like to know that this will become standard
> coding style requirement in fstests.
I think it would adress this specific issue, but I think it doesn't
address the bigger problem that fixing cleanup behaviour requires
touching a couple of thousand tests. i.e. it doesn't reduce the
maintenance burden of this code at all.
The vast majority of cleanup functions are identical and/or
unnecessary, so the right thing to do is to only have cleanup
functions for tests that need them, and for those that do need to
clean up to only have to clean up their own mess.
i.e. the test harness itself should be responsible for cleaning up
$tmp stuff and doing stuff like returning to the correct directory
after the test completes, not require every test to duplicate the
same cargo-culted behaviour...
Cheers,
Dave.
--
Dave Chinner
david@fromorbit.com
next prev parent reply other threads:[~2024-02-23 3:53 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-21 14:09 Dangerous commands (was:[ANNOUNCE] fstests: for-next branch updated to v2024.02.04) David Sterba
2024-02-21 16:13 ` Darrick J. Wong
2024-02-27 3:40 ` Zorro Lang
2024-02-29 18:44 ` David Sterba
2024-02-29 20:05 ` Eric Biggers
2024-02-23 3:53 ` Dave Chinner [this message]
2024-02-25 15:37 ` Zorro Lang
2024-02-29 19:19 ` David Sterba
2024-02-25 15:16 ` Zorro Lang
2024-02-25 16:51 ` Eric Biggers
2024-02-25 17:03 ` Darrick J. Wong
2024-02-25 17:45 ` Eric Biggers
2024-02-26 2:56 ` Zorro Lang
2024-02-26 18:18 ` Darrick J. Wong
2024-02-26 18:56 ` Darrick J. Wong
2024-02-27 5:18 ` Eric Biggers
2024-02-26 2:25 ` Zorro Lang
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=ZdgWt8gz4815Nr/F@dread.disaster.area \
--to=david@fromorbit.com \
--cc=dsterba@suse.cz \
--cc=fstests@vger.kernel.org \
--cc=zlang@redhat.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox