summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2018-04-04 13:03:21 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2018-04-04 13:03:21 +0100
commit846c63f269f2bd333a24730b3cb92dbb37960328 (patch)
tree4720b4a6410050b0184b6ad382c087551dddedbb
parent73c88c4437fb4f15cce9c0b44f01194e9c42bea8 (diff)
downloadrspamd-846c63f269f2bd333a24730b3cb92dbb37960328.tar.gz
rspamd-846c63f269f2bd333a24730b3cb92dbb37960328.zip
[Feature] Allow to set lua_cpath from options
-rw-r--r--src/lua/lua_common.c34
1 files changed, 27 insertions, 7 deletions
diff --git a/src/lua/lua_common.c b/src/lua/lua_common.c
index a1d3f27bc..183fa0503 100644
--- a/src/lua/lua_common.c
+++ b/src/lua/lua_common.c
@@ -225,7 +225,7 @@ void
rspamd_lua_set_path (lua_State *L, const ucl_object_t *cfg_obj, GHashTable *vars)
{
const gchar *old_path, *additional_path = NULL;
- const ucl_object_t *opts;
+ const ucl_object_t *opts = NULL;
const gchar *pluginsdir = RSPAMD_PLUGINSDIR,
*rulesdir = RSPAMD_RULESDIR,
*lualibdir = RSPAMD_LUALIBDIR,
@@ -341,13 +341,33 @@ rspamd_lua_set_path (lua_State *L, const ucl_object_t *cfg_obj, GHashTable *vars
lua_getfield (L, -1, "cpath");
old_path = luaL_checkstring (L, -1);
+ additional_path = NULL;
- rspamd_snprintf (path_buf, sizeof (path_buf),
- "%s/?%s;"
- "%s",
- libdir,
- OS_SO_SUFFIX,
- old_path);
+ if (opts != NULL) {
+ opts = ucl_object_lookup (opts, "lua_cpath");
+ if (opts != NULL && ucl_object_type (opts) == UCL_STRING) {
+ additional_path = ucl_object_tostring (opts);
+ }
+ }
+
+ if (additional_path) {
+ rspamd_snprintf (path_buf, sizeof (path_buf),
+ "%s/?%s;"
+ "%s;"
+ "%s",
+ libdir,
+ OS_SO_SUFFIX,
+ additional_path,
+ old_path);
+ }
+ else {
+ rspamd_snprintf (path_buf, sizeof (path_buf),
+ "%s/?%s;"
+ "%s",
+ libdir,
+ OS_SO_SUFFIX,
+ old_path);
+ }
lua_pop (L, 1);
lua_pushstring (L, path_buf);
lua_setfield (L, -2, "cpath");