Re: rm(1) bug, possibly serious



Hi,

On Tue, Sep 25, 2007 at 11:25:34AM -0400, Maxim Khitrov wrote:
On 9/25/07, Oliver Fromme <olli@xxxxxxxxxxxxxxxxx> wrote:
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).

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.

May I add some more confusion?

In tcsh:

(23:49) ob@nowhere:ttyp2 [~] which rm
/bin/rm
(23:49) ob@nowhere:ttyp2 [~] cd /tmp
(23:49) ob@nowhere:ttyp2 [/tmp] mkdir -p foo/bar
(23:49) ob@nowhere:ttyp2 [/tmp] cd foo/bar
(23:49) ob@nowhere:ttyp2 [foo/bar] rm -rf ../
(23:49) ob@nowhere:ttyp2 [foo/bar] pwd
pwd: .: No such file or directory
(23:52) ob@nowhere:ttyp2 [foo/bar] cd /tmp
(23:52) ob@nowhere:ttyp2 [/tmp] ls
(23:52) ob@nowhere:ttyp2 [/tmp]


In sh:

$ which rm
/bin/rm
$ cd /tmp
$ mkdir -p foo/bar
$ cd foo/bar
$ rm -rf ../
rm: ../: Invalid argument
$ pwd
/tmp/foo/bar
$ rm -rf ../
$ pwd
/tmp/foo/bar
$ cd /tmp
$ ls
foo
$ cd foo
$ ls


(23:53) ob@nowhere:ttyp2 [~] uname -a
FreeBSD nowhere.ob-home.lan 6.2-STABLE FreeBSD 6.2-STABLE #17: Sun Aug 5 19:03:13 CEST 2007 root@xxxxxxxxxxxxxxxxxxx:/usr/obj/usr/src/sys/NOWHERE i386


- Olli


--
| Oliver Brandmueller | Offenbacher Str. 1 | Germany D-14197 Berlin |
| Fon +49-172-3130856 | Fax +49-172-3145027 | WWW: http://the.addict.de/ |
| Ich bin das Internet. Sowahr ich Gott helfe. |
| Eine gewerbliche Nutzung aller enthaltenen Adressen ist nicht gestattet! |

Attachment: pgpYio47nS1f0.pgp
Description: PGP signature



Relevant Pages