Imported Upstream version 2.7
[ossec-hids.git] / src / syscheckd / config.c
index 500c612..0ee30e4 100755 (executable)
@@ -1,4 +1,5 @@
-/* @(#) $Id$ */
+/* @(#) $Id: ./src/syscheckd/config.c, 2011/09/08 dcid Exp $
+ */
 
 /* Copyright (C) 2009 Trend Micro Inc.
  * All right reserved.
@@ -14,6 +15,8 @@
 #include "syscheck.h"
 #include "config/config.h"
 
+char *SYSCHECK_EMPTY[] = { NULL };
+
 int Read_Syscheck_Config(char * cfgfile)
 {
     int modules = 0;
@@ -35,7 +38,10 @@ int Read_Syscheck_Config(char * cfgfile)
     syscheck.registry = NULL;
     syscheck.reg_fp = NULL;
     #endif
+    syscheck.prefilter_cmd = NULL;
+
 
+    debug2("%s: Reading Configuration [%s]", "syscheckd", cfgfile);
 
     /* Reading config */
     if(ReadConfig(modules, cfgfile, &syscheck, NULL) < 0)
@@ -43,18 +49,36 @@ int Read_Syscheck_Config(char * cfgfile)
 
 
     #ifdef CLIENT
+    debug2("%s: Reading Client Configuration [%s]", "syscheckd", cfgfile);
+
     /* Reading shared config */
     modules|= CAGENT_CONFIG;
     ReadConfig(modules, AGENTCONFIG, &syscheck, NULL);
     #endif
-              
 
+
+    #ifndef WIN32
     /* We must have at least one directory to check */
     if(!syscheck.dir || syscheck.dir[0] == NULL)
     {
         return(1);
     }
-                                        
+
+    #else
+    /* We must have at least one directory or registry key to check. Since
+       it's possible on Windows to have syscheck enabled but only monitoring
+       either the filesystem or the registry, both lists must be valid,
+       even if empty.
+     */
+    if(!syscheck.dir) syscheck.dir = SYSCHECK_EMPTY;
+    if(!syscheck.registry) syscheck.registry = SYSCHECK_EMPTY;
+
+    if((syscheck.dir[0] == NULL) && (syscheck.registry[0] == NULL))
+    {
+        return(1);
+    }
+    #endif
+
 
     return(0);
 }