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
This commit is contained in:
committed by
Bjørn Forsman
parent
35ca1b1069
commit
593cac9f89
@@ -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
|
||||
'';
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user