From 5107f6fd0acc7d8e5a69bd838f44f74f0a094290 Mon Sep 17 00:00:00 2001 From: Matthias Dieter Wallnöfer Date: Sun, 6 Sep 2009 17:27:51 +0200 Subject: s4:subtree delete module - Cosmetic adaptions --- source4/dsdb/samdb/ldb_modules/subtree_delete.c | 27 +++++++++++++++---------- 1 file changed, 16 insertions(+), 11 deletions(-) (limited to 'source4/dsdb/samdb/ldb_modules') 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); } -- cgit