Skip to content

Commit

Permalink
[OPS-1161] Add withHardeningProfile helper
Browse files Browse the repository at this point in the history
Problem: We want to harden our systemd services by using previously
defined profiles, so we need a way to easily apply them to our systemd
service configurations.

Solution: Add withHardeningProfile helper, remove DeviceAllow from
profiles, because it is used incorrectly (systemd complains and skips
this option), and the semantics of this use is already covered by PrivateDevices.
  • Loading branch information
Sereja313 committed Mar 5, 2024
1 parent fdf87eb commit 048a0ad
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

haskell = import ./haskell.nix { inherit lib nixpkgs; inherit (cabal) getTestedWithVersions; };

systemd = import ./systemd;
systemd = import ./systemd { inherit lib; };

types = import ./types.nix { inherit lib; };

Expand Down
6 changes: 6 additions & 0 deletions lib/systemd/default.nix
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
{ lib }:
{

hardeningProfiles = import ./profiles.nix;

hardenServices = import ./harden-services.nix;

userLevelServices = import ./user-level-services.nix;

withHardeningProfile = profile: serviceConfig: lib.mkMerge [
(builtins.mapAttrs (_: lib.mkDefault) profile)
serviceConfig
];
}
1 change: 0 additions & 1 deletion lib/systemd/profiles.nix
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ rec {
# "~CLONE_NEWUTS"
# ];
RestrictNamespaces = "yes";
DeviceAllow = "no";
IPAddressDeny = "any";
KeyringMode = "private";
NoNewPrivileges = "yes";
Expand Down

0 comments on commit 048a0ad

Please sign in to comment.