@@ -1,5 +1,12 @@
1−{ stdenv, fetchurl, autoconf, automake, libtool, bison
1+{ stdenv, lib, fetchurl, autoconf, automake, libtool, bison
22, libasr, libevent, zlib, openssl, db, pam
3+
4+# opensmtpd requires root for no reason to encrypt passwords, this patch fixes it
5+# see also https://github.com/OpenSMTPD/OpenSMTPD/issues/678
6+, unpriviledged_smtpctl_encrypt ? true
7+
8+# This enables you to override the '+' character which typically separates the user from the tag in user+tag@domain.tld
9+, tag_char ? null
310}:
411
512stdenv.mkDerivation rec {
@@ -16,6 +23,16 @@ stdenv.mkDerivation rec {
1623
1724 patches = [ ./proc_path.diff ];
1825
26+ postPatch = with builtins; with lib;
27+ optionalString (isString tag_char) ''
28+ sed -i -e "s,TAG_CHAR.*'+',TAG_CHAR '${tag_char}'," smtpd/smtpd-defines.h
29+ '' +
30+ optionalString unpriviledged_smtpctl_encrypt ''
31+ substituteInPlace smtpd/smtpctl.c --replace \
32+ 'if (geteuid())' \
33+ 'if (geteuid() != 0 && !(argc > 1 && !strcmp(argv[1], "encrypt")))'
34+ '';
35+
1936 configureFlags = [
2037 "--sysconfdir=/etc"
2138 "--localstatedir=/var"