From e0ef352ae76da647d837c3405263c34c11191f8e Mon Sep 17 00:00:00 2001 From: obadz Date: Mon, 23 May 2016 22:07:05 +0100 Subject: [PATCH] opensmtpd: add two configuration options unpriviledged_smtpctl_encrypt (defaults to true) -- lets you invoke smtpctl encrypt without being root tag_char -- lets you override the + as in user+tag@domain.tld --- pkgs/servers/mail/opensmtpd/default.nix | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/pkgs/servers/mail/opensmtpd/default.nix b/pkgs/servers/mail/opensmtpd/default.nix index 4edee78898e4..4dada752cf63 100644 --- a/pkgs/servers/mail/opensmtpd/default.nix +++ b/pkgs/servers/mail/opensmtpd/default.nix @@ -1,5 +1,12 @@ -{ stdenv, fetchurl, autoconf, automake, libtool, bison +{ stdenv, lib, fetchurl, autoconf, automake, libtool, bison , libasr, libevent, zlib, openssl, db, pam + +# opensmtpd requires root for no reason to encrypt passwords, this patch fixes it +# see also https://github.com/OpenSMTPD/OpenSMTPD/issues/678 +, unpriviledged_smtpctl_encrypt ? true + +# This enables you to override the '+' character which typically separates the user from the tag in user+tag@domain.tld +, tag_char ? null }: stdenv.mkDerivation rec { @@ -16,6 +23,16 @@ stdenv.mkDerivation rec { patches = [ ./proc_path.diff ]; + postPatch = with builtins; with lib; + optionalString (isString tag_char) '' + sed -i -e "s,TAG_CHAR.*'+',TAG_CHAR '${tag_char}'," smtpd/smtpd-defines.h + '' + + optionalString unpriviledged_smtpctl_encrypt '' + substituteInPlace smtpd/smtpctl.c --replace \ + 'if (geteuid())' \ + 'if (geteuid() != 0 && !(argc > 1 && !strcmp(argv[1], "encrypt")))' + ''; + configureFlags = [ "--sysconfdir=/etc" "--localstatedir=/var"