diff options
-rw-r--r-- | source4/dsdb/repl/drepl_out_helpers.c | 30 | ||||
-rw-r--r-- | source4/dsdb/repl/replicated_objects.c | 63 | ||||
-rw-r--r-- | source4/libnet/libnet_vampire.c | 63 | ||||
-rw-r--r-- | source4/torture/libnet/libnet_BecomeDC.c | 64 |
4 files changed, 125 insertions, 95 deletions
diff --git a/source4/dsdb/repl/drepl_out_helpers.c b/source4/dsdb/repl/drepl_out_helpers.c index c86956c42f..03f8842494 100644 --- a/source4/dsdb/repl/drepl_out_helpers.c +++ b/source4/dsdb/repl/drepl_out_helpers.c @@ -375,6 +375,7 @@ static void dreplsrv_op_pull_source_apply_changes_send(struct dreplsrv_op_pull_s uint32_t linked_attributes_count; struct drsuapi_DsReplicaLinkedAttribute *linked_attributes; const struct drsuapi_DsReplicaCursor2CtrEx *uptodateness_vector; + struct dsdb_extended_replicated_objects *objects; bool more_data = false; WERROR status; @@ -404,18 +405,27 @@ static void dreplsrv_op_pull_source_apply_changes_send(struct dreplsrv_op_pull_s return; } + status = dsdb_extended_replicated_objects_convert(service->samdb, + partition->nc.dn, + mapping_ctr, + object_count, + first_object, + linked_attributes_count, + linked_attributes, + &rf1, + uptodateness_vector, + &drsuapi->gensec_skey, + st, &objects); + if (!W_ERROR_IS_OK(status)) { + DEBUG(0,("Failed to convert objects: %s\n", win_errstr(status))); + composite_error(c, werror_to_ntstatus(status)); + return; + } + status = dsdb_extended_replicated_objects_commit(service->samdb, - partition->nc.dn, - mapping_ctr, - object_count, - first_object, - linked_attributes_count, - linked_attributes, - &rf1, - uptodateness_vector, - &drsuapi->gensec_skey, - st, NULL, + objects, &st->op->source_dsa->notify_uSN); + talloc_free(objects); if (!W_ERROR_IS_OK(status)) { DEBUG(0,("Failed to commit objects: %s\n", win_errstr(status))); composite_error(c, werror_to_ntstatus(status)); diff --git a/source4/dsdb/repl/replicated_objects.c b/source4/dsdb/repl/replicated_objects.c index 47291b68de..020d5f1b07 100644 --- a/source4/dsdb/repl/replicated_objects.c +++ b/source4/dsdb/repl/replicated_objects.c @@ -201,28 +201,24 @@ static WERROR dsdb_convert_object_ex(struct ldb_context *ldb, return WERR_OK; } -WERROR dsdb_extended_replicated_objects_commit(struct ldb_context *ldb, - const char *partition_dn, - const struct drsuapi_DsReplicaOIDMapping_Ctr *mapping_ctr, - uint32_t object_count, - const struct drsuapi_DsReplicaObjectListItemEx *first_object, - uint32_t linked_attributes_count, - const struct drsuapi_DsReplicaLinkedAttribute *linked_attributes, - const struct repsFromTo1 *source_dsa, - const struct drsuapi_DsReplicaCursor2CtrEx *uptodateness_vector, - const DATA_BLOB *gensec_skey, - TALLOC_CTX *mem_ctx, - struct dsdb_extended_replicated_objects **_out, - uint64_t *notify_uSN) +WERROR dsdb_extended_replicated_objects_convert(struct ldb_context *ldb, + const char *partition_dn, + const struct drsuapi_DsReplicaOIDMapping_Ctr *mapping_ctr, + uint32_t object_count, + const struct drsuapi_DsReplicaObjectListItemEx *first_object, + uint32_t linked_attributes_count, + const struct drsuapi_DsReplicaLinkedAttribute *linked_attributes, + const struct repsFromTo1 *source_dsa, + const struct drsuapi_DsReplicaCursor2CtrEx *uptodateness_vector, + const DATA_BLOB *gensec_skey, + TALLOC_CTX *mem_ctx, + struct dsdb_extended_replicated_objects **objects) { WERROR status; const struct dsdb_schema *schema; struct dsdb_extended_replicated_objects *out; - struct ldb_result *ext_res; const struct drsuapi_DsReplicaObjectListItemEx *cur; uint32_t i; - int ret; - uint64_t seq_num1, seq_num2; schema = dsdb_get_schema(ldb); if (!schema) { @@ -270,6 +266,18 @@ WERROR dsdb_extended_replicated_objects_commit(struct ldb_context *ldb, return WERR_FOOBAR; } + *objects = out; + return WERR_OK; +} + +WERROR dsdb_extended_replicated_objects_commit(struct ldb_context *ldb, + struct dsdb_extended_replicated_objects *objects, + uint64_t *notify_uSN) +{ + struct ldb_result *ext_res; + int ret; + uint64_t seq_num1, seq_num2; + /* TODO: handle linked attributes */ /* wrap the extended operation in a transaction @@ -278,23 +286,20 @@ WERROR dsdb_extended_replicated_objects_commit(struct ldb_context *ldb, ret = ldb_transaction_start(ldb); if (ret != LDB_SUCCESS) { DEBUG(0,(__location__ " Failed to start transaction\n")); - talloc_free(out); return WERR_FOOBAR; } - ret = dsdb_load_partition_usn(ldb, out->partition_dn, &seq_num1); + ret = dsdb_load_partition_usn(ldb, objects->partition_dn, &seq_num1); if (ret != LDB_SUCCESS) { DEBUG(0,(__location__ " Failed to load partition uSN\n")); - talloc_free(out); ldb_transaction_cancel(ldb); return WERR_FOOBAR; } - ret = ldb_extended(ldb, DSDB_EXTENDED_REPLICATED_OBJECTS_OID, out, &ext_res); + ret = ldb_extended(ldb, DSDB_EXTENDED_REPLICATED_OBJECTS_OID, objects, &ext_res); if (ret != LDB_SUCCESS) { DEBUG(0,("Failed to apply records: %s: %s\n", ldb_errstring(ldb), ldb_strerror(ret))); - talloc_free(out); ldb_transaction_cancel(ldb); return WERR_FOOBAR; } @@ -303,14 +308,12 @@ WERROR dsdb_extended_replicated_objects_commit(struct ldb_context *ldb, ret = ldb_transaction_prepare_commit(ldb); if (ret != LDB_SUCCESS) { DEBUG(0,(__location__ " Failed to prepare commit of transaction\n")); - talloc_free(out); return WERR_FOOBAR; } - ret = dsdb_load_partition_usn(ldb, out->partition_dn, &seq_num2); + ret = dsdb_load_partition_usn(ldb, objects->partition_dn, &seq_num2); if (ret != LDB_SUCCESS) { DEBUG(0,(__location__ " Failed to load partition uSN\n")); - talloc_free(out); ldb_transaction_cancel(ldb); return WERR_FOOBAR; } @@ -325,22 +328,14 @@ WERROR dsdb_extended_replicated_objects_commit(struct ldb_context *ldb, ret = ldb_transaction_commit(ldb); if (ret != LDB_SUCCESS) { DEBUG(0,(__location__ " Failed to commit transaction\n")); - talloc_free(out); return WERR_FOOBAR; } DEBUG(2,("Replicated %u objects (%u linked attributes) for %s\n", - out->num_objects, out->linked_attributes_count, - ldb_dn_get_linearized(out->partition_dn))); + objects->num_objects, objects->linked_attributes_count, + ldb_dn_get_linearized(objects->partition_dn))); - - if (_out) { - *_out = out; - } else { - talloc_free(out); - } - return WERR_OK; } diff --git a/source4/libnet/libnet_vampire.c b/source4/libnet/libnet_vampire.c index f7131c1d02..2f30826cce 100644 --- a/source4/libnet/libnet_vampire.c +++ b/source4/libnet/libnet_vampire.c @@ -280,7 +280,6 @@ static NTSTATUS vampire_apply_schema(struct vampire_state *s, if (!W_ERROR_IS_OK(status)) { return werror_to_ntstatus(status); } - DLIST_ADD_END(s->self_made_schema->classes, sc, struct dsdb_class *); } } @@ -291,20 +290,21 @@ static NTSTATUS vampire_apply_schema(struct vampire_state *s, return NT_STATUS_FOOBAR; } /* we don't want to access the self made schema anymore */ + s->schema = s->self_made_schema; s->self_made_schema = NULL; - s->schema = dsdb_get_schema(s->ldb); - status = dsdb_extended_replicated_objects_commit(s->ldb, - c->partition->nc.dn, - mapping_ctr, - object_count, - first_object, - linked_attributes_count, - linked_attributes, - s_dsa, - uptodateness_vector, - c->gensec_skey, - s, &objs, &seq_num); + /* Now convert the schema elements again, using the schema we just imported */ + status = dsdb_extended_replicated_objects_convert(s->ldb, + c->partition->nc.dn, + mapping_ctr, + object_count, + first_object, + linked_attributes_count, + linked_attributes, + s_dsa, + uptodateness_vector, + c->gensec_skey, + s, &objs); if (!W_ERROR_IS_OK(status)) { DEBUG(0,("Failed to commit objects: %s\n", win_errstr(status))); return werror_to_ntstatus(status); @@ -321,6 +321,12 @@ static NTSTATUS vampire_apply_schema(struct vampire_state *s, } } + status = dsdb_extended_replicated_objects_commit(s->ldb, objs, &seq_num); + if (!W_ERROR_IS_OK(status)) { + DEBUG(0,("Failed to commit objects: %s\n", win_errstr(status))); + return werror_to_ntstatus(status); + } + msg = ldb_msg_new(objs); NT_STATUS_HAVE_NO_MEMORY(msg); msg->dn = objs->partition_dn; @@ -535,19 +541,19 @@ static NTSTATUS vampire_store_chunk(void *private_data, } - status = dsdb_extended_replicated_objects_commit(s->ldb, - c->partition->nc.dn, - mapping_ctr, - object_count, - first_object, - linked_attributes_count, - linked_attributes, - s_dsa, - uptodateness_vector, - c->gensec_skey, - s, &objs, &seq_num); + status = dsdb_extended_replicated_objects_convert(s->ldb, + c->partition->nc.dn, + mapping_ctr, + object_count, + first_object, + linked_attributes_count, + linked_attributes, + s_dsa, + uptodateness_vector, + c->gensec_skey, + s, &objs); if (!W_ERROR_IS_OK(status)) { - DEBUG(0,("Failed to commit objects: %s\n", win_errstr(status))); + DEBUG(0,("Failed to convert objects: %s\n", win_errstr(status))); return werror_to_ntstatus(status); } @@ -561,6 +567,13 @@ static NTSTATUS vampire_store_chunk(void *private_data, NDR_PRINT_DEBUG(replPropertyMetaDataBlob, objs->objects[i].meta_data); } } + status = dsdb_extended_replicated_objects_commit(s->ldb, + objs, &seq_num); + if (!W_ERROR_IS_OK(status)) { + DEBUG(0,("Failed to commit objects: %s\n", win_errstr(status))); + return werror_to_ntstatus(status); + } + talloc_free(s_dsa); talloc_free(objs); diff --git a/source4/torture/libnet/libnet_BecomeDC.c b/source4/torture/libnet/libnet_BecomeDC.c index 342463875d..d990e803be 100644 --- a/source4/torture/libnet/libnet_BecomeDC.c +++ b/source4/torture/libnet/libnet_BecomeDC.c @@ -258,19 +258,19 @@ static NTSTATUS test_apply_schema(struct test_become_dc_state *s, s->self_made_schema = NULL; s->schema = dsdb_get_schema(s->ldb); - status = dsdb_extended_replicated_objects_commit(s->ldb, - c->partition->nc.dn, - mapping_ctr, - object_count, - first_object, - linked_attributes_count, - linked_attributes, - s_dsa, - uptodateness_vector, - c->gensec_skey, - s, &objs, &seq_num); + status = dsdb_extended_replicated_objects_convert(s->ldb, + c->partition->nc.dn, + mapping_ctr, + object_count, + first_object, + linked_attributes_count, + linked_attributes, + s_dsa, + uptodateness_vector, + c->gensec_skey, + s, &objs); if (!W_ERROR_IS_OK(status)) { - DEBUG(0,("Failed to commit objects: %s\n", win_errstr(status))); + DEBUG(0,("Failed to convert objects: %s\n", win_errstr(status))); return werror_to_ntstatus(status); } @@ -285,6 +285,13 @@ static NTSTATUS test_apply_schema(struct test_become_dc_state *s, } } + status = dsdb_extended_replicated_objects_commit(s->ldb, + objs, &seq_num); + if (!W_ERROR_IS_OK(status)) { + DEBUG(0,("Failed to commit objects: %s\n", win_errstr(status))); + return werror_to_ntstatus(status); + } + msg = ldb_msg_new(objs); NT_STATUS_HAVE_NO_MEMORY(msg); msg->dn = objs->partition_dn; @@ -500,19 +507,19 @@ static NTSTATUS test_become_dc_store_chunk(void *private_data, c->partition->nc.dn, object_count, linked_attributes_count)); } - status = dsdb_extended_replicated_objects_commit(s->ldb, - c->partition->nc.dn, - mapping_ctr, - object_count, - first_object, - linked_attributes_count, - linked_attributes, - s_dsa, - uptodateness_vector, - c->gensec_skey, - s, &objs, &seq_num); + status = dsdb_extended_replicated_objects_convert(s->ldb, + c->partition->nc.dn, + mapping_ctr, + object_count, + first_object, + linked_attributes_count, + linked_attributes, + s_dsa, + uptodateness_vector, + c->gensec_skey, + s, &objs); if (!W_ERROR_IS_OK(status)) { - DEBUG(0,("Failed to commit objects: %s\n", win_errstr(status))); + DEBUG(0,("Failed to convert objects: %s\n", win_errstr(status))); return werror_to_ntstatus(status); } @@ -526,8 +533,13 @@ static NTSTATUS test_become_dc_store_chunk(void *private_data, NDR_PRINT_DEBUG(replPropertyMetaDataBlob, objs->objects[i].meta_data); } } + status = dsdb_extended_replicated_objects_commit(s->ldb, objs, &seq_num); talloc_free(s_dsa); talloc_free(objs); + if (!W_ERROR_IS_OK(status)) { + DEBUG(0,("Failed to commit objects: %s\n", win_errstr(status))); + return werror_to_ntstatus(status); + } for (i=0; i < linked_attributes_count; i++) { const struct dsdb_attribute *sa; @@ -618,7 +630,7 @@ bool torture_net_become_dc(struct torture_context *torture) status = libnet_BecomeDC(s->ctx, s, &b); if (!NT_STATUS_IS_OK(status)) { - printf("libnet_BecomeDC() failed - %s\n", nt_errstr(status)); + printf("libnet_BecomeDC() failed - %s %s\n", nt_errstr(status), b.out.error_string); ret = false; goto cleanup; } @@ -693,7 +705,7 @@ cleanup: status = libnet_UnbecomeDC(s->ctx, s, &u); if (!NT_STATUS_IS_OK(status)) { - printf("libnet_UnbecomeDC() failed - %s\n", nt_errstr(status)); + printf("libnet_UnbecomeDC() failed - %s %s\n", nt_errstr(status), u.out.error_string); ret = false; } |