aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2021-02-14 10:06:01 -0600
committerRob Landley <rob@landley.net>2021-02-14 10:06:01 -0600
commit5c73305f0e4bb5e16aae798e177ec9213f853eec (patch)
tree39c02190b70601a611252615e54f161779ca099c
parent06b1d9e24e82e2919fd673fe5f63bd30c43a1e33 (diff)
downloadtoybox-5c73305f0e4bb5e16aae798e177ec9213f853eec.tar.gz
Add find -executable
Requested by aheirman on github: uses access(X_OK) which checks access control lists as well as permissions, and that _we_ can access them (u+x could be owned by a different user)...
-rw-r--r--toys/posix/find.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/toys/posix/find.c b/toys/posix/find.c
index 2d8ca0b1..3824f0c6 100644
--- a/toys/posix/find.c
+++ b/toys/posix/find.c
@@ -35,7 +35,7 @@ config FIND
-inum N inode number N -empty empty files and dirs
-type [bcdflps] type is (block, char, dir, file, symlink, pipe, socket)
-true always true -false always false
- -context PATTERN security context
+ -context PATTERN security context -executable access(X_OK) perm+ACL
-newerXY FILE X=acm time > FILE's Y=acm time (Y=t: FILE is literal time)
Numbers N may be prefixed by a - (less than) or + (greater than). Units for
@@ -345,11 +345,13 @@ static int do_find(struct dirtree *new)
} else test = 0;
}
} else if (!strcmp(s, "nouser")) {
- if (check) if (bufgetpwuid(new->st.st_uid)) test = 0;
+ if (check && bufgetpwuid(new->st.st_uid)) test = 0;
} else if (!strcmp(s, "nogroup")) {
- if (check) if (bufgetgrgid(new->st.st_gid)) test = 0;
+ if (check && bufgetgrgid(new->st.st_gid)) test = 0;
} else if (!strcmp(s, "prune")) {
if (check && S_ISDIR(new->st.st_mode) && !TT.depth) recurse = 0;
+ } else if (!strcmp(s, "executable")) {
+ if (check && faccessat(dirtree_parentfd(new), new->name,X_OK,0)) test = 0;
// Remaining filters take an argument
} else {