Subject: bug#15943: [PATCH] doc: enhance diagnostic when rm skips "." or ".." arguments

From: Eric Blake <[email-masked]>
Date: Wed, 20 Nov 2013 19:16:33 -0700

forcemerge 15943 15926
thanks

On 11/20/2013 05:54 PM, Linda Walsh wrote:
> On 20/11/2013 15:47, Bernhard Voelker wrote:
>>
>> -          /* If a command line argument resolves to "/" (and
>> --preserve-root
>> +          /* POSIX also says:
>> +             If a command line argument resolves to "/" (and

No need to spawn a new bug when the existing bug tracking the issue is
still under discussion.  And on the surface, this email has nothing to
do with the subject line of "enhance diagnostic when rm skips "." or
".." arguments".

> 
> Maybe since '/' doesn't really delete the file system itself,
> but only files and dirs underneath '/',

Huh?  When POSIX-compliant (that is, when --preserve-root is in effect),
attempting to 'rm -r /' does nothing at all.  When bypassing POSIX (with
'rm -r --no-preserve-root'), rm will delete as much as possible, and
eventually fail once it has deleted system resources that were essential
to the correct operation of the computer; but if you can get far enough,
it would eventually attempt rm("/").

> 
> Then the correct solution is if a user says
> to remove /tmp/
> it will remove everything under /tmp but not /tmp itself?
> 
> That doesn't seem to be disallowed by POSIX...

Not true.  POSIX requires 'rm -r /tmp/' to attempt to delete /tmp, but
that it might fail to do so if nested files are not deleted (perhaps due
to ownership) or if the user doesn't have rights to delete /tmp.

> (its a bit absurd, but as long as it conforms to POSIX
> it should be fine, right? ;-/)

Your idea of skipping the attempt to delete /tmp would not conform with
POSIX.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org