Skip to content

Commit

Permalink
[Backport release-24.11] nixos/ebusd: fix device access (#364192)
Browse files Browse the repository at this point in the history
  • Loading branch information
misuzu authored Dec 11, 2024
2 parents 7f64560 + 1ed38ed commit ecfbc4b
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions nixos/modules/services/home-automation/ebusd.nix
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,11 @@ in

config =
let
usesDev = hasPrefix "/" cfg.device;
usesDev = lib.any (prefix: lib.hasPrefix prefix cfg.device) [
"/"
"ens:/"
"enh:/"
];
in
mkIf cfg.enable {
systemd.services.ebusd = {
Expand Down Expand Up @@ -201,12 +205,14 @@ in

# Hardening
CapabilityBoundingSet = "";
DeviceAllow = optionals usesDev [ cfg.device ];
DeviceAllow = lib.optionals usesDev [
(lib.removePrefix "ens:" (lib.removePrefix "enh:" cfg.device))
];
DevicePolicy = "closed";
LockPersonality = true;
MemoryDenyWriteExecute = false;
NoNewPrivileges = true;
PrivateDevices = usesDev;
PrivateDevices = !usesDev;
PrivateUsers = true;
PrivateTmp = true;
ProtectClock = true;
Expand Down

0 comments on commit ecfbc4b

Please sign in to comment.