Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 25 Sep 2007 11:25:34 -0400
From:      "Maxim Khitrov" <mkhitrov@gmail.com>
To:        freebsd-stable@freebsd.org
Subject:   Re: rm(1) bug, possibly serious
Message-ID:  <26ddd1750709250825j2d70798awa96cd0d2d305e0a9@mail.gmail.com>
In-Reply-To: <200709251512.l8PFCoPe006574@lurza.secnetix.de>
References:  <200709251512.l8PFCoPe006574@lurza.secnetix.de>

next in thread | previous in thread | raw e-mail | index | archive | help
On 9/25/07, Oliver Fromme <olli@lurza.secnetix.de> wrote:
> Hi,
>
> Today I noticed the following behaviour on a 6-stable
> machine:
>
> $ cd /tmp
> $ mkdir -p foo/var
> $ cd foo/bar
> $ rm -rf ../
> rm: ../: Invalid argument
> $ rm -rf ../
> $
>
> Note that the command "rm -rf ../" was entered twice.
> The first time I got an error message (and exit code 1),
> the second time it apparently succeeded.  The very same
> command.
>
> Further investigation:
>
> $ cd /tmp
> $ mkdir -p foo/var
> $ cd foo/bar
> $ rm -rf ../
> rm: ../: Invalid argument
> $ ls -al ..
> ls: ..: No such file or directory
> $ ls /tmp/foo/bar
> ls: /tmp/foo/bar: No such file or directory
>
> That means:  Even though "rm -rf ../" prints an error
> message, indicating that the argument is invalid, it
> *DOES* remove the contents of the parent directory!
>
> To add further confusion, another "rm -rf ../" does
> not print an error message and seemingly succeeds,
> even though ".." does not exist anymore in the current
> directory (which has been removed).
>
> Shall I file a PR?  Or is rm working correctly, and
> my assumptions are wrong?
>
> Best regards
>    Oliver

Confirmed on CURRENT as well. Note that if you run rf -rf .. as the
first command, the command does fail with 'rm: "." and ".." may not be
removed'. Adding a / at the end does seem to get around this check.

- Max



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?26ddd1750709250825j2d70798awa96cd0d2d305e0a9>