[PATCH] Small cleanups

Volker Lendecke Volker.Lendecke at SerNet.DE
Mon Sep 25 13:23:11 UTC 2017


Hi!

Review appreciated!

Thanks, Volker

-- 
SerNet GmbH, Bahnhofsallee 1b, 37081 Göttingen
phone: +49-551-370000-0, fax: +49-551-370000-9
AG Göttingen, HRB 2816, GF: Dr. Johannes Loxen
http://www.sernet.de, mailto:kontakt at sernet.de
-------------- next part --------------
commit 4fbe0969626f39741ed9db19f7ef9b8446be14f8
Author: Volker Lendecke <vl at samba.org>
Date:   Sun Aug 6 15:49:01 2017 +0200

    winbind: Remove the use of "talloc_dict"
    
    As members we only collect names, indexed by sids. This is served
    well by just a simple dbwrap_rbt.
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
---
 source3/winbindd/wb_getgrsid.c       | 13 +++-----
 source3/winbindd/wb_group_members.c  | 60 ++++++++++++------------------------
 source3/winbindd/wb_next_grent.c     |  4 +--
 source3/winbindd/winbindd.h          |  2 --
 source3/winbindd/winbindd_getgrent.c |  4 +--
 source3/winbindd/winbindd_getgrgid.c |  2 +-
 source3/winbindd/winbindd_getgrnam.c |  2 +-
 source3/winbindd/winbindd_group.c    | 48 ++++++++++++++++-------------
 source3/winbindd/winbindd_proto.h    | 17 +++++-----
 9 files changed, 65 insertions(+), 87 deletions(-)

diff --git a/source3/winbindd/wb_getgrsid.c b/source3/winbindd/wb_getgrsid.c
index acfedf62c9d..b8b28ed2da8 100644
--- a/source3/winbindd/wb_getgrsid.c
+++ b/source3/winbindd/wb_getgrsid.c
@@ -21,6 +21,7 @@
 #include "winbindd.h"
 #include "librpc/gen_ndr/ndr_winbind_c.h"
 #include "../libcli/security/security.h"
+#include "lib/dbwrap/dbwrap_rbt.h"
 
 struct wb_getgrsid_state {
 	struct tevent_context *ev;
@@ -30,7 +31,7 @@ struct wb_getgrsid_state {
 	const char *name;
 	enum lsa_SidType type;
 	gid_t gid;
-	struct talloc_dict *members;
+	struct db_context *members;
 };
 
 static void wb_getgrsid_lookupsid_done(struct tevent_req *subreq);
@@ -150,7 +151,7 @@ static void wb_getgrsid_sid2gid_done(struct tevent_req *subreq)
 			return;
 		}
 
-		state->members = talloc_dict_init(state);
+		state->members = db_open_rbt(state);
 		if (tevent_req_nomem(state->members, req)) {
 			return;
 		}
@@ -163,11 +164,7 @@ static void wb_getgrsid_sid2gid_done(struct tevent_req *subreq)
 			return;
 		}
 
-		status = add_wbint_Principal_to_dict(talloc_tos(),
-						     &state->sid,
-						     &name,
-						     state->type,
-						     state->members);
+		status = add_member_to_db(state->members, &state->sid, name);
 		if (!NT_STATUS_IS_OK(status)) {
 			tevent_req_nterror(req, status);
 			return;
@@ -207,7 +204,7 @@ static void wb_getgrsid_got_members(struct tevent_req *subreq)
 
 NTSTATUS wb_getgrsid_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
 			  const char **domname, const char **name, gid_t *gid,
-			  struct talloc_dict **members)
+			  struct db_context **members)
 {
 	struct wb_getgrsid_state *state = tevent_req_data(
 		req, struct wb_getgrsid_state);
diff --git a/source3/winbindd/wb_group_members.c b/source3/winbindd/wb_group_members.c
index 5a20d87514c..7978b188143 100644
--- a/source3/winbindd/wb_group_members.c
+++ b/source3/winbindd/wb_group_members.c
@@ -22,6 +22,9 @@
 #include "librpc/gen_ndr/ndr_winbind_c.h"
 #include "../librpc/gen_ndr/ndr_security.h"
 #include "../libcli/security/security.h"
+#include "lib/util/util_tdb.h"
+#include "lib/dbwrap/dbwrap.h"
+#include "lib/dbwrap/dbwrap_rbt.h"
 
 /*
  * We have 3 sets of routines here:
@@ -268,14 +271,14 @@ static NTSTATUS wb_groups_members_recv(struct tevent_req *req,
 
 /*
  * This is the routine expanding a list of groups up to a certain level. We
- * collect the users in a talloc_dict: We have to add them without duplicates,
- * and talloc_dict is an indexed (here indexed by SID) data structure.
+ * collect the users in a rbt database: We have to add them without duplicates,
+ * and the db is indexed by SID.
  */
 
 struct wb_group_members_state {
 	struct tevent_context *ev;
 	int depth;
-	struct talloc_dict *users;
+	struct db_context *users;
 	struct wbint_Principal *groups;
 };
 
@@ -301,7 +304,7 @@ struct tevent_req *wb_group_members_send(TALLOC_CTX *mem_ctx,
 	}
 	state->ev = ev;
 	state->depth = max_depth;
-	state->users = talloc_dict_init(state);
+	state->users = db_open_rbt(state);
 	if (tevent_req_nomem(state->users, req)) {
 		return tevent_req_post(req, ev);
 	}
@@ -349,40 +352,18 @@ static NTSTATUS wb_group_members_next_subreq(
 	return NT_STATUS_OK;
 }
 
-
-/**
- * compose a wbint_Principal and add it to  talloc_dict
- *
- * NOTE: this has a side effect: *name needs to be talloc'd
- * and it is talloc_move'd to mem_ctx.
- */
-NTSTATUS add_wbint_Principal_to_dict(TALLOC_CTX *mem_ctx,
-				     struct dom_sid *sid,
-				     const char **name,
-				     enum lsa_SidType type,
-				     struct talloc_dict *dict)
+NTSTATUS add_member_to_db(struct db_context *db, struct dom_sid *sid,
+			  const char *name)
 {
-	struct wbint_Principal *m;
-	DATA_BLOB key;
-	bool ok;
-
-	m = talloc(mem_ctx, struct wbint_Principal);
-	if (m == NULL) {
-		return NT_STATUS_NO_MEMORY;
-	}
-
-	sid_copy(&m->sid, sid);
-	m->name = talloc_move(m, name);
-	m->type = type;
-
-	key = data_blob_const(&m->sid, sizeof(m->sid));
+	size_t len = ndr_size_dom_sid(sid, 0);
+	uint8_t sidbuf[len];
+	TDB_DATA key = { .dptr = sidbuf, .dsize = sizeof(sidbuf) };
+	NTSTATUS status;
 
-	ok = talloc_dict_set(dict, key, &m);
-	if (!ok) {
-		return NT_STATUS_NO_MEMORY;
-	}
+	sid_linearize(sidbuf, sizeof(sidbuf), sid);
 
-	return NT_STATUS_OK;
+	status = dbwrap_store(db, key, string_term_tdb_data(name), 0);
+	return status;
 }
 
 static void wb_group_members_done(struct tevent_req *subreq)
@@ -433,11 +414,8 @@ static void wb_group_members_done(struct tevent_req *subreq)
 			/*
 			 * Add a copy of members[i] to state->users
 			 */
-			status = add_wbint_Principal_to_dict(talloc_tos(),
-							     &members[i].sid,
-							     &members[i].name,
-							     members[i].type,
-							     state->users);
+			status = add_member_to_db(state->users, &members[i].sid,
+						  members[i].name);
 			if (tevent_req_nterror(req, status)) {
 				return;
 			}
@@ -476,7 +454,7 @@ static void wb_group_members_done(struct tevent_req *subreq)
 }
 
 NTSTATUS wb_group_members_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
-			       struct talloc_dict **members)
+			       struct db_context **members)
 {
 	struct wb_group_members_state *state = tevent_req_data(
 		req, struct wb_group_members_state);
diff --git a/source3/winbindd/wb_next_grent.c b/source3/winbindd/wb_next_grent.c
index fd925b609e5..d249287cc40 100644
--- a/source3/winbindd/wb_next_grent.c
+++ b/source3/winbindd/wb_next_grent.c
@@ -27,7 +27,7 @@ struct wb_next_grent_state {
 	int max_nesting;
 	struct getgrent_state *gstate;
 	struct winbindd_gr *gr;
-	struct talloc_dict *members;
+	struct db_context *members;
 };
 
 static void wb_next_grent_fetch_done(struct tevent_req *subreq);
@@ -150,7 +150,7 @@ static void wb_next_grent_getgrsid_done(struct tevent_req *subreq)
 }
 
 NTSTATUS wb_next_grent_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
-			    struct talloc_dict **members)
+			    struct db_context **members)
 {
 	struct wb_next_grent_state *state = tevent_req_data(
 		req, struct wb_next_grent_state);
diff --git a/source3/winbindd/winbindd.h b/source3/winbindd/winbindd.h
index 6951112629d..396f7f7946e 100644
--- a/source3/winbindd/winbindd.h
+++ b/source3/winbindd/winbindd.h
@@ -28,8 +28,6 @@
 #include "librpc/gen_ndr/dcerpc.h"
 #include "librpc/gen_ndr/winbind.h"
 
-#include "talloc_dict.h"
-
 #include "../lib/util/tevent_ntstatus.h"
 
 #ifdef HAVE_LIBNSCD
diff --git a/source3/winbindd/winbindd_getgrent.c b/source3/winbindd/winbindd_getgrent.c
index 21da75b4c52..2c8cbac083a 100644
--- a/source3/winbindd/winbindd_getgrent.c
+++ b/source3/winbindd/winbindd_getgrent.c
@@ -26,7 +26,7 @@ struct winbindd_getgrent_state {
 	int max_groups;
 	int num_groups;
 	struct winbindd_gr *groups;
-	struct talloc_dict **members;
+	struct db_context **members;
 };
 
 static void winbindd_getgrent_done(struct tevent_req *subreq);
@@ -72,7 +72,7 @@ struct tevent_req *winbindd_getgrent_send(TALLOC_CTX *mem_ctx,
 		return tevent_req_post(req, ev);
 	}
 
-	state->members = talloc_array(state, struct talloc_dict *,
+	state->members = talloc_array(state, struct db_context *,
 				      state->max_groups);
 	if (tevent_req_nomem(state->members, req)) {
 		TALLOC_FREE(state->groups);
diff --git a/source3/winbindd/winbindd_getgrgid.c b/source3/winbindd/winbindd_getgrgid.c
index 8e8bdeea86a..640ebfa4969 100644
--- a/source3/winbindd/winbindd_getgrgid.c
+++ b/source3/winbindd/winbindd_getgrgid.c
@@ -28,7 +28,7 @@ struct winbindd_getgrgid_state {
 	const char *domname;
 	const char *name;
 	gid_t gid;
-	struct talloc_dict *members;
+	struct db_context *members;
 };
 
 static void winbindd_getgrgid_gid2sid_done(struct tevent_req *subreq);
diff --git a/source3/winbindd/winbindd_getgrnam.c b/source3/winbindd/winbindd_getgrnam.c
index 12b16513caa..02d9abc28a2 100644
--- a/source3/winbindd/winbindd_getgrnam.c
+++ b/source3/winbindd/winbindd_getgrnam.c
@@ -27,7 +27,7 @@ struct winbindd_getgrnam_state {
 	const char *domname;
 	const char *name;
 	gid_t gid;
-	struct talloc_dict *members;
+	struct db_context *members;
 };
 
 static void winbindd_getgrnam_lookupname_done(struct tevent_req *subreq);
diff --git a/source3/winbindd/winbindd_group.c b/source3/winbindd/winbindd_group.c
index ae461bf3748..b5c9d3cf94e 100644
--- a/source3/winbindd/winbindd_group.c
+++ b/source3/winbindd/winbindd_group.c
@@ -24,6 +24,7 @@
 
 #include "includes.h"
 #include "winbindd.h"
+#include "lib/dbwrap/dbwrap.h"
 
 #undef DBGC_CLASS
 #define DBGC_CLASS DBGC_WINBIND
@@ -79,14 +80,19 @@ struct getgr_countmem {
 	size_t len;
 };
 
-static int getgr_calc_memberlen(DATA_BLOB key, void *data, void *priv)
+static int getgr_calc_memberlen(struct db_record *rec, void *private_data)
 {
-	struct wbint_Principal *m = talloc_get_type_abort(
-		data, struct wbint_Principal);
-	struct getgr_countmem *buf = (struct getgr_countmem *)priv;
+	struct getgr_countmem *buf = private_data;
+	TDB_DATA data = dbwrap_record_get_value(rec);
+	size_t len;
 
 	buf->num += 1;
-	buf->len += strlen(m->name) + 1;
+
+	len = buf->len + data.dsize;
+	if (len < buf->len) {
+		return 0;
+	}
+	buf->len = len;
 	return 0;
 }
 
@@ -95,37 +101,37 @@ struct getgr_stringmem {
 	char *buf;
 };
 
-static int getgr_unparse_members(DATA_BLOB key, void *data, void *priv)
+static int getgr_unparse_members(struct db_record *rec, void *private_data)
 {
-	struct wbint_Principal *m = talloc_get_type_abort(
-		data, struct wbint_Principal);
-	struct getgr_stringmem *buf = (struct getgr_stringmem *)priv;
+	struct getgr_stringmem *buf = private_data;
+	TDB_DATA data = dbwrap_record_get_value(rec);
 	int len;
 
-	len = strlen(m->name);
+	len = data.dsize-1;
 
-	memcpy(buf->buf + buf->ofs, m->name, len);
+	memcpy(buf->buf + buf->ofs, data.dptr, len);
 	buf->ofs += len;
 	buf->buf[buf->ofs] = ',';
 	buf->ofs += 1;
 	return 0;
 }
 
-NTSTATUS winbindd_print_groupmembers(struct talloc_dict *members,
+NTSTATUS winbindd_print_groupmembers(struct db_context *members,
 				     TALLOC_CTX *mem_ctx,
 				     int *num_members, char **result)
 {
 	struct getgr_countmem c;
 	struct getgr_stringmem m;
-	int res;
+	int count;
+	NTSTATUS status;
 
 	c.num = 0;
 	c.len = 0;
 
-	res = talloc_dict_traverse(members, getgr_calc_memberlen, &c);
-	if (res == -1) {
-		DEBUG(5, ("talloc_dict_traverse failed\n"));
-		return NT_STATUS_INTERNAL_ERROR;
+	status = dbwrap_traverse(members, getgr_calc_memberlen, &c, &count);
+	if (!NT_STATUS_IS_OK(status)) {
+		DBG_NOTICE("dbwrap_traverse failed: %s\n", nt_errstr(status));
+		return status;
 	}
 
 	m.ofs = 0;
@@ -135,11 +141,11 @@ NTSTATUS winbindd_print_groupmembers(struct talloc_dict *members,
 		return NT_STATUS_NO_MEMORY;
 	}
 
-	res = talloc_dict_traverse(members, getgr_unparse_members, &m);
-	if (res == -1) {
-		DEBUG(5, ("talloc_dict_traverse failed\n"));
+	status = dbwrap_traverse(members, getgr_unparse_members, &m, &count);
+	if (!NT_STATUS_IS_OK(status)) {
 		TALLOC_FREE(m.buf);
-		return NT_STATUS_INTERNAL_ERROR;
+		DBG_NOTICE("dbwrap_traverse failed: %s\n", nt_errstr(status));
+		return status;
 	}
 	m.buf[c.len-1] = '\0';
 
diff --git a/source3/winbindd/winbindd_proto.h b/source3/winbindd/winbindd_proto.h
index 7560fc53bae..46e6530105a 100644
--- a/source3/winbindd/winbindd_proto.h
+++ b/source3/winbindd/winbindd_proto.h
@@ -339,7 +339,9 @@ struct winbindd_domain *wb_child_domain(void);
 /* The following definitions come from winbindd/winbindd_group.c  */
 bool fill_grent(TALLOC_CTX *mem_ctx, struct winbindd_gr *gr,
 		const char *dom_name, const char *gr_name, gid_t unix_gid);
-NTSTATUS winbindd_print_groupmembers(struct talloc_dict *members,
+
+struct db_context;
+NTSTATUS winbindd_print_groupmembers(struct db_context *members,
 				     TALLOC_CTX *mem_ctx,
 				     int *num_members, char **result);
 
@@ -661,12 +663,9 @@ struct tevent_req *wb_group_members_send(TALLOC_CTX *mem_ctx,
 					 enum lsa_SidType type,
 					 int max_depth);
 NTSTATUS wb_group_members_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
-			       struct talloc_dict **members);
-NTSTATUS add_wbint_Principal_to_dict(TALLOC_CTX *mem_ctx,
-				     struct dom_sid *sid,
-				     const char **name,
-				     enum lsa_SidType type,
-				     struct talloc_dict *dict);
+			       struct db_context **members);
+NTSTATUS add_member_to_db(struct db_context *db, struct dom_sid *sid,
+			  const char *name);
 
 struct tevent_req *wb_getgrsid_send(TALLOC_CTX *mem_ctx,
 				    struct tevent_context *ev,
@@ -674,7 +673,7 @@ struct tevent_req *wb_getgrsid_send(TALLOC_CTX *mem_ctx,
 				    int max_nesting);
 NTSTATUS wb_getgrsid_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
 			  const char **domname, const char **name, gid_t *gid,
-			  struct talloc_dict **members);
+			  struct db_context **members);
 
 struct tevent_req *winbindd_getgrgid_send(TALLOC_CTX *mem_ctx,
 					  struct tevent_context *ev,
@@ -778,7 +777,7 @@ struct tevent_req *wb_next_grent_send(TALLOC_CTX *mem_ctx,
 				      struct getgrent_state *gstate,
 				      struct winbindd_gr *gr);
 NTSTATUS wb_next_grent_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
-			    struct talloc_dict **members);
+			    struct db_context **members);
 
 struct tevent_req *winbindd_setgrent_send(TALLOC_CTX *mem_ctx,
 					  struct tevent_context *ev,

commit d570636e253d39837ac7e60e2f49c1fe087a35ba
Author: Volker Lendecke <vl at samba.org>
Date:   Sun Aug 6 15:51:49 2017 +0200

    lib: Remove talloc_dict
    
    Looked like a good idea at its time, but its only user did not need
    it anyway
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
---
 source3/include/talloc_dict.h |  60 --------------
 source3/lib/talloc_dict.c     | 177 ------------------------------------------
 source3/selftest/tests.py     |   1 -
 source3/torture/torture.c     |  57 --------------
 source3/wscript_build         |   1 -
 5 files changed, 296 deletions(-)

diff --git a/source3/include/talloc_dict.h b/source3/include/talloc_dict.h
deleted file mode 100644
index 8305f8d15e2..00000000000
--- a/source3/include/talloc_dict.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
-   Unix SMB/CIFS implementation.
-   Little dictionary style data structure based on dbwrap_rbt
-   Copyright (C) Volker Lendecke 2009
-
-   This program is free software; you can redistribute it and/or modify
-   it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 3 of the License, or
-   (at your option) any later version.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program.  If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef __TALLOC_DICT_H__
-#define __TALLOC_DICT_H__
-
-#include "includes.h"
-
-struct talloc_dict;
-
-/*
- * Create a talloc_dict structure.
- */
-
-struct talloc_dict *talloc_dict_init(TALLOC_CTX *mem_ctx);
-
-/*
- * Add a talloced object to the dict. Nulls out the pointer to indicate that
- * the talloc ownership has been taken. If an object for "key" already exists,
- * the existing object is talloc_free()ed and overwritten by the new
- * object. If "data" is NULL, object for key "key" is deleted. Return false
- * for "no memory".
- */
-
-bool talloc_dict_set(struct talloc_dict *dict, DATA_BLOB key, void *data);
-
-/*
- * Fetch a talloced object. If "mem_ctx!=NULL", talloc_move the object there
- * and delete it from the dict.
- */
-
-void *talloc_dict_fetch(struct talloc_dict *dict, DATA_BLOB key,
-			TALLOC_CTX *mem_ctx);
-
-/*
- * Traverse a talloc_dict. If "fn" returns non-null, quit the traverse
- */
-
-int talloc_dict_traverse(struct talloc_dict *dict,
-			 int (*fn)(DATA_BLOB key, void *data,
-				   void *private_data),
-			 void *private_data);
-
-#endif
diff --git a/source3/lib/talloc_dict.c b/source3/lib/talloc_dict.c
deleted file mode 100644
index 75946790147..00000000000
--- a/source3/lib/talloc_dict.c
+++ /dev/null
@@ -1,177 +0,0 @@
-/*
-   Unix SMB/CIFS implementation.
-   Little dictionary style data structure based on dbwrap_rbt
-   Copyright (C) Volker Lendecke 2009
-
-   This program is free software; you can redistribute it and/or modify
-   it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 3 of the License, or
-   (at your option) any later version.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program.  If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "includes.h"
-#include "dbwrap/dbwrap.h"
-#include "dbwrap/dbwrap_rbt.h"
-#include "talloc_dict.h"
-#include "util_tdb.h"
-
-struct talloc_dict {
-	struct db_context *db;
-};
-
-struct talloc_dict *talloc_dict_init(TALLOC_CTX *mem_ctx)
-{
-	struct talloc_dict *result;
-
-	result = talloc(mem_ctx, struct talloc_dict);
-	if (result == NULL) {
-		return NULL;
-	}
-	result->db = db_open_rbt(result);
-	if (result->db == NULL) {
-		TALLOC_FREE(result);
-		return NULL;
-	}
-	return result;
-}
-
-/*
- * Add a talloced object to the dict. Nulls out the pointer to indicate that
- * the talloc ownership has been taken. If an object for "key" already exists,
- * the existing object is talloc_free()ed and overwritten by the new
- * object. If "data" is NULL, object for key "key" is deleted. Return false
- * for "no memory".
- */
-
-bool talloc_dict_set(struct talloc_dict *dict, DATA_BLOB key, void *pdata)
-{
-	struct db_record *rec;
-	NTSTATUS status = NT_STATUS_OK;
-	void *data = *(void **)pdata;
-	TDB_DATA value;
-
-	rec = dbwrap_fetch_locked(dict->db, talloc_tos(),
-				  make_tdb_data(key.data, key.length));
-	if (rec == NULL) {
-		return false;
-	}
-
-	value = dbwrap_record_get_value(rec);
-
-	if (value.dsize != 0) {
-		void *old_data;
-		if (value.dsize != sizeof(void *)) {
-			TALLOC_FREE(rec);
-			return false;
-		}
-		memcpy(&old_data, value.dptr, sizeof(old_data));
-		TALLOC_FREE(old_data);
-		if (data == NULL) {
-			status = dbwrap_record_delete(rec);
-		}
-	}
-	if (data != NULL) {
-		void *mydata = talloc_move(dict->db, &data);
-		*(void **)pdata = NULL;
-		status = dbwrap_record_store(rec,
-					     make_tdb_data((uint8_t *)&mydata,
-					     sizeof(mydata)), 0);
-	}
-	TALLOC_FREE(rec);
-	return NT_STATUS_IS_OK(status);
-}
-
-/*
- * Fetch a talloced object. If "mem_ctx!=NULL", talloc_move the object there
- * and delete it from the dict.
- */
-
-void *talloc_dict_fetch(struct talloc_dict *dict, DATA_BLOB key,
-			TALLOC_CTX *mem_ctx)
-{
-	struct db_record *rec;
-	void *result;
-	TDB_DATA value;
-
-	rec = dbwrap_fetch_locked(dict->db, talloc_tos(),
-				  make_tdb_data(key.data, key.length));
-	if (rec == NULL) {
-		return NULL;
-	}
-
-	value = dbwrap_record_get_value(rec);
-	if (value.dsize != sizeof(void *)) {
-		TALLOC_FREE(rec);
-		return NULL;
-	}
-	result = *(void **)value.dptr;
-
-	if (mem_ctx != NULL) {
-		NTSTATUS status;
-		status = dbwrap_record_delete(rec);
-		if (!NT_STATUS_IS_OK(status)) {
-			TALLOC_FREE(rec);
-			return NULL;
-		}
-		result = talloc_move(mem_ctx, &result);
-	}
-
-	return result;
-}
-
-struct talloc_dict_traverse_state {
-	int (*fn)(DATA_BLOB key, void *data, void *private_data);
-	void *private_data;
-};
-
-static int talloc_dict_traverse_fn(struct db_record *rec, void *private_data)
-{
-	TDB_DATA key;
-	TDB_DATA value;
-	struct talloc_dict_traverse_state *state =
-		(struct talloc_dict_traverse_state *)private_data;
-	void *p;
-
-	key = dbwrap_record_get_key(rec);
-	value = dbwrap_record_get_value(rec);
-
-	if (value.dsize != sizeof(void *)) {
-		return -1;
-	}
-
-	memcpy(&p, value.dptr, sizeof(p));
-	return state->fn(data_blob_const(key.dptr, key.dsize),
-			 p, state->private_data);
-}
-
-/*
- * Traverse a talloc_dict. If "fn" returns non-null, quit the traverse
- */
-
-int talloc_dict_traverse(struct talloc_dict *dict,
-			 int (*fn)(DATA_BLOB key, void *data,
-				   void *private_data),
-			 void *private_data)
-{
-	struct talloc_dict_traverse_state state;
-	NTSTATUS status;
-	int count = 0;
-
-	state.fn = fn;
-	state.private_data = private_data;
-	status = dbwrap_traverse(dict->db, talloc_dict_traverse_fn, &state,
-				 &count);
-	if (!NT_STATUS_IS_OK(status)) {
-		return -1;
-	} else {
-		return count;
-	}
-}
diff --git a/source3/selftest/tests.py b/source3/selftest/tests.py
index 73479fc5fcd..1c40e7e049b 100755
--- a/source3/selftest/tests.py
+++ b/source3/selftest/tests.py
@@ -124,7 +124,6 @@ plantestsuite("samba3.smbtorture_s3.plain(%s).%s" % (env, t), env, [os.path.join
 local_tests = [
     "LOCAL-SUBSTITUTE",
     "LOCAL-GENCACHE",
-    "LOCAL-TALLOC-DICT",
     "LOCAL-BASE64",
     "LOCAL-RBTREE",
     "LOCAL-MEMCACHE",
diff --git a/source3/torture/torture.c b/source3/torture/torture.c
index 4667517e008..bb4908fd127 100644
--- a/source3/torture/torture.c
+++ b/source3/torture/torture.c
@@ -31,7 +31,6 @@
 #include "dbwrap/dbwrap.h"
 #include "dbwrap/dbwrap_open.h"
 #include "dbwrap/dbwrap_rbt.h"
-#include "talloc_dict.h"
 #include "async_smb.h"
 #include "libsmb/libsmb.h"
 #include "libsmb/clirap.h"
@@ -10314,61 +10313,6 @@ failed:
 	return false;
 }
 
-
-struct talloc_dict_test {
-	int content;
-};
-
-static int talloc_dict_traverse_fn(DATA_BLOB key, void *data, void *priv)
-{
-	int *count = (int *)priv;
-	*count += 1;
-	return 0;
-}
-
-static bool run_local_talloc_dict(int dummy)
-{
-	struct talloc_dict *dict;
-	struct talloc_dict_test *t;
-	int key, count, res;
-	bool ok;
-
-	dict = talloc_dict_init(talloc_tos());
-	if (dict == NULL) {
-		return false;
-	}
-
-	t = talloc(talloc_tos(), struct talloc_dict_test);
-	if (t == NULL) {
-		return false;
-	}
-
-	key = 1;
-	t->content = 1;
-	ok = talloc_dict_set(dict, data_blob_const(&key, sizeof(key)), &t);
-	if (!ok) {
-		return false;
-	}
-
-	count = 0;
-	res = talloc_dict_traverse(dict, talloc_dict_traverse_fn, &count);
-	if (res == -1) {
-		return false;
-	}
-
-	if (count != 1) {
-		return false;
-	}
-
-	if (count != res) {
-		return false;
-	}
-
-	TALLOC_FREE(dict);
-
-	return true;
-}
-
 static bool run_local_string_to_sid(int dummy) {
 	struct dom_sid sid;
 
@@ -11657,7 +11601,6 @@ static struct {
 	{ "PIDHIGH", run_pidhigh },
 	{ "LOCAL-SUBSTITUTE", run_local_substitute, 0},
 	{ "LOCAL-GENCACHE", run_local_gencache, 0},
-	{ "LOCAL-TALLOC-DICT", run_local_talloc_dict, 0},
 	{ "LOCAL-DBWRAP-WATCH1", run_dbwrap_watch1, 0 },
 	{ "LOCAL-DBWRAP-WATCH2", run_dbwrap_watch2, 0 },
 	{ "LOCAL-DBWRAP-DO-LOCKED1", run_dbwrap_do_locked1, 0 },
diff --git a/source3/wscript_build b/source3/wscript_build
index 3f7fdff8dd3..e9852f04f11 100644
--- a/source3/wscript_build
+++ b/source3/wscript_build
@@ -382,7 +382,6 @@ bld.SAMBA3_SUBSYSTEM('samba3core',
                           lib/messages.c
                           lib/util_cluster.c
                           lib/id_cache.c
-                          lib/talloc_dict.c
                           lib/serverid.c
                           lib/server_id_watch.c
                           lib/server_id_db_util.c

commit 1f2fd39be90b0480fa46823d062990cc2b2c37c3
Author: Volker Lendecke <vl at samba.org>
Date:   Wed Aug 30 13:53:02 2017 +0200

    lib: Fix a signed/unsigned hickup
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
---
 lib/util/debug.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/util/debug.c b/lib/util/debug.c
index 8b28002501f..64285506d1b 100644
--- a/lib/util/debug.c
+++ b/lib/util/debug.c
@@ -628,7 +628,7 @@ utility lists registered debug class names's
 char *debug_list_class_names_and_levels(void)
 {
 	char *buf = NULL;
-	unsigned int i;
+	int i;
 	/* prepare strings */
 	for (i = 0; i < debug_num_classes; i++) {
 		buf = talloc_asprintf_append(buf,


More information about the samba-technical mailing list