From d97fb9a434fc278cfbccaddaed538c5134256b5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Floure?= Date: Tue, 21 May 2024 15:12:54 +0200 Subject: [PATCH] [__opendkim] add debian support --- type/__opendkim/files/opendkim.conf.sh | 8 ++++++ type/__opendkim/man.rst | 7 ++++-- type/__opendkim/manifest | 34 +++++++++++++++++++++++++- type/__opendkim/parameter/optional | 1 + 4 files changed, 47 insertions(+), 3 deletions(-) diff --git a/type/__opendkim/files/opendkim.conf.sh b/type/__opendkim/files/opendkim.conf.sh index 468b262..7e7fab0 100755 --- a/type/__opendkim/files/opendkim.conf.sh +++ b/type/__opendkim/files/opendkim.conf.sh @@ -3,6 +3,9 @@ echo "# Managed remotely, manual changes will be lost." +# Used for OS-specific configuration. +os=$(cat "${__global:?}/explorer/os") + # Optional chdir(2) if [ "$BASEDIR" ]; then @@ -63,3 +66,8 @@ if [ "$USERID" ]; then printf "UserID %s\n" "$USERID" fi + +if [ "$PIDFILE" ]; +then + printf "PidFile %s\n" "$PIDFILE" +fi diff --git a/type/__opendkim/man.rst b/type/__opendkim/man.rst index 996f16d..765e7d3 100644 --- a/type/__opendkim/man.rst +++ b/type/__opendkim/man.rst @@ -14,8 +14,8 @@ installation and basic configuration of an instance of OpenDKIM. Note that this type does not generate or ensure that a key is present: use `cdist-type__opendkim-genkey(7)` for that. -Note that this type is currently only implemented for Alpine Linux and FreeBSD. -Please contribute an implementation if you can. +Note that this type is currently only implemented for Debian, Alpine Linux and +FreeBSD. Please contribute an implementation if you can. REQUIRED PARAMETERS @@ -45,6 +45,9 @@ custom-config The string following this parameter is appended as-is in the configuration, to enable more complex configurations. +pidfile + Specifies the path to a file that should be created at process start + containing the process ID. BOOLEAN PARAMETERS ------------------ diff --git a/type/__opendkim/manifest b/type/__opendkim/manifest index dbd9fc0..9565493 100755 --- a/type/__opendkim/manifest +++ b/type/__opendkim/manifest @@ -21,13 +21,20 @@ os=$(cat "${__global:?}/explorer/os") CFG_DIR="/etc/opendkim" +CFG_FILE="$CFG_DIR/opendkim.conf" service="opendkim" case "$os" in 'alpine') : ;; +'debian') + CFG_DIR="/etc/dkimkeys" + CFG_FILE="/etc/opendkim.conf" + ;; 'freebsd') CFG_DIR="/usr/local/etc/mail" + CFG_FILE="$CFG_DIR/opendkim.conf" + service="milter-opendkim" ;; *) @@ -70,12 +77,37 @@ if [ -f "${__object:?}/parameter/userid" ]; then export USERID fi +if [ -f "${__object:?}/parameter/pidfile" ]; then + PIDFILE="$(cat "${__object:?}/parameter/pidfile")" + export PIDFILE +fi + +# Debian: set configuration specific to debian packaging if no explicit value +# is requested. +if [ "$os" = "debian" ]; then + # In Debian, opendkim runs as user "opendkim". A umask of 007 is required when + # using a local socket with MTAs that access the socket as a non-privileged + # user (for example, Postfix). You may need to add user "postfix" to group + # "opendkim" in that case. + if [ -z "$USERID" ]; then + export USERID="opendkim" + fi + + if [ -z "$UMASK" ]; then + export UMASK="007" + fi + + if [ -z "$PIDFILE" ]; then + export PIDFILE="/run/opendkim/opendkim.pid" + fi +fi + # Boolean parameters [ -f "${__object:?}/parameter/syslog" ] && export SYSLOG=yes # Generate and deploy configuration file. source_file="${__object:?}/files/opendkim.conf" -target_file="${CFG_DIR}/opendkim.conf" +target_file="${CFG_FILE}" mkdir -p "${__object:?}/files" diff --git a/type/__opendkim/parameter/optional b/type/__opendkim/parameter/optional index af59609..3ad5a9b 100644 --- a/type/__opendkim/parameter/optional +++ b/type/__opendkim/parameter/optional @@ -4,3 +4,4 @@ subdomains umask userid custom-config +pidfile