GNU bug report logs - #25817
rm: add option to avoid early exit on "."

Previous Next

Package: coreutils;

Reported by: L A Walsh <coreutils <at> tlinx.org>

Date: Mon, 20 Feb 2017 19:42:02 UTC

Severity: wishlist

Full log


View this message in rfc822 format

From: L A Walsh <coreutils <at> tlinx.org>
To: Eric Blake <eblake <at> redhat.com>
Cc: 25817 <at> debbugs.gnu.org
Subject: bug#25817: Why were Gnu coding standards violated in favor of posix for 'rm -fr .'?: request for reversion of behavior
Date: Mon, 20 Feb 2017 13:10:24 -0800

Eric Blake wrote:
> tag 25817 needinfo
> thanks
> 
> On 02/20/2017 01:41 PM, L A Walsh wrote:
> 
>> So... why should 'rm' not be able to start it's deletion
>> from the inside of a directory? (@ "." )?
> 
> Please give more details as to what you think is broken.  Instead of
> describing the problem in vague prose, please show a shell transcript
> that creates a sample directory layout and cd's into the place that you
> want, then attempts the removal that currently fails, as well as
> explaining what you hoped to have happen instead of an error message.
-----
#!/bin/bash
cd /tmp || exit 1
mkdir tstdir || exit 1
mkdir tstdir/usr
mkdir tstdir/var
mount --bind /var /tmp/tstdir/var
mount --bind /usr /tmp/tstdir/usr
mkdir tstdir/{1,2,3}
cd /tmp/tstdir || exit
rm -fr . --one-file-system
---------
Output:
rm: refusing to remove ‘.’ or ‘..’ directory: skipping ‘.’
----
Instead, it should have removed dirs 1,2,3 and not 
not 'var' or 'usr'.


----

rm originally did a depth first traversal and deletion
of files under it.

a few to several years ago a posix change was added to 
change the depth-first traversal and to
inspect local paths before doing the depth-first traversal
of directories like '.' -- and if it found '.' to disallow
any paths below '.' (prior to the depth-first traversal that
used to happen).








This bug report was last modified 6 years and 231 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.