diff options
Diffstat (limited to 'mail-filter/opendkim')
-rw-r--r-- | mail-filter/opendkim/files/opendkim-2.10.3-c-std.patch | 155 | ||||
-rw-r--r-- | mail-filter/opendkim/files/opendkim-2.10.3-fix-ldap-sasl-pc.patch | 69 | ||||
-rw-r--r-- | mail-filter/opendkim/files/opendkim-2.10.3-incompatible-pointer-types.patch | 32 | ||||
-rw-r--r-- | mail-filter/opendkim/files/opendkim-2.10.3-snprintf-include.patch | 27 | ||||
-rw-r--r-- | mail-filter/opendkim/metadata.xml | 7 | ||||
-rw-r--r-- | mail-filter/opendkim/opendkim-2.10.3-r30.ebuild (renamed from mail-filter/opendkim/opendkim-2.10.3-r26.ebuild) | 20 | ||||
-rw-r--r-- | mail-filter/opendkim/opendkim-2.10.3-r31.ebuild | 253 |
7 files changed, 547 insertions, 16 deletions
diff --git a/mail-filter/opendkim/files/opendkim-2.10.3-c-std.patch b/mail-filter/opendkim/files/opendkim-2.10.3-c-std.patch new file mode 100644 index 000000000000..08df8eb0b03b --- /dev/null +++ b/mail-filter/opendkim/files/opendkim-2.10.3-c-std.patch @@ -0,0 +1,155 @@ +From 2d6db0225da9632ddf25aa70839d9d6244af6a42 Mon Sep 17 00:00:00 2001 +From: Michael Orlitzky <michael@orlitzky.com> +Date: Thu, 23 Feb 2023 17:37:33 -0500 +Subject: [PATCH 1/1] configure.ac: update main() signatures to conform to the + standard. + +There are some tests in configure.ac that contain, + + int main() { ... } + +That's not the correct signature for main() according to the C +standard, and newer compilers are going to reject it. More information +about this can be found at, + + https://wiki.gentoo.org/wiki/Modern_C_porting + +In this case, the fix is simply to write + + int main(int argc, char** argv) { ... } + +instead. +--- + configure.ac | 14 +++++++------- + 1 file changed, 7 insertions(+), 7 deletions(-) + +diff --git a/configure.ac b/configure.ac +index 1eaa95d8..d8162303 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -147,7 +147,7 @@ dnscheck=' + #include <netinet/in.h> + #include <arpa/nameser.h> + #include <resolv.h> +-int main() { ++int main(int argc, char** argv) { + res_mkquery (0, 0, 0, 0, 0, 0, 0, 0, 0); + dn_expand (0, 0, 0, 0, 0); + dn_skipname (0, 0); +@@ -549,7 +549,7 @@ gprof_gmon_out="unknown" + if test x"$hasgprof" = x"yes" + then + gprofcheck=' +-int main() { ++int main(int argc, char** argv) { + long x; + + x = random(); +@@ -747,7 +747,7 @@ then + #if GNUTLS_VERSION_NUMBER < 0x020b07 + # error GnuTLS 2.11.7 or later required + #endif +- int main() ++ int main(int argc, char** argv) + { + return 0; + }' +@@ -759,7 +759,7 @@ then + + sha256check=' + #include <gnutls/gnutls.h> +- int main() ++ int main(int argc, char** argv) + { + int x = GNUTLS_DIG_SHA256; + }' +@@ -1191,7 +1191,7 @@ then + #include <libmemcached/memcached.h> + + int +-main() ++main(int argc, char** argv) + { + memcached_return_t x; + +@@ -1649,7 +1649,7 @@ then + #endif + + int +-main() ++main(int argc, char** argv) + { + return 0; + } +@@ -1859,7 +1859,7 @@ then + #endif + + int +-main() ++main(int argc, char** argv) + { + return 0; + } +-- +2.39.2 + +From 1f551737e838723f9ad9be1692bb12a9a3b4cdd9 Mon Sep 17 00:00:00 2001 +From: Michael Orlitzky <michael@orlitzky.com> +Date: Thu, 23 Feb 2023 18:15:50 -0500 +Subject: [PATCH 2/2] libvbr/vbr.c: modernize vbr_strlcpy() signature. + +The vbr_strlcpy() function declares that its arguments should live in +registers: + + vbr_strlcpy(dst, src, size) + register char *dst; + register const char *src; + ssize_t size; + { + ... + +This makes GCC unhappy when -Werror=strict-prototypes is used: + + vbr.c:167:1: error: function declaration isn't a prototype + [-Werror=strict-prototypes] + 167 | vbr_strlcpy(dst, src, size) + +The "register" keyword is largely obsolete on modern systems anyway, +since the compiler is better at determining how to move memory around +than the programmer is. So to appease GCC and simplify the code a bit, +the signature has been changed to, + + vbr_strlcpy(char *dst, const char *src, ssize_t size) { ... } + +changes. Lines starting # with '#' will be ignored, and an empty +message aborts the commit. # # On branch configure.ac-c-standard # +Your branch is up to date with 'origin/configure.ac-c-standard'. # # +Changes to be committed: # modified: libvbr/vbr.c # # Changes not +staged for commit: # modified: configure # # Untracked files: # +0000-cover-letter.patch # +--- + libvbr/vbr.c | 7 ++----- + 1 file changed, 2 insertions(+), 5 deletions(-) + +diff --git a/libvbr/vbr.c b/libvbr/vbr.c +index cb9124d7..c6a2439f 100644 +--- a/libvbr/vbr.c ++++ b/libvbr/vbr.c +@@ -164,12 +164,9 @@ static void vbr_error __P((VBR *, const char *, ...)); + */ + + size_t +-vbr_strlcpy(dst, src, size) +- register char *dst; +- register const char *src; +- ssize_t size; ++vbr_strlcpy(char *dst, const char *src, ssize_t size) + { +- register ssize_t i; ++ ssize_t i; + + if (size-- <= 0) + return strlen(src); +-- +2.39.2 + diff --git a/mail-filter/opendkim/files/opendkim-2.10.3-fix-ldap-sasl-pc.patch b/mail-filter/opendkim/files/opendkim-2.10.3-fix-ldap-sasl-pc.patch new file mode 100644 index 000000000000..9375d3c8bab9 --- /dev/null +++ b/mail-filter/opendkim/files/opendkim-2.10.3-fix-ldap-sasl-pc.patch @@ -0,0 +1,69 @@ +From f203e0a001468cd30a0a3b780c90f0f90cdc35b8 Mon Sep 17 00:00:00 2001 +From: Michael Orlitzky <michael@orlitzky.com> +Date: Sat, 2 Dec 2023 18:44:20 -0500 +Subject: [PATCH 1/2] configure.ac: update OpenLDAP's pkgconfig name + +OpenLDAP provides the file ldap.pc for its libldap library. This can +be verified via libraries/libldap/ldap.pc.in in the repository, + + https://git.openldap.org/openldap/openldap/-/blob/master/ + +Our ./configure script checks instead for the name "openldap", which +at some point may have been correct, but no longer works. We switch to +"ldap" so that we can locate the upstream file. + +On some platforms (https://bugs.gentoo.org/918512) this will fix a +linking error. Thanks to Chris Pritchard for the report and the +diagnosis. +--- + configure.ac | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/configure.ac b/configure.ac +index 1eaa95d8..b8353077 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -1800,7 +1800,7 @@ OPENLDAP_LIBS="" + if test \( x"$ldappath" = x"auto" -o x"$ldappath" = x"yes" \) -a \ + x"$PKG_CONFIG" != x"" + then +- PKG_CHECK_MODULES([OPENLDAP], [openldap >= 2.0.0], ++ PKG_CHECK_MODULES([OPENLDAP], [ldap >= 2.0.0], + [ + ldap_found="yes" + OPENLDAP_CPPFLAGS="$OPENLDAP_CFLAGS" + +From 12b1403eea40f3df59ef130a28164f16d08053fc Mon Sep 17 00:00:00 2001 +From: Michael Orlitzky <michael@orlitzky.com> +Date: Sat, 2 Dec 2023 18:52:09 -0500 +Subject: [PATCH 2/2] configure.ac: update Cyrus SASL's pkgconfig name + +Cyrus SASL provides the file libsasl2.pc for its libsasl2 +library. This can be verified in its git repository: + + https://github.com/cyrusimap/cyrus-sasl/blob/master/libsasl2.pc.in + +Our ./configure script checks instead for the name "cyrussasl", which +at some point may have been correct, but no longer works. We switch to +"libsasl2" so that we can locate the upstream file. + +On some platforms (https://bugs.gentoo.org/918512) this will fix a +linking error. Thanks to Chris Pritchard for the report and the +diagnosis. +--- + configure.ac | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/configure.ac b/configure.ac +index b8353077..071e8511 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -1890,7 +1890,7 @@ sasl_found="no" + if test \( x"$saslpath" = x"auto" -o x"$saslpath" = x"yes" \) -a \ + x"$PKG_CONFIG" != x"" + then +- PKG_CHECK_MODULES([SASL], [cyrussasl >= 2.1.0], ++ PKG_CHECK_MODULES([SASL], [libsasl2 >= 2.1.0], + [ + sasl_found="yes" + SASL_CPPFLAGS="$SASL_CFLAGS" diff --git a/mail-filter/opendkim/files/opendkim-2.10.3-incompatible-pointer-types.patch b/mail-filter/opendkim/files/opendkim-2.10.3-incompatible-pointer-types.patch new file mode 100644 index 000000000000..638d2b8b22bd --- /dev/null +++ b/mail-filter/opendkim/files/opendkim-2.10.3-incompatible-pointer-types.patch @@ -0,0 +1,32 @@ +From 514ed1085d7399f7fe3bb53e6ae4693168dd0ab9 Mon Sep 17 00:00:00 2001 +From: Michael Orlitzky <michael@orlitzky.com> +Date: Mon, 22 Apr 2024 07:37:40 -0400 +Subject: [PATCH] opendkim/opendkim.c: add two missing dkimf_dstring_get() + calls + +This fixes the build with CFLAGS="-Werror=incompatible-pointer-types", +which some newer compilers are planning to make default. + +Gentoo-Bug: https://bugs.gentoo.org/919366 +--- + opendkim/opendkim.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/opendkim/opendkim.c b/opendkim/opendkim.c +index d4229e8f..93d05a1e 100644 +--- a/opendkim/opendkim.c ++++ b/opendkim/opendkim.c +@@ -11656,8 +11656,8 @@ mlfi_eoh(SMFICTX *ctx) + (status != 0 || user == NULL || domain == NULL || + user[0] == '\0' || domain[0] == '\0')) + { +- strlcpy(addr, conf->conf_defsender, sizeof addr); +- status = dkim_mail_parse(addr, &user, &domain); ++ strlcpy(dkimf_dstring_get(addr), conf->conf_defsender, sizeof addr); ++ status = dkim_mail_parse(dkimf_dstring_get(addr), &user, &domain); + } + #endif /* _FFR_DEFAULT_SENDER */ + +-- +2.43.2 + diff --git a/mail-filter/opendkim/files/opendkim-2.10.3-snprintf-include.patch b/mail-filter/opendkim/files/opendkim-2.10.3-snprintf-include.patch new file mode 100644 index 000000000000..5cbe24b02cdb --- /dev/null +++ b/mail-filter/opendkim/files/opendkim-2.10.3-snprintf-include.patch @@ -0,0 +1,27 @@ +From 706554992156dd655e893268f201bbecbe283eb5 Mon Sep 17 00:00:00 2001 +From: Michael Orlitzky <michael@orlitzky.com> +Date: Thu, 23 Feb 2023 17:05:36 -0500 +Subject: [PATCH 1/1] libopendkim/util.c: include stdio.h for snprintf. + +This fixes a build failure on musl, reported at + + https://bugs.gentoo.org/896048 +--- + libopendkim/util.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/libopendkim/util.c b/libopendkim/util.c +index 6792b169..b1c6a769 100644 +--- a/libopendkim/util.c ++++ b/libopendkim/util.c +@@ -17,6 +17,7 @@ + # include <stdbool.h> + #endif /* HAVE_STDBOOL_H */ + #include <ctype.h> ++#include <stdio.h> + #include <assert.h> + #include <string.h> + #include <errno.h> +-- +2.39.2 + diff --git a/mail-filter/opendkim/metadata.xml b/mail-filter/opendkim/metadata.xml index a758a44a6e66..90a7b4f2c7b0 100644 --- a/mail-filter/opendkim/metadata.xml +++ b/mail-filter/opendkim/metadata.xml @@ -1,10 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd"> +<!DOCTYPE pkgmetadata SYSTEM "https://www.gentoo.org/dtd/metadata.dtd"> <pkgmetadata> - <maintainer type="person" proxied="yes"> - <email>klondike@gentoo.org</email> - <name>Francisco Blas Izquierdo Riera</name> - </maintainer> <maintainer type="person"> <email>mjo@gentoo.org</email> <name>Michael Orlitzky</name> @@ -55,5 +51,6 @@ </use> <upstream> <remote-id type="sourceforge">opendkim</remote-id> + <remote-id type="github">trusteddomainproject/OpenDKIM</remote-id> </upstream> </pkgmetadata> diff --git a/mail-filter/opendkim/opendkim-2.10.3-r26.ebuild b/mail-filter/opendkim/opendkim-2.10.3-r30.ebuild index d678d4120cc4..b689770a7ba0 100644 --- a/mail-filter/opendkim/opendkim-2.10.3-r26.ebuild +++ b/mail-filter/opendkim/opendkim-2.10.3-r30.ebuild @@ -1,4 +1,4 @@ -# Copyright 1999-2021 Gentoo Authors +# Copyright 1999-2023 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 EAPI=7 @@ -20,7 +20,7 @@ IUSE="berkdb ldap lmdb lua memcached opendbx poll sasl selinux +ssl static-libs BDEPEND="acct-user/opendkim test? ( ${LUA_DEPS} )" -COMMON_DEPEND="|| ( mail-filter/libmilter mail-mta/sendmail ) +COMMON_DEPEND="mail-filter/libmilter:= dev-libs/libbsd sys-apps/grep ssl? ( @@ -29,12 +29,11 @@ COMMON_DEPEND="|| ( mail-filter/libmilter mail-mta/sendmail ) berkdb? ( >=sys-libs/db-3.2:* ) opendbx? ( >=dev-db/opendbx-1.4.0 ) lua? ( ${LUA_DEPS} ) - ldap? ( net-nds/openldap ) - lmdb? ( dev-db/lmdb ) + 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 )" + unbound? ( >=net-dns/unbound-1.4.1:= net-dns/dnssec-root )" DEPEND="${COMMON_DEPEND}" @@ -57,6 +56,9 @@ PATCHES=( "${FILESDIR}/${P}-lua-pkgconfig-pt2.patch" "${FILESDIR}/${P}-define-P-macro-in-libvbr.patch" "${FILESDIR}/${P}-fix-libmilter-search.patch" + "${FILESDIR}/${P}-snprintf-include.patch" + "${FILESDIR}/${P}-c-std.patch" + "${FILESDIR}/${P}-fix-ldap-sasl-pc.patch" ) pkg_setup() { @@ -88,11 +90,6 @@ src_configure() { 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 @@ -114,6 +111,7 @@ src_configure() { $(use_enable static-libs static) \ $(use_enable stats) \ $(use_with memcached libmemcached) \ + $(use_with unbound) \ "${myconf[@]}" \ --enable-filter \ --with-milter \ diff --git a/mail-filter/opendkim/opendkim-2.10.3-r31.ebuild b/mail-filter/opendkim/opendkim-2.10.3-r31.ebuild new file mode 100644 index 000000000000..ce9242be5dfb --- /dev/null +++ b/mail-filter/opendkim/opendkim-2.10.3-r31.ebuild @@ -0,0 +1,253 @@ +# Copyright 1999-2024 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=7 + +LUA_COMPAT=( lua5-1 lua5-2 ) + +inherit autotools db-use systemd tmpfiles lua-single + +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 ~arm64 ~x86" +IUSE="berkdb ldap lmdb lua memcached opendbx poll sasl selinux +ssl static-libs stats querycache test unbound" + +BDEPEND="acct-user/opendkim + test? ( ${LUA_DEPS} )" + +COMMON_DEPEND="mail-filter/libmilter:= + dev-libs/libbsd + sys-apps/grep + ssl? ( + dev-libs/openssl:0= + ) + berkdb? ( >=sys-libs/db-3.2:* ) + opendbx? ( >=dev-db/opendbx-1.4.0 ) + lua? ( ${LUA_DEPS} ) + 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 )" + +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 ) + lua? ( ${LUA_REQUIRED_USE} ) + test? ( ${LUA_REQUIRED_USE} )" +RESTRICT="!test? ( test )" + +PATCHES=( + "${FILESDIR}/${P}-openrc.patch" + "${FILESDIR}/${P}-openssl-1.1.1.patch.r2" + "${FILESDIR}/${P}-lua-pkgconfig.patch" + "${FILESDIR}/${P}-lua-pkgconfig-pt2.patch" + "${FILESDIR}/${P}-define-P-macro-in-libvbr.patch" + "${FILESDIR}/${P}-fix-libmilter-search.patch" + "${FILESDIR}/${P}-snprintf-include.patch" + "${FILESDIR}/${P}-c-std.patch" + "${FILESDIR}/${P}-fix-ldap-sasl-pc.patch" + "${FILESDIR}/${P}-incompatible-pointer-types.patch" +) + +pkg_setup() { + use lua && lua-single_pkg_setup +} + +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 + + # The existing hard-coded path under /tmp is vulnerable to exploits + # since (for example) a user can create a symlink there to a file + # that portage will clobber. Reported upstream at, + # + # https://github.com/trusteddomainproject/OpenDKIM/issues/113 + # + sed -e "s:/tmp:${T}:" -i libopendkim/tests/t-testdata.h || die + + eautoreconf +} + +src_configure() { + local myconf=() + if use berkdb ; then + myconf+=( --with-db-incdir=$(db_includedir) ) + 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) \ + $(use_with unbound) \ + "${myconf[@]}" \ + --enable-filter \ + --with-milter \ + --enable-atps \ + --enable-identity_header \ + --enable-rate_limit \ + --enable-resign \ + --enable-replace_rules \ + --enable-default_sender \ + --enable-sender_macro \ + --enable-vbr \ + --disable-live-testing \ + --with-test-socket="${T}/opendkim.sock" +} + +src_compile() { + emake runstatedir=/run +} + +src_test() { + # Needed for now due to the expected sequencing of the setup/cleanup + # tests, https://github.com/trusteddomainproject/OpenDKIM/issues/110 + emake -j1 check +} + +src_install() { + default + find "${D}" -name '*.la' -type f -delete || die + + dosbin stats/opendkim-reportstats + + newinitd "${S}/contrib/OpenRC/opendkim.openrc" "${PN}" + newtmpfiles "${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" +} |