From ce8c342ed5d89597f49905fe6cde6f202cd7aef4 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Mon, 1 Jun 2026 12:52:37 -0400 Subject: [PATCH 1/8] contrib/systemd/opendkim.tmpfiles.in: new tmpfiles.d entry Both OpenRC and systemd can make use of tmpfiles.d entries, https://www.freedesktop.org/software/systemd/man/latest/tmpfiles.d.html Our sample configuration files effectively recommend putting a local socket inside @RUNSTATEDIR@/opendkim, so here we add a tmpfiles.d entry to create that directory and set the appropriate permissions, assuming that the user running opendkim will be opendkim:opendkim. --- contrib/systemd/opendkim.tmpfiles.in | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 contrib/systemd/opendkim.tmpfiles.in diff --git a/contrib/systemd/opendkim.tmpfiles.in b/contrib/systemd/opendkim.tmpfiles.in new file mode 100644 index 000000000..a91189745 --- /dev/null +++ b/contrib/systemd/opendkim.tmpfiles.in @@ -0,0 +1,5 @@ +# We allow everyone to read/traverse this directory because if it +# contains a local socket, then (for example) your MTA will want to +# look in there. Permissions on the socket itself are controlled +# by the "UserID" and "UMask" directives in the daemon's configuration. +d @RUNSTATEDIR@/opendkim 0755 opendkim opendkim From 1cedabeb83f2f8a05703592c8a27a7d34b0299a4 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Mon, 1 Jun 2026 12:55:59 -0400 Subject: [PATCH 2/8] Makefile.am: support for contrib/systemd/opendkim.tmpfiles Add contrib/systemd/opendkim.tmpfiles and its ".in" counterpart to the appropriate lists in Makefile.am so that the former is built from the latter. --- Makefile.am | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Makefile.am b/Makefile.am index 2187b2df8..7dcde0879 100644 --- a/Makefile.am +++ b/Makefile.am @@ -47,11 +47,13 @@ DISTCHECK_CONFIGURE_FLAGS=--enable-vbr --with-lua --enable-stats --with-odbx --w # # We want to *build and install* these on the target machine. -nodist_doc_DATA = opendkim/opendkim.conf.simple \ +nodist_doc_DATA = contrib/systemd/opendkim.tmpfiles \ + opendkim/opendkim.conf.simple \ opendkim/opendkim.conf.simple-verify # We want to *ship* these. -EXTRA_DIST = opendkim/opendkim.conf.simple.in \ +EXTRA_DIST = contrib/systemd/opendkim.tmpfiles.in \ + opendkim/opendkim.conf.simple.in \ opendkim/opendkim.conf.simple-verify.in # The next rule allow us to replace bindir, libdir, etc. within From 5b5004dabdf3c4d63200a6b0e39061eeec63360a Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Mon, 1 Jun 2026 12:59:29 -0400 Subject: [PATCH 3/8] Makefile.am: substitute @SBINDIR@ and @SYSCONFDIR@, too These two variables, corresponding to ./configure --sbindir and --sysconfdir, can be used by our service scripts. Let's begin substituting them in preparation for making the service scripts more robust. --- Makefile.am | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Makefile.am b/Makefile.am index 7dcde0879..0e127f8e5 100644 --- a/Makefile.am +++ b/Makefile.am @@ -61,7 +61,9 @@ EXTRA_DIST = contrib/systemd/opendkim.tmpfiles.in \ # be found in the "Installation Directory Variables" section. edit = sed -e 's|@DOMAIN[@]|$(DOMAIN)|g' \ -e 's|@LOCALSTATEDIR[@]|$(localstatedir)|g' \ - -e 's|@RUNSTATEDIR[@]|$(runstatedir)|g' + -e 's|@RUNSTATEDIR[@]|$(runstatedir)|g' \ + -e 's|@SBINDIR[@]|$(sbindir)|g' \ + -e 's|@SYSCONFDIR[@]|$(sysconfdir)|g' # This rule includes EVERY source/intermediate file as a dependency of # EVERY output file, which is clearly wrong, but it may be the best we From 4f04c2ad9e95c60e6045661b2b41bcbbd8e807e4 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Mon, 1 Jun 2026 13:06:05 -0400 Subject: [PATCH 4/8] contrib/openrc/opendkim.openrc.in: new OpenRC service script template Add a service script for the OpenRC init system used by many linux distributions: * https://github.com/openrc/openrc * https://en.wikipedia.org/wiki/OpenRC The service script is a template, in that the appropriate values of --sbindir, --runstatedir, and so on will be substituted into it at build-time. The hope is that this makes one script suitable for all OpenRC distributions. --- contrib/openrc/opendkim.openrc.in | 52 +++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 contrib/openrc/opendkim.openrc.in diff --git a/contrib/openrc/opendkim.openrc.in b/contrib/openrc/opendkim.openrc.in new file mode 100644 index 000000000..83f2f28be --- /dev/null +++ b/contrib/openrc/opendkim.openrc.in @@ -0,0 +1,52 @@ +#!/sbin/openrc-run + +CONFFILE="@SYSCONFDIR@/${RC_SVCNAME}.conf" +required_files="${CONFFILE}" + +command="@SBINDIR@/opendkim" +pidfile="@RUNSTATEDIR@/${RC_SVCNAME}.pid" +command_args="-P ${pidfile} -x ${CONFFILE}" +extra_commands="checkconfig" + +depend() { + use dns logger net + before mta +} + +checkconfig() { + # + # The opendkim.conf man page says, + # + # For parameters that are Boolean in nature, only the first byte + # of the value is processed... For negative values, the following + # are accepted: "F", "f", "N", "n", "0".' + # + if grep '^[[:space:]]*Background[[:space:]][[:space:]]*[FfNn0]' "${CONFFILE}" \ + >/dev/null 2>&1; then + eend 1 "${RC_SVCNAME} cannot run in the foreground!" + fi + if ! "${command}" -n "${command_args}"; then + eend 1 "${RC_SVCNAME} configuration check failed" + fi +} + +start_pre() { + # If this isn't a restart, make sure that the user's config isn't + # busted before we try to start the daemon (this will produce + # better error messages than if we just try to start it blindly). + # + # If, on the other hand, this *is* a restart, then the stop_pre + # action will have ensured that the config is usable and we don't + # need to do that again. + if [ "${RC_CMD}" != "restart" ]; then + checkconfig || return $? + fi +} + +stop_pre() { + # If this is a restart, check to make sure the user's config + # isn't busted before we stop the running daemon. + if [ "${RC_CMD}" = "restart" ]; then + checkconfig || return $? + fi +} From cc7987ad9ca60a101bbd2d1484ecddcb78e307fa Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Mon, 1 Jun 2026 13:11:44 -0400 Subject: [PATCH 5/8] Makefile.am: support for contrib/openrc/opendkim.openrc Add contrib/openrc/opendkim.openrc and its ".in" counterpart to the appropriate lists in Makefile.am so that the former is built from the latter. --- Makefile.am | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Makefile.am b/Makefile.am index 0e127f8e5..32838ab60 100644 --- a/Makefile.am +++ b/Makefile.am @@ -47,12 +47,14 @@ DISTCHECK_CONFIGURE_FLAGS=--enable-vbr --with-lua --enable-stats --with-odbx --w # # We want to *build and install* these on the target machine. -nodist_doc_DATA = contrib/systemd/opendkim.tmpfiles \ +nodist_doc_DATA = contrib/openrc/opendkim.openrc \ + contrib/systemd/opendkim.tmpfiles \ opendkim/opendkim.conf.simple \ opendkim/opendkim.conf.simple-verify # We want to *ship* these. -EXTRA_DIST = contrib/systemd/opendkim.tmpfiles.in \ +EXTRA_DIST = contrib/openrc/opendkim.openrc.in \ + contrib/systemd/opendkim.tmpfiles.in \ opendkim/opendkim.conf.simple.in \ opendkim/opendkim.conf.simple-verify.in From e67f84ac78beb8d7ff639a39da8b9a3dc728be0b Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Tue, 2 Jun 2026 11:24:27 -0400 Subject: [PATCH 6/8] contrib/openrc/README: explain what this directory contains --- contrib/openrc/README | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 contrib/openrc/README diff --git a/contrib/openrc/README b/contrib/openrc/README new file mode 100644 index 000000000..5b9f99e4a --- /dev/null +++ b/contrib/openrc/README @@ -0,0 +1,11 @@ +Service scripts and configuration for the OpenRC[0] init system. They +are supported by their authors and/or the maintainers of the OpenDKIM +package[1] in Gentoo linux (presently, one and the same). + +OpenRC uses the tmpfiles.d mechanism[2], so the tmpfiles entry in the +"systemd" subdirectory is relevant here as well. + + +[0] https://github.com/OpenRC/openrc +[1] https://packages.gentoo.org/packages/mail-filter/opendkim +[2] https://www.freedesktop.org/software/systemd/man/latest/tmpfiles.d.html From b9e2572ecc1878a9d9aedd1dc0efd99becf0b520 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Tue, 2 Jun 2026 11:26:19 -0400 Subject: [PATCH 7/8] autotools: install the openrc README Include the OpenRC "README" in dist_doc_DATA, and tell autoconf/automake about the directory that contains it. --- configure.ac | 1 + contrib/Makefile.am | 2 +- contrib/openrc/Makefile.am | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 contrib/openrc/Makefile.am diff --git a/configure.ac b/configure.ac index bf1a7fe12..46b7d8a0a 100644 --- a/configure.ac +++ b/configure.ac @@ -2733,6 +2733,7 @@ AC_CONFIG_FILES([ Makefile contrib/init/solaris/Makefile contrib/ldap/Makefile contrib/lua/Makefile + contrib/openrc/Makefile contrib/patches/Makefile contrib/repute/Makefile contrib/spec/Makefile diff --git a/contrib/Makefile.am b/contrib/Makefile.am index 76df01cd8..174074e64 100644 --- a/contrib/Makefile.am +++ b/contrib/Makefile.am @@ -3,6 +3,6 @@ #AUTOMAKE_OPTIONS = foreign -SUBDIRS = convert docs init ldap lua patches repute spec stats systemd +SUBDIRS = convert docs init ldap lua openrc patches repute spec stats systemd dist_doc_DATA = README diff --git a/contrib/openrc/Makefile.am b/contrib/openrc/Makefile.am new file mode 100644 index 000000000..63b12a1e1 --- /dev/null +++ b/contrib/openrc/Makefile.am @@ -0,0 +1 @@ +dist_doc_DATA = README From 6579ca7063fc220ed72fa62b76cd45b12385a437 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Thu, 4 Jun 2026 18:25:03 -0400 Subject: [PATCH 8/8] contrib/.gitignore: add openrc service script and tmpfiles entry These are built from templates, we aren't interested in them. --- contrib/.gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/contrib/.gitignore b/contrib/.gitignore index 88b99afa7..78a72c550 100644 --- a/contrib/.gitignore +++ b/contrib/.gitignore @@ -1,3 +1,5 @@ Makefile Makefile.in opendkim.spec +openrc/opendkim.openrc +systemd/opendkim.tmpfiles