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 /src/libserver/cfg_rcl.c | |
parent | 51746c82755e2d180ab9b6bcce38e977032ec737 (diff) | |
download | rspamd-04b317274d893f3f0efbc23ed8481534c0a36014.tar.gz rspamd-04b317274d893f3f0efbc23ed8481534c0a36014.zip |
[Minor] Allow to add additional paths to plugins
Issue: #2848
Diffstat (limited to 'src/libserver/cfg_rcl.c')
-rw-r--r-- | src/libserver/cfg_rcl.c | 25 |
1 files changed, 22 insertions, 3 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; } } |