git.iko.soy/typeable/nixpkgs
on master help sign in
tests/systemd-networkd: add regression test for service group

Previously systemd-networkd.service ran as systemd-network:nogroup. The wireguard private key file is now owned by root:systemd-network with mode 0640. It is therefore required that the systemd-network user is in the group with the same name, so that it is able to read the key file.

commitec16f4fd5b78edcd11f68cb96b41b9a810af315e authorWilliButz <wbutz@cyberfnord.de> dateMon 25 Nov 2019, 10:47 (7 years ago) parentfc91467
1 file changed+7−4
nixos/tests/systemd-networkd-wireguard.nix+7−4
nixos/tests/systemd-networkd-wireguard.nix+7−4
@@ -1,4 +1,4 @@
1−let generateNodeConf = { lib, pkgs, config, privkpath, pubk, peerId, nodeId, ...}: {
1+let generateNodeConf = { lib, pkgs, config, privk, pubk, peerId, nodeId, ...}: {
22 imports = [ common/user-account.nix ];
33 systemd.services.systemd-networkd.environment.SYSTEMD_LOG_LEVEL = "debug";
44 networking.useNetworkd = true;
@@ -7,13 +7,16 @@ let generateNodeConf = { lib, pkgs, config, privkpath, pubk, peerId, nodeId, ...
77 virtualisation.vlans = [ 1 ];
88 environment.systemPackages = with pkgs; [ wireguard-tools ];
99 boot.extraModulePackages = [ config.boot.kernelPackages.wireguard ];
10+ systemd.tmpfiles.rules = [
11+ "f /run/wg_priv 0640 root systemd-network - ${privk}"
12+ ];
1013 systemd.network = {
1114 enable = true;
1215 netdevs = {
1316 "90-wg0" = {
1417 netdevConfig = { Kind = "wireguard"; Name = "wg0"; };
1518 wireguardConfig = {
16− PrivateKeyFile = privkpath ;
19+ PrivateKeyFile = "/run/wg_priv";
1720 ListenPort = 51820;
1821 FwMark = 42;
1922 };
@@ -53,7 +56,7 @@ in import ./make-test-python.nix ({pkgs, ... }: {
5356 nodes = {
5457 node1 = { pkgs, ... }@attrs:
5558 let localConf = {
56− privkpath = pkgs.writeText "priv.key" "GDiXWlMQKb379XthwX0haAbK6hTdjblllpjGX0heP00=";
59+ privk = "GDiXWlMQKb379XthwX0haAbK6hTdjblllpjGX0heP00=";
5760 pubk = "iRxpqj42nnY0Qz8MAQbSm7bXxXP5hkPqWYIULmvW+EE=";
5861 nodeId = "1";
5962 peerId = "2";
@@ -62,7 +65,7 @@ in import ./make-test-python.nix ({pkgs, ... }: {
6265
6366 node2 = { pkgs, ... }@attrs:
6467 let localConf = {
65− privkpath = pkgs.writeText "priv.key" "eHxSI2jwX/P4AOI0r8YppPw0+4NZnjOxfbS5mt06K2k=";
68+ privk = "eHxSI2jwX/P4AOI0r8YppPw0+4NZnjOxfbS5mt06K2k=";
6669 pubk = "27s0OvaBBdHoJYkH9osZpjpgSOVNw+RaKfboT/Sfq0g=";
6770 nodeId = "2";
6871 peerId = "1";