svn commit: r283997 - head/bin/chmod

Sergey Kandaurov pluknet at FreeBSD.org
Thu Jun 4 19:18:59 UTC 2015


Author: pluknet
Date: Thu Jun  4 19:18:58 2015
New Revision: 283997
URL: https://svnweb.freebsd.org/changeset/base/283997

Log:
  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 an existing behavior in other BSDs, linux, OS X.
  
  Obtained from:	NetBSD

Modified:
  head/bin/chmod/chmod.c

Modified: head/bin/chmod/chmod.c
==============================================================================
--- head/bin/chmod/chmod.c	Thu Jun  4 19:11:56 2015	(r283996)
+++ head/bin/chmod/chmod.c	Thu Jun  4 19:18:58 2015	(r283997)
@@ -162,14 +162,16 @@ done:	argv += optind;
 			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));


More information about the svn-src-all mailing list