@@ -1,43 +1,33 @@
11{ stdenv, lib, fetchurl, fetchpatch, autoconf, automake, libtool, bison
2−, 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−# Deprecated: use the subaddressing-delimiter in the config file going forward
9−, tag_char ? null
2+, libasr, libevent, zlib, libressl, db, pam
103}:
114
12−if (tag_char != null)
13−then throw "opensmtpd: the tag_char argument is deprecated as it can now be specified at runtime via the 'subaddressing-delimiter' option of the configuration file"
14−else stdenv.mkDerivation rec {
5+stdenv.mkDerivation rec {
156 name = "opensmtpd-${version}";
16− version = "6.0.3p1";
7+ version = "6.4.0p1";
178
189 nativeBuildInputs = [ autoconf automake libtool bison ];
19− buildInputs = [ libasr libevent zlib openssl db pam ];
10+ buildInputs = [ libasr libevent zlib libressl db pam ];
2011
2112 src = fetchurl {
2213 url = "https://www.opensmtpd.org/archives/${name}.tar.gz";
23− sha256 = "291881862888655565e8bbe3cfb743310f5dc0edb6fd28a889a9a547ad767a81";
14+ sha256 = "1qxxhnlsmpfh9v4azgl0634955r085gsic1c66jdll21bd5w2mq8";
2415 };
2516
2617 patches = [
2718 ./proc_path.diff
28− (fetchpatch {
29− url = "https://github.com/OpenSMTPD/OpenSMTPD/commit/725ba4fa2ddf23bbcd1ff9ec92e86bbfaa6825c8.diff";
30− sha256 = "19rla0b2r53jpdiz25fcza29c2msz6j6paivxhp9jcy1xl457dqa";
31− })
19+ ./fix-build.diff # See https://github.com/OpenSMTPD/OpenSMTPD/pull/884
3220 ];
3321
34− postPatch = with builtins; with lib;
35− optionalString unpriviledged_smtpctl_encrypt ''
36− substituteInPlace smtpd/smtpctl.c --replace \
37− 'if (geteuid())' \
38− 'if (geteuid() != 0 && !(argc > 1 && !strcmp(argv[1], "encrypt")))'
39− substituteInPlace mk/smtpctl/Makefile.in --replace "chmod 2555" "chmod 0555"
40− '';
22+ # See https://github.com/OpenSMTPD/OpenSMTPD/issues/885 for the `sh bootstrap`
23+ # requirement
24+ postPatch = ''
25+ substituteInPlace smtpd/parse.y \
26+ --replace "/usr/libexec/" "$out/libexec/opensmtpd/"
27+ substituteInPlace mk/smtpctl/Makefile.am --replace "chgrp" "true"
28+ substituteInPlace mk/smtpctl/Makefile.am --replace "chmod 2555" "chmod 0555"
29+ sh bootstrap
30+ '';
4131
4232 configureFlags = [
4333 "--sysconfdir=/etc"
@@ -54,6 +44,9 @@ else stdenv.mkDerivation rec {
5444 "--with-table-db"
5545 ];
5646
47+ # See https://github.com/OpenSMTPD/OpenSMTPD/pull/884
48+ makeFlags = [ "CFLAGS=-ffunction-sections" "LDFLAGS=-Wl,--gc-sections" ];
49+
5750 installFlags = [
5851 "sysconfdir=\${out}/etc"
5952 "localstatedir=\${TMPDIR}"
@@ -67,6 +60,6 @@ else stdenv.mkDerivation rec {
6760 '';
6861 license = licenses.isc;
6962 platforms = platforms.linux;
70− maintainers = with maintainers; [ rickynils obadz ];
63+ maintainers = with maintainers; [ rickynils obadz ekleog ];
7164 };
7265}