The branch, master has been updated via 4b6e9a8e49bb0f63eed65fd84c0aa28b394482cd (commit) via 2bc8e572016c79677f40c9aad63706293e11e294 (commit) via d04cca005c049d52f802f676fba7868ba89e9399 (commit) via 5ef601e5eb793e5807d8171b7a3e0d6cc327a371 (commit) from f78f92acfe2710f9f3ff11f9acea8c240f6cc5e6 (commit)
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master - Log ----------------------------------------------------------------- commit 4b6e9a8e49bb0f63eed65fd84c0aa28b394482cd Author: Stefan Metzmacher <me...@samba.org> Date: Tue Sep 8 22:07:30 2009 +0200 socket_wrapper: swrap_read() should use SWRAP_RECV* for swrap_dump_packet() This is the same as swrap_recv(). metze commit 2bc8e572016c79677f40c9aad63706293e11e294 Author: Stefan Metzmacher <me...@samba.org> Date: Tue Sep 8 12:01:46 2009 +0200 s4:repl_meta_data: remove unused code metze commit d04cca005c049d52f802f676fba7868ba89e9399 Author: Stefan Metzmacher <me...@samba.org> Date: Thu Oct 2 11:28:13 2008 +0200 s3:drsuapi: add a simple DsRemoveDSServer() implementation metze commit 5ef601e5eb793e5807d8171b7a3e0d6cc327a371 Author: Stefan Metzmacher <me...@samba.org> Date: Wed Oct 1 06:28:32 2008 +0200 s4:drsuapi: add an incomplete DsAddEntry implementation metze ----------------------------------------------------------------------- Summary of changes: lib/socket_wrapper/socket_wrapper.c | 8 +- source4/dsdb/repl/replicated_objects.c | 165 +++++++++++++++++++++- source4/dsdb/samdb/ldb_modules/repl_meta_data.c | 11 -- source4/rpc_server/drsuapi/dcesrv_drsuapi.c | 82 +++++++++++- 4 files changed, 239 insertions(+), 27 deletions(-) Changeset truncated at 500 lines: diff --git a/lib/socket_wrapper/socket_wrapper.c b/lib/socket_wrapper/socket_wrapper.c index eb53c9c..a188cc6 100644 --- a/lib/socket_wrapper/socket_wrapper.c +++ b/lib/socket_wrapper/socket_wrapper.c @@ -671,8 +671,6 @@ enum swrap_packet_type { SWRAP_CLOSE_SEND, SWRAP_CLOSE_RECV, SWRAP_CLOSE_ACK, - SWRAP_READ, - SWRAP_READ_RST }; struct swrap_file_hdr { @@ -2060,11 +2058,11 @@ _PUBLIC_ ssize_t swrap_read(int s, void *buf, size_t len) ret = real_read(s, buf, len); if (ret == -1 && errno != EAGAIN && errno != ENOBUFS) { - swrap_dump_packet(si, NULL, SWRAP_READ_RST, NULL, 0); + swrap_dump_packet(si, NULL, SWRAP_RECV_RST, NULL, 0); } else if (ret == 0) { /* END OF FILE */ - swrap_dump_packet(si, NULL, SWRAP_READ_RST, NULL, 0); + swrap_dump_packet(si, NULL, SWRAP_RECV_RST, NULL, 0); } else if (ret > 0) { - swrap_dump_packet(si, NULL, SWRAP_READ, buf, ret); + swrap_dump_packet(si, NULL, SWRAP_RECV, buf, ret); } return ret; diff --git a/source4/dsdb/repl/replicated_objects.c b/source4/dsdb/repl/replicated_objects.c index 4005d0b..4002ea8 100644 --- a/source4/dsdb/repl/replicated_objects.c +++ b/source4/dsdb/repl/replicated_objects.c @@ -31,13 +31,12 @@ #include "libcli/auth/libcli_auth.h" #include "param/param.h" -static WERROR dsdb_convert_object(struct ldb_context *ldb, - const struct dsdb_schema *schema, - struct dsdb_extended_replicated_objects *ctr, - const struct drsuapi_DsReplicaObjectListItemEx *in, - const DATA_BLOB *gensec_skey, - TALLOC_CTX *mem_ctx, - struct dsdb_extended_replicated_object *out) +static WERROR dsdb_convert_object_ex(struct ldb_context *ldb, + const struct dsdb_schema *schema, + const struct drsuapi_DsReplicaObjectListItemEx *in, + const DATA_BLOB *gensec_skey, + TALLOC_CTX *mem_ctx, + struct dsdb_extended_replicated_object *out) { NTSTATUS nt_status; enum ndr_err_code ndr_err; @@ -241,7 +240,9 @@ WERROR dsdb_extended_replicated_objects_commit(struct ldb_context *ldb, return WERR_FOOBAR; } - status = dsdb_convert_object(ldb, schema, out, cur, gensec_skey, out->objects, &out->objects[i]); + status = dsdb_convert_object_ex(ldb, schema, + cur, gensec_skey, + out->objects, &out->objects[i]); W_ERROR_NOT_OK_RETURN(status); } if (i != out->num_objects) { @@ -285,3 +286,151 @@ WERROR dsdb_extended_replicated_objects_commit(struct ldb_context *ldb, return WERR_OK; } + +static WERROR dsdb_convert_object(struct ldb_context *ldb, + const struct dsdb_schema *schema, + const struct drsuapi_DsReplicaObjectListItem *in, + TALLOC_CTX *mem_ctx, + struct ldb_message **_msg) +{ + WERROR status; + uint32_t i; + struct ldb_message *msg; + + if (!in->object.identifier) { + return WERR_FOOBAR; + } + + if (!in->object.identifier->dn || !in->object.identifier->dn[0]) { + return WERR_FOOBAR; + } + + msg = ldb_msg_new(mem_ctx); + W_ERROR_HAVE_NO_MEMORY(msg); + + msg->dn = ldb_dn_new(msg, ldb, in->object.identifier->dn); + W_ERROR_HAVE_NO_MEMORY(msg->dn); + + msg->num_elements = in->object.attribute_ctr.num_attributes; + msg->elements = talloc_array(msg, struct ldb_message_element, + msg->num_elements); + W_ERROR_HAVE_NO_MEMORY(msg->elements); + + /* + * TODO: + * + * The DsAddEntry() call which creates a nTDSDSA object, + * also adds a servicePrincipalName in the following form + * to the computer account of the new domain controller + * referenced by the "serverReferenece" attribute. + * + * E3514235-4B06-11D1-AB04-00C04FC2DCD2/<new-ntdsdsa-object-guid-as-string>/<domain-dns-name> + * + * also note that the "serverReference" isn't added to the new object! + */ + + for (i=0; i < msg->num_elements; i++) { + struct drsuapi_DsReplicaAttribute *a; + struct ldb_message_element *e; + + a = &in->object.attribute_ctr.attributes[i]; + e = &msg->elements[i]; + + status = dsdb_attribute_drsuapi_to_ldb(ldb, schema, a, msg->elements, e); + W_ERROR_NOT_OK_RETURN(status); + } + + *_msg = msg; + return WERR_OK; +} + +WERROR dsdb_origin_objects_commit(struct ldb_context *ldb, + TALLOC_CTX *mem_ctx, + const struct drsuapi_DsReplicaObjectListItem *first_object, + uint32_t *_num, + struct drsuapi_DsReplicaObjectIdentifier2 **_ids) +{ + WERROR status; + const struct dsdb_schema *schema; + const struct drsuapi_DsReplicaObjectListItem *cur; + struct ldb_message **objects; + struct drsuapi_DsReplicaObjectIdentifier2 *ids; + uint32_t i; + uint32_t num_objects = 0; + const char * const attrs[] = { + "objectGUID", + "objectSid", + NULL + }; + struct ldb_result *res; + int ret; + + schema = dsdb_get_schema(ldb); + if (!schema) { + return WERR_DS_SCHEMA_NOT_LOADED; + } + + for (cur = first_object; cur; cur = cur->next_object) { + num_objects++; + } + + if (num_objects == 0) { + return WERR_OK; + } + + objects = talloc_array(mem_ctx, struct ldb_message *, + num_objects); + W_ERROR_HAVE_NO_MEMORY(objects); + + for (i=0, cur = first_object; cur; cur = cur->next_object, i++) { + status = dsdb_convert_object(ldb, schema, + cur, objects, &objects[i]); + W_ERROR_NOT_OK_RETURN(status); + } + + ids = talloc_array(mem_ctx, + struct drsuapi_DsReplicaObjectIdentifier2, + num_objects); + W_ERROR_HAVE_NO_MEMORY(objects); + + ret = ldb_transaction_start(ldb); + if (ret != 0) { + goto cancel; + } + + for (i=0; i < num_objects; i++) { + struct dom_sid *sid = NULL; + ret = ldb_add(ldb, objects[i]); + if (ret != 0) { + goto cancel; + } + ret = ldb_search(ldb, objects, &res, objects[i]->dn, + LDB_SCOPE_BASE, attrs, + "(objectClass=*)"); + if (ret != 0) { + goto cancel; + } + ids[i].guid = samdb_result_guid(res->msgs[0], "objectGUID"); + sid = samdb_result_dom_sid(objects, res->msgs[0], "objectSid"); + if (sid) { + ids[i].sid = *sid; + } else { + ZERO_STRUCT(ids[i].sid); + } + } + + ret = ldb_transaction_commit(ldb); + if (ret != 0) { + goto cancel; + } + + talloc_free(objects); + + *_num = num_objects; + *_ids = ids; + return WERR_OK; +cancel: + talloc_free(objects); + ldb_transaction_cancel(ldb); + return WERR_FOOBAR; +} diff --git a/source4/dsdb/samdb/ldb_modules/repl_meta_data.c b/source4/dsdb/samdb/ldb_modules/repl_meta_data.c index da9087a..6a2e6f2 100644 --- a/source4/dsdb/samdb/ldb_modules/repl_meta_data.c +++ b/source4/dsdb/samdb/ldb_modules/repl_meta_data.c @@ -1079,7 +1079,6 @@ static int replmd_replicated_uptodate_modify(struct replmd_replicated_request *a struct ldb_val *nrf_value = NULL; struct ldb_message_element *nrf_el = NULL; uint32_t i,j,ni=0; - uint64_t seq_num; bool found = false; time_t t = time(NULL); NTTIME now; @@ -1094,16 +1093,6 @@ static int replmd_replicated_uptodate_modify(struct replmd_replicated_request *a unix_to_nt_time(&now, t); - /* - * we use the next sequence number for our own highest_usn - * because we will do a modify request and this will increment - * our highest_usn - */ - ret = ldb_sequence_number(ldb, LDB_SEQ_NEXT, &seq_num); - if (ret != LDB_SUCCESS) { - return replmd_replicated_request_error(ar, ret); - } - /* * first create the new replUpToDateVector */ diff --git a/source4/rpc_server/drsuapi/dcesrv_drsuapi.c b/source4/rpc_server/drsuapi/dcesrv_drsuapi.c index 30096f1..a9c7eb7 100644 --- a/source4/rpc_server/drsuapi/dcesrv_drsuapi.c +++ b/source4/rpc_server/drsuapi/dcesrv_drsuapi.c @@ -688,7 +688,48 @@ static WERROR dcesrv_drsuapi_DsWriteAccountSpn(struct dcesrv_call_state *dce_cal static WERROR dcesrv_drsuapi_DsRemoveDSServer(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct drsuapi_DsRemoveDSServer *r) { - DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR); + struct drsuapi_bind_state *b_state; + struct dcesrv_handle *h; + struct ldb_dn *ntds_dn; + int ret; + bool ok; + + ZERO_STRUCT(r->out.res); + r->out.level_out = 1; + + DCESRV_PULL_HANDLE_WERR(h, r->in.bind_handle, DRSUAPI_BIND_HANDLE); + b_state = h->data; + + switch (r->in.level) { + case 1: + ntds_dn = ldb_dn_new(mem_ctx, b_state->sam_ctx, r->in.req->req1.server_dn); + W_ERROR_HAVE_NO_MEMORY(ntds_dn); + + ok = ldb_dn_validate(ntds_dn); + if (!ok) { + return WERR_FOOBAR; + } + + /* TODO: it's likely that we need more checks here */ + + ok = ldb_dn_add_child_fmt(ntds_dn, "CN=NTDS Settings"); + if (!ok) { + return WERR_FOOBAR; + } + + if (r->in.req->req1.commit) { + ret = ldb_delete(b_state->sam_ctx, ntds_dn); + if (ret != LDB_SUCCESS) { + return WERR_FOOBAR; + } + } + + return WERR_OK; + default: + break; + } + + return WERR_FOOBAR; } @@ -966,14 +1007,49 @@ static WERROR dcesrv_drsuapi_DsGetDomainControllerInfo(struct dcesrv_call_state return WERR_UNKNOWN_LEVEL; } - /* drsuapi_DsAddEntry */ static WERROR dcesrv_drsuapi_DsAddEntry(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct drsuapi_DsAddEntry *r) { - DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR); + WERROR status; + struct drsuapi_bind_state *b_state; + struct dcesrv_handle *h; + uint32_t num = 0; + struct drsuapi_DsReplicaObjectIdentifier2 *ids = NULL; + + /* TODO: check which out level the client supports */ + + ZERO_STRUCTP(r->out.ctr); + r->out.level_out = 3; + r->out.ctr->ctr3.level = 1; + r->out.ctr->ctr3.error = talloc_zero(mem_ctx, union drsuapi_DsAddEntryError); + + DCESRV_PULL_HANDLE_WERR(h, r->in.bind_handle, DRSUAPI_BIND_HANDLE); + b_state = h->data; + + switch (r->in.level) { + case 2: + status = dsdb_origin_objects_commit(b_state->sam_ctx, + mem_ctx, + &r->in.req->req2.first_object, + &num, + &ids); + if (!W_ERROR_IS_OK(status)) { + r->out.ctr->ctr3.error->info1.status = status; + W_ERROR_NOT_OK_RETURN(status); + } + + r->out.ctr->ctr3.count = num; + r->out.ctr->ctr3.objects = ids; + + return WERR_OK; + default: + break; + } + + return WERR_FOOBAR; } -- Samba Shared Repository