aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2013-11-19 16:17:13 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2013-11-19 16:17:13 +0000
commit4abb85d399ff5d9ae83dc76a9cfdb416ec13137a (patch)
treeba4f28252e9bd539bc0e963f44235276c170fb8b /src
parentc87580806c6e941fe34be0751f928325271ee7eb (diff)
downloadrspamd-4abb85d399ff5d9ae83dc76a9cfdb416ec13137a.tar.gz
rspamd-4abb85d399ff5d9ae83dc76a9cfdb416ec13137a.zip
Rework build and install paths.
Diffstat (limited to 'src')
-rw-r--r--src/lua/lua_cfg_file.c9
-rw-r--r--src/main.h2
-rw-r--r--src/util.c87
-rw-r--r--src/util.h7
4 files changed, 76 insertions, 29 deletions
diff --git a/src/lua/lua_cfg_file.c b/src/lua/lua_cfg_file.c
index 47fbd14bb..6fe773987 100644
--- a/src/lua/lua_cfg_file.c
+++ b/src/lua/lua_cfg_file.c
@@ -250,9 +250,12 @@ lua_check_condition (struct config_file *cfg, const gchar *condition)
/* Rspamd paths */
lua_newtable (L);
- lua_set_table_index (L, "etcdir", ETC_PREFIX);
- lua_set_table_index (L, "prefix", CMAKE_PREFIX);
- lua_set_table_index (L, "localstatesdir", LOCALSTATES_PREFIX);
+ lua_set_table_index (L, "confdir", RSPAMD_CONFDIR);
+ lua_set_table_index (L, "rundir", RSPAMD_RUNDIR);
+ lua_set_table_index (L, "dbdir", RSPAMD_DBDIR);
+ lua_set_table_index (L, "logdir", RSPAMD_LOGDIR);
+ lua_set_table_index (L, "pluginsdir", RSPAMD_PLUGINSDIR);
+ lua_set_table_index (L, "prefix", RSPAMD_PREFIX);
lua_setglobal (L, "rspamd_paths");
/* Make fake string */
diff --git a/src/main.h b/src/main.h
index f169b4f5d..29c8a9f0c 100644
--- a/src/main.h
+++ b/src/main.h
@@ -22,7 +22,7 @@
#include "roll_history.h"
/* Default values */
-#define FIXED_CONFIG_FILE ETC_PREFIX "/rspamd.conf"
+#define FIXED_CONFIG_FILE RSPAMD_CONFDIR "/rspamd.conf"
/* Time in seconds to exit for old worker */
#define SOFT_SHUTDOWN_TIME 10
/* Default metric name */
diff --git a/src/util.c b/src/util.c
index 1e0378d2a..7383f23d6 100644
--- a/src/util.c
+++ b/src/util.c
@@ -2387,14 +2387,20 @@ restart:
/*
* Variables:
* $CONFDIR - configuration directory
- * $LOCALSTATESDIR - local states directory
- * $INSTALLPREFIX - installation prefix
+ * $RUNDIR - local states directory
+ * $DBDIR - databases dir
+ * $LOGDIR - logs dir
+ * $PLUGINSDIR - pluggins dir
+ * $PREFIX - installation prefix
* $VERSION - rspamd version
*/
#define RSPAMD_CONFDIR_MACRO "CONFDIR"
-#define RSPAMD_LOCALSTATESDIR_MACRO "LOCALSTATESDIR"
-#define RSPAMD_INSTALLPREFIX_MACRO "INSTALLPREFIX"
+#define RSPAMD_RUNDIR_MACRO "RUNDIR"
+#define RSPAMD_DBDIR_MACRO "DBDIR"
+#define RSPAMD_LOGDIR_MACRO "LOGDIR"
+#define RSPAMD_PLUGINSDIR_MACRO "PLUGINSDIR"
+#define RSPAMD_PREFIX_MACRO "PREFIX"
#define RSPAMD_VERSION_MACRO "VERSION"
static const gchar *
@@ -2403,20 +2409,36 @@ rspamd_check_path_variable (const gchar *in, gsize *len)
switch (*in) {
case 'C':
if (strncmp (in, RSPAMD_CONFDIR_MACRO, sizeof (RSPAMD_CONFDIR_MACRO) - 1) == 0) {
- *len += sizeof (ETC_PREFIX) - 1;
+ *len += sizeof (RSPAMD_CONFDIR) - 1;
in += sizeof (RSPAMD_CONFDIR_MACRO) - 1;
}
break;
+ case 'R':
+ if (strncmp (in, RSPAMD_RUNDIR_MACRO, sizeof (RSPAMD_RUNDIR_MACRO) - 1) == 0) {
+ *len += sizeof (RSPAMD_RUNDIR) - 1;
+ in += sizeof (RSPAMD_RUNDIR_MACRO) - 1;
+ }
+ break;
+ case 'D':
+ if (strncmp (in, RSPAMD_DBDIR_MACRO, sizeof (RSPAMD_DBDIR_MACRO) - 1) == 0) {
+ *len += sizeof (RSPAMD_DBDIR) - 1;
+ in += sizeof (RSPAMD_DBDIR_MACRO) - 1;
+ }
+ break;
case 'L':
- if (strncmp (in, RSPAMD_LOCALSTATESDIR_MACRO, sizeof (RSPAMD_LOCALSTATESDIR_MACRO) - 1) == 0) {
- *len += sizeof (LOCALSTATES_PREFIX) - 1;
- in += sizeof (RSPAMD_LOCALSTATESDIR_MACRO) - 1;
+ if (strncmp (in, RSPAMD_LOGDIR_MACRO, sizeof (RSPAMD_LOGDIR_MACRO) - 1) == 0) {
+ *len += sizeof (RSPAMD_LOGDIR) - 1;
+ in += sizeof (RSPAMD_LOGDIR_MACRO) - 1;
}
break;
- case 'I':
- if (strncmp (in, RSPAMD_INSTALLPREFIX_MACRO, sizeof (RSPAMD_INSTALLPREFIX_MACRO) - 1) == 0) {
- *len += sizeof (CMAKE_PREFIX) - 1;
- in += sizeof (RSPAMD_INSTALLPREFIX_MACRO) - 1;
+ case 'P':
+ if (strncmp (in, RSPAMD_PREFIX_MACRO, sizeof (RSPAMD_PREFIX_MACRO) - 1) == 0) {
+ *len += sizeof (RSPAMD_PREFIX) - 1;
+ in += sizeof (RSPAMD_PREFIX_MACRO) - 1;
+ }
+ else if (strncmp (in, RSPAMD_PLUGINSDIR_MACRO, sizeof (RSPAMD_PLUGINSDIR_MACRO) - 1) == 0) {
+ *len += sizeof (RSPAMD_PLUGINSDIR) - 1;
+ in += sizeof (RSPAMD_PLUGINSDIR_MACRO) - 1;
}
break;
case 'V':
@@ -2442,23 +2464,42 @@ rspamd_expand_path_variable (const gchar *in, gchar **dest)
switch (*v) {
case 'C':
if (strncmp (v, RSPAMD_CONFDIR_MACRO, sizeof (RSPAMD_CONFDIR_MACRO) - 1) == 0) {
- memcpy (d, ETC_PREFIX, sizeof (ETC_PREFIX) - 1);
- d += sizeof (ETC_PREFIX) - 1;
+ memcpy (d, RSPAMD_CONFDIR, sizeof (RSPAMD_CONFDIR) - 1);
+ d += sizeof (RSPAMD_CONFDIR) - 1;
in += sizeof (RSPAMD_CONFDIR_MACRO) - 1;
}
break;
+ case 'R':
+ if (strncmp (v, RSPAMD_RUNDIR_MACRO, sizeof (RSPAMD_RUNDIR_MACRO) - 1) == 0) {
+ memcpy (d, RSPAMD_RUNDIR, sizeof (RSPAMD_RUNDIR) - 1);
+ d += sizeof (RSPAMD_RUNDIR) - 1;
+ in += sizeof (RSPAMD_RUNDIR_MACRO) - 1;
+ }
+ break;
+ case 'D':
+ if (strncmp (v, RSPAMD_DBDIR_MACRO, sizeof (RSPAMD_DBDIR_MACRO) - 1) == 0) {
+ memcpy (d, RSPAMD_DBDIR, sizeof (RSPAMD_DBDIR) - 1);
+ d += sizeof (RSPAMD_DBDIR) - 1;
+ in += sizeof (RSPAMD_DBDIR_MACRO) - 1;
+ }
+ break;
case 'L':
- if (strncmp (v, RSPAMD_LOCALSTATESDIR_MACRO, sizeof (RSPAMD_LOCALSTATESDIR_MACRO) - 1) == 0) {
- memcpy (d, LOCALSTATES_PREFIX, sizeof (LOCALSTATES_PREFIX) - 1);
- d += sizeof (LOCALSTATES_PREFIX) - 1;
- in += sizeof (RSPAMD_LOCALSTATESDIR_MACRO) - 1;
+ if (strncmp (v, RSPAMD_LOGDIR_MACRO, sizeof (RSPAMD_LOGDIR_MACRO) - 1) == 0) {
+ memcpy (d, RSPAMD_LOGDIR, sizeof (RSPAMD_LOGDIR) - 1);
+ d += sizeof (RSPAMD_LOGDIR) - 1;
+ in += sizeof (RSPAMD_LOGDIR_MACRO) - 1;
}
break;
- case 'I':
- if (strncmp (v, RSPAMD_INSTALLPREFIX_MACRO, sizeof (RSPAMD_INSTALLPREFIX_MACRO) - 1) == 0) {
- memcpy (d, CMAKE_PREFIX, sizeof (CMAKE_PREFIX) - 1);
- d += sizeof (CMAKE_PREFIX) - 1;
- in += sizeof (RSPAMD_INSTALLPREFIX_MACRO) - 1;
+ case 'P':
+ if (strncmp (v, RSPAMD_PREFIX_MACRO, sizeof (RSPAMD_PREFIX_MACRO) - 1) == 0) {
+ memcpy (d, RSPAMD_PREFIX, sizeof (RSPAMD_PREFIX) - 1);
+ d += sizeof (RSPAMD_PREFIX) - 1;
+ in += sizeof (RSPAMD_PREFIX_MACRO) - 1;
+ }
+ else if (strncmp (v, RSPAMD_PLUGINSDIR_MACRO, sizeof (RSPAMD_PLUGINSDIR_MACRO) - 1) == 0) {
+ memcpy (d, RSPAMD_PLUGINSDIR, sizeof (RSPAMD_PLUGINSDIR) - 1);
+ d += sizeof (RSPAMD_PLUGINSDIR) - 1;
+ in += sizeof (RSPAMD_PLUGINSDIR_MACRO) - 1;
}
break;
case 'V':
diff --git a/src/util.h b/src/util.h
index 9278f41a3..bda871c22 100644
--- a/src/util.h
+++ b/src/util.h
@@ -442,8 +442,11 @@ gint rspamd_read_passphrase (gchar *buf, gint size, gint rwflag, gpointer key);
/**
* Expand path that may contain configuration variables:
* $CONFDIR - configuration directory
- * $LOCALSTATESDIR - local states directory
- * $INSTALLPREFIX - installation prefix
+ * $RUNDIR - local states directory
+ * $DBDIR - databases dir
+ * $LOGDIR - logs dir
+ * $PLUGINSDIR - plugins dir
+ * $PREFIX - installation prefix
* $VERSION - rspamd version
* @param pool to use
* @param path path to expand