bug#18491: rm -r fails to delete entire hierarchy when path goes in and
From:
Gian Ntzik
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
User-agent:
Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux)
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