From aca8225e3b3e5a9d4ca2dc4a66ef6b4ce723d214 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Sat, 21 Jan 2012 19:13:43 +0000 Subject: [PATCH] * Invalidate the nscd hosts cache when an "ip-up" event occurs. This event is emitted by dhclient and by the network-interfaces job in case of statically configured interfaces. Invalidating the cache is necessary to get rid of negative queries. svn path=/nixos/trunk/; revision=31779 --- modules/services/networking/dhclient.nix | 2 -- modules/services/system/nscd.nix | 10 ++++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/modules/services/networking/dhclient.nix b/modules/services/networking/dhclient.nix index 38454d421b12..5d82854fef50 100644 --- a/modules/services/networking/dhclient.nix +++ b/modules/services/networking/dhclient.nix @@ -20,8 +20,6 @@ let #echo "$exit_status" >> /tmp/dhcp-exit if test "$reason" = BOUND -o "$reason" = REBOOT; then - ${pkgs.glibc}/sbin/nscd --invalidate hosts - # Restart ntpd. (The "ip-up" event below will trigger the # restart.) We need to restart it to make sure that it will # actually do something: if ntpd cannot resolve the server diff --git a/modules/services/system/nscd.nix b/modules/services/system/nscd.nix index 22d6e38a74b4..3f6ef510f5cd 100644 --- a/modules/services/system/nscd.nix +++ b/modules/services/system/nscd.nix @@ -57,5 +57,15 @@ in exec = "nscd -f ${./nscd.conf} -d 2> /dev/null"; }; + # Flush nscd's ‘hosts’ database when the network comes up to get + # rid of any negative entries. + jobs.invalidate_nscd = + { name = "invalidate-nscd"; + description = "Invalidate NSCD cache"; + startOn = "ip-up"; + task = true; + exec = "${pkgs.glibc}/sbin/nscd --invalidate hosts"; + }; + }; }