git.iko.soy/typeable/nixpkgs
on master help sign in
nixos/rdnssd: Major refactoring

This updates rdnssd to the following: * Using the systemd interfaces directly * Using the rdnssd user instead of the root user * Integrating with resolvconf instead of writing directly to /etc/resolv.conf

commitb3c423757e9f574ed51e1e5f01c7dfa1777def97 authorWilliam A. Kennington III <william@wkennington.com> dateSat 4 Apr 2015, 21:20 (12 years ago) parent45b37ca
2 files changed+40−12
nixos/modules/misc/ids.nix+2 nixos/modules/services/networking/rdnssd.nix+38−12
nixos/modules/misc/ids.nix+2
@@ -213,6 +213,7 @@
213213 zope2 = 185;
214214 ripple-data-api = 186;
215215 mediatomb = 187;
216+ rdnssd = 188;
216217
217218 # When adding a uid, make sure it doesn't match an existing gid. And don't use uids above 399!
218219
@@ -403,6 +404,7 @@
403404 #zope2 = 185; # unused
404405 #ripple-data-api = 186; #unused
405406 mediatomb = 187;
407+ #rdnssd = 188; # unused
406408
407409 # When adding a gid, make sure it doesn't match an existing
408410 # uid. Users and groups with the same name should have equal
nixos/modules/services/networking/rdnssd.nix+38−12
@@ -4,7 +4,12 @@
44{ config, lib, pkgs, ... }:
55
66with lib;
7−
7+let
8+ mergeHook = pkgs.writeScript "rdnssd-merge-hook" ''
9+ #! ${pkgs.stdenv.shell} -e
10+ ${pkgs.openresolv}/bin/resolvconf -u
11+ '';
12+in
813{
914
1015 ###### interface
@@ -30,18 +35,39 @@ with lib;
3035
3136 config = mkIf config.services.rdnssd.enable {
3237
33− jobs.rdnssd =
34− { description = "RDNSS daemon";
35−
36− # Start before the network interfaces are brought up so that
37− # the daemon receives RDNSS advertisements from the kernel.
38− startOn = "starting network-interfaces";
39−
40− # !!! Should write to /var/run/rdnssd/resolv.conf and run the daemon under another uid.
41− exec = "${pkgs.ndisc6}/sbin/rdnssd --resolv-file /etc/resolv.conf -u root";
42−
43− daemonType = "fork";
38+ systemd.services.rdnssd = {
39+ description = "RDNSS daemon";
40+ after = [ "network.target" ];
41+ wantedBy = [ "multi-user.target" ];
42+
43+ preStart = ''
44+ # Create the proper run directory
45+ mkdir -p /run/rdnssd
46+ touch /run/rdnssd/resolv.conf
47+ chown -R rdnssd /run/rdnssd
48+
49+ # Link the resolvconf interfaces to rdnssd
50+ rm -f /run/resolvconf/interfaces/rdnssd
51+ ln -s /run/rdnssd/resolv.conf /run/resolvconf/interfaces/rdnssd
52+ ${mergeHook}
53+ '';
54+
55+ postStop = ''
56+ rm -f /run/resolvconf/interfaces/rdnssd
57+ ${mergeHook}
58+ '';
59+
60+ serviceConfig = {
61+ ExecStart = "@${pkgs.ndisc6}/bin/rdnssd rdnssd -p /run/rdnssd/rdnssd.pid -r /run/rdnssd/resolv.conf -u rdnssd -H ${mergeHook}";
62+ Type = "forking";
63+ PIDFile = "/run/rdnssd/rdnssd.pid";
4464 };
65+ };
66+
67+ users.extraUsers.rdnssd = {
68+ description = "RDNSSD Daemon User";
69+ uid = config.ids.uids.rdnssd;
70+ };
4571
4672 };
4773