summary refs log tree commit diff
diff options
context:
space:
mode:
authorShaRose <ShawnAndrewRose@Gmail.Com>2019-10-21 19:18:04 +0000
committerShaRose <ShawnAndrewRose@Gmail.Com>2019-10-31 13:27:55 -0230
commit9e2308ed805eac8462343c90283d94c58a6e708b (patch)
tree9b9a66ff305ef434f065d9ce390a9e86c7674a21
parent1125fb02ccfca1a0cf63622d090b43c7e985c9ae (diff)
downloadnixpkgs-9e2308ed805eac8462343c90283d94c58a6e708b.tar
nixpkgs-9e2308ed805eac8462343c90283d94c58a6e708b.tar.gz
nixpkgs-9e2308ed805eac8462343c90283d94c58a6e708b.tar.bz2
nixpkgs-9e2308ed805eac8462343c90283d94c58a6e708b.tar.lz
nixpkgs-9e2308ed805eac8462343c90283d94c58a6e708b.tar.xz
nixpkgs-9e2308ed805eac8462343c90283d94c58a6e708b.tar.zst
nixpkgs-9e2308ed805eac8462343c90283d94c58a6e708b.zip
nixos/dnsdist: Add CAP_NET_BIND_SERVICE to AmbientCapabilities
It seems that dnsdist doesn't actually request CAP_NET_BIND_SERVICE, which is why normally it's executed and root and setuids to another, unprivileged, user. This means that as it is, dnsdist will be unable to bind to any port under 1024 and will fail with access denied.

Removing CAP_SETGID and CAP_SETUID is also related to this as we don't actually change the uid or gid after the fact as we use DynamicUser. (That part isn't strictly NEEDED but there's no reason to have those capabilities if we don't use them).

There are also some additional sandboxing we can remove from the service definition as they are assumed true or strict by DynamicUser: specifically PrivateTmp and ProtectSystem respectively.

ProtectHome is still there, despite being assumed read-only as setting it to true means they are seen as empty. I don't think it really matters as I don't know if systemd will ignore it or not, but I didn't see any reason to go hunting for excuses to make it a bigger change.
-rw-r--r--nixos/modules/services/networking/dnsdist.nix5
1 files changed, 2 insertions, 3 deletions
diff --git a/nixos/modules/services/networking/dnsdist.nix b/nixos/modules/services/networking/dnsdist.nix
index 12eee136e63..8249da69bc1 100644
--- a/nixos/modules/services/networking/dnsdist.nix
+++ b/nixos/modules/services/networking/dnsdist.nix
@@ -46,11 +46,10 @@ in {
         RestartSec="1";
         DynamicUser = true;
         StartLimitInterval="0";
-        PrivateTmp=true;
         PrivateDevices=true;
-        CapabilityBoundingSet="CAP_NET_BIND_SERVICE CAP_SETGID CAP_SETUID";
+        AmbientCapabilities="CAP_NET_BIND_SERVICE";
+        CapabilityBoundingSet="CAP_NET_BIND_SERVICE";
         ExecStart = "${pkgs.dnsdist}/bin/dnsdist --supervised --disable-syslog --config ${configFile}";
-        ProtectSystem="full";
         ProtectHome=true;
         RestrictAddressFamilies="AF_UNIX AF_INET AF_INET6";
         LimitNOFILE="16384";