aboutsummaryrefslogtreecommitdiffstats
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
parent75fbba70411f8707e88f4d4544544b49d8a92f7a (diff)
downloadrspamd-c8b9de60705ee1fb330e5f7d932ae132d82fdf21.tar.gz
rspamd-c8b9de60705ee1fb330e5f7d932ae132d82fdf21.zip
Store RULESDIR in the code and UCL.
-rw-r--r--config.h.in1
-rw-r--r--src/libserver/cfg_utils.c22
-rw-r--r--src/lua/lua_common.c37
3 files changed, 47 insertions, 13 deletions
diff --git a/config.h.in b/config.h.in
index 38c159030..41be3c587 100644
--- a/config.h.in
+++ b/config.h.in
@@ -241,6 +241,7 @@
#define RSPAMD_DBDIR "${DBDIR}"
#define RSPAMD_EXAMPLESDIR "${EXAMPLESDIR}"
#define RSPAMD_PLUGINSDIR "${PLUGINSDIR}"
+#define RSPAMD_RULESDIR "${RULESDIR}"
#define RSPAMD_WWWDIR "${WWWDIR}"
#define RSPAMD_PREFIX "${CMAKE_INSTALL_PREFIX}"
diff --git a/src/libserver/cfg_utils.c b/src/libserver/cfg_utils.c
index 1fe7d1483..6afff0476 100644
--- a/src/libserver/cfg_utils.c
+++ b/src/libserver/cfg_utils.c
@@ -644,6 +644,7 @@ rspamd_include_map_handler (const guchar *data, gsize len,
#define RSPAMD_DBDIR_MACRO "DBDIR"
#define RSPAMD_LOGDIR_MACRO "LOGDIR"
#define RSPAMD_PLUGINSDIR_MACRO "PLUGINSDIR"
+#define RSPAMD_RULESDIR_MACRO "RULESDIR"
#define RSPAMD_WWWDIR_MACRO "WWWDIR"
#define RSPAMD_PREFIX_MACRO "PREFIX"
#define RSPAMD_VERSION_MACRO "VERSION"
@@ -655,21 +656,24 @@ rspamd_ucl_add_conf_variables (struct ucl_parser *parser, GHashTable *vars)
gpointer k, v;
ucl_parser_register_variable (parser,
- RSPAMD_CONFDIR_MACRO,
- RSPAMD_CONFDIR);
+ RSPAMD_CONFDIR_MACRO,
+ RSPAMD_CONFDIR);
ucl_parser_register_variable (parser, RSPAMD_RUNDIR_MACRO,
- RSPAMD_RUNDIR);
+ RSPAMD_RUNDIR);
ucl_parser_register_variable (parser, RSPAMD_DBDIR_MACRO,
- RSPAMD_DBDIR);
+ RSPAMD_DBDIR);
ucl_parser_register_variable (parser, RSPAMD_LOGDIR_MACRO,
- RSPAMD_LOGDIR);
+ RSPAMD_LOGDIR);
ucl_parser_register_variable (parser,
- RSPAMD_PLUGINSDIR_MACRO,
- RSPAMD_PLUGINSDIR);
+ RSPAMD_PLUGINSDIR_MACRO,
+ RSPAMD_PLUGINSDIR);
+ ucl_parser_register_variable (parser,
+ RSPAMD_RULESDIR_MACRO,
+ RSPAMD_RULESDIR);
ucl_parser_register_variable (parser, RSPAMD_WWWDIR_MACRO,
- RSPAMD_WWWDIR);
+ RSPAMD_WWWDIR);
ucl_parser_register_variable (parser, RSPAMD_PREFIX_MACRO,
- RSPAMD_PREFIX);
+ RSPAMD_PREFIX);
ucl_parser_register_variable (parser, RSPAMD_VERSION_MACRO, RVERSION);
if (vars != NULL) {
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 *