diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2018-03-08 12:34:38 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2018-03-08 12:34:38 +0000 |
commit | 4b9b8cc4c72dc6e7e3db8b7ffadbb13a4e4f8d3f (patch) | |
tree | 31589f730ea02c83285a2cc996f0b32efb529766 /src | |
parent | 585af99ecefae1d219858b0d9b4ac8d268aa19c9 (diff) | |
download | rspamd-4b9b8cc4c72dc6e7e3db8b7ffadbb13a4e4f8d3f.tar.gz rspamd-4b9b8cc4c72dc6e7e3db8b7ffadbb13a4e4f8d3f.zip |
[Feature] Add torch conditional to configuration
Diffstat (limited to 'src')
-rw-r--r-- | src/libserver/cfg_utils.c | 50 |
1 files changed, 43 insertions, 7 deletions
diff --git a/src/libserver/cfg_utils.c b/src/libserver/cfg_utils.c index 5d0d94096..86009712e 100644 --- a/src/libserver/cfg_utils.c +++ b/src/libserver/cfg_utils.c @@ -1118,6 +1118,14 @@ rspamd_ucl_add_conf_variables (struct ucl_parser *parser, GHashTable *vars) ucl_parser_register_variable (parser, RSPAMD_BRANCH_VERSION_MACRO, RSPAMD_VERSION_BRANCH); +#if defined(WITH_TORCH) && defined(WITH_LUAJIT) && defined(__x86_64__) + ucl_parser_register_variable (parser, "HAS_TORCH", + "yes"); +#else + ucl_parser_register_variable (parser, "HAS_TORCH", + "no"); +#endif + if (vars != NULL) { g_hash_table_iter_init (&it, vars); @@ -1619,14 +1627,42 @@ rspamd_config_is_module_enabled (struct rspamd_config *cfg, else { enabled = ucl_object_lookup (conf, "enabled"); - if (enabled && ucl_object_type (enabled) == UCL_BOOLEAN) { - if (!ucl_object_toboolean (enabled)) { - rspamd_plugins_table_push_elt (L, - "disabled_explicitly", module_name); + if (enabled) { + if (ucl_object_type (enabled) == UCL_BOOLEAN) { + if (!ucl_object_toboolean (enabled)) { + rspamd_plugins_table_push_elt (L, + "disabled_explicitly", module_name); - msg_info_config ("%s module %s is disabled in the configuration", - is_c ? "internal" : "lua", module_name); - return FALSE; + msg_info_config ( + "%s module %s is disabled in the configuration", + is_c ? "internal" : "lua", module_name); + return FALSE; + } + } + else if (ucl_object_type (enabled) == UCL_STRING) { + gint ret; + + ret = rspamd_config_parse_flag (ucl_object_tostring (enabled), 0); + + if (ret == 0) { + rspamd_plugins_table_push_elt (L, + "disabled_explicitly", module_name); + + msg_info_config ( + "%s module %s is disabled in the configuration", + is_c ? "internal" : "lua", module_name); + return FALSE; + } + else if (ret == -1) { + rspamd_plugins_table_push_elt (L, + "disabled_failed", module_name); + + msg_info_config ( + "%s module %s has wrong enabled flag (%s) in the configuration", + is_c ? "internal" : "lua", module_name, + ucl_object_tostring (enabled)); + return FALSE; + } } } } |