r25693: Implement the rest of subtree renames, now that tridge waved his magic
authorAndrew Bartlett <abartlet@samba.org>
Thu, 18 Oct 2007 03:39:55 +0000 (05:39 +0200)
committerStefan Metzmacher <metze@samba.org>
Fri, 21 Dec 2007 04:43:17 +0000 (05:43 +0100)
over the ldb_tdb part of the problem.

Andrew Bartlett
(This used to be commit daca0cfd2fc2ec3344415d2d31f399ee3bf16151)

source4/dsdb/samdb/ldb_modules/subtree_rename.c
source4/scripting/libjs/provision.js

index 2cc83b308be14f9a084394178ecfc6bc695b3454..267892cf5814e4a7d9f7713ed86e57cf31b6cc82 100644 (file)
@@ -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;
index b9c7dda8e62b76f80c596246153afb3b6074827d..d4b2d63565142c681d3668de76a47dc66ffc925d 100644 (file)
@@ -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";