From dc875d97bb0183da8a72a947ab96237b3dfc96e0 Mon Sep 17 00:00:00 2001 From: Frederic Lepied Date: Mon, 21 Feb 2005 17:05:32 +0000 Subject: use the EXCLUDE_REGEXP to be able to exclude files or directory from the reports. --- src/msec_find/find.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'src/msec_find') diff --git a/src/msec_find/find.c b/src/msec_find/find.c index 294881e..a9e96aa 100644 --- a/src/msec_find/find.c +++ b/src/msec_find/find.c @@ -45,6 +45,7 @@ #include #include #include +#include #include @@ -63,6 +64,8 @@ static FILE *sgid_fd; static FILE *unowned_user_fd; static FILE *unowned_group_fd; static FILE *writable_fd; +static regex_t exclude_regexp; +static int use_regexp = 0; static int traverse(const char *file, const struct stat *sb, int flag, struct FTW *s) { @@ -81,7 +84,11 @@ static int traverse(const char *file, const struct stat *sb, int flag, struct FT */ if ( (strncmp("/proc", file, 5) == 0) || (strncmp("/dev", file, 4) == 0) ) return 0; - + + if (use_regexp && regexec(&exclude_regexp, file, 0, NULL, 0) == 0) { + return 0; + } + switch (flag) { /* * Regular file handling. @@ -132,6 +139,7 @@ static int traverse(const char *file, const struct stat *sb, int flag, struct FT __inline__ static void init() { static const char *mode = "w+"; + char *env; suid_fd = fopen(getenv("SUID_ROOT_TODAY"), mode); if ( ! suid_fd ) { @@ -162,6 +170,16 @@ __inline__ static void init() perror("fopen (unowned_group_today)"); exit(1); } + + env = getenv("EXCLUDE_REGEXP"); + if (env) { + if (regcomp(&exclude_regexp, env, 0) == 0) { + use_regexp = 1; + } else { + fprintf(stderr, "Unable to compile EXCLUDE_REGEXP '%s'\n", env); + exit(1); + } + } } int main(int argc, char **argv) -- cgit v1.2.1