[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#516212: nscd: init script doesn't flush cache during restart/reload



Package: nscd
Version: 2.7-10

I think I have found a couple closely related long-standing bugs related
to flushing the caches in the init script for nscd:

1. Can't flush the cache when nscd isn't running

Using /etc/init.d/nscd reload|restart is supposed to invalidate, or
flush, the caches for the passwd, group and hosts databases.  However
the way the init script works is that it first stops nscd, then tries to
flush the caches, and then it restarts nscd.  However, the --invalidate
flag seems to require that nscd be running and it silently fails to do
anything when nscd isn't running!  (the silent part seems like an nscd bug to me!)

2. nscd ignores more than one --invalidate option

The init script currently tries to flush the caches for the passwd,
group, and hosts tables all with one command.  However nscd seems to
silently ignore more than one instance of the --invalidate flag, so only
the passwd table would be flushed using the current init script, *if*
nscd was even running (see bug #1 above).

I would be glad to provide a transcript of 'nscd -g' invocations to show
what I'm seeing if that would be helpful.

The fix
-------
1. Run the --invalidate commands before stopping nscd or after
restarting it.
2. Run a separate --invalidate command for each table.
3. [Optional] convince upstream glibc developers to make nscd complain
loudly when more than one --invalidate flag is passed, and when
--invalidate is attempted when nscd isn't even up and running just like 'nscd -g' fails loudly when nscd isn't running.

Here is a patch against /etc/init.d/nscd from the latest experimental
nscd v2.9-0exp2 which fixes the problems for me:
--- nscd	2009-01-20 10:17:49.000000000 -0500
+++ nscd.fixed	2009-02-19 15:32:04.602864750 -0500
@@ -93,8 +93,10 @@
 	;;
 restart|force-reload|reload)
 	log_daemon_msg "Restarting $DESC" "$NAME"
+	for table in passwd group hosts; do
+		$DAEMON --invalidate $table
+	done
 	stop_nscd
-	$DAEMON --invalidate passwd --invalidate group --invalidate hosts
 	case "$?" in
 	0|1)
 		start_nscd

FYI, I first noticed the behavior on an Ubuntu Server 8.04 system with nscd
version 2.7-10ubuntu4, then I was able to reproduce it on an old Debian
server we have that has nscd version 2.3.6-15. It seems hard to believe that these bugs have been there for 2.5 years in Debian and Ubuntu! :)

Thanks in advance for your help getting this straightened out for me and everyone else!

Jason



Reply to: