aboutsummaryrefslogtreecommitdiffstats
path: root/src/msec_find
diff options
context:
space:
mode:
authorFrederic Lepied <flepied@mandriva.com>2005-02-21 17:05:32 +0000
committerFrederic Lepied <flepied@mandriva.com>2005-02-21 17:05:32 +0000
commitdc875d97bb0183da8a72a947ab96237b3dfc96e0 (patch)
treeff66757a62aff8ad355ca0e56af13e65cfd8c872 /src/msec_find
parent0514679f0a0bb8a7c3859f6126e081f2e213bd48 (diff)
downloadmsec-dc875d97bb0183da8a72a947ab96237b3dfc96e0.tar
msec-dc875d97bb0183da8a72a947ab96237b3dfc96e0.tar.gz
msec-dc875d97bb0183da8a72a947ab96237b3dfc96e0.tar.bz2
msec-dc875d97bb0183da8a72a947ab96237b3dfc96e0.tar.xz
msec-dc875d97bb0183da8a72a947ab96237b3dfc96e0.zip
use the EXCLUDE_REGEXP to be able to exclude files or directory from the
reports.
Diffstat (limited to 'src/msec_find')
-rw-r--r--src/msec_find/find.c20
1 files changed, 19 insertions, 1 deletions
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 <pwd.h>
#include <grp.h>
#include <sys/types.h>
+#include <regex.h>
#include <string.h>
@@ -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)