-/* @(#) $Id: syscheck-config.c,v 1.25 2009/11/04 15:18:59 dcid Exp $ */
+/* @(#) $Id$ */
/* Copyright (C) 2009 Trend Micro Inc.
* All right reserved.
*
* This program is a free software; you can redistribute it
* and/or modify it under the terms of the GNU General Public
- * License (version 3) as published by the FSF - Free Software
+ * License (version 2) as published by the FSF - Free Software
* Foundation
*/
-int dump_syscheck_entry(config *syscheck, char *entry, int vals, int reg)
+int dump_syscheck_entry(config *syscheck, char *entry, int vals, int reg, char *restrictfile)
{
int pl = 0;
os_calloc(2, sizeof(int), syscheck->opts);
syscheck->opts[pl + 1] = 0;
- syscheck->opts[pl] = vals;
+ syscheck->opts[pl] = vals;
+
+ os_calloc(2, sizeof(OSMatch *), syscheck->filerestrict);
+ syscheck->filerestrict[pl] = NULL;
+ syscheck->filerestrict[pl + 1] = NULL;
}
else
{
syscheck->opts);
syscheck->opts[pl + 1] = 0;
syscheck->opts[pl] = vals;
+
+ os_realloc(syscheck->filerestrict, (pl +2) * sizeof(char *),
+ syscheck->filerestrict);
+ syscheck->filerestrict[pl] = NULL;
+ syscheck->filerestrict[pl + 1] = NULL;
+ }
+ if(restrictfile)
+ {
+ os_calloc(1, sizeof(OSMatch), syscheck->filerestrict[pl]);
+ if(!OSMatch_Compile(restrictfile, syscheck->filerestrict[pl], 0))
+ {
+ OSMatch *ptm;
+
+ ptm = syscheck->filerestrict[pl];
+
+ merror(REGEX_COMPILE, ARGV0, restrictfile,
+ ptm->error);
+ free(syscheck->filerestrict[pl]);
+ syscheck->filerestrict[pl] = NULL;
+ }
}
}
}
/* Adding new entry */
- dump_syscheck_entry(syscheck, tmp_entry, 0, 1);
+ dump_syscheck_entry(syscheck, tmp_entry, 0, 1, NULL);
/* Next entry */
char *xml_check_group = "check_group";
char *xml_check_perm = "check_perm";
char *xml_real_time = "realtime";
+ char *xml_report_changes = "report_changes";
+ char *xml_restrict = "restrict";
+ char *restrictfile = NULL;
char **dir;
char *tmp_str;
dir = OS_StrBreak(',', dirs, MAX_DIR_SIZE); /* Max number */
char **values = NULL;
tmp_dir = *dir;
+ restrictfile = NULL;
/* Removing spaces at the beginning */
while(*tmp_dir == ' ')
return(0);
}
}
+ else if(strcmp(*attrs, xml_report_changes) == 0)
+ {
+ if(strcmp(*values, "yes") == 0)
+ {
+ opts|=CHECK_SEECHANGES;
+ }
+ else if(strcmp(*values, "no") == 0)
+ {
+ }
+ else
+ {
+ merror(SK_INV_OPT, ARGV0, *values, *attrs);
+ return(0);
+ }
+ }
+ else if(strcmp(*attrs, xml_restrict) == 0)
+ {
+ os_strdup(*values, restrictfile);
+ }
else
{
merror(SK_INV_ATTR, ARGV0, *attrs);
if(opts == 0)
{
merror(SYSCHECK_NO_OPT, ARGV0, dirs);
+ if(restrictfile) free(restrictfile);
return(0);
}
while(g.gl_pathv[gindex])
{
- dump_syscheck_entry(syscheck, g.gl_pathv[gindex], opts, 0);
+ dump_syscheck_entry(syscheck, g.gl_pathv[gindex], opts, 0, restrictfile);
gindex++;
}
else
{
- dump_syscheck_entry(syscheck, tmp_dir, opts, 0);
+ dump_syscheck_entry(syscheck, tmp_dir, opts, 0, restrictfile);
}
#else
- dump_syscheck_entry(syscheck, tmp_dir, opts, 0);
+ dump_syscheck_entry(syscheck, tmp_dir, opts, 0, restrictfile);
#endif
+
+ if(restrictfile)
+ {
+ free(restrictfile);
+ restrictfile = NULL;
+ }
/* Next entry */