changeset 1374:739d3fc60f48

Fix rm -rf of chmod 000 directories.
author Rob Landley <rob@landley.net>
date Thu, 03 Jul 2014 18:42:44 -0500
parents a3ee4f91462a
children b6645034202b
files toys/posix/rm.c
diffstat 1 files changed, 5 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/toys/posix/rm.c	Mon Jun 30 05:05:39 2014 -0500
+++ b/toys/posix/rm.c	Thu Jul 03 18:42:44 2014 -0500
@@ -47,6 +47,11 @@
 
   // handle directory recursion
   if (dir) {
+    // Handle chmod 000 directories when -f
+    if (faccessat(fd, try->name, R_OK, AT_SYMLINK_NOFOLLOW)) {
+      if (toys.optflags & FLAG_f) wfchmodat(fd, try->name, 0600);
+      else goto skip;
+    }
     if (try->data != -1) return DIRTREE_COMEAGAIN;
     using = AT_REMOVEDIR;
     if (try->symlink) goto skip;