summaryrefslogtreecommitdiffstats
path: root/usr.bin/find
diff options
context:
space:
mode:
authorroberto <roberto@FreeBSD.org>2000-06-12 10:36:52 +0000
committerroberto <roberto@FreeBSD.org>2000-06-12 10:36:52 +0000
commit242d3298bd04c4d03991e421f05413f69a528c24 (patch)
treecf245e06844e43f6e894f89cf6ea17d825f4e9ad /usr.bin/find
parent777866439c6717489a266d1582e9bb2849e41c2b (diff)
downloadFreeBSD-src-242d3298bd04c4d03991e421f05413f69a528c24.zip
FreeBSD-src-242d3298bd04c4d03991e421f05413f69a528c24.tar.gz
The find -perm option currently supports an exact match,
or if the mode is preceded by a '-', it checks for a match in at least the bits specified on the command line. It is often desirable to find things with any execute or setuid or setgid bits set. PR: bin/10169 Submitted by: Monte Mitzelfelt <monte@gonefishing.org>
Diffstat (limited to 'usr.bin/find')
-rw-r--r--usr.bin/find/find.14
-rw-r--r--usr.bin/find/find.h1
-rw-r--r--usr.bin/find/function.c5
3 files changed, 9 insertions, 1 deletions
diff --git a/usr.bin/find/find.1 b/usr.bin/find/find.1
index d605e19..cd51df3 100644
--- a/usr.bin/find/find.1
+++ b/usr.bin/find/find.1
@@ -324,7 +324,9 @@ of the file's mode bits participate
in the comparison.
If the mode is preceded by a dash (``\-''), this primary evaluates to true
if at least all of the bits in the mode are set in the file's mode bits.
-If the mode is not preceded by a dash, this primary evaluates to true if
+If the mode is preceded by a plus (``\+''), this primary evaluates to true
+if any of the bits in the mode are set in the file's mode bits.
+Otherwise, this primary evaluates to true if
the bits in the mode exactly match the file's mode bits.
Note, the first character of a symbolic mode may not be a dash (``\-'').
.It Ic -flags Op Fl Ns Ar flags
diff --git a/usr.bin/find/find.h b/usr.bin/find/find.h
index b6e2eab..36a9193 100644
--- a/usr.bin/find/find.h
+++ b/usr.bin/find/find.h
@@ -61,6 +61,7 @@ typedef struct _plandata {
#define F_MTFLAG 1 /* fstype */
#define F_MTTYPE 2
#define F_ATLEAST 1 /* perm */
+#define F_ANY 2 /* perm */
int flags; /* private flags */
enum ntype type; /* plan node type */
union {
diff --git a/usr.bin/find/function.c b/usr.bin/find/function.c
index 0dad26b..b53f182 100644
--- a/usr.bin/find/function.c
+++ b/usr.bin/find/function.c
@@ -926,6 +926,8 @@ f_perm(plan, entry)
(S_ISUID|S_ISGID|S_ISTXT|S_IRWXU|S_IRWXG|S_IRWXO);
if (plan->flags == F_ATLEAST)
return ((plan->m_data | mode) == mode);
+ else if (plan->flags == F_ANY )
+ return (plan->m_data & mode);
else
return (mode == plan->m_data);
/* NOTREACHED */
@@ -945,6 +947,9 @@ c_perm(perm)
if (*perm == '-') {
new->flags = F_ATLEAST;
++perm;
+ } else if (*perm == '+') {
+ new->flags = F_ANY;
+ ++perm;
}
if ((set = setmode(perm)) == NULL)
OpenPOWER on IntegriCloud