From 508527890adc7bedd47522a7dae0c96d2b2e4bae Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Tue, 23 Sep 2008 14:30:06 -0400 Subject: Merge ldb_search() and ldb_search_exp_fmt() into a simgle function. The previous ldb_search() interface made it way too easy to leak results, and being able to use a printf-like expression turns to be really useful. --- source4/winbind/idmap.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'source4/winbind') diff --git a/source4/winbind/idmap.c b/source4/winbind/idmap.c index 333a86445a..56ade3e8b1 100644 --- a/source4/winbind/idmap.c +++ b/source4/winbind/idmap.c @@ -54,11 +54,9 @@ static int idmap_get_bounds(struct idmap_context *idmap_ctx, uint32_t *low, dn = ldb_dn_new(tmp_ctx, ldb, "CN=CONFIG"); if (dn == NULL) goto failed; - ret = ldb_search(ldb, dn, LDB_SCOPE_BASE, NULL, NULL, &res); + ret = ldb_search(ldb, tmp_ctx, &res, dn, LDB_SCOPE_BASE, NULL, NULL); if (ret != LDB_SUCCESS) goto failed; - talloc_steal(tmp_ctx, res); - if (res->count != 1) { ret = -1; goto failed; @@ -228,7 +226,7 @@ NTSTATUS idmap_xid_to_sid(struct idmap_context *idmap_ctx, TALLOC_CTX *mem_ctx, goto failed; } - ret = ldb_search_exp_fmt(ldb, tmp_ctx, &res, NULL, LDB_SCOPE_SUBTREE, + ret = ldb_search(ldb, tmp_ctx, &res, NULL, LDB_SCOPE_SUBTREE, NULL, "(&(|(type=ID_TYPE_BOTH)(type=%s))" "(xidNumber=%u))", id_type, unixid->id); if (ret != LDB_SUCCESS) { @@ -345,7 +343,7 @@ NTSTATUS idmap_sid_to_xid(struct idmap_context *idmap_ctx, TALLOC_CTX *mem_ctx, return NT_STATUS_OK; } - ret = ldb_search_exp_fmt(ldb, tmp_ctx, &res, NULL, LDB_SCOPE_SUBTREE, + ret = ldb_search(ldb, tmp_ctx, &res, NULL, LDB_SCOPE_SUBTREE, NULL, "(&(objectClass=sidMap)(objectSid=%s))", ldap_encode_ndr_dom_sid(tmp_ctx, sid)); if (ret != LDB_SUCCESS) { @@ -401,7 +399,7 @@ NTSTATUS idmap_sid_to_xid(struct idmap_context *idmap_ctx, TALLOC_CTX *mem_ctx, /* Redo the search to make sure noone changed the mapping while we * weren't looking */ - ret = ldb_search_exp_fmt(ldb, tmp_ctx, &res, NULL, LDB_SCOPE_SUBTREE, + ret = ldb_search(ldb, tmp_ctx, &res, NULL, LDB_SCOPE_SUBTREE, NULL, "(&(objectClass=sidMap)(objectSid=%s))", ldap_encode_ndr_dom_sid(tmp_ctx, sid)); if (ret != LDB_SUCCESS) { @@ -431,15 +429,13 @@ NTSTATUS idmap_sid_to_xid(struct idmap_context *idmap_ctx, TALLOC_CTX *mem_ctx, goto failed; } - ret = ldb_search(ldb, dn, LDB_SCOPE_BASE, NULL, NULL, &res); + ret = ldb_search(ldb, tmp_ctx, &res, dn, LDB_SCOPE_BASE, NULL, NULL); if (ret != LDB_SUCCESS) { DEBUG(1, ("Search failed: %s\n", ldb_errstring(ldb))); status = NT_STATUS_NONE_MAPPED; goto failed; } - talloc_steal(tmp_ctx, res); - if (res->count != 1) { DEBUG(1, ("No CN=CONFIG record, idmap database is broken.\n")); status = NT_STATUS_NONE_MAPPED; -- cgit