Skip to content

Commit 593cac9

Browse files
michaelfranzlbjornfor
authored andcommitted
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 #385522
1 parent 35ca1b1 commit 593cac9

File tree

1 file changed

+1
-8
lines changed

1 file changed

+1
-8
lines changed

nixos/modules/services/mail/exim.nix

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -123,18 +123,11 @@ in
123123
wantedBy = [ "multi-user.target" ];
124124
restartTriggers = [ config.environment.etc."exim.conf".source ];
125125
serviceConfig = {
126+
ExecStartPre = "+${coreutils}/bin/install --group=${cfg.group} --owner=${cfg.user} --mode=0700 --directory ${cfg.spoolDir}";
126127
ExecStart = "!${cfg.package}/bin/exim -bdf -q${cfg.queueRunnerInterval}";
127128
ExecReload = "!${coreutils}/bin/kill -HUP $MAINPID";
128129
User = cfg.user;
129130
};
130-
preStart = ''
131-
if ! test -d ${cfg.spoolDir}; then
132-
${coreutils}/bin/mkdir -p ${cfg.spoolDir}
133-
${coreutils}/bin/chown ${cfg.user}:${cfg.group} ${cfg.spoolDir}
134-
fi
135-
'';
136131
};
137-
138132
};
139-
140133
}

0 commit comments

Comments
 (0)