Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 301720 - net-misc/networkmanager-0.7.2: stops nscd instead of invalidating its cache
Summary: net-misc/networkmanager-0.7.2: stops nscd instead of invalidating its cache
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: AMD64 Linux
: High normal
Assignee: Robert Piasek (RETIRED)
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-01-21 13:41 UTC by Ambroz Bizjak
Modified: 2010-03-22 09:10 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
patch to not stop nscd (networkmanager-0.7.2-nscd.patch,859 bytes, patch)
2010-01-21 13:42 UTC, Ambroz Bizjak
Details | Diff
Clear nscd hosts cache if nscd is installed. (NetworkManagerGentoo.diff,661 bytes, patch)
2010-02-12 10:21 UTC, Robert Piasek (RETIRED)
Details | Diff
Clear nscd hosts cache if nscd is installed. (0001-fix-use-nscd-i-to-clear-cache.patch,1.19 KB, patch)
2010-02-22 10:37 UTC, Robert Piasek (RETIRED)
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Ambroz Bizjak 2010-01-21 13:41:57 UTC
When NetworkManager changes /etc/resolv.conf, it wants to inform nscd (the service that caches dns names, among others). Most distribution backends in NetworkManager just do "/usr/sbin/nscd -i hosts", which invalidates the hosts cache. But the Gentoo backend for some reason stops nscd entirely with "/usr/bin/killall -q nscd". There is code for restarting it, but is under "#ifdef NM_NO_NAMED" which seems to me is never defined. That makes it impossible to use nscd with NetworkManager. For example, nscd will be killed whenever a connection is lost or made, and when NetworkManager exits. The init script reports that nscd crashed when this happens.

I've made a patch to invalidate nscd's cache rather than stopping it (it is not needed to check if nscd is running, in that case the program will just do nothing).

Reproducible: Always

Steps to Reproduce:
1. /etc/init.d/nscd start
2. /etc/init.d/NetoworkManager start
3. /etc/init.d/NetoworkManager stop
4. /etc/init.d/nscd status
Actual Results:  
    * status: crashed

Expected Results:  
NetworkManager shouldn't kill nscd.
Comment 1 Ambroz Bizjak 2010-01-21 13:42:49 UTC
Created attachment 217076 [details, diff]
patch to not stop nscd
Comment 2 Jeroen Roovers (RETIRED) gentoo-dev 2010-01-22 01:50:20 UTC
The Gentoo backend seems to kill any loose nscd instances only when it finds no instance was started by the init.d script. So if nscd was running on your system because you really wanted it to, then it would restart the service.

You could argue that it (the init.d script) should learn to invalidate the cache (the reload command is often used in that case) so that the service does not need to be restarted. After that you could change the nm backend to reflect that.
Comment 3 Ambroz Bizjak 2010-01-22 14:25:45 UTC
(In reply to comment #2)
> The Gentoo backend seems to kill any loose nscd instances only when it finds no
> instance was started by the init.d script. So if nscd was running on your
> system because you really wanted it to, then it would restart the service.
No, this is not what it does. Take a look at the code:

void nm_system_update_dns (void)
{
 #ifdef NM_NO_NAMED
	if (nm_spawn_process ("/etc/init.d/nscd status") == 0)
		nm_spawn_process ("/etc/init.d/nscd restart");
 #else
	nm_spawn_process("/usr/bin/killall -q nscd");
 #endif
}

Seeing that NM_NO_NAMED is never defined, it can be concluded that it always kills nscd, no matter what started it.

> You could argue that it (the init.d script) should learn to invalidate the
> cache (the reload command is often used in that case) so that the service does
> not need to be restarted. After that you could change the nm backend to reflect
> that.
nscd doesn't have a reload command. It supports invalidating a specific cache (e.g. the hosts cache), and this is done by connecting to the nscd server, rather than with a signal.
As nscd is designed to run as a single instance (it is hardcoded to use /var/run/nscd/socket), it always correct to do "/usr/sbin/nscd -i hosts". Nothing would benefit adding a reload command to the init script that does just that.
Comment 4 Robert Piasek (RETIRED) gentoo-dev 2010-02-12 10:21:40 UTC
Created attachment 219321 [details, diff]
Clear nscd hosts cache if nscd is installed.

I think it would be better to add one extra if.
Comment 5 Robert Piasek (RETIRED) gentoo-dev 2010-02-22 10:37:57 UTC
Created attachment 220679 [details, diff]
Clear nscd hosts cache if nscd is installed.

I submitted that patch upstream
Comment 6 Robert Piasek (RETIRED) gentoo-dev 2010-02-22 10:52:07 UTC
I'll be adding 0.8 to the tree very soon (once upstream make an official announcement) with this patch included.
Comment 7 Robert Piasek (RETIRED) gentoo-dev 2010-02-22 11:10:38 UTC
already committed upstream:
http://cgit.freedesktop.org/NetworkManager/NetworkManager/commit/?id=2183af36b6cb06d7d686f8e7913b63983cd3a172

courtesy of Alexander Sack 
Comment 8 Robert Piasek (RETIRED) gentoo-dev 2010-03-22 09:10:41 UTC
Included with Networkmanager-0.8