From c8ef95eaed944ec70ccd70c077cf465c6311c1b6 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Wed, 20 Dec 2006 19:56:20 +0100 Subject: "rm -rf /etc/motd" (run by non-root) now prints a diagnostic. * src/remove.c (remove_entry): Handle EACCES for a non-directory, too. Karl Berry reported that a cross-partition "mv /etc/issue ~" failed with the um,... suboptimal diagnostic, "mv: cannot remove `/etc/issue': Not a directory". * tests/rm/Makefile.am (TESTS): Add fail-eacces. * tests/rm/fail-eacces: New file. * NEWS: Mention that both mv and rm are affected. --- src/remove.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/remove.c') diff --git a/src/remove.c b/src/remove.c index 3dc692947..f6d3f0c67 100644 --- a/src/remove.c +++ b/src/remove.c @@ -1016,8 +1016,7 @@ remove_entry (int fd_cwd, Dirstack_state const *ds, char const *filename, errno = EISDIR; if (! x->recursive - || errno == ENOENT || errno == ENOTDIR - || errno == ELOOP || errno == ENAMETOOLONG) + || (cache_stat_ok (st) && !S_ISDIR (st->st_mode))) { if (ignorable_missing (x, errno)) return RM_OK; @@ -1028,6 +1027,7 @@ remove_entry (int fd_cwd, Dirstack_state const *ds, char const *filename, quote (full_filename (filename))); return RM_ERROR; } + assert (!cache_stat_ok (st) || S_ISDIR (st->st_mode)); } else { -- cgit v1.2.3-54-g00ecf