Re: rm(1) bug, possibly serious



On Tue, Sep 25, 2007 at 05:12:50PM +0200, Oliver Fromme wrote:
Hi,

Today I noticed the following behaviour on a 6-stable
machine:

$ cd /tmp
$ mkdir -p foo/var
$ cd foo/bar

Looks like you have mistyped 'mkdir' argument :)

$ rm -rf ../
rm: ../: Invalid argument

Please type 'pwd' here

$ 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

--
Oliver Fromme, secnetix GmbH & Co. KG, Marktplatz 29, 85567 Grafing b. M.
Handelsregister: Registergericht Muenchen, HRA 74606, GeschДftsfuehrung:
secnetix Verwaltungsgesellsch. mbH, Handelsregister: Registergericht MЭn-
chen, HRB 125758, GeschДftsfЭhrer: Maik Bachmann, Olaf Erb, Ralf Gebhart

FreeBSD-Dienstleistungen, -Produkte und mehr: http://www.secnetix.de/bsd

"The scanf() function is a large and complex beast that often does
something almost but not quite entirely unlike what you desired."
-- Chris Torek

--
The ultimate artifact may be found in the driven snow...
_______________________________________________
freebsd-stable@xxxxxxxxxxx mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-stable
To unsubscribe, send any mail to "freebsd-stable-unsubscribe@xxxxxxxxxxx"



Relevant Pages

  • rm(1) bug, possibly serious
    ... $ mkdir -p foo/var ... $ cd foo/bar ... rm: ../: Invalid argument ...
    (freebsd-stable)
  • Re: rm(1) bug, possibly serious
    ... $ mkdir -p foo/var ... $ cd foo/bar ... rm: ../: Invalid argument ...
    (freebsd-stable)
  • Re: Acting upon error messages
    ... but it will fail (won't report existence) if "$dir" is a symlink ... or symlink... ... > But what about mkdir returns error for whatever reason? ... I would like to print an error message an exit. ...
    (comp.unix.shell)
  • error: mkdir undeclared
    ... When trying to install a program that is originally made for linux, ... this error message: ... I guess there is a funktion mkdir in unistd.h at linux systems. ...
    (comp.unix.bsd.freebsd.misc)
  • Re: find exclude question.
    ... $ mkdir -p foo/bar ... You are demonstrating how to exclude all directories in a search path ...
    (comp.unix.shell)