repl_meta_data: Do rename before deleted object cleanup
authorAndrew Bartlett <abartlet@samba.org>
Mon, 21 Mar 2016 23:07:27 +0000 (12:07 +1300)
committerAndrew Bartlett <abartlet@samba.org>
Wed, 1 Jun 2016 12:01:36 +0000 (14:01 +0200)
Following from the lesson of subtree_rename, do the rename first,
as this is more likely to fail for some reason

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
Autobuild-User(master): Andrew Bartlett <abartlet@samba.org>
Autobuild-Date(master): Wed Jun  1 14:01:36 CEST 2016 on sn-devel-144

source4/dsdb/samdb/ldb_modules/repl_meta_data.c

index f65cc655c79b16e7e1f3add21ff2aad941ae5e04..c0c8de54d2e19d2290b935c3782e8ecebc43e11b 100644 (file)
@@ -3495,14 +3495,6 @@ static int replmd_delete_internals(struct ldb_module *module, struct ldb_request
         *
         */
 
-       ret = dsdb_module_modify(module, msg, DSDB_FLAG_OWN_MODULE, req);
-       if (ret != LDB_SUCCESS) {
-               ldb_asprintf_errstring(ldb, "replmd_delete: Failed to modify object %s in delete - %s",
-                                      ldb_dn_get_linearized(old_dn), ldb_errstring(ldb));
-               talloc_free(tmp_ctx);
-               return ret;
-       }
-
        /*
         * No matter what has happned with other renames, try again to
         * get this to be under the deleted DN.
@@ -3518,6 +3510,15 @@ static int replmd_delete_internals(struct ldb_module *module, struct ldb_request
                        talloc_free(tmp_ctx);
                        return ret;
                }
+               msg->dn = new_dn;
+       }
+
+       ret = dsdb_module_modify(module, msg, DSDB_FLAG_OWN_MODULE, req);
+       if (ret != LDB_SUCCESS) {
+               ldb_asprintf_errstring(ldb, "replmd_delete: Failed to modify object %s in delete - %s",
+                                      ldb_dn_get_linearized(old_dn), ldb_errstring(ldb));
+               talloc_free(tmp_ctx);
+               return ret;
        }
 
        talloc_free(tmp_ctx);