Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 4 Jun 2015 19:18:58 +0000 (UTC)
From:      Sergey Kandaurov <pluknet@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r283997 - head/bin/chmod
Message-ID:  <201506041918.t54JIwFQ061508@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
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));



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201506041918.t54JIwFQ061508>