commit e1c56a6321707b8c34244564d18bb831f9c224f7
Author: David Phillips <[email protected]>
AuthorDate: Sun Oct 1 16:36:05 2017 +1300
Commit: Michael Forney <[email protected]>
CommitDate: Sun Oct 1 11:54:24 2017 -0700
chmod: Use DIRFIRST
Previously, running `chmod 777` on a directory that had no read or
execute access (e.g. 111 or 000) would cause chmod to throw its
toys since it was trying to opendir before having added read permission
to the directory.
diff --git a/chmod.c b/chmod.c
index f671f32..c12d2f4 100644
--- a/chmod.c
+++ b/chmod.c
@@ -32,7 +32,7 @@ int
main(int argc, char *argv[])
{
struct recursor r = { .fn = chmodr, .hist = NULL, .depth = 0, .maxdepth
= 1,
- .follow = 'P', .flags = 0 };
+ .follow = 'P', .flags = DIRFIRST };
size_t i;
argv0 = *argv, argv0 ? (argc--, argv++) : (void *)0;