41 lines
1.2 KiB
Nix
41 lines
1.2 KiB
Nix
|
{lib, ...}: let
|
||
|
inherit (lib) mkOptionDefault mapAttrs;
|
||
|
|
||
|
hardenService = attrs:
|
||
|
attrs
|
||
|
// (mapAttrs (_: mkOptionDefault) {
|
||
|
AmbientCapabilities = "";
|
||
|
CapabilityBoundingSet = "";
|
||
|
LockPersonality = true;
|
||
|
MemoryDenyWriteExecute = true;
|
||
|
NoNewPrivileges = true;
|
||
|
PrivateDevices = true;
|
||
|
PrivateMounts = true;
|
||
|
PrivateTmp = true;
|
||
|
ProcSubset = "pid";
|
||
|
ProtectClock = true;
|
||
|
ProtectControlGroups = true;
|
||
|
ProtectHome = true;
|
||
|
ProtectHostname = true;
|
||
|
ProtectKernelLogs = true;
|
||
|
ProtectKernelModules = true;
|
||
|
ProtectKernelTunables = true;
|
||
|
ProtectProc = "invisible";
|
||
|
ProtectSystem = "strict";
|
||
|
RemoveIPC = true;
|
||
|
RestrictAddressFamilies = ["AF_UNIX" "AF_INET" "AF_INET6"];
|
||
|
RestrictNamespaces = true;
|
||
|
RestrictRealtime = true;
|
||
|
RestrictSUIDSGID = true;
|
||
|
SystemCallArchitectures = "native";
|
||
|
SystemCallErrorNumber = "EPERM";
|
||
|
SystemCallFilter = [
|
||
|
"@system-service"
|
||
|
# Route-chain and OpenJ9 requires @resources calls
|
||
|
"~@clock @cpu-emulation @debug @module @mount @obsolete @privileged @raw-io @reboot @swap"
|
||
|
];
|
||
|
});
|
||
|
in {
|
||
|
inherit hardenService;
|
||
|
}
|