nixos/mailman: wrap mailman cli to start as mailman user

This is essential when postgres socket authentication is used.
This commit is contained in:
Sandro Jäckel 2024-08-07 00:21:42 +02:00
parent b5cd423a36
commit 1b510687b4
No known key found for this signature in database
GPG Key ID: 3AF5A43A3EECC2E5

View File

@ -460,6 +460,16 @@ in {
ignoreCollisions = true; ignoreCollisions = true;
postBuild = '' postBuild = ''
find $out/bin/ -mindepth 1 -not -name "mailman*" -delete 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
''; '';
}) ]; }) ];