[SCM] Samba Shared Repository - branch master updated

Michael Adam obnox at samba.org
Fri Apr 20 16:56:04 MDT 2012


The branch, master has been updated
       via  c0ba829 s3:smbcontrol: remove an unused variable
       via  8e690ed s3:memcache: remove the idmap-part from memcache
       via  499e737 s3:id_cache: do not use the in-memory idmap cache (it is going to be removed)
       via  c89affb s3:passdb: do not use the in-memory idmap cache (it will be removed)
      from  3f00295 s3-dbwrap: dbwrap_watch_record_stored => NT_STATUS_NOT_FOUND is ok...

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit c0ba8295f24356abd08a601e105718e70fb4b4d8
Author: Michael Adam <obnox at samba.org>
Date:   Fri Apr 20 17:43:12 2012 +0200

    s3:smbcontrol: remove an unused variable
    
    Autobuild-User: Michael Adam <obnox at samba.org>
    Autobuild-Date: Sat Apr 21 00:55:13 CEST 2012 on sn-devel-104

commit 8e690ed3cf514ba34db4acc1d8b709aae052aedb
Author: Michael Adam <obnox at samba.org>
Date:   Fri Apr 20 10:56:58 2012 +0200

    s3:memcache: remove the idmap-part from memcache
    
    This was useful before the idmap cache was moved to gencache.
    Nowadays it is available to smbd through gencache, so we
    can remove the extra caching layer.

commit 499e7372bea051fa08c078d02175d6ea1e6ce8f9
Author: Michael Adam <obnox at samba.org>
Date:   Fri Apr 20 10:37:24 2012 +0200

    s3:id_cache: do not use the in-memory idmap cache (it is going to be removed)
    
    This also removes the ID_CACHE_FLUSH message.

commit c89affbd8da230cae6df25558fe621510690392c
Author: Michael Adam <obnox at samba.org>
Date:   Fri Apr 20 10:31:31 2012 +0200

    s3:passdb: do not use the in-memory idmap cache (it will be removed)

-----------------------------------------------------------------------

Summary of changes:
 source3/include/memcache.h       |    4 -
 source3/lib/id_cache.c           |   90 -----------------------
 source3/librpc/idl/messaging.idl |    2 +-
 source3/passdb/lookup_sid.c      |  145 --------------------------------------
 source3/passdb/lookup_sid.h      |    2 -
 source3/passdb/pdb_ldap.c        |    9 ---
 source3/smbd/server.c            |   13 ----
 source3/utils/smbcontrol.c       |   13 +---
 8 files changed, 4 insertions(+), 274 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/include/memcache.h b/source3/include/memcache.h
index 0a596b9..e0ac4af 100644
--- a/source3/include/memcache.h
+++ b/source3/include/memcache.h
@@ -35,10 +35,6 @@ struct memcache;
 
 enum memcache_number {
 	STAT_CACHE,
-	UID_SID_CACHE,
-	SID_UID_CACHE,
-	GID_SID_CACHE,
-	SID_GID_CACHE,
 	GETWD_CACHE,
 	GETPWNAM_CACHE,		/* talloc */
 	MANGLE_HASH2_CACHE,
diff --git a/source3/lib/id_cache.c b/source3/lib/id_cache.c
index 23dcce1..e6e3457 100644
--- a/source3/lib/id_cache.c
+++ b/source3/lib/id_cache.c
@@ -64,58 +64,6 @@ bool id_cache_ref_parse(const char* str, struct id_cache_ref* id)
 	return false;
 }
 
-static bool delete_uid_cache(uid_t puid)
-{
-	DATA_BLOB uid = data_blob_const(&puid, sizeof(puid));
-	DATA_BLOB sid;
-
-	if (!memcache_lookup(NULL, UID_SID_CACHE, uid, &sid)) {
-		DEBUG(3, ("UID %d is not memcached!\n", (int)puid));
-		return false;
-	}
-	DEBUG(3, ("Delete mapping UID %d <-> %s from memcache\n", (int)puid,
-		  sid_string_dbg((struct dom_sid*)sid.data)));
-	memcache_delete(NULL, SID_UID_CACHE, sid);
-	memcache_delete(NULL, UID_SID_CACHE, uid);
-	return true;
-}
-
-static bool delete_gid_cache(gid_t pgid)
-{
-	DATA_BLOB gid = data_blob_const(&pgid, sizeof(pgid));
-	DATA_BLOB sid;
-	if (!memcache_lookup(NULL, GID_SID_CACHE, gid, &sid)) {
-		DEBUG(3, ("GID %d is not memcached!\n", (int)pgid));
-		return false;
-	}
-	DEBUG(3, ("Delete mapping GID %d <-> %s from memcache\n", (int)pgid,
-		  sid_string_dbg((struct dom_sid*)sid.data)));
-	memcache_delete(NULL, SID_GID_CACHE, sid);
-	memcache_delete(NULL, GID_SID_CACHE, gid);
-	return true;
-}
-
-static bool delete_sid_cache(const struct dom_sid* psid)
-{
-	DATA_BLOB sid = data_blob_const(psid, ndr_size_dom_sid(psid, 0));
-	DATA_BLOB id;
-	if (memcache_lookup(NULL, SID_GID_CACHE, sid, &id)) {
-		DEBUG(3, ("Delete mapping %s <-> GID %d from memcache\n",
-			  sid_string_dbg(psid), *(int*)id.data));
-		memcache_delete(NULL, SID_GID_CACHE, sid);
-		memcache_delete(NULL, GID_SID_CACHE, id);
-	} else if (memcache_lookup(NULL, SID_UID_CACHE, sid, &id)) {
-		DEBUG(3, ("Delete mapping %s <-> UID %d from memcache\n",
-			  sid_string_dbg(psid), *(int*)id.data));
-		memcache_delete(NULL, SID_UID_CACHE, sid);
-		memcache_delete(NULL, UID_SID_CACHE, id);
-	} else {
-		DEBUG(3, ("SID %s is not memcached!\n", sid_string_dbg(psid)));
-		return false;
-	}
-	return true;
-}
-
 static bool delete_getpwnam_cache(const char *username)
 {
 	DATA_BLOB name = data_blob_string_const_null(username);
@@ -125,32 +73,16 @@ static bool delete_getpwnam_cache(const char *username)
 	return true;
 }
 
-static void flush_gid_cache(void)
-{
-	DEBUG(3, ("Flush GID <-> SID memcache\n"));
-	memcache_flush(NULL, SID_GID_CACHE);
-	memcache_flush(NULL, GID_SID_CACHE);
-}
-
-static void flush_uid_cache(void)
-{
-	DEBUG(3, ("Flush UID <-> SID memcache\n"));
-	memcache_flush(NULL, SID_UID_CACHE);
-	memcache_flush(NULL, UID_SID_CACHE);
-}
 void id_cache_delete_from_cache(const struct id_cache_ref* id)
 {
 	switch(id->type) {
 	case UID:
-		delete_uid_cache(id->id.uid);
 		idmap_cache_del_uid(id->id.uid);
 		break;
 	case GID:
-		delete_gid_cache(id->id.gid);
 		idmap_cache_del_gid(id->id.gid);
 		break;
 	case SID:
-		delete_sid_cache(&id->id.sid);
 		idmap_cache_del_sid(&id->id.sid);
 		break;
 	case USERNAME:
@@ -160,27 +92,6 @@ void id_cache_delete_from_cache(const struct id_cache_ref* id)
 	}
 }
 
-
-void id_cache_flush_message(struct messaging_context *msg_ctx,
-			    void* private_data,
-			    uint32_t msg_type,
-			    struct server_id server_id,
-			    DATA_BLOB* data)
-{
-	const char *msg = data ? (const char *)data->data : NULL;
-
-	if ((msg == NULL) || (msg[0] == '\0')) {
-		flush_gid_cache();
-		flush_uid_cache();
-	} else if (strncmp(msg, "GID", 3)) {
-		flush_gid_cache();
-	} else if (strncmp(msg, "UID", 3)) {
-		flush_uid_cache();
-	} else {
-		DEBUG(0, ("Invalid argument: %s\n", msg));
-	}
-}
-
 void id_cache_delete_message(struct messaging_context *msg_ctx,
 			     void *private_data,
 			     uint32_t msg_type,
@@ -200,6 +111,5 @@ void id_cache_delete_message(struct messaging_context *msg_ctx,
 
 void id_cache_register_msgs(struct messaging_context *ctx)
 {
-	messaging_register(ctx, NULL, ID_CACHE_FLUSH,  id_cache_flush_message);
 	messaging_register(ctx, NULL, ID_CACHE_DELETE, id_cache_delete_message);
 }
diff --git a/source3/librpc/idl/messaging.idl b/source3/librpc/idl/messaging.idl
index 24c280b..5493d75 100644
--- a/source3/librpc/idl/messaging.idl
+++ b/source3/librpc/idl/messaging.idl
@@ -35,7 +35,7 @@ interface messaging
 		MSG_REQ_DMALLOC_LOG_CHANGED	= 0x000C,
 		MSG_SHUTDOWN			= 0x000D,
 
-		ID_CACHE_FLUSH			= 0x000E,
+		/* ID_CACHE_FLUSH		= 0x000E, obsoleted */
 		ID_CACHE_DELETE			= 0x000F,
 		ID_CACHE_KILL			= 0x0010,
 
diff --git a/source3/passdb/lookup_sid.c b/source3/passdb/lookup_sid.c
index cfc78ad..f544a3f 100644
--- a/source3/passdb/lookup_sid.c
+++ b/source3/passdb/lookup_sid.c
@@ -1012,115 +1012,6 @@ bool lookup_sid(TALLOC_CTX *mem_ctx, const struct dom_sid *sid,
  modified to use linked lists by jra.
 *****************************************************************/  
 
-/*****************************************************************
-  Find a SID given a uid.
-*****************************************************************/
-
-static bool fetch_sid_from_uid_cache(struct dom_sid *psid, uid_t uid)
-{
-	DATA_BLOB cache_value;
-
-	if (!memcache_lookup(NULL, UID_SID_CACHE,
-			     data_blob_const(&uid, sizeof(uid)),
-			     &cache_value)) {
-		return false;
-	}
-
-	memcpy(psid, cache_value.data, MIN(sizeof(*psid), cache_value.length));
-	SMB_ASSERT(cache_value.length >= offsetof(struct dom_sid, id_auth));
-	SMB_ASSERT(cache_value.length == ndr_size_dom_sid(psid, 0));
-
-	return true;
-}
-
-/*****************************************************************
-  Find a uid given a SID.
-*****************************************************************/
-
-static bool fetch_uid_from_cache( uid_t *puid, const struct dom_sid *psid )
-{
-	DATA_BLOB cache_value;
-
-	if (!memcache_lookup(NULL, SID_UID_CACHE,
-			     data_blob_const(psid, ndr_size_dom_sid(psid, 0)),
-			     &cache_value)) {
-		return false;
-	}
-
-	SMB_ASSERT(cache_value.length == sizeof(*puid));
-	memcpy(puid, cache_value.data, sizeof(*puid));
-
-	return true;
-}
-
-/*****************************************************************
- Store uid to SID mapping in cache.
-*****************************************************************/
-
-void store_uid_sid_cache(const struct dom_sid *psid, uid_t uid)
-{
-	memcache_add(NULL, SID_UID_CACHE,
-		     data_blob_const(psid, ndr_size_dom_sid(psid, 0)),
-		     data_blob_const(&uid, sizeof(uid)));
-	memcache_add(NULL, UID_SID_CACHE,
-		     data_blob_const(&uid, sizeof(uid)),
-		     data_blob_const(psid, ndr_size_dom_sid(psid, 0)));
-}
-
-/*****************************************************************
-  Find a SID given a gid.
-*****************************************************************/
-
-static bool fetch_sid_from_gid_cache(struct dom_sid *psid, gid_t gid)
-{
-	DATA_BLOB cache_value;
-
-	if (!memcache_lookup(NULL, GID_SID_CACHE,
-			     data_blob_const(&gid, sizeof(gid)),
-			     &cache_value)) {
-		return false;
-	}
-
-	memcpy(psid, cache_value.data, MIN(sizeof(*psid), cache_value.length));
-	SMB_ASSERT(cache_value.length >= offsetof(struct dom_sid, id_auth));
-	SMB_ASSERT(cache_value.length == ndr_size_dom_sid(psid, 0));
-
-	return true;
-}
-
-/*****************************************************************
-  Find a gid given a SID.
-*****************************************************************/
-
-static bool fetch_gid_from_cache(gid_t *pgid, const struct dom_sid *psid)
-{
-	DATA_BLOB cache_value;
-
-	if (!memcache_lookup(NULL, SID_GID_CACHE,
-			     data_blob_const(psid, ndr_size_dom_sid(psid, 0)),
-			     &cache_value)) {
-		return false;
-	}
-
-	SMB_ASSERT(cache_value.length == sizeof(*pgid));
-	memcpy(pgid, cache_value.data, sizeof(*pgid));
-
-	return true;
-}
-
-/*****************************************************************
- Store gid to SID mapping in cache.
-*****************************************************************/
-
-void store_gid_sid_cache(const struct dom_sid *psid, gid_t gid)
-{
-	memcache_add(NULL, SID_GID_CACHE,
-		     data_blob_const(psid, ndr_size_dom_sid(psid, 0)),
-		     data_blob_const(&gid, sizeof(gid)));
-	memcache_add(NULL, GID_SID_CACHE,
-		     data_blob_const(&gid, sizeof(gid)),
-		     data_blob_const(psid, ndr_size_dom_sid(psid, 0)));
-}
 
 /*****************************************************************
  *THE LEGACY* convert uid_t to SID function.
@@ -1149,7 +1040,6 @@ static void legacy_uid_to_sid(struct dom_sid *psid, uid_t uid)
 	DEBUG(10,("LEGACY: uid %u -> sid %s\n", (unsigned int)uid,
 		  sid_string_dbg(psid)));
 
-	store_uid_sid_cache(psid, uid);
 	return;
 }
 
@@ -1180,7 +1070,6 @@ static void legacy_gid_to_sid(struct dom_sid *psid, gid_t gid)
 	DEBUG(10,("LEGACY: gid %u -> sid %s\n", (unsigned int)gid,
 		  sid_string_dbg(psid)));
 
-	store_gid_sid_cache(psid, gid);
 	return;
 }
 
@@ -1223,7 +1112,6 @@ done:
 	DEBUG(10,("LEGACY: sid %s -> uid %u\n", sid_string_dbg(psid),
 		  (unsigned int)*puid ));
 
-	store_uid_sid_cache(psid, *puid);
 	return true;
 }
 
@@ -1291,8 +1179,6 @@ static bool legacy_sid_to_gid(const struct dom_sid *psid, gid_t *pgid)
 	DEBUG(10,("LEGACY: sid %s -> gid %u\n", sid_string_dbg(psid),
 		  (unsigned int)*pgid ));
 
-	store_gid_sid_cache(psid, *pgid);
-
 	TALLOC_FREE(map);
 	return true;
 }
@@ -1307,9 +1193,6 @@ void uid_to_sid(struct dom_sid *psid, uid_t uid)
 	bool ret;
 	ZERO_STRUCTP(psid);
 
-	if (fetch_sid_from_uid_cache(psid, uid))
-		return;
-
 	/* Check the winbindd cache directly. */
 	ret = idmap_cache_find_uid2sid(uid, psid, &expired);
 
@@ -1346,7 +1229,6 @@ void uid_to_sid(struct dom_sid *psid, uid_t uid)
 	DEBUG(10,("uid %u -> sid %s\n", (unsigned int)uid,
 		  sid_string_dbg(psid)));
 
-	store_uid_sid_cache(psid, uid);
 	return;
 }
 
@@ -1360,9 +1242,6 @@ void gid_to_sid(struct dom_sid *psid, gid_t gid)
 	bool ret;
 	ZERO_STRUCTP(psid);
 
-	if (fetch_sid_from_gid_cache(psid, gid))
-		return;
-
 	/* Check the winbindd cache directly. */
 	ret = idmap_cache_find_gid2sid(gid, psid, &expired);
 
@@ -1399,7 +1278,6 @@ void gid_to_sid(struct dom_sid *psid, gid_t gid)
 	DEBUG(10,("gid %u -> sid %s\n", (unsigned int)gid,
 		  sid_string_dbg(psid)));
 
-	store_gid_sid_cache(psid, gid);
 	return;
 }
 
@@ -1423,14 +1301,6 @@ bool sids_to_unix_ids(const struct dom_sid *sids, uint32_t num_sids,
 		bool expired;
 		uint32_t rid;
 
-		if (fetch_uid_from_cache(&ids[i].id.uid, &sids[i])) {
-			ids[i].type = WBC_ID_TYPE_UID;
-			continue;
-		}
-		if (fetch_gid_from_cache(&ids[i].id.gid, &sids[i])) {
-			ids[i].type = WBC_ID_TYPE_GID;
-			continue;
-		}
 		if (sid_peek_check_rid(&global_sid_Unix_Users,
 				       &sids[i], &rid)) {
 			ids[i].type = WBC_ID_TYPE_UID;
@@ -1517,13 +1387,6 @@ bool sid_to_uid(const struct dom_sid *psid, uid_t *puid)
 	uint32 rid;
 	gid_t gid;
 
-	if (fetch_uid_from_cache(puid, psid))
-		return true;
-
-	if (fetch_gid_from_cache(&gid, psid)) {
-		return false;
-	}
-
 	/* Optimize for the Unix Users Domain
 	 * as the conversion is straightforward */
 	if (sid_peek_check_rid(&global_sid_Unix_Users, psid, &rid)) {
@@ -1563,7 +1426,6 @@ bool sid_to_uid(const struct dom_sid *psid, uid_t *puid)
 	DEBUG(10,("sid %s -> uid %u\n", sid_string_dbg(psid),
 		(unsigned int)*puid ));
 
-	store_uid_sid_cache(psid, *puid);
 	return true;
 }
 
@@ -1579,12 +1441,6 @@ bool sid_to_gid(const struct dom_sid *psid, gid_t *pgid)
 	uint32 rid;
 	uid_t uid;
 
-	if (fetch_gid_from_cache(pgid, psid))
-		return true;
-
-	if (fetch_uid_from_cache(&uid, psid))
-		return false;
-
 	/* Optimize for the Unix Groups Domain
 	 * as the conversion is straightforward */
 	if (sid_peek_check_rid(&global_sid_Unix_Groups, psid, &rid)) {
@@ -1625,7 +1481,6 @@ bool sid_to_gid(const struct dom_sid *psid, gid_t *pgid)
 	DEBUG(10,("sid %s -> gid %u\n", sid_string_dbg(psid),
 		  (unsigned int)*pgid ));
 
-	store_gid_sid_cache(psid, *pgid);
 	return true;
 }
 
diff --git a/source3/passdb/lookup_sid.h b/source3/passdb/lookup_sid.h
index c9f8ddd..693e001 100644
--- a/source3/passdb/lookup_sid.h
+++ b/source3/passdb/lookup_sid.h
@@ -80,8 +80,6 @@ NTSTATUS lookup_sids(TALLOC_CTX *mem_ctx, int num_sids,
 bool lookup_sid(TALLOC_CTX *mem_ctx, const struct dom_sid *sid,
 		const char **ret_domain, const char **ret_name,
 		enum lsa_SidType *ret_type);
-void store_uid_sid_cache(const struct dom_sid *psid, uid_t uid);
-void store_gid_sid_cache(const struct dom_sid *psid, gid_t gid);
 void uid_to_sid(struct dom_sid *psid, uid_t uid);
 void gid_to_sid(struct dom_sid *psid, gid_t gid);
 bool sid_to_uid(const struct dom_sid *psid, uid_t *puid);
diff --git a/source3/passdb/pdb_ldap.c b/source3/passdb/pdb_ldap.c
index 49f48bd..d9e272e 100644
--- a/source3/passdb/pdb_ldap.c
+++ b/source3/passdb/pdb_ldap.c
@@ -1070,16 +1070,12 @@ static bool init_sam_from_ldap(struct ldapsam_privates *ldap_state,
 			goto fn_exit;
 		}
 
-		store_uid_sid_cache(pdb_get_user_sid(sampass),
-				    sampass->unix_pw->pw_uid);
 		idmap_cache_set_sid2uid(pdb_get_user_sid(sampass),
 					sampass->unix_pw->pw_uid);
 
 		gid_to_sid(&mapped_gsid, sampass->unix_pw->pw_gid);
 		primary_gsid = pdb_get_group_sid(sampass);
 		if (primary_gsid && dom_sid_equal(primary_gsid, &mapped_gsid)) {
-			store_gid_sid_cache(primary_gsid,
-					    sampass->unix_pw->pw_gid);
 			idmap_cache_set_sid2gid(primary_gsid,
 						sampass->unix_pw->pw_gid);
 		}
@@ -2479,7 +2475,6 @@ for gidNumber(%lu)\n",(unsigned long)map->gid));
 	}
 
 	if (lp_parm_bool(-1, "ldapsam", "trusted", false)) {
-		store_gid_sid_cache(&map->sid, map->gid);
 		idmap_cache_set_sid2gid(&map->sid, map->gid);
 	}
 
@@ -5040,7 +5035,6 @@ static bool ldapsam_sid_to_id(struct pdb_methods *methods,
 
 		*gid = strtoul(gid_str, NULL, 10);
 		*type = (enum lsa_SidType)strtoul(value, NULL, 10);
-		store_gid_sid_cache(sid, *gid);
 		idmap_cache_set_sid2gid(sid, *gid);
 		ret = True;
 		goto done;
@@ -5058,7 +5052,6 @@ static bool ldapsam_sid_to_id(struct pdb_methods *methods,
 
 	*uid = strtoul(value, NULL, 10);
 	*type = SID_NAME_USER;
-	store_uid_sid_cache(sid, *uid);
 	idmap_cache_set_sid2uid(sid, *uid);
 
 	ret = True;
@@ -5129,7 +5122,6 @@ static bool ldapsam_uid_to_sid(struct pdb_methods *methods, uid_t uid,
 
 	sid_copy(sid, &user_sid);
 
-	store_uid_sid_cache(sid, uid);
 	idmap_cache_set_sid2uid(sid, uid);
 
 	ret = true;
@@ -5199,7 +5191,6 @@ static bool ldapsam_gid_to_sid(struct pdb_methods *methods, gid_t gid,
 
 	sid_copy(sid, &group_sid);
 
-	store_gid_sid_cache(sid, gid);
 	idmap_cache_set_sid2gid(sid, gid);
 
 	ret = true;
diff --git a/source3/smbd/server.c b/source3/smbd/server.c
index 912d7a1..363203e 100644
--- a/source3/smbd/server.c
+++ b/source3/smbd/server.c
@@ -248,17 +248,6 @@ static void smbd_parent_id_cache_kill(struct messaging_context *msg_ctx,
 	messaging_send_to_children(msg_ctx, msg_type, data);
 }
 
-static void smbd_parent_id_cache_flush(struct messaging_context *ctx,
-				       void* data,
-				       uint32_t msg_type,
-				       struct server_id srv_id,
-				       DATA_BLOB* msg_data)
-{
-	id_cache_flush_message(ctx, data, msg_type, srv_id, msg_data);
-
-	messaging_send_to_children(ctx, msg_type, msg_data);
-}
-
 static void smbd_parent_id_cache_delete(struct messaging_context *ctx,


-- 
Samba Shared Repository


More information about the samba-cvs mailing list