diff --git a/nixos/modules/services/mail/opensmtpd.nix b/nixos/modules/services/mail/opensmtpd.nix index 1e846e6e5564..d1f944ac88eb 100644 --- a/nixos/modules/services/mail/opensmtpd.nix +++ b/nixos/modules/services/mail/opensmtpd.nix @@ -113,9 +113,11 @@ in source = "${cfg.package}/bin/smtpctl"; }; - services.mail.sendmailSetuidWrapper = lib.mkIf cfg.setSendmail ( - security.wrappers.smtpctl // { program = "sendmail"; } - ); + services.mail.sendmailSetuidWrapper = lib.mkIf cfg.setSendmail + (security.wrappers.smtpctl // { + source = "${sendmail}/bin/sendmail"; + program = "sendmail"; + }); systemd.tmpfiles.rules = [ "d /var/spool/smtpd 711 root - - -" diff --git a/nixos/tests/opensmtpd.nix b/nixos/tests/opensmtpd.nix index d5b5d0fcc356..483464362fa7 100644 --- a/nixos/tests/opensmtpd.nix +++ b/nixos/tests/opensmtpd.nix @@ -16,7 +16,24 @@ import ./make-test-python.nix { } ]; }; - environment.systemPackages = [ pkgs.opensmtpd ]; + environment.systemPackages = let + testSendmail = pkgs.writeScriptBin "test-sendmail" '' + #!/bin/sh + set -euxo pipefail + echo "========= SENDING" >&2 + ${pkgs.system-sendmail}/bin/sendmail -v -f alice@smtp1 bob@smtp2 >&2 <&2 + ''; + in [ + pkgs.opensmtpd + testSendmail + ]; services.opensmtpd = { enable = true; extraServerArgs = [ "-v" ]; @@ -108,9 +125,12 @@ import ./make-test-python.nix { print("===> content:", content) split = content.split(b'\r\n') print("===> split:", split) - lastline = split[-3] + split.reverse() + lastline = next(filter(lambda x: x != b"", map(bytes.strip, split))) print("===> lastline:", lastline) assert lastline.strip() == b'Hello World' + imap.store(refs[0], '+FLAGS', '\\Deleted') + imap.expunge() ''; in [ @@ -139,6 +159,11 @@ import ./make-test-python.nix { smtp1.wait_until_fails("smtpctl show queue | egrep .") smtp2.wait_until_fails("smtpctl show queue | egrep .") client.succeed("check-mail-landed >&2") + + smtp1.succeed("test-sendmail") + smtp1.wait_until_fails("smtpctl show queue | egrep .") + smtp2.wait_until_fails("smtpctl show queue | egrep .") + client.succeed("check-mail-landed >&2") ''; meta.timeout = 1800;