]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
[Minor] Support local confdir in lua
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Sat, 6 Oct 2018 08:23:03 +0000 (09:23 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Sat, 6 Oct 2018 08:23:03 +0000 (09:23 +0100)
src/lua/lua_common.c
src/lua/lua_common.h
src/lua/lua_config.c

index ac7a393b8779554d460307e8a4d2290d5c384a69..ab344e4849e7a5a2e753a11faf7349fdf27775c5 100644 (file)
@@ -580,10 +580,15 @@ rspamd_lua_set_globals (struct rspamd_config *cfg, lua_State *L,
        /* Set known paths as rspamd_paths global */
        lua_getglobal (L, "rspamd_paths");
        if (lua_isnil (L, -1)) {
-               const gchar *confdir = RSPAMD_CONFDIR, *rundir = RSPAMD_RUNDIR,
-                               *dbdir = RSPAMD_DBDIR, *logdir = RSPAMD_LOGDIR,
-                               *wwwdir = RSPAMD_WWWDIR, *pluginsdir = RSPAMD_PLUGINSDIR,
-                               *rulesdir = RSPAMD_RULESDIR, *lualibdir = RSPAMD_LUALIBDIR,
+               const gchar *confdir = RSPAMD_CONFDIR,
+                               *local_confdir = RSPAMD_LOCAL_CONFDIR,
+                               *rundir = RSPAMD_RUNDIR,
+                               *dbdir = RSPAMD_DBDIR,
+                               *logdir = RSPAMD_LOGDIR,
+                               *wwwdir = RSPAMD_WWWDIR,
+                               *pluginsdir = RSPAMD_PLUGINSDIR,
+                               *rulesdir = RSPAMD_RULESDIR,
+                               *lualibdir = RSPAMD_LUALIBDIR,
                                *prefix = RSPAMD_PREFIX;
                const gchar *t;
 
@@ -628,6 +633,11 @@ rspamd_lua_set_globals (struct rspamd_config *cfg, lua_State *L,
                        confdir = t;
                }
 
+               t = getenv ("LOCAL_CONFDIR");
+               if (t) {
+                       local_confdir = t;
+               }
+
 
                if (vars) {
                        t = g_hash_table_lookup (vars, "PLUGINSDIR");
@@ -660,6 +670,11 @@ rspamd_lua_set_globals (struct rspamd_config *cfg, lua_State *L,
                                confdir = t;
                        }
 
+                       t = g_hash_table_lookup (vars, "LOCAL_CONFDIR");
+                       if (t) {
+                               local_confdir = t;
+                       }
+
                        t = g_hash_table_lookup (vars, "DBDIR");
                        if (t) {
                                dbdir = t;
@@ -674,6 +689,7 @@ rspamd_lua_set_globals (struct rspamd_config *cfg, lua_State *L,
                lua_createtable (L, 0, 9);
 
                rspamd_lua_table_set (L, RSPAMD_CONFDIR_INDEX, confdir);
+               rspamd_lua_table_set (L, RSPAMD_LOCAL_CONFDIR_INDEX, local_confdir);
                rspamd_lua_table_set (L, RSPAMD_RUNDIR_INDEX, rundir);
                rspamd_lua_table_set (L, RSPAMD_DBDIR_INDEX, dbdir);
                rspamd_lua_table_set (L, RSPAMD_LOGDIR_INDEX, logdir);
index af0b5f824704d43ad777f157d822ffebab37e648..fccbf51150538d328437245b4ff8c91196fa5c86 100644 (file)
@@ -425,6 +425,7 @@ gboolean rspamd_lua_require_function (lua_State *L, const gchar *modname,
 
 /* Paths defs */
 #define RSPAMD_CONFDIR_INDEX "CONFDIR"
+#define RSPAMD_LOCAL_CONFDIR_INDEX "LOCAL_CONFDIR"
 #define RSPAMD_RUNDIR_INDEX "RUNDIR"
 #define RSPAMD_DBDIR_INDEX "DBDIR"
 #define RSPAMD_LOGDIR_INDEX "LOGDIR"
index f15c04e467422c710850fc2566951262e32974a3..32796fb01a73eb25926fcd9d72f79b69a4c4fba9 100644 (file)
@@ -3453,6 +3453,7 @@ lua_config_load_ucl (lua_State *L)
 
                if (lua_istable (L, -1)) {
                        LUA_TABLE_TO_HASH(paths, RSPAMD_CONFDIR_INDEX);
+                       LUA_TABLE_TO_HASH(paths, RSPAMD_LOCAL_CONFDIR_INDEX);
                        LUA_TABLE_TO_HASH(paths, RSPAMD_RUNDIR_INDEX);
                        LUA_TABLE_TO_HASH(paths, RSPAMD_DBDIR_INDEX);
                        LUA_TABLE_TO_HASH(paths, RSPAMD_LOGDIR_INDEX);