GNU bug report logs - #18491
rm -r fails to delete entire hierarchy when path goes in and out of it

Previous Next

Package: coreutils;

Reported by: Gian Ntzik <gian.ntzik08 <at> imperial.ac.uk>

Date: Wed, 17 Sep 2014 19:42:02 UTC

Severity: normal

Full log


View this message in rfc822 format

From: Gian Ntzik <gian.ntzik08 <at> imperial.ac.uk>
To: 18491 <at> debbugs.gnu.org
Subject: bug#18491: rm -r fails to delete entire hierarchy when path goes in and out of it
Date: Wed, 17 Sep 2014 06:38:56 +0100
Hello,

It seems that using rm -r with a path that goes into a (non-empty)
directory intended for removal (and back up e.g. using dot-dots) fails
to remove the directory. The directory is rendered empty, but itself not
removed.

For example,

$ mkdir -p /tmp/a/b/c
$ mkdir -p /tmp/a/e
$ rm -r /tmp/a/b/../../a
rm: cannot remove ‘/tmp/a/b/../../a’: No such file or directory

Then,

$ ls /tmp/a

yeilds empty contents, and

$ ls -d /tmp/a
/tmp/a

yields that the directory intended for removal still exists.

I have tested this in Ubuntu 14.04 where coreutils is at version 8.21. I
have also tested it with version 8.23 built from source also on Ubuntu
14.04.

I do not believe this is the intended behavior, but a bug.

Obviously, once the contents of /tmp/a have been removed, the path
/tmp/a/b/../../a is no longer resolvable. However, the same applies for
any sub-directory of /tmp/a. For example, once /tmp/a/b has been
removed, /tmp/a/b/../../a/e is also no longer resolvable. It seems that
rm -r takes care to avoid such issues during recursion but fails to do
so at the very end.

Thank you,

Gian Ntzik




This bug report was last modified 10 years and 278 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.