about summary refs log tree commit diff
diff options
context:
space:
mode:
authorRenaud <c0bw3b@users.noreply.github.com>2019-05-09 20:09:40 +0200
committerGitHub <noreply@github.com>2019-05-09 20:09:40 +0200
commitc17ec06f663c9f26a033edc6c5fe54b071b39c9a (patch)
tree0e051b31b1b4090748a26bc601e1a9ae5299b718
parent0954c36972bbb634c0bc111e591ce264605c4f75 (diff)
parent329df959581629113d4643465d1a2fcddef7fef2 (diff)
downloadnixlib-c17ec06f663c9f26a033edc6c5fe54b071b39c9a.tar
nixlib-c17ec06f663c9f26a033edc6c5fe54b071b39c9a.tar.gz
nixlib-c17ec06f663c9f26a033edc6c5fe54b071b39c9a.tar.bz2
nixlib-c17ec06f663c9f26a033edc6c5fe54b071b39c9a.tar.lz
nixlib-c17ec06f663c9f26a033edc6c5fe54b071b39c9a.tar.xz
nixlib-c17ec06f663c9f26a033edc6c5fe54b071b39c9a.tar.zst
nixlib-c17ec06f663c9f26a033edc6c5fe54b071b39c9a.zip
Merge pull request #60569 from dtzWill/update/vnstat-2.2
vnstat: 2.1 -> 2.2
-rw-r--r--nixos/modules/services/monitoring/vnstat.nix19
-rw-r--r--pkgs/applications/networking/vnstat/default.nix15
2 files changed, 27 insertions, 7 deletions
diff --git a/nixos/modules/services/monitoring/vnstat.nix b/nixos/modules/services/monitoring/vnstat.nix
index cb2f8c07edb9..e9bedb704a43 100644
--- a/nixos/modules/services/monitoring/vnstat.nix
+++ b/nixos/modules/services/monitoring/vnstat.nix
@@ -28,14 +28,29 @@ in {
       path = [ pkgs.coreutils ];
       after = [ "network.target" ];
       wantedBy = [ "multi-user.target" ];
-      unitConfig.documentation = "man:vnstatd(1) man:vnstat(1) man:vnstat.conf(5)";
+      documentation = [
+        "man:vnstatd(1)"
+        "man:vnstat(1)"
+        "man:vnstat.conf(5)"
+      ];
       preStart = "chmod 755 /var/lib/vnstat";
       serviceConfig = {
         ExecStart = "${pkgs.vnstat}/bin/vnstatd -n";
         ExecReload = "${pkgs.procps}/bin/kill -HUP $MAINPID";
-        ProtectHome = true;
+
+        # Hardening (from upstream example service)
+        ProtectSystem = "strict";
+        StateDirectory = "vnstat";
         PrivateDevices = true;
+        ProtectKernelTunables = true;
+        ProtectControlGroups = true;
+        ProtectHome = true;
+        ProtectKernelModules = true;
         PrivateTmp = true;
+        MemoryDenyWriteExecute = true;
+        RestrictRealtime = true;
+        RestrictNamespaces = true;
+
         User = "vnstatd";
       };
     };
diff --git a/pkgs/applications/networking/vnstat/default.nix b/pkgs/applications/networking/vnstat/default.nix
index b384efc5fe89..7b3e62779e95 100644
--- a/pkgs/applications/networking/vnstat/default.nix
+++ b/pkgs/applications/networking/vnstat/default.nix
@@ -1,20 +1,25 @@
-{ stdenv, fetchurl, gd, ncurses, sqlite }:
+{ stdenv, fetchurl, pkgconfig, gd, ncurses, sqlite, check }:
 
 stdenv.mkDerivation rec {
-  name = "vnstat-${version}";
+  pname = "vnstat";
   version = "2.2";
 
   src = fetchurl {
     sha256 = "0b7020rlc568pz6vkiy28kl8493z88wzrn18wv9b0iq2bv1pn2n6";
-    url = "https://humdi.net/vnstat/${name}.tar.gz";
+    url = "https://humdi.net/${pname}/${pname}-${version}.tar.gz";
   };
 
-  buildInputs = [ gd ncurses sqlite ];
-
   postPatch = ''
     substituteInPlace src/cfg.c --replace /usr/local $out
   '';
 
+  nativeBuildInputs = [ pkgconfig ];
+  buildInputs = [ gd ncurses sqlite ];
+
+  checkInputs = [ check ];
+
+  doCheck = true;
+
   meta = with stdenv.lib; {
     description = "Console-based network statistics utility for Linux";
     longDescription = ''