svn commit: samba r19720 - in branches/SAMBA_4_0/source/lib/ldb:
common nssldb
metze at samba.org
metze at samba.org
Wed Nov 15 16:09:37 GMT 2006
Author: metze
Date: 2006-11-15 16:09:36 +0000 (Wed, 15 Nov 2006)
New Revision: 19720
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=19720
Log:
- don't pass a pointer reference to ldb_search_default_callback()
as it's ugly when it free's the callers memory on failure!
- only steal the controls on a LDB_REPLY_EXTENDED, LDB_REPLY_DONE
and ignore them on LDB_REPLY_ENTRY, LDB_REPLY_REFERRAL as we currently
have not way to return them in a ldb_result (we should fix this!)
metze
Modified:
branches/SAMBA_4_0/source/lib/ldb/common/ldb.c
branches/SAMBA_4_0/source/lib/ldb/nssldb/ldb-nss.c
Changeset:
Modified: branches/SAMBA_4_0/source/lib/ldb/common/ldb.c
===================================================================
--- branches/SAMBA_4_0/source/lib/ldb/common/ldb.c 2006-11-15 15:33:38 UTC (rev 19719)
+++ branches/SAMBA_4_0/source/lib/ldb/common/ldb.c 2006-11-15 16:09:36 UTC (rev 19720)
@@ -532,12 +532,13 @@
return LDB_ERR_OPERATIONS_ERROR;
}
- res = *((struct ldb_result **)context);
+ res = talloc_get_type(context, struct ldb_result);
if (!res || !ares) {
+ ldb_set_errstring(ldb, "NULL res or ares in callback");
goto error;
}
-
+
switch (ares->type) {
case LDB_REPLY_ENTRY:
res->msgs = talloc_realloc(res, res->msgs, struct ldb_message *, res->count + 2);
@@ -566,18 +567,15 @@
res->refs[n + 1] = NULL;
case LDB_REPLY_EXTENDED:
case LDB_REPLY_DONE:
- /* Should do something here to detect if this never
- * happens */
+ /* TODO: we should really support controls on entries and referrals too! */
+ res->controls = talloc_move(res, &ares->controls);
break;
}
- talloc_steal(res, ares->controls);
talloc_free(ares);
return LDB_SUCCESS;
error:
talloc_free(ares);
- talloc_free(res);
- *((struct ldb_result **)context) = NULL;
return LDB_ERR_OPERATIONS_ERROR;
}
@@ -753,16 +751,19 @@
enum ldb_scope scope,
const char *expression,
const char * const *attrs,
- struct ldb_result **res)
+ struct ldb_result **_res)
{
struct ldb_request *req;
int ret;
+ struct ldb_result *res;
- *res = talloc_zero(ldb, struct ldb_result);
- if (! *res) {
+ *_res = NULL;
+
+ res = talloc_zero(ldb, struct ldb_result);
+ if (!res) {
return LDB_ERR_OPERATIONS_ERROR;
}
-
+
ret = ldb_build_search_req(&req, ldb, ldb,
base?base:ldb_get_default_basedn(ldb),
scope,
@@ -786,10 +787,10 @@
done:
if (ret != LDB_SUCCESS) {
- talloc_free(*res);
- *res = NULL;
+ talloc_free(res);
}
+ *_res = res;
return ret;
}
Modified: branches/SAMBA_4_0/source/lib/ldb/nssldb/ldb-nss.c
===================================================================
--- branches/SAMBA_4_0/source/lib/ldb/nssldb/ldb-nss.c 2006-11-15 15:33:38 UTC (rev 19719)
+++ branches/SAMBA_4_0/source/lib/ldb/nssldb/ldb-nss.c 2006-11-15 16:09:36 UTC (rev 19720)
@@ -336,7 +336,7 @@
#define _LDB_NSS_ALLOC_CHECK(mem) do { if (!mem) { errno = ENOMEM; return NSS_STATUS_UNAVAIL; } } while(0)
-NSS_STATUS _ldb_nss_group_request(struct ldb_result **res,
+NSS_STATUS _ldb_nss_group_request(struct ldb_result **_res,
struct ldb_dn *group_dn,
const char * const *attrs,
const char *mattr)
@@ -346,8 +346,9 @@
struct ldb_asq_control *asqc;
struct ldb_request *req;
int ret;
+ struct ldb_result *res = *_res;
- ctrls = talloc_array(*res, struct ldb_control *, 2);
+ ctrls = talloc_array(res, struct ldb_control *, 2);
_LDB_NSS_ALLOC_CHECK(ctrls);
ctrl = talloc(ctrls, struct ldb_control);
@@ -370,7 +371,7 @@
ret = ldb_build_search_req(
&req,
_ldb_nss_ctx->ldb,
- *res,
+ res,
group_dn,
LDB_SCOPE_BASE,
"(objectClass=*)",
More information about the samba-cvs
mailing list