resolvconf: use correct output files when used with dnsmasq

This commit is contained in:
David McFarland 2024-10-15 23:00:40 -03:00
parent 538f39e5cf
commit 403604ca66
3 changed files with 20 additions and 3 deletions

View File

@ -114,6 +114,15 @@ in
''; '';
}; };
subscriberFiles = lib.mkOption {
type = lib.types.listOf lib.types.path;
default = [];
description = ''
Files written by resolvconf updates
'';
internal = true;
};
}; };
}; };
@ -134,6 +143,8 @@ in
(lib.mkIf cfg.enable { (lib.mkIf cfg.enable {
users.groups.resolvconf = {}; users.groups.resolvconf = {};
networking.resolvconf.subscriberFiles = [ "/etc/resolv.conf" ];
networking.resolvconf.package = pkgs.openresolv; networking.resolvconf.package = pkgs.openresolv;
environment.systemPackages = [ cfg.package ]; environment.systemPackages = [ cfg.package ];
@ -150,8 +161,9 @@ in
script = '' script = ''
${lib.getExe cfg.package} -u ${lib.getExe cfg.package} -u
chgrp -R resolvconf /etc/resolv.conf /run/resolvconf files=(/run/resolvconf ${lib.escapeShellArgs cfg.subscriberFiles})
chmod -R g=u /etc/resolv.conf /run/resolvconf chgrp -R resolvconf "''${files[@]}"
chmod -R g=u "''${files[@]}"
''; '';
}; };

View File

@ -250,7 +250,7 @@ in
Restart = "always"; Restart = "always";
AmbientCapabilities = [ "CAP_NET_ADMIN" "CAP_NET_RAW" "CAP_NET_BIND_SERVICE" ]; AmbientCapabilities = [ "CAP_NET_ADMIN" "CAP_NET_RAW" "CAP_NET_BIND_SERVICE" ];
ReadWritePaths = [ "/proc/sys/net/ipv6" ] ReadWritePaths = [ "/proc/sys/net/ipv6" ]
++ lib.optionals useResolvConf [ "/etc/resolv.conf" "/run/resolvconf" ]; ++ lib.optionals useResolvConf ([ "/run/resolvconf" ] ++ config.networking.resolvconf.subscriberFiles);
DeviceAllow = ""; DeviceAllow = "";
LockPersonality = true; LockPersonality = true;
MemoryDenyWriteExecute = true; MemoryDenyWriteExecute = true;

View File

@ -133,6 +133,11 @@ in
dnsmasq_conf=/etc/dnsmasq-conf.conf dnsmasq_conf=/etc/dnsmasq-conf.conf
dnsmasq_resolv=/etc/dnsmasq-resolv.conf dnsmasq_resolv=/etc/dnsmasq-resolv.conf
''; '';
subscriberFiles = [
"/etc/dnsmasq-conf.conf"
"/etc/dnsmasq-resolv.conf"
];
}; };
systemd.services.dnsmasq = { systemd.services.dnsmasq = {