svn commit: samba r21998 - in branches: SAMBA_3_0/source/libsmb SAMBA_3_0_25/source/libsmb

gd at samba.org gd at samba.org
Wed Mar 28 10:00:43 GMT 2007


Author: gd
Date: 2007-03-28 10:00:42 +0000 (Wed, 28 Mar 2007)
New Revision: 21998

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

Log:
Fix tdb keynames in netsamlogon_clear_cached_user().

No point in deleting U/DOMAIN/RID and UG/DOMAIN/RID keys if we only store U/SID
and UG/SID keys :-)

Next we need to verify the need of calling netsamlogon_clear_cached_user() at all.

Guenther


Modified:
   branches/SAMBA_3_0/source/libsmb/samlogon_cache.c
   branches/SAMBA_3_0_25/source/libsmb/samlogon_cache.c


Changeset:
Modified: branches/SAMBA_3_0/source/libsmb/samlogon_cache.c
===================================================================
--- branches/SAMBA_3_0/source/libsmb/samlogon_cache.c	2007-03-28 01:11:27 UTC (rev 21997)
+++ branches/SAMBA_3_0/source/libsmb/samlogon_cache.c	2007-03-28 10:00:42 UTC (rev 21998)
@@ -59,9 +59,10 @@
 ***********************************************************************/
 void netsamlogon_clear_cached_user(TDB_CONTEXT *tdb, NET_USER_INFO_3 *user)
 {
-	fstring domain;
 	TDB_DATA key;
 	BOOL got_tdb = False;
+	DOM_SID sid;
+	fstring key_str, sid_string;
 
 	/* We may need to call this function from smbd which will not have
            winbindd_cache.tdb open.  Open the tdb if a NULL is passed. */
@@ -77,30 +78,25 @@
 		got_tdb = True;
 	}
 
-	unistr2_to_ascii(domain, &user->uni_logon_dom, sizeof(domain) - 1);
+	sid_copy(&sid, &user->dom_sid.sid);
+	sid_append_rid(&sid, user->user_rid);
 
-	/* Clear U/DOMAIN/RID cache entry */
+	/* Clear U/SID cache entry */
 
-	asprintf(&key.dptr, "U/%s/%d", domain, user->user_rid);
-	key.dsize = strlen(key.dptr) - 1; /* keys are not NULL terminated */
+	fstr_sprintf(key_str, "U/%s", sid_to_string(sid_string, &sid));
 
-	DEBUG(10, ("netsamlogon_clear_cached_user: clearing %s\n", key.dptr));
+	DEBUG(10, ("netsamlogon_clear_cached_user: clearing %s\n", key_str));
 
-	tdb_delete(tdb, key);
+	tdb_delete(tdb, string_tdb_data(key_str));
 
-	SAFE_FREE(key.dptr);
+	/* Clear UG/SID cache entry */
 
-	/* Clear UG/DOMAIN/RID cache entry */
+	fstr_sprintf(key_str, "UG/%s", sid_to_string(sid_string, &sid));
 
-	asprintf(&key.dptr, "UG/%s/%d", domain, user->user_rid);
-	key.dsize = strlen(key.dptr) - 1; /* keys are not NULL terminated */
-
 	DEBUG(10, ("netsamlogon_clear_cached_user: clearing %s\n", key.dptr));
 
-	tdb_delete(tdb, key);
+	tdb_delete(tdb, string_tdb_data(key_str));
 
-	SAFE_FREE(key.dptr);
-
 	if (got_tdb)
 		tdb_close(tdb);
 }

Modified: branches/SAMBA_3_0_25/source/libsmb/samlogon_cache.c
===================================================================
--- branches/SAMBA_3_0_25/source/libsmb/samlogon_cache.c	2007-03-28 01:11:27 UTC (rev 21997)
+++ branches/SAMBA_3_0_25/source/libsmb/samlogon_cache.c	2007-03-28 10:00:42 UTC (rev 21998)
@@ -59,9 +59,10 @@
 ***********************************************************************/
 void netsamlogon_clear_cached_user(TDB_CONTEXT *tdb, NET_USER_INFO_3 *user)
 {
-	fstring domain;
 	TDB_DATA key;
 	BOOL got_tdb = False;
+	DOM_SID sid;
+	fstring key_str, sid_string;
 
 	/* We may need to call this function from smbd which will not have
            winbindd_cache.tdb open.  Open the tdb if a NULL is passed. */
@@ -77,30 +78,25 @@
 		got_tdb = True;
 	}
 
-	unistr2_to_ascii(domain, &user->uni_logon_dom, sizeof(domain) - 1);
+	sid_copy(&sid, &user->dom_sid.sid);
+	sid_append_rid(&sid, user->user_rid);
 
-	/* Clear U/DOMAIN/RID cache entry */
+	/* Clear U/SID cache entry */
 
-	asprintf(&key.dptr, "U/%s/%d", domain, user->user_rid);
-	key.dsize = strlen(key.dptr) - 1; /* keys are not NULL terminated */
+	fstr_sprintf(key_str, "U/%s", sid_to_string(sid_string, &sid));
 
-	DEBUG(10, ("netsamlogon_clear_cached_user: clearing %s\n", key.dptr));
+	DEBUG(10, ("netsamlogon_clear_cached_user: clearing %s\n", key_str));
 
-	tdb_delete(tdb, key);
+	tdb_delete(tdb, string_tdb_data(key_str));
 
-	SAFE_FREE(key.dptr);
+	/* Clear UG/SID cache entry */
 
-	/* Clear UG/DOMAIN/RID cache entry */
+	fstr_sprintf(key_str, "UG/%s", sid_to_string(sid_string, &sid));
 
-	asprintf(&key.dptr, "UG/%s/%d", domain, user->user_rid);
-	key.dsize = strlen(key.dptr) - 1; /* keys are not NULL terminated */
-
 	DEBUG(10, ("netsamlogon_clear_cached_user: clearing %s\n", key.dptr));
 
-	tdb_delete(tdb, key);
+	tdb_delete(tdb, string_tdb_data(key_str));
 
-	SAFE_FREE(key.dptr);
-
 	if (got_tdb)
 		tdb_close(tdb);
 }



More information about the samba-cvs mailing list