nixos/rspamd: add systemd service sandbox
Drop preStart script in favour of systemd StateDirectory parameter.
This commit is contained in:
parent
5e1d141809
commit
7e9f3e9eb1
@ -394,16 +394,43 @@ in
|
|||||||
restartTriggers = [ rspamdDir ];
|
restartTriggers = [ rspamdDir ];
|
||||||
|
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
ExecStart = "${pkgs.rspamd}/bin/rspamd ${optionalString cfg.debug "-d"} --user=${cfg.user} --group=${cfg.group} --pid=/run/rspamd.pid -c /etc/rspamd/rspamd.conf -f";
|
ExecStart = "${pkgs.rspamd}/bin/rspamd ${optionalString cfg.debug "-d"} -c /etc/rspamd/rspamd.conf -f";
|
||||||
Restart = "always";
|
Restart = "always";
|
||||||
RuntimeDirectory = "rspamd";
|
|
||||||
PrivateTmp = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
preStart = ''
|
User = "${cfg.user}";
|
||||||
${pkgs.coreutils}/bin/mkdir -p /var/lib/rspamd
|
Group = "${cfg.group}";
|
||||||
${pkgs.coreutils}/bin/chown ${cfg.user}:${cfg.group} /var/lib/rspamd
|
|
||||||
'';
|
RuntimeDirectory = "rspamd";
|
||||||
|
RuntimeDirectoryMode = "0755";
|
||||||
|
StateDirectory = "rspamd";
|
||||||
|
StateDirectoryMode = "0700";
|
||||||
|
|
||||||
|
AmbientCapabilities = "";
|
||||||
|
CapabilityBoundingSet = "";
|
||||||
|
DevicePolicy = "closed";
|
||||||
|
LockPersonality = true;
|
||||||
|
NoNewPrivileges = true;
|
||||||
|
PrivateDevices = true;
|
||||||
|
PrivateMounts = true;
|
||||||
|
PrivateTmp = true;
|
||||||
|
PrivateUsers = true;
|
||||||
|
ProtectClock = true;
|
||||||
|
ProtectControlGroups = true;
|
||||||
|
ProtectHome = true;
|
||||||
|
ProtectHostname = true;
|
||||||
|
ProtectKernelLogs = true;
|
||||||
|
ProtectKernelModules = true;
|
||||||
|
ProtectKernelTunables = true;
|
||||||
|
ProtectSystem = "strict";
|
||||||
|
RemoveIPC = true;
|
||||||
|
RestrictAddressFamilies = "AF_INET AF_INET6 AF_UNIX";
|
||||||
|
RestrictNamespaces = true;
|
||||||
|
RestrictRealtime = true;
|
||||||
|
RestrictSUIDSGID = true;
|
||||||
|
SystemCallArchitectures = "native";
|
||||||
|
SystemCallFilter = "@system-service";
|
||||||
|
UMask = "0077";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
imports = [
|
imports = [
|
||||||
|
Loading…
x
Reference in New Issue
Block a user