r14321: When we have libnscd and winbindd comes (back) online, try to flush the
authorGünther Deschner <gd@samba.org>
Mon, 13 Mar 2006 15:13:35 +0000 (15:13 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 16:15:24 +0000 (11:15 -0500)
nscd caches so that NSS-calls can deliver accurate information.

Guenther
(This used to be commit a32a423a0e9e0d4dd21282fd528bcd3247fddbd1)

source3/Makefile.in
source3/configure.in
source3/nsswitch/winbindd.h
source3/nsswitch/winbindd_dual.c

index c178fbaa85807cbf18f756fd78ba3e9895704ee9..a6cc3d8255dab45f2f4aea1c80232391cee118f9 100644 (file)
@@ -35,6 +35,7 @@ PASSDB_LIBS=@PASSDB_LIBS@
 IDMAP_LIBS=@IDMAP_LIBS@
 KRB5LIBS=@KRB5_LIBS@
 LDAP_LIBS=@LDAP_LIBS@
+NSCD_LIBS=@NSCD_LIBS@
 
 INSTALLCMD=@INSTALL@
 INSTALLLIBCMD_SH=@INSTALLLIBCMD_SH@
@@ -1180,7 +1181,7 @@ bin/librpc_echo.@SHLIBEXT@: $(RPC_ECHO_OBJ)
 bin/winbindd@EXEEXT@: $(WINBINDD_OBJ) @BUILD_POPT@ bin/.dummy
        @echo "Linking $@"
        @$(CC) $(FLAGS) @PIE_LDFLAGS@ -o $@ $(WINBINDD_OBJ) $(LDFLAGS) $(DYNEXP) $(LIBS) \
-               @POPTLIBS@ $(KRB5LIBS) $(LDAP_LIBS) $(PASSDB_LIBS)
+               @POPTLIBS@ $(KRB5LIBS) $(LDAP_LIBS) $(PASSDB_LIBS) $(NSCD_LIBS)
 
 # Please don't add .o files to libnss_winbind, libnss_wins, or the pam_winbind
 # libraries.  Add to the appropriate PICOBJ variable instead.
index fd1648010d0a36fc0e09f63d0f06b1ce30b3ae61..7369b07959d0c6f1a6289ea4a9c624374e21f0a2 100644 (file)
@@ -266,6 +266,7 @@ AC_SUBST(UNINSTALL_CIFSMOUNT)
 AC_SUBST(EXTRA_SBIN_PROGS)
 AC_SUBST(EXTRA_ALL_TARGETS)
 AC_SUBST(CONFIG_LIBS)
+AC_SUBST(NSCD_LIBS)
 
 # Set defaults
 PIE_CFLAGS=""
@@ -3528,6 +3529,8 @@ if test x"$with_ads_support" != x"no"; then
 LIBS="$ac_save_LIBS"
 fi
 
+AC_CHECK_LIB_EXT(nscd, NSCD_LIBS, nscd_flush_cache)
+
 #################################################
 # check for automount support
 AC_MSG_CHECKING(whether to use automount)
index e81102571c922c57f8f005cd85fa5b07050c5147..6a220438a9be9324ec382fb5bc55304e2f15e07b 100644 (file)
 
 #include "winbindd_nss.h"
 
+#ifdef HAVE_LIBNSCD
+#include "libnscd.h"
+#endif
+
 #undef DBGC_CLASS
 #define DBGC_CLASS DBGC_WINBIND
 
index 7864254c4656c6db77c71034c0596314928319ce..b77f49979922d9ab69408d08969cc19d679bee76 100644 (file)
@@ -559,6 +559,7 @@ static void child_msg_offline(int msg_type, struct process_id src, void *buf, si
 static void child_msg_online(int msg_type, struct process_id src, void *buf, size_t len)
 {
        struct winbindd_domain *domain;
+       int ret;
 
        DEBUG(5,("child_msg_online received.\n"));
 
@@ -570,6 +571,21 @@ static void child_msg_online(int msg_type, struct process_id src, void *buf, siz
        /* Set our global state as online. */
        set_global_winbindd_state_online();
 
+#ifdef HAVE_NSCD_FLUSH_CACHE
+       /* Flush nscd caches to get accurate new information */
+       ret = nscd_flush_cache("passwd");
+       if (ret) {
+               DEBUG(5,("failed to flush nscd cache for 'passwd' service: %s\n",
+                       error_message(ret)));
+       }
+
+       ret = nscd_flush_cache("group");
+       if (ret) {
+               DEBUG(5,("failed to flush nscd cache for 'group' service: %s\n",
+                       error_message(ret)));
+       }
+#endif
+
        /* Mark everything online - delete any negative cache entries
           to force an immediate reconnect. */