[patch] chmod: change directory permissions in pre-order

Sergey Kandaurov pluknet at freebsd.org
Thu Jun 4 10:55:39 UTC 2015


Change directory permissions in pre-order.
In this order, it won't try to recurse into a directory for which
it doesn't have permission, before changing that permission.
This follows the existing behavior in other BSDs, linux, OS X.

Obtained from:  NetBSD
Found by:	while digging in buildbot sources
-------------- next part --------------
Index: chmod.c
===================================================================
--- chmod.c	(revision 283969)
+++ chmod.c	(working copy)
@@ -162,14 +162,16 @@
 			atflag = AT_SYMLINK_NOFOLLOW;
 
 		switch (p->fts_info) {
-		case FTS_D:			/* Change it at FTS_DP. */
+		case FTS_D:
 			if (!Rflag)
 				fts_set(ftsp, p, FTS_SKIP);
-			continue;
+			break;
 		case FTS_DNR:			/* Warn, chmod. */
 			warnx("%s: %s", p->fts_path, strerror(p->fts_errno));
 			rval = 1;
 			break;
+		case FTS_DP:			/* Already changed at FTS_D. */
+			continue;
 		case FTS_ERR:			/* Warn, continue. */
 		case FTS_NS:
 			warnx("%s: %s", p->fts_path, strerror(p->fts_errno));
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 473 bytes
Desc: not available
URL: <http://lists.freebsd.org/pipermail/freebsd-current/attachments/20150604/1493b07f/attachment.sig>


More information about the freebsd-current mailing list