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