aboutsummaryrefslogtreecommitdiffstats
path: root/src/lua
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2015-08-07 14:39:45 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2015-08-07 14:39:45 +0100
commitc8b9de60705ee1fb330e5f7d932ae132d82fdf21 (patch)
tree781f847d8ca20d6b7d9d7c361a00afcf1dd10a4d /src/lua
parent75fbba70411f8707e88f4d4544544b49d8a92f7a (diff)
downloadrspamd-c8b9de60705ee1fb330e5f7d932ae132d82fdf21.tar.gz
rspamd-c8b9de60705ee1fb330e5f7d932ae132d82fdf21.zip
Store RULESDIR in the code and UCL.
Diffstat (limited to 'src/lua')
-rw-r--r--src/lua/lua_common.c37
1 files changed, 33 insertions, 4 deletions
diff --git a/src/lua/lua_common.c b/src/lua/lua_common.c
index 2f1f645ff..6526b3b53 100644
--- a/src/lua/lua_common.c
+++ b/src/lua/lua_common.c
@@ -165,6 +165,16 @@ lua_add_actions_global (lua_State *L)
lua_setglobal (L, "rspamd_actions");
}
+#define RSPAMD_CONFDIR_INDEX "CONFDIR"
+#define RSPAMD_RUNDIR_INDEX "RUNDIR"
+#define RSPAMD_DBDIR_INDEX "DBDIR"
+#define RSPAMD_LOGDIR_INDEX "LOGDIR"
+#define RSPAMD_PLUGINSDIR_INDEX "PLUGINSDIR"
+#define RSPAMD_RULESDIR_INDEX "RULESDIR"
+#define RSPAMD_WWWDIR_INDEX "WWWDIR"
+#define RSPAMD_PREFIX_INDEX "PREFIX"
+#define RSPAMD_VERSION_INDEX "VERSION"
+
void
rspamd_lua_set_path (lua_State *L, struct rspamd_config *cfg)
{
@@ -191,18 +201,37 @@ rspamd_lua_set_path (lua_State *L, struct rspamd_config *cfg)
}
if (additional_path) {
- rspamd_snprintf (path_buf, sizeof (path_buf), "%s/lua/?.lua;%s/lua/?.lua;%s;%s",
- RSPAMD_PLUGINSDIR, RSPAMD_CONFDIR, additional_path, old_path);
+ rspamd_snprintf (path_buf, sizeof (path_buf),
+ "%s/lua/?.lua;%s/lua/?.lua;%s;%s;%s",
+ RSPAMD_PLUGINSDIR, RSPAMD_CONFDIR, RSPAMD_RULESDIR,
+ additional_path, old_path);
}
else {
- rspamd_snprintf (path_buf, sizeof (path_buf), "%s/lua/?.lua;%s/lua/?.lua;%s",
- RSPAMD_PLUGINSDIR, RSPAMD_CONFDIR, old_path);
+ rspamd_snprintf (path_buf, sizeof (path_buf),
+ "%s/lua/?.lua;%s/lua/?.lua;%s;%s",
+ RSPAMD_PLUGINSDIR, RSPAMD_CONFDIR, RSPAMD_RULESDIR,
+ old_path);
}
lua_pop (L, 1);
lua_pushstring (L, path_buf);
lua_setfield (L, -2, "path");
lua_pop (L, 1);
+
+ /* Set known paths as rspamd_paths global */
+ lua_getglobal (L, "rspamd_paths");
+ if (lua_isnil (L, -1)) {
+ lua_newtable (L);
+ rspamd_lua_table_set (L, RSPAMD_CONFDIR_INDEX, RSPAMD_CONFDIR);
+ rspamd_lua_table_set (L, RSPAMD_RUNDIR_INDEX, RSPAMD_RUNDIR);
+ rspamd_lua_table_set (L, RSPAMD_DBDIR_INDEX, RSPAMD_DBDIR);
+ rspamd_lua_table_set (L, RSPAMD_LOGDIR_INDEX, RSPAMD_LOGDIR);
+ rspamd_lua_table_set (L, RSPAMD_WWWDIR_INDEX, RSPAMD_WWWDIR);
+ rspamd_lua_table_set (L, RSPAMD_PLUGINSDIR_INDEX, RSPAMD_PLUGINSDIR);
+ rspamd_lua_table_set (L, RSPAMD_RULESDIR_INDEX, RSPAMD_RULESDIR);
+ rspamd_lua_table_set (L, RSPAMD_PREFIX_INDEX, RSPAMD_PREFIX);
+ lua_setglobal (L, "rspamd_paths");
+ }
}
lua_State *