diff options
author | Andrew Bartlett <abartlet@samba.org> | 2007-10-18 05:39:55 +0200 |
---|---|---|
committer | Stefan Metzmacher <metze@samba.org> | 2007-12-21 05:43:17 +0100 |
commit | 21c65d93eba74d615fa7727e684097f51cf568bc (patch) | |
tree | d06ebf53f28406483384267d23e86a3e4eb6b89f | |
parent | 5861a17042d1dfb9ae77a519b7e0da9484c2074c (diff) | |
download | samba-21c65d93eba74d615fa7727e684097f51cf568bc.tar.gz samba-21c65d93eba74d615fa7727e684097f51cf568bc.tar.xz samba-21c65d93eba74d615fa7727e684097f51cf568bc.zip |
r25693: Implement the rest of subtree renames, now that tridge waved his magic
over the ldb_tdb part of the problem.
Andrew Bartlett
(This used to be commit daca0cfd2fc2ec3344415d2d31f399ee3bf16151)
-rw-r--r-- | source4/dsdb/samdb/ldb_modules/subtree_rename.c | 56 | ||||
-rw-r--r-- | source4/scripting/libjs/provision.js | 4 |
2 files changed, 36 insertions, 24 deletions
diff --git a/source4/dsdb/samdb/ldb_modules/subtree_rename.c b/source4/dsdb/samdb/ldb_modules/subtree_rename.c index 2cc83b308be..267892cf581 100644 --- a/source4/dsdb/samdb/ldb_modules/subtree_rename.c +++ b/source4/dsdb/samdb/ldb_modules/subtree_rename.c @@ -79,20 +79,26 @@ static struct subtree_rename_context *subtree_rename_init_handle(struct ldb_requ static int subtree_rename_search_callback(struct ldb_context *ldb, void *context, struct ldb_reply *ares) { + struct ldb_request *req; + struct subtree_rename_context *ac = talloc_get_type(context, struct subtree_rename_context); + TALLOC_CTX *mem_ctx = talloc_new(ac); + + if (!mem_ctx) { + ldb_oom(ac->module->ldb); + return LDB_ERR_OPERATIONS_ERROR; + } /* OK, we have one of *many* search results here: We should also get the entry we tried to rename. This callback handles this and everything below it. */ - if (ares->type == LDB_REPLY_ENTRY) { + /* Only entries are interesting, and we handle the case of the parent seperatly */ + if (ares->type == LDB_REPLY_ENTRY + && ldb_dn_compare(ares->message->dn, ac->orig_req->op.rename.olddn) != 0) { /* And it is an actual entry: now create a rename from it */ - struct subtree_rename_context *ac = talloc_get_type(context, struct subtree_rename_context); - struct ldb_request *req; int ret; - TALLOC_CTX *mem_ctx = talloc_new(ac); - struct ldb_dn *newdn = ldb_dn_copy(mem_ctx, ares->message->dn); if (!newdn) { ldb_oom(ac->module->ldb); @@ -118,26 +124,30 @@ static int subtree_rename_search_callback(struct ldb_context *ldb, void *context talloc_steal(req, newdn); talloc_steal(req, ares->message->dn); - + talloc_free(ares); - - ac->down_req = talloc_realloc(ac, ac->down_req, - struct ldb_request *, ac->num_requests + 1); - if (!ac->down_req) { - ldb_oom(ac->module->ldb); - return LDB_ERR_OPERATIONS_ERROR; - } - ac->down_req[ac->num_requests] = req; - ac->num_requests++; - return ldb_next_request(ac->module, req); + } else if (ares->type == LDB_REPLY_DONE) { + req = talloc(mem_ctx, struct ldb_request); + *req = *ac->orig_req; + talloc_free(ares); } else { talloc_free(ares); + return LDB_SUCCESS; } - - return LDB_SUCCESS; - + + ac->down_req = talloc_realloc(ac, ac->down_req, + struct ldb_request *, ac->num_requests + 1); + if (!ac->down_req) { + ldb_oom(ac->module->ldb); + return LDB_ERR_OPERATIONS_ERROR; + } + ac->down_req[ac->num_requests] = req; + ac->num_requests++; + + return ldb_next_request(ac->module, req); + } /* rename */ @@ -148,7 +158,7 @@ static int subtree_rename(struct ldb_module *module, struct ldb_request *req) struct subtree_rename_context *ac; int ret; struct ldb_search_options_control *search_options; - if (ldb_dn_is_special(req->op.mod.message->dn)) { /* 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); } @@ -175,6 +185,10 @@ static int subtree_rename(struct ldb_module *module, struct ldb_request *req) ac, subtree_rename_search_callback); + if (ret != LDB_SUCCESS) { + return ret; + } + /* We want to find any partitions under this entry. That way, * if we try and rename a whole partition, the partitions * module should cause us to fail the lot */ @@ -238,8 +252,6 @@ static int subtree_rename_wait_none(struct ldb_handle *handle) { } } - ret = LDB_SUCCESS; - done: handle->state = LDB_ASYNC_DONE; return ret; diff --git a/source4/scripting/libjs/provision.js b/source4/scripting/libjs/provision.js index b9c7dda8e62..d4b2d635651 100644 --- a/source4/scripting/libjs/provision.js +++ b/source4/scripting/libjs/provision.js @@ -972,8 +972,8 @@ function provision_guess() subobj.CONFIGDN_LDB = "configuration.ldb"; subobj.SCHEMADN_LDB = "schema.ldb"; subobj.DOMAINDN_MOD = "subtree_rename,pdc_fsmo,password_hash"; - subobj.CONFIGDN_MOD = "naming_fsmo"; - subobj.SCHEMADN_MOD = "schema_fsmo"; + subobj.CONFIGDN_MOD = "subtree_rename,naming_fsmo"; + subobj.SCHEMADN_MOD = "subtree_rename,schema_fsmo"; subobj.DOMAINDN_MOD2 = ",objectguid"; subobj.CONFIGDN_MOD2 = ",objectguid"; subobj.SCHEMADN_MOD2 = ",objectguid"; |