aboutsummaryrefslogtreecommitdiffstats
path: root/mail-filter/opendkim
diff options
context:
space:
mode:
authorWynn Wolf Arbor2020-06-10 12:21:44 +0200
committerWynn Wolf Arbor2020-06-10 12:21:44 +0200
commit21cce7783e0707f637b75c325d9cb2b5c6e2a479 (patch)
treeea918d94bca6acbbcd1336cc8fd8a56a176fef9f /mail-filter/opendkim
parent74066c403a6ee86ab6d97d0fbf91c457b726be6a (diff)
downloadpramantha-21cce7783e0707f637b75c325d9cb2b5c6e2a479.tar.gz
mail-filter/opendkim: Add 2.10.3-r18
This ebuild contains fixes for musl-based systems. See [1]. [1] https://github.com/gentoo/gentoo/pull/16140 Package-Manager: Portage-2.3.99, Repoman-2.3.22
Diffstat (limited to '')
-rw-r--r--mail-filter/opendkim/Manifest7
-rw-r--r--mail-filter/opendkim/files/opendkim-2.10.3-define-P-macro-in-libvbr.patch40
-rw-r--r--mail-filter/opendkim/files/opendkim-2.10.3-lua-pkgconfig.patch174
-rw-r--r--mail-filter/opendkim/files/opendkim-2.10.3-openrc.patch295
-rw-r--r--mail-filter/opendkim/files/opendkim-2.10.3-openssl-1.1.1.patch.r2170
-rw-r--r--mail-filter/opendkim/metadata.xml72
-rw-r--r--mail-filter/opendkim/opendkim-2.10.3-r18.ebuild229
7 files changed, 987 insertions, 0 deletions
diff --git a/mail-filter/opendkim/Manifest b/mail-filter/opendkim/Manifest
new file mode 100644
index 0000000..0a7bf38
--- /dev/null
+++ b/mail-filter/opendkim/Manifest
@@ -0,0 +1,7 @@
+AUX opendkim-2.10.3-define-P-macro-in-libvbr.patch 1111 BLAKE2B ef21e6609a80eadfc3c493b088df6afe368d0ed833d04e7cde922e643b434a7033c888e1b7158d1085152b128a60d95fae722885f15be08c63bed898e4924127 SHA512 6cf0cb4e54814f661f9869bfdfda0ab44c67f237475ebc69b18c670de9f356bb5375740dc8e0a922f25a3215ad5a884725629c92eac1dbf8251364725d77c105
+AUX opendkim-2.10.3-lua-pkgconfig.patch 5688 BLAKE2B 57fd8b57d12af4d1351e8bfa2ad01a39e85a6f1e440e3754e497082f5f1098dfc8c31771b1f83ae59f1e53ef242af78093601b1348b62945deacf8afdc42fca0 SHA512 b9ee7e625d1a3f00dcda7e441a81749d773daa9cfad7f046dd03d775564f1c111648c883ef1dcc16a6b518239b6a66bee4ba59f59227d182fcf61b887594d1d7
+AUX opendkim-2.10.3-openrc.patch 10203 BLAKE2B e825ae1258c82607eb6d10d5acc3246908868fd3d5703ba0044f93bdf51e5a95dbc39a1e3060855073d14c31da5cb3985afe81c526f592f56463bf698ce4c317 SHA512 34499044cb768d54c0c1653a62fb34c9815990d815c98ccfba22afc1ad9c837c6689ff17a3d1da1221d698c91ce9d77a1964d99055527dfd797f8d428e1db615
+AUX opendkim-2.10.3-openssl-1.1.1.patch.r2 5966 BLAKE2B c0dcb757f1195e8a3fc055f5162b805bf5bb2fe7a6a7c24317cfc1f0ed05491803f2fefbc22e96409a339f9741cac5344044a1efadec1f3e3c87084b2c221ed6 SHA512 e532d0411bc6cf1f55bf2de1bad54dc29d19558b2c4ea27aa72f17738688d48f111c3662e88064169a78347144eae289b362bfa4849ab4d3b06ff97d439cce47
+DIST opendkim-2.10.3.tar.gz 1210224 BLAKE2B affd4526568431fa1afee93a167c5569912c9344ea4e6eee3281a035bd0c76d2be5d2e8e144bbebabd681a73388a37ac56d9a2e4daf00af9baadad14ffb42265 SHA512 97923e533d072c07ae4d16a46cbed95ee799aa50f19468d8bc6d1dc534025a8616c3b4b68b5842bc899b509349a2c9a67312d574a726b048c0ea46dd4fcc45d8
+EBUILD opendkim-2.10.3-r18.ebuild 7445 BLAKE2B 52d7f1193f6a1c98e4f53f4070342a07906f1af664b3f67fe9dedb98bd8342250027fab234512006b38b3385fda06ea851deb56cfc3977fe134f1d91c29fe51f SHA512 9a7405360a169d9379ec5ffeecfc045452420e6098cde272a9a22fef7694b5d5692d966f512e2d77072f8ef6169a71736b72ded99766a9a2f7c4e663b35d65d1
+MISC metadata.xml 2185 BLAKE2B 0cfb33303e8edf764700664863e2dbf90a288e71cf1a078c33ebaac20b11e398e34ae8ca289732b24401ec1f4b192e2c922a86297632af9a039736c52e0ac143 SHA512 56753bc62e8fa16ad3df9e49c2877bbfa5ca8f2f617455c8b9757e50cdd2afe6b27d2d185edb3620d447e42277d755373eafb448da08262723cfb0b5863c3399
diff --git a/mail-filter/opendkim/files/opendkim-2.10.3-define-P-macro-in-libvbr.patch b/mail-filter/opendkim/files/opendkim-2.10.3-define-P-macro-in-libvbr.patch
new file mode 100644
index 0000000..bbb4eb8
--- /dev/null
+++ b/mail-filter/opendkim/files/opendkim-2.10.3-define-P-macro-in-libvbr.patch
@@ -0,0 +1,40 @@
+From 50a91575cee8d08682f090d2d6bdb4806eccfbcd Mon Sep 17 00:00:00 2001
+From: Wynn Wolf Arbor <wolf@oriole.systems>
+Date: Wed, 10 Jun 2020 09:37:03 +0200
+Subject: [PATCH] Define __P() macro in libvbr
+
+Definitions for this macro have been added throughout the codebase in
+commits 91e7407d, 705948fd, 227fa252, 842c1733, and b730bdc0, but one
+was still missing from libvbr. glibc contains a definition for legacy
+reasons, but other libcs might not. Particularly, the musl libc does not
+contain it, leading to build errors when enabling support for VBR.
+
+Add a definition for __P() to vbr.h to fix this.
+---
+ libvbr/vbr.h | 10 ++++++++++
+ 1 file changed, 10 insertions(+)
+
+diff --git a/libvbr/vbr.h b/libvbr/vbr.h
+index 4bef1f36..3bcb9212 100644
+--- a/libvbr/vbr.h
++++ b/libvbr/vbr.h
+@@ -12,6 +12,16 @@
+ /* system includes */
+ #include <sys/types.h>
+
++#ifdef __STDC__
++# ifndef __P
++# define __P(x) x
++# endif /* ! __P */
++#else /* __STDC__ */
++# ifndef __P
++# define __P(x) ()
++# endif /* ! __P */
++#endif /* __STDC__ */
++
+ /* strings */
+ #define VBR_ALL "all"
+ #define VBR_INFOHEADER "VBR-Info"
+--
+2.27.0
+
diff --git a/mail-filter/opendkim/files/opendkim-2.10.3-lua-pkgconfig.patch b/mail-filter/opendkim/files/opendkim-2.10.3-lua-pkgconfig.patch
new file mode 100644
index 0000000..ee8d576
--- /dev/null
+++ b/mail-filter/opendkim/files/opendkim-2.10.3-lua-pkgconfig.patch
@@ -0,0 +1,174 @@
+From 1f1c947a983c49677544ab08dea3ea04869a8caf Mon Sep 17 00:00:00 2001
+From: Michael Orlitzky <michael@orlitzky.com>
+Date: Sun, 26 Jan 2020 22:29:16 -0500
+Subject: [PATCH 1/1] configure.ac: check for "lua" with pkg-config in addition
+ to "lua5.1".
+
+The upstream Lua pkg-config file is named lua.pc, so unless some
+distribution renames it, OpenDKIM should be looking for "lua"
+and not "lua5.1" in its PKG_CHECK_MODULES call. In any case, we
+should definitely be checking for "lua", so this commit appends it
+to the list of modules we look for. The "lua5.1" module was left
+alone, because I don't know enough of the history to be sure that
+removing it is the right thing to do.
+
+When the call to PKG_CHECK_MODULES fails, OpenDKIM falls back to
+a manual search that looks in /usr/lib, and this can detect 32-bit
+libraries on a 64-bit system. Therefore it is preferable that the
+PKG_CHECK_MODULES call succeed.
+
+In the process of adding this fallback, I realized that some
+additional actions need to be performed in the success branch of
+the existing (and new) PKG_CHECK_MODULES call. The following
+three lines were added,
+
+ AC_SEARCH_LIBS([dlopen], [dl])
+ AC_SUBST([LUA_MANNOTICE], "")
+ AC_DEFINE([USE_LUA], 1, [support for Lua scripting])
+
+to tell various parts of OpenDKIM that we do indeed have Lua support.
+Afterwards, it became clear that those three lines could be factored
+out of *every* lua check, so that has been done as well.
+
+Closes: https://github.com/trusteddomainproject/OpenDKIM/issues/62
+Gentoo-bug: https://bugs.gentoo.org/704556
+---
+ configure.ac | 45 +++++++++++++++++----------------------------
+ 1 file changed, 17 insertions(+), 28 deletions(-)
+
+diff --git a/configure.ac b/configure.ac
+index a478bb83..1d0db41a 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -1495,12 +1495,20 @@ lua_found="no"
+
+ if test \( x"$luapath" = x"auto" -o x"$luapath" = x"yes" \) -a x"$PKG_CONFIG" != x""
+ then
+- PKG_CHECK_MODULES([LIBLUA], [lua5.1],
+- [
+- lua_found="yes"
+- LIBLUA_INCDIRS="$LIBLUA_CFLAGS"
+- ],
+- [AC_MSG_WARN([pkg-config for Lua not found, trying manual search...])])
++ PKG_CHECK_MODULES([LIBLUA], [lua5.1], [
++ LIBLUA_INCDIRS="$LIBLUA_CFLAGS"
++ lua_found="yes"
++ ],
++ [
++ AC_MSG_WARN([pkg-config for lua5.1 not found, trying lua...])
++ PKG_CHECK_MODULES([LIBLUA], [lua], [
++ LIBLUA_INCDIRS="$LIBLUA_CFLAGS"
++ lua_found="yes"
++ ],
++ [AC_MSG_WARN([pkg-config for lua not found, trying manual search...])]
++ )
++ ]
++ )
+ fi
+
+ if test \( x"$luapath" = x"yes" -o x"$luapath" = x"auto" \) -a x"$lua_found" = x"no"
+@@ -1515,10 +1523,6 @@ then
+ LIBLUA_INCDIRS="-I$d/include/lua51"
+ LIBLUA_LIBDIRS="-L$d/lib/lua51"
+ LIBLUA_LIBS="-llua -lm"
+- AC_SEARCH_LIBS([dlopen], [dl])
+- AC_DEFINE([USE_LUA], 1,
+- [support for Lua scripting])
+- AC_SUBST([LUA_MANNOTICE], "")
+ lua_found="yes"
+ break
+ elif test -f $d/include/lua52/lua.h
+@@ -1527,10 +1531,6 @@ then
+ LIBLUA_INCDIRS="-I$d/include/lua52"
+ LIBLUA_LIBDIRS="-L$d/lib/lua52"
+ LIBLUA_LIBS="-llua -lm"
+- AC_SEARCH_LIBS([dlopen], [dl])
+- AC_DEFINE([USE_LUA], 1,
+- [support for Lua scripting])
+- AC_SUBST([LUA_MANNOTICE], "")
+ lua_found="yes"
+ break
+ elif test -f $d/include/lua5.1/lua.h
+@@ -1539,10 +1539,6 @@ then
+ LIBLUA_INCDIRS="-I$d/include/lua5.1"
+ LIBLUA_LIBDIRS="-L$d/lib"
+ LIBLUA_LIBS="-llua5.1 -lm"
+- AC_SEARCH_LIBS([dlopen], [dl])
+- AC_DEFINE([USE_LUA], 1,
+- [support for Lua scripting])
+- AC_SUBST([LUA_MANNOTICE], "")
+ lua_found="yes"
+ break
+ elif test -f $d/include/lua5.2/lua.h
+@@ -1551,10 +1547,6 @@ then
+ LIBLUA_INCDIRS="-I$d/include/lua5.2"
+ LIBLUA_LIBDIRS="-L$d/lib"
+ LIBLUA_LIBS="-llua5.2 -lm"
+- AC_SEARCH_LIBS([dlopen], [dl])
+- AC_DEFINE([USE_LUA], 1,
+- [support for Lua scripting])
+- AC_SUBST([LUA_MANNOTICE], "")
+ lua_found="yes"
+ break
+ elif test -f $d/include/lua.h
+@@ -1563,7 +1555,6 @@ then
+ LIBLUA_INCDIRS="-I$d/include"
+ LIBLUA_LIBDIRS="-L$d/lib"
+ LIBLUA_LIBS="-llua -lm"
+- AC_SEARCH_LIBS([dlopen], [dl])
+ lua_found="yes"
+ break
+ fi
+@@ -1588,7 +1579,6 @@ then
+ LIBLUA_INCDIRS="-I$luapath/include/lua51"
+ LIBLUA_LIBDIRS="-L$luapath/lib/lua51"
+ LIBLUA_LIBS="-llua -lm"
+- AC_SEARCH_LIBS([dlopen], [dl])
+ lua_found="yes"
+ elif test -f $luapath/include/lua52/lua.h
+ then
+@@ -1596,7 +1586,6 @@ then
+ LIBLUA_INCDIRS="-I$luapath/include/lua52"
+ LIBLUA_LIBDIRS="-L$luapath/lib/lua52"
+ LIBLUA_LIBS="-llua -lm"
+- AC_SEARCH_LIBS([dlopen], [dl])
+ lua_found="yes"
+ elif test -f $luapath/include/lua5.1/lua.h
+ then
+@@ -1604,7 +1593,6 @@ then
+ LIBLUA_INCDIRS="-I$luapath/include/lua5.1"
+ LIBLUA_LIBDIRS="-L$luapath/lib"
+ LIBLUA_LIBS="-llua5.1 -lm"
+- AC_SEARCH_LIBS([dlopen], [dl])
+ lua_found="yes"
+ elif test -f $luapath/include/lua5.2/lua.h
+ then
+@@ -1612,7 +1600,6 @@ then
+ LIBLUA_INCDIRS="-I$luapath/include/lua5.2"
+ LIBLUA_LIBDIRS="-L$luapath/lib"
+ LIBLUA_LIBS="-llua5.2 -lm"
+- AC_SEARCH_LIBS([dlopen], [dl])
+ lua_found="yes"
+ elif test -f $luapath/include/lua.h
+ then
+@@ -1620,7 +1607,6 @@ then
+ LIBLUA_INCDIRS="-I$luapath/include"
+ LIBLUA_LIBDIRS="-L$luapath/lib"
+ LIBLUA_LIBS="-llua -lm"
+- AC_SEARCH_LIBS([dlopen], [dl])
+ lua_found="yes"
+ else
+ AC_MSG_ERROR(not found at $luapath)
+@@ -1629,6 +1615,9 @@ fi
+
+ if test x"$lua_found" = x"yes"
+ then
++ AC_SUBST([LUA_MANNOTICE], "")
++ AC_DEFINE([USE_LUA], 1, [support for Lua scripting])
++ AC_SEARCH_LIBS([dlopen], [dl])
+ saved_CPPFLAGS="$CPPFLAGS"
+ CPPFLAGS="$outer_CPPFLAGS $LIBLUA_INCDIRS"
+ AC_MSG_CHECKING([Lua version])
+--
+2.24.1
+
diff --git a/mail-filter/opendkim/files/opendkim-2.10.3-openrc.patch b/mail-filter/opendkim/files/opendkim-2.10.3-openrc.patch
new file mode 100644
index 0000000..b4700e3
--- /dev/null
+++ b/mail-filter/opendkim/files/opendkim-2.10.3-openrc.patch
@@ -0,0 +1,295 @@
+diff --git a/Makefile.am b/Makefile.am
+index ee2d21ab..b085b988 100644
+--- a/Makefile.am
++++ b/Makefile.am
+@@ -39,6 +39,52 @@ DISTCLEANFILES = opendkim-@VERSION@.tar.gz
+ # though.
+ DISTCHECK_CONFIGURE_FLAGS=--enable-vbr --with-lua --enable-stats --with-odbx --with-db --with-openssl=/usr/local --enable-atps --enable-replace_rules
+
++
++#
++# Handle some scripts and configuration files that need @VARIABLE@
++# replacements here, so that we can share the rules (which are
++# identical) between all of the targets.
++#
++
++# We want to *build and install* these on the target machine.
++nodist_doc_DATA = contrib/OpenRC/opendkim.openrc \
++ contrib/systemd/opendkim.service \
++ contrib/systemd/opendkim.tmpfiles \
++ opendkim/opendkim.conf.simple \
++ opendkim/opendkim.conf.simple-verify
++
++# Custom variable to keep the rule below as sane as possible.
++doc_DATA_intermediate = contrib/OpenRC/opendkim.openrc.in
++
++# We want to *ship* these.
++EXTRA_DIST = contrib/OpenRC/opendkim.openrc.in.in \
++ contrib/systemd/opendkim.service.in \
++ 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
++# files. The example is taken from the autoconf documentation and can
++# be found in the "Installation Directory Variables" section.
++edit = sed -e 's|@DOMAIN[@]|$(DOMAIN)|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
++# can do without duplication. At least it's the right kind of wrong,
++# and rebuilds too often rather than not often enough.
++$(nodist_doc_DATA): $(doc_DATA_intermediate) $(EXTRA_DIST) Makefile
++ rm -f $@ $@.tmp
++ srcdir=''; \
++ test -f ./$@.in || srcdir=$(srcdir)/; \
++ $(edit) $${srcdir}$@.in > $@.tmp
++ mv $@.tmp $@
++
++
++
++
+ $(DIST_ARCHIVES): distcheck
+
+ $(DIST_ARCHIVES).md5: $(DIST_ARCHIVES)
+diff --git a/configure.ac b/configure.ac
+index 76914fd9..a478bb83 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -65,6 +65,9 @@ AC_PROG_CC_C99
+ AM_PROG_CC_C_O
+ AC_PROG_LIBTOOL
+
++# Used by the OpenRC service script, at least.
++AC_PROG_GREP
++
+ PKG_PROG_PKG_CONFIG
+
+ #
+@@ -2628,6 +2631,11 @@ AC_SUBST(SPECCONFIGURE)
+ AC_SUBST(SPECREQUIRES)
+ AC_SUBST(SPECBUILDREQUIRES)
+
++# Autoconf 2.70 will support this, and many distros patch it in,
++# but Autoconf 2.70 hasn't actually been released yet.
++AS_IF([test -z "${runstatedir}"], [runstatedir='${localstatedir}/run'])
++AC_SUBST([runstatedir])
++
+ #
+ # Finish up
+ #
+@@ -2639,6 +2647,7 @@ AC_OUTPUT([ Makefile
+ contrib/docs/Makefile
+ contrib/init/Makefile
+ contrib/init/generic/Makefile
++ contrib/OpenRC/opendkim.openrc.in
+ contrib/init/redhat/Makefile
+ contrib/init/redhat/opendkim
+ contrib/init/redhat/opendkim-default-keygen
+@@ -2650,8 +2659,6 @@ AC_OUTPUT([ Makefile
+ contrib/spec/Makefile
+ contrib/spec/opendkim.spec
+ contrib/stats/Makefile
+- contrib/systemd/Makefile
+- contrib/systemd/opendkim.service
+ libopendkim/opendkim.pc libopendkim/Makefile
+ libopendkim/docs/Makefile
+ libopendkim/tests/Makefile
+@@ -2664,8 +2671,6 @@ AC_OUTPUT([ Makefile
+ opendkim/opendkim-lua.3
+ opendkim/opendkim-testkey.8 opendkim/opendkim-stats.8
+ opendkim/opendkim-testmsg.8 opendkim/opendkim.conf.5
+- opendkim/opendkim.conf.simple
+- opendkim/opendkim.conf.simple-verify
+ opendkim/opendkim-atpszone.8 opendkim/opendkim-spam.1
+ opendkim/tests/Makefile
+ stats/Makefile stats/opendkim-importstats.8
+diff --git a/contrib/Makefile.am b/contrib/Makefile.am
+index 76df01cd..401130bb 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 patches repute spec stats
+
+ dist_doc_DATA = README
+diff --git a/contrib/OpenRC/opendkim.openrc.in.in b/contrib/OpenRC/opendkim.openrc.in.in
+new file mode 100644
+index 00000000..4b783615
+--- /dev/null
++++ b/contrib/OpenRC/opendkim.openrc.in.in
+@@ -0,0 +1,54 @@
++#!/sbin/openrc-run
++# Copyright 1999-2019 Gentoo Authors
++# Distributed under the terms of the GNU General Public License v2
++
++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:]]\+[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
++}
+diff --git a/contrib/systemd/Makefile.am b/contrib/systemd/Makefile.am
+deleted file mode 100644
+index 2ffc88cc..00000000
+--- a/contrib/systemd/Makefile.am
++++ /dev/null
+@@ -1,3 +0,0 @@
+-# Copyright (c) 2013, The Trusted Domain Project. All rights reserved.
+-
+-dist_doc_DATA = opendkim.service
+diff --git a/contrib/systemd/opendkim.service.in b/contrib/systemd/opendkim.service.in
+index f7665f43..236f8a06 100644
+--- a/contrib/systemd/opendkim.service.in
++++ b/contrib/systemd/opendkim.service.in
+@@ -1,20 +1,28 @@
+-# If you are using OpenDKIM with SQL datasets it might be necessary to start OpenDKIM after the database servers.
+-# For example, if using both MariaDB and PostgreSQL, change "After=" in the "[Unit]" section to:
+-# After=network.target nss-lookup.target syslog.target mariadb.service postgresql.service
++# If you are using OpenDKIM with SQL datasets, you should start
++# OpenDKIM after your database server. For example, when using
++# PostgreSQL, you should create a supplementary ".conf" file in the
++# appropriate directory containing,
++#
++# [Unit]
++# After=postgresql.service
++#
+
+ [Unit]
+ Description=DomainKeys Identified Mail (DKIM) Milter
+-Documentation=man:opendkim(8) man:opendkim.conf(5) man:opendkim-genkey(8) man:opendkim-genzone(8) man:opendkim-testadsp(8) man:opendkim-testkey http://www.opendkim.org/docs.html
++Documentation=man:opendkim(8) \
++ man:opendkim.conf(5) \
++ man:opendkim-genkey(8) \
++ man:opendkim-genzone(8) \
++ man:opendkim-testkey(8) \
++ http://www.opendkim.org/docs.html
+ After=network.target nss-lookup.target syslog.target
+
+ [Service]
+ Type=forking
+-PIDFile=@localstatedir@/run/opendkim/opendkim.pid
+-EnvironmentFile=-@sysconfdir@/sysconfig/opendkim
+-ExecStart=@sbindir@/opendkim $OPTIONS
++ExecStart=@SBINDIR@/opendkim -P @RUNSTATEDIR@/opendkim.pid
++ExecStartPre=@SBINDIR@/opendkim -P @RUNSTATEDIR@/opendkim.pid -n -f
+ ExecReload=/bin/kill -USR1 $MAINPID
+-User=opendkim
+-Group=opendkim
++PIDFile=@RUNSTATEDIR@/opendkim.pid
+
+ [Install]
+ WantedBy=multi-user.target
+diff --git a/contrib/systemd/opendkim.tmpfiles.in b/contrib/systemd/opendkim.tmpfiles.in
+new file mode 100644
+index 00000000..a9118974
+--- /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
+diff --git a/opendkim/Makefile.am b/opendkim/Makefile.am
+index 4aa615c1..7d514771 100644
+--- a/opendkim/Makefile.am
++++ b/opendkim/Makefile.am
+@@ -16,9 +16,11 @@ endif
+ sbin_PROGRAMS += opendkim-stats
+ endif
+
++
+ dist_sbin_SCRIPTS = opendkim-genkey
+-dist_doc_DATA = opendkim.conf.sample opendkim.conf.simple \
+- opendkim.conf.simple-verify README.SQL
++
++dist_doc_DATA = opendkim.conf.sample README.SQL
++
+
+ if BUILD_FILTER
+ sbin_PROGRAMS += opendkim
+diff --git a/opendkim/opendkim.conf.simple-verify.in b/opendkim/opendkim.conf.simple-verify.in
+index 2224b64f..463048ab 100644
+--- a/opendkim/opendkim.conf.simple-verify.in
++++ b/opendkim/opendkim.conf.simple-verify.in
+@@ -17,5 +17,5 @@ Mode v
+
+ # ADSPDiscard no
+
+-# PidFile /var/run/opendkim/opendkim.pid
++# PidFile @RUNSTATEDIR@/opendkim.pid
+
+diff --git a/opendkim/opendkim.conf.simple.in b/opendkim/opendkim.conf.simple.in
+index 735b924b..b70bfb46 100644
+--- a/opendkim/opendkim.conf.simple.in
++++ b/opendkim/opendkim.conf.simple.in
+@@ -12,6 +12,12 @@ KeyFile /var/db/dkim/@DOMAIN@.private
+
+ Socket inet:8891@localhost
+
++# To use a local socket instead, specify a path here. The "standard"
++# location is under @RUNSTATEDIR@/opendkim, and it's best to agree
++# on that directory so that various init systems can configure its
++# permissions and ownership automatically.
++#Socket local:@RUNSTATEDIR@/opendkim/opendkim.sock
++
+ ReportAddress postmaster@@DOMAIN@
+ SendReports yes
+
+@@ -25,4 +31,4 @@ SendReports yes
+ #
+ # PeerList X.X.X.X
+
+-# PidFile /var/run/opendkim/opendkim.pid
++# PidFile @RUNSTATEDIR@/opendkim.pid
diff --git a/mail-filter/opendkim/files/opendkim-2.10.3-openssl-1.1.1.patch.r2 b/mail-filter/opendkim/files/opendkim-2.10.3-openssl-1.1.1.patch.r2
new file mode 100644
index 0000000..cc8f48b
--- /dev/null
+++ b/mail-filter/opendkim/files/opendkim-2.10.3-openssl-1.1.1.patch.r2
@@ -0,0 +1,170 @@
+From FreeBSD: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=223568
+--- a/configure.ac 2015-05-12 18:43:09 UTC
++++ b/configure.ac
+@@ -860,26 +860,28 @@ then
+ AC_SEARCH_LIBS([ERR_peek_error], [crypto], ,
+ AC_MSG_ERROR([libcrypto not found]))
+
+- AC_SEARCH_LIBS([SSL_library_init], [ssl], ,
+- [
+- if test x"$enable_shared" = x"yes"
+- then
+- AC_MSG_ERROR([Cannot build shared opendkim
+- against static openssl libraries.
+- Configure with --disable-shared
+- to get this working or obtain a
+- shared libssl library for
+- opendkim to use.])
+- fi
+
+- # avoid caching issue - last result of SSL_library_init
+- # shouldn't be cached for this next check
+- unset ac_cv_search_SSL_library_init
+- LIBCRYPTO_LIBS="$LIBCRYPTO_LIBS -ldl"
+- AC_SEARCH_LIBS([SSL_library_init], [ssl], ,
+- AC_MSG_ERROR([libssl not found]), [-ldl])
+- ]
+- )
++ AC_LINK_IFELSE(
++ [AC_LANG_PROGRAM([[#include <openssl/ssl.h>]],
++ [[SSL_library_init();]])],
++ [od_have_ossl="yes";],
++ [od_have_ossl="no";])
++ if test x"$od_have_ossl" = x"no"
++ then
++ if test x"$enable_shared" = x"yes"
++ then
++ AC_MSG_ERROR([Cannot build shared opendkim
++ against static openssl libraries.
++ Configure with --disable-shared
++ to get this working or obtain a
++ shared libssl library for
++ opendkim to use.])
++ fi
++
++ LIBCRYPTO_LIBS="$LIBCRYPTO_LIBS -ldl"
++ AC_SEARCH_LIBS([SSL_library_init], [ssl], ,
++ AC_MSG_ERROR([libssl not found]), [-ldl])
++ fi
+
+ AC_CHECK_DECL([SHA256_DIGEST_LENGTH],
+ AC_DEFINE([HAVE_SHA256], 1,
+--- a/libopendkim/tests/Makefile.in 2015-05-12 18:43:48 UTC
++++ b/libopendkim/tests/Makefile.in
+@@ -1108,8 +1108,10 @@ am__nobase_list = $(am__nobase_strip_setup); \
+ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
+ END { for (dir in files) print dir, files[dir] }'
+ am__base_list = \
+- sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
+- sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
++ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\
++/ /g' | \
++ sed '$$!N;$$!N;$$!N;$$!N;s/\
++/ /g'
+ am__uninstall_files_from_dir = { \
+ test -z "$$files" \
+ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \
+@@ -4131,16 +4133,19 @@ uninstall-am: uninstall-dist_docDATA
+ @LCOV_TRUE@description.txt: $(check_PROGRAMS) $(check_SCRIPTS)
+ @LCOV_TRUE@ rm -f $@
+ @LCOV_TRUE@ for i in $(check_PROGRAMS); do \
+-@LCOV_TRUE@ testname=$${i/t-}; \
+-@LCOV_TRUE@ testname=$${testname//-/_}; \
++@LCOV_TRUE@ testname=$${i#t-}; \
++@LCOV_TRUE@ testname=$$(echo $${testname} | sed -e 's/-/_/g'); \
+ @LCOV_TRUE@ fgrep '***' $$i.c | tail -n 1 | \
+-@LCOV_TRUE@ (echo $${testname} ; sed -e 's/[^*]*\*\*\*\(.*\)\\n.*/\t\1\n/g' ) >> $@; \
++@LCOV_TRUE@ (echo $${testname} ; sed -e 's/[^*]*\*\*\*\(.*\)\\
++@LCOV_TRUE@.*/ \1\
++@LCOV_TRUE@/g' ) >> $@; \
+ @LCOV_TRUE@ done
+ @LCOV_TRUE@ for i in $(check_SCRIPTS); do \
+-@LCOV_TRUE@ testname=$${i/t-}; \
+-@LCOV_TRUE@ testname=$${testname//-/_}; \
++@LCOV_TRUE@ testname=$${i#t-}; \
++@LCOV_TRUE@ testname=$$(echo $${testname} | sed -e 's/-/_/g'); \
+ @LCOV_TRUE@ grep '^#' $$i | tail -n 1 | \
+-@LCOV_TRUE@ (echo $${testname} ; sed -e 's/^# \(.*\)/\t\1\n/g' ) >> $@; \
++@LCOV_TRUE@ (echo $${testname} ; sed -e 's/^# \(.*\)/ \1\
++@LCOV_TRUE@/g' ) >> $@; \
+ @LCOV_TRUE@ done
+
+ @LCOV_TRUE@description.html: description.txt
+--- a/libopendkim/dkim-canon.c 2015-05-11 03:56:13 UTC
++++ b/libopendkim/dkim-canon.c
+@@ -388,7 +388,7 @@ dkim_canon_header_string(struct dkim_dstring *dstr, dk
+ }
+
+ /* skip all spaces before first word */
+- while (*p != '\0' && DKIM_ISWSP(*p))
++ while (*p != '\0' && DKIM_ISLWSP(*p))
+ p++;
+
+ space = FALSE; /* just saw a space */
+--- a/opendkim/tests/Makefile.in 2015-05-12 18:43:49 UTC
++++ b/opendkim/tests/Makefile.in
+@@ -139,8 +139,10 @@ am__nobase_list = $(am__nobase_strip_setup); \
+ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
+ END { for (dir in files) print dir, files[dir] }'
+ am__base_list = \
+- sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
+- sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
++ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\
++/ /g' | \
++ sed '$$!N;$$!N;$$!N;$$!N;s/\
++/ /g'
+ am__uninstall_files_from_dir = { \
+ test -z "$$files" \
+ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \
+@@ -1298,14 +1300,16 @@ uninstall-am: uninstall-dist_docDATA
+ @LCOV_TRUE@description.txt: $(check_SCRIPTS)
+ @LCOV_TRUE@ rm -f $@
+ @LCOV_TRUE@ for test in $? ; do \
+-@LCOV_TRUE@ testname=$${test/t-}; \
+-@LCOV_TRUE@ testname=$${testname//-/_}; \
++@LCOV_TRUE@ testname=$${test#t-}; \
++@LCOV_TRUE@ testname=$$(echo $${testname} | sed -e 's/-/_/g'); \
+ @LCOV_TRUE@ grep ^# $$test | tail -n 1 | \
+-@LCOV_TRUE@ sed -e "s/^#\(.*\)/$${testname}\n\t\1\n/g" >> $@; \
++@LCOV_TRUE@ sed -e "s/^#\(.*\)/$${testname}\
++@LCOV_TRUE@ \1\
++@LCOV_TRUE@/g" >> $@; \
+ @LCOV_TRUE@ done
+
+ @LCOV_TRUE@description.html: description.txt
+-@LCOV_TRUE@ gendesc --output $@ $<
++@LCOV_TRUE@ gendesc --output $@ $?
+
+ @LCOV_TRUE@maintainer-clean-local:
+ @LCOV_TRUE@ -rm -rf lcov/[^C]*
+--- a/opendkim/opendkim-crypto.c 2013-02-25 21:02:41 UTC
++++ b/opendkim/opendkim-crypto.c
+@@ -222,7 +222,11 @@ dkimf_crypto_free_id(void *ptr)
+ {
+ assert(pthread_setspecific(id_key, ptr) == 0);
+
++#if OPENSSL_VERSION_NUMBER >= 0x10100000 && !defined (LIBRESSL_VERSION_NUMBER)
++ OPENSSL_thread_stop();
++#else
+ ERR_remove_state(0);
++#endif
+
+ free(ptr);
+
+@@ -392,11 +396,15 @@ dkimf_crypto_free(void)
+ {
+ if (crypto_init_done)
+ {
++#if OPENSSL_VERSION_NUMBER >= 0x10100000 && !defined (LIBRESSL_VERSION_NUMBER)
++ OPENSSL_thread_stop();
++#else
+ CRYPTO_cleanup_all_ex_data();
+ CONF_modules_free();
+ EVP_cleanup();
+ ERR_free_strings();
+ ERR_remove_state(0);
++#endif
+
+ if (nmutexes > 0)
+ {
+
diff --git a/mail-filter/opendkim/metadata.xml b/mail-filter/opendkim/metadata.xml
new file mode 100644
index 0000000..224c3bd
--- /dev/null
+++ b/mail-filter/opendkim/metadata.xml
@@ -0,0 +1,72 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
+<pkgmetadata>
+
+ <maintainer type="person">
+ <email>gentoo@seichter.de</email>
+ <name>Ralph Seichter</name>
+ </maintainer>
+
+ <maintainer type="person">
+ <email>klondike@gentoo.org</email>
+ <name>Francisco Blas Izquierdo Riera</name>
+ </maintainer>
+
+ <maintainer type="person">
+ <email>mjo@gentoo.org</email>
+ <name>Michael Orlitzky</name>
+ </maintainer>
+
+ <maintainer type="project">
+ <email>proxy-maint@gentoo.org</email>
+ <name>Proxy Maintainers</name>
+ </maintainer>
+
+ <longdescription>
+ A program implementing the Milter API that signs and verifies
+ using the DKIM standard. This is a fork of Sendmail's DKIM-milter
+ </longdescription>
+ <use>
+ <flag name="unbound">
+ Use the unbound dnssec library to perform DKIM DNS
+ queries.
+ </flag>
+ <flag name="opendbx">
+ Use opendbx backend to facilitate dataset driven OpenDKIM
+ configuration options like stats, bodylengthdb, etc. against a
+ wide variety of database types
+ </flag>
+ <flag name="sasl">
+ Used to authenticate to a LDAP server in various ways if
+ required.
+ </flag>
+ <flag name="ldap">
+ Enable openldap as a dataset facilitator or keys, determining
+ domains to sign for, and any other dataset that opendkim
+ supports.
+ </flag>
+ <flag name="lua">
+ Enables control over signature verification, filtering and
+ policy to be controlled by user defined lua scripts.
+ </flag>
+ <flag name="poll">
+ Use poll() instead of select() for the provided asynchronous
+ resolver library.
+ </flag>
+ <flag name="memcached">
+ Add support for using <pkg>dev-libs/libmemcached</pkg>
+ </flag>
+ <flag name="lmdb">
+ Add support for using <pkg>dev-db/lmdb</pkg>
+ </flag>
+ <flag name="querycache">
+ Add support for query caching (requires 'berkdb' flag)
+ </flag>
+ <flag name="stats">
+ Add support for statistics (requires 'opendbx' flag)
+ </flag>
+ </use>
+ <upstream>
+ <remote-id type="sourceforge">opendkim</remote-id>
+ </upstream>
+</pkgmetadata>
diff --git a/mail-filter/opendkim/opendkim-2.10.3-r18.ebuild b/mail-filter/opendkim/opendkim-2.10.3-r18.ebuild
new file mode 100644
index 0000000..f204ea3
--- /dev/null
+++ b/mail-filter/opendkim/opendkim-2.10.3-r18.ebuild
@@ -0,0 +1,229 @@
+# Copyright 1999-2020 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=7
+
+inherit autotools db-use eutils systemd tmpfiles
+
+DESCRIPTION="A milter providing DKIM signing and verification"
+HOMEPAGE="http://opendkim.org/"
+SRC_URI="https://downloads.sourceforge.net/project/opendkim/${P}.tar.gz"
+
+# The GPL-2 is for the init script, bug 425960.
+LICENSE="BSD GPL-2 Sendmail-Open-Source"
+SLOT="0"
+KEYWORDS="amd64 ~arm x86"
+IUSE="berkdb ldap libressl lmdb lua memcached opendbx poll sasl selinux +ssl static-libs stats querycache test unbound"
+
+BDEPEND="acct-user/opendkim
+ test? ( dev-lang/lua:* )"
+
+COMMON_DEPEND="|| ( mail-filter/libmilter mail-mta/sendmail )
+ dev-libs/libbsd
+ sys-apps/grep
+ ssl? (
+ !libressl? ( dev-libs/openssl:0= )
+ libressl? ( dev-libs/libressl:0= )
+ )
+ berkdb? ( >=sys-libs/db-3.2:* )
+ opendbx? ( >=dev-db/opendbx-1.4.0 )
+ lua? ( dev-lang/lua:* )
+ ldap? ( net-nds/openldap )
+ lmdb? ( dev-db/lmdb )
+ memcached? ( dev-libs/libmemcached )
+ sasl? ( dev-libs/cyrus-sasl )
+ unbound? ( >=net-dns/unbound-1.4.1:= net-dns/dnssec-root )
+ !unbound? ( net-libs/ldns )"
+
+DEPEND="${COMMON_DEPEND}"
+
+RDEPEND="${COMMON_DEPEND}
+ acct-user/opendkim
+ sys-process/psmisc
+ selinux? ( sec-policy/selinux-dkim )"
+
+REQUIRED_USE="sasl? ( ldap )
+ stats? ( opendbx )
+ querycache? ( berkdb )"
+RESTRICT="!test? ( test )"
+
+PATCHES=(
+ "${FILESDIR}/${P}-openrc.patch"
+ "${FILESDIR}/${P}-openssl-1.1.1.patch.r2"
+ "${FILESDIR}/${P}-lua-pkgconfig.patch"
+ "${FILESDIR}/${P}-define-P-macro-in-libvbr.patch"
+)
+
+src_prepare() {
+ default
+
+ sed -e 's:/var/db/dkim:/var/lib/opendkim:g' \
+ -i opendkim/opendkim.conf.sample opendkim/opendkim.conf.simple.in \
+ || die
+ sed -e 's:dist_doc_DATA:dist_html_DATA:' \
+ -i libopendkim/docs/Makefile.am \
+ || die
+ eautoreconf
+}
+
+src_configure() {
+ local myconf=()
+ if use berkdb ; then
+ myconf+=( --with-db-incdir=$(db_includedir) )
+ fi
+ if use unbound; then
+ myconf+=( --with-unbound )
+ else
+ myconf+=( --with-ldns )
+ fi
+ if use ldap; then
+ myconf+=( $(use_with sasl) )
+ fi
+
+ # We install the our configuration filed under e.g. /etc/opendkim,
+ # so the next line is necessary to point the daemon and all of its
+ # documentation to the right location by default.
+ myconf+=( --sysconfdir="${EPREFIX}/etc/${PN}" )
+
+ econf \
+ $(use_with berkdb db) \
+ $(use_with opendbx odbx) \
+ $(use_with lua) \
+ $(use_enable lua rbl) \
+ $(use_with ldap openldap) \
+ $(use_with lmdb) \
+ $(use_enable poll) \
+ $(use_enable querycache query_cache) \
+ $(use_enable static-libs static) \
+ $(use_enable stats) \
+ $(use_with memcached libmemcached) \
+ "${myconf[@]}" \
+ --enable-filter \
+ --enable-atps \
+ --enable-identity_header \
+ --enable-rate_limit \
+ --enable-resign \
+ --enable-replace_rules \
+ --enable-default_sender \
+ --enable-sender_macro \
+ --disable-live-testing \
+ --with-test-socket="${T}/opendkim.sock"
+}
+
+src_compile() {
+ emake runstatedir=/run
+}
+
+src_install() {
+ default
+ find "${D}" -name '*.la' -type f -delete || die
+
+ dosbin stats/opendkim-reportstats
+
+ newinitd "${S}/contrib/OpenRC/opendkim.openrc" "${PN}"
+ systemd_newtmpfilesd "${S}/contrib/systemd/opendkim.tmpfiles" "${PN}.conf"
+ systemd_newunit "contrib/systemd/opendkim.service" "${PN}.service"
+
+ dodir /etc/opendkim
+ keepdir /var/lib/opendkim
+
+ # The OpenDKIM data (particularly, your keys) should be read-only to
+ # the UserID that the daemon runs as.
+ fowners root:opendkim /var/lib/opendkim
+ fperms 750 /var/lib/opendkim
+
+ # Tweak the "simple" example configuration a bit before installing
+ # it unconditionally.
+ local cf="${T}/opendkim.conf"
+ # Some MTAs are known to break DKIM signatures with "simple"
+ # canonicalization [1], so we choose the "relaxed" policy
+ # over OpenDKIM's current default settings.
+ # [1] https://wordtothewise.com/2016/12/dkim-canonicalization-or-why-microsoft-breaks-your-mail/
+ sed -E -e 's:^(Canonicalization)[[:space:]]+.*:\1\trelaxed/relaxed:' \
+ "${S}/opendkim/opendkim.conf.simple" >"${cf}" || die
+ cat >>"${cf}" <<EOT || die
+
+# The UMask is really only used for the PID file (root:root) and the
+# local UNIX socket, if you're using one. It should be 0117 for the
+# socket.
+UMask 0117
+UserID opendkim
+
+# For use with unbound
+#TrustAnchorFile /etc/dnssec/root-anchors.txt
+EOT
+ insinto /etc/opendkim
+ doins "${cf}"
+}
+
+pkg_postinst() {
+ tmpfiles_process "${PN}.conf"
+ if [[ -z ${REPLACING_VERSION} ]]; then
+ elog "If you want to sign your mail messages and need some help"
+ elog "please run:"
+ elog " emerge --config ${CATEGORY}/${PN}"
+ elog "It will help you create your key and give you hints on how"
+ elog "to configure your DNS and MTA."
+
+ elog "If you are using a local (UNIX) socket, then you will"
+ elog "need to make sure that your MTA has read/write access"
+ elog "to the socket file. This is best accomplished by creating"
+ elog "a completely-new group with only your MTA user and the"
+ elog "\"opendkim\" user in it. Step-by-step instructions can be"
+ elog "found on our Wiki, at https://wiki.gentoo.org/wiki/OpenDKIM ."
+ else
+ ewarn "The user account for the OpenDKIM daemon has changed"
+ ewarn "from \"milter\" to \"opendkim\" to prevent unrelated services"
+ ewarn "from being able to read your private keys. You should"
+ ewarn "adjust your existing configuration to use the \"opendkim\""
+ ewarn "user and group, and change the permissions on"
+ ewarn "${ROOT}/var/lib/opendkim to root:opendkim with mode 0750."
+ ewarn "The owner and group of the files within that directory"
+ ewarn "will likely need to be adjusted as well."
+ fi
+}
+
+pkg_config() {
+ local selector keysize pubkey
+
+ read -p "Enter the selector name (default ${HOSTNAME}): " selector
+ [[ -n "${selector}" ]] || selector="${HOSTNAME}"
+ if [[ -z "${selector}" ]]; then
+ eerror "Oddly enough, you don't have a HOSTNAME."
+ return 1
+ fi
+ if [[ -f "${ROOT}/var/lib/opendkim/${selector}.private" ]]; then
+ ewarn "The private key for this selector already exists."
+ else
+ keysize=1024
+ # Generate the private and public keys. Note that opendkim-genkeys
+ # sets umask=077 on its own to keep these safe. However, we want
+ # them to be readable (only!) to the opendkim user, and we manage
+ # that by changing their groups and making everything group-readable.
+ opendkim-genkey -b ${keysize} -D "${ROOT}/var/lib/opendkim/" \
+ -s "${selector}" -d '(your domain)' && \
+ chgrp --no-dereference opendkim \
+ "${ROOT}/var/lib/opendkim/${selector}".{private,txt} || \
+ { eerror "Failed to create private and public keys."; return 1; }
+ chmod g+r "${ROOT}/var/lib/opendkim/${selector}".{private,txt}
+ fi
+
+ # opendkim selector configuration
+ echo
+ einfo "Make sure you have the following settings in your /etc/opendkim/opendkim.conf:"
+ einfo " Keyfile /var/lib/opendkim/${selector}.private"
+ einfo " Selector ${selector}"
+
+ # MTA configuration
+ echo
+ einfo "If you are using Postfix, add following lines to your main.cf:"
+ einfo " smtpd_milters = unix:/run/opendkim/opendkim.sock"
+ einfo " non_smtpd_milters = unix:/run/opendkim/opendkim.sock"
+ einfo " and read http://www.postfix.org/MILTER_README.html"
+
+ # DNS configuration
+ einfo "After you configured your MTA, publish your key by adding this TXT record to your domain:"
+ cat "${ROOT}/var/lib/opendkim/${selector}.txt"
+ einfo "t=y signifies you only test the DKIM on your domain. See following page for the complete list of tags:"
+ einfo " http://www.dkim.org/specs/rfc4871-dkimbase.html#key-text"
+}