new upstream release (3.3.0); modify package compatibility for Stretch
[ossec-hids.git] / src / syscheckd / config.c
1 /* Copyright (C) 2009 Trend Micro Inc.
2  * All right reserved.
3  *
4  * This program is a free software; you can redistribute it
5  * and/or modify it under the terms of the GNU General Public
6  * License (version 2) as published by the FSF - Free Software
7  * Foundation
8  */
9
10 #include "shared.h"
11 #include "syscheck.h"
12 #include "config/config.h"
13
14 #ifdef WIN32
15 static char *SYSCHECK_EMPTY[] = { NULL };
16 #endif
17
18
19 int Read_Syscheck_Config(const char *cfgfile)
20 {
21     int modules = 0;
22
23     modules |= CSYSCHECK;
24
25     syscheck.rootcheck      = 0;
26     syscheck.disabled       = 0;
27     syscheck.skip_nfs       = 0;
28     syscheck.scan_on_start  = 1;
29     syscheck.time           = SYSCHECK_WAIT * 2;
30     syscheck.ignore         = NULL;
31     syscheck.ignore_regex   = NULL;
32     syscheck.nodiff         = NULL;
33     syscheck.nodiff_regex   = NULL;
34     syscheck.scan_day       = NULL;
35     syscheck.scan_time      = NULL;
36     syscheck.dir            = NULL;
37     syscheck.opts           = NULL;
38     syscheck.realtime       = NULL;
39 #ifdef WIN32
40     syscheck.registry       = NULL;
41     syscheck.reg_fp         = NULL;
42 #endif
43     syscheck.prefilter_cmd  = NULL;
44
45     debug2("%s: Reading Configuration [%s]", "syscheckd", cfgfile);
46
47     /* Read config */
48     if (ReadConfig(modules, cfgfile, &syscheck, NULL) < 0) {
49         return (OS_INVALID);
50     }
51
52 #ifdef CLIENT
53     debug2("%s: Reading Client Configuration [%s]", "syscheckd", cfgfile);
54
55     /* Read shared config */
56     modules |= CAGENT_CONFIG;
57     ReadConfig(modules, AGENTCONFIG, &syscheck, NULL);
58 #endif
59
60 #ifndef WIN32
61     /* We must have at least one directory to check */
62     if (!syscheck.dir || syscheck.dir[0] == NULL) {
63         return (1);
64     }
65 #else
66     /* We must have at least one directory or registry key to check. Since
67        it's possible on Windows to have syscheck enabled but only monitoring
68        either the filesystem or the registry, both lists must be valid,
69        even if empty.
70      */
71     if (!syscheck.dir) {
72         syscheck.dir = SYSCHECK_EMPTY;
73     }
74     if (!syscheck.registry) {
75         syscheck.registry = SYSCHECK_EMPTY;
76     }
77     if ((syscheck.dir[0] == NULL) && (syscheck.registry[0] == NULL)) {
78         return (1);
79     }
80 #endif
81
82     return (0);
83 }
84