From 9f1863d45fe596e258596a4b4cc9a4064bcb11d3 Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Sat, 4 Feb 2017 21:03:59 -0500 Subject: Implement -nouser and -nogroup --- eval.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'eval.c') diff --git a/eval.c b/eval.c index 4494cff..35501e0 100644 --- a/eval.c +++ b/eval.c @@ -18,6 +18,8 @@ #include #include #include +#include +#include #include #include #include @@ -225,6 +227,30 @@ bool eval_uid(const struct expr *expr, struct eval_state *state) { return do_cmp(expr, statbuf->st_uid); } +/** + * -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. */ -- cgit v1.2.3