summaryrefslogtreecommitdiff
path: root/source4/lib/ldb
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2010-10-13 20:58:38 +1100
committerAndrew Tridgell <tridge@samba.org>2010-10-13 11:00:04 +0000
commit269143fa0031ef0b6d801b47aab48ff3b1414565 (patch)
treee83088e77860bd0e7dc513aaa2792a42008c9885 /source4/lib/ldb
parent549c044b9fe76e7d5a47a08fe73a99c87a41ddf4 (diff)
downloadsamba-269143fa0031ef0b6d801b47aab48ff3b1414565.tar.gz
samba-269143fa0031ef0b6d801b47aab48ff3b1414565.tar.bz2
samba-269143fa0031ef0b6d801b47aab48ff3b1414565.zip
s4-ldb: take advantage of ldb_match_msg_error() in more places
this gives better error checking
Diffstat (limited to 'source4/lib/ldb')
-rw-r--r--source4/lib/ldb/include/ldb_module.h7
-rw-r--r--source4/lib/ldb/ldb_map/ldb_map_outbound.c13
-rw-r--r--source4/lib/ldb/ldb_tdb/ldb_index.c10
-rw-r--r--source4/lib/ldb/ldb_tdb/ldb_search.c10
4 files changed, 32 insertions, 8 deletions
diff --git a/source4/lib/ldb/include/ldb_module.h b/source4/lib/ldb/include/ldb_module.h
index 18982b975f..a708063ed8 100644
--- a/source4/lib/ldb/include/ldb_module.h
+++ b/source4/lib/ldb/include/ldb_module.h
@@ -135,6 +135,13 @@ int ldb_match_msg(struct ldb_context *ldb,
struct ldb_dn *base,
enum ldb_scope scope);
+int ldb_match_msg_error(struct ldb_context *ldb,
+ const struct ldb_message *msg,
+ const struct ldb_parse_tree *tree,
+ struct ldb_dn *base,
+ enum ldb_scope scope,
+ bool *matched);
+
int ldb_match_msg_objectclass(const struct ldb_message *msg,
const char *objectclass);
diff --git a/source4/lib/ldb/ldb_map/ldb_map_outbound.c b/source4/lib/ldb/ldb_map/ldb_map_outbound.c
index 98cd525e86..40be94c894 100644
--- a/source4/lib/ldb/ldb_map/ldb_map_outbound.c
+++ b/source4/lib/ldb/ldb_map/ldb_map_outbound.c
@@ -1070,14 +1070,19 @@ int map_return_entry(struct map_context *ac, struct ldb_reply *ares)
const char * const *attrs;
struct ldb_context *ldb;
unsigned int i;
+ int ret;
+ bool matched;
ldb = ldb_module_get_ctx(ac->module);
/* Merged result doesn't match original query, skip */
- if (!ldb_match_msg(ldb, ares->message,
- ac->req->op.search.tree,
- ac->req->op.search.base,
- ac->req->op.search.scope)) {
+ ret = ldb_match_msg_error(ldb, ares->message,
+ ac->req->op.search.tree,
+ ac->req->op.search.base,
+ ac->req->op.search.scope,
+ &matched);
+ if (ret != LDB_SUCCESS) return ret;
+ if (!matched) {
ldb_debug(ldb, LDB_DEBUG_TRACE, "ldb_map: "
"Skipping record '%s': "
"doesn't match original search",
diff --git a/source4/lib/ldb/ldb_tdb/ldb_index.c b/source4/lib/ldb/ldb_tdb/ldb_index.c
index a39e6c7097..db49455745 100644
--- a/source4/lib/ldb/ldb_tdb/ldb_index.c
+++ b/source4/lib/ldb/ldb_tdb/ldb_index.c
@@ -918,6 +918,7 @@ static int ltdb_index_filter(const struct dn_list *dn_list,
for (i = 0; i < dn_list->count; i++) {
struct ldb_dn *dn;
int ret;
+ bool matched;
msg = ldb_msg_new(ac);
if (!msg) {
@@ -944,8 +945,13 @@ static int ltdb_index_filter(const struct dn_list *dn_list,
return LDB_ERR_OPERATIONS_ERROR;
}
- if (!ldb_match_msg(ldb, msg,
- ac->tree, ac->base, ac->scope)) {
+ ret = ldb_match_msg_error(ldb, msg,
+ ac->tree, ac->base, ac->scope, &matched);
+ if (ret != LDB_SUCCESS) {
+ talloc_free(msg);
+ return ret;
+ }
+ if (!matched) {
talloc_free(msg);
continue;
}
diff --git a/source4/lib/ldb/ldb_tdb/ldb_search.c b/source4/lib/ldb/ldb_tdb/ldb_search.c
index 9ebec90233..ca47fa3a5d 100644
--- a/source4/lib/ldb/ldb_tdb/ldb_search.c
+++ b/source4/lib/ldb/ldb_tdb/ldb_search.c
@@ -384,6 +384,7 @@ static int search_func(struct tdb_context *tdb, TDB_DATA key, TDB_DATA data, voi
struct ltdb_context *ac;
struct ldb_message *msg;
int ret;
+ bool matched;
ac = talloc_get_type(state, struct ltdb_context);
ldb = ldb_module_get_ctx(ac->module);
@@ -415,8 +416,13 @@ static int search_func(struct tdb_context *tdb, TDB_DATA key, TDB_DATA data, voi
}
/* see if it matches the given expression */
- if (!ldb_match_msg(ldb, msg,
- ac->tree, ac->base, ac->scope)) {
+ ret = ldb_match_msg_error(ldb, msg,
+ ac->tree, ac->base, ac->scope, &matched);
+ if (ret != LDB_SUCCESS) {
+ talloc_free(msg);
+ return -1;
+ }
+ if (!matched) {
talloc_free(msg);
return 0;
}