nixos/mailman: wrap mailman cli to start as mailman user (#332847)

This commit is contained in:
Sandro 2024-11-27 23:07:31 +01:00 committed by GitHub
commit 1af52db201
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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
'';
}) ];