diff options
Diffstat (limited to 'nixpkgs/pkgs/servers/mail/opensmtpd')
-rw-r--r-- | nixpkgs/pkgs/servers/mail/opensmtpd/default.nix | 65 | ||||
-rw-r--r-- | nixpkgs/pkgs/servers/mail/opensmtpd/extras.nix | 91 | ||||
-rw-r--r-- | nixpkgs/pkgs/servers/mail/opensmtpd/proc_path.diff | 59 |
3 files changed, 215 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..ab2bdae0add7 --- /dev/null +++ b/nixpkgs/pkgs/servers/mail/opensmtpd/default.nix @@ -0,0 +1,65 @@ +{ lib, stdenv, fetchurl, autoconf, automake, libtool, bison +, libasr, libevent, zlib, libressl, db, pam, nixosTests +}: + +stdenv.mkDerivation rec { + pname = "opensmtpd"; + version = "6.8.0p2"; + + nativeBuildInputs = [ autoconf automake libtool bison ]; + buildInputs = [ libasr libevent zlib libressl db pam ]; + + src = fetchurl { + url = "https://www.opensmtpd.org/archives/${pname}-${version}.tar.gz"; + sha256 = "05sd7bmq29ibnqbl2z53hiyprfxzf0qydfdaixs68rz55wqhbgsi"; + }; + + patches = [ + ./proc_path.diff # TODO: upstream to OpenSMTPD, see https://github.com/NixOS/nixpkgs/issues/54045 + ]; + + # See https://github.com/OpenSMTPD/OpenSMTPD/issues/885 for the `sh bootstrap` + # requirement + postPatch = '' + 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 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; [ 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..65ff08b45396 --- /dev/null +++ b/nixpkgs/pkgs/servers/mail/opensmtpd/extras.nix @@ -0,0 +1,91 @@ +{ lib, stdenv, fetchurl, openssl, libevent, libasr, + python2, pkg-config, lua5, perl, libmysqlclient, postgresql, sqlite, hiredis, + enablePython ? true, + enableLua ? true, + enablePerl ? true, + enableMysql ? true, + enablePostgres ? true, + enableSqlite ? true, + enableRedis ? true, +}: + +stdenv.mkDerivation rec { + pname = "opensmtpd-extras"; + version = "6.7.1"; + + src = fetchurl { + url = "https://www.opensmtpd.org/archives/${pname}-${version}.tar.gz"; + sha256 = "1b1mx71bvmv92lbm08wr2p60g3qhikvv3n15zsr6dcwbk9aqahzq"; + }; + + nativeBuildInputs = [ pkg-config ]; + buildInputs = [ openssl libevent + libasr python2 lua5 perl libmysqlclient 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" + + ] ++ lib.optionals enablePython [ + "--with-python=${python2}" + "--with-filter-python" + "--with-queue-python" + "--with-table-python" + "--with-scheduler-python" + + ] ++ lib.optionals enableLua [ + "--with-lua=${pkg-config}" + "--with-filter-lua" + + ] ++ lib.optionals enablePerl [ + "--with-perl=${perl}" + "--with-filter-perl" + + ] ++ lib.optionals enableMysql [ + "--with-table-mysql" + + ] ++ lib.optionals enablePostgres [ + "--with-table-postgres" + + ] ++ lib.optionals enableSqlite [ + "--with-table-sqlite" + + ] ++ lib.optionals enableRedis [ + "--with-table-redis" + ]; + + NIX_CFLAGS_COMPILE = lib.optionalString enableRedis + "-I${hiredis}/include/hiredis -lhiredis" + + lib.optionalString enableMysql + " -L${libmysqlclient}/lib/mysql"; + + meta = with 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/proc_path.diff b/nixpkgs/pkgs/servers/mail/opensmtpd/proc_path.diff new file mode 100644 index 000000000000..a60bb603aacf --- /dev/null +++ b/nixpkgs/pkgs/servers/mail/opensmtpd/proc_path.diff @@ -0,0 +1,59 @@ +diff --git a/usr.sbin/smtpd/smtpd.c b/usr.sbin/smtpd/smtpd.c +index e049f07c..a1bd03a0 100644 +--- a/usr.sbin/smtpd/smtpd.c ++++ b/usr.sbin/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/usr.sbin/smtpd/table.c b/usr.sbin/smtpd/table.c +index 9cfdfb99..24dfcca4 100644 +--- a/usr.sbin/smtpd/table.c ++++ b/usr.sbin/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"); |