summaryrefslogtreecommitdiff
path: root/source4/dsdb
diff options
context:
space:
mode:
Diffstat (limited to 'source4/dsdb')
-rw-r--r--source4/dsdb/samdb/ldb_modules/subtree_delete.c27
1 files changed, 16 insertions, 11 deletions
diff --git a/source4/dsdb/samdb/ldb_modules/subtree_delete.c b/source4/dsdb/samdb/ldb_modules/subtree_delete.c
index 55a24549dd..241cc5f7d6 100644
--- a/source4/dsdb/samdb/ldb_modules/subtree_delete.c
+++ b/source4/dsdb/samdb/ldb_modules/subtree_delete.c
@@ -69,8 +69,8 @@ static int subtree_delete_search_callback(struct ldb_request *req,
ldb = ldb_module_get_ctx(ac->module);
if (!ares) {
- return ldb_module_done(ac->req, NULL, NULL,
- LDB_ERR_OPERATIONS_ERROR);
+ ret = LDB_ERR_OPERATIONS_ERROR;
+ goto done;
}
if (ares->error != LDB_SUCCESS) {
return ldb_module_done(ac->req, ares->controls,
@@ -79,21 +79,23 @@ static int subtree_delete_search_callback(struct ldb_request *req,
switch (ares->type) {
case LDB_REPLY_ENTRY:
+ /* count entry */
+ ++(ac->num_children);
talloc_free(ares);
- ac->num_children++;
+ ret = LDB_SUCCESS;
break;
case LDB_REPLY_REFERRAL:
-
/* ignore */
talloc_free(ares);
+ ret = LDB_SUCCESS;
break;
case LDB_REPLY_DONE:
+ talloc_free(ares);
if (ac->num_children > 0) {
- talloc_free(ares);
ldb_asprintf_errstring(ldb,
"Cannot delete %s, not a leaf node "
"(has %d children)\n",
@@ -105,13 +107,14 @@ static int subtree_delete_search_callback(struct ldb_request *req,
/* ok no children, let the original request through */
ret = ldb_next_request(ac->module, ac->req);
- if (ret != LDB_SUCCESS) {
- return ldb_module_done(ac->req, NULL, NULL, ret);
- }
+ break;
+ }
- /* free our own context we are not going to be called back */
- talloc_free(ac);
+done:
+ if (ret != LDB_SUCCESS) {
+ return ldb_module_done(ac->req, NULL, NULL, ret);
}
+
return LDB_SUCCESS;
}
@@ -122,7 +125,9 @@ static int subtree_delete(struct ldb_module *module, struct ldb_request *req)
struct ldb_request *search_req;
struct subtree_delete_context *ac;
int ret;
- if (ldb_dn_is_special(req->op.rename.olddn)) { /* do not manipulate our control entries */
+
+ if (ldb_dn_is_special(req->op.rename.olddn)) {
+ /* do not manipulate our control entries */
return ldb_next_request(module, req);
}