bug-coreutils
[Top][All Lists]
Advanced

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

Re: coreutils 'rm /' incompatibility with 2006-06-30 draft POSIX


From: Jim Meyering
Subject: Re: coreutils 'rm /' incompatibility with 2006-06-30 draft POSIX
Date: Fri, 01 Sep 2006 12:22:21 +0200

Paul Eggert <address@hidden> wrote:
> The 2006-06-30 draft of POSIX has this new requirement for 'rm':
>
>   if an operand resolves to the root directory, rm shall write a
>   diagnostic message to standard error and do nothing more
>
>   (XCUd1 page 834 lines 32337-32338)
>
> Traditional 'rm' has this behavior, e.g., Solaris 10:
>
>   $ /bin/rm -ir /
>   rm of / is not allowed
>
> but GNU 'rm' does not:
>
>   $ rm -ir /
>   rm: descend into write-protected directory `/'? ^C
>
> I prefer the traditional (and soon-to-be-standardized) behavior, as it
> avoids common user errors when -i is not specified, but I don't fully
> understand how this is implemented in GNU coreutils so I thought I'd
> just report the problem for starters.
>
> A couple of issues I see with the current implementation:
>
>   * The check for root's dev and ino is done recursively, but surely
>     it should be done only at the top level?  (I'm not sure why it's
>     done recursively now.)  The POSIX requirement talks only about the
>     top level, and I don't see how you could recurse to the root.

Hi Paul,

That can happen on a file system that permits hard links to directories,
and, slightly more realistically, with bind mounts.  It would also be
necessary with a corrupt file system (which each of the above would be,
at least by some measure, considering the cycle).

Of course, in those cases, rm would eventually detect the cycle,
but by then it'd probably be far too late to do any good.

>   * The --preserve-root option should now be the default for 'rm',
>     even though it is not the default for chmod/chown/chgrp.

I agree.  And on the release schedule front, the timing is right.
You're welcome to make that change.

Jim




reply via email to

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