about summary refs log tree commit diff
path: root/nixpkgs/pkgs/servers/mail/opensmtpd
diff options
context:
space:
mode:
Diffstat (limited to 'nixpkgs/pkgs/servers/mail/opensmtpd')
-rw-r--r--nixpkgs/pkgs/servers/mail/opensmtpd/default.nix68
-rw-r--r--nixpkgs/pkgs/servers/mail/opensmtpd/extras.nix92
-rw-r--r--nixpkgs/pkgs/servers/mail/opensmtpd/fix-build.diff12
-rw-r--r--nixpkgs/pkgs/servers/mail/opensmtpd/proc_path.diff59
4 files changed, 231 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/servers/mail/opensmtpd/default.nix b/nixpkgs/pkgs/servers/mail/opensmtpd/default.nix
new file mode 100644
index 000000000000..695450f18222
--- /dev/null
+++ b/nixpkgs/pkgs/servers/mail/opensmtpd/default.nix
@@ -0,0 +1,68 @@
+{ stdenv, lib, fetchurl, fetchpatch, autoconf, automake, libtool, bison
+, libasr, libevent, zlib, libressl, db, pam, nixosTests
+}:
+
+stdenv.mkDerivation rec {
+  name = "opensmtpd-${version}";
+  version = "6.4.0p2";
+
+  nativeBuildInputs = [ autoconf automake libtool bison ];
+  buildInputs = [ libasr libevent zlib libressl db pam ];
+
+  src = fetchurl {
+    url = "https://www.opensmtpd.org/archives/${name}.tar.gz";
+    sha256 = "1y7snhsrcdi56vaa23iwjpybhyrnnh2f6dxrfnacn7xgy5xwzbvn";
+  };
+
+  patches = [
+    ./proc_path.diff
+    ./fix-build.diff # See https://github.com/OpenSMTPD/OpenSMTPD/pull/884
+  ];
+
+  # See https://github.com/OpenSMTPD/OpenSMTPD/issues/885 for the `sh bootstrap`
+  # requirement
+  postPatch = ''
+    substituteInPlace smtpd/parse.y \
+      --replace "/usr/libexec/" "$out/libexec/opensmtpd/"
+    substituteInPlace mk/smtpctl/Makefile.am --replace "chgrp" "true"
+    substituteInPlace mk/smtpctl/Makefile.am --replace "chmod 2555" "chmod 0555"
+    sh bootstrap
+  '';
+
+  configureFlags = [
+    "--sysconfdir=/etc"
+    "--localstatedir=/var"
+    "--with-mantype=doc"
+    "--with-auth-pam"
+    "--without-auth-bsdauth"
+    "--with-path-socket=/run"
+    "--with-user-smtpd=smtpd"
+    "--with-user-queue=smtpq"
+    "--with-group-queue=smtpq"
+    "--with-path-CAfile=/etc/ssl/certs/ca-certificates.crt"
+    "--with-libevent=${libevent.dev}"
+    "--with-table-db"
+  ];
+
+  # See https://github.com/OpenSMTPD/OpenSMTPD/pull/884
+  makeFlags = [ "CFLAGS=-ffunction-sections" "LDFLAGS=-Wl,--gc-sections" ];
+
+  installFlags = [
+    "sysconfdir=\${out}/etc"
+    "localstatedir=\${TMPDIR}"
+  ];
+
+  meta = with stdenv.lib; {
+    homepage = https://www.opensmtpd.org/;
+    description = ''
+      A free implementation of the server-side SMTP protocol as defined by
+      RFC 5321, with some additional standard extensions
+    '';
+    license = licenses.isc;
+    platforms = platforms.linux;
+    maintainers = with maintainers; [ rickynils obadz ekleog ];
+  };
+  passthru.tests = {
+    basic-functionality-and-dovecot-interaction = nixosTests.opensmtpd;
+  };
+}
diff --git a/nixpkgs/pkgs/servers/mail/opensmtpd/extras.nix b/nixpkgs/pkgs/servers/mail/opensmtpd/extras.nix
new file mode 100644
index 000000000000..1d4ad63c37d2
--- /dev/null
+++ b/nixpkgs/pkgs/servers/mail/opensmtpd/extras.nix
@@ -0,0 +1,92 @@
+{ stdenv, fetchurl, openssl, libevent, libasr,
+  python2, pkgconfig, lua5, perl, mysql, postgresql, sqlite, hiredis,
+  enablePython ? true,
+  enableLua ? true,
+  enablePerl ? true,
+  enableMysql ? true,
+  enablePostgres ? true,
+  enableSqlite ? true,
+  enableRedis ? true,
+}:
+
+stdenv.mkDerivation rec {
+  name = "opensmtpd-extras-${version}";
+  version = "6.4.0";
+
+  src = fetchurl {
+    url = "https://www.opensmtpd.org/archives/${name}.tar.gz";
+    sha256 = "09k25l7zy5ch3fk6qphni2h0rxdp8wacmfag1whi608dgimrhrnb";
+  };
+
+  nativeBuildInputs = [ pkgconfig ];
+  buildInputs = [ openssl libevent
+    libasr python2 lua5 perl mysql.connector-c postgresql sqlite hiredis ];
+
+  configureFlags = [
+    "--sysconfdir=/etc"
+    "--localstatedir=/var"
+    "--with-privsep-user=smtpd"
+    "--with-libevent-dir=${libevent.dev}"
+
+    "--with-filter-clamav"
+    "--with-filter-dkim-signer"
+    "--with-filter-dnsbl"
+    "--with-filter-monkey"
+    "--with-filter-pause"
+    "--with-filter-regex"
+    "--with-filter-spamassassin"
+    "--with-filter-stub"
+    "--with-filter-trace"
+    "--with-filter-void"
+    "--with-queue-null"
+    "--with-queue-ram"
+    "--with-queue-stub"
+    "--with-table-ldap"
+    "--with-table-socketmap"
+    "--with-table-passwd"
+    "--with-table-stub"
+    "--with-scheduler-ram"
+    "--with-scheduler-stub"
+
+  ] ++ stdenv.lib.optional enablePython [
+    "--with-python=${python2}"
+    "--with-filter-python"
+    "--with-queue-python"
+    "--with-table-python"
+    "--with-scheduler-python"
+
+  ] ++ stdenv.lib.optional enableLua [
+    "--with-lua=${pkgconfig}"
+    "--with-filter-lua"
+
+  ] ++ stdenv.lib.optional enablePerl [
+    "--with-perl=${perl}"
+    "--with-filter-perl"
+
+  ] ++ stdenv.lib.optional enableMysql [
+    "--with-table-mysql"
+
+  ] ++ stdenv.lib.optional enablePostgres [
+    "--with-table-postgres"
+
+  ] ++ stdenv.lib.optional enableSqlite [
+    "--with-table-sqlite"
+
+  ] ++ stdenv.lib.optional enableRedis [
+    "--with-table-redis"
+  ];
+
+  NIX_CFLAGS_COMPILE =
+    stdenv.lib.optional enableRedis
+      "-I${hiredis}/include/hiredis -lhiredis"
+    ++ stdenv.lib.optional enableMysql
+      "-L${mysql.connector-c}/lib/mysql";
+
+  meta = with stdenv.lib; {
+    homepage = https://www.opensmtpd.org/;
+    description = "Extra plugins for the OpenSMTPD mail server";
+    license = licenses.isc;
+    platforms = platforms.linux;
+    maintainers = with maintainers; [ gebner ekleog ];
+  };
+}
diff --git a/nixpkgs/pkgs/servers/mail/opensmtpd/fix-build.diff b/nixpkgs/pkgs/servers/mail/opensmtpd/fix-build.diff
new file mode 100644
index 000000000000..1f995fd4f623
--- /dev/null
+++ b/nixpkgs/pkgs/servers/mail/opensmtpd/fix-build.diff
@@ -0,0 +1,12 @@
+diff --git a/mk/smtpctl/Makefile.am b/mk/smtpctl/Makefile.am
+index 5af0b713..f0fce735 100644
+--- a/mk/smtpctl/Makefile.am
++++ b/mk/smtpctl/Makefile.am
+@@ -4,6 +4,7 @@ sbin_PROGRAMS=          smtpctl
+ 
+ smtpctl_SOURCES=	$(smtpd_srcdir)/enqueue.c
+ smtpctl_SOURCES+=	$(smtpd_srcdir)/parser.c
++smtpctl_SOURCES+=	$(smtpd_srcdir)/config.c
+ smtpctl_SOURCES+=	$(smtpd_srcdir)/log.c
+ smtpctl_SOURCES+=	$(smtpd_srcdir)/envelope.c
+ smtpctl_SOURCES+=	$(smtpd_srcdir)/queue_backend.c
diff --git a/nixpkgs/pkgs/servers/mail/opensmtpd/proc_path.diff b/nixpkgs/pkgs/servers/mail/opensmtpd/proc_path.diff
new file mode 100644
index 000000000000..5e1cfd004299
--- /dev/null
+++ b/nixpkgs/pkgs/servers/mail/opensmtpd/proc_path.diff
@@ -0,0 +1,59 @@
+diff --git a/smtpd/smtpd.c b/smtpd/smtpd.c
+index e049f07c..a1bd03a0 100644
+--- a/smtpd/smtpd.c
++++ b/smtpd/smtpd.c
+@@ -1157,6 +1157,7 @@ fork_proc_backend(const char *key, const char *conf, const char *procname)
+ 	char		path[PATH_MAX];
+ 	char		name[PATH_MAX];
+ 	char		*arg;
++	char		*proc_path;
+ 
+ 	if (strlcpy(name, conf, sizeof(name)) >= sizeof(name)) {
+ 		log_warnx("warn: %s-proc: conf too long", key);
+@@ -1167,7 +1168,12 @@ fork_proc_backend(const char *key, const char *conf, const char *procname)
+ 	if (arg)
+ 		*arg++ = '\0';
+ 
+-	if (snprintf(path, sizeof(path), PATH_LIBEXEC "/%s-%s", key, name) >=
++	proc_path = getenv("OPENSMTPD_PROC_PATH");
++	if (proc_path == NULL) {
++		proc_path = PATH_LIBEXEC;
++	}
++
++	if (snprintf(path, sizeof(path), "%s/%s-%s", proc_path, key, name) >=
+ 	    (ssize_t)sizeof(path)) {
+ 		log_warn("warn: %s-proc: exec path too long", key);
+ 		return (-1);
+diff --git a/smtpd/table.c b/smtpd/table.c
+index 9cfdfb99..24dfcca4 100644
+--- a/smtpd/table.c
++++ b/smtpd/table.c
+@@ -201,6 +201,7 @@ table_create(const char *backend, const char *name, const char *tag,
+ 	struct table_backend	*tb;
+ 	char			 buf[LINE_MAX];
+ 	char			 path[LINE_MAX];
++	const char		*proc_path;
+ 	size_t			 n;
+ 	struct stat		 sb;
+ 
+@@ -215,11 +216,16 @@ table_create(const char *backend, const char *name, const char *tag,
+ 	if (name && table_find(name, NULL))
+ 		fatalx("table_create: table \"%s\" already defined", name);
+ 
++	proc_path = getenv("OPENSMTPD_PROC_PATH");
++	if (proc_path == NULL) {
++		proc_path = PATH_LIBEXEC;
++	}
++
+ 	if ((tb = table_backend_lookup(backend)) == NULL) {
+-		if ((size_t)snprintf(path, sizeof(path), PATH_LIBEXEC"/table-%s",
+-			backend) >= sizeof(path)) {
+-			fatalx("table_create: path too long \""
+-			    PATH_LIBEXEC"/table-%s\"", backend);
++		if ((size_t)snprintf(path, sizeof(path), "%s/table-%s",
++			proc_path, backend) >= sizeof(path)) {
++			fatalx("table_create: path too long \"%s/table-%s\"",
++				proc_path, backend);
+ 		}
+ 		if (stat(path, &sb) == 0) {
+ 			tb = table_backend_lookup("proc");