From d3e0a89ca62863b7294ce1fda6eda468bd9eaa90 Mon Sep 17 00:00:00 2001 From: Martin Weinelt Date: Sun, 29 Sep 2024 12:29:19 +0200 Subject: [PATCH] nixos/logrotate: relax hardening The previous hardening change restricted the unit too much, breaking legitimate functionality of logrotate. Unfortunately this was not covered by our NixOS test. --- nixos/modules/services/logging/logrotate.nix | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/nixos/modules/services/logging/logrotate.nix b/nixos/modules/services/logging/logrotate.nix index 6fb5f0588d97..8584563d881d 100644 --- a/nixos/modules/services/logging/logrotate.nix +++ b/nixos/modules/services/logging/logrotate.nix @@ -260,6 +260,8 @@ in # hardening CapabilityBoundingSet = [ "CAP_CHOWN" + "CAP_DAC_OVERRIDE" + "CAP_SETUID" "CAP_SETGID" ]; DevicePolicy = "closed"; @@ -280,16 +282,16 @@ in ProtectSystem = "full"; RestrictNamespaces = true; RestrictRealtime = true; - RestrictSUIDSGID = true; + RestrictSUIDSGID = false; # can create sgid directories SystemCallArchitectures = "native"; SystemCallFilter = [ - "@system-service" + "@system-service @setuid" "~@privileged @resources" "@chown" ]; UMask = "0027"; } // lib.optionalAttrs (!cfg.allowNetworking) { - PrivateNetwork = true; + PrivateNetwork = true; # e.g. mail delivery RestrictAddressFamilies = "none"; }; };