X-Git-Url: http://ftp.carnet.hr/carnet-debian/scm?a=blobdiff_plain;f=src%2Fconfig%2Falerts-config.c;h=7b86126fb65552d04af760fb3bc3f57664671c36;hb=3f728675941dc69d4e544d3a880a56240a6e394a;hp=85efc9504c3baeb597cf901e0c25352c8607a43e;hpb=301048b51990573e58a30dc4a5bb4ec285cad554;p=ossec-hids.git diff --git a/src/config/alerts-config.c b/src/config/alerts-config.c old mode 100755 new mode 100644 index 85efc95..7b86126 --- a/src/config/alerts-config.c +++ b/src/config/alerts-config.c @@ -1,5 +1,3 @@ -/* $OSSEC, alerts-config.c, v0.1, 2005/04/02, Daniel B. Cid$ */ - /* Copyright (C) 2009 Trend Micro Inc. * All right reserved. * @@ -9,69 +7,77 @@ * Foundation */ -/* Functions to handle the configuration files - */ - - #include "shared.h" #include "global-config.h" +#include "config.h" -int Read_Alerts(XML_NODE node, void *configp, void *mailp) +int Read_Alerts(XML_NODE node, void *configp, __attribute__((unused)) void *mailp) { int i = 0; /* XML definitions */ - char *xml_email_level = "email_alert_level"; - char *xml_log_level = "log_alert_level"; + const char *xml_email_level = "email_alert_level"; + const char *xml_log_level = "log_alert_level"; + +#ifdef LIBGEOIP_ENABLED + /* GeoIP */ + const char *xml_log_geoip = "use_geoip"; +#endif _Config *Config; - Config = (_Config *)configp; - - while(node[i]) - { - if(!node[i]->element) - { - merror(XML_ELEMNULL, ARGV0); - return(OS_INVALID); - } - else if(!node[i]->content) - { - merror(XML_VALUENULL, ARGV0, node[i]->element); - return(OS_INVALID); + if (!Config) { + merror("%s: ERROR: Configuration handle is NULL.", __local_name); + return (OS_INVALID); + } + + while (node[i]) { + if (!node[i]->element) { + merror(XML_ELEMNULL, __local_name); + return (OS_INVALID); + } else if (!node[i]->content) { + merror(XML_VALUENULL, __local_name, node[i]->element); + return (OS_INVALID); } /* Mail notification */ - else if(strcmp(node[i]->element, xml_email_level) == 0) - { - if(!OS_StrIsNum(node[i]->content)) - { - merror(XML_VALUEERR,ARGV0,node[i]->element,node[i]->content); - return(OS_INVALID); + else if (strcmp(node[i]->element, xml_email_level) == 0) { + if (!OS_StrIsNum(node[i]->content)) { + merror(XML_VALUEERR, __local_name, node[i]->element, node[i]->content); + return (OS_INVALID); } - Config->mailbylevel = atoi(node[i]->content); + Config->mailbylevel = (u_int8_t) atoi(node[i]->content); } /* Log alerts */ - else if(strcmp(node[i]->element, xml_log_level) == 0) - { - if(!OS_StrIsNum(node[i]->content)) - { - merror(XML_VALUEERR,ARGV0,node[i]->element,node[i]->content); - return(OS_INVALID); + else if (strcmp(node[i]->element, xml_log_level) == 0) { + if (!OS_StrIsNum(node[i]->content)) { + merror(XML_VALUEERR, __local_name, node[i]->element, node[i]->content); + return (OS_INVALID); + } + Config->logbylevel = (u_int8_t) atoi(node[i]->content); + } +#ifdef LIBGEOIP_ENABLED + /* Enable GeoIP */ + else if (strcmp(node[i]->element, xml_log_geoip) == 0) { + if (strcmp(node[i]->content, "yes") == 0) { + Config->loggeoip = 1; + } else if (strcmp(node[i]->content, "no") == 0) { + Config->loggeoip = 0; + } else { + merror(XML_VALUEERR, __local_name, node[i]->element, node[i]->content); + return (OS_INVALID); } - Config->logbylevel = atoi(node[i]->content); + } - else - { - merror(XML_INVELEM, ARGV0, node[i]->element); - return(OS_INVALID); +#endif + else { + merror(XML_INVELEM, __local_name, node[i]->element); + return (OS_INVALID); } i++; } - return(0); + return (0); } - -/* EOF */