diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/cfg_xml.c | 624 | ||||
-rw-r--r-- | src/cfg_xml.h | 122 | ||||
-rw-r--r-- | src/lua/lua_config.c | 44 | ||||
-rw-r--r-- | src/main.c | 7 | ||||
-rw-r--r-- | src/plugins/chartable.c | 2 | ||||
-rw-r--r-- | src/plugins/dkim_check.c | 11 | ||||
-rw-r--r-- | src/plugins/fuzzy_check.c | 13 | ||||
-rw-r--r-- | src/plugins/regexp.c | 4 | ||||
-rw-r--r-- | src/plugins/spf.c | 6 | ||||
-rw-r--r-- | src/plugins/surbl.c | 13 |
10 files changed, 2 insertions, 844 deletions
diff --git a/src/cfg_xml.c b/src/cfg_xml.c index 1e20f0456..e8f0207cb 100644 --- a/src/cfg_xml.c +++ b/src/cfg_xml.c @@ -67,603 +67,6 @@ enum xml_read_state { #define EOL "\n" -#if 0 -#define NULL_ATTR \ -{ \ - NULL, \ - NULL, \ - 0, \ - NULL \ -} \ - -#define NULL_DEF_ATTR \ -{ \ - NULL, \ - 0, \ - NULL \ -} \ - -enum xml_config_section { - XML_SECTION_MAIN, - XML_SECTION_OPTIONS, - XML_SECTION_LOGGING, - XML_SECTION_WORKER, - XML_SECTION_METRIC, - XML_SECTION_CLASSIFIER, - XML_SECTION_STATFILE, - XML_SECTION_MODULE, - XML_SECTION_MODULE_META, - XML_SECTION_MODULES, - XML_SECTION_VIEW -}; - -struct xml_config_param { - const gchar *name; - element_handler_func handler; - gint offset; - gpointer user_data; -}; - -struct xml_default_config_param { - element_default_handler_func handler; - gint offset; - gpointer user_data; -}; - -struct xml_parser_rule { - enum xml_config_section section; - struct xml_config_param params[MAX_PARAM]; - struct xml_default_config_param default_param; -}; - -struct xml_subparser { - enum xml_read_state state; - const GMarkupParser *parser; - gpointer user_data; - void (*fin_func)(gpointer ud); -}; - -/* Here we describes our basic grammar */ -static struct xml_parser_rule grammar[] = { - { XML_SECTION_MAIN, { - { - "pidfile", - xml_handle_string, - G_STRUCT_OFFSET (struct config_file, pid_file), - NULL - }, - { - "lua", - handle_lua, - 0, - NULL - }, - { - "raw_mode", - xml_handle_boolean, - G_STRUCT_OFFSET (struct config_file, raw_mode), - NULL - }, - { - "check_attachements", - xml_handle_boolean, - G_STRUCT_OFFSET (struct config_file, check_text_attachements), - NULL - }, - { - "tempdir", - xml_handle_string, - G_STRUCT_OFFSET (struct config_file, temp_dir), - NULL - }, - { - "checksum", - xml_handle_string, - G_STRUCT_OFFSET (struct config_file, dump_checksum), - NULL - }, - { - "statfile_pool_size", - xml_handle_size, - G_STRUCT_OFFSET (struct config_file, max_statfile_size), - NULL - }, - { - "filters", - xml_handle_string, - G_STRUCT_OFFSET (struct config_file, filters_str), - NULL - }, - { - "variable", - handle_variable, - 0, - NULL - }, - { - "composite", - handle_composite, - 0, - NULL - }, - { - "user_settings", - handle_user_settings, - 0, - NULL - }, - { - "domain_settings", - handle_domain_settings, - 0, - NULL - }, - { - "cache_file", - xml_handle_string, - G_STRUCT_OFFSET (struct config_file, cache_filename), - NULL - }, - { - "dns_timeout", - xml_handle_seconds, - G_STRUCT_OFFSET (struct config_file, dns_timeout), - NULL - }, - { - "dns_retransmits", - xml_handle_uint32, - G_STRUCT_OFFSET (struct config_file, dns_retransmits), - NULL - }, - { - "dns_throttling_errors", - xml_handle_uint32, - G_STRUCT_OFFSET (struct config_file, dns_throttling_errors), - NULL - }, - { - "dns_throttling_time", - xml_handle_seconds, - G_STRUCT_OFFSET (struct config_file, dns_throttling_time), - NULL - }, - NULL_ATTR - }, - NULL_DEF_ATTR - }, - { XML_SECTION_OPTIONS, { - { - "statfile_pool_size", - xml_handle_size, - G_STRUCT_OFFSET (struct config_file, max_statfile_size), - NULL - }, - { - "user_settings", - handle_user_settings, - 0, - NULL - }, - { - "domain_settings", - handle_domain_settings, - 0, - NULL - }, - { - "cache_file", - xml_handle_string, - G_STRUCT_OFFSET (struct config_file, cache_filename), - NULL - }, - { - "dns_timeout", - xml_handle_seconds, - G_STRUCT_OFFSET (struct config_file, dns_timeout), - NULL - }, - { - "dns_retransmits", - xml_handle_uint32, - G_STRUCT_OFFSET (struct config_file, dns_retransmits), - NULL - }, - { - "dns_nameserver", - options_handle_nameserver, - 0, - NULL - }, - { - "raw_mode", - xml_handle_boolean, - G_STRUCT_OFFSET (struct config_file, raw_mode), - NULL - }, - { - "one_shot", - xml_handle_boolean, - G_STRUCT_OFFSET (struct config_file, one_shot_mode), - NULL - }, - { - "check_attachements", - xml_handle_boolean, - G_STRUCT_OFFSET (struct config_file, check_text_attachements), - NULL - }, - { - "tempdir", - xml_handle_string, - G_STRUCT_OFFSET (struct config_file, temp_dir), - NULL - }, - { - "pidfile", - xml_handle_string, - G_STRUCT_OFFSET (struct config_file, pid_file), - NULL - }, - { - "filters", - xml_handle_string, - G_STRUCT_OFFSET (struct config_file, filters_str), - NULL - }, - { - "sync_interval", - xml_handle_seconds, - G_STRUCT_OFFSET (struct config_file, statfile_sync_interval), - NULL - }, - { - "sync_timeout", - xml_handle_seconds, - G_STRUCT_OFFSET (struct config_file, statfile_sync_timeout), - NULL - }, - { - "max_diff", - xml_handle_size, - G_STRUCT_OFFSET (struct config_file, max_diff), - NULL - }, - { - "map_watch_interval", - xml_handle_seconds_double, - G_STRUCT_OFFSET (struct config_file, map_timeout), - NULL - }, - { - "dynamic_conf", - xml_handle_string, - G_STRUCT_OFFSET (struct config_file, dynamic_conf), - NULL - }, - { - "use_mlock", - xml_handle_boolean, - G_STRUCT_OFFSET (struct config_file, mlock_statfile_pool), - NULL - }, - { - "rrd", - xml_handle_string, - G_STRUCT_OFFSET (struct config_file, rrd_file), - NULL - }, - { - "history_file", - xml_handle_string, - G_STRUCT_OFFSET (struct config_file, history_file), - NULL - }, - NULL_ATTR - }, - NULL_DEF_ATTR - }, - { XML_SECTION_LOGGING, { - { - "type", - handle_log_type, - 0, - NULL - }, - { - "level", - handle_log_level, - 0, - NULL - }, - { - "log_urls", - xml_handle_boolean, - G_STRUCT_OFFSET (struct config_file, log_urls), - NULL - }, - { - "log_buffer", - xml_handle_uint32, - G_STRUCT_OFFSET (struct config_file, log_buf_size), - NULL - }, - { - "debug_ip", - xml_handle_string, - G_STRUCT_OFFSET (struct config_file, debug_ip_map), - NULL - }, - { - "debug_symbols", - xml_handle_string_list, - G_STRUCT_OFFSET (struct config_file, debug_symbols), - NULL - }, - { - "log_color", - xml_handle_boolean, - G_STRUCT_OFFSET (struct config_file, log_color), - NULL - }, - NULL_ATTR - }, - NULL_DEF_ATTR - }, - { XML_SECTION_WORKER, { - { - "type", - worker_handle_type, - 0, - NULL - }, - { - "bind_socket", - worker_handle_bind, - 0, - NULL - }, - { - "count", - xml_handle_uint16, - G_STRUCT_OFFSET (struct worker_conf, count), - NULL - }, - { - "maxfiles", - xml_handle_uint32, - G_STRUCT_OFFSET (struct worker_conf, rlimit_nofile), - NULL - }, - { - "maxcore", - xml_handle_uint32, - G_STRUCT_OFFSET (struct worker_conf, rlimit_maxcore), - NULL - }, - NULL_ATTR - }, - { - worker_handle_param, - 0, - NULL - } - }, - { XML_SECTION_METRIC, { - { - "name", - xml_handle_string, - G_STRUCT_OFFSET (struct metric, name), - NULL - }, - { - "grow_factor", - xml_handle_double, - G_STRUCT_OFFSET (struct metric, grow_factor), - NULL - }, - { - "required_score", - xml_handle_deprecated, - 0, - NULL - }, - { - "reject_score", - xml_handle_deprecated, - 0, - NULL - }, - { - "subject", - xml_handle_string, - G_STRUCT_OFFSET (struct metric, subject), - NULL - }, - { - "symbol", - handle_metric_symbol, - 0, - NULL - }, - { - "action", - handle_metric_action, - 0, - NULL - }, - NULL_ATTR - }, - NULL_DEF_ATTR - }, - { XML_SECTION_CLASSIFIER, { - { - "metric", - xml_handle_string, - G_STRUCT_OFFSET (struct classifier_config, metric), - NULL - }, - { - "tokenizer", - handle_classifier_tokenizer, - 0, - NULL - }, - NULL_ATTR - }, - { - handle_classifier_opt, - 0, - NULL - } - }, - { XML_SECTION_STATFILE, { - { - "symbol", - xml_handle_string, - G_STRUCT_OFFSET (struct statfile, symbol), - NULL - }, - { - "path", - xml_handle_string, - G_STRUCT_OFFSET (struct statfile, path), - NULL - }, - { - "label", - xml_handle_string, - G_STRUCT_OFFSET (struct statfile, label), - NULL - }, - { - "size", - xml_handle_size, - G_STRUCT_OFFSET (struct statfile, size), - NULL - }, - { - "spam", - xml_handle_boolean, - G_STRUCT_OFFSET (struct statfile, is_spam), - NULL - }, - { - "normalizer", - handle_statfile_normalizer, - 0, - NULL - }, - { - "binlog", - handle_statfile_binlog, - 0, - NULL - }, - { - "binlog_rotate", - handle_statfile_binlog_rotate, - 0, - NULL - }, - { - "binlog_master", - handle_statfile_binlog_master, - 0, - NULL - }, - NULL_ATTR - }, - { - handle_statfile_opt, - 0, - NULL - } - }, - { XML_SECTION_MODULE_META, { - { - "name", - xml_handle_string, - G_STRUCT_OFFSET (struct module_meta_opt, name), - NULL - }, - NULL_ATTR - }, - { - handle_module_meta, - 0, - NULL - } - }, - { XML_SECTION_MODULE, { - NULL_ATTR - }, - { - handle_module_opt, - 0, - NULL - } - }, - { XML_SECTION_MODULES, { - { - "path", - handle_module_path, - 0, - NULL - }, - NULL_ATTR - }, - NULL_DEF_ATTR - }, - { XML_SECTION_VIEW, { - { - "skip_check", - xml_handle_boolean, - G_STRUCT_OFFSET (struct rspamd_view, skip_check), - NULL - }, - { - "ip", - handle_view_ip, - 0, - NULL - }, - { - "client_ip", - handle_view_client_ip, - 0, - NULL - }, - { - "from", - handle_view_from, - 0, - NULL - }, - { - "rcpt", - handle_view_rcpt, - 0, - NULL - }, - { - "symbols", - handle_view_symbols, - 0, - NULL - }, - NULL_ATTR - }, - NULL_DEF_ATTR - }, -}; - -GHashTable *module_options = NULL, - *worker_options = NULL, - *classifier_options = NULL, - *subparsers = NULL; -#endif - GQuark xml_error_quark (void) { @@ -924,30 +327,3 @@ rspamd_xml_error (GMarkupParseContext *context, GError *error, gpointer user_dat msg_err ("xml parser error: %s, at state \"%s\"", error->message, xml_state_to_string (ud)); } - -/* Register new module option */ -void -register_module_opt (const gchar *mname, const gchar *optname, enum module_opt_type type) -{ - msg_err ("this function is depreciated and must not be used"); -} - -/* Register new worker's options */ -void -register_worker_opt (gint wtype, const gchar *optname, element_handler_func func, gpointer dest_struct, gint offset) -{ - msg_err ("this function is depreciated and must not be used"); -} - -/* Register new classifier option */ -void -register_classifier_opt (const gchar *ctype, const gchar *optname) -{ - msg_err ("this function is depreciated and must not be used"); -} - -void -register_subparser (const gchar *tag, int state, const GMarkupParser *parser, void (*fin_func)(gpointer ud), gpointer user_data) -{ - msg_err ("this function is depreciated and must not be used"); -} diff --git a/src/cfg_xml.h b/src/cfg_xml.h index 9799b4926..e9d2707b0 100644 --- a/src/cfg_xml.h +++ b/src/cfg_xml.h @@ -14,19 +14,6 @@ #define MAX_INHERIT 5 -enum module_opt_type { - MODULE_OPT_TYPE_STRING = 0, - MODULE_OPT_TYPE_INT, - MODULE_OPT_TYPE_UINT, - MODULE_OPT_TYPE_DOUBLE, - MODULE_OPT_TYPE_TIME, - MODULE_OPT_TYPE_MAP, - MODULE_OPT_TYPE_SIZE, - MODULE_OPT_TYPE_FLAG, - MODULE_OPT_TYPE_META, - MODULE_OPT_TYPE_ANY -}; - /** * Structure that is used for semantic resolution of configuration */ @@ -40,11 +27,6 @@ struct rspamd_xml_userdata { gint nested; }; -/* Text is NULL terminated here */ -typedef gboolean (*element_handler_func) (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, gint offset); -typedef gboolean (*element_default_handler_func) (struct config_file *cfg, struct rspamd_xml_userdata *ctx, const gchar *tag, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, gint offset); - -/* Callbacks */ /* Called for open tags <foo bar="baz"> */ void rspamd_xml_start_element (GMarkupParseContext *context, @@ -67,110 +49,10 @@ void rspamd_xml_text (GMarkupParseContext *context, gpointer user_data, GError **error); -/* Called on error, including one set by other -* methods in the vtable. The GError should not be freed. -*/ -void rspamd_xml_error (GMarkupParseContext *context, - GError *error, - gpointer user_data); - - -/* Handlers */ -/* Basic xml parsing functions */ -gboolean xml_handle_string (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, gint offset); -gboolean xml_handle_string_list (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, gint offset); - -/* Handle glist attributes as strings */ -gboolean xml_handle_list (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, gint offset); - -/* Numeric params */ -gboolean xml_handle_size (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, gint offset); -gboolean xml_handle_size_64 (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, gint offset); -gboolean xml_handle_double (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, gint offset); -gboolean xml_handle_seconds (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, gint offset); -gboolean xml_handle_seconds_double (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, gint offset); -gboolean xml_handle_int (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, gint offset); -gboolean xml_handle_uint32 (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, gint offset); -gboolean xml_handle_uint16 (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, gint offset); - -/* Flags */ -gboolean xml_handle_boolean (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, gint offset); - -/* For deprecated attributes */ -gboolean xml_handle_deprecated (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, gint offset); - -/* Specific params */ -/* Options specific */ -gboolean options_handle_nameserver (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, gint offset); -/* Handle workers param */ -gboolean worker_handle_param (struct config_file *cfg, struct rspamd_xml_userdata *ctx, const gchar *tag, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, gint offset); -gboolean worker_handle_type (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, gint offset); -gboolean worker_handle_bind (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, gint offset); - -/* Handle metric symbol */ -gboolean handle_metric_symbol (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, gint offset); -gboolean handle_metric_action (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, gint offset); - -/* Handle common module option */ -gboolean handle_module_opt (struct config_file *cfg, struct rspamd_xml_userdata *ctx, const gchar *tag, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, gint offset); -gboolean handle_module_meta (struct config_file *cfg, struct rspamd_xml_userdata *ctx, const gchar *tag, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, gint offset); - -/* Handle loging params */ -gboolean handle_log_type (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, gint offset); -gboolean handle_log_level (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, gint offset); - -/* Handle lua include */ -gboolean handle_lua (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, gint offset); - -/* Handle path to modules */ -gboolean handle_module_path (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, gint offset); - -/* Handle variables and composites */ -gboolean handle_variable (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, gint offset); -gboolean handle_composite (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, gint offset); - -/* Handle views */ -gboolean handle_view_ip (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, gint offset); -gboolean handle_view_client_ip (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, gint offset); -gboolean handle_view_from (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, gint offset); -gboolean handle_view_rcpt (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, gint offset); -gboolean handle_view_symbols (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, gint offset); - -/* Handle settings */ -gboolean handle_user_settings (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, gint offset); -gboolean handle_domain_settings (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, gint offset); - -/* Handle classifier */ -gboolean handle_classifier_tokenizer (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, gint offset); -gboolean handle_classifier_opt (struct config_file *cfg, struct rspamd_xml_userdata *ctx, const gchar *tag, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, gint offset); - -/* Handle statfile */ -gboolean handle_statfile_normalizer (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, gint offset); -gboolean handle_statfile_binlog (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, gint offset); -gboolean handle_statfile_binlog_rotate (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, gint offset); -gboolean handle_statfile_binlog_master (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, gint offset); -gboolean handle_statfile_opt (struct config_file *cfg, struct rspamd_xml_userdata *ctx, const gchar *tag, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, gint offset); - -/* Register new module option */ -void register_module_opt (const gchar *mname, const gchar *optname, enum module_opt_type type); - -/* Register new worker's options */ -void register_worker_opt (gint wtype, const gchar *optname, element_handler_func func, gpointer dest_struct, gint offset); - -/* Register new classifier option */ -void register_classifier_opt (const gchar *ctype, const gchar *optname); - -/* Register new xml subparser */ -void register_subparser (const gchar *tag, int state, - const GMarkupParser *parser, void (*fin_func)(gpointer ud), gpointer user_data); - -/* Check validity of module option */ -gboolean check_module_option (const gchar *mname, const gchar *optname, const gchar *data); - -/* Dumper functions */ -gboolean xml_dump_config (struct config_file *cfg, const gchar *filename); /* XML error quark for reporting errors */ GQuark xml_error_quark (void); +void rspamd_xml_error (GMarkupParseContext *context, GError *error, gpointer user_data); + #endif diff --git a/src/lua/lua_config.c b/src/lua/lua_config.c index 4e8e6eb6d..48686ff03 100644 --- a/src/lua/lua_config.c +++ b/src/lua/lua_config.c @@ -341,50 +341,6 @@ lua_config_register_function (lua_State *L) static gint lua_config_register_module_option (lua_State *L) { - struct config_file *cfg = lua_check_config (L); - const gchar *mname, *optname, *stype; - enum module_opt_type type; - - if (cfg) { - mname = memory_pool_strdup (cfg->cfg_pool, luaL_checkstring (L, 2)); - optname = memory_pool_strdup (cfg->cfg_pool, luaL_checkstring (L, 3)); - stype = memory_pool_strdup (cfg->cfg_pool, luaL_checkstring (L, 4)); - if (mname && optname) { - if (stype == NULL) { - stype = "string"; - } - if (g_ascii_strcasecmp (stype, "string") == 0) { - type = MODULE_OPT_TYPE_STRING; - } - else if (g_ascii_strcasecmp (stype, "int") == 0) { - type = MODULE_OPT_TYPE_INT; - } - else if (g_ascii_strcasecmp (stype, "uint") == 0) { - type = MODULE_OPT_TYPE_UINT; - } - else if (g_ascii_strcasecmp (stype, "time") == 0) { - type = MODULE_OPT_TYPE_TIME; - } - else if (g_ascii_strcasecmp (stype, "size") == 0) { - type = MODULE_OPT_TYPE_SIZE; - } - else if (g_ascii_strcasecmp (stype, "map") == 0) { - type = MODULE_OPT_TYPE_MAP; - } - else if (g_ascii_strcasecmp (stype, "double") == 0) { - type = MODULE_OPT_TYPE_DOUBLE; - } - else { - msg_err ("unknown type '%s' for option: %s, for module: %s", stype, optname, mname); - luaL_error (L, "unknown type '%s' for option: %s, for module: %s", stype, optname, mname); - return 0; - } - register_module_opt (mname, optname, type); - return 1; - } - luaL_error (L, "bad arguments for register module option, must be: register_module_option(modulename, optionname, optiontype)"); - } - return 0; } diff --git a/src/main.c b/src/main.c index 50e295398..c350951f1 100644 --- a/src/main.c +++ b/src/main.c @@ -1123,13 +1123,6 @@ main (gint argc, gchar **argv, gchar **env) /* Init listen sockets hash */ listen_sockets = g_hash_table_new (g_direct_hash, g_direct_equal); - /* Init classifiers options */ - register_classifier_opt ("bayes", "min_tokens"); - register_classifier_opt ("winnow", "min_tokens"); - register_classifier_opt ("bayes", "max_tokens"); - register_classifier_opt ("winnow", "max_tokens"); - register_classifier_opt ("winnow", "learn_threshold"); - /* Pre-init of cache */ rspamd_main->cfg->cache = g_new0 (struct symbols_cache, 1); rspamd_main->cfg->cache->static_pool = memory_pool_new (memory_pool_get_size ()); diff --git a/src/plugins/chartable.c b/src/plugins/chartable.c index 69197dfd6..ec848f6df 100644 --- a/src/plugins/chartable.c +++ b/src/plugins/chartable.c @@ -76,8 +76,6 @@ chartable_module_init (struct config_file *cfg, struct module_ctx **ctx) chartable_module_ctx->chartable_pool = memory_pool_new (memory_pool_get_size ()); *ctx = (struct module_ctx *)chartable_module_ctx; - register_module_opt ("chartable", "symbol", MODULE_OPT_TYPE_STRING); - register_module_opt ("chartable", "threshold", MODULE_OPT_TYPE_STRING); return 0; } diff --git a/src/plugins/dkim_check.c b/src/plugins/dkim_check.c index 8e3fa4c23..95e07370a 100644 --- a/src/plugins/dkim_check.c +++ b/src/plugins/dkim_check.c @@ -96,17 +96,6 @@ dkim_module_init (struct config_file *cfg, struct module_ctx **ctx) dkim_module_ctx->dkim_pool = memory_pool_new (memory_pool_get_size ()); *ctx = (struct module_ctx *)dkim_module_ctx; - register_module_opt ("dkim", "symbol_reject", MODULE_OPT_TYPE_STRING); - register_module_opt ("dkim", "symbol_tempfail", MODULE_OPT_TYPE_STRING); - register_module_opt ("dkim", "symbol_allow", MODULE_OPT_TYPE_STRING); - register_module_opt ("dkim", "dkim_cache_size", MODULE_OPT_TYPE_UINT); - register_module_opt ("dkim", "dkim_cache_expire", MODULE_OPT_TYPE_TIME); - register_module_opt ("dkim", "whitelist", MODULE_OPT_TYPE_MAP); - register_module_opt ("dkim", "domains", MODULE_OPT_TYPE_MAP); - register_module_opt ("dkim", "strict_multiplier", MODULE_OPT_TYPE_UINT); - register_module_opt ("dkim", "time_jitter", MODULE_OPT_TYPE_TIME); - register_module_opt ("dkim", "trusted_only", MODULE_OPT_TYPE_FLAG); - register_module_opt ("dkim", "skip_multi", MODULE_OPT_TYPE_FLAG); return 0; } diff --git a/src/plugins/fuzzy_check.c b/src/plugins/fuzzy_check.c index 60549b849..066d58272 100644 --- a/src/plugins/fuzzy_check.c +++ b/src/plugins/fuzzy_check.c @@ -357,19 +357,6 @@ fuzzy_check_module_init (struct config_file *cfg, struct module_ctx **ctx) fuzzy_module_ctx->mappings = g_hash_table_new (g_direct_hash, g_direct_equal); *ctx = (struct module_ctx *)fuzzy_module_ctx; - /* Register module options */ - register_module_opt ("fuzzy_check", "symbol", MODULE_OPT_TYPE_STRING); - register_module_opt ("fuzzy_check", "max_score", MODULE_OPT_TYPE_DOUBLE); - register_module_opt ("fuzzy_check", "servers", MODULE_OPT_TYPE_STRING); - register_module_opt ("fuzzy_check", "fuzzy_map", MODULE_OPT_TYPE_STRING); - register_module_opt ("fuzzy_check", "whitelist", MODULE_OPT_TYPE_STRING); - register_module_opt ("fuzzy_check", "mime_types", MODULE_OPT_TYPE_STRING); - register_module_opt ("fuzzy_check", "min_length", MODULE_OPT_TYPE_UINT); - register_module_opt ("fuzzy_check", "min_bytes", MODULE_OPT_TYPE_UINT); - register_module_opt ("fuzzy_check", "min_height", MODULE_OPT_TYPE_UINT); - register_module_opt ("fuzzy_check", "min_width", MODULE_OPT_TYPE_UINT); - register_module_opt ("fuzzy_check", "min_symbols", MODULE_OPT_TYPE_UINT); - register_module_opt ("fuzzy_check", "timeout", MODULE_OPT_TYPE_TIME); return 0; } diff --git a/src/plugins/regexp.c b/src/plugins/regexp.c index df5e322f8..e9789b566 100644 --- a/src/plugins/regexp.c +++ b/src/plugins/regexp.c @@ -530,10 +530,6 @@ regexp_module_init (struct config_file *cfg, struct module_ctx **ctx) register_expression_function ("has_content_part_len", rspamd_has_content_part_len, NULL); (void)luaopen_regexp (cfg->lua_state); - register_module_opt ("regexp", "dynamic_rules", MODULE_OPT_TYPE_STRING); - register_module_opt ("regexp", "max_size", MODULE_OPT_TYPE_SIZE); - register_module_opt ("regexp", "max_threads", MODULE_OPT_TYPE_SIZE); - register_module_opt ("regexp", "/^\\S+$/", MODULE_OPT_TYPE_STRING); return 0; } diff --git a/src/plugins/spf.c b/src/plugins/spf.c index cf1fbb180..8b27174d9 100644 --- a/src/plugins/spf.c +++ b/src/plugins/spf.c @@ -87,12 +87,6 @@ spf_module_init (struct config_file *cfg, struct module_ctx **ctx) spf_module_ctx->spf_pool = memory_pool_new (memory_pool_get_size ()); *ctx = (struct module_ctx *)spf_module_ctx; - register_module_opt ("spf", "symbol_fail", MODULE_OPT_TYPE_STRING); - register_module_opt ("spf", "symbol_softfail", MODULE_OPT_TYPE_STRING); - register_module_opt ("spf", "symbol_allow", MODULE_OPT_TYPE_STRING); - register_module_opt ("spf", "spf_cache_size", MODULE_OPT_TYPE_UINT); - register_module_opt ("spf", "spf_cache_expire", MODULE_OPT_TYPE_TIME); - register_module_opt ("spf", "whitelist", MODULE_OPT_TYPE_MAP); return 0; } diff --git a/src/plugins/surbl.c b/src/plugins/surbl.c index 6430bf92f..d3622e80b 100644 --- a/src/plugins/surbl.c +++ b/src/plugins/surbl.c @@ -238,19 +238,6 @@ surbl_module_init (struct config_file *cfg, struct module_ctx **ctx) *ctx = (struct module_ctx *)surbl_module_ctx; register_protocol_command ("urls", urls_command_handler); - /* Register module options */ - register_module_opt ("surbl", "redirector", MODULE_OPT_TYPE_STRING); - register_module_opt ("surbl", "redirector_symbol", MODULE_OPT_TYPE_STRING); - register_module_opt ("surbl", "url_expire", MODULE_OPT_TYPE_TIME); - register_module_opt ("surbl", "redirector_connect_timeout", MODULE_OPT_TYPE_TIME); - register_module_opt ("surbl", "redirector_read_timeout", MODULE_OPT_TYPE_TIME); - register_module_opt ("surbl", "max_urls", MODULE_OPT_TYPE_UINT); - register_module_opt ("surbl", "redirector_hosts_map", MODULE_OPT_TYPE_STRING); - register_module_opt ("surbl", "exceptions", MODULE_OPT_TYPE_STRING); - register_module_opt ("surbl", "whitelist", MODULE_OPT_TYPE_STRING); - register_module_opt ("surbl", "/^suffix_.*$/", MODULE_OPT_TYPE_STRING); - register_module_opt ("surbl", "/^options_.*$/", MODULE_OPT_TYPE_STRING); - register_module_opt ("surbl", "/^bit_.*$/", MODULE_OPT_TYPE_STRING); return 0; } |