aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2017-03-02 14:50:50 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2017-03-02 14:50:50 +0000
commit147ead02c4e60cf54092fadc4da7d5834e7e88a4 (patch)
tree65a2f0df5d153aaa216de6260916352e64f1a912 /src/plugins
parentd27ecaeca539cbe4e91db3b61f3244e303561654 (diff)
downloadrspamd-147ead02c4e60cf54092fadc4da7d5834e7e88a4.tar.gz
rspamd-147ead02c4e60cf54092fadc4da7d5834e7e88a4.zip
[Fix] Fix lua exports from plugins during reload
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/dkim_check.c37
-rw-r--r--src/plugins/fuzzy_check.c41
-rw-r--r--src/plugins/surbl.c43
3 files changed, 60 insertions, 61 deletions
diff --git a/src/plugins/dkim_check.c b/src/plugins/dkim_check.c
index d36f13e39..11d6f2c9a 100644
--- a/src/plugins/dkim_check.c
+++ b/src/plugins/dkim_check.c
@@ -275,7 +275,18 @@ dkim_module_init (struct rspamd_config *cfg, struct module_ctx **ctx)
NULL,
0);
- /* Register global methods */
+ return 0;
+}
+
+gint
+dkim_module_config (struct rspamd_config *cfg)
+{
+ const ucl_object_t *value;
+ gint res = TRUE, cb_id = -1, check_id = -1;
+ guint cache_size;
+ gboolean got_trusted = FALSE;
+
+ /* Register global methods */
lua_getglobal (cfg->lua_state, "rspamd_plugins");
if (lua_type (cfg->lua_state, -1) == LUA_TTABLE) {
@@ -285,22 +296,16 @@ dkim_module_init (struct rspamd_config *cfg, struct module_ctx **ctx)
lua_pushstring (cfg->lua_state, "sign");
lua_pushcfunction (cfg->lua_state, lua_dkim_sign_handler);
lua_settable (cfg->lua_state, -3);
- /* Finish dkim key */
+ /* Finish dkim key */
lua_settable (cfg->lua_state, -3);
}
lua_pop (cfg->lua_state, 1); /* Remove global function */
- return 0;
-}
-
-gint
-dkim_module_config (struct rspamd_config *cfg)
-{
- const ucl_object_t *value;
- gint res = TRUE, cb_id = -1, check_id = -1;
- guint cache_size;
- gboolean got_trusted = FALSE;
+ dkim_module_ctx->dkim_sign_hash = rspamd_lru_hash_new (
+ 128,
+ g_free, /* Keys are just C-strings */
+ (GDestroyNotify)rspamd_dkim_sign_key_unref);
if (!rspamd_config_is_module_enabled (cfg, "dkim")) {
return TRUE;
@@ -308,8 +313,8 @@ dkim_module_config (struct rspamd_config *cfg)
dkim_module_ctx->whitelist_ip = radix_create_compressed ();
- if ((value =
- rspamd_config_get_module_opt (cfg, "options", "check_local")) != NULL) {
+ if ((value =
+ rspamd_config_get_module_opt (cfg, "options", "check_local")) != NULL) {
dkim_module_ctx->check_local = ucl_obj_toboolean (value);
}
else {
@@ -506,10 +511,6 @@ dkim_module_config (struct rspamd_config *cfg)
dkim_module_ctx->dkim_pool,
dkim_module_ctx->sign_condition_ref);
- dkim_module_ctx->dkim_sign_hash = rspamd_lru_hash_new (
- 128,
- g_free, /* Keys are just C-strings */
- (GDestroyNotify)rspamd_dkim_sign_key_unref);
check_id = rspamd_symbols_cache_add_symbol (cfg->cache,
"DKIM_SIGN",
0,
diff --git a/src/plugins/fuzzy_check.c b/src/plugins/fuzzy_check.c
index 38456f4ca..9d4e61121 100644
--- a/src/plugins/fuzzy_check.c
+++ b/src/plugins/fuzzy_check.c
@@ -649,8 +649,6 @@ fuzzy_parse_rule (struct rspamd_config *cfg, const ucl_object_t *obj,
gint
fuzzy_check_module_init (struct rspamd_config *cfg, struct module_ctx **ctx)
{
- lua_State *L = cfg->lua_state;
-
if (fuzzy_module_ctx == NULL) {
fuzzy_module_ctx = g_malloc0 (sizeof (struct fuzzy_ctx));
@@ -885,25 +883,6 @@ fuzzy_check_module_init (struct rspamd_config *cfg, struct module_ctx **ctx)
NULL,
0);
- /* Register global methods */
- lua_getglobal (L, "rspamd_plugins");
-
- if (lua_type (L, -1) == LUA_TTABLE) {
- lua_pushstring (L, "fuzzy_check");
- lua_createtable (L, 0, 2);
- /* Set methods */
- lua_pushstring (L, "unlearn");
- lua_pushcfunction (L, fuzzy_lua_unlearn_handler);
- lua_settable (L, -3);
- lua_pushstring (L, "learn");
- lua_pushcfunction (L, fuzzy_lua_learn_handler);
- lua_settable (L, -3);
- /* Finish fuzzy_check key */
- lua_settable (L, -3);
- }
-
- lua_pop (L, 1); /* Remove global function */
-
return 0;
}
@@ -913,6 +892,7 @@ fuzzy_check_module_config (struct rspamd_config *cfg)
const ucl_object_t *value, *cur, *elt;
ucl_object_iter_t it;
gint res = TRUE, cb_id, nrules = 0;
+ lua_State *L = cfg->lua_state;
if (!rspamd_config_is_module_enabled (cfg, "fuzzy_check")) {
return TRUE;
@@ -1049,6 +1029,25 @@ fuzzy_check_module_config (struct rspamd_config *cfg)
msg_info_config ("init internal fuzzy_check module, %d rules loaded",
nrules);
+ /* Register global methods */
+ lua_getglobal (L, "rspamd_plugins");
+
+ if (lua_type (L, -1) == LUA_TTABLE) {
+ lua_pushstring (L, "fuzzy_check");
+ lua_createtable (L, 0, 2);
+ /* Set methods */
+ lua_pushstring (L, "unlearn");
+ lua_pushcfunction (L, fuzzy_lua_unlearn_handler);
+ lua_settable (L, -3);
+ lua_pushstring (L, "learn");
+ lua_pushcfunction (L, fuzzy_lua_learn_handler);
+ lua_settable (L, -3);
+ /* Finish fuzzy_check key */
+ lua_settable (L, -3);
+ }
+
+ lua_pop (L, 1); /* Remove global function */
+
return res;
}
diff --git a/src/plugins/surbl.c b/src/plugins/surbl.c
index 91ff3ac9c..f079be445 100644
--- a/src/plugins/surbl.c
+++ b/src/plugins/surbl.c
@@ -277,8 +277,6 @@ fin_redirectors_list (struct map_cb_data *data)
gint
surbl_module_init (struct rspamd_config *cfg, struct module_ctx **ctx)
{
- lua_State *L;
-
surbl_module_ctx = g_malloc0 (sizeof (struct surbl_ctx));
surbl_module_ctx->use_redirector = 0;
@@ -453,26 +451,6 @@ surbl_module_init (struct rspamd_config *cfg, struct module_ctx **ctx)
NULL,
0);
- /* Register global methods */
- L = cfg->lua_state;
- lua_getglobal (L, "rspamd_plugins");
-
- if (lua_type (L, -1) == LUA_TTABLE) {
- lua_pushstring (L, "surbl");
- lua_createtable (L, 0, 2);
- /* Set methods */
- lua_pushstring (L, "register_redirect");
- lua_pushcfunction (L, surbl_register_redirect_handler);
- lua_settable (L, -3);
- lua_pushstring (L, "continue_process");
- lua_pushcfunction (L, surbl_continue_process_handler);
- lua_settable (L, -3);
- /* Finish fuzzy_check key */
- lua_settable (L, -3);
- }
-
- lua_pop (L, 1); /* Remove global function */
-
return 0;
}
@@ -726,6 +704,27 @@ surbl_module_config (struct rspamd_config *cfg)
const gchar *redir_val;
gint nrules = 0;
ucl_object_t *monitored_opts;
+ lua_State *L;
+
+ /* Register global methods */
+ L = cfg->lua_state;
+ lua_getglobal (L, "rspamd_plugins");
+
+ if (lua_type (L, -1) == LUA_TTABLE) {
+ lua_pushstring (L, "surbl");
+ lua_createtable (L, 0, 2);
+ /* Set methods */
+ lua_pushstring (L, "register_redirect");
+ lua_pushcfunction (L, surbl_register_redirect_handler);
+ lua_settable (L, -3);
+ lua_pushstring (L, "continue_process");
+ lua_pushcfunction (L, surbl_continue_process_handler);
+ lua_settable (L, -3);
+ /* Finish fuzzy_check key */
+ lua_settable (L, -3);
+ }
+
+ lua_pop (L, 1); /* Remove global function */
if (!rspamd_config_is_module_enabled (cfg, "surbl")) {
return TRUE;