Merge commit 'v2.5.1'
[ossec-hids.git] / src / config / config.c
index c707e0f..c0cda89 100755 (executable)
@@ -1,11 +1,11 @@
-/* @(#) $Id: config.c,v 1.25 2009/08/27 18:17:41 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
  */
 
@@ -40,6 +40,7 @@ int read_main_elements(OS_XML xml, int modules,
     char *osremote = "remote";
     char *osclient = "client";
     char *oscommand = "command";
+    char *osreports = "reports";
     char *osactive_response = "active-response";
 
     
@@ -48,7 +49,7 @@ int read_main_elements(OS_XML xml, int modules,
         XML_NODE chld_node = NULL;
         
         chld_node = OS_GetElementsbyNode(&xml,node[i]);
-        
+
         if(!node[i]->element)
         {
             merror(XML_ELEMNULL, ARGV0);
@@ -132,13 +133,20 @@ int read_main_elements(OS_XML xml, int modules,
             if((modules & CAR)&&(ReadActiveResponses(chld_node, d1, d2)<0))
                 return(OS_INVALID);
         }
+        else if(strcmp(node[i]->element, osreports) == 0)
+        {
+            if((modules & CREPORTS)&&(Read_CReports(chld_node, d1, d2)<0))
+                return(OS_INVALID);
+        }
         else
         {
             merror(XML_INVELEM, ARGV0, node[i]->element);
             return(OS_INVALID);
         }
         
+        //printf("before\n");
         OS_ClearNode(chld_node);
+        //printf("after\n");
         i++;
     }
 
@@ -170,6 +178,9 @@ int ReadConfig(int modules, char *cfgfile, void *d1, void *d2)
     {
         if(modules & CAGENT_CONFIG)
         {
+            #ifndef CLIENT
+            merror(XML_ERROR, ARGV0, cfgfile, xml.err, xml.err_line);
+            #endif
         }
         else
         {
@@ -229,6 +240,7 @@ int ReadConfig(int modules, char *cfgfile, void *d1, void *d2)
                 {
                     if(strcmp(xml_agent_name, node[i]->attributes[attrs]) == 0)
                     {
+                        #ifdef CLIENT
                         char *agentname = os_read_agent_name();
 
                         if(!agentname)
@@ -243,9 +255,11 @@ int ReadConfig(int modules, char *cfgfile, void *d1, void *d2)
                             }
                             free(agentname);
                         }
+                        #endif
                     }
                     else if(strcmp(xml_agent_os, node[i]->attributes[attrs]) == 0)
                     {
+                        #ifdef CLIENT
                         char *agentos = getuname();
 
                         if(agentos)
@@ -261,6 +275,7 @@ int ReadConfig(int modules, char *cfgfile, void *d1, void *d2)
                             passed_agent_test = 0;
                             merror("%s: ERROR: Unable to retrieve uname.", ARGV0);
                         }
+                        #endif
                     }
                     else if(strcmp(xml_agent_overwrite, node[i]->attributes[attrs]) == 0)
                     {