X-Git-Url: http://ftp.carnet.hr/carnet-debian/scm?p=ossec-hids.git;a=blobdiff_plain;f=src%2Fconfig%2Fglobal-config.c;h=dad66a4a136f758bf1268660a2e7fd9e225c087d;hp=93803089fbd7c25a4339095100074b30450349f1;hb=6ef2f786c6c8ead94841b5f93baf9f43421f08c8;hpb=301048b51990573e58a30dc4a5bb4ec285cad554 diff --git a/src/config/global-config.c b/src/config/global-config.c index 9380308..dad66a4 100755 --- a/src/config/global-config.c +++ b/src/config/global-config.c @@ -1,4 +1,5 @@ -/* @(#) $Id$ */ +/* @(#) $Id: ./src/config/global-config.c, 2011/09/08 dcid Exp $ + */ /* Copyright (C) 2009 Trend Micro Inc. * All right reserved. @@ -45,8 +46,8 @@ int Read_GlobalSK(XML_NODE node, void *configp, void *mailp) _Config *Config; Config = (_Config *)configp; - - + + /* Shouldn't be here if !Config */ if(!Config) return(0); @@ -164,12 +165,18 @@ int Read_Global(XML_NODE node, void *configp, void *mailp) char *xml_smtpserver = "smtp_server"; char *xml_mailmaxperhour = "email_maxperhour"; +#ifdef GEOIP + /* GeoIP */ + char *xml_geoip_db_path = "geoip_db_path"; + char *xml_geoip6_db_path = "geoip6_db_path"; +#endif + _Config *Config; MailConfig *Mail; - + Config = (_Config *)configp; Mail = (MailConfig *)mailp; - + /* Getting right white_size */ if(Config && Config->white_list) { @@ -182,7 +189,7 @@ int Read_Global(XML_NODE node, void *configp, void *mailp) ww++; } } - + /* Getting right white_size */ if(Config && Config->hostname_white_list) { @@ -195,7 +202,7 @@ int Read_Global(XML_NODE node, void *configp, void *mailp) ww++; } } - + /* Getting mail_to size */ if(Mail && Mail->to) { @@ -224,13 +231,13 @@ int Read_Global(XML_NODE node, void *configp, void *mailp) else if(strcmp(node[i]->element, xml_mailnotify) == 0) { if(strcmp(node[i]->content, "yes") == 0) - { - if(Config) Config->mailnotify = 1; + { + if(Config) Config->mailnotify = 1; if(Mail) Mail->mn = 1; } else if(strcmp(node[i]->content, "no") == 0) - { - if(Config) Config->mailnotify = 0; + { + if(Config) Config->mailnotify = 0; if(Mail) Mail->mn = 0; } else @@ -267,12 +274,12 @@ int Read_Global(XML_NODE node, void *configp, void *mailp) else if(strcmp(node[i]->element, xml_prelude) == 0) { if(strcmp(node[i]->content, "yes") == 0) - { - if(Config) Config->prelude = 1; + { + if(Config) Config->prelude = 1; } else if(strcmp(node[i]->content, "no") == 0) - { - if(Config) Config->prelude = 0; + { + if(Config) Config->prelude = 0; } else { @@ -391,11 +398,11 @@ int Read_Global(XML_NODE node, void *configp, void *mailp) char *ip_address_regex = "^[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}/?" "([0-9]{0,2}|[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3})$"; - + if(Config && OS_PRegex(node[i]->content, ip_address_regex)) { white_size++; - Config->white_list = + Config->white_list = realloc(Config->white_list, sizeof(os_ip *)*white_size); if(!Config->white_list) { @@ -405,11 +412,11 @@ int Read_Global(XML_NODE node, void *configp, void *mailp) os_calloc(1, sizeof(os_ip), Config->white_list[white_size -2]); Config->white_list[white_size -1] = NULL; - + if(!OS_IsValidIP(node[i]->content, Config->white_list[white_size -2])) { - merror(INVALID_IP, ARGV0, + merror(INVALID_IP, ARGV0, node[i]->content); return(OS_INVALID); } @@ -421,20 +428,20 @@ int Read_Global(XML_NODE node, void *configp, void *mailp) Config->hostname_white_list = realloc(Config->hostname_white_list, sizeof(OSMatch *)*hostname_white_size); - + if(!Config->hostname_white_list) { merror(MEM_ERROR, ARGV0); return(OS_INVALID); } - os_calloc(1, - sizeof(OSMatch), + os_calloc(1, + sizeof(OSMatch), Config->hostname_white_list[hostname_white_size -2]); Config->hostname_white_list[hostname_white_size -1] = NULL; if(!OSMatch_Compile( - node[i]->content, - Config->hostname_white_list[hostname_white_size -2], + node[i]->content, + Config->hostname_white_list[hostname_white_size -2], 0)) { merror(REGEX_COMPILE, ARGV0, node[i]->content, @@ -443,12 +450,12 @@ int Read_Global(XML_NODE node, void *configp, void *mailp) return(-1); } } - + #endif - + } - /* For the email now + /* For the email now * email_to, email_from, smtp_Server and maxperhour. * We will use a separate structure for that. */ @@ -461,7 +468,7 @@ int Read_Global(XML_NODE node, void *configp, void *mailp) return(OS_INVALID); } #endif - + if(Mail) { mailto_size++; @@ -499,7 +506,7 @@ int Read_Global(XML_NODE node, void *configp, void *mailp) return(OS_INVALID); } } - #endif + #endif } else if(strcmp(node[i]->element, xml_mailmaxperhour) == 0) { @@ -519,6 +526,24 @@ int Read_Global(XML_NODE node, void *configp, void *mailp) } } } +#ifdef GEOIP + /* GeoIP v4 DB location */ + else if(strcmp(node[i]->element, xml_geoip_db_path) == 0) + { + if(Config) + { + os_strdup(node[i]->content, Config->geoip_db_path); + } + } + /* GeoIP v6 DB location */ + else if(strcmp(node[i]->element, xml_geoip6_db_path) == 0) + { + if(Config) + { + os_strdup(node[i]->content, Config->geoip6_db_path); + } + } +#endif else { merror(XML_INVELEM, ARGV0, node[i]->element);