Imported Upstream version 2.5.1
[ossec-hids.git] / src / config / localfile-config.c
index dd523e8..6f53bff 100755 (executable)
@@ -1,11 +1,11 @@
-/* @(#) $Id: localfile-config.c,v 1.25 2009/11/03 21:07:32 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
  */
 
@@ -31,7 +31,8 @@ int Read_Localfile(XML_NODE node, void *d1, void *d2)
     char *xml_localfile_location = "location";
     char *xml_localfile_command = "command";
     char *xml_localfile_logformat = "log_format";
-
+    char *xml_localfile_frequency = "frequency";
+    char *xml_localfile_alias = "alias";
 
     logreader *logf;
     logreader_config *log_config;
@@ -46,9 +47,11 @@ int Read_Localfile(XML_NODE node, void *d1, void *d2)
         logf = log_config->config;
         logf[0].file = NULL;
         logf[0].command = NULL;
+        logf[0].alias = NULL;
         logf[0].logformat = NULL;
         logf[1].file = NULL;
         logf[1].command = NULL;
+        logf[1].alias = NULL;
         logf[1].logformat = NULL;
     }
     else
@@ -64,16 +67,19 @@ int Read_Localfile(XML_NODE node, void *d1, void *d2)
         logf = log_config->config;
         logf[pl +1].file = NULL;
         logf[pl +1].command = NULL;
+        logf[pl +1].alias = NULL;
         logf[pl +1].logformat = NULL;
     }
     
     logf[pl].file = NULL;
     logf[pl].command = NULL;
+    logf[pl].alias = NULL;
     logf[pl].logformat = NULL;
     logf[pl].fp = NULL;
     logf[pl].ffile = NULL;
     logf[pl].djb_program_name = NULL;
-    
+    logf[pl].ign = 360;
+
     
     /* Searching for entries related to files */
     i = 0;
@@ -94,6 +100,16 @@ int Read_Localfile(XML_NODE node, void *d1, void *d2)
             os_strdup(node[i]->content, logf[pl].file);
             logf[pl].command = logf[pl].file;
         }
+        else if(strcmp(node[i]->element,xml_localfile_frequency) == 0)
+        {
+            if(!OS_StrIsNum(node[i]->content))
+            {
+                merror(XML_VALUEERR,ARGV0,node[i]->element,node[i]->content);
+                return(OS_INVALID);
+            }
+
+            logf[pl].ign = atoi(node[i]->content);
+        }
         else if(strcmp(node[i]->element,xml_localfile_location) == 0)
         {
             #ifdef WIN32
@@ -190,11 +206,13 @@ int Read_Localfile(XML_NODE node, void *d1, void *d2)
                 logf = log_config->config;
                 
                 logf[pl].file = NULL;
+                logf[pl].alias = NULL;
                 logf[pl].logformat = NULL;
                 logf[pl].fp = NULL;
                 logf[pl].ffile = NULL;
                             
                 logf[pl +1].file = NULL;
+                logf[pl +1].alias = NULL;
                 logf[pl +1].logformat = NULL;
 
                 /* We can not increment the file count in here */
@@ -242,6 +260,9 @@ int Read_Localfile(XML_NODE node, void *d1, void *d2)
             if(strcmp(logf[pl].logformat, "syslog") == 0)
             {
             }
+            else if(strcmp(logf[pl].logformat, "generic") == 0)
+            {
+            }
             else if(strcmp(logf[pl].logformat, "snort-full") == 0)
             {
             }
@@ -278,6 +299,39 @@ int Read_Localfile(XML_NODE node, void *d1, void *d2)
             else if(strcmp(logf[pl].logformat, "command") == 0)
             {
             }
+            else if(strcmp(logf[pl].logformat, "full_command") == 0)
+            {
+            }
+            else if(strncmp(logf[pl].logformat, "multi-line", 10) == 0)
+            {
+                int x = 0;
+                logf[pl].logformat+=10;
+
+                while(logf[pl].logformat[0] == ' ')
+                    logf[pl].logformat++;
+                
+                if(logf[pl].logformat[0] != ':')
+                {
+                    merror(XML_VALUEERR,ARGV0,node[i]->element,node[i]->content);
+                    return(OS_INVALID);
+                }
+                logf[pl].logformat++;
+
+                while(*logf[pl].logformat == ' ')
+                    logf[pl].logformat++;
+                
+                while(logf[pl].logformat[x] >= '0' && logf[pl].logformat[x] <= '9')    
+                    x++;
+
+                while(logf[pl].logformat[x] == ' ')
+                    x++;
+
+                if(logf[pl].logformat[x] != '\0')
+                {
+                    merror(XML_VALUEERR,ARGV0,node[i]->element,node[i]->content);
+                    return(OS_INVALID);
+                }
+            }
             else if(strcmp(logf[pl].logformat, EVENTLOG) == 0)
             {
             }
@@ -287,6 +341,10 @@ int Read_Localfile(XML_NODE node, void *d1, void *d2)
                 return(OS_INVALID);
             }
         }
+        else if(strcasecmp(node[i]->element,xml_localfile_alias) == 0)
+        {
+            os_strdup(node[i]->content, logf[pl].alias);
+        }
         else
         {
             merror(XML_INVELEM, ARGV0, node[i]->element);
@@ -366,7 +424,8 @@ int Read_Localfile(XML_NODE node, void *d1, void *d2)
          }
     }
 
-    if(strcmp(logf[pl].logformat, "command") == 0)
+    if((strcmp(logf[pl].logformat, "command") == 0)||
+       (strcmp(logf[pl].logformat, "full_command") == 0)) 
     {
         if(!logf[pl].command)
         {