svn commit: samba r5647 - in branches/SAMBA_3_0/source: auth groupdb lib rpc_server

vlendec at samba.org vlendec at samba.org
Thu Mar 3 16:52:45 GMT 2005


Author: vlendec
Date: 2005-03-03 16:52:44 +0000 (Thu, 03 Mar 2005)
New Revision: 5647

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=5647

Log:
Caches are good for performance, but you get a consistency problem.

Fix bug # 2401.

Volker

Modified:
   branches/SAMBA_3_0/source/auth/auth_util.c
   branches/SAMBA_3_0/source/groupdb/mapping.c
   branches/SAMBA_3_0/source/lib/util_pw.c
   branches/SAMBA_3_0/source/rpc_server/srv_samr_nt.c


Changeset:
Modified: branches/SAMBA_3_0/source/auth/auth_util.c
===================================================================
--- branches/SAMBA_3_0/source/auth/auth_util.c	2005-03-03 09:26:08 UTC (rev 5646)
+++ branches/SAMBA_3_0/source/auth/auth_util.c	2005-03-03 16:52:44 UTC (rev 5647)
@@ -50,6 +50,7 @@
 	if (homedir)
 		all_string_sub(add_script, "%H", homedir, sizeof(pstring));
 	ret = smbrun(add_script,NULL);
+	flush_pwnam_cache();
 	DEBUG(ret ? 0 : 3,("smb_create_user: Running the command `%s' gave %d\n",add_script,ret));
 	return ret;
 }

Modified: branches/SAMBA_3_0/source/groupdb/mapping.c
===================================================================
--- branches/SAMBA_3_0/source/groupdb/mapping.c	2005-03-03 09:26:08 UTC (rev 5646)
+++ branches/SAMBA_3_0/source/groupdb/mapping.c	2005-03-03 16:52:44 UTC (rev 5647)
@@ -1050,6 +1050,7 @@
 		all_string_sub(add_script, "%g", unix_group, sizeof(add_script));
 		all_string_sub(add_script, "%u", unix_user, sizeof(add_script));
 		ret = smbrun(add_script,NULL);
+		flush_pwnam_cache();
 		DEBUG(ret ? 0 : 3,("smb_set_primary_group: "
 			 "Running the command `%s' gave %d\n",add_script,ret));
 		return ret;
@@ -1060,6 +1061,7 @@
 	if ( winbind_set_user_primary_group( unix_user, unix_group ) ) {
 		DEBUG(3,("smb_delete_group: winbindd set the group (%s) as the primary group for user (%s)\n",
 			unix_group, unix_user));
+		flush_pwnam_cache();
 		return 0;
 	}		
 	

Modified: branches/SAMBA_3_0/source/lib/util_pw.c
===================================================================
--- branches/SAMBA_3_0/source/lib/util_pw.c	2005-03-03 09:26:08 UTC (rev 5646)
+++ branches/SAMBA_3_0/source/lib/util_pw.c	2005-03-03 16:52:44 UTC (rev 5647)
@@ -70,6 +70,20 @@
 	return;
 }
 
+void flush_pwnam_cache(void)
+{
+	int i;
+
+	init_pwnam_cache();
+
+	for (i=0; i<PWNAMCACHE_SIZE; i++) {
+		if (pwnam_cache[i] == NULL)
+			continue;
+
+		passwd_free(&pwnam_cache[i]);
+	}
+}
+
 struct passwd *getpwnam_alloc(const char *name) 
 {
 	int i;

Modified: branches/SAMBA_3_0/source/rpc_server/srv_samr_nt.c
===================================================================
--- branches/SAMBA_3_0/source/rpc_server/srv_samr_nt.c	2005-03-03 09:26:08 UTC (rev 5646)
+++ branches/SAMBA_3_0/source/rpc_server/srv_samr_nt.c	2005-03-03 16:52:44 UTC (rev 5647)
@@ -2335,6 +2335,7 @@
 	
 	/* implicit call to getpwnam() next.  we have a valid SID coming out of this call */
 
+	flush_pwnam_cache();
 	nt_status = pdb_init_sam_new(&sam_pass, account, new_rid);
 
 	/* this code is order such that we have no unnecessary retuns 
@@ -3805,6 +3806,7 @@
 		return -1;
 	all_string_sub(del_script, "%u", unix_user, sizeof(del_script));
 	ret = smbrun(del_script,NULL);
+	flush_pwnam_cache();
 	DEBUG(ret ? 0 : 3,("smb_delete_user: Running the command `%s' gave %d\n",del_script,ret));
 
 	return ret;



More information about the samba-cvs mailing list