summaryrefslogtreecommitdiff
path: root/bin/chmod
diff options
context:
space:
mode:
authorSergey Kandaurov <pluknet@FreeBSD.org>2015-06-04 19:18:58 +0000
committerSergey Kandaurov <pluknet@FreeBSD.org>2015-06-04 19:18:58 +0000
commitdb1a93d4fef4c79b54e687a36912592693555372 (patch)
tree2ac266d448b244eab21a568f4aae8321d2e1d1aa /bin/chmod
parentff09e23f53d77ba5095fee0154f7041970a785c5 (diff)
downloadsrc-test-db1a93d4fef4c79b54e687a36912592693555372.tar.gz
src-test-db1a93d4fef4c79b54e687a36912592693555372.zip
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
Notes
Notes: svn path=/head/; revision=283997
Diffstat (limited to 'bin/chmod')
-rw-r--r--bin/chmod/chmod.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/bin/chmod/chmod.c b/bin/chmod/chmod.c
index 9b801576efa71..2ccce2d7830e0 100644
--- a/bin/chmod/chmod.c
+++ b/bin/chmod/chmod.c
@@ -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));