From 8abcc6ba09d0a8978f901fecf66fe8072de02ab9 Mon Sep 17 00:00:00 2001 From: Martin Weinelt Date: Wed, 21 Jul 2021 15:08:44 +0200 Subject: [PATCH] nixos/pppd: replace CAP_SYS_ADMIN with CAP_BPF The kernel before version 5.7 required CAP_SYS_ADMIN to conduct BPF operations. After that a separate capability CAP_BPF was created, which should be sufficient in this scenario and will further tighten the sandbox around our pppd service. Tested on my personal DSL line. --- nixos/modules/services/networking/pppd.nix | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/nixos/modules/services/networking/pppd.nix b/nixos/modules/services/networking/pppd.nix index c1cbdb461765..45c841dbea8b 100644 --- a/nixos/modules/services/networking/pppd.nix +++ b/nixos/modules/services/networking/pppd.nix @@ -82,13 +82,21 @@ in LD_PRELOAD = "${pkgs.libredirect}/lib/libredirect.so"; NIX_REDIRECTS = "/var/run=/run/pppd"; }; - serviceConfig = { + serviceConfig = let + capabilities = [ + "CAP_BPF" + "CAP_SYS_TTY_CONFIG" + "CAP_NET_ADMIN" + "CAP_NET_RAW" + ]; + in + { ExecStart = "${getBin cfg.package}/sbin/pppd call ${peerCfg.name} nodetach nolog"; Restart = "always"; RestartSec = 5; - AmbientCapabilities = "CAP_SYS_TTY_CONFIG CAP_NET_ADMIN CAP_NET_RAW CAP_SYS_ADMIN"; - CapabilityBoundingSet = "CAP_SYS_TTY_CONFIG CAP_NET_ADMIN CAP_NET_RAW CAP_SYS_ADMIN"; + AmbientCapabilities = capabilities; + CapabilityBoundingSet = capabilities; KeyringMode = "private"; LockPersonality = true; MemoryDenyWriteExecute = true;