Skip to content

Commit

Permalink
Merge #69
Browse files Browse the repository at this point in the history
69: harmonia: more hardening r=Mic92 a=Mic92



Co-authored-by: Jörg Thalheim <[email protected]>
  • Loading branch information
bors[bot] and Mic92 authored May 7, 2023
2 parents 636318e + b194fd1 commit 612e21d
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions module.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ let

format = pkgs.formats.toml { };
configFile = format.generate "harmonia.toml" cfg.settings;

harmonia = import ./. { inherit pkgs; };
in
{
options = {
Expand Down Expand Up @@ -36,8 +34,6 @@ in
priority = 50;
};

environment.systemPackages = [ harmonia ];

systemd.services.harmonia = {
description = "harmonia binary cache service";

Expand All @@ -60,11 +56,14 @@ in
environment.HOME = "/run/harmonia";

serviceConfig = {
ExecStart = "${harmonia}/bin/harmonia";
ExecStart = "${import ./. { inherit pkgs; }}/bin/harmonia";

User = "harmonia";
Group = "harmonia";
DynamicUser = true;
PrivateUsers = true;
DeviceAllow = [ "" ];
UMask = "0066";

RuntimeDirectory = "harmonia";
LoadCredential = lib.optional (cfg.signKeyPath != null) "sign-key:${cfg.signKeyPath}";
Expand All @@ -74,15 +73,28 @@ in
"~@privileged"
"~@resources"
];
CapabilityBoundingSet = "";
ProtectKernelModules = true;
ProtectKernelTunables = true;
ProtectControlGroups = true;
ProtectKernelLogs = true;
ProtectHostname = true;
ProtectClock = true;
RestrictRealtime = true;
MemoryDenyWriteExecute = true;
ProcSubset = "pid";
ProtectProc = "invisible";
RestrictNamespaces = true;
SystemCallArchitectures = "native";

PrivateNetwork = false;
PrivateTmp = true;
PrivateDevices = true;
PrivateMounts = true;
ProtectProc = true;
NoNewPrivileges = true;
ProtectSystem = "strict";
ProtectHome = true;
LockPersonality = true;
RestrictAddressFamilies = "AF_UNIX AF_INET AF_INET6";

LimitNOFILE = 65536;
Expand Down

0 comments on commit 612e21d

Please sign in to comment.