Skip to content

Commit

Permalink
Add POSTSRSD_CONFIGDIR cache variable
Browse files Browse the repository at this point in the history
  • Loading branch information
roehling committed Aug 13, 2023
1 parent 4bcefa9 commit 82e7471
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 25 deletions.
46 changes: 27 additions & 19 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,25 @@ include(CheckTypeSize)
include(CheckSymbolExists)
include(TestBigEndian)

set(POSTSRSD_CONFIGDIR
"${CMAKE_INSTALL_FULL_SYSCONFDIR}"
CACHE
PATH
"The default directory where PostSRSd should look for configuration files"
)
set(POSTSRSD_DATADIR
"${CMAKE_INSTALL_FULL_LOCALSTATEDIR}/lib/${PROJECT_NAME}"
CACHE PATH "The default directory where PostSRSd should put runtime data"
)
set(POSTSRSD_CHROOTDIR
"${POSTSRSD_DATADIR}"
CACHE PATH "The default chroot directory where PostSRSd should jail itself"
)
set(POSTSRSD_USER
"nobody"
CACHE STRING "The default unprivileged user as which PostSRSd will run"
)

option(WITH_MILTER "Enable SRS rewrite via Milter (requires libmilter)" OFF)
add_feature_info(WITH_MILTER WITH_MILTER "run PostSRSd as milter")
option(WITH_SQLITE
Expand All @@ -54,8 +73,8 @@ option(WITH_REDIS
OFF
)
add_feature_info(WITH_REDIS WITH_REDIS "use Redis as database backend")

option(TESTS_WITH_ASAN "Run test suite with AddressSanitizer" ON)
option(DEVELOPER_BUILD "Add strict compiler options for development only" OFF)
option(GENERATE_SRS_SECRET "Generate and install a postsrsd.secret" ON)
add_feature_info(
GENERATE_SRS_SECRET
Expand All @@ -67,19 +86,6 @@ add_feature_info(
INSTALL_SYSTEMD_SERVICE INSTALL_SYSTEMD_SERVICE
"install the systemd postsrsd.service unit"
)
option(DEVELOPER_BUILD "Add strict compiler options for development only" OFF)
set(POSTSRSD_USER
"nobody"
CACHE STRING "The default unprivileged user as which PostSRSd will run"
)
set(POSTSRSD_DATADIR
"${CMAKE_INSTALL_FULL_LOCALSTATEDIR}/lib/${PROJECT_NAME}"
CACHE PATH "The default directory where PostSRSd should put runtime data"
)
set(POSTSRSD_CHROOTDIR
"${POSTSRSD_DATADIR}"
CACHE PATH "The default chroot directory where PostSRSd should jail itself"
)
find_systemd_unit_destination(DETECTED_SYSTEMD_UNITDIR)
set(SYSTEMD_UNITDIR
"${DETECTED_SYSTEMD_UNITDIR}"
Expand Down Expand Up @@ -107,10 +113,11 @@ mark_as_advanced(
TESTS_WITH_ASAN
GENERATE_SRS_SECRET
DEVELOPER_BUILD
POSTSRSD_USER
POSTSRSD_DATADIR
POSTSRSD_CHROOTDIR
SYSTEMD_UNITDIR
POSTSRSD_CONFIGDIR
POSTSRSD_CHROOTDIR
POSTSRSD_DATADIR
POSTSRSD_USER
)

FetchContent_Declare(
Expand Down Expand Up @@ -374,15 +381,16 @@ if(GENERATE_SRS_SECRET)
)
install(
CODE "\
if(NOT EXISTS \"\$ENV{DESTDIR}${CMAKE_INSTALL_FULL_SYSCONFDIR}/${PROJECT_NAME}.secret\")
if(NOT EXISTS \"\$ENV{DESTDIR}${POSTSRSD_CONFIGDIR}/${PROJECT_NAME}.secret\")
message(STATUS \"Generating: \$ENV{DESTDIR}${POSTSRSD_CONFIGDIR}/${PROJECT_NAME}.secret\")
execute_process(
COMMAND ${DD} if=${RANDOM_SOURCE} bs=18 count=1
COMMAND ${BASE64_ENCODE}
OUTPUT_FILE \"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.secret\"
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE
)
file(INSTALL DESTINATION \"${CMAKE_INSTALL_FULL_SYSCONFDIR}\" FILES \"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.secret\" RENAME \"${PROJECT_NAME}.secret\" PERMISSIONS OWNER_READ OWNER_WRITE)
file(INSTALL DESTINATION \"${POSTSRSD_CONFIGDIR}\" FILES \"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.secret\" RENAME \"${PROJECT_NAME}.secret\" PERMISSIONS OWNER_READ OWNER_WRITE)
file(REMOVE \"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.secret\")
endif()"
)
Expand Down
6 changes: 3 additions & 3 deletions data/postsrsd.conf.in
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ domains = {}
# large number of domains for which you need to act as mail forwarder.
#
# Example:
# domains-file = "@CMAKE_INSTALL_FULL_SYSCONFDIR@/@[email protected]"
# domains-file = "@POSTSRSD_CONFIGDIR@/@[email protected]"
#
#domains-file =

Expand Down Expand Up @@ -110,9 +110,9 @@ original-envelope = embedded
# only accessible by root (chmod 600).
#
# Example:
# secrets-file = "@CMAKE_INSTALL_FULL_SYSCONFDIR@/@[email protected]"
# secrets-file = "@POSTSRSD_CONFIGDIR@/@[email protected]"
#
secrets-file = "@CMAKE_INSTALL_FULL_SYSCONFDIR@/@[email protected]"
secrets-file = "@POSTSRSD_CONFIGDIR@/@[email protected]"

# SRS tag separator
# This is the character following the initial SRS0 or SRS1 tag of a generated
Expand Down
2 changes: 1 addition & 1 deletion data/postsrsd.service.in
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Before=postfix.service
After=network.target

[Service]
ExecStart=@CMAKE_INSTALL_FULL_SBINDIR@/postsrsd -C @CMAKE_INSTALL_FULL_SYSCONFDIR@/@[email protected]
ExecStart=@CMAKE_INSTALL_FULL_SBINDIR@/postsrsd -C @POSTSRSD_CONFIGDIR@/@[email protected]

[Install]
WantedBy=multi-user.target
4 changes: 2 additions & 2 deletions src/postsrsd_build_config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
/* clang-format off */
#define POSTSRSD_VERSION "@PROJECT_VERSION@"
#define SIZEOF_UNSIGNED_LONG @SIZEOF_UNSIGNED_LONG@
#define DEFAULT_CONFIG_FILE "@CMAKE_INSTALL_FULL_SYSCONFDIR@/@[email protected]"
#define DEFAULT_SECRETS_FILE "@CMAKE_INSTALL_FULL_SYSCONFDIR@/@[email protected]"
#define DEFAULT_CONFIG_FILE "@POSTSRSD_CONFIGDIR@/@[email protected]"
#define DEFAULT_SECRETS_FILE "@POSTSRSD_CONFIGDIR@/@[email protected]"
#define DEFAULT_CHROOT_DIR "@POSTSRSD_CHROOTDIR@"
#define DEFAULT_POSTSRSD_USER "@POSTSRSD_USER@"
/* clang-format on */
Expand Down

0 comments on commit 82e7471

Please sign in to comment.