From 1b510687b4f54c14490f941a7f66312df94d2788 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sandro=20J=C3=A4ckel?= Date: Wed, 7 Aug 2024 00:21:42 +0200 Subject: [PATCH] nixos/mailman: wrap mailman cli to start as mailman user This is essential when postgres socket authentication is used. --- nixos/modules/services/mail/mailman.nix | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/nixos/modules/services/mail/mailman.nix b/nixos/modules/services/mail/mailman.nix index 95b77da250b2..4f2312cc5de2 100644 --- a/nixos/modules/services/mail/mailman.nix +++ b/nixos/modules/services/mail/mailman.nix @@ -460,6 +460,16 @@ in { ignoreCollisions = true; postBuild = '' find $out/bin/ -mindepth 1 -not -name "mailman*" -delete + '' + lib.optionalString config.security.sudo.enable '' + mv $out/bin/mailman $out/bin/.mailman-wrapped + echo '#!${pkgs.runtimeShell} + sudo=exec + if [[ "$USER" != mailman ]]; then + sudo="exec /run/wrappers/bin/sudo -u mailman" + fi + $sudo ${placeholder "out"}/bin/.mailman-wrapped "$@" + ' > $out/bin/mailman + chmod +x $out/bin/mailman ''; }) ];