-/* @(#) $Id: global-config.c,v 1.24 2009/07/23 19:31:35 dcid Exp $ */
+/* @(#) $Id: ./src/config/global-config.c, 2011/09/08 dcid Exp $
+ */
/* 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
*/
_Config *Config;
Config = (_Config *)configp;
-
-
+
+
/* Shouldn't be here if !Config */
if(!Config)
return(0);
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)
{
ww++;
}
}
-
+
/* Getting right white_size */
if(Config && Config->hostname_white_list)
{
ww++;
}
}
-
+
/* Getting mail_to size */
if(Mail && Mail->to)
{
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
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
{
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)
{
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);
}
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,
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.
*/
return(OS_INVALID);
}
#endif
-
+
if(Mail)
{
mailto_size++;
return(OS_INVALID);
}
}
- #endif
+ #endif
}
else if(strcmp(node[i]->element, xml_mailmaxperhour) == 0)
{
}
}
}
+#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);