From dbc8bb8dbc278b80dd13e732da9647c9df856fa4 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Mon, 13 Dec 2010 20:54:22 +0300 Subject: Implement checking options for modules Implement checking for classifier options Fix redirector to handle timeouts and invalid replies properly Fix surbl module not to check each url --- src/cfg_utils.c | 48 +++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 43 insertions(+), 5 deletions(-) (limited to 'src/cfg_utils.c') diff --git a/src/cfg_utils.c b/src/cfg_utils.c index 2a0f548b8..b98746fe9 100644 --- a/src/cfg_utils.c +++ b/src/cfg_utils.c @@ -901,12 +901,12 @@ static GMarkupParser xml_parser = { gboolean read_xml_config (struct config_file *cfg, const gchar *filename) { - struct stat st; + struct stat st; gint fd; - gchar *data; - gboolean res; - GMarkupParseContext *ctx; - GError *err = NULL; + gchar *data; + gboolean res; + GMarkupParseContext *ctx; + GError *err = NULL; struct rspamd_xml_userdata ud; @@ -939,6 +939,44 @@ read_xml_config (struct config_file *cfg, const gchar *filename) return res; } +static void +modules_config_callback (gpointer key, gpointer value, gpointer ud) +{ + extern GHashTable *module_options; + GHashTable *cur_module; + GList *cur; + struct module_opt *opt; + const gchar *mname = key; + gboolean *res = ud; + + if ((cur_module = g_hash_table_lookup (module_options, mname)) == NULL) { + msg_warn ("module %s has not registered any options but is presented in configuration", mname); + *res = FALSE; + return; + } + + cur = value; + while (cur) { + opt = cur->data; + + if (!opt->is_lua && !check_module_option (mname, opt->param, opt->value)) { + *res = FALSE; + return; + } + + cur = g_list_next (cur); + } +} + +gboolean +check_modules_config (struct config_file *cfg) +{ + gboolean res = TRUE; + + g_hash_table_foreach (cfg->modules_opts, modules_config_callback, &res); + return res; +} + /* * vi:ts=4 */ -- cgit v1.2.3