Skip to content

Commit

Permalink
Merge pull request #1597 from ddpbsd/no_recurse
Browse files Browse the repository at this point in the history
Add a no_recurse option to syscheckd.
  • Loading branch information
atomicturtle authored Dec 15, 2018
2 parents 814b47c + a59c77b commit ab8d105
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/config/syscheck-config.c
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ static int read_attr(syscheck_config *syscheck, const char *dirs, char **g_attrs
const char *xml_real_time = "realtime";
const char *xml_report_changes = "report_changes";
const char *xml_restrict = "restrict";
const char *xml_no_recurse = "no_recurse";

char *restrictfile = NULL;
char **dir;
Expand Down Expand Up @@ -348,6 +349,14 @@ static int read_attr(syscheck_config *syscheck, const char *dirs, char **g_attrs
restrictfile = NULL;
}
os_strdup(*values, restrictfile);
} else if (strcmp(*attrs, xml_no_recurse) == 0) {
if(strcmp(*values, "yes") == 0) {
opts |= CHECK_NORECURSE;
} else {
merror(SK_INV_OPT, __local_name, *values, *attrs);
ret = 0;
goto out_free;
}
} else {
merror(SK_INV_ATTR, __local_name, *attrs);
ret = 0;
Expand Down Expand Up @@ -828,6 +837,7 @@ char *syscheck_opts2str(char *buf, int buflen, int opts) {
CHECK_SHA1SUM,
CHECK_REALTIME,
CHECK_SEECHANGES,
CHECK_NORECURSE,
0
};
char *check_strings[] = {
Expand All @@ -839,6 +849,7 @@ char *syscheck_opts2str(char *buf, int buflen, int opts) {
"sha1sum",
"realtime",
"report_changes",
"no_recurse",
NULL
};

Expand Down
4 changes: 4 additions & 0 deletions src/config/syscheck-config.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
#define CHECK_SHA1SUM 0000040
#define CHECK_REALTIME 0000100
#define CHECK_SEECHANGES 0000200
#define CHECK_SHA256SUM 0000400
#define CHECK_GENERIC 0001000
#define CHECK_NORECURSE 0002000


#include <stdio.h>

Expand Down
15 changes: 15 additions & 0 deletions src/syscheckd/create_db.c
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,21 @@ int read_dir(const char *dir_name, int opts, OSMatch *restriction)
*s_name = '\0';
strncpy(s_name, entry->d_name, PATH_MAX - dir_size - 2);

/* Check if the file is a directory */
if(opts & CHECK_NORECURSE) {
struct stat recurse_sb;
if((stat(f_name, &recurse_sb)) < 0) {
merror("%s: ERR: Cannot stat %s: %s", ARGV0, f_name, strerror(errno));
} else {
switch (recurse_sb.st_mode & S_IFMT) {
case S_IFDIR:
continue;
break;
}
}
}


/* Check integrity of the file */
read_file(f_name, opts, restriction);
}
Expand Down

0 comments on commit ab8d105

Please sign in to comment.