summaryrefslogtreecommitdiffstats
path: root/eval.c
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2017-02-04 21:03:59 -0500
committerTavian Barnes <tavianator@tavianator.com>2017-02-04 21:05:39 -0500
commit9f1863d45fe596e258596a4b4cc9a4064bcb11d3 (patch)
tree4a627b699f52f03eabd145852891c2aef7c5cb76 /eval.c
parent538e4b2054e9802ebc860943e0a43baf2ee46741 (diff)
downloadbfs-9f1863d45fe596e258596a4b4cc9a4064bcb11d3.tar.xz
Implement -nouser and -nogroup
Diffstat (limited to 'eval.c')
-rw-r--r--eval.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/eval.c b/eval.c
index 4494cff..35501e0 100644
--- a/eval.c
+++ b/eval.c
@@ -18,6 +18,8 @@
#include <errno.h>
#include <fcntl.h>
#include <fnmatch.h>
+#include <grp.h>
+#include <pwd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -226,6 +228,30 @@ bool eval_uid(const struct expr *expr, struct eval_state *state) {
}
/**
+ * -nogroup test.
+ */
+bool eval_nogroup(const struct expr *expr, struct eval_state *state) {
+ const struct stat *statbuf = fill_statbuf(state);
+ if (!statbuf) {
+ return false;
+ }
+
+ return getgrgid(statbuf->st_gid) == NULL;
+}
+
+/**
+ * -nouser test.
+ */
+bool eval_nouser(const struct expr *expr, struct eval_state *state) {
+ const struct stat *statbuf = fill_statbuf(state);
+ if (!statbuf) {
+ return false;
+ }
+
+ return getpwuid(statbuf->st_uid) == NULL;
+}
+
+/**
* -delete action.
*/
bool eval_delete(const struct expr *expr, struct eval_state *state) {