diff --git a/hosts/common/default.nix b/hosts/common/default.nix index b8d657a..8e156dc 100644 --- a/hosts/common/default.nix +++ b/hosts/common/default.nix @@ -14,6 +14,7 @@ in { ./services/cups.nix ./services/dbus.nix + ./services/logrotate.nix ./services/openssh.nix ./services/pcscd.nix ./services/pipewire.nix diff --git a/hosts/common/services/logrotate.nix b/hosts/common/services/logrotate.nix new file mode 100644 index 0000000..d922b0d --- /dev/null +++ b/hosts/common/services/logrotate.nix @@ -0,0 +1,42 @@ +{ ... }: +{ + # source: https://github.com/logrotate/logrotate/blob/main/examples/logrotate.service + systemd.services.logrotate = { + documentation = [ "man:logrotate(8)" "man:logrotate.conf(5)" ]; + unitConfig.RequiresMountsFor = "/var/log"; + serviceConfig = { + Nice = 19; + IOSchedulingClass = "best-effort"; + IOSchedulingPriority = 7; + + ReadWritePaths = [ "/var/log" ]; + + AmbientCapabilities = [ "" ]; + CapabilityBoundingSet = [ "" ]; + DeviceAllow = [ "" ]; + LockPersonality = true; + MemoryDenyWriteExecute = true; + NoNewPrivileges = true; # disable for third party rotate scripts + PrivateDevices = true; + PrivateNetwork = true; # disable for mail delivery + PrivateTmp = true; + ProtectClock = true; + ProtectControlGroups = true; + ProtectHome = true; # disable for userdir logs + ProtectHostname = true; + ProtectKernelLogs = true; + ProtectKernelModules = true; + ProtectKernelTunables = true; + ProtectProc = "invisible"; + ProtectSystem = "full"; + RestrictNamespaces = true; + RestrictRealtime = true; + RestrictSUIDSGID = true; # disable for creating setgid directories + SocketBindDeny = [ "any" ]; + SystemCallArchitectures = "native"; + SystemCallFilter = [ + "@system-service" + ]; + }; + }; +}