1
0
mirror of https://github.com/samba-team/samba.git synced 2025-08-02 00:22:11 +03:00

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 daca0cfd2f)
This commit is contained in:
Andrew Bartlett
2007-10-18 05:39:55 +02:00
committed by Stefan Metzmacher
parent 5861a17042
commit 21c65d93eb
2 changed files with 37 additions and 25 deletions

View 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) 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: /* OK, we have one of *many* search results here:
We should also get the entry we tried to rename. This We should also get the entry we tried to rename. This
callback handles this and everything below it. 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 */ /* 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; int ret;
TALLOC_CTX *mem_ctx = talloc_new(ac);
struct ldb_dn *newdn = ldb_dn_copy(mem_ctx, ares->message->dn); struct ldb_dn *newdn = ldb_dn_copy(mem_ctx, ares->message->dn);
if (!newdn) { if (!newdn) {
ldb_oom(ac->module->ldb); 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, newdn);
talloc_steal(req, ares->message->dn); 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); talloc_free(ares);
} else if (ares->type == LDB_REPLY_DONE) {
req = talloc(mem_ctx, struct ldb_request);
*req = *ac->orig_req;
talloc_free(ares);
} else { } else {
talloc_free(ares); 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 */ /* rename */
@ -148,7 +158,7 @@ static int subtree_rename(struct ldb_module *module, struct ldb_request *req)
struct subtree_rename_context *ac; struct subtree_rename_context *ac;
int ret; int ret;
struct ldb_search_options_control *search_options; 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); return ldb_next_request(module, req);
} }
@ -175,6 +185,10 @@ static int subtree_rename(struct ldb_module *module, struct ldb_request *req)
ac, ac,
subtree_rename_search_callback); subtree_rename_search_callback);
if (ret != LDB_SUCCESS) {
return ret;
}
/* We want to find any partitions under this entry. That way, /* We want to find any partitions under this entry. That way,
* if we try and rename a whole partition, the partitions * if we try and rename a whole partition, the partitions
* module should cause us to fail the lot */ * 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: done:
handle->state = LDB_ASYNC_DONE; handle->state = LDB_ASYNC_DONE;
return ret; return ret;

View File

@ -972,8 +972,8 @@ function provision_guess()
subobj.CONFIGDN_LDB = "configuration.ldb"; subobj.CONFIGDN_LDB = "configuration.ldb";
subobj.SCHEMADN_LDB = "schema.ldb"; subobj.SCHEMADN_LDB = "schema.ldb";
subobj.DOMAINDN_MOD = "subtree_rename,pdc_fsmo,password_hash"; subobj.DOMAINDN_MOD = "subtree_rename,pdc_fsmo,password_hash";
subobj.CONFIGDN_MOD = "naming_fsmo"; subobj.CONFIGDN_MOD = "subtree_rename,naming_fsmo";
subobj.SCHEMADN_MOD = "schema_fsmo"; subobj.SCHEMADN_MOD = "subtree_rename,schema_fsmo";
subobj.DOMAINDN_MOD2 = ",objectguid"; subobj.DOMAINDN_MOD2 = ",objectguid";
subobj.CONFIGDN_MOD2 = ",objectguid"; subobj.CONFIGDN_MOD2 = ",objectguid";
subobj.SCHEMADN_MOD2 = ",objectguid"; subobj.SCHEMADN_MOD2 = ",objectguid";