mirror of
https://github.com/NixOS/nixpkgs.git
synced 2026-07-06 17:13:24 -05:00
nixos/frp: guard server-only systemd options
(cherry picked from commit 9c9b748d4f)
This commit is contained in:
parent
d542db7453
commit
61a402a7e5
1 changed files with 35 additions and 31 deletions
|
|
@ -59,37 +59,41 @@ in
|
|||
after = if isClient then [ "network-online.target" ] else [ "network.target" ];
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
description = "A fast reverse proxy frp ${cfg.role}";
|
||||
serviceConfig = {
|
||||
Type = "simple";
|
||||
Restart = "on-failure";
|
||||
RestartSec = 15;
|
||||
ExecStart = "${cfg.package}/bin/${executableFile} --strict_config -c ${configFile}";
|
||||
StateDirectoryMode = lib.optionalString isServer "0700";
|
||||
DynamicUser = true;
|
||||
# Hardening
|
||||
UMask = lib.optionalString isServer "0007";
|
||||
CapabilityBoundingSet = serviceCapability;
|
||||
AmbientCapabilities = serviceCapability;
|
||||
PrivateDevices = true;
|
||||
ProtectHostname = true;
|
||||
ProtectClock = true;
|
||||
ProtectKernelTunables = true;
|
||||
ProtectKernelModules = true;
|
||||
ProtectKernelLogs = true;
|
||||
ProtectControlGroups = true;
|
||||
RestrictAddressFamilies = [
|
||||
"AF_INET"
|
||||
"AF_INET6"
|
||||
]
|
||||
++ lib.optionals isClient [ "AF_UNIX" ];
|
||||
LockPersonality = true;
|
||||
MemoryDenyWriteExecute = true;
|
||||
RestrictRealtime = true;
|
||||
RestrictSUIDSGID = true;
|
||||
PrivateMounts = true;
|
||||
SystemCallArchitectures = "native";
|
||||
SystemCallFilter = [ "@system-service" ];
|
||||
};
|
||||
serviceConfig =
|
||||
{
|
||||
Type = "simple";
|
||||
Restart = "on-failure";
|
||||
RestartSec = 15;
|
||||
ExecStart = "${cfg.package}/bin/${executableFile} --strict_config -c ${configFile}";
|
||||
DynamicUser = true;
|
||||
# Hardening
|
||||
CapabilityBoundingSet = serviceCapability;
|
||||
AmbientCapabilities = serviceCapability;
|
||||
PrivateDevices = true;
|
||||
ProtectHostname = true;
|
||||
ProtectClock = true;
|
||||
ProtectKernelTunables = true;
|
||||
ProtectKernelModules = true;
|
||||
ProtectKernelLogs = true;
|
||||
ProtectControlGroups = true;
|
||||
RestrictAddressFamilies = [
|
||||
"AF_INET"
|
||||
"AF_INET6"
|
||||
]
|
||||
++ lib.optionals isClient [ "AF_UNIX" ];
|
||||
LockPersonality = true;
|
||||
MemoryDenyWriteExecute = true;
|
||||
RestrictRealtime = true;
|
||||
RestrictSUIDSGID = true;
|
||||
PrivateMounts = true;
|
||||
SystemCallArchitectures = "native";
|
||||
SystemCallFilter = [ "@system-service" ];
|
||||
}
|
||||
// lib.optionalAttrs isServer {
|
||||
StateDirectory = "frp";
|
||||
StateDirectoryMode = "0700";
|
||||
UMask = "0007";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue