rm -r fails to delete entire hierarchy when path goes in and out of it

Cathey, Jim jcathey at ciena.com
Wed Sep 17 16:52:06 UTC 2014


Pretty sure 'our' upstream rm (in a prior life) expressly
prohibited -r on starting paths that contained .. members.
Too many weirdo cases where you would get into trouble.

-- Jim

-----Original Message-----
From: busybox [mailto:busybox-bounces at busybox.net] On Behalf Of Ralf Friedl
Sent: Wednesday, September 17, 2014 2:02 AM
To: Gian Ntzik; busybox at busybox.net
Subject: Re: rm -r fails to delete entire hierarchy when path goes in and out of it

Gian Ntzik wrote:
> It seems that using rm -r with a path that goes into the hierarchy
> intended for removal (and back up e.g. using dot-dots) fails to remove
> the entire hierarchy.
>
> For example,
>
> $ mkdir -p /tmp/a/b/c
> $ mkdir -p /tmp/a/e
> $ rm -r /tmp/a/b/../../a
> rm: can't remove 'a/b/../../a/e': No such file or directory
> rm: can't remove 'a/b/../../a': No such file or directory
GNU rm does this:
$ mkdir -p /tmp/a/b/c /tmp/a/e
$ rm -r /tmp/a/b/../../a
rm: cannot remove '/tmp/a/b/../../a': No such file or directory

In general I think it is not a good idea to pass such arguments to rm.

_______________________________________________
busybox mailing list
busybox at busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


More information about the busybox mailing list