diff options
author | Tavian Barnes <tavianator@tavianator.com> | 2017-02-04 21:03:59 -0500 |
---|---|---|
committer | Tavian Barnes <tavianator@tavianator.com> | 2017-02-04 21:05:39 -0500 |
commit | 9f1863d45fe596e258596a4b4cc9a4064bcb11d3 (patch) | |
tree | 4a627b699f52f03eabd145852891c2aef7c5cb76 /eval.c | |
parent | 538e4b2054e9802ebc860943e0a43baf2ee46741 (diff) | |
download | bfs-9f1863d45fe596e258596a4b4cc9a4064bcb11d3.tar.xz |
Implement -nouser and -nogroup
Diffstat (limited to 'eval.c')
-rw-r--r-- | eval.c | 26 |
1 files changed, 26 insertions, 0 deletions
@@ -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) { |