From 89223af8fefcc5f32a5f79591402e45ce6796d13 Mon Sep 17 00:00:00 2001 From: Ricardo Correia Date: Wed, 18 Feb 2026 22:05:34 +0000 Subject: [PATCH] opensmtpd: fix offline enqueueing Note: for it to work correctly, it requires `services.opensmtpd.setSendmail` is set to true. Fixes #255691 Co-authored-by: Sandro --- nixos/modules/services/mail/opensmtpd.nix | 21 +++++++++++++++------ pkgs/by-name/op/opensmtpd/offline.patch | 20 ++++++++++++++++++++ pkgs/by-name/op/opensmtpd/package.nix | 14 ++++++++++++-- 3 files changed, 47 insertions(+), 8 deletions(-) create mode 100644 pkgs/by-name/op/opensmtpd/offline.patch diff --git a/nixos/modules/services/mail/opensmtpd.nix b/nixos/modules/services/mail/opensmtpd.nix index ba5226351a57..4ec30ce09dae 100644 --- a/nixos/modules/services/mail/opensmtpd.nix +++ b/nixos/modules/services/mail/opensmtpd.nix @@ -105,12 +105,21 @@ in }; }; - security.wrappers.smtpctl = { - owner = "root"; - group = "smtpq"; - setuid = false; - setgid = true; - source = "${cfg.package}/bin/smtpctl"; + security.wrappers = { + makemap = { + owner = "root"; + group = "smtpq"; + setuid = false; + setgid = true; + source = "${cfg.package}/bin/smtpctl"; + }; + smtpctl = { + owner = "root"; + group = "smtpq"; + setuid = false; + setgid = true; + source = "${cfg.package}/bin/smtpctl"; + }; }; services.mail.sendmailSetuidWrapper = lib.mkIf cfg.setSendmail ( diff --git a/pkgs/by-name/op/opensmtpd/offline.patch b/pkgs/by-name/op/opensmtpd/offline.patch new file mode 100644 index 000000000000..69e36bcc5870 --- /dev/null +++ b/pkgs/by-name/op/opensmtpd/offline.patch @@ -0,0 +1,20 @@ +Commit ID: 0527fcb65d6af4271a33dbd425f30d457fc7ab4f +Change ID: puqrnyuutmspqxqtkkqqrsmsxnyqvomm +Author : Ricardo Correia (2026-02-18 23:51:00) +Committer: Ricardo Correia (2026-02-19 00:43:47) + + (no description set) + +diff --git a/usr.sbin/smtpd/smtpd.c b/usr.sbin/smtpd/smtpd.c +index 2365b1ee46..b9e40e1417 100644 +--- a/usr.sbin/smtpd/smtpd.c ++++ b/usr.sbin/smtpd/smtpd.c +@@ -1806,7 +1806,7 @@ + envp[1] = (char *)NULL; + environ = envp; + +- execvp(PATH_SMTPCTL, args.list); ++ execvp(@@PATH_SENDMAIL@@, args.list); + _exit(1); + } + diff --git a/pkgs/by-name/op/opensmtpd/package.nix b/pkgs/by-name/op/opensmtpd/package.nix index bc1e20cdd177..6bb0ea028df0 100644 --- a/pkgs/by-name/op/opensmtpd/package.nix +++ b/pkgs/by-name/op/opensmtpd/package.nix @@ -14,6 +14,7 @@ pam, libxcrypt, nixosTests, + binPath ? "/run/wrappers/bin", }: stdenv.mkDerivation (finalAttrs: { @@ -43,11 +44,20 @@ stdenv.mkDerivation (finalAttrs: { patches = [ ./proc_path.diff # TODO: upstream to OpenSMTPD, see https://github.com/NixOS/nixpkgs/issues/54045 + ./offline.patch ]; postPatch = '' - substituteInPlace mk/smtpctl/Makefile.am --replace "chgrp" "true" - substituteInPlace mk/smtpctl/Makefile.am --replace "chmod 2555" "chmod 0555" + substituteInPlace mk/smtpctl/Makefile.am \ + --replace-fail "chgrp" "true" \ + --replace "chmod 2555" "chmod 0555" + substituteInPlace mk/pathnames \ + --replace-fail "-DPATH_SMTPCTL=\\\"\$(sbindir)" \ + "-DPATH_SMTPCTL=\\\"${binPath}" \ + --replace-fail "-DPATH_MAKEMAP=\\\"\$(sbindir)" \ + "-DPATH_MAKEMAP=\\\"${binPath}" + substituteInPlace usr.sbin/smtpd/smtpd.c \ + --replace-fail "@@PATH_SENDMAIL@@" "\"${binPath}/sendmail\"" ''; configureFlags = [