nixos/rtkit: harden systemd service

This commit is contained in:
h7x4
2025-10-21 16:59:54 +09:00
parent 62ce7da0f2
commit 96be3f19b4
+39 -4
View File
@@ -57,10 +57,45 @@ in
systemd.packages = [ package ];
systemd.services.rtkit-daemon = {
serviceConfig.ExecStart = [
"" # Resets command from upstream unit.
"${package}/libexec/rtkit-daemon ${utils.escapeSystemdExecArgs cfg.args}"
];
serviceConfig = {
ExecStart = [
"" # Resets command from upstream unit.
"${package}/libexec/rtkit-daemon ${utils.escapeSystemdExecArgs cfg.args}"
];
# Needs to verify the user of the processes.
PrivateUsers = "full";
# Needs to access other processes to modify their scheduling modes.
ProcSubset = "all";
ProtectProc = "default";
# Canary needs to be realtime.
RestrictRealtime = false;
LockPersonality = true;
MemoryDenyWriteExecute = true;
NoNewPrivileges = true;
PrivateDevices = true;
PrivateTmp = "disconnected";
ProtectClock = true;
ProtectControlGroups = "strict";
ProtectHome = true;
ProtectHostname = true;
ProtectKernelLogs = true;
ProtectKernelModules = true;
ProtectKernelTunables = true;
ProtectSystem = "strict";
RemoveIPC = true;
RestrictAddressFamilies = [ "AF_UNIX" ];
IPAddressDeny = "any";
RestrictNamespaces = true;
RestrictSUIDSGID = true;
SystemCallArchitectures = "native";
SystemCallFilter = [
"@system-service"
"@mount" # Needs chroot(1)
];
UMask = "0777";
};
};
users.users.rtkit = {