diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2019-04-16 13:37:32 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2019-04-16 13:37:32 +0100 |
commit | 04b317274d893f3f0efbc23ed8481534c0a36014 (patch) | |
tree | 4bb50c62d7c85298666a458ce9890b3de36e30ab | |
parent | 51746c82755e2d180ab9b6bcce38e977032ec737 (diff) | |
download | rspamd-04b317274d893f3f0efbc23ed8481534c0a36014.tar.gz rspamd-04b317274d893f3f0efbc23ed8481534c0a36014.zip |
[Minor] Allow to add additional paths to plugins
Issue: #2848
-rw-r--r-- | src/libserver/cfg_rcl.c | 25 | ||||
-rw-r--r-- | src/libserver/cfg_rcl.h | 1 | ||||
-rw-r--r-- | src/libstat/backends/sqlite3_backend.c | 2 | ||||
-rw-r--r-- | src/rspamadm/confighelp.c | 2 |
4 files changed, 25 insertions, 5 deletions
diff --git a/src/libserver/cfg_rcl.c b/src/libserver/cfg_rcl.c index a9f957183..20bf7a7c6 100644 --- a/src/libserver/cfg_rcl.c +++ b/src/libserver/cfg_rcl.c @@ -845,6 +845,7 @@ rspamd_rcl_lua_handler (rspamd_mempool_t *pool, const ucl_object_t *obj, gboolean rspamd_rcl_add_lua_plugins_path (struct rspamd_config *cfg, const gchar *path, + gboolean main_path, GHashTable *modules_seen, GError **err) { @@ -856,7 +857,7 @@ rspamd_rcl_add_lua_plugins_path (struct rspamd_config *cfg, if (stat (path, &st) == -1) { - if (errno != ENOENT) { + if (errno != ENOENT || main_path) { g_set_error (err, CFG_RCL_ERROR, errno, @@ -866,7 +867,7 @@ rspamd_rcl_add_lua_plugins_path (struct rspamd_config *cfg, return FALSE; } else { - msg_info_config ("plugins path %s is absent, skip it", path); + msg_debug_config ("optional plugins path %s is absent, skip it", path); return TRUE; } @@ -986,6 +987,7 @@ rspamd_rcl_modules_handler (rspamd_mempool_t *pool, const ucl_object_t *obj, if (ucl_object_tostring_safe (cur, &data)) { if (!rspamd_rcl_add_lua_plugins_path (cfg, rspamd_mempool_strdup (cfg->cfg_pool, data), + TRUE, mods_seen, err)) { return FALSE; @@ -1008,6 +1010,23 @@ rspamd_rcl_modules_handler (rspamd_mempool_t *pool, const ucl_object_t *obj, if (ucl_object_tostring_safe (cur, &data)) { if (!rspamd_rcl_add_lua_plugins_path (cfg, rspamd_mempool_strdup (cfg->cfg_pool, data), + FALSE, + mods_seen, + err)) { + return FALSE; + } + } + } + } + + val = ucl_object_lookup (obj, "try_path"); + + if (val) { + LL_FOREACH (val, cur) { + if (ucl_object_tostring_safe (cur, &data)) { + if (!rspamd_rcl_add_lua_plugins_path (cfg, + rspamd_mempool_strdup (cfg->cfg_pool, data), + FALSE, mods_seen, err)) { return FALSE; @@ -1018,7 +1037,7 @@ rspamd_rcl_modules_handler (rspamd_mempool_t *pool, const ucl_object_t *obj, } else if (ucl_object_tostring_safe (obj, &data)) { if (!rspamd_rcl_add_lua_plugins_path (cfg, - rspamd_mempool_strdup (cfg->cfg_pool, data), NULL, err)) { + rspamd_mempool_strdup (cfg->cfg_pool, data), TRUE, NULL, err)) { return FALSE; } } diff --git a/src/libserver/cfg_rcl.h b/src/libserver/cfg_rcl.h index 12a89a673..8d957a402 100644 --- a/src/libserver/cfg_rcl.h +++ b/src/libserver/cfg_rcl.h @@ -445,6 +445,7 @@ ucl_object_t *rspamd_rcl_add_doc_by_example (struct rspamd_config *cfg, */ gboolean rspamd_rcl_add_lua_plugins_path (struct rspamd_config *cfg, const gchar *path, + gboolean main_path, GHashTable *modules_seen, GError **err); diff --git a/src/libstat/backends/sqlite3_backend.c b/src/libstat/backends/sqlite3_backend.c index 5b5a6b896..9904e469b 100644 --- a/src/libstat/backends/sqlite3_backend.c +++ b/src/libstat/backends/sqlite3_backend.c @@ -554,7 +554,7 @@ rspamd_sqlite3_init (struct rspamd_stat_ctx *ctx, if ((bk = rspamd_sqlite3_opendb (cfg->cfg_pool, stf, filename, stf->opts, TRUE, &err)) == NULL) { - msg_err_config ("cannot open sqlite3 db: %e", err); + msg_err_config ("cannot open sqlite3 db %s: %e", filename, err); g_error_free (err); return NULL; } diff --git a/src/rspamadm/confighelp.c b/src/rspamadm/confighelp.c index a414545db..a5b67a400 100644 --- a/src/rspamadm/confighelp.c +++ b/src/rspamadm/confighelp.c @@ -234,7 +234,7 @@ rspamadm_confighelp (gint argc, gchar **argv, const struct rspamadm_command *cmd rspamd_rcl_config_init (cfg, NULL); lua_pushboolean (cfg->lua_state, true); lua_setglobal (cfg->lua_state, "confighelp"); - rspamd_rcl_add_lua_plugins_path (cfg, plugins_path, NULL, NULL); + rspamd_rcl_add_lua_plugins_path (cfg, plugins_path, FALSE, NULL, NULL); /* Init modules to get documentation strings */ i = 0; |