From: Vsevolod Stakhov Date: Tue, 19 Nov 2013 16:17:13 +0000 (+0000) Subject: Rework build and install paths. X-Git-Tag: 0.6.0~47 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=4abb85d399ff5d9ae83dc76a9cfdb416ec13137a;p=rspamd.git Rework build and install paths. --- diff --git a/CMakeLists.txt b/CMakeLists.txt index e558c93e5..fda25e115 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -43,6 +43,42 @@ OPTION(FORCE_GMIME24 "Link with gmime2.4 [default: OFF]" # Build optimized code for following CPU (default i386) #SET(CPU_TUNE "i686") +# Now CMAKE_INSTALL_PREFIX is a base prefix for everything +# CONFDIR - for configuration +# MANDIR - for manual pages +# RUNDIR - for runtime files +# DBDIR - for static files +# LOGDIR - for log files +# EXAMPLESDIR - for examples files + +IF(NOT CONFDIR) + SET(CONFDIR "${CMAKE_INSTALL_PREFIX}/etc/rspamd") +ENDIF(NOT CONFDIR) + +IF(NOT MANDIR) + SET(MANDIR "${CMAKE_INSTALL_PREFIX}/share/man") +ENDIF(NOT MANDIR) + +IF(NOT RUNDIR) + SET(RUNDIR "${CMAKE_INSTALL_PREFIX}/var/run/rspamd") +ENDIF(NOT RUNDIR) + +IF(NOT DBDIR) + SET(DBDIR "${CMAKE_INSTALL_PREFIX}/var/lib/rspamd") +ENDIF(NOT DBDIR) + +IF(NOT LOGDIR) + SET(LOGDIR "${CMAKE_INSTALL_PREFIX}/var/log/rspamd") +ENDIF(NOT LOGDIR) + +IF(NOT EXAMPLESDIR) + SET(EXAMPLESDIR "${CMAKE_INSTALL_PREFIX}/share/examples/rspamd") +ENDIF(NOT EXAMPLESDIR) + +IF(NOT PLUGINSDIR) + SET(PLUGINSDIR "${CMAKE_INSTALL_PREFIX}/share/rspamd") +ENDIF(NOT PLUGINSDIR) + ############################# INCLUDE SECTION ############################################# INCLUDE(CheckIncludeFiles) @@ -217,31 +253,6 @@ IF(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD") IF(ENABLE_REDIRECTOR MATCHES "ON") CONFIGURE_FILE(freebsd/redirector.sh.in freebsd/redirector @ONLY) ENDIF(ENABLE_REDIRECTOR MATCHES "ON") - IF(CMAKE_INSTALL_PREFIX) - IF(NOT ETC_PREFIX) - SET(ETC_PREFIX "${CMAKE_INSTALL_PREFIX}/etc") - ENDIF(NOT ETC_PREFIX) - IF(NOT MAN_PREFIX) - SET(MAN_PREFIX "${CMAKE_INSTALL_PREFIX}/man") - ENDIF(NOT MAN_PREFIX) - IF(NOT LOCALSTATES_PREFIX) - SET(LOCALSTATES_PREFIX "${CMAKE_INSTALL_PREFIX}/var/run/rspamd") - ENDIF(NOT LOCALSTATES_PREFIX) - SET(PREFIX "${CMAKE_INSTALL_PREFIX}") - ELSE(CMAKE_INSTALL_PREFIX) - IF(NOT ETC_PREFIX) - SET(ETC_PREFIX /usr/local/etc) - ENDIF(NOT ETC_PREFIX) - IF(NOT MAN_PREFIX) - SET(MAN_PREFIX /usr/local/man) - ENDIF(NOT MAN_PREFIX) - IF(NOT LOCALSTATES_PREFIX) - SET(LOCALSTATES_PREFIX "/var/run/rspamd") - ENDIF(NOT LOCALSTATES_PREFIX) - IF(NOT PREFIX) - SET(PREFIX /usr/local) - ENDIF(NOT PREFIX) - ENDIF(CMAKE_INSTALL_PREFIX) FIND_LIBRARY(LIBINTL_LIBRARY NAMES intl PATHS /lib /opt/lib /usr/lib @@ -254,32 +265,6 @@ ENDIF(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD") IF(CMAKE_SYSTEM_NAME STREQUAL "Darwin") SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_BSD_SOURCE -DDARWIN") - - IF(CMAKE_INSTALL_PREFIX) - IF(NOT ETC_PREFIX) - SET(ETC_PREFIX "${CMAKE_INSTALL_PREFIX}/etc") - ENDIF(NOT ETC_PREFIX) - IF(NOT MAN_PREFIX) - SET(MAN_PREFIX "${CMAKE_INSTALL_PREFIX}/man") - ENDIF(NOT MAN_PREFIX) - IF(NOT LOCALSTATES_PREFIX) - SET(LOCALSTATES_PREFIX "${CMAKE_INSTALL_PREFIX}/var/run/rspamd") - ENDIF(NOT LOCALSTATES_PREFIX) - SET(PREFIX "${CMAKE_INSTALL_PREFIX}") - ELSE(CMAKE_INSTALL_PREFIX) - IF(NOT ETC_PREFIX) - SET(ETC_PREFIX /usr/local/etc) - ENDIF(NOT ETC_PREFIX) - IF(NOT MAN_PREFIX) - SET(MAN_PREFIX /usr/local/man) - ENDIF(NOT MAN_PREFIX) - IF(NOT LOCALSTATES_PREFIX) - SET(LOCALSTATES_PREFIX "/var/run/rspamd") - ENDIF(NOT LOCALSTATES_PREFIX) - IF(NOT PREFIX) - SET(PREFIX /usr/local) - ENDIF(NOT PREFIX) - ENDIF(CMAKE_INSTALL_PREFIX) FIND_LIBRARY(LIBINTL_LIBRARY NAMES intl PATHS /lib /opt/lib @@ -293,33 +278,6 @@ ENDIF(CMAKE_SYSTEM_NAME STREQUAL "Darwin") IF(CMAKE_SYSTEM_NAME STREQUAL "Linux") SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_GNU_SOURCE -DLINUX") - IF(CMAKE_INSTALL_PREFIX) - IF(NOT ETC_PREFIX) - SET(ETC_PREFIX "${CMAKE_INSTALL_PREFIX}/etc") - ENDIF(NOT ETC_PREFIX) - - IF(NOT MAN_PREFIX) - SET(MAN_PREFIX "${CMAKE_INSTALL_PREFIX}/share/man") - ENDIF(NOT MAN_PREFIX) - IF(NOT LOCALSTATES_PREFIX) - SET(LOCALSTATES_PREFIX "${CMAKE_INSTALL_PREFIX}/var/run/rspamd") - ENDIF(NOT LOCALSTATES_PREFIX) - - SET(PREFIX "${CMAKE_INSTALL_PREFIX}") - ELSE(CMAKE_INSTALL_PREFIX) - IF(NOT ETC_PREFIX) - SET(ETC_PREFIX /etc) - ENDIF(NOT ETC_PREFIX) - IF(NOT PREFIX) - SET(PREFIX /usr) - ENDIF(NOT PREFIX) - IF(NOT MAN_PREFIX) - SET(MAN_PREFIX /usr/share/man) - ENDIF(NOT MAN_PREFIX) - IF(NOT LOCALSTATES_PREFIX) - SET(LOCALSTATES_PREFIX "/var/run/rspamd") - ENDIF(NOT LOCALSTATES_PREFIX) - ENDIF(CMAKE_INSTALL_PREFIX) IF(BUILD_CPU_MODE STREQUAL "32") SET(CMAKE_C_FLAGS "-D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE ${CMAKE_C_FLAGS}") ENDIF(BUILD_CPU_MODE STREQUAL "32") @@ -371,32 +329,6 @@ IF(CMAKE_SYSTEM_NAME STREQUAL "SunOS") ENDIF (BUILD_CPU_MODE STREQUAL "32") SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D__EXTENSIONS__ -DSOLARIS -D_POSIX_SOURCE -D_POSIX_C_SOURCE=200112L") - - IF(CMAKE_INSTALL_PREFIX) - IF(NOT ETC_PREFIX) - SET(ETC_PREFIX "${CMAKE_INSTALL_PREFIX}/etc") - ENDIF(NOT ETC_PREFIX) - IF(NOT MAN_PREFIX) - SET(MAN_PREFIX "${CMAKE_INSTALL_PREFIX}/man") - ENDIF(NOT MAN_PREFIX) - IF(NOT LOCALSTATES_PREFIX) - SET(LOCALSTATES_PREFIX "/var/run/rspamd") - ENDIF(NOT LOCALSTATES_PREFIX) - SET(PREFIX "${CMAKE_INSTALL_PREFIX}") - ELSE(CMAKE_INSTALL_PREFIX) - IF(NOT ETC_PREFIX) - SET(ETC_PREFIX /etc) - ENDIF(NOT ETC_PREFIX) - IF(NOT PREFIX) - SET(PREFIX /usr) - ENDIF(NOT PREFIX) - IF(NOT MAN_PREFIX) - SET(MAN_PREFIX /usr/share/man) - ENDIF(NOT MAN_PREFIX) - IF(NOT LOCALSTATES_PREFIX) - SET(LOCALSTATES_PREFIX "/var/run/rspamd") - ENDIF(NOT LOCALSTATES_PREFIX) - ENDIF(CMAKE_INSTALL_PREFIX) LIST(APPEND CMAKE_REQUIRED_LIBRARIES rt) LIST(APPEND CMAKE_REQUIRED_LIBRARIES dl) @@ -424,32 +356,6 @@ IF(NOT INCLUDEDIR) SET(INCLUDEDIR include/rspamd) ENDIF(NOT INCLUDEDIR) -# Check prefixes -IF(NOT ETC_PREFIX) - IF(CMAKE_INSTALL_PREFIX) - MESSAGE(WARNING "Your system is unknown for rspamd, assume defining ETC_PREFIX and MAN_PREFIX by -D option, now ETC_PREFIX and MAN_PREFIX are relative to ${CMAKE_INSTALL_PREFIX}") - SET(ETC_PREFIX "${CMAKE_INSTALL_PREFIX}/etc") - ELSE(CMAKE_INSTALL_PREFIX) - MESSAGE(FATAL_ERROR "Your system is unknown for rspamd and no CMAKE_INSTALL_PREFIX specified, assume defining CMAKE_INSTALL_PREFIX") - ENDIF(CMAKE_INSTALL_PREFIX) - MESSAGE(STATUS "Configuring for ${CMAKE_SYSTEM_NAME}") -ENDIF(NOT ETC_PREFIX) -IF(NOT MAN_PREFIX) - IF(CMAKE_INSTALL_PREFIX) - SET(MAN_PREFIX "${CMAKE_INSTALL_PREFIX}/man") - ENDIF(CMAKE_INSTALL_PREFIX) -ENDIF(NOT MAN_PREFIX) -IF(NOT LOCALSTATES_PREFIX) - IF(CMAKE_INSTALL_PREFIX) - SET(LOCALSTATES_PREFIX "${CMAKE_INSTALL_PREFIX}/var/run/rspamd") - ENDIF(CMAKE_INSTALL_PREFIX) -ENDIF(NOT LOCALSTATES_PREFIX) - -# Now CMAKE_INSTALL_PREFIX is a base prefix for everything -# ETC_PREFIX - for configuration -# MAN_PREFIX - for manual pages -# LOCALSTATES_PREFIX - for runtime files - # Now find libraries and headers # Find lua libraries @@ -1091,7 +997,6 @@ LIST(LENGTH PLUGINSSRC RSPAMD_MODULES_NUM) CONFIGURE_FILE(config.h.in src/config.h) CONFIGURE_FILE(contrib/exim/local_scan.c.in contrib/exim/local_scan_rspamd.c @ONLY) -CONFIGURE_FILE(conf/rspamd-basic.xml.in conf/rspamd.xml.sample @ONLY) ######################### LINK SECTION ############################### @@ -1166,56 +1071,34 @@ ENDIF(GLIB_COMPAT) INSTALL(TARGETS rspamd RUNTIME DESTINATION bin) # Configs -INSTALL(CODE "FILE(MAKE_DIRECTORY \$ENV{DESTDIR}${ETC_PREFIX}/rspamd)") - -INSTALL(FILES conf/2tld.inc RENAME 2tld.inc DESTINATION ${ETC_PREFIX}/rspamd) -IF(NOT EXISTS ${ETC_PREFIX}/rspamd/2tld.inc OR BUILD_PORT) - INSTALL(FILES conf/2tld.inc DESTINATION ${ETC_PREFIX}/rspamd) -ENDIF(NOT EXISTS ${ETC_PREFIX}/rspamd/2tld.inc OR BUILD_PORT) +INSTALL(CODE "FILE(MAKE_DIRECTORY \$ENV{DESTDIR}${CONFDIR})") +INSTALL(CODE "FILE(MAKE_DIRECTORY \$ENV{DESTDIR}${EXAMPLESDIR})") +INSTALL(CODE "FILE(MAKE_DIRECTORY \$ENV{DESTDIR}${PLUGINSDIR}/lua)") -INSTALL(FILES conf/surbl-whitelist.inc RENAME surbl-whitelist.inc DESTINATION ${ETC_PREFIX}/rspamd) -IF(NOT EXISTS ${ETC_PREFIX}/rspamd/surbl-whitelist.inc OR BUILD_PORT) - INSTALL(FILES conf/surbl-whitelist.inc DESTINATION ${ETC_PREFIX}/rspamd) -ENDIF(NOT EXISTS ${ETC_PREFIX}/rspamd/surbl-whitelist.inc OR BUILD_PORT) +INSTALL(FILES conf/2tld.inc RENAME 2tld.inc DESTINATION ${CONFDIR}) -IF(NOT DEBIAN_BUILD) - INSTALL(FILES ${CMAKE_BINARY_DIR}/conf/rspamd.xml.sample DESTINATION ${ETC_PREFIX}) -ENDIF(NOT DEBIAN_BUILD) +INSTALL(FILES conf/surbl-whitelist.inc RENAME surbl-whitelist.inc DESTINATION ${CONFDIR}) # Lua plugins -INSTALL(CODE "FILE(MAKE_DIRECTORY \$ENV{DESTDIR}${ETC_PREFIX}/rspamd/plugins/lua)") -FILE(GLOB LUA_PLUGINS RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}/src/plugins/lua" "${CMAKE_CURRENT_SOURCE_DIR}/src/plugins/lua/*.lua" ) +FILE(GLOB LUA_PLUGINS RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}/src/plugins/lua" + "${CMAKE_CURRENT_SOURCE_DIR}/src/plugins/lua/*.lua" ) FOREACH(LUA_PLUGIN ${LUA_PLUGINS}) GET_FILENAME_COMPONENT(_rp ${LUA_PLUGIN} PATH) - INSTALL(CODE "FILE(MAKE_DIRECTORY \$ENV{DESTDIR}${ETC_PREFIX}/rspamd/plugins/lua/${_rp})") - INSTALL(FILES "src/plugins/lua/${LUA_PLUGIN}" DESTINATION ${ETC_PREFIX}/rspamd/plugins/lua/${_rp}) + INSTALL(CODE "FILE(MAKE_DIRECTORY \$ENV{DESTDIR}${PLUGINSDIR}/lua/${_rp})") + INSTALL(FILES "src/plugins/lua/${LUA_PLUGIN}" DESTINATION ${PLUGINSDIR}/lua/${_rp}) ENDFOREACH(LUA_PLUGIN) # Lua config -INSTALL(CODE "FILE(MAKE_DIRECTORY \$ENV{DESTDIR}${ETC_PREFIX}/rspamd/lua)") -FILE(GLOB_RECURSE LUA_CONFIGS RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}/conf/lua" "${CMAKE_CURRENT_SOURCE_DIR}/conf/lua/*.lua") +INSTALL(CODE "FILE(MAKE_DIRECTORY \$ENV{DESTDIR}${CONFDIR}/lua)") +FILE(GLOB_RECURSE LUA_CONFIGS RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}/conf/lua" + "${CMAKE_CURRENT_SOURCE_DIR}/conf/lua/*.lua") FOREACH(LUA_CONF ${LUA_CONFIGS}) GET_FILENAME_COMPONENT(_rp ${LUA_CONF} PATH) - INSTALL(CODE "FILE(MAKE_DIRECTORY \$ENV{DESTDIR}${ETC_PREFIX}/rspamd/lua/${_rp})") - INSTALL(FILES "conf/lua/${LUA_CONF}" DESTINATION ${ETC_PREFIX}/rspamd/lua/${_rp}) + INSTALL(CODE "FILE(MAKE_DIRECTORY \$ENV{DESTDIR}${CONFDIR}/lua/${_rp})") + INSTALL(FILES "conf/lua/${LUA_CONF}" DESTINATION ${CONFDIR}/lua/${_rp}) ENDFOREACH(LUA_CONF) # Manual pages -INSTALL(FILES "doc/rspamd.8" DESTINATION ${MAN_PREFIX}/man8) -INSTALL(FILES "doc/rspamc.1" DESTINATION ${MAN_PREFIX}/man1) - -# Start scripts -IF(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD" AND NOT BUILD_PORT) - INSTALL(PROGRAMS ${CMAKE_BINARY_DIR}/freebsd/rspamd DESTINATION ${ETC_PREFIX}/rc.d) - IF(ENABLE_REDIRECTOR MATCHES "ON") - INSTALL(PROGRAMS ${CMAKE_BINARY_DIR}/freebsd/redirector DESTINATION ${ETC_PREFIX}/rc.d) - ENDIF(ENABLE_REDIRECTOR MATCHES "ON") - INSTALL(CODE "FILE(MAKE_DIRECTORY \$ENV{DESTDIR}/${LOCALSTATES_PREFIX})") - INSTALL(CODE "EXECUTE_PROCESS(COMMAND chown ${RSPAMD_USER}:${RSPAMD_GROUP} \$ENV{DESTDIR}/${LOCALSTATES_PREFIX})") -ENDIF(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD" AND NOT BUILD_PORT) -IF(CMAKE_SYSTEM_NAME STREQUAL "Linux" AND NOT DEBIAN_BUILD) - INSTALL(PROGRAMS "linux/${LINUX_START_SCRIPT}" DESTINATION ${ETC_PREFIX}/init.d RENAME rspamd) - INSTALL(CODE "FILE(MAKE_DIRECTORY \$ENV{DESTDIR}/${LOCALSTATES_PREFIX})") - INSTALL(CODE "EXECUTE_PROCESS(COMMAND chown ${RSPAMD_USER}:${RSPAMD_GROUP} \$ENV{DESTDIR}/${LOCALSTATES_PREFIX})") -ENDIF(CMAKE_SYSTEM_NAME STREQUAL "Linux" AND NOT DEBIAN_BUILD) +INSTALL(FILES "doc/rspamd.8" DESTINATION ${MANDIR}/man8) +INSTALL(FILES "doc/rspamc.1" DESTINATION ${MANDIR}/man1) \ No newline at end of file diff --git a/config.h.in b/config.h.in index d678e2998..c7e44d846 100644 --- a/config.h.in +++ b/config.h.in @@ -215,9 +215,13 @@ #define uthash_malloc(sz) g_slice_alloc(sz) #define uthash_free(ptr,sz) g_slice_free1(sz, ptr) -#define ETC_PREFIX "${ETC_PREFIX}" -#define LOCALSTATES_PREFIX "${LOCALSTATES_PREFIX}" -#define CMAKE_PREFIX "${CMAKE_INSTALL_PREFIX}" +#define RSPAMD_CONFDIR "${CONFDIR}" +#define RSPAMD_RUNDIR "${RUNDIR}" +#define RSPAMD_LOGDIR "${LOGDIR}" +#define RSPAMD_DBDIR "${DBDIR}" +#define RSPAMD_EXAMPLESDIR "${EXAMPLESDIR}" +#define RSPAMD_PLUGINSDIR "${PLUGINSDIR}" +#define RSPAMD_PREFIX "${CMAKE_INSTALL_PREFIX}" #define RVERSION "${RSPAMD_VERSION}" #define RID "${RSPAMD_ID}" diff --git a/debian/rspamd.init b/debian/rspamd.init index 1ac3ea6d2..c3fab74b4 100755 --- a/debian/rspamd.init +++ b/debian/rspamd.init @@ -16,7 +16,7 @@ PATH=/sbin:/usr/sbin:/bin:/usr/bin DESC="Rspamd" NAME=rspamd DAEMON=/usr/bin/$NAME -DAEMON_ARGS="-c /etc/rspamd.xml" +DAEMON_ARGS="-c /etc/rspamd.conf" DESC="rapid spam filtering system" PIDFILE=/var/lib/rspamd/$NAME.pid SCRIPTNAME=/etc/init.d/$NAME diff --git a/debian/rules b/debian/rules index 54b8a8407..d7456e138 100755 --- a/debian/rules +++ b/debian/rules @@ -6,6 +6,17 @@ include /usr/share/dpkg/buildflags.mk include /usr/share/cdbs/1/rules/debhelper.mk include /usr/share/cdbs/1/class/cmake.mk -DEB_CMAKE_NORMAL_ARGS+= -DETC_PREFIX=/etc -DMAN_PREFIX=/usr/share/man -DLOCALSTATES_PREFIX=/var/lib -DLIBDIR=/usr/lib -DINCLUDEDIR=/usr/include -DNO_SHARED=ON -DDEBIAN_BUILD=1 -DRSPAMD_GROUP=rspamd -DRSPAMD_USER=rspamd +DEB_CMAKE_NORMAL_ARGS+= -DCONFDIR=/etc \ + -DMANDIR=/usr/share/man \ + -DRUNDIR=/var/run/rspamd \ + -DDBDIR=/var/lib/rspamd \ + -DLOGDIR=/var/log/rspamd \ + -DPLUGINSDIR=/usr/share/rspamd \ + -DLIBDIR=/usr/lib \ + -DINCLUDEDIR=/usr/include \ + -DNO_SHARED=ON \ + -DDEBIAN_BUILD=1 \ + -DRSPAMD_GROUP=rspamd \ + -DRSPAMD_USER=rspamd clean:: rm -f src/modules.c \ No newline at end of file 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