summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source3/Makefile.in4
-rw-r--r--source3/groupdb/mapping.c17
-rw-r--r--source3/include/includes.h4
-rw-r--r--source3/lib/util.c21
-rw-r--r--source3/nsswitch/winbindd.c3
-rw-r--r--source3/nsswitch/winbindd_dual.c3
-rw-r--r--source3/nsswitch/winbindd_util.c21
-rw-r--r--source3/passdb/pdb_interface.c6
-rw-r--r--source3/passdb/pdb_ldap.c4
-rw-r--r--source3/passdb/pdb_smbpasswd.c4
-rw-r--r--source3/passdb/pdb_tdb.c4
-rw-r--r--source3/utils/net_rpc_samsync.c3
12 files changed, 68 insertions, 26 deletions
diff --git a/source3/Makefile.in b/source3/Makefile.in
index a8db82576c..49daac8f92 100644
--- a/source3/Makefile.in
+++ b/source3/Makefile.in
@@ -965,7 +965,7 @@ bin/smbd@EXEEXT@: $(SMBD_OBJ) @BUILD_POPT@ bin/.dummy
@echo Linking $@
@$(CC) $(FLAGS) @PIE_LDFLAGS@ -o $@ $(SMBD_OBJ) $(LDFLAGS) $(LDAP_LIBS) \
$(KRB5LIBS) $(DYNEXP) $(PRINT_LIBS) $(AUTH_LIBS) \
- $(ACL_LIBS) $(PASSDB_LIBS) $(LIBS) @POPTLIBS@ @SMBD_LIBS@
+ $(ACL_LIBS) $(PASSDB_LIBS) $(LIBS) @POPTLIBS@ @SMBD_LIBS@ $(NSCD_LIBS)
bin/nmbd@EXEEXT@: $(NMBD_OBJ) @BUILD_POPT@ bin/.dummy
@echo Linking $@
@@ -992,7 +992,7 @@ bin/smbctool@EXEEXT@: $(TOOL_OBJ) @BUILD_POPT@ bin/.dummy
bin/net@EXEEXT@: $(NET_OBJ) @BUILD_POPT@ bin/.dummy
@echo Linking $@
- @$(CC) $(FLAGS) @PIE_LDFLAGS@ -o $@ $(NET_OBJ) $(DYNEXP) $(LDFLAGS) $(LIBS) @POPTLIBS@ $(KRB5LIBS) $(UUID_LIBS) $(LDAP_LIBS) $(PASSDB_LIBS) $(TERMLDFLAGS) $(TERMLIBS)
+ @$(CC) $(FLAGS) @PIE_LDFLAGS@ -o $@ $(NET_OBJ) $(DYNEXP) $(LDFLAGS) $(LIBS) @POPTLIBS@ $(KRB5LIBS) $(UUID_LIBS) $(LDAP_LIBS) $(PASSDB_LIBS) $(TERMLDFLAGS) $(TERMLIBS) $(NSCD_LIBS)
bin/profiles@EXEEXT@: $(PROFILES_OBJ) @BUILD_POPT@ bin/.dummy
@echo Linking $@
diff --git a/source3/groupdb/mapping.c b/source3/groupdb/mapping.c
index 3d7b9f3f91..1d7934e9bf 100644
--- a/source3/groupdb/mapping.c
+++ b/source3/groupdb/mapping.c
@@ -878,9 +878,12 @@ int smb_create_group(const char *unix_group, gid_t *new_gid)
pstring_sub(add_script, "%g", unix_group);
ret = smbrun(add_script, &fd);
DEBUG(ret ? 0 : 3,("smb_create_group: Running the command `%s' gave %d\n",add_script,ret));
+ if (ret == 0) {
+ smb_nscd_flush_group_cache();
+ }
if (ret != 0)
return ret;
-
+
if (fd != 0) {
fstring output;
@@ -920,6 +923,9 @@ int smb_delete_group(const char *unix_group)
pstring_sub(del_script, "%g", unix_group);
ret = smbrun(del_script,NULL);
DEBUG(ret ? 0 : 3,("smb_delete_group: Running the command `%s' gave %d\n",del_script,ret));
+ if (ret == 0) {
+ smb_nscd_flush_group_cache();
+ }
return ret;
}
@@ -944,6 +950,9 @@ int smb_set_primary_group(const char *unix_group, const char* unix_user)
flush_pwnam_cache();
DEBUG(ret ? 0 : 3,("smb_set_primary_group: "
"Running the command `%s' gave %d\n",add_script,ret));
+ if (ret == 0) {
+ smb_nscd_flush_group_cache();
+ }
return ret;
}
@@ -967,6 +976,9 @@ int smb_add_user_group(const char *unix_group, const char *unix_user)
pstring_sub(add_script, "%u", unix_user);
ret = smbrun(add_script,NULL);
DEBUG(ret ? 0 : 3,("smb_add_user_group: Running the command `%s' gave %d\n",add_script,ret));
+ if (ret == 0) {
+ smb_nscd_flush_group_cache();
+ }
return ret;
}
@@ -990,6 +1002,9 @@ int smb_delete_user_group(const char *unix_group, const char *unix_user)
pstring_sub(del_script, "%u", unix_user);
ret = smbrun(del_script,NULL);
DEBUG(ret ? 0 : 3,("smb_delete_user_group: Running the command `%s' gave %d\n",del_script,ret));
+ if (ret == 0) {
+ smb_nscd_flush_group_cache();
+ }
return ret;
}
diff --git a/source3/include/includes.h b/source3/include/includes.h
index 6c152bff0c..bcf0fa4277 100644
--- a/source3/include/includes.h
+++ b/source3/include/includes.h
@@ -1237,4 +1237,8 @@ void exit_server(const char *const reason) NORETURN_ATTRIBUTE ;
void exit_server_cleanly(const char *const reason) NORETURN_ATTRIBUTE ;
void exit_server_fault(void) NORETURN_ATTRIBUTE ;
+#ifdef HAVE_LIBNSCD
+#include "libnscd.h"
+#endif
+
#endif /* _INCLUDES_H */
diff --git a/source3/lib/util.c b/source3/lib/util.c
index e04ed977bb..2391566e6c 100644
--- a/source3/lib/util.c
+++ b/source3/lib/util.c
@@ -3017,3 +3017,24 @@ int this_is_smp(void)
return 0;
#endif
}
+
+static void smb_nscd_flush_cache(const char *service)
+{
+#ifdef HAVE_NSCD_FLUSH_CACHE
+ if (!nscd_flush_cache(service)) {
+ DEBUG(10,("failed to flush nscd cache for '%s' service: %s. "
+ "Is nscd running?\n",
+ service, strerror(errno)));
+ }
+#endif
+}
+
+void smb_nscd_flush_user_cache(void)
+{
+ return smb_nscd_flush_cache("passwd");
+}
+
+void smb_nscd_flush_group_cache(void)
+{
+ return smb_nscd_flush_cache("group");
+}
diff --git a/source3/nsswitch/winbindd.c b/source3/nsswitch/winbindd.c
index df8f821c8b..8d5a7042c6 100644
--- a/source3/nsswitch/winbindd.c
+++ b/source3/nsswitch/winbindd.c
@@ -1063,7 +1063,8 @@ int main(int argc, char **argv)
init_idmap_child();
- winbindd_flush_nscd_cache();
+ smb_nscd_flush_user_cache();
+ smb_nscd_flush_group_cache();
/* Loop waiting for requests */
diff --git a/source3/nsswitch/winbindd_dual.c b/source3/nsswitch/winbindd_dual.c
index 128c468dd3..1a3de3f1e5 100644
--- a/source3/nsswitch/winbindd_dual.c
+++ b/source3/nsswitch/winbindd_dual.c
@@ -606,7 +606,8 @@ 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();
- winbindd_flush_nscd_cache();
+ smb_nscd_flush_user_cache();
+ smb_nscd_flush_group_cache();
/* Try and mark everything online - delete any negative cache entries
to force a reconnect now. */
diff --git a/source3/nsswitch/winbindd_util.c b/source3/nsswitch/winbindd_util.c
index a99115690d..4d99b0fbe6 100644
--- a/source3/nsswitch/winbindd_util.c
+++ b/source3/nsswitch/winbindd_util.c
@@ -1218,27 +1218,6 @@ BOOL winbindd_upgrade_idmap(void)
return idmap_convert(idmap_name);
}
-void winbindd_flush_nscd_cache(void)
-{
-#ifdef HAVE_NSCD_FLUSH_CACHE
-
- /* Flush nscd caches to get accurate new information */
- int ret = nscd_flush_cache("passwd");
- if (ret) {
- DEBUG(5,("failed to flush nscd cache for 'passwd' service: %s\n",
- strerror(errno)));
- }
-
- ret = nscd_flush_cache("group");
- if (ret) {
- DEBUG(5,("failed to flush nscd cache for 'group' service: %s\n",
- strerror(errno)));
- }
-#else
- return;
-#endif
-}
-
NTSTATUS lookup_usergroups_cached(struct winbindd_domain *domain,
TALLOC_CTX *mem_ctx,
const DOM_SID *user_sid,
diff --git a/source3/passdb/pdb_interface.c b/source3/passdb/pdb_interface.c
index cc05d97468..7252ea4c8c 100644
--- a/source3/passdb/pdb_interface.c
+++ b/source3/passdb/pdb_interface.c
@@ -366,6 +366,9 @@ static NTSTATUS pdb_default_create_user(struct pdb_methods *methods,
add_ret = smbrun(add_script,NULL);
DEBUG(add_ret ? 0 : 3, ("_samr_create_user: Running the command `%s' gave %d\n",
add_script, add_ret));
+ if (add_ret == 0) {
+ smb_nscd_flush_user_cache();
+ }
#ifdef ENABLE_BUILD_FARM_HACKS
if (add_ret != 0) {
@@ -443,6 +446,9 @@ static int smb_delete_user(const char *unix_user)
all_string_sub(del_script, "%u", unix_user, sizeof(del_script));
ret = smbrun(del_script,NULL);
flush_pwnam_cache();
+ if (ret == 0) {
+ smb_nscd_flush_user_cache();
+ }
DEBUG(ret ? 0 : 3,("smb_delete_user: Running the command `%s' gave %d\n",del_script,ret));
return ret;
diff --git a/source3/passdb/pdb_ldap.c b/source3/passdb/pdb_ldap.c
index e0f79c140d..0f03a1cc6e 100644
--- a/source3/passdb/pdb_ldap.c
+++ b/source3/passdb/pdb_ldap.c
@@ -1870,6 +1870,10 @@ static NTSTATUS ldapsam_rename_sam_account(struct pdb_methods *my_methods,
DEBUG(rc ? 0 : 3,("Running the command `%s' gave %d\n",
rename_script, rc));
+ if (rc == 0) {
+ smb_nscd_flush_user_cache();
+ }
+
if (rc)
return NT_STATUS_UNSUCCESSFUL;
diff --git a/source3/passdb/pdb_smbpasswd.c b/source3/passdb/pdb_smbpasswd.c
index 905cf8f2a2..afc00445f4 100644
--- a/source3/passdb/pdb_smbpasswd.c
+++ b/source3/passdb/pdb_smbpasswd.c
@@ -1550,6 +1550,10 @@ static NTSTATUS smbpasswd_rename_sam_account (struct pdb_methods *my_methods,
DEBUG(rename_ret ? 0 : 3,("Running the command `%s' gave %d\n", rename_script, rename_ret));
+ if (rename_ret == 0) {
+ smb_nscd_flush_user_cache();
+ }
+
if (rename_ret)
goto done;
} else {
diff --git a/source3/passdb/pdb_tdb.c b/source3/passdb/pdb_tdb.c
index b16368baf1..e9beaa0536 100644
--- a/source3/passdb/pdb_tdb.c
+++ b/source3/passdb/pdb_tdb.c
@@ -1461,6 +1461,10 @@ static NTSTATUS tdbsam_rename_sam_account(struct pdb_methods *my_methods,
DEBUG(rename_ret ? 0 : 3,("Running the command `%s' gave %d\n", rename_script, rename_ret));
+ if (rename_ret == 0) {
+ smb_nscd_flush_user_cache();
+ }
+
if (rename_ret) {
goto done;
}
diff --git a/source3/utils/net_rpc_samsync.c b/source3/utils/net_rpc_samsync.c
index 0b54a6c97f..1337c11eca 100644
--- a/source3/utils/net_rpc_samsync.c
+++ b/source3/utils/net_rpc_samsync.c
@@ -508,6 +508,9 @@ static NTSTATUS fetch_account_info(uint32 rid, SAM_ACCOUNT_INFO *delta)
add_ret = smbrun(add_script,NULL);
DEBUG(add_ret ? 0 : 1,("fetch_account: Running the command `%s' "
"gave %d\n", add_script, add_ret));
+ if (add_ret == 0) {
+ smb_nscd_flush_user_cache();
+ }
}
/* try and find the possible unix account again */