From 593cac9f894d7d4894e0155bacbbc69e7ef552dd Mon Sep 17 00:00:00 2001 From: Michael Franzl Date: Tue, 26 Aug 2025 16:45:23 +0200 Subject: [PATCH] services.exim: Fix failing systemd service ExecStartPre script The previous script ran unprivileged by default (because the default value of cfg.user was "exim"), and enabling the exim service always failed. It also would have created the directory with unspecified permissions. The new mechanism uses coreutil's install tool to create the directory on systemd service start, with proper ownership and restrictive permissions. Fixes NixOS#385522 --- nixos/modules/services/mail/exim.nix | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/nixos/modules/services/mail/exim.nix b/nixos/modules/services/mail/exim.nix index 77f8bd4b0dca..56b29a311497 100644 --- a/nixos/modules/services/mail/exim.nix +++ b/nixos/modules/services/mail/exim.nix @@ -123,18 +123,11 @@ in wantedBy = [ "multi-user.target" ]; restartTriggers = [ config.environment.etc."exim.conf".source ]; serviceConfig = { + ExecStartPre = "+${coreutils}/bin/install --group=${cfg.group} --owner=${cfg.user} --mode=0700 --directory ${cfg.spoolDir}"; ExecStart = "!${cfg.package}/bin/exim -bdf -q${cfg.queueRunnerInterval}"; ExecReload = "!${coreutils}/bin/kill -HUP $MAINPID"; User = cfg.user; }; - preStart = '' - if ! test -d ${cfg.spoolDir}; then - ${coreutils}/bin/mkdir -p ${cfg.spoolDir} - ${coreutils}/bin/chown ${cfg.user}:${cfg.group} ${cfg.spoolDir} - fi - ''; }; - }; - }