diff options
Diffstat (limited to 'source4')
46 files changed, 525 insertions, 6717 deletions
diff --git a/source4/Makefile b/source4/Makefile index 7dae4729b7..26cab668c8 100644 --- a/source4/Makefile +++ b/source4/Makefile @@ -301,8 +301,8 @@ data.mk: config.status $(MK_FILES) testcov-html:: include $(pidldir)/config.mk -selftestdir := $(srcdir)/selftest -include $(selftestdir)/config.mk +selftestdir := $(srcdir)/../selftest +include $(srcdir)/selftest/config.mk showflags:: @echo ' pwd = '`/bin/pwd` diff --git a/source4/dsdb/repl/drepl_out_helpers.c b/source4/dsdb/repl/drepl_out_helpers.c index 800645014d..c292c6db74 100644 --- a/source4/dsdb/repl/drepl_out_helpers.c +++ b/source4/dsdb/repl/drepl_out_helpers.c @@ -246,40 +246,42 @@ static void dreplsrv_op_pull_source_get_changes_send(struct dreplsrv_op_pull_sou r = talloc(st, struct drsuapi_DsGetNCChanges); if (composite_nomem(r, c)) return; - r->in.level = talloc(r, int32_t); - if (composite_nomem(r->in.level, c)) return; - r->out.level = talloc(r, int32_t); - if (composite_nomem(r->out.level, c)) return; + r->out.level_out = talloc(r, int32_t); + if (composite_nomem(r->out.level_out, c)) return; + r->in.req = talloc(r, union drsuapi_DsGetNCChangesRequest); + if (composite_nomem(r->in.req, c)) return; + r->out.ctr = talloc(r, union drsuapi_DsGetNCChangesCtr); + if (composite_nomem(r->out.ctr, c)) return; r->in.bind_handle = &drsuapi->bind_handle; if (drsuapi->remote_info28.supported_extensions & DRSUAPI_SUPPORTED_EXTENSION_GETCHGREQ_V8) { - *r->in.level = 8; - r->in.req.req8.destination_dsa_guid = service->ntds_guid; - r->in.req.req8.source_dsa_invocation_id = rf1->source_dsa_invocation_id; - r->in.req.req8.naming_context = &partition->nc; - r->in.req.req8.highwatermark = rf1->highwatermark; - r->in.req.req8.uptodateness_vector = NULL;/*&partition->uptodatevector_ex;*/ - r->in.req.req8.replica_flags = rf1->replica_flags; - r->in.req.req8.max_object_count = 133; - r->in.req.req8.max_ndr_size = 1336811; - r->in.req.req8.extended_op = DRSUAPI_EXOP_NONE; - r->in.req.req8.fsmo_info = 0; - r->in.req.req8.partial_attribute_set = NULL; - r->in.req.req8.partial_attribute_set_ex = NULL; - r->in.req.req8.mapping_ctr.num_mappings = 0; - r->in.req.req8.mapping_ctr.mappings = NULL; + r->in.level = 8; + r->in.req->req8.destination_dsa_guid = service->ntds_guid; + r->in.req->req8.source_dsa_invocation_id= rf1->source_dsa_invocation_id; + r->in.req->req8.naming_context = &partition->nc; + r->in.req->req8.highwatermark = rf1->highwatermark; + r->in.req->req8.uptodateness_vector = NULL;/*&partition->uptodatevector_ex;*/ + r->in.req->req8.replica_flags = rf1->replica_flags; + r->in.req->req8.max_object_count = 133; + r->in.req->req8.max_ndr_size = 1336811; + r->in.req->req8.extended_op = DRSUAPI_EXOP_NONE; + r->in.req->req8.fsmo_info = 0; + r->in.req->req8.partial_attribute_set = NULL; + r->in.req->req8.partial_attribute_set_ex= NULL; + r->in.req->req8.mapping_ctr.num_mappings= 0; + r->in.req->req8.mapping_ctr.mappings = NULL; } else { - *r->in.level = 5; - r->in.req.req5.destination_dsa_guid = service->ntds_guid; - r->in.req.req5.source_dsa_invocation_id = rf1->source_dsa_invocation_id; - r->in.req.req5.naming_context = &partition->nc; - r->in.req.req5.highwatermark = rf1->highwatermark; - r->in.req.req5.uptodateness_vector = NULL;/*&partition->uptodatevector_ex;*/ - r->in.req.req5.replica_flags = rf1->replica_flags; - r->in.req.req5.max_object_count = 133; - r->in.req.req5.max_ndr_size = 1336770; - r->in.req.req5.extended_op = DRSUAPI_EXOP_NONE; - r->in.req.req5.fsmo_info = 0; + r->in.level = 5; + r->in.req->req5.destination_dsa_guid = service->ntds_guid; + r->in.req->req5.source_dsa_invocation_id= rf1->source_dsa_invocation_id; + r->in.req->req5.naming_context = &partition->nc; + r->in.req->req5.highwatermark = rf1->highwatermark; + r->in.req->req5.uptodateness_vector = NULL;/*&partition->uptodatevector_ex;*/ + r->in.req->req5.replica_flags = rf1->replica_flags; + r->in.req->req5.max_object_count = 133; + r->in.req->req5.max_ndr_size = 1336770; + r->in.req->req5.extended_op = DRSUAPI_EXOP_NONE; + r->in.req->req5.fsmo_info = 0; } req = dcerpc_drsuapi_DsGetNCChanges_send(drsuapi->pipe, r, r); @@ -311,28 +313,28 @@ static void dreplsrv_op_pull_source_get_changes_recv(struct rpc_request *req) return; } - if (*r->out.level == 1) { + if (*r->out.level_out == 1) { ctr_level = 1; - ctr1 = &r->out.ctr.ctr1; - } else if (*r->out.level == 2 && - r->out.ctr.ctr2.mszip1.ts) { + ctr1 = &r->out.ctr->ctr1; + } else if (*r->out.level_out == 2 && + r->out.ctr->ctr2.mszip1.ts) { ctr_level = 1; - ctr1 = &r->out.ctr.ctr2.mszip1.ts->ctr1; - } else if (*r->out.level == 6) { + ctr1 = &r->out.ctr->ctr2.mszip1.ts->ctr1; + } else if (*r->out.level_out == 6) { ctr_level = 6; - ctr6 = &r->out.ctr.ctr6; - } else if (*r->out.level == 7 && - r->out.ctr.ctr7.level == 6 && - r->out.ctr.ctr7.type == DRSUAPI_COMPRESSION_TYPE_MSZIP && - r->out.ctr.ctr7.ctr.mszip6.ts) { + ctr6 = &r->out.ctr->ctr6; + } else if (*r->out.level_out == 7 && + r->out.ctr->ctr7.level == 6 && + r->out.ctr->ctr7.type == DRSUAPI_COMPRESSION_TYPE_MSZIP && + r->out.ctr->ctr7.ctr.mszip6.ts) { ctr_level = 6; - ctr6 = &r->out.ctr.ctr7.ctr.mszip6.ts->ctr6; - } else if (*r->out.level == 7 && - r->out.ctr.ctr7.level == 6 && - r->out.ctr.ctr7.type == DRSUAPI_COMPRESSION_TYPE_XPRESS && - r->out.ctr.ctr7.ctr.xpress6.ts) { + ctr6 = &r->out.ctr->ctr7.ctr.mszip6.ts->ctr6; + } else if (*r->out.level_out == 7 && + r->out.ctr->ctr7.level == 6 && + r->out.ctr->ctr7.type == DRSUAPI_COMPRESSION_TYPE_XPRESS && + r->out.ctr->ctr7.ctr.xpress6.ts) { ctr_level = 6; - ctr6 = &r->out.ctr.ctr7.ctr.xpress6.ts->ctr6; + ctr6 = &r->out.ctr->ctr7.ctr.xpress6.ts->ctr6; } else { composite_error(c, werror_to_ntstatus(WERR_BAD_NET_RESP)); return; diff --git a/source4/dsdb/samdb/ldb_modules/extended_dn.c b/source4/dsdb/samdb/ldb_modules/extended_dn.c index 88a8887056..a0602d9281 100644 --- a/source4/dsdb/samdb/ldb_modules/extended_dn.c +++ b/source4/dsdb/samdb/ldb_modules/extended_dn.c @@ -424,7 +424,7 @@ static int extended_search(struct ldb_module *module, struct ldb_request *req) valstr = str; } else { DATA_BLOB binary; - binary = strhex_to_data_blob(str); + binary = strhex_to_data_blob(NULL, str); if (!binary.data) { ldb_oom(module->ldb); return LDB_ERR_OPERATIONS_ERROR; @@ -471,7 +471,7 @@ static int extended_search(struct ldb_module *module, struct ldb_request *req) valstr = str; } else { DATA_BLOB binary; - binary = strhex_to_data_blob(str); + binary = strhex_to_data_blob(NULL, str); if (!binary.data) { ldb_oom(module->ldb); return LDB_ERR_OPERATIONS_ERROR; diff --git a/source4/dsdb/samdb/ldb_modules/password_hash.c b/source4/dsdb/samdb/ldb_modules/password_hash.c index c4451d1355..5ed7f1fbad 100644 --- a/source4/dsdb/samdb/ldb_modules/password_hash.c +++ b/source4/dsdb/samdb/ldb_modules/password_hash.c @@ -482,12 +482,11 @@ static int setup_primary_kerberos(struct setup_password_fields_io *io, if (old_scp) { DATA_BLOB blob; - blob = strhex_to_data_blob(old_scp->data); + blob = strhex_to_data_blob(io->ac, old_scp->data); if (!blob.data) { ldb_oom(io->ac->module->ldb); return LDB_ERR_OPERATIONS_ERROR; } - talloc_steal(io->ac, blob.data); /* TODO: use ndr_pull_struct_blob_all(), when the ndr layer handles it correct with relative pointers */ ndr_err = ndr_pull_struct_blob(&blob, io->ac, lp_iconv_convenience(ldb_get_opaque(io->ac->module->ldb, "loadparm")), &_old_pkb, @@ -596,12 +595,11 @@ static int setup_primary_kerberos_newer(struct setup_password_fields_io *io, if (old_scp) { DATA_BLOB blob; - blob = strhex_to_data_blob(old_scp->data); + blob = strhex_to_data_blob(io->ac, old_scp->data); if (!blob.data) { ldb_oom(io->ac->module->ldb); return LDB_ERR_OPERATIONS_ERROR; } - talloc_steal(io->ac, blob.data); /* TODO: use ndr_pull_struct_blob_all(), when the ndr layer handles it correct with relative pointers */ ndr_err = ndr_pull_struct_blob(&blob, io->ac, diff --git a/source4/dsdb/schema/schema_init.c b/source4/dsdb/schema/schema_init.c index 93697a3df0..69d4c2ce80 100644 --- a/source4/dsdb/schema/schema_init.c +++ b/source4/dsdb/schema/schema_init.c @@ -199,9 +199,8 @@ WERROR dsdb_get_oid_mappings_ldb(const struct dsdb_schema *schema, return ntstatus_to_werror(nt_status); } - *schemaInfo = strhex_to_data_blob(schema->schema_info); + *schemaInfo = strhex_to_data_blob(mem_ctx, schema->schema_info); W_ERROR_HAVE_NO_MEMORY(schemaInfo->data); - talloc_steal(mem_ctx, schemaInfo->data); return WERR_OK; } @@ -819,12 +818,11 @@ int dsdb_schema_from_ldb_results(TALLOC_CTX *mem_ctx, struct ldb_context *ldb, } info_val = ldb_msg_find_ldb_val(schema_res->msgs[0], "schemaInfo"); if (!info_val) { - info_val_default = strhex_to_data_blob("FF0000000000000000000000000000000000000000"); + info_val_default = strhex_to_data_blob(mem_ctx, "FF0000000000000000000000000000000000000000"); if (!info_val_default.data) { dsdb_oom(error_string, mem_ctx); return LDB_ERR_OPERATIONS_ERROR; } - talloc_steal(mem_ctx, info_val_default.data); info_val = &info_val_default; } diff --git a/source4/dsdb/schema/schema_set.c b/source4/dsdb/schema/schema_set.c index f8de82e56a..d0aae4e221 100644 --- a/source4/dsdb/schema/schema_set.c +++ b/source4/dsdb/schema/schema_set.c @@ -328,11 +328,10 @@ WERROR dsdb_attach_schema_from_ldif_file(struct ldb_context *ldb, const char *pf info_val = ldb_msg_find_ldb_val(msg, "schemaInfo"); if (!info_val) { - info_val_default = strhex_to_data_blob("FF0000000000000000000000000000000000000000"); + info_val_default = strhex_to_data_blob(mem_ctx, "FF0000000000000000000000000000000000000000"); if (!info_val_default.data) { goto nomem; } - talloc_steal(mem_ctx, info_val_default.data); info_val = &info_val_default; } diff --git a/source4/kdc/hdb-samba4.c b/source4/kdc/hdb-samba4.c index 3a1379bee4..b6a48e79d0 100644 --- a/source4/kdc/hdb-samba4.c +++ b/source4/kdc/hdb-samba4.c @@ -277,12 +277,11 @@ static krb5_error_code LDB_message2entry_keys(krb5_context context, if (scpk) { DATA_BLOB blob; - blob = strhex_to_data_blob(scpk->data); + blob = strhex_to_data_blob(mem_ctx, scpk->data); if (!blob.data) { ret = ENOMEM; goto out; } - talloc_steal(mem_ctx, blob.data); /* we cannot use ndr_pull_struct_blob_all() here, as w2k and w2k3 add padding bytes */ ndr_err = ndr_pull_struct_blob(&blob, mem_ctx, iconv_convenience, &_pkb, diff --git a/source4/lib/registry/util.c b/source4/lib/registry/util.c index 68efd56a86..b3b6e49ea5 100644 --- a/source4/lib/registry/util.c +++ b/source4/lib/registry/util.c @@ -140,8 +140,7 @@ _PUBLIC_ bool reg_string_to_val(TALLOC_CTX *mem_ctx, break; case REG_BINARY: - *data = strhex_to_data_blob(data_str); - talloc_steal(mem_ctx, data->data); + *data = strhex_to_data_blob(mem_ctx, data_str); break; default: diff --git a/source4/libcli/raw/rawfile.c b/source4/libcli/raw/rawfile.c index d39c61551b..d174fbfc28 100644 --- a/source4/libcli/raw/rawfile.c +++ b/source4/libcli/raw/rawfile.c @@ -30,6 +30,50 @@ if (!req) return NULL; \ } while (0) +/** + Return a string representing a CIFS attribute for a file. +**/ +_PUBLIC_ char *attrib_string(TALLOC_CTX *mem_ctx, uint32_t attrib) +{ + int i, len; + const struct { + char c; + uint16_t attr; + } attr_strs[] = { + {'V', FILE_ATTRIBUTE_VOLUME}, + {'D', FILE_ATTRIBUTE_DIRECTORY}, + {'A', FILE_ATTRIBUTE_ARCHIVE}, + {'H', FILE_ATTRIBUTE_HIDDEN}, + {'S', FILE_ATTRIBUTE_SYSTEM}, + {'N', FILE_ATTRIBUTE_NORMAL}, + {'R', FILE_ATTRIBUTE_READONLY}, + {'d', FILE_ATTRIBUTE_DEVICE}, + {'t', FILE_ATTRIBUTE_TEMPORARY}, + {'s', FILE_ATTRIBUTE_SPARSE}, + {'r', FILE_ATTRIBUTE_REPARSE_POINT}, + {'c', FILE_ATTRIBUTE_COMPRESSED}, + {'o', FILE_ATTRIBUTE_OFFLINE}, + {'n', FILE_ATTRIBUTE_NONINDEXED}, + {'e', FILE_ATTRIBUTE_ENCRYPTED} + }; + char *ret; + + ret = talloc_array(mem_ctx, char, ARRAY_SIZE(attr_strs)+1); + if (!ret) { + return NULL; + } + + for (len=i=0; i<ARRAY_SIZE(attr_strs); i++) { + if (attrib & attr_strs[i].attr) { + ret[len++] = attr_strs[i].c; + } + } + + ret[len] = 0; + + return ret; +} + /**************************************************************************** Rename a file - async interface ****************************************************************************/ diff --git a/source4/libnet/libnet_become_dc.c b/source4/libnet/libnet_become_dc.c index 4cbebbf6d0..6e7924248c 100644 --- a/source4/libnet/libnet_become_dc.c +++ b/source4/libnet/libnet_become_dc.c @@ -2173,11 +2173,15 @@ static void becomeDC_drsuapi1_add_entry_send(struct libnet_BecomeDC_state *s) /* setup request structure */ r->in.bind_handle = &s->drsuapi1.bind_handle; r->in.level = 2; - r->in.req.req2.first_object.next_object = NULL; - r->in.req.req2.first_object.object.identifier = identifier; - r->in.req.req2.first_object.object.flags = 0x00000000; - r->in.req.req2.first_object.object.attribute_ctr.num_attributes = num_attrs; - r->in.req.req2.first_object.object.attribute_ctr.attributes = attrs; + r->in.req = talloc(s, union drsuapi_DsAddEntryRequest); + r->in.req->req2.first_object.next_object = NULL; + r->in.req->req2.first_object.object.identifier = identifier; + r->in.req->req2.first_object.object.flags = 0x00000000; + r->in.req->req2.first_object.object.attribute_ctr.num_attributes= num_attrs; + r->in.req->req2.first_object.object.attribute_ctr.attributes = attrs; + + r->out.level_out = talloc(s, int32_t); + r->out.ctr = talloc(s, union drsuapi_DsAddEntryCtr); req = dcerpc_drsuapi_DsAddEntry_send(s->drsuapi1.pipe, r, r); composite_continue_rpc(c, req, becomeDC_drsuapi1_add_entry_recv, s); @@ -2212,37 +2216,37 @@ static void becomeDC_drsuapi1_add_entry_recv(struct rpc_request *req) return; } - if (r->out.level == 3) { - if (r->out.ctr.ctr3.count != 1) { + if (*r->out.level_out == 3) { + if (r->out.ctr->ctr3.count != 1) { WERROR status; - if (r->out.ctr.ctr3.level != 1) { + if (r->out.ctr->ctr3.level != 1) { composite_error(c, NT_STATUS_INVALID_NETWORK_RESPONSE); return; } - if (!r->out.ctr.ctr3.error) { + if (!r->out.ctr->ctr3.error) { composite_error(c, NT_STATUS_INVALID_NETWORK_RESPONSE); return; } - status = r->out.ctr.ctr3.error->info1.status; + status = r->out.ctr->ctr3.error->info1.status; - if (!r->out.ctr.ctr3.error->info1.info) { + if (!r->out.ctr->ctr3.error->info1.info) { composite_error(c, werror_to_ntstatus(status)); return; } /* see if we can get a more detailed error */ - switch (r->out.ctr.ctr3.error->info1.level) { + switch (r->out.ctr->ctr3.error->info1.level) { case 1: - status = r->out.ctr.ctr3.error->info1.info->error1.status; + status = r->out.ctr->ctr3.error->info1.info->error1.status; break; case 4: case 5: case 6: case 7: - status = r->out.ctr.ctr3.error->info1.info->errorX.status; + status = r->out.ctr->ctr3.error->info1.info->errorX.status; break; } @@ -2250,14 +2254,14 @@ static void becomeDC_drsuapi1_add_entry_recv(struct rpc_request *req) return; } - s->dest_dsa.ntds_guid = r->out.ctr.ctr3.objects[0].guid; - } else if (r->out.level == 2) { - if (r->out.ctr.ctr2.count != 1) { - composite_error(c, werror_to_ntstatus(r->out.ctr.ctr2.error.status)); + s->dest_dsa.ntds_guid = r->out.ctr->ctr3.objects[0].guid; + } else if (*r->out.level_out == 2) { + if (r->out.ctr->ctr2.count != 1) { + composite_error(c, werror_to_ntstatus(r->out.ctr->ctr2.error.status)); return; } - s->dest_dsa.ntds_guid = r->out.ctr.ctr2.objects[0].guid; + s->dest_dsa.ntds_guid = r->out.ctr->ctr2.objects[0].guid; } else { composite_error(c, NT_STATUS_INVALID_NETWORK_RESPONSE); return; @@ -2392,40 +2396,42 @@ static void becomeDC_drsuapi_pull_partition_send(struct libnet_BecomeDC_state *s r = talloc(s, struct drsuapi_DsGetNCChanges); if (composite_nomem(r, c)) return; - r->in.level = talloc(r, int32_t); - if (composite_nomem(r->in.level, c)) return; - r->out.level = talloc(r, int32_t); - if (composite_nomem(r->out.level, c)) return; + r->out.level_out = talloc(r, int32_t); + if (composite_nomem(r->out.level_out, c)) return; + r->in.req = talloc(r, union drsuapi_DsGetNCChangesRequest); + if (composite_nomem(r->in.req, c)) return; + r->out.ctr = talloc(r, union drsuapi_DsGetNCChangesCtr); + if (composite_nomem(r->out.ctr, c)) return; r->in.bind_handle = &drsuapi_h->bind_handle; if (drsuapi_h->remote_info28.supported_extensions & DRSUAPI_SUPPORTED_EXTENSION_GETCHGREQ_V8) { - *r->in.level = 8; - r->in.req.req8.destination_dsa_guid = partition->destination_dsa_guid; - r->in.req.req8.source_dsa_invocation_id = partition->source_dsa_invocation_id; - r->in.req.req8.naming_context = &partition->nc; - r->in.req.req8.highwatermark = partition->highwatermark; - r->in.req.req8.uptodateness_vector = NULL; - r->in.req.req8.replica_flags = partition->replica_flags; - r->in.req.req8.max_object_count = 133; - r->in.req.req8.max_ndr_size = 1336811; - r->in.req.req8.extended_op = DRSUAPI_EXOP_NONE; - r->in.req.req8.fsmo_info = 0; - r->in.req.req8.partial_attribute_set = NULL; - r->in.req.req8.partial_attribute_set_ex = NULL; - r->in.req.req8.mapping_ctr.num_mappings = 0; - r->in.req.req8.mapping_ctr.mappings = NULL; + r->in.level = 8; + r->in.req->req8.destination_dsa_guid = partition->destination_dsa_guid; + r->in.req->req8.source_dsa_invocation_id= partition->source_dsa_invocation_id; + r->in.req->req8.naming_context = &partition->nc; + r->in.req->req8.highwatermark = partition->highwatermark; + r->in.req->req8.uptodateness_vector = NULL; + r->in.req->req8.replica_flags = partition->replica_flags; + r->in.req->req8.max_object_count = 133; + r->in.req->req8.max_ndr_size = 1336811; + r->in.req->req8.extended_op = DRSUAPI_EXOP_NONE; + r->in.req->req8.fsmo_info = 0; + r->in.req->req8.partial_attribute_set = NULL; + r->in.req->req8.partial_attribute_set_ex= NULL; + r->in.req->req8.mapping_ctr.num_mappings= 0; + r->in.req->req8.mapping_ctr.mappings = NULL; } else { - *r->in.level = 5; - r->in.req.req5.destination_dsa_guid = partition->destination_dsa_guid; - r->in.req.req5.source_dsa_invocation_id = partition->source_dsa_invocation_id; - r->in.req.req5.naming_context = &partition->nc; - r->in.req.req5.highwatermark = partition->highwatermark; - r->in.req.req5.uptodateness_vector = NULL; - r->in.req.req5.replica_flags = partition->replica_flags; - r->in.req.req5.max_object_count = 133; - r->in.req.req5.max_ndr_size = 1336770; - r->in.req.req5.extended_op = DRSUAPI_EXOP_NONE; - r->in.req.req5.fsmo_info = 0; + r->in.level = 5; + r->in.req->req5.destination_dsa_guid = partition->destination_dsa_guid; + r->in.req->req5.source_dsa_invocation_id= partition->source_dsa_invocation_id; + r->in.req->req5.naming_context = &partition->nc; + r->in.req->req5.highwatermark = partition->highwatermark; + r->in.req->req5.uptodateness_vector = NULL; + r->in.req->req5.replica_flags = partition->replica_flags; + r->in.req->req5.max_object_count = 133; + r->in.req->req5.max_ndr_size = 1336770; + r->in.req->req5.extended_op = DRSUAPI_EXOP_NONE; + r->in.req->req5.fsmo_info = 0; } /* @@ -2457,28 +2463,28 @@ static WERROR becomeDC_drsuapi_pull_partition_recv(struct libnet_BecomeDC_state return r->out.result; } - if (*r->out.level == 1) { + if (*r->out.level_out == 1) { ctr_level = 1; - ctr1 = &r->out.ctr.ctr1; - } else if (*r->out.level == 2 && - r->out.ctr.ctr2.mszip1.ts) { + ctr1 = &r->out.ctr->ctr1; + } else if (*r->out.level_out == 2 && + r->out.ctr->ctr2.mszip1.ts) { ctr_level = 1; - ctr1 = &r->out.ctr.ctr2.mszip1.ts->ctr1; - } else if (*r->out.level == 6) { + ctr1 = &r->out.ctr->ctr2.mszip1.ts->ctr1; + } else if (*r->out.level_out == 6) { ctr_level = 6; - ctr6 = &r->out.ctr.ctr6; - } else if (*r->out.level == 7 && - r->out.ctr.ctr7.level == 6 && - r->out.ctr.ctr7.type == DRSUAPI_COMPRESSION_TYPE_MSZIP && - r->out.ctr.ctr7.ctr.mszip6.ts) { + ctr6 = &r->out.ctr->ctr6; + } else if (*r->out.level_out == 7 && + r->out.ctr->ctr7.level == 6 && + r->out.ctr->ctr7.type == DRSUAPI_COMPRESSION_TYPE_MSZIP && + r->out.ctr->ctr7.ctr.mszip6.ts) { ctr_level = 6; - ctr6 = &r->out.ctr.ctr7.ctr.mszip6.ts->ctr6; - } else if (*r->out.level == 7 && - r->out.ctr.ctr7.level == 6 && - r->out.ctr.ctr7.type == DRSUAPI_COMPRESSION_TYPE_XPRESS && - r->out.ctr.ctr7.ctr.xpress6.ts) { + ctr6 = &r->out.ctr->ctr7.ctr.mszip6.ts->ctr6; + } else if (*r->out.level_out == 7 && + r->out.ctr->ctr7.level == 6 && + r->out.ctr->ctr7.type == DRSUAPI_COMPRESSION_TYPE_XPRESS && + r->out.ctr->ctr7.ctr.xpress6.ts) { ctr_level = 6; - ctr6 = &r->out.ctr.ctr7.ctr.xpress6.ts->ctr6; + ctr6 = &r->out.ctr->ctr7.ctr.xpress6.ts->ctr6; } else { return WERR_BAD_NET_RESP; } diff --git a/source4/libnet/libnet_join.c b/source4/libnet/libnet_join.c index f4de9031ec..0ed5e8ae26 100644 --- a/source4/libnet/libnet_join.c +++ b/source4/libnet/libnet_join.c @@ -162,13 +162,19 @@ static NTSTATUS libnet_JoinADSDomain(struct libnet_context *ctx, struct libnet_J ZERO_STRUCT(r_crack_names); r_crack_names.in.bind_handle = &drsuapi_bind_handle; r_crack_names.in.level = 1; - r_crack_names.in.req.req1.codepage = 1252; /* western european */ - r_crack_names.in.req.req1.language = 0x00000407; /* german */ - r_crack_names.in.req.req1.count = 1; - r_crack_names.in.req.req1.names = names; - r_crack_names.in.req.req1.format_flags = DRSUAPI_DS_NAME_FLAG_NO_FLAGS; - r_crack_names.in.req.req1.format_offered= DRSUAPI_DS_NAME_FORMAT_SID_OR_SID_HISTORY; - r_crack_names.in.req.req1.format_desired= DRSUAPI_DS_NAME_FORMAT_FQDN_1779; + r_crack_names.in.req = talloc(r, union drsuapi_DsNameRequest); + if (!r_crack_names.in.req) { + r->out.error_string = NULL; + talloc_free(tmp_ctx); + return NT_STATUS_NO_MEMORY; + } + r_crack_names.in.req->req1.codepage = 1252; /* western european */ + r_crack_names.in.req->req1.language = 0x00000407; /* german */ + r_crack_names.in.req->req1.count = 1; + r_crack_names.in.req->req1.names = names; + r_crack_names.in.req->req1.format_flags = DRSUAPI_DS_NAME_FLAG_NO_FLAGS; + r_crack_names.in.req->req1.format_offered = DRSUAPI_DS_NAME_FORMAT_SID_OR_SID_HISTORY; + r_crack_names.in.req->req1.format_desired = DRSUAPI_DS_NAME_FORMAT_FQDN_1779; names[0].str = dom_sid_string(tmp_ctx, r->out.account_sid); if (!names[0].str) { r->out.error_string = NULL; @@ -176,6 +182,14 @@ static NTSTATUS libnet_JoinADSDomain(struct libnet_context *ctx, struct libnet_J return NT_STATUS_NO_MEMORY; } + r_crack_names.out.ctr = talloc(r, union drsuapi_DsNameCtr); + r_crack_names.out.level_out = talloc(r, int32_t); + if (!r_crack_names.out.ctr || !r_crack_names.out.level_out) { + r->out.error_string = NULL; + talloc_free(tmp_ctx); + return NT_STATUS_NO_MEMORY; + } + status = dcerpc_drsuapi_DsCrackNames(drsuapi_pipe, tmp_ctx, &r_crack_names); if (!NT_STATUS_IS_OK(status)) { if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { @@ -201,24 +215,24 @@ static NTSTATUS libnet_JoinADSDomain(struct libnet_context *ctx, struct libnet_J "DsCrackNames failed - %s", win_errstr(r_crack_names.out.result)); talloc_free(tmp_ctx); return NT_STATUS_UNSUCCESSFUL; - } else if (r_crack_names.out.level != 1 - || !r_crack_names.out.ctr.ctr1 - || r_crack_names.out.ctr.ctr1->count != 1) { + } else if (*r_crack_names.out.level_out != 1 + || !r_crack_names.out.ctr->ctr1 + || r_crack_names.out.ctr->ctr1->count != 1) { r->out.error_string = talloc_asprintf(r, "DsCrackNames failed"); talloc_free(tmp_ctx); return NT_STATUS_INVALID_PARAMETER; - } else if (r_crack_names.out.ctr.ctr1->array[0].status != DRSUAPI_DS_NAME_STATUS_OK) { - r->out.error_string = talloc_asprintf(r, "DsCrackNames failed: %d", r_crack_names.out.ctr.ctr1->array[0].status); + } else if (r_crack_names.out.ctr->ctr1->array[0].status != DRSUAPI_DS_NAME_STATUS_OK) { + r->out.error_string = talloc_asprintf(r, "DsCrackNames failed: %d", r_crack_names.out.ctr->ctr1->array[0].status); talloc_free(tmp_ctx); return NT_STATUS_UNSUCCESSFUL; - } else if (r_crack_names.out.ctr.ctr1->array[0].result_name == NULL) { + } else if (r_crack_names.out.ctr->ctr1->array[0].result_name == NULL) { r->out.error_string = talloc_asprintf(r, "DsCrackNames failed: no result name"); talloc_free(tmp_ctx); return NT_STATUS_INVALID_PARAMETER; } /* Store the DN of our machine account. */ - account_dn_str = r_crack_names.out.ctr.ctr1->array[0].result_name; + account_dn_str = r_crack_names.out.ctr->ctr1->array[0].result_name; /* Now we know the user's DN, open with LDAP, read and modify a few things */ @@ -328,8 +342,8 @@ static NTSTATUS libnet_JoinADSDomain(struct libnet_context *ctx, struct libnet_J } /* DsCrackNames to find out the DN of the domain. */ - r_crack_names.in.req.req1.format_offered = DRSUAPI_DS_NAME_FORMAT_NT4_ACCOUNT; - r_crack_names.in.req.req1.format_desired = DRSUAPI_DS_NAME_FORMAT_FQDN_1779; + r_crack_names.in.req->req1.format_offered = DRSUAPI_DS_NAME_FORMAT_NT4_ACCOUNT; + r_crack_names.in.req->req1.format_desired = DRSUAPI_DS_NAME_FORMAT_FQDN_1779; names[0].str = talloc_asprintf(tmp_ctx, "%s\\", r->out.domain_name); if (!names[0].str) { r->out.error_string = NULL; @@ -362,11 +376,11 @@ static NTSTATUS libnet_JoinADSDomain(struct libnet_context *ctx, struct libnet_J "DsCrackNames failed - %s", win_errstr(r_crack_names.out.result)); talloc_free(tmp_ctx); return NT_STATUS_UNSUCCESSFUL; - } else if (r_crack_names.out.level != 1 - || !r_crack_names.out.ctr.ctr1 - || r_crack_names.out.ctr.ctr1->count != 1 - || !r_crack_names.out.ctr.ctr1->array[0].result_name - || r_crack_names.out.ctr.ctr1->array[0].status != DRSUAPI_DS_NAME_STATUS_OK) { + } else if (*r_crack_names.out.level_out != 1 + || !r_crack_names.out.ctr->ctr1 + || r_crack_names.out.ctr->ctr1->count != 1 + || !r_crack_names.out.ctr->ctr1->array[0].result_name + || r_crack_names.out.ctr->ctr1->array[0].status != DRSUAPI_DS_NAME_STATUS_OK) { r->out.error_string = talloc_asprintf(r, "DsCrackNames failed"); talloc_free(tmp_ctx); return NT_STATUS_UNSUCCESSFUL; @@ -377,8 +391,8 @@ static NTSTATUS libnet_JoinADSDomain(struct libnet_context *ctx, struct libnet_J talloc_steal(r, account_dn_str); /* Store the domain DN. */ - r->out.domain_dn_str = r_crack_names.out.ctr.ctr1->array[0].result_name; - talloc_steal(r, r_crack_names.out.ctr.ctr1->array[0].result_name); + r->out.domain_dn_str = r_crack_names.out.ctr->ctr1->array[0].result_name; + talloc_steal(r, r_crack_names.out.ctr->ctr1->array[0].result_name); /* Store the KVNO of the account, critical for some kerberos * operations */ diff --git a/source4/libnet/libnet_unbecome_dc.c b/source4/libnet/libnet_unbecome_dc.c index 2ee3c641b2..79c6dc0fc1 100644 --- a/source4/libnet/libnet_unbecome_dc.c +++ b/source4/libnet/libnet_unbecome_dc.c @@ -639,9 +639,13 @@ static void unbecomeDC_drsuapi_remove_ds_server_send(struct libnet_UnbecomeDC_st r->in.bind_handle = &s->drsuapi.bind_handle; r->in.level = 1; - r->in.req.req1.server_dn= s->dest_dsa.server_dn_str; - r->in.req.req1.domain_dn= s->domain.dn_str; - r->in.req.req1.commit = true; + r->in.req = talloc(s, union drsuapi_DsRemoveDSServerRequest); + r->in.req->req1.server_dn = s->dest_dsa.server_dn_str; + r->in.req->req1.domain_dn = s->domain.dn_str; + r->in.req->req1.commit = true; + + r->out.level_out = talloc(s, int32_t); + r->out.res = talloc(s, union drsuapi_DsRemoveDSServerResult); req = dcerpc_drsuapi_DsRemoveDSServer_send(s->drsuapi.pipe, s, r); composite_continue_rpc(c, req, unbecomeDC_drsuapi_remove_ds_server_recv, s); @@ -662,7 +666,7 @@ static void unbecomeDC_drsuapi_remove_ds_server_recv(struct rpc_request *req) return; } - if (r->out.level != 1) { + if (*r->out.level_out != 1) { composite_error(c, NT_STATUS_INVALID_NETWORK_RESPONSE); return; } diff --git a/source4/librpc/config.mk b/source4/librpc/config.mk index a4eaae4367..819b79f91f 100644 --- a/source4/librpc/config.mk +++ b/source4/librpc/config.mk @@ -139,12 +139,12 @@ NDR_FRSAPI_OBJ_FILES = $(gen_ndrsrcdir)/ndr_frsapi.o [SUBSYSTEM::NDR_DRSUAPI] PUBLIC_DEPENDENCIES = LIBNDR NDR_COMPRESSION NDR_SECURITY NDR_SAMR ASN1_UTIL -NDR_DRSUAPI_OBJ_FILES = $(gen_ndrsrcdir)/ndr_drsuapi.o $(ndrsrcdir)/ndr_drsuapi.o +NDR_DRSUAPI_OBJ_FILES = $(gen_ndrsrcdir)/ndr_drsuapi.o ../librpc/ndr/ndr_drsuapi.o [SUBSYSTEM::NDR_DRSBLOBS] PUBLIC_DEPENDENCIES = LIBNDR NDR_MISC NDR_DRSUAPI -NDR_DRSBLOBS_OBJ_FILES = $(gen_ndrsrcdir)/ndr_drsblobs.o $(ndrsrcdir)/ndr_drsblobs.o +NDR_DRSBLOBS_OBJ_FILES = $(gen_ndrsrcdir)/ndr_drsblobs.o ../librpc/ndr/ndr_drsblobs.o [SUBSYSTEM::NDR_SASL_HELPERS] PUBLIC_DEPENDENCIES = LIBNDR diff --git a/source4/librpc/idl/drsblobs.idl b/source4/librpc/idl/drsblobs.idl deleted file mode 100644 index 087f0c982d..0000000000 --- a/source4/librpc/idl/drsblobs.idl +++ /dev/null @@ -1,521 +0,0 @@ -#include "idl_types.h" - -import "drsuapi.idl", "misc.idl", "samr.idl", "lsa.idl"; - -[ - uuid("12345778-1234-abcd-0001-00000001"), - version(0.0), - pointer_default(unique), - helpstring("Active Directory Replication LDAP Blobs") -] -interface drsblobs { - typedef bitmap drsuapi_DsReplicaSyncOptions drsuapi_DsReplicaSyncOptions; - typedef bitmap drsuapi_DsReplicaNeighbourFlags drsuapi_DsReplicaNeighbourFlags; - typedef [v1_enum] enum drsuapi_DsAttributeId drsuapi_DsAttributeId; - typedef [v1_enum] enum lsa_TrustAuthType lsa_TrustAuthType; - /* - * replPropertyMetaData - * w2k uses version 1 - * w2k3 uses version 1 - */ - typedef struct { - drsuapi_DsAttributeId attid; - uint32 version; - NTTIME_1sec originating_change_time; - GUID originating_invocation_id; - hyper originating_usn; - hyper local_usn; - } replPropertyMetaData1; - - typedef struct { - uint32 count; - uint32 reserved; - replPropertyMetaData1 array[count]; - } replPropertyMetaDataCtr1; - - typedef [nodiscriminant] union { - [case(1)] replPropertyMetaDataCtr1 ctr1; - } replPropertyMetaDataCtr; - - typedef [public] struct { - uint32 version; - uint32 reserved; - [switch_is(version)] replPropertyMetaDataCtr ctr; - } replPropertyMetaDataBlob; - - void decode_replPropertyMetaData( - [in] replPropertyMetaDataBlob blob - ); - - /* - * replUpToDateVector - * w2k uses version 1 - * w2k3 uses version 2 - */ - typedef struct { - uint32 count; - uint32 reserved; - drsuapi_DsReplicaCursor cursors[count]; - } replUpToDateVectorCtr1; - - typedef struct { - uint32 count; - uint32 reserved; - drsuapi_DsReplicaCursor2 cursors[count]; - } replUpToDateVectorCtr2; - - typedef [nodiscriminant] union { - [case(1)] replUpToDateVectorCtr1 ctr1; - [case(2)] replUpToDateVectorCtr2 ctr2; - } replUpToDateVectorCtr; - - typedef [public] struct { - uint32 version; - uint32 reserved; - [switch_is(version)] replUpToDateVectorCtr ctr; - } replUpToDateVectorBlob; - - void decode_replUpToDateVector( - [in] replUpToDateVectorBlob blob - ); - - /* - * repsFrom/repsTo - * w2k uses version 1 - * w2k3 uses version 1 - */ - typedef [public,gensize] struct { - [value(strlen(dns_name)+1)] uint32 __dns_name_size; - [charset(DOS)] uint8 dns_name[__dns_name_size]; - } repsFromTo1OtherInfo; - - typedef [public,gensize,flag(NDR_PAHEX)] struct { - /* this includes the 8 bytes of the repsFromToBlob header */ - [value(ndr_size_repsFromTo1(this, ndr->flags)+8)] uint32 blobsize; - uint32 consecutive_sync_failures; - NTTIME_1sec last_success; - NTTIME_1sec last_attempt; - WERROR result_last_attempt; - [relative] repsFromTo1OtherInfo *other_info; - [value(ndr_size_repsFromTo1OtherInfo(other_info, ndr->flags))] uint32 other_info_length; - drsuapi_DsReplicaNeighbourFlags replica_flags; - uint8 schedule[84]; - uint32 reserved; - drsuapi_DsReplicaHighWaterMark highwatermark; - GUID source_dsa_obj_guid; /* the 'objectGuid' field of the CN=NTDS Settings object */ - GUID source_dsa_invocation_id; /* the 'invocationId' field of the CN=NTDS Settings object */ - GUID transport_guid; - } repsFromTo1; - - typedef [nodiscriminant] union { - [case(1)] repsFromTo1 ctr1; - } repsFromTo; - - typedef [public] struct { - uint32 version; - uint32 reserved; - [switch_is(version)] repsFromTo ctr; - } repsFromToBlob; - - void decode_repsFromTo( - [in] repsFromToBlob blob - ); - - /* - * partialAttributeSet - * w2k uses version 1 - * w2k3 uses version 1 - */ - typedef struct { - uint32 count; - drsuapi_DsAttributeId array[count]; - } partialAttributeSetCtr1; - - typedef [nodiscriminant] union { - [case(1)] partialAttributeSetCtr1 ctr1; - } partialAttributeSetCtr; - - typedef [public] struct { - uint32 version; - uint32 reserved; - [switch_is(version)] partialAttributeSetCtr ctr; - } partialAttributeSetBlob; - - void decode_partialAttributeSet( - [in] partialAttributeSetBlob blob - ); - - /* - * prefixMap - * w2k unknown - * w2k3 unknown - * samba4 uses 0x44534442 'DSDB' - * - * as we windows don't return the prefixMap attribute when you ask for - * we don't know the format, but the attribute is not replicated - * so that we can choose our own format... - */ - typedef [v1_enum] enum { - PREFIX_MAP_VERSION_DSDB = 0x44534442 - } prefixMapVersion; - - typedef [nodiscriminant] union { - [case(PREFIX_MAP_VERSION_DSDB)] drsuapi_DsReplicaOIDMapping_Ctr dsdb; - } prefixMapCtr; - - typedef [public] struct { - prefixMapVersion version; - uint32 reserved; - [switch_is(version)] prefixMapCtr ctr; - } prefixMapBlob; - - void decode_prefixMap( - [in] prefixMapBlob blob - ); - - /* - * the cookie for the LDAP dirsync control - */ - typedef [nodiscriminant,gensize] union { - [case(0)]; - [default] replUpToDateVectorBlob uptodateness_vector; - } ldapControlDirSyncExtra; - - typedef struct { - [value(3)] uint32 u1; - NTTIME time; - uint32 u2; - uint32 u3; - [value(ndr_size_ldapControlDirSyncExtra(&extra, extra.uptodateness_vector.version, 0))] - uint32 extra_length; - drsuapi_DsReplicaHighWaterMark highwatermark; - GUID guid1; - [switch_is(extra_length)] ldapControlDirSyncExtra extra; - } ldapControlDirSyncBlob; - - typedef [public,relative_base] struct { - [charset(DOS),value("MSDS")] uint8 msds[4]; - [subcontext(0)] ldapControlDirSyncBlob blob; - } ldapControlDirSyncCookie; - - void decode_ldapControlDirSync( - [in] ldapControlDirSyncCookie cookie - ); - - typedef struct { - [value(2*strlen_m(name))] uint16 name_len; - [value(strlen(data))] uint16 data_len; - uint16 reserved; /* 2 for 'Packages', 1 for 'Primary:*', but should be ignored */ - [charset(UTF16)] uint8 name[name_len]; - /* - * the data field contains data as HEX strings - * - * 'Packages': - * data contains the list of packages - * as non termiated UTF16 strings with - * a UTF16 NULL byte as separator - * - * 'Primary:Kerberos-Newer-Keys': - * ... - * - * 'Primary:Kerberos': - * ... - * - * 'Primary:WDigest': - * ... - * - * 'Primary:CLEARTEXT': - * data contains the cleartext password - * as UTF16 string encoded as HEX string - */ - [charset(DOS)] uint8 data[data_len]; - } supplementalCredentialsPackage; - - /* this are 0x30 (48) whitespaces (0x20) */ - const string SUPPLEMENTAL_CREDENTIALS_PREFIX = " "; - - typedef [flag(NDR_PAHEX)] enum { - SUPPLEMENTAL_CREDENTIALS_SIGNATURE = 0x0050 - } supplementalCredentialsSignature; - - typedef [gensize] struct { - [value(SUPPLEMENTAL_CREDENTIALS_PREFIX),charset(UTF16)] uint16 prefix[0x30]; - [value(SUPPLEMENTAL_CREDENTIALS_SIGNATURE)] supplementalCredentialsSignature signature; - uint16 num_packages; - supplementalCredentialsPackage packages[num_packages]; - } supplementalCredentialsSubBlob; - - typedef [public] struct { - [value(0)] uint32 unknown1; - [value(ndr_size_supplementalCredentialsSubBlob(&sub, ndr->flags))] uint32 __ndr_size; - [value(0)] uint32 unknown2; - [subcontext(0),subcontext_size(__ndr_size)] supplementalCredentialsSubBlob sub; - [value(0)] uint8 unknown3; - } supplementalCredentialsBlob; - - void decode_supplementalCredentials( - [in] supplementalCredentialsBlob blob - ); - - typedef [public] struct { - [flag(STR_NOTERM|NDR_REMAINING)] string_array names; - } package_PackagesBlob; - - void decode_Packages( - [in] package_PackagesBlob blob - ); - - typedef struct { - [value(2*strlen_m(string))] uint16 length; - [value(2*strlen_m(string))] uint16 size; - [relative,subcontext(0),subcontext_size(size),flag(STR_NOTERM|NDR_REMAINING)] string *string; - } package_PrimaryKerberosString; - - typedef struct { - [value(0)] uint16 reserved1; - [value(0)] uint16 reserved2; - [value(0)] uint32 reserved3; - uint32 keytype; - [value((value?value->length:0))] uint32 value_len; - [relative,subcontext(0),subcontext_size(value_len),flag(NDR_REMAINING)] DATA_BLOB *value; - } package_PrimaryKerberosKey3; - - typedef struct { - uint16 num_keys; - uint16 num_old_keys; - package_PrimaryKerberosString salt; - package_PrimaryKerberosKey3 keys[num_keys]; - package_PrimaryKerberosKey3 old_keys[num_old_keys]; - [value(0)] uint32 padding1; - [value(0)] uint32 padding2; - [value(0)] uint32 padding3; - [value(0)] uint32 padding4; - [value(0)] uint32 padding5; - } package_PrimaryKerberosCtr3; - - typedef struct { - [value(0)] uint16 reserved1; - [value(0)] uint16 reserved2; - [value(0)] uint32 reserved3; - uint32 iteration_count; - uint32 keytype; - [value((value?value->length:0))] uint32 value_len; - [relative,subcontext(0),subcontext_size(value_len),flag(NDR_REMAINING)] DATA_BLOB *value; - } package_PrimaryKerberosKey4; - - typedef struct { - uint16 num_keys; - [value(0)] uint16 num_service_keys; - uint16 num_old_keys; - uint16 num_older_keys; - package_PrimaryKerberosString salt; - uint32 default_iteration_count; - package_PrimaryKerberosKey4 keys[num_keys]; - package_PrimaryKerberosKey4 service_keys[num_service_keys]; - package_PrimaryKerberosKey4 old_keys[num_old_keys]; - package_PrimaryKerberosKey4 older_keys[num_older_keys]; - } package_PrimaryKerberosCtr4; - - typedef [nodiscriminant] union { - [case(3)] package_PrimaryKerberosCtr3 ctr3; - [case(4)] package_PrimaryKerberosCtr4 ctr4; - } package_PrimaryKerberosCtr; - - typedef [public] struct { - uint16 version; - [value(0)] uint16 flags; - [switch_is(version)] package_PrimaryKerberosCtr ctr; - } package_PrimaryKerberosBlob; - - void decode_PrimaryKerberos( - [in] package_PrimaryKerberosBlob blob - ); - - typedef [public] struct { - [flag(NDR_REMAINING)] DATA_BLOB cleartext; - } package_PrimaryCLEARTEXTBlob; - - void decode_PrimaryCLEARTEXT( - [in] package_PrimaryCLEARTEXTBlob blob - ); - - typedef [flag(NDR_PAHEX)] struct { - uint8 hash[16]; - } package_PrimaryWDigestHash; - - typedef [public] struct { - [value(0x31)] uint16 unknown1; - [value(0x01)] uint8 unknown2; - uint8 num_hashes; - [value(0)] uint32 unknown3; - [value(0)] udlong uuknown4; - package_PrimaryWDigestHash hashes[num_hashes]; - } package_PrimaryWDigestBlob; - - void decode_PrimaryWDigest( - [in] package_PrimaryWDigestBlob blob - ); - - typedef struct { - [value(0)] uint32 size; - } AuthInfoNone; - - typedef struct { - [value(16)] uint32 size; - samr_Password password; - } AuthInfoNT4Owf; - - /* - * the secret value is encoded as UTF16 if it's a string - * but depending the AuthType, it might also be krb5 trusts have random bytes here, so converting to UTF16 - * mayfail... - * - * TODO: We should try handle the case of a random buffer in all places - * we deal with cleartext passwords from windows - * - * so we don't use this: - * - * uint32 value_len; - * [charset(UTF16)] uint8 value[value_len]; - */ - - typedef struct { - uint32 size; - uint8 password[size]; - } AuthInfoClear; - - typedef struct { - [value(4)] uint32 size; - uint32 version; - } AuthInfoVersion; - - typedef [nodiscriminant] union { - [case(TRUST_AUTH_TYPE_NONE)] AuthInfoNone none; - [case(TRUST_AUTH_TYPE_NT4OWF)] AuthInfoNT4Owf nt4owf; - [case(TRUST_AUTH_TYPE_CLEAR)] AuthInfoClear clear; - [case(TRUST_AUTH_TYPE_VERSION)] AuthInfoVersion version; - } AuthInfo; - - typedef [public] struct { - NTTIME LastUpdateTime; - lsa_TrustAuthType AuthType; - - [switch_is(AuthType)] AuthInfo AuthInfo; - [flag(NDR_ALIGN4)] DATA_BLOB _pad; - } AuthenticationInformation; - - typedef [nopull,nopush,noprint] struct { - /* sizeis here is bogus, but this is here just for the structure */ - [size_is(1)] AuthenticationInformation array[]; - } AuthenticationInformationArray; - - /* This is nopull,nopush because we pass count down to the - * manual parser of AuthenticationInformationArray */ - typedef [public,nopull,nopush,noprint,gensize] struct { - uint32 count; - [relative] AuthenticationInformationArray *current; - [relative] AuthenticationInformationArray *previous; - } trustAuthInOutBlob; - - void decode_trustAuthInOut( - [in] trustAuthInOutBlob blob - ); - - typedef [public,gensize] struct { - uint32 count; - [relative] AuthenticationInformation *current[count]; - } trustCurrentPasswords; - - typedef [public,nopull] struct { - uint8 confounder[512]; - [subcontext(0),subcontext_size(outgoing_size)] trustCurrentPasswords outgoing; - [subcontext(0),subcontext_size(incoming_size)] trustCurrentPasswords incoming; - [value(ndr_size_trustCurrentPasswords(&outgoing, ndr->flags))] uint32 outgoing_size; - [value(ndr_size_trustCurrentPasswords(&incoming, ndr->flags))] uint32 incoming_size; - } trustDomainPasswords; - - void decode_trustDomainPasswords( - [in] trustDomainPasswords blob - ); - - typedef [public] struct { - uint32 marker; - DATA_BLOB data; - } DsCompressedChunk; - - typedef struct { - uint16 __size; - [size_is(__size),charset(DOS)] uint8 *string; - } ExtendedErrorAString; - - typedef struct { - uint16 __size; - [size_is(__size),charset(UTF16)] uint16 *string; - } ExtendedErrorUString; - - typedef struct { - uint16 length; - [size_is(length)] uint8 *data; - } ExtendedErrorBlob; - - typedef enum { - EXTENDED_ERROR_COMPUTER_NAME_PRESENT = 1, - EXTENDED_ERROR_COMPUTER_NAME_NOT_PRESENT= 2 - } ExtendedErrorComputerNamePresent; - - typedef [switch_type(ExtendedErrorComputerNamePresent)] union { - [case(EXTENDED_ERROR_COMPUTER_NAME_PRESENT)] ExtendedErrorUString name; - [case(EXTENDED_ERROR_COMPUTER_NAME_NOT_PRESENT)]; - } ExtendedErrorComputerNameU; - - typedef struct { - ExtendedErrorComputerNamePresent present; - [switch_is(present)] ExtendedErrorComputerNameU n; - } ExtendedErrorComputerName; - - typedef enum { - EXTENDED_ERROR_PARAM_TYPE_ASCII_STRING = 1, - EXTENDED_ERROR_PARAM_TYPE_UNICODE_STRING = 2, - EXTENDED_ERROR_PARAM_TYPE_UINT32 = 3, - EXTENDED_ERROR_PARAM_TYPE_UINT16 = 4, - EXTENDED_ERROR_PARAM_TYPE_UINT64 = 5, - EXTENDED_ERROR_PARAM_TYPE_NONE = 6, - EXTENDED_ERROR_PARAM_TYPE_BLOB = 7 - } ExtendedErrorParamType; - - typedef [switch_type(ExtendedErrorParamType)] union { - [case(EXTENDED_ERROR_PARAM_TYPE_ASCII_STRING)] ExtendedErrorAString a_string; - [case(EXTENDED_ERROR_PARAM_TYPE_UNICODE_STRING)] ExtendedErrorUString u_string; - [case(EXTENDED_ERROR_PARAM_TYPE_UINT32)] uint32 uint32; - [case(EXTENDED_ERROR_PARAM_TYPE_UINT16)] uint16 uint16; - [case(EXTENDED_ERROR_PARAM_TYPE_UINT64)] hyper uint64; - [case(EXTENDED_ERROR_PARAM_TYPE_NONE)]; - [case(EXTENDED_ERROR_PARAM_TYPE_BLOB)] ExtendedErrorBlob blob; - } ExtendedErrorParamU; - - typedef struct { - ExtendedErrorParamType type; - [switch_is(type)] ExtendedErrorParamU p; - } ExtendedErrorParam; - - typedef [public] struct { - ExtendedErrorInfo *next; - ExtendedErrorComputerName computer_name; - hyper pid; - NTTIME time; - uint32 generating_component; - WERROR status; - uint16 detection_location; - uint16 flags; - uint16 num_params; - [size_is(num_params)] ExtendedErrorParam params[]; - } ExtendedErrorInfo; - - typedef struct { - [unique] ExtendedErrorInfo *info; - } ExtendedErrorInfoPtr; - - void decode_ExtendedErrorInfo ( - [in,subcontext(0xFFFFFC01)] ExtendedErrorInfoPtr ptr - ); -} diff --git a/source4/librpc/idl/drsuapi.idl b/source4/librpc/idl/drsuapi.idl deleted file mode 100644 index f89d9e1f39..0000000000 --- a/source4/librpc/idl/drsuapi.idl +++ /dev/null @@ -1,1597 +0,0 @@ -#include "idl_types.h" - -import "security.idl", "misc.idl", "samr.idl"; - -[ - uuid("e3514235-4b06-11d1-ab04-00c04fc2dcd2"), - version(4.0), - endpoint("ncacn_np:[\\pipe\\lsass]","ncacn_np:[\\pipe\\protected_storage]", "ncacn_ip_tcp:", "ncalrpc:"), - authservice("ldap"), - helpstring("Active Directory Replication"), - helper("librpc/ndr/ndr_drsuapi.h"), - pointer_default(unique) -] -interface drsuapi -{ - typedef bitmap samr_GroupAttrs samr_GroupAttrs; - - /*****************/ - /* Function 0x00 */ - typedef [bitmap32bit] bitmap { - DRSUAPI_SUPPORTED_EXTENSION_BASE = 0x00000001, - DRSUAPI_SUPPORTED_EXTENSION_ASYNC_REPLICATION = 0x00000002, - DRSUAPI_SUPPORTED_EXTENSION_REMOVEAPI = 0x00000004, - DRSUAPI_SUPPORTED_EXTENSION_MOVEREQ_V2 = 0x00000008, - DRSUAPI_SUPPORTED_EXTENSION_GETCHG_COMPRESS = 0x00000010, - DRSUAPI_SUPPORTED_EXTENSION_DCINFO_V1 = 0x00000020, - DRSUAPI_SUPPORTED_EXTENSION_RESTORE_USN_OPTIMIZATION = 0x00000040, - DRSUAPI_SUPPORTED_EXTENSION_00000080 = 0x00000080, - DRSUAPI_SUPPORTED_EXTENSION_KCC_EXECUTE = 0x00000100, - DRSUAPI_SUPPORTED_EXTENSION_ADDENTRY_V2 = 0x00000200, - DRSUAPI_SUPPORTED_EXTENSION_LINKED_VALUE_REPLICATION = 0x00000400, - DRSUAPI_SUPPORTED_EXTENSION_DCINFO_V2 = 0x00000800, - DRSUAPI_SUPPORTED_EXTENSION_INSTANCE_TYPE_NOT_REQ_ON_MOD= 0x00001000, - DRSUAPI_SUPPORTED_EXTENSION_CRYPTO_BIND = 0x00002000, - DRSUAPI_SUPPORTED_EXTENSION_GET_REPL_INFO = 0x00004000, - DRSUAPI_SUPPORTED_EXTENSION_STRONG_ENCRYPTION = 0x00008000, - DRSUAPI_SUPPORTED_EXTENSION_DCINFO_V01 = 0x00010000, - DRSUAPI_SUPPORTED_EXTENSION_TRANSITIVE_MEMBERSHIP = 0x00020000, - DRSUAPI_SUPPORTED_EXTENSION_ADD_SID_HISTORY = 0x00040000, - DRSUAPI_SUPPORTED_EXTENSION_POST_BETA3 = 0x00080000, - DRSUAPI_SUPPORTED_EXTENSION_00100000 = 0x00100000, - DRSUAPI_SUPPORTED_EXTENSION_GET_MEMBERSHIPS2 = 0x00200000, - DRSUAPI_SUPPORTED_EXTENSION_GETCHGREQ_V6 = 0x00400000, - DRSUAPI_SUPPORTED_EXTENSION_NONDOMAIN_NCS = 0x00800000, - DRSUAPI_SUPPORTED_EXTENSION_GETCHGREQ_V8 = 0x01000000, - DRSUAPI_SUPPORTED_EXTENSION_GETCHGREPLY_V5 = 0x02000000, - DRSUAPI_SUPPORTED_EXTENSION_GETCHGREPLY_V6 = 0x04000000, - /* - * the following 3 have the same value - * repadmin.exe /bind says that - */ - DRSUAPI_SUPPORTED_EXTENSION_ADDENTRYREPLY_V3 = 0x08000000, - DRSUAPI_SUPPORTED_EXTENSION_GETCHGREPLY_V7 = 0x08000000, - DRSUAPI_SUPPORTED_EXTENSION_VERIFY_OBJECT = 0x08000000, - DRSUAPI_SUPPORTED_EXTENSION_XPRESS_COMPRESS = 0x10000000, - DRSUAPI_SUPPORTED_EXTENSION_20000000 = 0x20000000, - DRSUAPI_SUPPORTED_EXTENSION_40000000 = 0x40000000, - DRSUAPI_SUPPORTED_EXTENSION_80000000 = 0x80000000 - } drsuapi_SupportedExtensions; - - typedef [bitmap32bit] bitmap { - DRSUAPI_SUPPORTED_EXTENSION_ADAM = 0x00000001, - DRSUAPI_SUPPORTED_EXTENSION_LH_BETA2 = 0x00000002 - } drsuapi_SupportedExtensionsExt; - - /* this is used by w2k */ - typedef struct { - drsuapi_SupportedExtensions supported_extensions; - GUID site_guid; - uint32 pid; - } drsuapi_DsBindInfo24; - - /* this is used by w2k3 */ - typedef struct { - drsuapi_SupportedExtensions supported_extensions; - GUID site_guid; - uint32 pid; - uint32 repl_epoch; - } drsuapi_DsBindInfo28; - - /* this is used by w2k8 */ - typedef struct { - drsuapi_SupportedExtensions supported_extensions; - GUID site_guid; - uint32 pid; - uint32 repl_epoch; - drsuapi_SupportedExtensionsExt supported_extensions_ext; - GUID config_dn_guid; - } drsuapi_DsBindInfo48; - - typedef struct { - [flag(NDR_REMAINING)] DATA_BLOB info; - } drsuapi_DsBindInfoFallBack; - - typedef [nodiscriminant] union { - [case(24)][subcontext(4)] drsuapi_DsBindInfo24 info24; - [case(28)][subcontext(4)] drsuapi_DsBindInfo28 info28; - [case(48)][subcontext(4)] drsuapi_DsBindInfo48 info48; - [default][subcontext(4)] drsuapi_DsBindInfoFallBack FallBack; - } drsuapi_DsBindInfo; - - /* the drsuapi_DsBindInfoCtr was this before - * typedef [flag(NDR_PAHEX)] struct { - * [range(1,10000)] uint32 length; - * [size_is(length)] uint8 data[]; - * } drsuapi_DsBindInfo; - * - * but we don't want the caller to manually decode this blob, - * so we're doing it here - */ - - typedef struct { - [range(1,10000)] uint32 length; - [switch_is(length)] drsuapi_DsBindInfo info; - } drsuapi_DsBindInfoCtr; - - /* this is a magic guid you need to pass to DsBind to make drsuapi_DsWriteAccountSpn() work - * - * maybe the bind_guid could also be the invocation_id see drsuapi_DsReplicaConnection04 - */ - const char *DRSUAPI_DS_BIND_GUID = "e24d201a-4fd6-11d1-a3da-0000f875ae0d"; - /* - * this magic guid are needed to fetch the whole tree with drsuapi_DsGetNCChanges() - * as administrator and this values are also used in the destination_dsa_guid field - * of drsuapi_DsGetNCChangesReq5/8 and the source_dsa_guid is zero. - */ - const char *DRSUAPI_DS_BIND_GUID_W2K = "6abec3d1-3054-41c8-a362-5a0c5b7d5d71"; - const char *DRSUAPI_DS_BIND_GUID_W2K3 = "6afab99c-6e26-464a-975f-f58f105218bc"; - - [public] WERROR drsuapi_DsBind( - [in,unique] GUID *bind_guid, - [in,out,unique] drsuapi_DsBindInfoCtr *bind_info, - [out] policy_handle *bind_handle - ); - - /*****************/ - /* Function 0x01 */ - WERROR drsuapi_DsUnbind( - [in,out] policy_handle *bind_handle - ); - - /*****************/ - /* Function 0x02 */ - typedef [public,gensize] struct { - [value(ndr_size_drsuapi_DsReplicaObjectIdentifier(r, ndr->flags)-4)] uint32 __ndr_size; - [value(ndr_size_dom_sid28(&sid, ndr->flags))] uint32 __ndr_size_sid; - GUID guid; - dom_sid28 sid; - [value(strlen_m(dn))] uint32 __ndr_size_dn; - [charset(UTF16),size_is(__ndr_size_dn+1)] uint16 dn[]; - } drsuapi_DsReplicaObjectIdentifier; - - typedef [public] bitmap { - DRSUAPI_DS_REPLICA_SYNC_ASYNCHRONOUS_OPERATION = 0x00000001, - DRSUAPI_DS_REPLICA_SYNC_WRITEABLE = 0x00000002, - DRSUAPI_DS_REPLICA_SYNC_PERIODIC = 0x00000004, - DRSUAPI_DS_REPLICA_SYNC_INTERSITE_MESSAGING = 0x00000008, - DRSUAPI_DS_REPLICA_SYNC_ALL_SOURCES = 0x00000010, - DRSUAPI_DS_REPLICA_SYNC_FULL = 0x00000020, - DRSUAPI_DS_REPLICA_SYNC_URGENT = 0x00000040, - DRSUAPI_DS_REPLICA_SYNC_NO_DISCARD = 0x00000080, - DRSUAPI_DS_REPLICA_SYNC_FORCE = 0x00000100, - DRSUAPI_DS_REPLICA_SYNC_ADD_REFERENCE = 0x00000200, - DRSUAPI_DS_REPLICA_SYNC_NEVER_COMPLETED = 0x00000400, - DRSUAPI_DS_REPLICA_SYNC_TWO_WAY = 0x00000800, - DRSUAPI_DS_REPLICA_SYNC_NEVER_NOTIFY = 0x00001000, - DRSUAPI_DS_REPLICA_SYNC_INITIAL = 0x00002000, - DRSUAPI_DS_REPLICA_SYNC_USE_COMPRESSION = 0x00004000, - DRSUAPI_DS_REPLICA_SYNC_ABANDONED = 0x00008000, - DRSUAPI_DS_REPLICA_SYNC_INITIAL_IN_PROGRESS = 0x00010000, - DRSUAPI_DS_REPLICA_SYNC_PARTIAL_ATTRIBUTE_SET = 0x00020000, - DRSUAPI_DS_REPLICA_SYNC_REQUEUE = 0x00040000, - DRSUAPI_DS_REPLICA_SYNC_NOTIFICATION = 0x00080000, - DRSUAPI_DS_REPLICA_SYNC_ASYNCHRONOUS_REPLICA = 0x00100000, - DRSUAPI_DS_REPLICA_SYNC_CRITICAL = 0x00200000, - DRSUAPI_DS_REPLICA_SYNC_FULL_IN_PROGRESS = 0x00400000, - DRSUAPI_DS_REPLICA_SYNC_PREEMPTED = 0x00800000 - } drsuapi_DsReplicaSyncOptions; - - typedef struct { - drsuapi_DsReplicaObjectIdentifier *naming_context; - GUID source_dsa_guid; - astring *other_info; /* I assume this is related to the repsFromTo1OtherInfo dns_name */ - drsuapi_DsReplicaSyncOptions options; - } drsuapi_DsReplicaSyncRequest1; - - typedef [switch_type(int32)] union { - [case(1)] drsuapi_DsReplicaSyncRequest1 req1; - } drsuapi_DsReplicaSyncRequest; - - WERROR drsuapi_DsReplicaSync( - [in] policy_handle *bind_handle, - [in] int32 level, - [in,switch_is(level)] drsuapi_DsReplicaSyncRequest req - ); - - /*****************/ - /* Function 0x03 */ - typedef [public] struct { - hyper tmp_highest_usn; /* updated after each object update */ - hyper reserved_usn; - hyper highest_usn; /* updated after a full replication cycle */ - } drsuapi_DsReplicaHighWaterMark; - - typedef [public] struct { - GUID source_dsa_invocation_id; /* the 'invocationId' field of the CN=NTDS Settings object */ - hyper highest_usn; /* updated after a full replication cycle */ - } drsuapi_DsReplicaCursor; - - typedef struct { - [value(1)] uint32 version; - [value(0)] uint32 reserved1; - [range(0,0x100000)] uint32 count; - [value(0)] uint32 reserved2; - [size_is(count)] drsuapi_DsReplicaCursor cursors[]; - } drsuapi_DsReplicaCursorCtrEx; - - typedef [public] bitmap { - /* the _WRITEABLE flag indicates a replication with all attributes - * - * --metze - */ - DRSUAPI_DS_REPLICA_NEIGHBOUR_WRITEABLE = 0x00000010, - DRSUAPI_DS_REPLICA_NEIGHBOUR_SYNC_ON_STARTUP = 0x00000020, - DRSUAPI_DS_REPLICA_NEIGHBOUR_DO_SCHEDULED_SYNCS = 0x00000040, - DRSUAPI_DS_REPLICA_NEIGHBOUR_USE_ASYNC_INTERSIDE_TRANSPORT = 0x00000080, - DRSUAPI_DS_REPLICA_NEIGHBOUR_TWO_WAY_SYNC = 0x00000200, - DRSUAPI_DS_REPLICA_NEIGHBOUR_RETURN_OBJECT_PARENTS = 0x00000800, - DRSUAPI_DS_REPLICA_NEIGHBOUR_FULL_IN_PROGRESS = 0x00001000, /* was 0x00010000, */ - DRSUAPI_DS_REPLICA_NEIGHBOUR_FULL_NEXT_PACKET = 0x00002000, /* was 0x00020000, */ - DRSUAPI_DS_REPLICA_NEIGHBOUR_NEVER_SYNCED = 0x00200000, - DRSUAPI_DS_REPLICA_NEIGHBOUR_PREEMPTED = 0x01000000, - DRSUAPI_DS_REPLICA_NEIGHBOUR_IGNORE_CHANGE_NOTIFICATIONS = 0x04000000, - DRSUAPI_DS_REPLICA_NEIGHBOUR_DISABLE_SCHEDULED_SYNC = 0x08000000, - /* - * the following NOTE applies to DsGetNCChangesRequest5: - * - the data is only compressed when 10 or more objects are replicated - * - but there could also be a size limit of 35 KBytes or something like that - * - the reply is DsGetNCChangesCtr2 - * - maybe the same applies to DsGetNCChangesRequest8... - * - * --metze - */ - DRSUAPI_DS_REPLICA_NEIGHBOUR_COMPRESS_CHANGES = 0x10000000, - DRSUAPI_DS_REPLICA_NEIGHBOUR_NO_CHANGE_NOTIFICATIONS = 0x20000000, - DRSUAPI_DS_REPLICA_NEIGHBOUR_PARTIAL_ATTRIBUTE_SET = 0x40000000 - } drsuapi_DsReplicaNeighbourFlags; - - typedef [flag(NDR_PAHEX),v1_enum] enum { - DRSUAPI_EXOP_NONE = 0x00000000, - DRSUAPI_EXOP_FSMO_REQ_ROLE = 0x00000001, - DRSUAPI_EXOP_FSMO_RID_ALLOC = 0x00000002, - DRSUAPI_EXOP_FSMO_RID_REQ_ROLE = 0x00000003, - DRSUAPI_EXOP_FSMO_REQ_PDC = 0x00000004, - DRSUAPI_EXOP_FSMO_ABANDON_ROLE = 0x00000005, - DRSUAPI_EXOP_REPL_OBJ = 0x00000006, - DRSUAPI_EXOP_REPL_SECRET = 0x00000007 - } drsuapi_DsExtendedOperation; - - typedef [flag(NDR_PAHEX),v1_enum] enum { - DRSUAPI_EXOP_ERR_NONE = 0x00000000, - DRSUAPI_EXOP_ERR_SUCCESS = 0x00000001, - DRSUAPI_EXOP_ERR_UNKNOWN_OP = 0x00000002, - DRSUAPI_EXOP_ERR_FSMO_NOT_OWNER = 0x00000003, - DRSUAPI_EXOP_ERR_UPDATE_ERR = 0x00000004, - DRSUAPI_EXOP_ERR_EXCEPTION = 0x00000005, - DRSUAPI_EXOP_ERR_UNKNOWN_CALLER = 0x00000006, - DRSUAPI_EXOP_ERR_RID_ALLOC = 0x00000007, - DRSUAPI_EXOP_ERR_FSMO_OWNER_DELETED = 0x00000008, - DRSUAPI_EXOP_ERR_FMSO_PENDING_OP = 0x00000009, - DRSUAPI_EXOP_ERR_MISMATCH = 0x0000000A, - DRSUAPI_EXOP_ERR_COULDNT_CONTACT = 0x0000000B, - DRSUAPI_EXOP_ERR_FSMO_REFUSING_ROLES = 0x0000000C, - DRSUAPI_EXOP_ERR_DIR_ERROR = 0x0000000D, - DRSUAPI_EXOP_ERR_FSMO_MISSING_SETTINGS = 0x0000000E, - DRSUAPI_EXOP_ERR_ACCESS_DENIED = 0x0000000F, - DRSUAPI_EXOP_ERR_PARAM_ERROR = 0x00000010 - } drsuapi_DsExtendedError; - - typedef struct { - GUID destination_dsa_guid; - GUID source_dsa_invocation_id; /* the 'invocationId' field of the CN=NTDS Settings object */ - [ref] drsuapi_DsReplicaObjectIdentifier *naming_context; - drsuapi_DsReplicaHighWaterMark highwatermark; - drsuapi_DsReplicaCursorCtrEx *uptodateness_vector; - drsuapi_DsReplicaNeighbourFlags replica_flags; - uint32 max_object_count; /* w2k3 uses min(133,max(100,max_object_count)) */ - uint32 max_ndr_size; /* w2k3 seems to ignore this */ - drsuapi_DsExtendedOperation extended_op; - hyper fsmo_info; - } drsuapi_DsGetNCChangesRequest5; - - /* - * In DRSUAPI all attributes with syntax 2.5.5.2 - * are identified by uint32 values - * - * the following table shows the mapping used between the two representations - * e.g. - objectClass 'nTDSDSA' has governsID: 1.2.840.113556.1.5.7000.47 - * and a UINT32-ID of '0x0017002F'. - * - so the OID 1.2.840.113556.1.5.7000.47 is splitted into a - * OID-prefix: 1.2.840.113556.1.5.7000 - * and a value: 47 => 0x2F - * - the mapping table gives a UINT32-prefix: 0x00170000 - * - and the UINT32-ID is 0x0017002F = 0x00170000 | 0x2F - * - * This prefix mapping table is replied in the drsuapi_DsReplicaOIDMapping_Ctr - * array. The following are the default mappings of w2k3 - * - * OID-prefix => UINT32-Id prefix - * - * 2.5.4.* => 0x00000000 (standard attributes RFC2256 core.schema) - * 2.5.6.* => 0x00010000 (standard object classes RFC2256 core.schema) - * 1.2.840.113556.1.2.* => 0x00020000 - * 1.2.840.113556.1.3.* => 0x00030000 - * 2.5.5.* => 0x00080000 (attributeSyntax OID's) - * 1.2.840.113556.1.4.* => 0x00090000 - * 1.2.840.113556.1.5.* => 0x000A0000 - * 2.16.840.1.113730.3.* => 0x00140000 - * 0.9.2342.19200300.100.1.* => 0x00150000 - * 2.16.840.1.113730.3.1.* => 0x00160000 - * 1.2.840.113556.1.5.7000.* => 0x00170000 - * 2.5.21.* => 0x00180000 (attrs for SubSchema) - * 2.5.18.* => 0x00190000 (createTimeStamp,modifyTimeStamp, SubSchema) - * 2.5.20.* => 0x001A0000 - * 1.3.6.1.4.1.1466.101.119.* => 0x001B0000 (dynamicObject, entryTTL) - * 2.16.840.1.113730.3.2.* => 0x001C0000 - * 1.3.6.1.4.1.250.1.* => 0x001D0000 - * 1.2.840.113549.1.9.* => 0x001E0000 (unstructuredAddress,unstructuredName) - * 0.9.2342.19200300.100.4.* => 0x001F0000 - * - * Here's a list of used 'attributeSyntax' OID's - * - * 2.5.5.1 => Object(DS-DN) string - * struct drsuapi_DsObjectIdentifier3 - * - * 2.5.5.2 => OID-string - * => all values are represented as uint32 values in drsuapi - * => governsID, attributeID and attributeSyntax returned as OID-Strings in LDAP - * => mayContain, mustContain and all other attributes with 2.5.5.2 syntax - * are returned as attribute names - * - * 2.5.5.4 => String(Teletex) case-insensitive string with teletex charset - * - * 2.5.5.5 => String(IA5) case-sensitive string - * - * 2.5.5.6 => String(Numeric) - * => eg. internationalISDNNumber - * - * 2.5.5.7 => Object(DN-Binary) B:<byte count>:<bytes>:<object DN> - * => e.g. wellKnownObjects - * - * 2.5.5.8 => BOOL - * - * 2.5.5.9 => int32 - * - * 2.5.5.10 => DATA_BLOB - * => struct GUID - * - * 2.5.5.11 => LDAP timestring - * => NTTIME_1sec - * - * 2.5.5.12 => String(Unicode) case-insensitive string - * => 'standard strings' - * - * 2.5.5.13 => Object(Presentation-Address) string - * => used in objectClass applicationEntity - * - * 2.5.5.14 => Object(DN-String) S:<char count>:<string>:<object DN> - * => not used - * - * 2.5.5.15 => ntSecurityDescriptor - * - * 2.5.5.16 => int64 - * - * 2.5.5.17 => dom_sid - */ - typedef [nopush,nopull] struct { - [range(0,10000),value(ndr_size_drsuapi_DsReplicaOID_oid(oid, 0))] uint32 __ndr_size; - [size_is(__ndr_size),charset(DOS)] uint8 *oid; /* it's encoded with asn1_write_OID_String() */ - } drsuapi_DsReplicaOID; - - typedef struct { - uint32 id_prefix; - drsuapi_DsReplicaOID oid; - } drsuapi_DsReplicaOIDMapping; - - typedef [public] struct { - [range(0,0x100000)] uint32 num_mappings; - [size_is(num_mappings)] drsuapi_DsReplicaOIDMapping *mappings; - } drsuapi_DsReplicaOIDMapping_Ctr; - - typedef [flag(NDR_PAHEX),v1_enum] enum { - DRSUAPI_OBJECTCLASS_top = 0x00010000, - DRSUAPI_OBJECTCLASS_classSchema = 0x0003000d, - DRSUAPI_OBJECTCLASS_attributeSchema = 0x0003000e - } drsuapi_DsObjectClassId; - - typedef [flag(NDR_PAHEX),v1_enum,public] enum { - DRSUAPI_ATTRIBUTE_objectClass = 0x00000000, - DRSUAPI_ATTRIBUTE_description = 0x0000000d, - DRSUAPI_ATTRIBUTE_member = 0x0000001f, - DRSUAPI_ATTRIBUTE_instanceType = 0x00020001, - DRSUAPI_ATTRIBUTE_whenCreated = 0x00020002, - DRSUAPI_ATTRIBUTE_hasMasterNCs = 0x0002000e, - DRSUAPI_ATTRIBUTE_governsID = 0x00020016, - DRSUAPI_ATTRIBUTE_attributeID = 0x0002001e, - DRSUAPI_ATTRIBUTE_attributeSyntax = 0x00020020, - DRSUAPI_ATTRIBUTE_isSingleValued = 0x00020021, - DRSUAPI_ATTRIBUTE_rangeLower = 0x00020022, - DRSUAPI_ATTRIBUTE_rangeUpper = 0x00020023, - DRSUAPI_ATTRIBUTE_dMDLocation = 0x00020024, - DRSUAPI_ATTRIBUTE_objectVersion = 0x0002004c, - DRSUAPI_ATTRIBUTE_invocationId = 0x00020073, - DRSUAPI_ATTRIBUTE_showInAdvancedViewOnly = 0x000200a9, - DRSUAPI_ATTRIBUTE_adminDisplayName = 0x000200c2, - DRSUAPI_ATTRIBUTE_adminDescription = 0x000200e2, - DRSUAPI_ATTRIBUTE_oMSyntax = 0x000200e7, - DRSUAPI_ATTRIBUTE_ntSecurityDescriptor = 0x00020119, - DRSUAPI_ATTRIBUTE_searchFlags = 0x0002014e, - DRSUAPI_ATTRIBUTE_lDAPDisplayName = 0x000201cc, - DRSUAPI_ATTRIBUTE_name = 0x00090001, - DRSUAPI_ATTRIBUTE_userAccountControl = 0x00090008, - DRSUAPI_ATTRIBUTE_currentValue = 0x0009001b, - DRSUAPI_ATTRIBUTE_homeDirectory = 0x0009002c, - DRSUAPI_ATTRIBUTE_homeDrive = 0x0009002d, - DRSUAPI_ATTRIBUTE_scriptPath = 0x0009003e, - DRSUAPI_ATTRIBUTE_profilePath = 0x0009008b, - DRSUAPI_ATTRIBUTE_objectSid = 0x00090092, - DRSUAPI_ATTRIBUTE_schemaIDGUID = 0x00090094, - DRSUAPI_ATTRIBUTE_dBCSPwd = 0x00090037,/* lmPwdHash */ - DRSUAPI_ATTRIBUTE_logonHours = 0x00090040, - DRSUAPI_ATTRIBUTE_userWorkstations = 0x00090056, - DRSUAPI_ATTRIBUTE_unicodePwd = 0x0009005a,/* ntPwdHash */ - DRSUAPI_ATTRIBUTE_ntPwdHistory = 0x0009005e, - DRSUAPI_ATTRIBUTE_priorValue = 0x00090064, - DRSUAPI_ATTRIBUTE_supplementalCredentials = 0x0009007d, - DRSUAPI_ATTRIBUTE_trustAuthIncoming = 0x00090081, - DRSUAPI_ATTRIBUTE_trustAuthOutgoing = 0x00090087, - DRSUAPI_ATTRIBUTE_lmPwdHistory = 0x000900a0, - DRSUAPI_ATTRIBUTE_sAMAccountName = 0x000900dd, - DRSUAPI_ATTRIBUTE_sAMAccountType = 0x0009012e, - DRSUAPI_ATTRIBUTE_fSMORoleOwner = 0x00090171, - DRSUAPI_ATTRIBUTE_systemFlags = 0x00090177, - DRSUAPI_ATTRIBUTE_serverReference = 0x00090203, - DRSUAPI_ATTRIBUTE_serverReferenceBL = 0x00090204, - DRSUAPI_ATTRIBUTE_initialAuthIncoming = 0x0009021b, - DRSUAPI_ATTRIBUTE_initialAuthOutgoing = 0x0009021c, - DRSUAPI_ATTRIBUTE_wellKnownObjects = 0x0009026a, - DRSUAPI_ATTRIBUTE_dNSHostName = 0x0009026b, - DRSUAPI_ATTRIBUTE_isMemberOfPartialAttributeSet = 0x0009027f, - DRSUAPI_ATTRIBUTE_userPrincipalName = 0x00090290, - DRSUAPI_ATTRIBUTE_groupType = 0x000902ee, - DRSUAPI_ATTRIBUTE_servicePrincipalName = 0x00090303, - DRSUAPI_ATTRIBUTE_objectCategory = 0x0009030e, - DRSUAPI_ATTRIBUTE_gPLink = 0x0009037b, - DRSUAPI_ATTRIBUTE_msDS_Behavior_Version = 0x000905b3, - DRSUAPI_ATTRIBUTE_msDS_KeyVersionNumber = 0x000906f6, - DRSUAPI_ATTRIBUTE_msDS_HasDomainNCs = 0x0009071c, - DRSUAPI_ATTRIBUTE_msDS_hasMasterNCs = 0x0009072c - } drsuapi_DsAttributeId; - - typedef struct { - [value(1)] uint32 version; - [value(0)] uint32 reserved1; - [range(1,0x100000)] uint32 num_attids; - [size_is(num_attids)] drsuapi_DsAttributeId attids[]; - } drsuapi_DsPartialAttributeSet; - - typedef struct { - GUID destination_dsa_guid; - GUID source_dsa_invocation_id; /* the 'invocationId' field of the CN=NTDS Settings object */ - [ref] drsuapi_DsReplicaObjectIdentifier *naming_context; - drsuapi_DsReplicaHighWaterMark highwatermark; - drsuapi_DsReplicaCursorCtrEx *uptodateness_vector; - drsuapi_DsReplicaNeighbourFlags replica_flags; - uint32 max_object_count; /* w2k3 uses min(133,max(100,max_object_count)) */ - uint32 max_ndr_size; /* w2k3 seems to ignore this */ - drsuapi_DsExtendedOperation extended_op; - hyper fsmo_info; - drsuapi_DsPartialAttributeSet *partial_attribute_set; - drsuapi_DsPartialAttributeSet *partial_attribute_set_ex; - drsuapi_DsReplicaOIDMapping_Ctr mapping_ctr; - } drsuapi_DsGetNCChangesRequest8; - - typedef [switch_type(int32)] union { - [case(5)] drsuapi_DsGetNCChangesRequest5 req5; - [case(8)] drsuapi_DsGetNCChangesRequest8 req8; - } drsuapi_DsGetNCChangesRequest; - - typedef [public] struct { - GUID source_dsa_invocation_id; /* the 'invocationId' field of the CN=NTDS Settings object */ - hyper highest_usn; /* updated after a full replication cycle */ - NTTIME last_sync_success; - } drsuapi_DsReplicaCursor2; - - typedef struct { - [value(2)] uint32 version; - [value(0)] uint32 reserved1; - [range(0,0x100000)] uint32 count; - [value(0)] uint32 reserved2; - [size_is(count)] drsuapi_DsReplicaCursor2 cursors[]; - } drsuapi_DsReplicaCursor2CtrEx; - - /* Generic DATA_BLOB values */ - typedef struct { - [range(0,10485760),value(ndr_size_DATA_BLOB(0,blob,0))] uint32 __ndr_size; - DATA_BLOB *blob; - } drsuapi_DsAttributeValue; - - typedef struct { - [range(0,10485760)] uint32 num_values; - [size_is(num_values)] drsuapi_DsAttributeValue *values; - } drsuapi_DsAttributeValueCtr; - - /* DN String values */ - typedef [public,gensize] struct { - [value(ndr_size_drsuapi_DsReplicaObjectIdentifier3(r, ndr->flags))] uint32 __ndr_size; - [value(ndr_size_dom_sid28(&sid,ndr->flags))] uint32 __ndr_size_sid; - GUID guid; - dom_sid28 sid; - [value(strlen_m(dn))] uint32 __ndr_size_dn; - [charset(UTF16)] uint16 dn[__ndr_size_dn+1]; - } drsuapi_DsReplicaObjectIdentifier3; - - typedef [public,gensize] struct { - [value(ndr_size_drsuapi_DsReplicaObjectIdentifier3Binary(r, ndr->flags))] uint32 __ndr_size; - [value(ndr_size_dom_sid28(&sid,ndr->flags))] uint32 __ndr_size_sid; - GUID guid; - dom_sid28 sid; - [value(strlen_m(dn))] uint32 __ndr_size_dn; - [charset(UTF16)] uint16 dn[__ndr_size_dn+1]; - [value(binary.length + 4)] uint32 __ndr_size_binary; - [flag(NDR_REMAINING)] DATA_BLOB binary; - } drsuapi_DsReplicaObjectIdentifier3Binary; - - typedef [public] struct { - drsuapi_DsAttributeId attid; - drsuapi_DsAttributeValueCtr value_ctr; - } drsuapi_DsReplicaAttribute; - - typedef struct { - [range(0,1048576)] uint32 num_attributes; - [size_is(num_attributes)] drsuapi_DsReplicaAttribute *attributes; - } drsuapi_DsReplicaAttributeCtr; - - typedef [public] bitmap { - DRSUAPI_DS_REPLICA_OBJECT_FROM_MASTER = 0x00000001, - DRSUAPI_DS_REPLICA_OBJECT_DYNAMIC = 0x00000002, - DRSUAPI_DS_REPLICA_OBJECT_REMOTE_MODIFY = 0x00010000 - } drsuapi_DsReplicaObjectFlags; - - typedef [public] struct { - drsuapi_DsReplicaObjectIdentifier *identifier; - drsuapi_DsReplicaObjectFlags flags; - drsuapi_DsReplicaAttributeCtr attribute_ctr; - } drsuapi_DsReplicaObject; - - typedef struct { - uint32 version; - NTTIME_1sec originating_change_time; - GUID originating_invocation_id; - hyper originating_usn; - } drsuapi_DsReplicaMetaData; - - typedef [public] struct { - [range(0,1048576)] uint32 count; - [size_is(count)] drsuapi_DsReplicaMetaData meta_data[]; - } drsuapi_DsReplicaMetaDataCtr; - - typedef [public,noprint] struct { - drsuapi_DsReplicaObjectListItemEx *next_object; - drsuapi_DsReplicaObject object; - boolean32 is_nc_prefix; - GUID *parent_object_guid; - drsuapi_DsReplicaMetaDataCtr *meta_data_ctr; - } drsuapi_DsReplicaObjectListItemEx; - - typedef [public,gensize] struct { - GUID source_dsa_guid; /* the 'objectGUID' field of the CN=NTDS Settings object */ - GUID source_dsa_invocation_id; /* the 'invocationId' field of the CN=NTDS Settings object */ - drsuapi_DsReplicaObjectIdentifier *naming_context; - drsuapi_DsReplicaHighWaterMark old_highwatermark; - drsuapi_DsReplicaHighWaterMark new_highwatermark; - drsuapi_DsReplicaCursorCtrEx *uptodateness_vector; - drsuapi_DsReplicaOIDMapping_Ctr mapping_ctr; - drsuapi_DsExtendedError extended_ret; /* w2k sends the nc_object_count value here */ - uint32 object_count; - /* this +55 is sometimes +56, so I don't know where this comes from... --metze */ - [value(ndr_size_drsuapi_DsGetNCChangesCtr1(r,ndr->flags)+55)] uint32 __ndr_size; - drsuapi_DsReplicaObjectListItemEx *first_object; - boolean32 more_data; - } drsuapi_DsGetNCChangesCtr1; - - /* - * if the DRSUAPI_DS_LINKED_ATTRIBUTE_FLAG_ACTIVE flag - * isn't there it means the value is deleted - */ - typedef [public] bitmap { - DRSUAPI_DS_LINKED_ATTRIBUTE_FLAG_ACTIVE = 0x00000001 - } drsuapi_DsLinkedAttributeFlags; - - typedef [public] struct { - drsuapi_DsReplicaObjectIdentifier *identifier; - drsuapi_DsAttributeId attid; - drsuapi_DsAttributeValue value; - drsuapi_DsLinkedAttributeFlags flags; - NTTIME_1sec originating_add_time; - drsuapi_DsReplicaMetaData meta_data; - } drsuapi_DsReplicaLinkedAttribute; - - typedef [public,gensize] struct { - GUID source_dsa_guid; /* the 'objectGUID' field of the CN=NTDS Settings object */ - GUID source_dsa_invocation_id; /* the 'invocationId' field of the CN=NTDS Settings object */ - drsuapi_DsReplicaObjectIdentifier *naming_context; - drsuapi_DsReplicaHighWaterMark old_highwatermark; - drsuapi_DsReplicaHighWaterMark new_highwatermark; - drsuapi_DsReplicaCursor2CtrEx *uptodateness_vector; - drsuapi_DsReplicaOIDMapping_Ctr mapping_ctr; - drsuapi_DsExtendedError extended_ret; - uint32 object_count; - /* this +55 is sometimes +56, so I don't know where this comes from... --metze */ - [value(ndr_size_drsuapi_DsGetNCChangesCtr6(r,ndr->flags)+55)] uint32 __ndr_size; - drsuapi_DsReplicaObjectListItemEx *first_object; - boolean32 more_data; - uint32 nc_object_count; /* estimated amount of objects in the whole NC */ - uint32 nc_linked_attributes_count; /* estimated amount of linked values in the whole NC */ - [range(0,1048576)] uint32 linked_attributes_count; - [size_is(linked_attributes_count)] drsuapi_DsReplicaLinkedAttribute *linked_attributes; - WERROR drs_error; - } drsuapi_DsGetNCChangesCtr6; - - typedef [public] struct { - [subcontext(0xFFFFFC01)] drsuapi_DsGetNCChangesCtr1 ctr1; - } drsuapi_DsGetNCChangesCtr1TS; - - typedef [public] struct { - [subcontext(0xFFFFFC01)] drsuapi_DsGetNCChangesCtr6 ctr6; - } drsuapi_DsGetNCChangesCtr6TS; - - typedef [nopush] struct { - uint32 decompressed_length; - uint32 compressed_length; - [subcontext(4),subcontext_size(compressed_length), - compression(NDR_COMPRESSION_MSZIP,compressed_length,decompressed_length)] - drsuapi_DsGetNCChangesCtr1TS *ts; - } drsuapi_DsGetNCChangesMSZIPCtr1; - - typedef [nopush] struct { - uint32 decompressed_length; - uint32 compressed_length; - [subcontext(4),subcontext_size(compressed_length), - compression(NDR_COMPRESSION_MSZIP,compressed_length,decompressed_length)] - drsuapi_DsGetNCChangesCtr6TS *ts; - } drsuapi_DsGetNCChangesMSZIPCtr6; - - typedef [nopush] struct { - uint32 decompressed_length; - uint32 compressed_length; - [subcontext(4),subcontext_size(compressed_length), - compression(NDR_COMPRESSION_XPRESS,compressed_length,decompressed_length)] - drsuapi_DsGetNCChangesCtr1TS *ts; - } drsuapi_DsGetNCChangesXPRESSCtr1; - - typedef [nopush] struct { - uint32 decompressed_length; - uint32 compressed_length; - [subcontext(4),subcontext_size(compressed_length), - compression(NDR_COMPRESSION_XPRESS,compressed_length,decompressed_length)] - drsuapi_DsGetNCChangesCtr6TS *ts; - } drsuapi_DsGetNCChangesXPRESSCtr6; - - typedef [enum16bit] enum { - DRSUAPI_COMPRESSION_TYPE_MSZIP = 2, - DRSUAPI_COMPRESSION_TYPE_XPRESS = 3 - } drsuapi_DsGetNCChangesCompressionType; - - typedef [nodiscriminant,flag(NDR_PAHEX)] union { - [case(1|(DRSUAPI_COMPRESSION_TYPE_MSZIP<<16))] drsuapi_DsGetNCChangesMSZIPCtr1 mszip1; - [case(6|(DRSUAPI_COMPRESSION_TYPE_MSZIP<<16))] drsuapi_DsGetNCChangesMSZIPCtr6 mszip6; - [case(1|(DRSUAPI_COMPRESSION_TYPE_XPRESS<<16))] drsuapi_DsGetNCChangesXPRESSCtr1 xpress1; - [case(6|(DRSUAPI_COMPRESSION_TYPE_XPRESS<<16))] drsuapi_DsGetNCChangesXPRESSCtr6 xpress6; - } drsuapi_DsGetNCChangesCompressedCtr; - - typedef struct { - drsuapi_DsGetNCChangesMSZIPCtr1 mszip1; - } drsuapi_DsGetNCChangesCtr2; - - typedef struct { - [range(0,6)] int32 level; - [range(2,3)] drsuapi_DsGetNCChangesCompressionType type; - [switch_is(level | (type<<16))] drsuapi_DsGetNCChangesCompressedCtr ctr; - } drsuapi_DsGetNCChangesCtr7; - - typedef [switch_type(int32)] union { - [case(1)] drsuapi_DsGetNCChangesCtr1 ctr1; - [case(2)] drsuapi_DsGetNCChangesCtr2 ctr2; - [case(6)] drsuapi_DsGetNCChangesCtr6 ctr6; - [case(7)] drsuapi_DsGetNCChangesCtr7 ctr7; - } drsuapi_DsGetNCChangesCtr; - - WERROR drsuapi_DsGetNCChanges( - [in] policy_handle *bind_handle, - [in,out,ref] int32 *level, - [in,switch_is(*level)] drsuapi_DsGetNCChangesRequest req, - [out,switch_is(*level)] drsuapi_DsGetNCChangesCtr ctr - ); - - /*****************/ - /* Function 0x04 */ - typedef bitmap { - DRSUAPI_DS_REPLICA_UPDATE_ASYNCHRONOUS_OPERATION = 0x00000001, - DRSUAPI_DS_REPLICA_UPDATE_WRITEABLE = 0x00000002, - DRSUAPI_DS_REPLICA_UPDATE_ADD_REFERENCE = 0x00000004, - DRSUAPI_DS_REPLICA_UPDATE_DELETE_REFERENCE = 0x00000008, - DRSUAPI_DS_REPLICA_UPDATE_0x00000010 = 0x00000010 - } drsuapi_DsReplicaUpdateRefsOptions; - - typedef struct { - [ref] drsuapi_DsReplicaObjectIdentifier *naming_context; - [ref,charset(DOS),string] uint8 *dest_dsa_dns_name; - GUID dest_dsa_guid; - drsuapi_DsReplicaUpdateRefsOptions options; - } drsuapi_DsReplicaUpdateRefsRequest1; - - typedef [switch_type(int32)] union { - [case(1)] drsuapi_DsReplicaUpdateRefsRequest1 req1; - } drsuapi_DsReplicaUpdateRefsRequest; - - WERROR drsuapi_DsReplicaUpdateRefs( - [in] policy_handle *bind_handle, - [in] int32 level, - [in,switch_is(level)] drsuapi_DsReplicaUpdateRefsRequest req - ); - - /*****************/ - /* Function 0x05 */ - typedef bitmap { - DRSUAPI_DS_REPLICA_ADD_ASYNCHRONOUS_OPERATION = 0x00000001, - DRSUAPI_DS_REPLICA_ADD_WRITEABLE = 0x00000002 - /* TODO ... */ - } drsuapi_DsReplicaAddOptions; - - [todo] WERROR DRSUAPI_REPLICA_ADD(); - - /*****************/ - /* Function 0x06 */ - typedef bitmap { - DRSUAPI_DS_REPLICA_DELETE_ASYNCHRONOUS_OPERATION = 0x00000001, - DRSUAPI_DS_REPLICA_DELETE_WRITEABLE = 0x00000002 - /* TODO ... */ - } drsuapi_DsReplicaDeleteOptions; - - [todo] WERROR DRSUAPI_REPLICA_DEL(); - - /*****************/ - /* Function 0x07 */ - typedef bitmap { - DRSUAPI_DS_REPLICA_MODIFY_ASYNCHRONOUS_OPERATION = 0x00000001, - DRSUAPI_DS_REPLICA_MODIFY_WRITEABLE = 0x00000002 - } drsuapi_DsReplicaModifyOptions; - - [todo] WERROR DRSUAPI_REPLICA_MODIFY(); - - /*****************/ - /* Function 0x08 */ - [todo] WERROR DRSUAPI_VERIFY_NAMES(); - - /*****************/ - /* Function 0x09 */ - - /* how are type 4 and 7 different from 2 and 3 ? */ - typedef [v1_enum] enum { - DRSUAPI_DS_MEMBERSHIP_TYPE_UNIVERSAL_AND_DOMAIN_GROUPS = 1, - DRSUAPI_DS_MEMBERSHIP_TYPE_DOMAIN_LOCAL_GROUPS = 2, - DRSUAPI_DS_MEMBERSHIP_TYPE_DOMAIN_GROUPS = 3, - DRSUAPI_DS_MEMBERSHIP_TYPE_DOMAIN_LOCAL_GROUPS2 = 4, - DRSUAPI_DS_MEMBERSHIP_TYPE_UNIVERSAL_GROUPS = 5, - DRSUAPI_DS_MEMBERSHIP_TYPE_GROUPMEMBERS = 6, - DRSUAPI_DS_MEMBERSHIP_TYPE_DOMAIN_GROUPS2 = 7 - } drsuapi_DsMembershipType; - - typedef struct { - NTSTATUS status; - [range(0,10000)] uint32 num_memberships; - [range(0,10000)] uint32 num_sids; - [size_is(num_memberships)] drsuapi_DsReplicaObjectIdentifier **info_array; - [size_is(num_memberships)] samr_GroupAttrs *group_attrs; - [size_is(num_sids)] dom_sid28 **sids; - } drsuapi_DsGetMembershipsCtr1; - - typedef [switch_type(int32)] union { - [case(1)] drsuapi_DsGetMembershipsCtr1 ctr1; - } drsuapi_DsGetMembershipsCtr; - - const int DRSUAPI_DS_MEMBERSHIP_FLAG_GROUP_ATTR = 0x1; - - typedef struct { - [range(1,10000)] uint32 count; - [size_is(count)] drsuapi_DsReplicaObjectIdentifier **info_array; - uint32 flags; - drsuapi_DsMembershipType type; - drsuapi_DsReplicaObjectIdentifier *domain; - } drsuapi_DsGetMembershipsRequest1; - - typedef [switch_type(int32)] union { - [case(1)] drsuapi_DsGetMembershipsRequest1 req1; - } drsuapi_DsGetMembershipsRequest; - - [todo] WERROR drsuapi_DsGetMemberships( - [in] policy_handle *bind_handle, - [in] int32 level, - [in,ref] [switch_is(level)] drsuapi_DsGetMembershipsRequest *req, - [out,ref] int32 *level_out, - [out,ref] [switch_is(*level_out)] drsuapi_DsGetMembershipsCtr *ctr - ); - - /*****************/ - /* Function 0x0a */ - [todo] WERROR DRSUAPI_INTER_DOMAIN_MOVE(); - - /*****************/ - /* Function 0x0b */ - typedef struct { - uint32 unknown1; - uint32 unknown2; - [range(0,0x00A00000)] uint32 length; - [size_is(length)] uint8 *data; - } drsuapi_DsGetNT4ChangeLogRequest1; - - typedef [switch_type(uint32)] union { - [case(1)] drsuapi_DsGetNT4ChangeLogRequest1 req1; - } drsuapi_DsGetNT4ChangeLogRequest; - - typedef struct { - [range(0,0x00A00000)] uint32 length1; - [range(0,0x00A00000)] uint32 length2; - hyper unknown1; - NTTIME time2; - hyper unknown3; - NTTIME time4; - hyper unknown5; - NTTIME time6; - NTSTATUS status; - [size_is(length1)] uint8 *data1; - [size_is(length2)] uint8 *data2; - } drsuapi_DsGetNT4ChangeLogInfo1; - - typedef [switch_type(uint32)] union { - [case(1)] drsuapi_DsGetNT4ChangeLogInfo1 info1; - } drsuapi_DsGetNT4ChangeLogInfo; - - [todo] WERROR drsuapi_DsGetNT4ChangeLog( - [in] policy_handle *bind_handle, - [in] uint32 level, - [in,ref] [switch_is(level)] drsuapi_DsGetNT4ChangeLogRequest *req, - [out,ref] uint32 *level_out, - [out,ref] [switch_is(*level_out)] drsuapi_DsGetNT4ChangeLogInfo *info - ); - - /*****************/ - /* Function 0x0c */ - typedef [v1_enum] enum { - DRSUAPI_DS_NAME_STATUS_OK = 0, - DRSUAPI_DS_NAME_STATUS_RESOLVE_ERROR = 1, - DRSUAPI_DS_NAME_STATUS_NOT_FOUND = 2, - DRSUAPI_DS_NAME_STATUS_NOT_UNIQUE = 3, - DRSUAPI_DS_NAME_STATUS_NO_MAPPING = 4, - DRSUAPI_DS_NAME_STATUS_DOMAIN_ONLY = 5, - DRSUAPI_DS_NAME_STATUS_NO_SYNTACTICAL_MAPPING = 6, - DRSUAPI_DS_NAME_STATUS_TRUST_REFERRAL = 7 - } drsuapi_DsNameStatus; - - typedef [v1_enum] enum { - DRSUAPI_DS_NAME_FLAG_NO_FLAGS = 0x0, - DRSUAPI_DS_NAME_FLAG_SYNTACTICAL_ONLY = 0x1, - DRSUAPI_DS_NAME_FLAG_EVAL_AT_DC = 0x2, - DRSUAPI_DS_NAME_FLAG_GCVERIFY = 0x4, - DRSUAPI_DS_NAME_FLAG_TRUST_REFERRAL = 0x8 - } drsuapi_DsNameFlags; - - typedef [v1_enum] enum { - DRSUAPI_DS_NAME_FORMAT_UNKNOWN = 0, - DRSUAPI_DS_NAME_FORMAT_FQDN_1779 = 1, - DRSUAPI_DS_NAME_FORMAT_NT4_ACCOUNT = 2, - DRSUAPI_DS_NAME_FORMAT_DISPLAY = 3, - DRSUAPI_DS_NAME_FORMAT_GUID = 6, - DRSUAPI_DS_NAME_FORMAT_CANONICAL = 7, - DRSUAPI_DS_NAME_FORMAT_USER_PRINCIPAL = 8, - DRSUAPI_DS_NAME_FORMAT_CANONICAL_EX = 9, - DRSUAPI_DS_NAME_FORMAT_SERVICE_PRINCIPAL = 10, - DRSUAPI_DS_NAME_FORMAT_SID_OR_SID_HISTORY = 11, - DRSUAPI_DS_NAME_FORMAT_DNS_DOMAIN = 12 - } drsuapi_DsNameFormat; - - typedef struct { - [string,charset(UTF16)] uint16 *str; - } drsuapi_DsNameString; - - typedef struct { - uint32 codepage; /* 0x000004e4 - 1252 is german codepage*/ - uint32 language; /* 0x00000407 - german language ID*/ - drsuapi_DsNameFlags format_flags; - drsuapi_DsNameFormat format_offered; - drsuapi_DsNameFormat format_desired; - [range(1,10000)] uint32 count; - [size_is(count)] drsuapi_DsNameString *names; - } drsuapi_DsNameRequest1; - - typedef [switch_type(int32)] union { - [case(1)] drsuapi_DsNameRequest1 req1; - } drsuapi_DsNameRequest; - - typedef struct { - drsuapi_DsNameStatus status; - [charset(UTF16),string] uint16 *dns_domain_name; - [charset(UTF16),string] uint16 *result_name; - } drsuapi_DsNameInfo1; - - typedef struct { - uint32 count; - [size_is(count)] drsuapi_DsNameInfo1 *array; - } drsuapi_DsNameCtr1; - - typedef [switch_type(int32)] union { - [case(1)] drsuapi_DsNameCtr1 *ctr1; - } drsuapi_DsNameCtr; - - WERROR drsuapi_DsCrackNames( - [in] policy_handle *bind_handle, - [in, out] int32 level, - [in,switch_is(level)] drsuapi_DsNameRequest req, - [out,switch_is(level)] drsuapi_DsNameCtr ctr - ); - - /*****************/ - /* Function 0x0d */ - typedef [v1_enum] enum { - DRSUAPI_DS_SPN_OPERATION_ADD = 0, - DRSUAPI_DS_SPN_OPERATION_REPLACE= 1, - DRSUAPI_DS_SPN_OPERATION_DELETE = 2 - } drsuapi_DsSpnOperation; - - typedef struct { - drsuapi_DsSpnOperation operation; - uint32 unknown1; - [charset(UTF16),string] uint16 *object_dn; - [range(0,10000)] uint32 count; - [size_is(count)] drsuapi_DsNameString *spn_names; - } drsuapi_DsWriteAccountSpnRequest1; - - typedef [switch_type(int32)] union { - [case(1)] drsuapi_DsWriteAccountSpnRequest1 req1; - } drsuapi_DsWriteAccountSpnRequest; - - typedef struct { - WERROR status; - } drsuapi_DsWriteAccountSpnResult1; - - typedef [switch_type(int32)] union { - [case(1)] drsuapi_DsWriteAccountSpnResult1 res1; - } drsuapi_DsWriteAccountSpnResult; - - WERROR drsuapi_DsWriteAccountSpn( - [in] policy_handle *bind_handle, - [in,out] int32 level, - [in,switch_is(level)] drsuapi_DsWriteAccountSpnRequest req, - [out,switch_is(level)] drsuapi_DsWriteAccountSpnResult res - ); - - /*****************/ - /* Function 0x0e */ - typedef struct { - [charset(UTF16),string] uint16 *server_dn; - [charset(UTF16),string] uint16 *domain_dn; - boolean32 commit; - } drsuapi_DsRemoveDSServerRequest1; - - typedef [switch_type(int32)] union { - [case(1)] drsuapi_DsRemoveDSServerRequest1 req1; - } drsuapi_DsRemoveDSServerRequest; - - typedef struct { - boolean32 last_dc_in_domain; - } drsuapi_DsRemoveDSServerResult1; - - typedef [switch_type(int32)] union { - [case(1)] drsuapi_DsRemoveDSServerResult1 res1; - } drsuapi_DsRemoveDSServerResult; - - WERROR drsuapi_DsRemoveDSServer( - [in] policy_handle *bind_handle, - [in,out] int32 level, - [in,switch_is(level)] drsuapi_DsRemoveDSServerRequest req, - [out,switch_is(level)] drsuapi_DsRemoveDSServerResult res - ); - - /*****************/ - /* Function 0x0f */ - [todo] WERROR DRSUAPI_REMOVE_DS_DOMAIN(); - - /*****************/ - /* Function 0x10 */ - typedef struct { - [charset(UTF16),string] uint16 *domain_name; /* netbios or dns */ - int32 level; /* specifies the switch level for the request */ - } drsuapi_DsGetDCInfoRequest1; - - typedef [switch_type(int32)] union { - [case(1)] drsuapi_DsGetDCInfoRequest1 req1; - } drsuapi_DsGetDCInfoRequest; - - typedef struct { - [charset(UTF16),string] uint16 *netbios_name; - [charset(UTF16),string] uint16 *dns_name; - [charset(UTF16),string] uint16 *site_name; - [charset(UTF16),string] uint16 *computer_dn; - [charset(UTF16),string] uint16 *server_dn; - uint32 is_pdc; - uint32 is_enabled; - } drsuapi_DsGetDCInfo1; - - typedef struct { - [range(0,10000)] uint32 count; - [size_is(count)] drsuapi_DsGetDCInfo1 *array; - } drsuapi_DsGetDCInfoCtr1; - - typedef struct { - [charset(UTF16),string] uint16 *netbios_name; - [charset(UTF16),string] uint16 *dns_name; - [charset(UTF16),string] uint16 *site_name; - [charset(UTF16),string] uint16 *site_dn; - [charset(UTF16),string] uint16 *computer_dn; - [charset(UTF16),string] uint16 *server_dn; - [charset(UTF16),string] uint16 *ntds_dn; - uint32 is_pdc; - uint32 is_enabled; - uint32 is_gc; - GUID site_guid; - GUID computer_guid; - GUID server_guid; - GUID ntds_guid; - } drsuapi_DsGetDCInfo2; - - typedef struct { - [range(0,10000)] uint32 count; - [size_is(count)] drsuapi_DsGetDCInfo2 *array; - } drsuapi_DsGetDCInfoCtr2; - - typedef struct { - [charset(UTF16),string] uint16 *netbios_name; - [charset(UTF16),string] uint16 *dns_name; - [charset(UTF16),string] uint16 *site_name; - [charset(UTF16),string] uint16 *site_dn; - [charset(UTF16),string] uint16 *computer_dn; - [charset(UTF16),string] uint16 *server_dn; - [charset(UTF16),string] uint16 *ntds_dn; - uint32 is_pdc; - uint32 is_enabled; - uint32 is_gc; - uint32 is_rodc; - GUID site_guid; - GUID computer_guid; - GUID server_guid; - GUID ntds_guid; - } drsuapi_DsGetDCInfo3; - - typedef struct { - [range(0,10000)] uint32 count; - [size_is(count)] drsuapi_DsGetDCInfo3 *array; - } drsuapi_DsGetDCInfoCtr3; - - /* - * this represents an active connection to the - * Directory System Agent (DSA) - * this can be via LDAP or DRSUAPI - */ - typedef struct { - [flag(NDR_BIG_ENDIAN)] ipv4address client_ip_address; - uint32 unknown2; - uint32 connection_time; /* in seconds */ - uint32 unknown4; - uint32 unknown5; - uint32 unknown6; - /* - * client_account can be the following: - * "W2K3\Administrator" - * "Administrator@W2K3" - * "cn=Administrator,cn=Users,DC=w2k3,DC=vmnet1,DC=vm,DC=base" - * "" - * or NULL - */ - [charset(UTF16),string] uint16 *client_account; - } drsuapi_DsGetDCConnection01; - - typedef struct { - [range(0,10000)] uint32 count; - [size_is(count)] drsuapi_DsGetDCConnection01 *array; - } drsuapi_DsGetDCConnectionCtr01; - - typedef [v1_enum] enum { - DRSUAPI_DC_INFO_CTR_1 = 1, - DRSUAPI_DC_INFO_CTR_2 = 2, - DRSUAPI_DC_INFO_CTR_3 = 3, - DRSUAPI_DC_CONNECTION_CTR_01 = -1 - } drsuapi_DsGetDCInfoCtrLevels; - - typedef [switch_type(int32)] union { - [case(DRSUAPI_DC_INFO_CTR_1)] drsuapi_DsGetDCInfoCtr1 ctr1; - [case(DRSUAPI_DC_INFO_CTR_2)] drsuapi_DsGetDCInfoCtr2 ctr2; - [case(DRSUAPI_DC_INFO_CTR_3)] drsuapi_DsGetDCInfoCtr3 ctr3; - [case(DRSUAPI_DC_CONNECTION_CTR_01)] drsuapi_DsGetDCConnectionCtr01 ctr01; - } drsuapi_DsGetDCInfoCtr; - - WERROR drsuapi_DsGetDomainControllerInfo( - [in] policy_handle *bind_handle, - [in] int32 level, - [in,switch_is(level)] drsuapi_DsGetDCInfoRequest req, - [out] int32 level_out, - [out,switch_is(level_out)] drsuapi_DsGetDCInfoCtr ctr - ); - - /*****************/ - /* Function 0x11 */ - typedef [public,noprint] struct { - drsuapi_DsReplicaObjectListItem *next_object; - drsuapi_DsReplicaObject object; - } drsuapi_DsReplicaObjectListItem; - - /* - * 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! - */ - const char *DRSUAPI_NTDSDSA_KRB5_SERVICE_GUID = "E3514235-4B06-11D1-AB04-00C04FC2DCD2"; - - /* - * please note the the current idl - * for DsAddEntry does only parse - * what I saw between 2 w2k3 boxes - * in my dssync experiments I got some other replies - * so all I want to say is that this is very incomplete yet... - * --metze - */ - typedef struct { - drsuapi_DsReplicaObjectListItem first_object; - } drsuapi_DsAddEntryRequest2; - - typedef [switch_type(int32)] union { - [case(2)] drsuapi_DsAddEntryRequest2 req2; - } drsuapi_DsAddEntryRequest; - - typedef struct { - uint32 unknown1; - WERROR status; - uint32 unknown2; - uint16 unknown3; - } drsuapi_DsAddEntryErrorInfoX; - - typedef struct { - [range(0,10485760)] uint32 size; - [size_is(size)] uint8 *data; - } drsuapi_DsAddEntryExtraErrorBuffer; - - typedef struct { - drsuapi_DsAddEntryErrorInfoX error; - drsuapi_DsAttributeId attid; - uint32 unknown2; - drsuapi_DsAddEntryExtraErrorBuffer buffer; - } drsuapi_DsAddEntryExtraError1; - - typedef /*[noprint]*/ struct { - drsuapi_DsAddEntryErrorListItem1 *next; - drsuapi_DsAddEntryExtraError1 error; - } drsuapi_DsAddEntryErrorListItem1; - - typedef struct { - drsuapi_DsReplicaObjectIdentifier *id; - WERROR status; - drsuapi_DsAddEntryErrorListItem1 first; - } drsuapi_DsAddEntryErrorInfo1; - - typedef [switch_type(uint32)] union { - [case(1)] drsuapi_DsAddEntryErrorInfo1 error1; -/* [case(2)] drsuapi_DsAddEntryErrorInfo2 error2; - [case(3)] drsuapi_DsAddEntryErrorInfo3 error3; -*/ [case(4)] drsuapi_DsAddEntryErrorInfoX errorX; - [case(5)] drsuapi_DsAddEntryErrorInfoX errorX; - [case(6)] drsuapi_DsAddEntryErrorInfoX errorX; - [case(7)] drsuapi_DsAddEntryErrorInfoX errorX; - } drsuapi_DsAddEntryErrorInfo; - - typedef struct { - WERROR status; - uint32 level; - [switch_is(level)] drsuapi_DsAddEntryErrorInfo *info; - } drsuapi_DsAddEntryError1; - - typedef [switch_type(uint32)] union { - [case(1)] drsuapi_DsAddEntryError1 info1; - } drsuapi_DsAddEntryError; - - typedef struct { - GUID guid; - dom_sid28 sid; - } drsuapi_DsReplicaObjectIdentifier2; - - typedef struct { - drsuapi_DsReplicaObjectIdentifier *id; - uint32 unknown1; - drsuapi_DsAddEntryErrorInfoX error; - [range(0,10000)] uint32 count; - [size_is(count)] drsuapi_DsReplicaObjectIdentifier2 *objects; - } drsuapi_DsAddEntryCtr2; - - typedef struct { - drsuapi_DsReplicaObjectIdentifier *id; - uint32 level; - [switch_is(level)] drsuapi_DsAddEntryError *error; - [range(0,10000)] uint32 count; - [size_is(count)] drsuapi_DsReplicaObjectIdentifier2 *objects; - } drsuapi_DsAddEntryCtr3; - - typedef [switch_type(int32)] union { - [case(2)] drsuapi_DsAddEntryCtr2 ctr2; - [case(3)] drsuapi_DsAddEntryCtr3 ctr3; - } drsuapi_DsAddEntryCtr; - - [public] WERROR drsuapi_DsAddEntry( - [in] policy_handle *bind_handle, - [in,out] int32 level, - [in,switch_is(level)] drsuapi_DsAddEntryRequest req, - [out,switch_is(level)] drsuapi_DsAddEntryCtr ctr - ); - - /*****************/ - /* Function 0x12 */ - [todo] WERROR DRSUAPI_EXECUTE_KCC(); - - /*****************/ - /* Function 0x13 */ - typedef [v1_enum] enum { - DRSUAPI_DS_REPLICA_GET_INFO = 1, - DRSUAPI_DS_REPLICA_GET_INFO2 = 2 - } drsuapi_DsReplicaGetInfoLevel; - - typedef [v1_enum] enum { - DRSUAPI_DS_REPLICA_INFO_NEIGHBORS = 0, - DRSUAPI_DS_REPLICA_INFO_CURSORS = 1, - DRSUAPI_DS_REPLICA_INFO_OBJ_METADATA = 2, - DRSUAPI_DS_REPLICA_INFO_KCC_DSA_CONNECT_FAILURES = 3, - DRSUAPI_DS_REPLICA_INFO_KCC_DSA_LINK_FAILURES = 4, - DRSUAPI_DS_REPLICA_INFO_PENDING_OPS = 5, - DRSUAPI_DS_REPLICA_INFO_ATTRIBUTE_VALUE_METADATA = 6, - DRSUAPI_DS_REPLICA_INFO_CURSORS2 = 7, - DRSUAPI_DS_REPLICA_INFO_CURSORS3 = 8, - DRSUAPI_DS_REPLICA_INFO_OBJ_METADATA2 = 9, - DRSUAPI_DS_REPLICA_INFO_ATTRIBUTE_VALUE_METADATA2 = 10, - DRSUAPI_DS_REPLICA_INFO_NEIGHBORS02 = -2, - DRSUAPI_DS_REPLICA_INFO_CONNECTIONS04 = -4, - DRSUAPI_DS_REPLICA_INFO_CURSORS05 = -5, - DRSUAPI_DS_REPLICA_INFO_06 = -6 - } drsuapi_DsReplicaInfoType; - - typedef struct { - drsuapi_DsReplicaInfoType info_type; - [charset(UTF16),string] uint16 *object_dn; - GUID guid1; - } drsuapi_DsReplicaGetInfoRequest1; - - typedef struct { - drsuapi_DsReplicaInfoType info_type; - [charset(UTF16),string] uint16 *object_dn; - GUID guid1; - uint32 unknown1; - [charset(UTF16),string] uint16 *string1; - [charset(UTF16),string] uint16 *string2; - uint32 unknown2; - } drsuapi_DsReplicaGetInfoRequest2; - - typedef [switch_type(drsuapi_DsReplicaGetInfoLevel)] union { - [case(DRSUAPI_DS_REPLICA_GET_INFO)] drsuapi_DsReplicaGetInfoRequest1 req1; - [case(DRSUAPI_DS_REPLICA_GET_INFO2)] drsuapi_DsReplicaGetInfoRequest2 req2; - } drsuapi_DsReplicaGetInfoRequest; - - typedef struct { - [charset(UTF16),string] uint16 *naming_context_dn; - [charset(UTF16),string] uint16 *source_dsa_obj_dn; - [charset(UTF16),string] uint16 *source_dsa_address; - [charset(UTF16),string] uint16 *transport_obj_dn; - drsuapi_DsReplicaNeighbourFlags replica_flags; - uint32 reserved; - GUID naming_context_obj_guid; - GUID source_dsa_obj_guid; - GUID source_dsa_invocation_id; - GUID transport_obj_guid; - hyper tmp_highest_usn; - hyper highest_usn; - NTTIME last_success; - NTTIME last_attempt; - WERROR result_last_attempt; - uint32 consecutive_sync_failures; - } drsuapi_DsReplicaNeighbour; - - typedef struct { - uint32 count; - uint32 reserved; - [size_is(count)] drsuapi_DsReplicaNeighbour array[]; - } drsuapi_DsReplicaNeighbourCtr; - - typedef struct { - uint32 count; - uint32 reserved; - [size_is(count)] drsuapi_DsReplicaCursor array[]; - } drsuapi_DsReplicaCursorCtr; - - typedef struct { - [charset(UTF16),string] uint16 *attribute_name; - uint32 version; - NTTIME originating_change_time; - GUID originating_invocation_id; - hyper originating_usn; - hyper local_usn; - } drsuapi_DsReplicaObjMetaData; - - typedef struct { - uint32 count; - uint32 reserved; - [size_is(count)] drsuapi_DsReplicaObjMetaData array[]; - } drsuapi_DsReplicaObjMetaDataCtr; - - typedef struct { - [charset(UTF16),string] uint16 *dsa_obj_dn; - GUID dsa_obj_guid; - NTTIME first_failure; - uint32 num_failures; - WERROR last_result; - } drsuapi_DsReplicaKccDsaFailure; - - typedef struct { - uint32 count; - uint32 reserved; - [size_is(count)] drsuapi_DsReplicaKccDsaFailure array[]; - } drsuapi_DsReplicaKccDsaFailuresCtr; - - typedef enum { - DRSUAPI_DS_REPLICA_OP_TYPE_SYNC = 0, - DRSUAPI_DS_REPLICA_OP_TYPE_ADD = 1, - DRSUAPI_DS_REPLICA_OP_TYPE_DELETE = 2, - DRSUAPI_DS_REPLICA_OP_TYPE_MODIFY = 3, - DRSUAPI_DS_REPLICA_OP_TYPE_UPDATE_REFS = 4 - } drsuapi_DsReplicaOpType; - - typedef [switch_type(drsuapi_DsReplicaOpType)] union { - [case(DRSUAPI_DS_REPLICA_OP_TYPE_SYNC)] drsuapi_DsReplicaSyncOptions sync; - [case(DRSUAPI_DS_REPLICA_OP_TYPE_ADD)] drsuapi_DsReplicaAddOptions add; - [case(DRSUAPI_DS_REPLICA_OP_TYPE_DELETE)] drsuapi_DsReplicaDeleteOptions op_delete; - [case(DRSUAPI_DS_REPLICA_OP_TYPE_MODIFY)] drsuapi_DsReplicaModifyOptions modify; - [case(DRSUAPI_DS_REPLICA_OP_TYPE_UPDATE_REFS)] drsuapi_DsReplicaUpdateRefsOptions update_refs; - [default] uint32 unknown; - } drsuapi_DsRplicaOpOptions; - - typedef struct { - NTTIME operation_start; - uint32 serial_num; /* unique till reboot */ - uint32 priority; - drsuapi_DsReplicaOpType operation_type; - [switch_is(operation_type)] drsuapi_DsRplicaOpOptions options; - [charset(UTF16),string] uint16 *nc_dn; - [charset(UTF16),string] uint16 *remote_dsa_obj_dn; - [charset(UTF16),string] uint16 *remote_dsa_address; - GUID nc_obj_guid; - GUID remote_dsa_obj_guid; - } drsuapi_DsReplicaOp; - - typedef struct { - NTTIME time; - uint32 count; - [size_is(count)] drsuapi_DsReplicaOp array[]; - } drsuapi_DsReplicaOpCtr; - - typedef struct { - [charset(UTF16),string] uint16 *attribute_name; - [charset(UTF16),string] uint16 *object_dn; - [value(ndr_size_DATA_BLOB(0,binary,0))] uint32 __ndr_size_binary; - DATA_BLOB *binary; - NTTIME deleted; - NTTIME created; - uint32 version; - NTTIME originating_change_time; - GUID originating_invocation_id; - hyper originating_usn; - hyper local_usn; - } drsuapi_DsReplicaAttrValMetaData; - - typedef struct { - uint32 count; - int32 enumeration_context; - [size_is(count)] drsuapi_DsReplicaAttrValMetaData array[]; - } drsuapi_DsReplicaAttrValMetaDataCtr; - - typedef struct { - uint32 count; - int32 enumeration_context; - [size_is(count)] drsuapi_DsReplicaCursor2 array[]; - } drsuapi_DsReplicaCursor2Ctr; - - typedef struct { - GUID source_dsa_invocation_id; - hyper highest_usn; - NTTIME last_sync_success; - [charset(UTF16),string] uint16 *source_dsa_obj_dn; - } drsuapi_DsReplicaCursor3; - - typedef struct { - uint32 count; - int32 enumeration_context; - [size_is(count)] drsuapi_DsReplicaCursor3 array[]; - } drsuapi_DsReplicaCursor3Ctr; - - typedef struct { - [charset(UTF16),string] uint16 *attribute_name; - uint32 version; - NTTIME originating_change_time; - GUID originating_invocation_id; - hyper originating_usn; - hyper local_usn; - [charset(UTF16),string] uint16 *originating_dsa_dn; - } drsuapi_DsReplicaObjMetaData2; - - typedef struct { - uint32 count; - int32 enumeration_context; - [size_is(count)] drsuapi_DsReplicaObjMetaData2 array[]; - } drsuapi_DsReplicaObjMetaData2Ctr; - - typedef struct { - [charset(UTF16),string] uint16 *attribute_name; - [charset(UTF16),string] uint16 *object_dn; - [value(ndr_size_DATA_BLOB(0,binary,0))] uint32 __ndr_size_binary; - DATA_BLOB *binary; - NTTIME deleted; - NTTIME created; - uint32 version; - NTTIME originating_change_time; - GUID originating_invocation_id; - hyper originating_usn; - hyper local_usn; - [charset(UTF16),string] uint16 *originating_dsa_dn; - } drsuapi_DsReplicaAttrValMetaData2; - - typedef struct { - uint32 count; - int32 enumeration_context; - [size_is(count)] drsuapi_DsReplicaAttrValMetaData2 array[]; - } drsuapi_DsReplicaAttrValMetaData2Ctr; - - typedef struct { - hyper u1; /* session number? */ - uint32 u2; - uint32 u3; - GUID bind_guid; - NTTIME_1sec bind_time; - [flag(NDR_BIG_ENDIAN)] ipv4address client_ip_address; - uint32 u5; /* this is the same value the client used as pid in the DsBindInfoX struct */ - } drsuapi_DsReplicaConnection04; - - typedef struct { - [range(0,10000)] uint32 count; - uint32 reserved; - [size_is(count)] drsuapi_DsReplicaConnection04 array[]; - } drsuapi_DsReplicaConnection04Ctr; - - typedef struct { - [charset(UTF16),string] uint16 *str1; - uint32 u1; - uint32 u2; - uint32 u3; - uint32 u4; - uint32 u5; - hyper u6; - uint32 u7; - } drsuapi_DsReplica06; - - typedef struct { - [range(0,256)] uint32 count; - uint32 reserved; - [size_is(count)] drsuapi_DsReplica06 array[]; - } drsuapi_DsReplica06Ctr; - - typedef [switch_type(drsuapi_DsReplicaInfoType)] union { - [case(DRSUAPI_DS_REPLICA_INFO_NEIGHBORS)] drsuapi_DsReplicaNeighbourCtr *neighbours; - [case(DRSUAPI_DS_REPLICA_INFO_CURSORS)] drsuapi_DsReplicaCursorCtr *cursors; - [case(DRSUAPI_DS_REPLICA_INFO_OBJ_METADATA)] drsuapi_DsReplicaObjMetaDataCtr *objmetadata; - [case(DRSUAPI_DS_REPLICA_INFO_KCC_DSA_CONNECT_FAILURES)] drsuapi_DsReplicaKccDsaFailuresCtr *connectfailures; - [case(DRSUAPI_DS_REPLICA_INFO_KCC_DSA_LINK_FAILURES)] drsuapi_DsReplicaKccDsaFailuresCtr *linkfailures; - [case(DRSUAPI_DS_REPLICA_INFO_PENDING_OPS)] drsuapi_DsReplicaOpCtr *pendingops; - [case(DRSUAPI_DS_REPLICA_INFO_ATTRIBUTE_VALUE_METADATA)] drsuapi_DsReplicaAttrValMetaDataCtr *attrvalmetadata; - [case(DRSUAPI_DS_REPLICA_INFO_CURSORS2)] drsuapi_DsReplicaCursor2Ctr *cursors2; - [case(DRSUAPI_DS_REPLICA_INFO_CURSORS3)] drsuapi_DsReplicaCursor3Ctr *cursors3; - [case(DRSUAPI_DS_REPLICA_INFO_OBJ_METADATA2)] drsuapi_DsReplicaObjMetaData2Ctr *objmetadata2; - [case(DRSUAPI_DS_REPLICA_INFO_ATTRIBUTE_VALUE_METADATA2)] drsuapi_DsReplicaAttrValMetaData2Ctr *attrvalmetadata2; - [case(DRSUAPI_DS_REPLICA_INFO_NEIGHBORS02)] drsuapi_DsReplicaNeighbourCtr *neighbours02; - [case(DRSUAPI_DS_REPLICA_INFO_CONNECTIONS04)] drsuapi_DsReplicaConnection04Ctr *connections04; - [case(DRSUAPI_DS_REPLICA_INFO_CURSORS05)] drsuapi_DsReplicaCursorCtrEx *cursors05; - [case(DRSUAPI_DS_REPLICA_INFO_06)] drsuapi_DsReplica06Ctr *i06; - } drsuapi_DsReplicaInfo; - - WERROR drsuapi_DsReplicaGetInfo( - [in] policy_handle *bind_handle, - [in] drsuapi_DsReplicaGetInfoLevel level, - [in,ref,switch_is(level)] drsuapi_DsReplicaGetInfoRequest *req, - [out,ref] drsuapi_DsReplicaInfoType *info_type, - [out,ref,switch_is(*info_type)] drsuapi_DsReplicaInfo *info - ); - - /*****************/ - /* Function 0x14 */ - [todo] WERROR DRSUAPI_ADD_SID_HISTORY(); - - /*****************/ - /* Function 0x15 */ - - typedef struct { - [range(0,10000)] uint32 num_entries; - [size_is(num_entries)] drsuapi_DsGetMembershipsCtr1 **ctrl_array; - } drsuapi_DsGetMemberships2Ctr1; - - typedef [switch_type(int32)] union { - [case(1)] drsuapi_DsGetMembershipsCtr1 ctr1; - } drsuapi_DsGetMemberships2Ctr; - - typedef struct { - [range(1,10000)] uint32 num_req; - [size_is(num_req)] drsuapi_DsGetMembershipsRequest1 **req_array; - } drsuapi_DsGetMemberships2Request1; - - typedef [switch_type(int32)] union { - [case(1)] drsuapi_DsGetMemberships2Request1 req1; - } drsuapi_DsGetMemberships2Request; - - WERROR drsuapi_DsGetMemberships2( - [in] policy_handle *bind_handle, - [in] int32 level, - [in,ref] [switch_is(level)] drsuapi_DsGetMemberships2Request *req, - [out,ref] int32 *level_out, - [out,ref] [switch_is(*level_out)] drsuapi_DsGetMemberships2Ctr *ctr - ); - - /*****************/ - /* Function 0x16 */ - [todo] WERROR DRSUAPI_REPLICA_VERIFY_OBJECTS(); - - /*****************/ - /* Function 0x17 */ - [todo] WERROR DRSUAPI_GET_OBJECT_EXISTENCE(); - - /*****************/ - /* Function 0x18 */ - typedef struct { - WERROR error_code; - uint32 site_cost; - } drsuapi_DsSiteCostInfo; - - typedef struct { - [range(0,10000)] uint32 num_info; - [size_is(num_info)] drsuapi_DsSiteCostInfo *info; - uint32 unknown; - } drsuapi_QuerySitesByCostCtr1; - - typedef [switch_type(int32)] union { - [case(1)] drsuapi_QuerySitesByCostCtr1 ctr1; - } drsuapi_QuerySitesByCostCtr; - - typedef struct { - [charset(UTF16),string] uint16 *site_from; - [range(1,10000)] uint32 num_req; - [size_is(num_req)] [charset(UTF16),string] uint16 **site_to; - uint32 flags; - } drsuapi_QuerySitesByCostRequest1; - - typedef [switch_type(int32)] union { - [case(1)] drsuapi_QuerySitesByCostRequest1 req1; - } drsuapi_QuerySitesByCostRequest; - - WERROR drsuapi_QuerySitesByCost( - [in] policy_handle *bind_handle, - [in] int32 level, - [in,ref] [switch_is(level)] drsuapi_QuerySitesByCostRequest *req, - [out,ref] int32 *level_out, - [out,ref] [switch_is(*level_out)] drsuapi_QuerySitesByCostCtr *ctr - ); -} diff --git a/source4/librpc/ndr/ndr_drsblobs.c b/source4/librpc/ndr/ndr_drsblobs.c deleted file mode 100644 index aecb0c3b16..0000000000 --- a/source4/librpc/ndr/ndr_drsblobs.c +++ /dev/null @@ -1,213 +0,0 @@ -/* - Unix SMB/CIFS implementation. - - Manually parsed structures found in the DRS protocol - - Copyright (C) Andrew Bartlett <abartlet@samba.org> 2008 - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. -*/ - -#include "includes.h" -#include "librpc/gen_ndr/ndr_drsblobs.h" - -/* parser auto-generated by pidl, then hand-modified by abartlet */ - -/* Modified to have 'count' specified */ -static enum ndr_err_code ndr_push_AuthenticationInformationArray_with_count(struct ndr_push *ndr, int ndr_flags, int count, - const struct AuthenticationInformationArray *r) -{ - uint32_t cntr_array_0; - if (ndr_flags & NDR_SCALARS) { - NDR_CHECK(ndr_push_align(ndr, 4)); - for (cntr_array_0 = 0; cntr_array_0 < count; cntr_array_0++) { - NDR_CHECK(ndr_push_AuthenticationInformation(ndr, NDR_SCALARS, &r->array[cntr_array_0])); - } - } - if (ndr_flags & NDR_BUFFERS) { - for (cntr_array_0 = 0; cntr_array_0 < count; cntr_array_0++) { - NDR_CHECK(ndr_push_AuthenticationInformation(ndr, NDR_BUFFERS, &r->array[cntr_array_0])); - } - } - return NDR_ERR_SUCCESS; -} - -/* Modified to have 'count' specified, and to allocate the array */ -static enum ndr_err_code ndr_pull_AuthenticationInformationArray_with_count(struct ndr_pull *ndr, int ndr_flags, int count, struct AuthenticationInformationArray *r) -{ - uint32_t cntr_array_0; - TALLOC_CTX *_mem_save_array_0; - if (ndr_flags & NDR_SCALARS) { - NDR_CHECK(ndr_pull_align(ndr, 4)); - NDR_PULL_ALLOC_N(ndr, r->array, count); - _mem_save_array_0 = NDR_PULL_GET_MEM_CTX(ndr); - NDR_PULL_SET_MEM_CTX(ndr, r->array, 0); - for (cntr_array_0 = 0; cntr_array_0 < count; cntr_array_0++) { - NDR_CHECK(ndr_pull_AuthenticationInformation(ndr, NDR_SCALARS, &r->array[cntr_array_0])); - } - NDR_PULL_SET_MEM_CTX(ndr, _mem_save_array_0, 0); - } - if (ndr_flags & NDR_BUFFERS) { - for (cntr_array_0 = 0; cntr_array_0 < count; cntr_array_0++) { - NDR_CHECK(ndr_pull_AuthenticationInformation(ndr, NDR_BUFFERS, &r->array[cntr_array_0])); - } - } - return NDR_ERR_SUCCESS; -} - -/* Modified to have 'count' specified */ -_PUBLIC_ void ndr_print_AuthenticationInformationArray_with_count(struct ndr_print *ndr, const char *name, int count, const struct AuthenticationInformationArray *r) -{ - uint32_t cntr_array_0; - ndr_print_struct(ndr, name, "AuthenticationInformationArray"); - ndr->depth++; - ndr->print(ndr, "%s: ARRAY(%d)", "array", (int)1); - ndr->depth++; - for (cntr_array_0=0;cntr_array_0<count;cntr_array_0++) { - char *idx_0=NULL; - if (asprintf(&idx_0, "[%d]", cntr_array_0) != -1) { - ndr_print_AuthenticationInformation(ndr, "array", &r->array[cntr_array_0]); - free(idx_0); - } - } - ndr->depth--; - ndr->depth--; -} - -/* Modified to call AuthenticationInformationArray with 'count' specified */ -_PUBLIC_ enum ndr_err_code ndr_push_trustAuthInOutBlob(struct ndr_push *ndr, int ndr_flags, const struct trustAuthInOutBlob *r) -{ - if (ndr_flags & NDR_SCALARS) { - NDR_CHECK(ndr_push_align(ndr, 4)); - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->count)); - NDR_CHECK(ndr_push_relative_ptr1(ndr, r->current)); - NDR_CHECK(ndr_push_relative_ptr1(ndr, r->previous)); - } - if (ndr_flags & NDR_BUFFERS) { - if (r->current) { - NDR_CHECK(ndr_push_relative_ptr2(ndr, r->current)); - NDR_CHECK(ndr_push_AuthenticationInformationArray_with_count(ndr, NDR_SCALARS|NDR_BUFFERS, r->count, r->current)); - } - if (r->previous) { - NDR_CHECK(ndr_push_relative_ptr2(ndr, r->previous)); - NDR_CHECK(ndr_push_AuthenticationInformationArray_with_count(ndr, NDR_SCALARS|NDR_BUFFERS, r->count, r->previous)); - } - } - return NDR_ERR_SUCCESS; -} - -_PUBLIC_ enum ndr_err_code ndr_pull_trustAuthInOutBlob(struct ndr_pull *ndr, int ndr_flags, struct trustAuthInOutBlob *r) -{ - uint32_t _ptr_current; - TALLOC_CTX *_mem_save_current_0; - uint32_t _ptr_previous; - TALLOC_CTX *_mem_save_previous_0; - if (ndr_flags & NDR_SCALARS) { - NDR_CHECK(ndr_pull_align(ndr, 4)); - NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->count)); - NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_current)); - if (_ptr_current) { - NDR_PULL_ALLOC(ndr, r->current); - NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->current, _ptr_current)); - } else { - r->current = NULL; - } - NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_previous)); - if (_ptr_previous) { - NDR_PULL_ALLOC(ndr, r->previous); - NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->previous, _ptr_previous)); - } else { - r->previous = NULL; - } - } - if (ndr_flags & NDR_BUFFERS) { - if (r->current) { - uint32_t _relative_save_offset; - _relative_save_offset = ndr->offset; - NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->current)); - _mem_save_current_0 = NDR_PULL_GET_MEM_CTX(ndr); - NDR_PULL_SET_MEM_CTX(ndr, r->current, 0); - NDR_CHECK(ndr_pull_AuthenticationInformationArray_with_count(ndr, NDR_SCALARS|NDR_BUFFERS, r->count, r->current)); - NDR_PULL_SET_MEM_CTX(ndr, _mem_save_current_0, 0); - ndr->offset = _relative_save_offset; - } - if (r->previous) { - uint32_t _relative_save_offset; - _relative_save_offset = ndr->offset; - NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->previous)); - _mem_save_previous_0 = NDR_PULL_GET_MEM_CTX(ndr); - NDR_PULL_SET_MEM_CTX(ndr, r->previous, 0); - NDR_CHECK(ndr_pull_AuthenticationInformationArray_with_count(ndr, NDR_SCALARS|NDR_BUFFERS, r->count, r->previous)); - NDR_PULL_SET_MEM_CTX(ndr, _mem_save_previous_0, 0); - ndr->offset = _relative_save_offset; - } - } - return NDR_ERR_SUCCESS; -} - -_PUBLIC_ void ndr_print_trustAuthInOutBlob(struct ndr_print *ndr, const char *name, const struct trustAuthInOutBlob *r) -{ - ndr_print_struct(ndr, name, "trustAuthInOutBlob"); - ndr->depth++; - ndr_print_uint32(ndr, "count", r->count); - ndr_print_ptr(ndr, "current", r->current); - ndr->depth++; - if (r->current) { - ndr_print_AuthenticationInformationArray_with_count(ndr, "current", r->count, r->current); - } - ndr->depth--; - ndr_print_ptr(ndr, "previous", r->previous); - ndr->depth++; - if (r->previous) { - ndr_print_AuthenticationInformationArray_with_count(ndr, "previous", r->count, r->previous); - } - ndr->depth--; - ndr->depth--; -} - -_PUBLIC_ enum ndr_err_code ndr_pull_trustDomainPasswords(struct ndr_pull *ndr, int ndr_flags, struct trustDomainPasswords *r) -{ - if (ndr_flags & NDR_SCALARS) { - uint32_t offset; - NDR_PULL_ALIGN(ndr, 4); - NDR_PULL_NEED_BYTES(ndr, 8); - - offset = ndr->offset; - ndr->offset = ndr->data_size - 8; - - NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->outgoing_size)); - NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->incoming_size)); - - ndr->offset = offset; - NDR_CHECK(ndr_pull_array_uint8(ndr, NDR_SCALARS, r->confounder, 512)); - { - struct ndr_pull *_ndr_outgoing; - NDR_CHECK(ndr_pull_subcontext_start(ndr, &_ndr_outgoing, 0, r->outgoing_size)); - NDR_CHECK(ndr_pull_trustCurrentPasswords(_ndr_outgoing, NDR_SCALARS|NDR_BUFFERS, &r->outgoing)); - NDR_CHECK(ndr_pull_subcontext_end(ndr, _ndr_outgoing, 0, r->outgoing_size)); - } - { - struct ndr_pull *_ndr_incoming; - NDR_CHECK(ndr_pull_subcontext_start(ndr, &_ndr_incoming, 0, r->incoming_size)); - NDR_CHECK(ndr_pull_trustCurrentPasswords(_ndr_incoming, NDR_SCALARS|NDR_BUFFERS, &r->incoming)); - NDR_CHECK(ndr_pull_subcontext_end(ndr, _ndr_incoming, 0, r->incoming_size)); - } - NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->outgoing_size)); - NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->incoming_size)); - } - if (ndr_flags & NDR_BUFFERS) { - } - return NDR_ERR_SUCCESS; -} - diff --git a/source4/librpc/ndr/ndr_drsuapi.c b/source4/librpc/ndr/ndr_drsuapi.c deleted file mode 100644 index cb022d2ad3..0000000000 --- a/source4/librpc/ndr/ndr_drsuapi.c +++ /dev/null @@ -1,351 +0,0 @@ -/* - Unix SMB/CIFS implementation. - - routines for printing some linked list structs in DRSUAPI - - Copyright (C) Stefan (metze) Metzmacher 2005 - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. -*/ - - -#include "includes.h" -#include "librpc/gen_ndr/ndr_drsuapi.h" -#include "librpc/gen_ndr/ndr_misc.h" -#include "../lib/util/asn1.h" -#include "librpc/ndr/ndr_compression.h" - -void ndr_print_drsuapi_DsReplicaObjectListItem(struct ndr_print *ndr, const char *name, - const struct drsuapi_DsReplicaObjectListItem *r) -{ - ndr_print_struct(ndr, name, "drsuapi_DsReplicaObjectListItem"); - ndr->depth++; - ndr_print_ptr(ndr, "next_object", r->next_object); - ndr_print_drsuapi_DsReplicaObject(ndr, "object", &r->object); - ndr->depth--; - if (r->next_object) { - ndr_print_drsuapi_DsReplicaObjectListItem(ndr, "next_object", r->next_object); - } -} - -void ndr_print_drsuapi_DsReplicaObjectListItemEx(struct ndr_print *ndr, const char *name, const struct drsuapi_DsReplicaObjectListItemEx *r) -{ - ndr_print_struct(ndr, name, "drsuapi_DsReplicaObjectListItemEx"); - ndr->depth++; - ndr_print_ptr(ndr, "next_object", r->next_object); - ndr_print_drsuapi_DsReplicaObject(ndr, "object", &r->object); - ndr_print_uint32(ndr, "is_nc_prefix", r->is_nc_prefix); - ndr_print_ptr(ndr, "parent_object_guid", r->parent_object_guid); - ndr->depth++; - if (r->parent_object_guid) { - ndr_print_GUID(ndr, "parent_object_guid", r->parent_object_guid); - } - ndr->depth--; - ndr_print_ptr(ndr, "meta_data_ctr", r->meta_data_ctr); - ndr->depth++; - if (r->meta_data_ctr) { - ndr_print_drsuapi_DsReplicaMetaDataCtr(ndr, "meta_data_ctr", r->meta_data_ctr); - } - ndr->depth--; - ndr->depth--; - if (r->next_object) { - ndr_print_drsuapi_DsReplicaObjectListItemEx(ndr, "next_object", r->next_object); - } -} - -#define _OID_PUSH_CHECK(call) do { \ - bool _status; \ - _status = call; \ - if (_status != true) { \ - return ndr_push_error(ndr, NDR_ERR_SUBCONTEXT, "OID Conversion Error: %s\n", __location__); \ - } \ -} while (0) - -#define _OID_PULL_CHECK(call) do { \ - bool _status; \ - _status = call; \ - if (_status != true) { \ - return ndr_pull_error(ndr, NDR_ERR_SUBCONTEXT, "OID Conversion Error: %s\n", __location__); \ - } \ -} while (0) - -enum ndr_err_code ndr_push_drsuapi_DsReplicaOID(struct ndr_push *ndr, int ndr_flags, const struct drsuapi_DsReplicaOID *r) -{ - if (ndr_flags & NDR_SCALARS) { - NDR_CHECK(ndr_push_align(ndr, 4)); - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_size_drsuapi_DsReplicaOID_oid(r->oid, 0))); - NDR_CHECK(ndr_push_unique_ptr(ndr, r->oid)); - } - if (ndr_flags & NDR_BUFFERS) { - if (r->oid) { - DATA_BLOB blob; - - if (strncasecmp("ff", r->oid, 2) == 0) { - blob = strhex_to_data_blob(r->oid); - if (!blob.data) { - return ndr_push_error(ndr, NDR_ERR_SUBCONTEXT, - "HEX String Conversion Error: %s\n", - __location__); - } - } else { - _OID_PUSH_CHECK(ber_write_OID_String(&blob, r->oid)); - } - talloc_steal(ndr, blob.data); - - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, blob.length)); - NDR_CHECK(ndr_push_array_uint8(ndr, NDR_SCALARS, blob.data, blob.length)); - } - } - return NDR_ERR_SUCCESS; -} - -enum ndr_err_code ndr_pull_drsuapi_DsReplicaOID(struct ndr_pull *ndr, int ndr_flags, struct drsuapi_DsReplicaOID *r) -{ - uint32_t _ptr_oid; - TALLOC_CTX *_mem_save_oid_0; - if (ndr_flags & NDR_SCALARS) { - NDR_CHECK(ndr_pull_align(ndr, 4)); - NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->__ndr_size)); - if (r->__ndr_size < 0 || r->__ndr_size > 10000) { - return ndr_pull_error(ndr, NDR_ERR_RANGE, "value out of range"); - } - NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_oid)); - if (_ptr_oid) { - NDR_PULL_ALLOC(ndr, r->oid); - } else { - r->oid = NULL; - } - } - if (ndr_flags & NDR_BUFFERS) { - if (r->oid) { - DATA_BLOB _oid_array; - const char *_oid; - - _mem_save_oid_0 = NDR_PULL_GET_MEM_CTX(ndr); - NDR_PULL_SET_MEM_CTX(ndr, ndr, 0); - NDR_CHECK(ndr_pull_array_size(ndr, &r->oid)); - _oid_array.length = ndr_get_array_size(ndr, &r->oid); - NDR_PULL_ALLOC_N(ndr, _oid_array.data, _oid_array.length); - NDR_CHECK(ndr_pull_array_uint8(ndr, NDR_SCALARS, _oid_array.data, _oid_array.length)); - NDR_PULL_SET_MEM_CTX(ndr, _mem_save_oid_0, 0); - - if (_oid_array.length && _oid_array.data[0] == 0xFF) { - _oid = data_blob_hex_string(ndr, &_oid_array); - NDR_ERR_HAVE_NO_MEMORY(_oid); - } else { - _OID_PULL_CHECK(ber_read_OID_String(ndr, _oid_array, &_oid)); - } - data_blob_free(&_oid_array); - talloc_steal(r->oid, _oid); - r->oid = _oid; - } - if (r->oid) { - NDR_CHECK(ndr_check_array_size(ndr, (void*)&r->oid, r->__ndr_size)); - } - } - return NDR_ERR_SUCCESS; -} - -size_t ndr_size_drsuapi_DsReplicaOID_oid(const char *oid, int flags) -{ - DATA_BLOB _blob; - size_t ret = 0; - - if (!oid) return 0; - - if (strncasecmp("ff", oid, 2) == 0) { - _blob = strhex_to_data_blob(oid); - if (_blob.data) { - ret = _blob.length; - } - } else { - if (ber_write_OID_String(&_blob, oid)) { - ret = _blob.length; - } - } - data_blob_free(&_blob); - return ret; -} - -enum ndr_err_code ndr_push_drsuapi_DsGetNCChangesMSZIPCtr1(struct ndr_push *ndr, int ndr_flags, const struct drsuapi_DsGetNCChangesMSZIPCtr1 *r) -{ - if (ndr_flags & NDR_SCALARS) { - uint32_t decompressed_length = 0; - uint32_t compressed_length = 0; - if (r->ts) { - { - struct ndr_push *_ndr_ts; - NDR_CHECK(ndr_push_subcontext_start(ndr, &_ndr_ts, 4, -1)); - { - struct ndr_push *_ndr_ts_compressed; - NDR_CHECK(ndr_push_compression_start(_ndr_ts, &_ndr_ts_compressed, NDR_COMPRESSION_MSZIP, -1)); - NDR_CHECK(ndr_push_drsuapi_DsGetNCChangesCtr1TS(_ndr_ts_compressed, NDR_SCALARS|NDR_BUFFERS, r->ts)); - decompressed_length = _ndr_ts_compressed->offset; - NDR_CHECK(ndr_push_compression_end(_ndr_ts, _ndr_ts_compressed, NDR_COMPRESSION_MSZIP, -1)); - } - compressed_length = _ndr_ts->offset; - talloc_free(_ndr_ts); - } - } - NDR_CHECK(ndr_push_align(ndr, 4)); - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, decompressed_length)); - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, compressed_length)); - NDR_CHECK(ndr_push_unique_ptr(ndr, r->ts)); - } - if (ndr_flags & NDR_BUFFERS) { - if (r->ts) { - { - struct ndr_push *_ndr_ts; - NDR_CHECK(ndr_push_subcontext_start(ndr, &_ndr_ts, 4, -1)); - { - struct ndr_push *_ndr_ts_compressed; - NDR_CHECK(ndr_push_compression_start(_ndr_ts, &_ndr_ts_compressed, NDR_COMPRESSION_MSZIP, -1)); - NDR_CHECK(ndr_push_drsuapi_DsGetNCChangesCtr1TS(_ndr_ts_compressed, NDR_SCALARS|NDR_BUFFERS, r->ts)); - NDR_CHECK(ndr_push_compression_end(_ndr_ts, _ndr_ts_compressed, NDR_COMPRESSION_MSZIP, -1)); - } - NDR_CHECK(ndr_push_subcontext_end(ndr, _ndr_ts, 4, -1)); - } - } - } - return NDR_ERR_SUCCESS; -} - -enum ndr_err_code ndr_push_drsuapi_DsGetNCChangesMSZIPCtr6(struct ndr_push *ndr, int ndr_flags, const struct drsuapi_DsGetNCChangesMSZIPCtr6 *r) -{ - if (ndr_flags & NDR_SCALARS) { - uint32_t decompressed_length = 0; - uint32_t compressed_length = 0; - if (r->ts) { - { - struct ndr_push *_ndr_ts; - NDR_CHECK(ndr_push_subcontext_start(ndr, &_ndr_ts, 4, -1)); - { - struct ndr_push *_ndr_ts_compressed; - NDR_CHECK(ndr_push_compression_start(_ndr_ts, &_ndr_ts_compressed, NDR_COMPRESSION_MSZIP, -1)); - NDR_CHECK(ndr_push_drsuapi_DsGetNCChangesCtr6TS(_ndr_ts_compressed, NDR_SCALARS|NDR_BUFFERS, r->ts)); - decompressed_length = _ndr_ts_compressed->offset; - NDR_CHECK(ndr_push_compression_end(_ndr_ts, _ndr_ts_compressed, NDR_COMPRESSION_MSZIP, -1)); - } - compressed_length = _ndr_ts->offset; - talloc_free(_ndr_ts); - } - } - NDR_CHECK(ndr_push_align(ndr, 4)); - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, decompressed_length)); - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, compressed_length)); - NDR_CHECK(ndr_push_unique_ptr(ndr, r->ts)); - } - if (ndr_flags & NDR_BUFFERS) { - if (r->ts) { - { - struct ndr_push *_ndr_ts; - NDR_CHECK(ndr_push_subcontext_start(ndr, &_ndr_ts, 4, -1)); - { - struct ndr_push *_ndr_ts_compressed; - NDR_CHECK(ndr_push_compression_start(_ndr_ts, &_ndr_ts_compressed, NDR_COMPRESSION_MSZIP, -1)); - NDR_CHECK(ndr_push_drsuapi_DsGetNCChangesCtr6TS(_ndr_ts_compressed, NDR_SCALARS|NDR_BUFFERS, r->ts)); - NDR_CHECK(ndr_push_compression_end(_ndr_ts, _ndr_ts_compressed, NDR_COMPRESSION_MSZIP, -1)); - } - NDR_CHECK(ndr_push_subcontext_end(ndr, _ndr_ts, 4, -1)); - } - } - } - return NDR_ERR_SUCCESS; -} - -enum ndr_err_code ndr_push_drsuapi_DsGetNCChangesXPRESSCtr1(struct ndr_push *ndr, int ndr_flags, const struct drsuapi_DsGetNCChangesXPRESSCtr1 *r) -{ - if (ndr_flags & NDR_SCALARS) { - uint32_t decompressed_length = 0; - uint32_t compressed_length = 0; - if (r->ts) { - { - struct ndr_push *_ndr_ts; - NDR_CHECK(ndr_push_subcontext_start(ndr, &_ndr_ts, 4, -1)); - { - struct ndr_push *_ndr_ts_compressed; - NDR_CHECK(ndr_push_compression_start(_ndr_ts, &_ndr_ts_compressed, NDR_COMPRESSION_XPRESS, -1)); - NDR_CHECK(ndr_push_drsuapi_DsGetNCChangesCtr1TS(_ndr_ts_compressed, NDR_SCALARS|NDR_BUFFERS, r->ts)); - decompressed_length = _ndr_ts_compressed->offset; - NDR_CHECK(ndr_push_compression_end(_ndr_ts, _ndr_ts_compressed, NDR_COMPRESSION_XPRESS, -1)); - } - compressed_length = _ndr_ts->offset; - talloc_free(_ndr_ts); - } - } - NDR_CHECK(ndr_push_align(ndr, 4)); - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, decompressed_length)); - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, compressed_length)); - NDR_CHECK(ndr_push_unique_ptr(ndr, r->ts)); - } - if (ndr_flags & NDR_BUFFERS) { - if (r->ts) { - { - struct ndr_push *_ndr_ts; - NDR_CHECK(ndr_push_subcontext_start(ndr, &_ndr_ts, 4, -1)); - { - struct ndr_push *_ndr_ts_compressed; - NDR_CHECK(ndr_push_compression_start(_ndr_ts, &_ndr_ts_compressed, NDR_COMPRESSION_XPRESS, -1)); - NDR_CHECK(ndr_push_drsuapi_DsGetNCChangesCtr1TS(_ndr_ts_compressed, NDR_SCALARS|NDR_BUFFERS, r->ts)); - NDR_CHECK(ndr_push_compression_end(_ndr_ts, _ndr_ts_compressed, NDR_COMPRESSION_XPRESS, -1)); - } - NDR_CHECK(ndr_push_subcontext_end(ndr, _ndr_ts, 4, -1)); - } - } - } - return NDR_ERR_SUCCESS; -} - -enum ndr_err_code ndr_push_drsuapi_DsGetNCChangesXPRESSCtr6(struct ndr_push *ndr, int ndr_flags, const struct drsuapi_DsGetNCChangesXPRESSCtr6 *r) -{ - if (ndr_flags & NDR_SCALARS) { - uint32_t decompressed_length = 0; - uint32_t compressed_length = 0; - if (r->ts) { - { - struct ndr_push *_ndr_ts; - NDR_CHECK(ndr_push_subcontext_start(ndr, &_ndr_ts, 4, -1)); - { - struct ndr_push *_ndr_ts_compressed; - NDR_CHECK(ndr_push_compression_start(_ndr_ts, &_ndr_ts_compressed, NDR_COMPRESSION_XPRESS, -1)); - NDR_CHECK(ndr_push_drsuapi_DsGetNCChangesCtr6TS(_ndr_ts_compressed, NDR_SCALARS|NDR_BUFFERS, r->ts)); - decompressed_length = _ndr_ts_compressed->offset; - NDR_CHECK(ndr_push_compression_end(_ndr_ts, _ndr_ts_compressed, NDR_COMPRESSION_XPRESS, -1)); - } - compressed_length = _ndr_ts->offset; - talloc_free(_ndr_ts); - } - } - NDR_CHECK(ndr_push_align(ndr, 4)); - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, decompressed_length)); - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, compressed_length)); - NDR_CHECK(ndr_push_unique_ptr(ndr, r->ts)); - } - if (ndr_flags & NDR_BUFFERS) { - if (r->ts) { - { - struct ndr_push *_ndr_ts; - NDR_CHECK(ndr_push_subcontext_start(ndr, &_ndr_ts, 4, -1)); - { - struct ndr_push *_ndr_ts_compressed; - NDR_CHECK(ndr_push_compression_start(_ndr_ts, &_ndr_ts_compressed, NDR_COMPRESSION_XPRESS, -1)); - NDR_CHECK(ndr_push_drsuapi_DsGetNCChangesCtr6TS(_ndr_ts_compressed, NDR_SCALARS|NDR_BUFFERS, r->ts)); - NDR_CHECK(ndr_push_compression_end(_ndr_ts, _ndr_ts_compressed, NDR_COMPRESSION_XPRESS, -1)); - } - NDR_CHECK(ndr_push_subcontext_end(ndr, _ndr_ts, 4, -1)); - } - } - } - return NDR_ERR_SUCCESS; -} diff --git a/source4/librpc/ndr/ndr_drsuapi.h b/source4/librpc/ndr/ndr_drsuapi.h deleted file mode 100644 index c663eadd7a..0000000000 --- a/source4/librpc/ndr/ndr_drsuapi.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - Unix SMB/CIFS implementation. - - routines for printing some linked list structs in DRSUAPI - - Copyright (C) Stefan (metze) Metzmacher 2005-2006 - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. -*/ - -#ifndef _LIBRPC_NDR_NDR_DRSUAPI_H -#define _LIBRPC_NDR_NDR_DRSUAPI_H - -void ndr_print_drsuapi_DsReplicaObjectListItem(struct ndr_print *ndr, const char *name, - const struct drsuapi_DsReplicaObjectListItem *r); - -void ndr_print_drsuapi_DsReplicaObjectListItemEx(struct ndr_print *ndr, const char *name, - const struct drsuapi_DsReplicaObjectListItemEx *r); - -enum ndr_err_code ndr_push_drsuapi_DsReplicaOID(struct ndr_push *ndr, int ndr_flags, const struct drsuapi_DsReplicaOID *r); -enum ndr_err_code ndr_pull_drsuapi_DsReplicaOID(struct ndr_pull *ndr, int ndr_flags, struct drsuapi_DsReplicaOID *r); -size_t ndr_size_drsuapi_DsReplicaOID_oid(const char *oid, int flags); - -#endif /* _LIBRPC_NDR_NDR_DRSUAPI_H */ diff --git a/source4/rpc_server/drsuapi/dcesrv_drsuapi.c b/source4/rpc_server/drsuapi/dcesrv_drsuapi.c index d555ba27bf..a84f24a3e8 100644 --- a/source4/rpc_server/drsuapi/dcesrv_drsuapi.c +++ b/source4/rpc_server/drsuapi/dcesrv_drsuapi.c @@ -337,12 +337,14 @@ WERROR dcesrv_drsuapi_DsCrackNames(struct dcesrv_call_state *dce_call, TALLOC_CT struct drsuapi_bind_state *b_state; struct dcesrv_handle *h; - r->out.level = r->in.level; - ZERO_STRUCT(r->out.ctr); + *r->out.level_out = r->in.level; DCESRV_PULL_HANDLE_WERR(h, r->in.bind_handle, DRSUAPI_BIND_HANDLE); b_state = h->data; + r->out.ctr = talloc_zero(mem_ctx, union drsuapi_DsNameCtr); + W_ERROR_HAVE_NO_MEMORY(r->out.ctr); + switch (r->in.level) { case 1: { struct drsuapi_DsNameCtr1 *ctr1; @@ -353,16 +355,16 @@ WERROR dcesrv_drsuapi_DsCrackNames(struct dcesrv_call_state *dce_call, TALLOC_CT ctr1 = talloc(mem_ctx, struct drsuapi_DsNameCtr1); W_ERROR_HAVE_NO_MEMORY(ctr1); - count = r->in.req.req1.count; + count = r->in.req->req1.count; names = talloc_array(mem_ctx, struct drsuapi_DsNameInfo1, count); W_ERROR_HAVE_NO_MEMORY(names); for (i=0; i < count; i++) { status = DsCrackNameOneName(b_state->sam_ctx, mem_ctx, - r->in.req.req1.format_flags, - r->in.req.req1.format_offered, - r->in.req.req1.format_desired, - r->in.req.req1.names[i].str, + r->in.req->req1.format_flags, + r->in.req->req1.format_offered, + r->in.req->req1.format_desired, + r->in.req->req1.names[i].str, &names[i]); if (!W_ERROR_IS_OK(status)) { return status; @@ -371,7 +373,7 @@ WERROR dcesrv_drsuapi_DsCrackNames(struct dcesrv_call_state *dce_call, TALLOC_CT ctr1->count = count; ctr1->array = names; - r->out.ctr.ctr1 = ctr1; + r->out.ctr->ctr1 = ctr1; return WERR_OK; } @@ -389,17 +391,20 @@ static WERROR dcesrv_drsuapi_DsWriteAccountSpn(struct dcesrv_call_state *dce_cal struct drsuapi_bind_state *b_state; struct dcesrv_handle *h; - r->out.level = r->in.level; + *r->out.level_out = r->in.level; DCESRV_PULL_HANDLE_WERR(h, r->in.bind_handle, DRSUAPI_BIND_HANDLE); b_state = h->data; + r->out.res = talloc(mem_ctx, union drsuapi_DsWriteAccountSpnResult); + W_ERROR_HAVE_NO_MEMORY(r->out.res); + switch (r->in.level) { case 1: { struct drsuapi_DsWriteAccountSpnRequest1 *req; struct ldb_message *msg; int count, i, ret; - req = &r->in.req.req1; + req = &r->in.req->req1; count = req->count; msg = ldb_msg_new(mem_ctx); @@ -409,7 +414,7 @@ static WERROR dcesrv_drsuapi_DsWriteAccountSpn(struct dcesrv_call_state *dce_cal msg->dn = ldb_dn_new(msg, b_state->sam_ctx, req->object_dn); if ( ! ldb_dn_validate(msg->dn)) { - r->out.res.res1.status = WERR_OK; + r->out.res->res1.status = WERR_OK; return WERR_OK; } @@ -440,9 +445,9 @@ static WERROR dcesrv_drsuapi_DsWriteAccountSpn(struct dcesrv_call_state *dce_cal DEBUG(0,("Failed to modify SPNs on %s: %s\n", ldb_dn_get_linearized(msg->dn), ldb_errstring(b_state->sam_ctx))); - r->out.res.res1.status = WERR_ACCESS_DENIED; + r->out.res->res1.status = WERR_ACCESS_DENIED; } else { - r->out.res.res1.status = WERR_OK; + r->out.res->res1.status = WERR_OK; } return WERR_OK; @@ -519,14 +524,16 @@ static WERROR dcesrv_drsuapi_DsGetDomainControllerInfo_1(struct drsuapi_bind_sta int ret, i; - r->out.level_out = r->in.req.req1.level; + *r->out.level_out = r->in.req->req1.level; + r->out.ctr = talloc(mem_ctx, union drsuapi_DsGetDCInfoCtr); + W_ERROR_HAVE_NO_MEMORY(r->out.ctr); sites_dn = samdb_sites_dn(b_state->sam_ctx, mem_ctx); if (!sites_dn) { return WERR_DS_OBJ_NOT_FOUND; } - switch (r->out.level_out) { + switch (*r->out.level_out) { case -1: /* this level is not like the others */ return WERR_UNKNOWN_LEVEL; @@ -549,9 +556,9 @@ static WERROR dcesrv_drsuapi_DsGetDomainControllerInfo_1(struct drsuapi_bind_sta return WERR_GENERAL_FAILURE; } - switch (r->out.level_out) { + switch (*r->out.level_out) { case 1: - ctr1 = &r->out.ctr.ctr1; + ctr1 = &r->out.ctr->ctr1; ctr1->count = res->count; ctr1->array = talloc_zero_array(mem_ctx, struct drsuapi_DsGetDCInfo1, @@ -614,7 +621,7 @@ static WERROR dcesrv_drsuapi_DsGetDomainControllerInfo_1(struct drsuapi_bind_sta } break; case 2: - ctr2 = &r->out.ctr.ctr2; + ctr2 = &r->out.ctr->ctr2; ctr2->count = res->count; ctr2->array = talloc_zero_array(mem_ctx, struct drsuapi_DsGetDCInfo2, diff --git a/source4/selftest/README b/source4/selftest/README deleted file mode 100644 index f8be20a569..0000000000 --- a/source4/selftest/README +++ /dev/null @@ -1,119 +0,0 @@ -# vim: ft=rst - -This directory contains test scripts that are useful for running a -bunch of tests all at once. - -Available testsuites -==================== -The available testsuites are obtained from a script, usually -selftest/samba{3,4}_tests.sh. This script should for each testsuite output -the name of the test, the command to run and the environment that should be -provided. Use the included "plantest" function to generate the required output. - -Testsuite behaviour -================================ - -Exit code ------------- -The testsuites should exit with a non-zero exit code if at least one -test failed. Skipped tests should not influence the exit code. - -Output format -------------- -Testsuites can simply use the exit code to indicate whether all of their -tests have succeeded or one or more have failed. It is also possible to -provide more granular information using the Subunit protocol. - -This protocol works by writing simple messages to standard output. Any -messages that can not be interpreted by this protocol are considered comments -for the last announced test. - -Accepted commands are: - -test -~~~~~~~~~~~~ -test: <NAME> - -Announce that a new test with the specified name is starting - -success -~~~~~~~~~~~~~~~ -success: <NAME> - -Announce that the test with the specified name is done and ran successfully. - -failure -~~~~~~~~~~~~~~~ -failure: <NAME> -failure: <NAME> [ REASON ] - -Announce that the test with the specified name failed. Optionally, it is -possible to specify a reason it failed. - -skip -~~~~~~~~~~~~ -skip: <NAME> -skip: <NAME> [ REASON ] - -Announce that the test with the specified name was skipped. Optionally a -reason can be specified. - -knownfail -~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -knownfail: <NAME> -knownfail: <NAME> [ REASON ] - -Announce that the test with the specified name was run and failed as expected. -Alternatively it is also possible to simply return "failure:" here but -specify in the samba4-knownfailures file that it is failing. - -Environments -============ -Tests often need to run against a server with particular things set up, -a "environment". This environment is provided by the test "target": Samba 3, -Samba 4 or Windows. - -The following environments are currently available: - - - none: No server set up, no variables set. - - dc: Domain controller set up. The following environment variables will - be set: - - * USERNAME: Administrator user name - * PASSWORD: Administrator password - * DOMAIN: Domain name - * REALM: Realm name - * SERVER: DC host name - * SERVER_IP: DC IPv4 address - * NETBIOSNAME: DC NetBIOS name - * NETIOSALIAS: DC NetBIOS alias - - - member: Domain controller and member server that is joined to it set up. The - following environment variables will be set: - - * USERNAME: Domain administrator user name - * PASSWORD: Domain administrator password - * DOMAIN: Domain name - * REALM: Realm name - * SERVER: Name of the member server - - -Running tests -============= - -To run all the tests use:: - - make test - -To run a quick subset (aiming for about 1 minute of testing) run:: - - make quicktest - -To run a specific test, use this syntax:: - - make test TESTS=testname - -for example:: - - make test TESTS=samba4.BASE-DELETE - diff --git a/source4/selftest/SocketWrapper.pm b/source4/selftest/SocketWrapper.pm deleted file mode 100644 index e63605b8df..0000000000 --- a/source4/selftest/SocketWrapper.pm +++ /dev/null @@ -1,66 +0,0 @@ -#!/usr/bin/perl -# Bootstrap Samba and run a number of tests against it. -# Copyright (C) 2005-2007 Jelmer Vernooij <jelmer@samba.org> -# Published under the GNU GPL, v3 or later. - -package SocketWrapper; - -use Exporter; -@ISA = qw(Exporter); -@EXPORT_OK = qw(setup_dir setup_pcap set_default_iface); - -use strict; -use FindBin qw($RealBin); - -sub setup_dir($$) -{ - my ($dir, $pcap) = @_; - my $pcap_dir = undef; - - if (defined($dir)) { - if ( -d $dir ) { - unlink <$dir/*>; - } else { - mkdir($dir, 0777); - } - - if ($pcap) { - $pcap_dir = $dir."/pcap"; - - if ( -d $pcap_dir ) { - unlink <$pcap_dir/*>; - } else { - mkdir($pcap_dir, 0777); - } - } - } - - if (defined($pcap_dir)) { - $ENV{SOCKET_WRAPPER_PCAP_DIR} = $pcap_dir; - } else { - delete $ENV{SOCKET_WRAPPER_PCAP_DIR}; - } - - if (defined($dir)) { - $ENV{SOCKET_WRAPPER_DIR} = $dir; - } else { - delete $ENV{SOCKET_WRAPPER_DIR}; - } - - return $dir; -} - -sub setup_pcap($) -{ - my ($pcap_file) = @_; - - $ENV{SOCKET_WRAPPER_PCAP_FILE} = $pcap_file; -} - -sub set_default_iface($) -{ - my ($i) = @_; - $ENV{SOCKET_WRAPPER_DEFAULT_IFACE} = $i; -} - -1; diff --git a/source4/selftest/Subunit.pm b/source4/selftest/Subunit.pm deleted file mode 100644 index 05e51da541..0000000000 --- a/source4/selftest/Subunit.pm +++ /dev/null @@ -1,97 +0,0 @@ -package Subunit; - -require Exporter; -@ISA = qw(Exporter); -@EXPORT_OK = qw(parse_results); - -use strict; - -sub parse_results($$$$$) -{ - my ($msg_ops, $statistics, $fh, $expecting_failure, $open_tests) = @_; - my $unexpected_ok = 0; - my $expected_fail = 0; - my $unexpected_fail = 0; - my $unexpected_err = 0; - my $orig_open_len = $#$open_tests; - - while(<$fh>) { - if (/^test: (.+)\n/) { - $msg_ops->control_msg($_); - $msg_ops->start_test($open_tests, $1); - push (@$open_tests, $1); - } elsif (/^(success|successful|failure|skip|knownfail|error): (.*?)( \[)?([ \t]*)\n/) { - $msg_ops->control_msg($_); - my $reason = undef; - if ($3) { - $reason = ""; - # reason may be specified in next lines - my $terminated = 0; - while(<$fh>) { - $msg_ops->control_msg($_); - if ($_ eq "]\n") { $terminated = 1; last; } else { $reason .= $_; } - } - - unless ($terminated) { - $statistics->{TESTS_ERROR}++; - $msg_ops->end_test($open_tests, $2, $1, 1, "reason interrupted"); - return 1; - } - } - my $result = $1; - if ($1 eq "success" or $1 eq "successful") { - pop(@$open_tests); #FIXME: Check that popped value == $2 - if ($expecting_failure->(join(".", @$open_tests) . ".$2")) { - $statistics->{TESTS_UNEXPECTED_OK}++; - $msg_ops->end_test($open_tests, $2, $1, 1, $reason); - $unexpected_ok++; - } else { - $statistics->{TESTS_EXPECTED_OK}++; - $msg_ops->end_test($open_tests, $2, $1, 0, $reason); - } - } elsif ($1 eq "failure") { - pop(@$open_tests); #FIXME: Check that popped value == $2 - if ($expecting_failure->(join(".", @$open_tests) . ".$2")) { - $statistics->{TESTS_EXPECTED_FAIL}++; - $msg_ops->end_test($open_tests, $2, $1, 0, $reason); - $expected_fail++; - } else { - $statistics->{TESTS_UNEXPECTED_FAIL}++; - $msg_ops->end_test($open_tests, $2, $1, 1, $reason); - $unexpected_fail++; - } - } elsif ($1 eq "knownfail") { - pop(@$open_tests); #FIXME: Check that popped value == $2 - $statistics->{TESTS_EXPECTED_FAIL}++; - $msg_ops->end_test($open_tests, $2, $1, 0, $reason); - } elsif ($1 eq "skip") { - $statistics->{TESTS_SKIP}++; - pop(@$open_tests); #FIXME: Check that popped value == $2 - $msg_ops->end_test($open_tests, $2, $1, 0, $reason); - } elsif ($1 eq "error") { - $statistics->{TESTS_ERROR}++; - pop(@$open_tests); #FIXME: Check that popped value == $2 - $msg_ops->end_test($open_tests, $2, $1, 1, $reason); - $unexpected_err++; - } - } else { - $msg_ops->output_msg($_); - } - } - - while ($#$open_tests > $orig_open_len) { - $msg_ops->end_test($open_tests, pop(@$open_tests), "error", 1, - "was started but never finished!"); - $statistics->{TESTS_ERROR}++; - $unexpected_err++; - } - - return 1 if $unexpected_err > 0; - return 1 if $unexpected_fail > 0; - return 1 if $unexpected_ok > 0 and $expected_fail > 0; - return 0 if $unexpected_ok > 0 and $expected_fail == 0; - return 0 if $expected_fail > 0; - return 1; -} - -1; diff --git a/source4/selftest/TODO b/source4/selftest/TODO deleted file mode 100644 index 67776ffc76..0000000000 --- a/source4/selftest/TODO +++ /dev/null @@ -1,2 +0,0 @@ -- warn about unexpected successes -- better way to detect that smbd has finished initialization diff --git a/source4/selftest/config.mk b/source4/selftest/config.mk index 58db087105..74c177d8e8 100644 --- a/source4/selftest/config.mk +++ b/source4/selftest/config.mk @@ -2,12 +2,12 @@ TEST_FORMAT = plain SELFTEST = $(LD_LIBPATH_OVERRIDE) $(PERL) $(selftestdir)/selftest.pl --prefix=${selftest_prefix} \ --builddir=$(builddir) --srcdir=$(srcdir) \ - --expected-failures=$(srcdir)/samba4-knownfail \ + --expected-failures=$(srcdir)/selftest/knownfail \ --format=$(TEST_FORMAT) \ - --exclude=$(srcdir)/samba4-skip --testlist="./selftest/samba4_tests.sh|" \ + --exclude=$(srcdir)/selftest/skip --testlist="./selftest/tests.sh|" \ $(TEST_OPTIONS) -SELFTEST_NOSLOW_OPTS = --exclude=$(srcdir)/samba4-slow +SELFTEST_NOSLOW_OPTS = --exclude=$(srcdir)/selftest/slow SELFTEST_QUICK_OPTS = $(SELFTEST_NOSLOW_OPTS) --quick slowtest:: everything diff --git a/source4/samba4-knownfail b/source4/selftest/knownfail index f99db4fb1b..f99db4fb1b 100644 --- a/source4/samba4-knownfail +++ b/source4/selftest/knownfail diff --git a/source4/selftest/output/buildfarm.pm b/source4/selftest/output/buildfarm.pm deleted file mode 100644 index cee6c1e63a..0000000000 --- a/source4/selftest/output/buildfarm.pm +++ /dev/null @@ -1,120 +0,0 @@ -#!/usr/bin/perl - -package output::buildfarm; - -use Exporter; -@ISA = qw(Exporter); - -use FindBin qw($RealBin); -use lib "$RealBin/.."; - -use Subunit qw(parse_results); - -use strict; - -sub new($$$) { - my ($class) = @_; - my $self = { - test_output => {}, - start_time => time() - }; - bless($self, $class); -} - -sub start_testsuite($$) -{ - my ($self, $name) = @_; - my $out = ""; - - $self->{NAME} = $name; - $self->{START_TIME} = time(); - - my $duration = $self->{START_TIME} - $self->{start_time}; - $out .= "--==--==--==--==--==--==--==--==--==--==--\n"; - $out .= "Running test $name (level 0 stdout)\n"; - $out .= "--==--==--==--==--==--==--==--==--==--==--\n"; - $out .= scalar(localtime())."\n"; - $out .= "SELFTEST RUNTIME: " . $duration . "s\n"; - $out .= "NAME: $name\n"; - - $self->{test_output}->{$name} = ""; - - print $out; -} - -sub output_msg($$) -{ - my ($self, $output) = @_; - - $self->{test_output}->{$self->{NAME}} .= $output; -} - -sub control_msg($$) -{ - my ($self, $output) = @_; - - $self->{test_output}->{$self->{NAME}} .= $output; -} - -sub end_testsuite($$$$$$) -{ - my ($self, $name, $result, $unexpected, $reason) = @_; - my $out = ""; - - $out .= "TEST RUNTIME: " . (time() - $self->{START_TIME}) . "s\n"; - - if (not $unexpected) { - $out .= "ALL OK\n"; - } else { - $out .= "ERROR: $reason\n"; - $out .= $self->{test_output}->{$name}; - } - - $out .= "==========================================\n"; - if (not $unexpected) { - $out .= "TEST PASSED: $name\n"; - } else { - $out .= "TEST FAILED: $name (status $reason)\n"; - } - $out .= "==========================================\n"; - - print $out; -} - -sub start_test($$$) -{ - my ($self, $parents, $testname) = @_; - - if ($#$parents == -1) { - $self->start_testsuite($testname); - } -} - -sub end_test($$$$$) -{ - my ($self, $parents, $testname, $result, $unexpected, $reason) = @_; - - if ($unexpected) { - $self->{test_output}->{$self->{NAME}} .= "UNEXPECTED($result): $testname\n"; - } - - if ($#$parents == -1) { - $self->end_testsuite($testname, $result, $unexpected, $reason); - } -} - -sub summary($) -{ - my ($self) = @_; - - print "DURATION: " . (time() - $self->{start_time}) . " seconds\n"; -} - -sub skip_testsuite($$$$) -{ - my ($self, $name, $reason) = @_; - - print "SKIPPED: $name\n"; -} - -1; diff --git a/source4/selftest/output/html.pm b/source4/selftest/output/html.pm deleted file mode 100644 index 1049527129..0000000000 --- a/source4/selftest/output/html.pm +++ /dev/null @@ -1,354 +0,0 @@ -#!/usr/bin/perl - -package output::html; -use Exporter; -@ISA = qw(Exporter); - -use strict; -use warnings; - -use FindBin qw($RealBin); -use lib "$RealBin/.."; - -use Subunit qw(parse_results); - -sub new($$$) { - my ($class, $dirname, $statistics) = @_; - my $self = { - dirname => $dirname, - active_test => undef, - local_statistics => {}, - statistics => $statistics, - msg => "", - error_summary => { - skip => [], - expected_success => [], - unexpected_success => [], - expected_failure => [], - unexpected_failure => [], - skip_testsuites => [], - error => [] - } - }; - - link("$RealBin/output/testresults.css", "$dirname/testresults.css"); - - open(INDEX, ">$dirname/index.html"); - - bless($self, $class); - - $self->print_html_header("Samba Testsuite Run", *INDEX); - - print INDEX " <center>"; - print INDEX " <table>\n"; - print INDEX " <tr>\n"; - print INDEX " <td class=\"tableHead\">Test</td>\n"; - print INDEX " <td class=\"tableHead\">Result</td>\n"; - print INDEX " </tr>\n"; - - return $self; -} - -sub print_html_header($$$) -{ - my ($self, $title, $fh) = @_; - - print $fh "<html lang=\"en\">\n"; - print $fh "<head>\n"; - print $fh " <title>$title</title>\n"; - print $fh " <link rel=\"stylesheet\" type=\"text/css\" href=\"testresults.css\"/>\n"; - print $fh "</head>\n"; - print $fh "<body>\n"; - print $fh "<table width=\"100%\" border=\"0\" cellspacing=\"0\">\n"; - print $fh " <tr><td class=\"title\">$title</td></tr>\n"; - print $fh " <tr><td>\n"; -} - -sub print_html_footer($$) -{ - my ($self, $fh) = @_; - - print $fh "</td></tr>\n"; - print $fh "</table>\n"; - print $fh "</body>\n"; - print $fh "</html>\n"; -} - -sub output_msg($$); - -sub start_testsuite($$) -{ - my ($self, $name) = @_; - - $self->{local_statistics} = { - success => 0, - skip => 0, - error => 0, - failure => 0 - }; - - $self->{NAME} = $name; - $self->{HTMLFILE} = "$name.html"; - $self->{HTMLFILE} =~ s/[:\t\n \/]/_/g; - - open(TEST, ">$self->{dirname}/$self->{HTMLFILE}") or die("Unable to open $self->{HTMLFILE} for writing"); - - $self->print_html_header("Test Results for $name", *TEST); - - print TEST "<h2>Tests</h2>\n"; - - print TEST " <table>\n"; -} - -sub control_msg($$) -{ - my ($self, $output) = @_; - - $self->{msg} .= "<span class=\"control\">$output<br/></span>\n"; -} - -sub output_msg($$) -{ - my ($self, $output) = @_; - - unless (defined($self->{active_test})) { - print TEST "$output<br/>"; - } else { - $self->{msg} .= "$output<br/>"; - } -} - -sub end_testsuite($$$$) -{ - my ($self, $name, $result, $unexpected, $reason) = @_; - - print TEST "</table>\n"; - - print TEST "<div class=\"duration\">Duration: " . (time() - $self->{START_TIME}) . "s</div>\n"; - - $self->print_html_footer(*TEST); - - close(TEST); - - print INDEX "<tr>\n"; - print INDEX " <td class=\"testSuite\"><a href=\"$self->{HTMLFILE}\">$name</a></td>\n"; - my $st = $self->{local_statistics}; - - if (not $unexpected) { - if ($result eq "failure") { - print INDEX " <td class=\"resultExpectedFailure\">"; - } else { - print INDEX " <td class=\"resultOk\">"; - } - } else { - print INDEX " <td class=\"resultFailure\">"; - } - - my $l = 0; - if ($st->{success} > 0) { - print INDEX "$st->{success} ok"; - $l++; - } - if ($st->{skip} > 0) { - print INDEX ", " if ($l); - print INDEX "$st->{skip} skipped"; - $l++; - } - if ($st->{failure} > 0) { - print INDEX ", " if ($l); - print INDEX "$st->{failure} failures"; - $l++; - } - if ($st->{error} > 0) { - print INDEX ", " if ($l); - print INDEX "$st->{error} errors"; - $l++; - } - - if ($l == 0) { - if (not $unexpected) { - print INDEX "OK"; - } else { - print INDEX "FAIL"; - } - } - - print INDEX "</td>"; - - print INDEX "</tr>\n"; -} - -sub start_test($$) -{ - my ($self, $parents, $testname) = @_; - - if ($#$parents == -1) { - $self->{START_TIME} = time(); - $self->start_testsuite($testname); - return; - } - - $self->{active_test} = $testname; - $self->{msg} = ""; -} - -sub end_test($$$$$$) -{ - my ($self, $parents, $testname, $result, $unexpected, $reason) = @_; - - if ($#$parents == -1) { - $self->end_testsuite($testname, $result, $unexpected, $reason); - return; - } - - print TEST "<tr>"; - - $self->{local_statistics}->{$result}++; - - my $track_class; - - if ($result eq "skip") { - print TEST "<td class=\"outputSkipped\">\n"; - $track_class = "skip"; - } elsif ($unexpected) { - print TEST "<td class=\"outputFailure\">\n"; - if ($result eq "error") { - $track_class = "error"; - } else { - $track_class = "unexpected_$result"; - } - } else { - if ($result eq "failure") { - print TEST "<td class=\"outputExpectedFailure\">\n"; - } else { - print TEST "<td class=\"outputOk\">\n"; - } - $track_class = "expected_$result"; - } - - push(@{$self->{error_summary}->{$track_class}}, , - [$self->{HTMLFILE}, $testname, $self->{NAME}, - $reason]); - - print TEST "<a name=\"$testname\"><h3>$testname</h3></a>\n"; - - print TEST $self->{msg}; - - if (defined($reason)) { - print TEST "<div class=\"reason\">$reason</div>\n"; - } - - print TEST "</td></tr>\n"; - - $self->{active_test} = undef; -} - -sub summary($) -{ - my ($self) = @_; - - my $st = $self->{statistics}; - print INDEX "<tr>\n"; - print INDEX " <td class=\"testSuiteTotal\">Total</td>\n"; - - if ($st->{TESTS_UNEXPECTED_OK} == 0 and - $st->{TESTS_UNEXPECTED_FAIL} == 0 and - $st->{TESTS_ERROR} == 0) { - print INDEX " <td class=\"resultOk\">"; - } else { - print INDEX " <td class=\"resultFailure\">"; - } - print INDEX ($st->{TESTS_EXPECTED_OK} + $st->{TESTS_UNEXPECTED_OK}) . " ok"; - if ($st->{TESTS_UNEXPECTED_OK} > 0) { - print INDEX " ($st->{TESTS_UNEXPECTED_OK} unexpected)"; - } - if ($st->{TESTS_SKIP} > 0) { - print INDEX ", $st->{TESTS_SKIP} skipped"; - } - if (($st->{TESTS_UNEXPECTED_FAIL} + $st->{TESTS_EXPECTED_FAIL}) > 0) { - print INDEX ", " . ($st->{TESTS_UNEXPECTED_FAIL} + $st->{TESTS_EXPECTED_FAIL}) . " failures"; - if ($st->{TESTS_UNEXPECTED_FAIL} > 0) { - print INDEX " ($st->{TESTS_EXPECTED_FAIL} expected)"; - } - } - if ($st->{TESTS_ERROR} > 0) { - print INDEX ", $st->{TESTS_ERROR} errors"; - } - - print INDEX "</td>"; - - print INDEX "</tr>\n"; - - print INDEX "</table>\n"; - print INDEX "<a href=\"summary.html\">Summary</a>\n"; - print INDEX "</center>\n"; - $self->print_html_footer(*INDEX); - close(INDEX); - - my $summ = $self->{error_summary}; - open(SUMMARY, ">$self->{dirname}/summary.html"); - $self->print_html_header("Summary", *SUMMARY); - sub print_table($$) { - my ($title, $list) = @_; - return if ($#$list == -1); - print SUMMARY "<h3>$title</h3>\n"; - print SUMMARY "<table>\n"; - print SUMMARY "<tr>\n"; - print SUMMARY " <td class=\"tableHead\">Testsuite</td>\n"; - print SUMMARY " <td class=\"tableHead\">Test</td>\n"; - print SUMMARY " <td class=\"tableHead\">Reason</td>\n"; - print SUMMARY "</tr>\n"; - - foreach (@$list) { - print SUMMARY "<tr>\n"; - print SUMMARY " <td><a href=\"" . $$_[0] . "\">$$_[2]</a></td>\n"; - print SUMMARY " <td><a href=\"" . $$_[0] . "#$$_[1]\">$$_[1]</a></td>\n"; - if (defined($$_[3])) { - print SUMMARY " <td>$$_[3]</td>\n"; - } else { - print SUMMARY " <td></td>\n"; - } - print SUMMARY "</tr>\n"; - } - - print SUMMARY "</table>"; - } - print_table("Errors", $summ->{error}); - print_table("Unexpected successes", $summ->{unexpected_success}); - print_table("Unexpected failures", $summ->{unexpected_failure}); - print_table("Skipped tests", $summ->{skip}); - print_table("Expected failures", $summ->{expected_failure}); - - print SUMMARY "<h3>Skipped testsuites</h3>\n"; - print SUMMARY "<table>\n"; - print SUMMARY "<tr>\n"; - print SUMMARY " <td class=\"tableHead\">Testsuite</td>\n"; - print SUMMARY " <td class=\"tableHead\">Reason</td>\n"; - print SUMMARY "</tr>\n"; - - foreach (@{$summ->{skip_testsuites}}) { - print SUMMARY "<tr>\n"; - print SUMMARY " <td>$$_[0]</td>\n"; - if (defined($$_[1])) { - print SUMMARY " <td>$$_[1]</td>\n"; - } else { - print SUMMARY " <td></td>\n"; - } - print SUMMARY "</tr>\n"; - } - - print SUMMARY "</table>"; - - $self->print_html_footer(*SUMMARY); - close(SUMMARY); -} - -sub skip_testsuite($$$$) -{ - my ($self, $name, $reason) = @_; - - push (@{$self->{error_summary}->{skip_testsuites}}, - [$name, $reason]); -} - -1; diff --git a/source4/selftest/output/plain.pm b/source4/selftest/output/plain.pm deleted file mode 100644 index 4e1e290534..0000000000 --- a/source4/selftest/output/plain.pm +++ /dev/null @@ -1,212 +0,0 @@ -#!/usr/bin/perl - -package output::plain; -use Exporter; -@ISA = qw(Exporter); - -use FindBin qw($RealBin); -use lib "$RealBin/.."; - -use strict; - -sub new($$$$$$$) { - my ($class, $summaryfile, $verbose, $immediate, $statistics, $totaltests) = @_; - my $self = { - verbose => $verbose, - immediate => $immediate, - statistics => $statistics, - start_time => time(), - test_output => {}, - suitesfailed => [], - suites_ok => 0, - skips => {}, - summaryfile => $summaryfile, - index => 0, - totalsuites => $totaltests, - }; - bless($self, $class); -} - -sub output_msg($$); - -sub start_testsuite($$) -{ - my ($self, $name) = @_; - - $self->{index}++; - $self->{NAME} = $name; - $self->{START_TIME} = time(); - - my $duration = $self->{START_TIME} - $self->{start_time}; - - $self->{test_output}->{$name} = "" unless($self->{verbose}); - - my $out = ""; - $out .= "[$self->{index}/$self->{totalsuites} in ".$duration."s"; - $out .= sprintf(", %d errors", ($#{$self->{suitesfailed}}+1)) if ($#{$self->{suitesfailed}} > -1); - $out .= "] $name"; - if ($self->{immediate}) { - print "$out\n"; - } else { - print "$out: "; - } -} - -sub output_msg($$) -{ - my ($self, $output) = @_; - - if ($self->{verbose}) { - require FileHandle; - print $output; - STDOUT->flush(); - } else { - $self->{test_output}->{$self->{NAME}} .= $output; - } -} - -sub control_msg($$) -{ - my ($self, $output) = @_; - - $self->output_msg($output); -} - -sub end_testsuite($$$$$) -{ - my ($self, $name, $result, $unexpected, $reason) = @_; - my $out = ""; - - if ($unexpected) { - if ($result eq "success" and not defined($reason)) { - $reason = "Expected negative exit code, got positive exit code"; - } - $self->output_msg("ERROR: $reason\n"); - push (@{$self->{suitesfailed}}, $name); - } else { - $self->{suites_ok}++; - } - - if ($unexpected and $self->{immediate} and not $self->{verbose}) { - $out .= $self->{test_output}->{$name}; - } - - if (not $self->{immediate}) { - if (not $unexpected) { - $out .= " ok\n"; - } else { - $out .= " " . uc($result) . "\n"; - } - } - - print $out; -} - -sub start_test($$$) -{ - my ($self, $parents, $testname) = @_; - - if ($#$parents == -1) { - $self->start_testsuite($testname); - } -} - -sub end_test($$$$$) -{ - my ($self, $parents, $testname, $result, $unexpected, $reason) = @_; - - if ($#$parents == -1) { - $self->end_testsuite($testname, $result, $unexpected, $reason); - return; - } - - my $append = ""; - - unless ($unexpected) { - $self->{test_output}->{$self->{NAME}} = ""; - if (not $self->{immediate}) { - if ($result eq "failure") { print "f"; } - elsif ($result eq "skip") { print "s"; } - elsif ($result eq "success") { print "."; } - else { print "?($result)"; } - } - return; - } - - my $fullname = join(".", @$parents).".$testname"; - - $append = "UNEXPECTED($result): $testname ($fullname)\n"; - - $self->{test_output}->{$self->{NAME}} .= $append; - - if ($self->{immediate} and not $self->{verbose}) { - print $self->{test_output}->{$self->{NAME}}; - $self->{test_output}->{$self->{NAME}} = ""; - } - - if (not $self->{immediate}) { - if ($result eq "error") { print "E"; } - elsif ($result eq "failure") { print "F"; } - elsif ($result eq "success") { print "S"; } - else { print "?"; } - } -} - -sub summary($) -{ - my ($self) = @_; - - open(SUMMARY, ">$self->{summaryfile}"); - - if ($#{$self->{suitesfailed}} > -1) { - print SUMMARY "= Failed tests =\n"; - - foreach (@{$self->{suitesfailed}}) { - print SUMMARY "== $_ ==\n"; - print SUMMARY $self->{test_output}->{$_}."\n\n"; - } - - print SUMMARY "\n"; - } - - if (not $self->{immediate} and not $self->{verbose}) { - foreach (@{$self->{suitesfailed}}) { - print "===============================================================================\n"; - print "FAIL: $_\n"; - print $self->{test_output}->{$_}; - print "\n"; - } - } - - print SUMMARY "= Skipped tests =\n"; - foreach my $reason (keys %{$self->{skips}}) { - print SUMMARY "$reason\n"; - foreach my $name (@{$self->{skips}->{$reason}}) { - print SUMMARY "\t$name\n"; - } - print SUMMARY "\n"; - } - close(SUMMARY); - - print "\nA summary with detailed informations can be found in:\n $self->{summaryfile}\n"; - - if ($#{$self->{suitesfailed}} == -1) { - my $ok = $self->{statistics}->{TESTS_EXPECTED_OK} + - $self->{statistics}->{TESTS_EXPECTED_FAIL}; - print "\nALL OK ($ok tests in $self->{suites_ok} testsuites)\n"; - } else { - print "\nFAILED ($self->{statistics}->{TESTS_UNEXPECTED_FAIL} failures and $self->{statistics}->{TESTS_ERROR} errors in ". ($#{$self->{suitesfailed}}+1) ." testsuites)\n"; - } - -} - -sub skip_testsuite($$) -{ - my ($self, $name, $reason) = @_; - - push (@{$self->{skips}->{$reason}}, $name); - - $self->{totalsuites}--; -} - -1; diff --git a/source4/selftest/output/testresults.css b/source4/selftest/output/testresults.css deleted file mode 100644 index 66d1d6b2ad..0000000000 --- a/source4/selftest/output/testresults.css +++ /dev/null @@ -1,129 +0,0 @@ -/* Stylesheet for Samba test results. - * - * Partially based on the CSS file from lcov. - */ - -/* All views: main title format */ -td.title -{ - text-align: center; - padding-bottom: 10px; - font-family: sans-serif; - font-size: 20pt; - font-style: italic; - font-weight: bold; -} - -/* Index table headers */ -td.tableHead -{ - text-align: center; - color: #FFFFFF; - background-color: #6688D4; - font-family: sans-serif; - font-size: 120%; - font-weight: bold; -} - -/* Testsuite names */ -td.testSuite -{ - text-align: left; - padding-left: 10px; - padding-right: 20px; - color: #284FA8; - background-color: #DAE7FE; - font-family: monospace; -} - -/* Successful */ -td.resultOk -{ - text-align: right; - padding-left: 10px; - padding-right: 10px; - background-color: #A7FC9D; - font-weight: bold; -} - -/* Failure */ -td.resultFailure -{ - text-align: right; - padding-left: 10px; - padding-right: 10px; - background-color: #FF0000; - font-weight: bold; -} - -/* Expected failure */ -td.resultExpectedFailure -{ - text-align: right; - padding-left: 10px; - padding-right: 10px; - background-color: #FFA500; - font-weight: bold; -} - -/* Skipped */ -td.resultSkipped -{ - text-align: center; - padding-left: 10px; - padding-right: 10px; - background-color: #FFEA20; - font-weight: bold; -} - -td.duration -{ - text-align: right; -} - -td.durationSkipped -{ - text-align: right; -} - -td.outputSkipped -{ - background-color: #FFEA20; -} - -td.outputOk -{ - background-color: #A7FC9D; -} - -td.outputFailure -{ - background-color: #FF0000; -} - -td.outputExpectedFailure -{ - background-color: #FFA500; -} - -div.reason -{ - text-align: center; - font-weight: bold; -} - -span.control -{ - display: none; -} - -div.duration -{ - text-align: right; - font-weight: bold; -} - -div.command -{ - background-color: gray; -} diff --git a/source4/samba4-quick b/source4/selftest/quick index 7bea619f18..7bea619f18 100644 --- a/source4/samba4-quick +++ b/source4/selftest/quick diff --git a/source4/selftest/selftest.pl b/source4/selftest/selftest.pl deleted file mode 100755 index 92aa67e8d3..0000000000 --- a/source4/selftest/selftest.pl +++ /dev/null @@ -1,871 +0,0 @@ -#!/usr/bin/perl -# Bootstrap Samba and run a number of tests against it. -# Copyright (C) 2005-2008 Jelmer Vernooij <jelmer@samba.org> -# Published under the GNU GPL, v3 or later. - -=pod - -=head1 NAME - -selftest - Samba test runner - -=head1 SYNOPSIS - -selftest --help - -selftest [--srcdir=DIR] [--builddir=DIR] [--target=samba4|samba3|win|kvm] [--socket-wrapper] [--quick] [--exclude=FILE] [--include=FILE] [--one] [--prefix=prefix] [--immediate] [--testlist=FILE] [TESTS] - -=head1 DESCRIPTION - -A simple test runner. TESTS is a regular expression with tests to run. - -=head1 OPTIONS - -=over 4 - -=item I<--help> - -Show list of available options. - -=item I<--srcdir=DIR> - -Source directory. - -=item I<--builddir=DIR> - -Build directory. - -=item I<--prefix=DIR> - -Change directory to run tests in. Default is 'st'. - -=item I<--immediate> - -Show errors as soon as they happen rather than at the end of the test run. - -=item I<--target samba4|samba3|win|kvm> - -Specify test target against which to run. Default is 'samba4'. - -=item I<--quick> - -Run only a limited number of tests. Intended to run in about 30 seconds on -moderately recent systems. - -=item I<--socket-wrapper> - -Use socket wrapper library for communication with server. Only works -when the server is running locally. - -Will prevent TCP and UDP ports being opened on the local host but -(transparently) redirects these calls to use unix domain sockets. - -=item I<--expected-failures> - -Specify a file containing a list of tests that are expected to fail. Failures for -these tests will be counted as successes, successes will be counted as failures. - -The format for the file is, one entry per line: - -TESTSUITE-NAME.TEST-NAME - -The reason for a test can also be specified, by adding a hash sign (#) and the reason -after the test name. - -=item I<--exclude> - -Specify a file containing a list of tests that should be skipped. Possible -candidates are tests that segfault the server, flip or don't end. The format of this file is the same as -for the --expected-failures flag. - -=item I<--include> - -Specify a file containing a list of tests that should be run. Same format -as the --exclude flag. - -Not includes specified means all tests will be run. - -=item I<--one> - -Abort as soon as one test fails. - -=item I<--testlist> - -Load a list of tests from the specified location. - -=back - -=head1 ENVIRONMENT - -=over 4 - -=item I<SMBD_VALGRIND> - -=item I<TORTURE_MAXTIME> - -=item I<VALGRIND> - -=item I<TLS_ENABLED> - -=item I<srcdir> - -=back - -=head1 LICENSE - -selftest is licensed under the GNU General Public License L<http://www.gnu.org/licenses/gpl.html>. - -=head1 AUTHOR - -Jelmer Vernooij - -=cut - -use strict; - -use FindBin qw($RealBin $Script); -use File::Spec; -use Getopt::Long; -use POSIX; -use Cwd qw(abs_path); -use lib "$RealBin"; -use Subunit qw(parse_results); -use SocketWrapper; - -my $opt_help = 0; -my $opt_target = "samba4"; -my $opt_quick = 0; -my $opt_socket_wrapper = 0; -my $opt_socket_wrapper_pcap = undef; -my $opt_socket_wrapper_keep_pcap = undef; -my $opt_one = 0; -my $opt_immediate = 0; -my $opt_expected_failures = undef; -my @opt_exclude = (); -my @opt_include = (); -my $opt_verbose = 0; -my $opt_image = undef; -my $opt_testenv = 0; -my $ldap = undef; -my $opt_analyse_cmd = undef; -my $opt_resetup_env = undef; -my $opt_bindir = undef; -my $opt_no_lazy_setup = undef; -my $opt_format = "plain"; -my @testlists = (); - -my $srcdir = "."; -my $builddir = "."; -my $prefix = "./st"; - -my @expected_failures = (); -my @includes = (); -my @excludes = (); - -my $statistics = { - SUITES_FAIL => 0, - - TESTS_UNEXPECTED_OK => 0, - TESTS_EXPECTED_OK => 0, - TESTS_UNEXPECTED_FAIL => 0, - TESTS_EXPECTED_FAIL => 0, - TESTS_ERROR => 0, - TESTS_SKIP => 0, -}; - -sub find_in_list($$) -{ - my ($list, $fullname) = @_; - - foreach (@$list) { - if ($fullname =~ /$$_[0]/) { - return ($$_[1]) if ($$_[1]); - return "NO REASON SPECIFIED"; - } - } - - return undef; -} - -sub expecting_failure($) -{ - my ($name) = @_; - return find_in_list(\@expected_failures, $name); -} - -sub skip($) -{ - my ($name) = @_; - - return find_in_list(\@excludes, $name); -} - -sub getlog_env($); - -sub setup_pcap($) -{ - my ($name) = @_; - - return unless ($opt_socket_wrapper_pcap); - return unless defined($ENV{SOCKET_WRAPPER_PCAP_DIR}); - - my $fname = $name; - $fname =~ s%[^abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789\-]%_%g; - - my $pcap_file = "$ENV{SOCKET_WRAPPER_PCAP_DIR}/$fname.pcap"; - - SocketWrapper::setup_pcap($pcap_file); - - return $pcap_file; -} - -sub cleanup_pcap($$$) -{ - my ($pcap_file, $expected_ret, $ret) = @_; - - return unless ($opt_socket_wrapper_pcap); - return if ($opt_socket_wrapper_keep_pcap); - return unless ($expected_ret == $ret); - return unless defined($pcap_file); - - unlink($pcap_file); -} - -sub run_testsuite($$$$$$) -{ - my ($envname, $name, $cmd, $i, $totalsuites, $msg_ops) = @_; - my $pcap_file = setup_pcap($name); - - $msg_ops->start_test([], $name); - - unless (open(RESULT, "$cmd 2>&1|")) { - $statistics->{TESTS_ERROR}++; - $msg_ops->end_test([], $name, "error", 1, "Unable to run $cmd: $!"); - $statistics->{SUITES_FAIL}++; - return 0; - } - - my $expected_ret = parse_results( - $msg_ops, $statistics, *RESULT, \&expecting_failure, [$name]); - - my $envlog = getlog_env($envname); - $msg_ops->output_msg("ENVLOG: $envlog\n") if ($envlog ne ""); - - $msg_ops->output_msg("CMD: $cmd\n"); - - my $ret = close(RESULT); - $ret = 0 unless $ret == 1; - - my $exitcode = $? >> 8; - - if ($ret == 1) { - $msg_ops->end_test([], $name, "success", $expected_ret != $ret, undef); - } else { - $msg_ops->end_test([], $name, "failure", $expected_ret != $ret, "Exit code was $exitcode"); - } - - cleanup_pcap($pcap_file, $expected_ret, $ret); - - if (not $opt_socket_wrapper_keep_pcap and defined($pcap_file)) { - $msg_ops->output_msg("PCAP FILE: $pcap_file\n"); - } - - if ($ret != $expected_ret) { - $statistics->{SUITES_FAIL}++; - exit(1) if ($opt_one); - } - - return ($ret == $expected_ret); -} - -sub ShowHelp() -{ - print "Samba test runner -Copyright (C) Jelmer Vernooij <jelmer\@samba.org> - -Usage: $Script [OPTIONS] PREFIX - -Generic options: - --help this help page - --target=samba[34]|win|kvm Samba version to target - --testlist=FILE file to read available tests from - -Paths: - --prefix=DIR prefix to run tests in [st] - --srcdir=DIR source directory [.] - --builddir=DIR output directory [.] - -Target Specific: - --socket-wrapper-pcap save traffic to pcap directories - --socket-wrapper-keep-pcap keep all pcap files, not just those for tests that - failed - --socket-wrapper enable socket wrapper - --expected-failures=FILE specify list of tests that is guaranteed to fail - -Samba4 Specific: - --ldap=openldap|fedora-ds back samba onto specified ldap server - -Samba3 Specific: - --bindir=PATH path to binaries - -Kvm Specific: - --image=PATH path to KVM image - -Behaviour: - --quick run quick overall test - --one abort when the first test fails - --immediate print test output for failed tests during run - --verbose be verbose - --analyse-cmd CMD command to run after each test -"; - exit(0); -} - -my $result = GetOptions ( - 'help|h|?' => \$opt_help, - 'target=s' => \$opt_target, - 'prefix=s' => \$prefix, - 'socket-wrapper' => \$opt_socket_wrapper, - 'socket-wrapper-pcap' => \$opt_socket_wrapper_pcap, - 'socket-wrapper-keep-pcap' => \$opt_socket_wrapper_keep_pcap, - 'quick' => \$opt_quick, - 'one' => \$opt_one, - 'immediate' => \$opt_immediate, - 'expected-failures=s' => \$opt_expected_failures, - 'exclude=s' => \@opt_exclude, - 'include=s' => \@opt_include, - 'srcdir=s' => \$srcdir, - 'builddir=s' => \$builddir, - 'verbose' => \$opt_verbose, - 'testenv' => \$opt_testenv, - 'ldap:s' => \$ldap, - 'analyse-cmd=s' => \$opt_analyse_cmd, - 'no-lazy-setup' => \$opt_no_lazy_setup, - 'resetup-environment' => \$opt_resetup_env, - 'bindir:s' => \$opt_bindir, - 'format=s' => \$opt_format, - 'image=s' => \$opt_image, - 'testlist=s' => \@testlists - ); - -exit(1) if (not $result); - -ShowHelp() if ($opt_help); - -my $tests = shift; - -# quick hack to disable rpc validation when using valgrind - its way too slow -unless (defined($ENV{VALGRIND})) { - $ENV{VALIDATE} = "validate"; - $ENV{MALLOC_CHECK_} = 2; -} - -my $old_pwd = "$RealBin/.."; - -# Backwards compatibility: -if (defined($ENV{TEST_LDAP}) and $ENV{TEST_LDAP} eq "yes") { - if (defined($ENV{FEDORA_DS_ROOT})) { - $ldap = "fedora-ds"; - } else { - $ldap = "openldap"; - } -} - -my $torture_maxtime = ($ENV{TORTURE_MAXTIME} or 1200); -if ($ldap) { - # LDAP is slow - $torture_maxtime *= 2; -} - -$prefix =~ s+//+/+; -$prefix =~ s+/./+/+; -$prefix =~ s+/$++; - -die("using an empty prefix isn't allowed") unless $prefix ne ""; - -#Ensure we have the test prefix around -mkdir($prefix, 0777) unless -d $prefix; - -my $prefix_abs = abs_path($prefix); -my $srcdir_abs = abs_path($srcdir); - -die("using an empty absolute prefix isn't allowed") unless $prefix_abs ne ""; -die("using '/' as absolute prefix isn't allowed") unless $prefix_abs ne "/"; - -$ENV{PREFIX} = $prefix; -$ENV{KRB5CCNAME} = "$prefix/krb5ticket"; -$ENV{PREFIX_ABS} = $prefix_abs; -$ENV{SRCDIR} = $srcdir; -$ENV{SRCDIR_ABS} = $srcdir_abs; - -if (defined($ENV{RUN_FROM_BUILD_FARM}) and - ($ENV{RUN_FROM_BUILD_FARM} eq "yes")) { - $opt_format = "buildfarm"; -} - -my $tls_enabled = not $opt_quick; -$ENV{TLS_ENABLED} = ($tls_enabled?"yes":"no"); -$ENV{LDB_MODULES_PATH} = "$old_pwd/bin/modules/ldb"; -$ENV{LD_SAMBA_MODULE_PATH} = "$old_pwd/bin/modules"; -sub prefix_pathvar($$) -{ - my ($name, $newpath) = @_; - if (defined($ENV{$name})) { - $ENV{$name} = "$newpath:$ENV{$name}"; - } else { - $ENV{$name} = $newpath; - } -} -prefix_pathvar("PKG_CONFIG_PATH", "$old_pwd/bin/pkgconfig"); -prefix_pathvar("PYTHONPATH", "$old_pwd/bin/python"); - -if ($opt_socket_wrapper_keep_pcap) { - # Socket wrapper keep pcap implies socket wrapper pcap - $opt_socket_wrapper_pcap = 1; -} - -if ($opt_socket_wrapper_pcap) { - # Socket wrapper pcap implies socket wrapper - $opt_socket_wrapper = 1; -} - -my $socket_wrapper_dir; -if ($opt_socket_wrapper) { - $socket_wrapper_dir = SocketWrapper::setup_dir("$prefix/w", $opt_socket_wrapper_pcap); - print "SOCKET_WRAPPER_DIR=$socket_wrapper_dir\n"; -} else { - warn("Not using socket wrapper, but also not running as root. Will not be able to listen on proper ports") unless $< == 0; -} - -my $target; -my $testenv_default = "none"; - -if ($opt_target eq "samba4") { - $testenv_default = "member"; - require target::Samba4; - $target = new Samba4($opt_bindir or "$srcdir/bin", $ldap, "$srcdir/setup"); -} elsif ($opt_target eq "samba3") { - if ($opt_socket_wrapper and `$opt_bindir/smbd -b | grep SOCKET_WRAPPER` eq "") { - die("You must include --enable-socket-wrapper when compiling Samba in order to execute 'make test'. Exiting...."); - } - $testenv_default = "dc"; - require target::Samba3; - $target = new Samba3($opt_bindir); -} elsif ($opt_target eq "win") { - die("Windows tests will not run with socket wrapper enabled.") - if ($opt_socket_wrapper); - $testenv_default = "dc"; - require target::Windows; - $target = new Windows(); -} elsif ($opt_target eq "kvm") { - die("Kvm tests will not run with socket wrapper enabled.") - if ($opt_socket_wrapper); - require target::Kvm; - die("No image specified") unless ($opt_image); - $target = new Kvm($opt_image, undef); -} - -# -# Start a Virtual Distributed Ethernet Switch -# Returns the pid of the switch. -# -sub start_vde_switch($) -{ - my ($path) = @_; - - system("vde_switch --pidfile $path/vde.pid --sock $path/vde.sock --daemon"); - - open(PID, "$path/vde.pid"); - <PID> =~ /([0-9]+)/; - my $pid = $1; - close(PID); - - return $pid; -} - -# Stop a Virtual Distributed Ethernet Switch -sub stop_vde_switch($) -{ - my ($pid) = @_; - kill 9, $pid; -} - -sub read_test_regexes($) -{ - my ($name) = @_; - my @ret = (); - open(LF, "<$name") or die("unable to read $name: $!"); - while (<LF>) { - chomp; - next if (/^#/); - if (/^(.*?)([ \t]+)\#([\t ]*)(.*?)$/) { - push (@ret, [$1, $4]); - } else { - s/^(.*?)([ \t]+)\#([\t ]*)(.*?)$//; - push (@ret, [$_, undef]); - } - } - close(LF); - return @ret; -} - -if (defined($opt_expected_failures)) { - @expected_failures = read_test_regexes($opt_expected_failures); -} - -foreach (@opt_exclude) { - push (@excludes, read_test_regexes($_)); -} - -if ($opt_quick) { - push (@includes, read_test_regexes("samba4-quick")); -} - -foreach (@opt_include) { - push (@includes, read_test_regexes($_)); -} - -my $interfaces = join(',', ("127.0.0.6/8", - "127.0.0.7/8", - "127.0.0.8/8", - "127.0.0.9/8", - "127.0.0.10/8", - "127.0.0.11/8")); - -my $conffile = "$prefix_abs/client/client.conf"; - -sub write_clientconf($$) -{ - my ($conffile, $vars) = @_; - - mkdir("$prefix/client", 0777) unless -d "$prefix/client"; - - if ( -d "$prefix/client/private" ) { - unlink <$prefix/client/private/*>; - } else { - mkdir("$prefix/client/private", 0777); - } - - open(CF, ">$conffile"); - print CF "[global]\n"; - if (defined($ENV{VALGRIND})) { - print CF "\ticonv:native = true\n"; - } else { - print CF "\ticonv:native = false\n"; - } - print CF "\tnetbios name = client\n"; - if (defined($vars->{DOMAIN})) { - print CF "\tworkgroup = $vars->{DOMAIN}\n"; - } - if (defined($vars->{REALM})) { - print CF "\trealm = $vars->{REALM}\n"; - } - if (defined($vars->{NCALRPCDIR})) { - print CF "\tncalrpc dir = $vars->{NCALRPCDIR}\n"; - } - if (defined($vars->{PIDDIR})) { - print CF "\tpid directory = $vars->{PIDDIR}\n"; - } - if (defined($vars->{WINBINDD_SOCKET_DIR})) { - print CF "\twinbindd socket directory = $vars->{WINBINDD_SOCKET_DIR}\n"; - } - if ($opt_socket_wrapper) { - print CF "\tinterfaces = $interfaces\n"; - } - print CF " - private dir = $prefix_abs/client/private - name resolve order = bcast - panic action = $srcdir_abs/script/gdb_backtrace \%PID\% \%PROG\% - max xmit = 32K - notify:inotify = false - ldb:nosync = true - system:anonymous = true - torture:basedir = $prefix_abs/client -#We don't want to pass our self-tests if the PAC code is wrong - gensec:require_pac = true - modules dir = $ENV{LD_SAMBA_MODULE_PATH} -"; - close(CF); -} - -my @torture_options = (); -push (@torture_options, "--configfile=$conffile"); -# ensure any one smbtorture call doesn't run too long -push (@torture_options, "--maximum-runtime=$torture_maxtime"); -push (@torture_options, "--target=$opt_target"); -push (@torture_options, "--basedir=$prefix_abs"); -push (@torture_options, "--option=torture:progress=no") unless ($opt_verbose); -push (@torture_options, "--format=subunit"); -push (@torture_options, "--option=torture:quick=yes") if ($opt_quick); - -$ENV{TORTURE_OPTIONS} = join(' ', @torture_options); -print "OPTIONS $ENV{TORTURE_OPTIONS}\n"; - -my @todo = (); - -my $testsdir = "$srcdir/selftest"; -$ENV{SMB_CONF_PATH} = "$conffile"; -$ENV{CONFIGURATION} = "--configfile=$conffile"; - -my %required_envs = (); - -sub read_testlist($) -{ - my ($filename) = @_; - - my @ret = (); - open(IN, $filename) or die("Unable to open $filename: $!"); - - while (<IN>) { - if ($_ eq "-- TEST --\n") { - my $name = <IN>; - $name =~ s/\n//g; - my $env = <IN>; - $env =~ s/\n//g; - my $cmdline = <IN>; - $cmdline =~ s/\n//g; - if (not defined($tests) or $name =~ /$tests/) { - $required_envs{$env} = 1; - push (@ret, [$name, $env, $cmdline]); - } - } else { - print; - } - } - close(IN) or die("Error creating recipe"); - return @ret; -} - -if ($#testlists == -1) { - die("No testlists specified"); -} - -my @available = (); -foreach my $fn (@testlists) { - foreach (read_testlist($fn)) { - my $name = $$_[0]; - next if (@includes and not find_in_list(\@includes, $name)); - push (@available, $_); - } -} - -my $msg_ops; -if ($opt_format eq "buildfarm") { - require output::buildfarm; - $msg_ops = new output::buildfarm($statistics); -} elsif ($opt_format eq "plain") { - require output::plain; - $msg_ops = new output::plain("$prefix/summary", $opt_verbose, $opt_immediate, $statistics, $#available+1); -} elsif ($opt_format eq "html") { - require output::html; - mkdir("test-results", 0777); - $msg_ops = new output::html("test-results", $statistics); -} else { - die("Invalid output format '$opt_format'"); -} - - -foreach (@available) { - my $name = $$_[0]; - my $skipreason = skip($name); - if ($skipreason) { - $msg_ops->skip_testsuite($name, $skipreason); - } else { - push(@todo, $_); - } -} - -if ($#todo == -1) { - print STDERR "No tests to run\n"; - exit(1); - } - -my $suitestotal = $#todo + 1; -my $i = 0; -$| = 1; - -my %running_envs = (); - -my @exported_envvars = ( - # domain stuff - "DOMAIN", - "REALM", - - # domain controller stuff - "DC_SERVER", - "DC_SERVER_IP", - "DC_NETBIOSNAME", - "DC_NETBIOSALIAS", - - # server stuff - "SERVER", - "SERVER_IP", - "NETBIOSNAME", - "NETBIOSALIAS", - - # user stuff - "USERNAME", - "PASSWORD", - "DC_USERNAME", - "DC_PASSWORD", - - # misc stuff - "KRB5_CONFIG", - "WINBINDD_SOCKET_DIR", - "WINBINDD_PRIV_PIPE_DIR" -); - -$SIG{INT} = $SIG{QUIT} = $SIG{TERM} = sub { - my $signame = shift; - teardown_env($_) foreach(keys %running_envs); - die("Received signal $signame"); -}; - -sub setup_env($) -{ - my ($envname) = @_; - - my $testenv_vars; - if ($envname eq "none") { - $testenv_vars = {}; - } elsif (defined($running_envs{$envname})) { - $testenv_vars = $running_envs{$envname}; - if (not $target->check_env($testenv_vars)) { - $testenv_vars = undef; - } - } else { - $testenv_vars = $target->setup_env($envname, $prefix); - } - - return undef unless defined($testenv_vars); - - $running_envs{$envname} = $testenv_vars; - - SocketWrapper::set_default_iface(6); - write_clientconf($conffile, $testenv_vars); - - foreach (@exported_envvars) { - if (defined($testenv_vars->{$_})) { - $ENV{$_} = $testenv_vars->{$_}; - } else { - delete $ENV{$_}; - } - } - - return $testenv_vars; -} - -sub exported_envvars_str($) -{ - my ($testenv_vars) = @_; - my $out = ""; - - foreach (@exported_envvars) { - next unless defined($testenv_vars->{$_}); - $out .= $_."=".$testenv_vars->{$_}."\n"; - } - - return $out; -} - -sub getlog_env($) -{ - my ($envname) = @_; - return "" if ($envname eq "none"); - return $target->getlog_env($running_envs{$envname}); -} - -sub check_env($) -{ - my ($envname) = @_; - return 1 if ($envname eq "none"); - return $target->check_env($running_envs{$envname}); -} - -sub teardown_env($) -{ - my ($envname) = @_; - return if ($envname eq "none"); - $target->teardown_env($running_envs{$envname}); - delete $running_envs{$envname}; -} - -if ($opt_no_lazy_setup) { - setup_env($_) foreach (keys %required_envs); -} - -if ($opt_testenv) { - my $testenv_name = $ENV{SELFTEST_TESTENV}; - $testenv_name = $testenv_default unless defined($testenv_name); - - my $testenv_vars = setup_env($testenv_name); - - $ENV{PIDDIR} = $testenv_vars->{PIDDIR}; - - my $envvarstr = exported_envvars_str($testenv_vars); - - my $term = ($ENV{TERM} or "xterm"); - system("$term -e 'echo -e \" -Welcome to the Samba4 Test environment '$testenv_name' - -This matches the client environment used in make test -server is pid `cat \$PIDDIR/samba.pid` - -Some useful environment variables: -TORTURE_OPTIONS=\$TORTURE_OPTIONS -CONFIGURATION=\$CONFIGURATION - -$envvarstr -\" && LD_LIBRARY_PATH=$ENV{LD_LIBRARY_PATH} bash'"); - teardown_env($testenv_name); -} else { - foreach (@todo) { - $i++; - my $cmd = $$_[2]; - $cmd =~ s/([\(\)])/\\$1/g; - my $name = $$_[0]; - my $envname = $$_[1]; - - my $envvars = setup_env($envname); - if (not defined($envvars)) { - $msg_ops->skip_testsuite($name, "unable to set up environment $envname"); - next; - } - - run_testsuite($envname, $name, $cmd, $i, $suitestotal, - $msg_ops); - - if (defined($opt_analyse_cmd)) { - system("$opt_analyse_cmd \"$name\""); - } - - teardown_env($envname) if ($opt_resetup_env); - } -} - -print "\n"; - -teardown_env($_) foreach (keys %running_envs); - -$target->stop(); - -$msg_ops->summary(); - -my $failed = 0; - -# if there were any valgrind failures, show them -foreach (<$prefix/valgrind.log*>) { - next unless (-s $_); - system("grep DWARF2.CFI.reader $_ > /dev/null"); - if ($? >> 8 == 0) { - print "VALGRIND FAILURE\n"; - $failed++; - system("cat $_"); - } -} - -if ($opt_format eq "buildfarm") { - print "TEST STATUS: $statistics->{SUITES_FAIL}\n"; -} - -exit $statistics->{SUITES_FAIL}; diff --git a/source4/samba4-skip b/source4/selftest/skip index e3e2d2d525..e3e2d2d525 100644 --- a/source4/samba4-skip +++ b/source4/selftest/skip diff --git a/source4/samba4-slow b/source4/selftest/slow index d414368de8..d414368de8 100644 --- a/source4/samba4-slow +++ b/source4/selftest/slow diff --git a/source4/selftest/target/Kvm.pm b/source4/selftest/target/Kvm.pm deleted file mode 100644 index 3b17a2909c..0000000000 --- a/source4/selftest/target/Kvm.pm +++ /dev/null @@ -1,167 +0,0 @@ -#!/usr/bin/perl -# Start a KVM machine and run a number of tests against it. -# Copyright (C) 2005-2008 Jelmer Vernooij <jelmer@samba.org> -# Published under the GNU GPL, v3 or later. - -package Kvm; - -use strict; -use Cwd qw(abs_path); -use FindBin qw($RealBin); -use POSIX; - -sub new($$$$) { - my ($classname, $dc_image, $vdesocket) = @_; - my $self = { - dc_image => $dc_image, - vdesocket => $vdesocket, - }; - bless $self; - return $self; -} - -sub write_kvm_ifup($$$) -{ - my ($self, $path, $ip_prefix) = @_; - open(SCRIPT, ">$path/kvm-ifup"); - - print SCRIPT <<__EOF__; -#!/bin/sh - -PREFIX=$ip_prefix - -/sbin/ifconfig \$1 \$PREFIX.1 up - -cat <<EOF>$path/udhcpd.conf -interface \$1 -start \$PREFIX.20 -end \$PREFIX.20 -max_leases 1 -lease_file $path/udhcpd.leases -pidfile $path/udhcpd.pid -EOF - -touch $path/udhcpd.leases - -/usr/sbin/udhcpd $path/udhcpd.conf - -exit 0 -__EOF__ - close(SCRIPT); - chmod(0755, "$path/kvm-ifup"); - - return ("$path/kvm-ifup", "$path/udhcpd.pid", "$ip_prefix.20"); -} - -sub teardown_env($$) -{ - my ($self, $envvars) = @_; - - print "Killing kvm instance $envvars->{KVM_PID}\n"; - - kill 9, $envvars->{KVM_PID}; - - if (defined($envvars->{DHCPD_PID})) { - print "Killing dhcpd instance $envvars->{DHCPD_PID}\n"; - kill 9, $envvars->{DHCPD_PID}; - } - - return 0; -} - -sub getlog_env($$) -{ - my ($self, $envvars) = @_; - - return ""; -} - -sub check_env($$) -{ - my ($self, $envvars) = @_; - - # FIXME: Check whether $self->{pid} is still running - - return 1; -} - -sub read_pidfile($) -{ - my ($path) = @_; - - open(PID, $path); - <PID> =~ /([0-9]+)/; - my ($pid) = $1; - close(PID); - return $pid; -} - -sub start($$$) -{ - my ($self, $path, $image) = @_; - - my $pidfile = "$path/kvm.pid"; - - my $opts = (defined($ENV{KVM_OPTIONS})?$ENV{KVM_OPTIONS}:"-nographic"); - - if (defined($ENV{KVM_SNAPSHOT})) { - $opts .= " -loadvm $ENV{KVM_SNAPSHOT}"; - } - - my $netopts; - my $dhcp_pid; - my $ip_address; - - if ($self->{vdesocket}) { - $netopts = "vde,socket=$self->{vdesocket}"; - } else { - my $ifup_script, $dhcpd_pidfile; - ($ifup_script, $dhcpd_pidfile, $ip_address) = $self->write_kvm_ifup($path, "192.168.9"); - $netopts = "tap,script=$ifup_script"; - $dhcp_pid = read_pidfile($dhcpd_pidfile); - } - - system("kvm -name \"Samba 4 Test Subject\" $opts -monitor unix:$path/kvm.monitor,server,nowait -daemonize -pidfile $pidfile -snapshot $image -net nic -net $netopts"); - - return (read_pidfile($pidfile), $dhcp_pid, $ip_address); -} - -sub setup_env($$$) -{ - my ($self, $envname, $path) = @_; - - if ($envname eq "dc") { - ($self->{dc_pid}, $self->{dc_dhcpd_pid}, $self->{dc_ip}) = $self->start($path, $self->{dc_image}); - - sub choose_var($$) { - my ($name, $default) = @_; - return defined($ENV{"KVM_DC_$name"})?$ENV{"KVM_DC_$name"}:$default; - } - - if ($envname eq "dc") { - return { - KVM_PID => $self->{dc_pid}, - DHCPD_PID => $self->{dc_dhcpd_pid}, - USERNAME => choose_var("USERNAME", "Administrator"), - PASSWORD => choose_var("PASSWORD", "penguin"), - DOMAIN => choose_var("DOMAIN", "SAMBA"), - REALM => choose_var("REALM", "SAMBA"), - SERVER => choose_var("SERVER", "DC"), - SERVER_IP => $self->{dc_ip}, - NETBIOSNAME => choose_var("NETBIOSNAME", "DC"), - NETBIOSALIAS => choose_var("NETBIOSALIAS", "DC"), - }; - } else { - return undef; - } - } else { - return undef; - } -} - -sub stop($) -{ - my ($self) = @_; -} - -1; diff --git a/source4/selftest/target/Samba3.pm b/source4/selftest/target/Samba3.pm deleted file mode 100644 index b0c4eb22bd..0000000000 --- a/source4/selftest/target/Samba3.pm +++ /dev/null @@ -1,434 +0,0 @@ -#!/usr/bin/perl -# Bootstrap Samba and run a number of tests against it. -# Copyright (C) 2005-2007 Jelmer Vernooij <jelmer@samba.org> -# Published under the GNU GPL, v3 or later. - -package Samba3; - -use strict; -use Cwd qw(abs_path); -use FindBin qw($RealBin); -use POSIX; - -sub binpath($$) -{ - my ($self, $binary) = @_; - - if (defined($self->{bindir})) { - my $path = "$self->{bindir}/$binary"; - -f $path or die("File $path doesn't exist"); - return $path; - } - - return $binary; -} - -sub new($$) { - my ($classname, $bindir) = @_; - my $self = { bindir => $bindir }; - bless $self; - return $self; -} - -sub teardown_env($$) -{ - my ($self, $envvars) = @_; - - my $smbdpid = read_pid($envvars, "smbd"); - my $nmbdpid = read_pid($envvars, "nmbd"); -# my $winbinddpid = read_pid($envvars, "winbindd"); - - $self->stop_sig_term($smbdpid); - $self->stop_sig_term($nmbdpid); -# $self->stop_sig_term($winbinddpid); - $self->stop_sig_kill($smbdpid); - $self->stop_sig_kill($nmbdpid); -# $self->stop_sig_kill($winbinddpid); - - return 0; -} - -sub getlog_env_app($$$) -{ - my ($self, $envvars, $name) = @_; - - my $title = "$name LOG of: $envvars->{NETBIOSNAME}\n"; - my $out = $title; - - open(LOG, "<".$envvars->{$name."_TEST_LOG"}); - - seek(LOG, $envvars->{$name."_TEST_LOG_POS"}, SEEK_SET); - while (<LOG>) { - $out .= $_; - } - $envvars->{$name."_TEST_LOG_POS"} = tell(LOG); - close(LOG); - - return "" if $out eq $title; - - return $out; -} - -sub getlog_env($$) -{ - my ($self, $envvars) = @_; - my $ret = ""; - - $ret .= $self->getlog_env_app($envvars, "SMBD"); - $ret .= $self->getlog_env_app($envvars, "NMBD"); -# $ret .= $self->getlog_env_app($envvars, "WINBINDD"); - - return $ret; -} - -sub check_env($$) -{ - my ($self, $envvars) = @_; - - # TODO ... - return 1; -} - -sub setup_env($$$) -{ - my ($self, $envname, $path) = @_; - - if ($envname eq "dc") { - return $self->setup_dc("$path/dc"); - } else { - return undef; - } -} - -sub setup_dc($$) -{ - my ($self, $path) = @_; - - my $vars = $self->provision($path, "dc"); - - $self->check_or_start($vars, - ($ENV{NMBD_MAXTIME} or 2700), - ($ENV{WINBINDD_MAXTIME} or 2700), - ($ENV{SMBD_MAXTIME} or 2700)); - - $self->wait_for_start($vars); - - return $vars; -} - -sub stop($) -{ - my ($self) = @_; -} - -sub stop_sig_term($$) { - my ($self, $pid) = @_; - kill("USR1", $pid) or kill("ALRM", $pid) or warn("Unable to kill $pid: $!"); -} - -sub stop_sig_kill($$) { - my ($self, $pid) = @_; - kill("ALRM", $pid) or warn("Unable to kill $pid: $!"); -} - -sub write_pid($$$) -{ - my ($env_vars, $app, $pid) = @_; - - open(PID, ">$env_vars->{PIDDIR}/timelimit.$app.pid"); - print PID $pid; - close(PID); -} - -sub read_pid($$) -{ - my ($env_vars, $app) = @_; - - open(PID, "<$env_vars->{PIDDIR}/timelimit.$app.pid"); - my $pid = <PID>; - close(PID); - return $pid; -} - -sub check_or_start($$$$) { - my ($self, $env_vars, $nmbd_maxtime, $winbindd_maxtime, $smbd_maxtime) = @_; - - unlink($env_vars->{NMBD_TEST_LOG}); - print "STARTING NMBD..."; - my $pid = fork(); - if ($pid == 0) { - open STDOUT, ">$env_vars->{NMBD_TEST_LOG}"; - open STDERR, '>&STDOUT'; - - $ENV{WINBINDD_SOCKET_DIR} = $env_vars->{WINBINDD_SOCKET_DIR}; - - my @optargs = ("-d0"); - if (defined($ENV{NMBD_OPTIONS})) { - @optargs = split(/ /, $ENV{NMBD_OPTIONS}); - } - - $ENV{MAKE_TEST_BINARY} = $self->binpath("nmbd"); - - my @preargs = ($self->binpath("timelimit"), $nmbd_maxtime); - if(defined($ENV{NMBD_VALGRIND})) { - @preargs = split(/ /, $ENV{NMBD_VALGRIND}); - } - - exec(@preargs, $self->binpath("nmbd"), "-F", "-S", "--no-process-group", "-s", $env_vars->{SERVERCONFFILE}, @optargs) or die("Unable to start nmbd: $!"); - } - write_pid($env_vars, "nmbd", $pid); - print "DONE\n"; - -# disable winbindd until the build-farm faked_users work with it -# unlink($env_vars->{WINBINDD_TEST_LOG}); -# print "STARTING WINBINDD..."; -# $pid = fork(); -# if ($pid == 0) { -# open STDOUT, ">$env_vars->{WINBINDD_TEST_LOG}"; -# open STDERR, '>&STDOUT'; -# -# $ENV{WINBINDD_SOCKET_DIR} = $env_vars->{WINBINDD_SOCKET_DIR}; -# -# my @optargs = ("-d0"); -# if (defined($ENV{WINBINDD_OPTIONS})) { -# @optargs = split(/ /, $ENV{WINBINDD_OPTIONS}); -# } -# -# $ENV{MAKE_TEST_BINARY} = $self->binpath("winbindd"); -# exec($self->binpath("timelimit"), $winbindd_maxtime, $ENV{WINBINDD_VALGRIND}, $self->binpath("winbindd"), "-F", "-S", "--no-process-group", "-s", $env_vars->{SERVERCONFFILE}, @optargs) or die("Unable to start winbindd: $!"); -# } -# write_pid($env_vars, "winbindd", $pid); -# print "DONE\n"; - - unlink($env_vars->{SMBD_TEST_LOG}); - print "STARTING SMBD..."; - $pid = fork(); - if ($pid == 0) { - open STDOUT, ">$env_vars->{SMBD_TEST_LOG}"; - open STDERR, '>&STDOUT'; - - $ENV{WINBINDD_SOCKET_DIR} = $env_vars->{WINBINDD_SOCKET_DIR}; - - $ENV{MAKE_TEST_BINARY} = $self->binpath("smbd"); - my @optargs = ("-d0"); - if (defined($ENV{SMBD_OPTIONS})) { - @optargs = split(/ /, $ENV{SMBD_OPTIONS}); - } - my @preargs = ($self->binpath("timelimit"), $smbd_maxtime); - if(defined($ENV{SMBD_VALGRIND})) { - @preargs = split(/ /,$ENV{SMBD_VALGRIND}); - } - exec(@preargs, $self->binpath("smbd"), "-F", "-S", "--no-process-group", "-s", $env_vars->{SERVERCONFFILE}, @optargs) or die("Unable to start smbd: $!"); - } - write_pid($env_vars, "smbd", $pid); - print "DONE\n"; - - return 0; -} - -sub create_clientconf($$$) -{ - my ($self, $prefix, $domain) = @_; - - my $lockdir = "$prefix/locks"; - my $logdir = "$prefix/logs"; - my $piddir = "$prefix/pid"; - my $privatedir = "$prefix/private"; - my $scriptdir = "$RealBin/.."; - my $conffile = "$prefix/smb.conf"; - - my $torture_interfaces='127.0.0.6/8,127.0.0.7/8,127.0.0.8/8,127.0.0.9/8,127.0.0.10/8,127.0.0.11/8'; - open(CONF, ">$conffile"); - print CONF " -[global] - workgroup = $domain - - private dir = $privatedir - pid directory = $piddir - lock directory = $lockdir - log file = $logdir/log.\%m - log level = 0 - - name resolve order = bcast - - netbios name = TORTURE_6 - interfaces = $torture_interfaces - panic action = $scriptdir/gdb_backtrace \%d %\$(MAKE_TEST_BINARY) - - passdb backend = tdbsam - "; - close(CONF); -} - -sub provision($$$) -{ - my ($self, $prefix, $role) = @_; - - ## - ## setup the various environment variables we need - ## - - my %ret = (); - my $server = "LOCALHOST2"; - my $server_ip = "127.0.0.2"; - my $domain = "SAMBA-TEST"; - - my $username = `PATH=/usr/ucb:$ENV{PATH} whoami`; - chomp $username; - my $password = "test"; - - my $srcdir="$RealBin/.."; - my $scriptdir="$srcdir/selftest"; - my $prefix_abs = abs_path($prefix); - - my @dirs = (); - - my $shrdir="$prefix_abs/share"; - push(@dirs,$shrdir); - - my $libdir="$prefix_abs/lib"; - push(@dirs,$libdir); - - my $piddir="$prefix_abs/pid"; - push(@dirs,$piddir); - - my $privatedir="$prefix_abs/private"; - push(@dirs,$privatedir); - - my $lockdir="$prefix_abs/lockdir"; - push(@dirs,$lockdir); - - my $logdir="$prefix_abs/logs"; - push(@dirs,$logdir); - - # this gets autocreated by winbindd - my $wbsockdir="$prefix_abs/winbindd"; - my $wbsockprivdir="$lockdir/winbindd_privileged"; - - ## - ## create the test directory layout - ## - mkdir($prefix_abs, 0777); - print "CREATE TEST ENVIRONMENT IN '$prefix'..."; - system("rm -rf $prefix_abs/*"); - mkdir($_, 0777) foreach(@dirs); - - my $conffile="$libdir/server.conf"; - - open(CONF, ">$conffile") or die("Unable to open $conffile"); - print CONF " -[global] - workgroup = $domain - - private dir = $privatedir - pid directory = $piddir - lock directory = $lockdir - log file = $logdir/log.\%m - log level = 0 - - name resolve order = bcast - - netbios name = $server - interfaces = $server_ip/8 - bind interfaces only = yes - panic action = $scriptdir/gdb_backtrace %d %\$(MAKE_TEST_BINARY) - - passdb backend = tdbsam - - ; Necessary to add the build farm hacks - add user script = /bin/false - add machine script = /bin/false - - kernel oplocks = no - kernel change notify = no - - syslog = no - printing = bsd - printcap name = /dev/null - -"; - - if ($role eq "dc") { - print CONF "\tdomain logons = yes\n"; - print CONF "\tdomain master = yes\n"; - } - -print CONF " - - winbindd:socket dir = $wbsockdir - -[tmp] - path = $shrdir - read only = no - smbd:sharedelay = 100000 - map hidden = yes - map system = yes - create mask = 755 -[hideunread] - copy = tmp - hide unreadable = yes -[hideunwrite] - copy = tmp - hide unwriteable files = yes -[print1] - copy = tmp - printable = yes - printing = test -[print2] - copy = print1 -[print3] - copy = print1 -[print4] - copy = print1 - "; - close(CONF); - - ## - ## create a test account - ## - - open(PWD, "|".$self->binpath("smbpasswd")." -c $conffile -L -s -a $username"); - print PWD "$password\n$password\n"; - close(PWD) or die("Unable to set password for test account"); - - print "DONE\n"; - - $ret{SERVER_IP} = $server_ip; - $ret{NMBD_TEST_LOG} = "$prefix/nmbd_test.log"; - $ret{WINBINDD_TEST_LOG} = "$prefix/winbindd_test.log"; - $ret{SMBD_TEST_LOG} = "$prefix/smbd_test.log"; - $ret{SERVERCONFFILE} = $conffile; - $ret{CONFIGURATION} ="-s $conffile"; - $ret{SERVER} = $server; - $ret{USERNAME} = $username; - $ret{DOMAIN} = $domain; - $ret{NETBIOSNAME} = $server; - $ret{PASSWORD} = $password; - $ret{PIDDIR} = $piddir; - $ret{WINBINDD_SOCKET_DIR} = $wbsockdir; - $ret{WINBINDD_PRIV_PIPE_DIR} = $wbsockprivdir; - return \%ret; -} - -sub wait_for_start($$) -{ - my ($self, $envvars) = @_; - - # give time for nbt server to register its names - print "delaying for nbt name registration\n"; - sleep(10); - # This will return quickly when things are up, but be slow if we need to wait for (eg) SSL init - system($self->binpath("nmblookup") ." $envvars->{CONFIGURATION} -U $envvars->{SERVER_IP} __SAMBA__"); - system($self->binpath("nmblookup") ." $envvars->{CONFIGURATION} __SAMBA__"); - system($self->binpath("nmblookup") ." $envvars->{CONFIGURATION} -U 127.255.255.255 __SAMBA__"); - system($self->binpath("nmblookup") ." $envvars->{CONFIGURATION} -U $envvars->{SERVER_IP} $envvars->{SERVER}"); - system($self->binpath("nmblookup") ." $envvars->{CONFIGURATION} $envvars->{SERVER}"); - # make sure smbd is also up set - print "wait for smbd\n"; - system($self->binpath("smbclient") ." $envvars->{CONFIGURATION} -L $envvars->{SERVER_IP} -U% -p 139 | head -2"); - system($self->binpath("smbclient") ." $envvars->{CONFIGURATION} -L $envvars->{SERVER_IP} -U% -p 139 | head -2"); - - print $self->getlog_env($envvars); -} - -1; diff --git a/source4/selftest/target/Samba4.pm b/source4/selftest/target/Samba4.pm deleted file mode 100644 index 9364008ee2..0000000000 --- a/source4/selftest/target/Samba4.pm +++ /dev/null @@ -1,956 +0,0 @@ -#!/usr/bin/perl -# Bootstrap Samba and run a number of tests against it. -# Copyright (C) 2005-2007 Jelmer Vernooij <jelmer@samba.org> -# Published under the GNU GPL, v3 or later. - -package Samba4; - -use strict; -use Cwd qw(abs_path); -use FindBin qw($RealBin); -use POSIX; - -sub new($$$$) { - my ($classname, $bindir, $ldap, $setupdir) = @_; - my $self = { - vars => {}, - ldap => $ldap, - bindir => $bindir, - setupdir => $setupdir - }; - bless $self; - return $self; -} - -sub openldap_start($$$) { - my ($slapd_conf, $uri, $logs) = @_; - my $oldpath = $ENV{PATH}; - my $olroot = ""; - my $olpath = ""; - if (defined $ENV{OPENLDAP_ROOT}) { - $olroot = "$ENV{OPENLDAP_ROOT}"; - $olpath = "$olroot/libexec:$olroot/sbin:"; - } - $ENV{PATH} = "$olpath/usr/local/sbin:/usr/sbin:/sbin:$ENV{PATH}"; - system("slapd -d63 -f $slapd_conf -h $uri > $logs 2>&1 &"); - $ENV{PATH} = $oldpath; -} - -sub slapd_start($$) -{ - my $count = 0; - my ($self, $env_vars) = @_; - - my $uri = $env_vars->{LDAP_URI}; - - # running slapd in the background means it stays in the same process group, so it can be - # killed by timelimit - if ($self->{ldap} eq "fedora-ds") { - system("$ENV{FEDORA_DS_ROOT}/sbin/ns-slapd -D $env_vars->{FEDORA_DS_DIR} -d0 -i $env_vars->{FEDORA_DS_PIDFILE}> $env_vars->{LDAPDIR}/logs 2>&1 &"); - } elsif ($self->{ldap} eq "openldap") { - openldap_start($env_vars->{SLAPD_CONF}, $uri, "$env_vars->{LDAPDIR}/logs"); - } - while (system("$self->{bindir}/ldbsearch -H $uri -s base -b \"\" supportedLDAPVersion > /dev/null") != 0) { - $count++; - if ($count > 40) { - $self->slapd_stop($env_vars); - return 0; - } - sleep(1); - } - return 1; -} - -sub slapd_stop($$) -{ - my ($self, $envvars) = @_; - if ($self->{ldap} eq "fedora-ds") { - system("$envvars->{LDAPDIR}/slapd-samba4/stop-slapd"); - } elsif ($self->{ldap} eq "openldap") { - open(IN, "<$envvars->{OPENLDAP_PIDFILE}") or - die("unable to open slapd pid file: $envvars->{OPENLDAP_PIDFILE}"); - kill 9, <IN>; - close(IN); - } - return 1; -} - -sub check_or_start($$$) -{ - my ($self, $env_vars, $max_time) = @_; - return 0 if ( -p $env_vars->{SMBD_TEST_FIFO}); - - unlink($env_vars->{SMBD_TEST_FIFO}); - POSIX::mkfifo($env_vars->{SMBD_TEST_FIFO}, 0700); - unlink($env_vars->{SMBD_TEST_LOG}); - - print "STARTING SMBD... "; - my $pid = fork(); - if ($pid == 0) { - open STDIN, $env_vars->{SMBD_TEST_FIFO}; - open STDOUT, ">$env_vars->{SMBD_TEST_LOG}"; - open STDERR, '>&STDOUT'; - - SocketWrapper::set_default_iface($env_vars->{SOCKET_WRAPPER_DEFAULT_IFACE}); - - my $valgrind = ""; - if (defined($ENV{SMBD_VALGRIND})) { - $valgrind = $ENV{SMBD_VALGRIND}; - } - - $ENV{KRB5_CONFIG} = $env_vars->{KRB5_CONFIG}; - - $ENV{NSS_WRAPPER_PASSWD} = $env_vars->{NSS_WRAPPER_PASSWD}; - $ENV{NSS_WRAPPER_GROUP} = $env_vars->{NSS_WRAPPER_GROUP}; - - # Start slapd before smbd, but with the fifo on stdin - if (defined($self->{ldap})) { - $self->slapd_start($env_vars) or - die("couldn't start slapd (2nd time)"); - } - - my $optarg = ""; - if (defined($max_time)) { - $optarg = "--maximum-runtime=$max_time "; - } - if (defined($ENV{SMBD_OPTIONS})) { - $optarg.= " $ENV{SMBD_OPTIONS}"; - } - my $ret = system("$valgrind $self->{bindir}/samba $optarg $env_vars->{CONFIGURATION} -M single -i --leak-report-full"); - if ($? == -1) { - print "Unable to start samba: $ret: $!\n"; - exit 1; - } - unlink($env_vars->{SMBD_TEST_FIFO}); - my $exit = $? >> 8; - if ( $ret == 0 ) { - print "samba exits with status $exit\n"; - } elsif ( $ret & 127 ) { - print "samba got signal ".($ret & 127)." and exits with $exit!\n"; - } else { - $ret = $? >> 8; - print "samba failed with status $exit!\n"; - } - exit $exit; - } - print "DONE\n"; - - open(DATA, ">$env_vars->{SMBD_TEST_FIFO}"); - - return $pid; -} - -sub wait_for_start($$) -{ - my ($self, $testenv_vars) = @_; - # give time for nbt server to register its names - print "delaying for nbt name registration\n"; - sleep 2; - - # This will return quickly when things are up, but be slow if we - # need to wait for (eg) SSL init - system("bin/nmblookup $testenv_vars->{CONFIGURATION} $testenv_vars->{SERVER}"); - system("bin/nmblookup $testenv_vars->{CONFIGURATION} -U $testenv_vars->{SERVER_IP} $testenv_vars->{SERVER}"); - system("bin/nmblookup $testenv_vars->{CONFIGURATION} $testenv_vars->{NETBIOSNAME}"); - system("bin/nmblookup $testenv_vars->{CONFIGURATION} -U $testenv_vars->{SERVER_IP} $testenv_vars->{NETBIOSNAME}"); - system("bin/nmblookup $testenv_vars->{CONFIGURATION} $testenv_vars->{NETBIOSALIAS}"); - system("bin/nmblookup $testenv_vars->{CONFIGURATION} -U $testenv_vars->{SERVER_IP} $testenv_vars->{NETBIOSALIAS}"); - system("bin/nmblookup $testenv_vars->{CONFIGURATION} $testenv_vars->{SERVER}"); - system("bin/nmblookup $testenv_vars->{CONFIGURATION} -U $testenv_vars->{SERVER_IP} $testenv_vars->{SERVER}"); - system("bin/nmblookup $testenv_vars->{CONFIGURATION} $testenv_vars->{NETBIOSNAME}"); - system("bin/nmblookup $testenv_vars->{CONFIGURATION} -U $testenv_vars->{SERVER_IP} $testenv_vars->{NETBIOSNAME}"); - system("bin/nmblookup $testenv_vars->{CONFIGURATION} $testenv_vars->{NETBIOSALIAS}"); - system("bin/nmblookup $testenv_vars->{CONFIGURATION} -U $testenv_vars->{SERVER_IP} $testenv_vars->{NETBIOSALIAS}"); - - print $self->getlog_env($testenv_vars); -} - -sub write_ldb_file($$$) -{ - my ($self, $file, $ldif) = @_; - - open(LDIF, "|$self->{bindir}/ldbadd -H $file >/dev/null"); - print LDIF $ldif; - return close(LDIF); -} - -sub add_wins_config($$) -{ - my ($self, $privatedir) = @_; - - return $self->write_ldb_file("$privatedir/wins_config.ldb", " -dn: name=TORTURE_6,CN=PARTNERS -objectClass: wreplPartner -name: TORTURE_6 -address: 127.0.0.6 -pullInterval: 0 -pushChangeCount: 0 -type: 0x3 -"); -} - -sub mk_fedora_ds($$$) -{ - my ($self, $ldapdir, $configuration) = @_; - - my $fedora_ds_inf = "$ldapdir/fedorads.inf"; - my $fedora_ds_extra_ldif = "$ldapdir/fedorads-partitions.ldif"; - - #Make the subdirectory be as fedora DS would expect - my $fedora_ds_dir = "$ldapdir/slapd-samba4"; - - my $pidfile = "$fedora_ds_dir/logs/slapd-samba4.pid"; - -my $dir = getcwd(); -chdir "$ENV{FEDORA_DS_ROOT}/bin" || die; - if (system("perl $ENV{FEDORA_DS_ROOT}/sbin/setup-ds.pl --silent --file=$fedora_ds_inf >&2") != 0) { - chdir $dir; - die("perl $ENV{FEDORA_DS_ROOT}/sbin/setup-ds.pl --silent --file=$fedora_ds_inf FAILED: $?"); - } - chdir $dir || die; - - return ($fedora_ds_dir, $pidfile); -} - -sub mk_openldap($$$) -{ - my ($self, $ldapdir, $configuration) = @_; - - my $slapd_conf = "$ldapdir/slapd.conf"; - my $pidfile = "$ldapdir/slapd.pid"; - my $modconf = "$ldapdir/modules.conf"; - - my $oldpath = $ENV{PATH}; - my $olpath = ""; - my $olroot = ""; - if (defined $ENV{OPENLDAP_ROOT}) { - $olroot = "$ENV{OPENLDAP_ROOT}"; - $olpath = "$olroot/libexec:$olroot/sbin:"; - } - $ENV{PATH} = "$olpath/usr/local/sbin:/usr/sbin:/sbin:$ENV{PATH}"; - - unlink($modconf); - open(CONF, ">$modconf"); close(CONF); - - if (system("slaptest -u -f $slapd_conf >&2") != 0) { - open(CONF, ">$modconf"); - # enable slapd modules - print CONF " -modulepath $olroot/libexec/openldap -moduleload syncprov -moduleload memberof -moduleload refint -"; - close(CONF); - } - if (system("slaptest -u -f $slapd_conf >&2") != 0) { - open(CONF, ">$modconf"); - # enable slapd modules - print CONF " -modulepath $olroot/libexec/openldap -moduleload back_hdb -moduleload syncprov -moduleload memberof -moduleload refint -"; - close(CONF); - } - - if (system("slaptest -u -f $slapd_conf >&2") != 0) { - open(CONF, ">$modconf"); - # enable slapd modules - print CONF " -moduleload back_hdb -moduleload syncprov -moduleload memberof -moduleload refint -"; - close(CONF); - } - - if (system("slaptest -u -f $slapd_conf >&2") != 0) { - open(CONF, ">$modconf"); - # enable slapd modules - print CONF " -modulepath /usr/lib/ldap -moduleload back_hdb -moduleload syncprov -moduleload memberof -moduleload refint -"; - close(CONF); - } - - if (system("slaptest -u -f $slapd_conf >&2") != 0) { - open(CONF, ">$modconf"); - # enable slapd modules (Fedora layout) - print CONF " -modulepath /usr/lib/openldap -moduleload syncprov -moduleload memberof -moduleload refint -"; - close(CONF); - } - - if (system("slaptest -u -f $slapd_conf >&2") != 0) { - open(CONF, ">$modconf"); - # enable slapd modules (Fedora x86_64 layout) - print CONF " -modulepath /usr/lib64/openldap -moduleload syncprov -moduleload memberof -moduleload refint -"; - close(CONF); - } - - system("slaptest -u -f $slapd_conf") == 0 or die("slaptest still fails after adding modules"); - - - $ENV{PATH} = $oldpath; - - return ($slapd_conf, $pidfile); -} - -sub mk_keyblobs($$) -{ - my ($self, $tlsdir) = @_; - - #TLS and PKINIT crypto blobs - my $dhfile = "$tlsdir/dhparms.pem"; - my $cafile = "$tlsdir/ca.pem"; - my $certfile = "$tlsdir/cert.pem"; - my $reqkdc = "$tlsdir/req-kdc.der"; - my $kdccertfile = "$tlsdir/kdc.pem"; - my $keyfile = "$tlsdir/key.pem"; - my $adminkeyfile = "$tlsdir/adminkey.pem"; - my $reqadmin = "$tlsdir/req-admin.der"; - my $admincertfile = "$tlsdir/admincert.pem"; - - mkdir($tlsdir, 0777); - - #This is specified here to avoid draining entropy on every run - open(DHFILE, ">$dhfile"); - print DHFILE <<EOF; ------BEGIN DH PARAMETERS----- -MGYCYQC/eWD2xkb7uELmqLi+ygPMKyVcpHUo2yCluwnbPutEueuxrG/Cys8j8wLO -svCN/jYNyR2NszOmg7ZWcOC/4z/4pWDVPUZr8qrkhj5MRKJc52MncfaDglvEdJrv -YX70obsCAQI= ------END DH PARAMETERS----- -EOF - close(DHFILE); - - #Likewise, we pregenerate the key material. This allows the - #other certificates to be pre-generated - open(KEYFILE, ">$keyfile"); - print KEYFILE <<EOF; ------BEGIN RSA PRIVATE KEY----- -MIICXQIBAAKBgQDKg6pAwCHUMA1DfHDmWhZfd+F0C+9Jxcqvpw9ii9En3E1uflpc -ol3+S9/6I/uaTmJHZre+DF3dTzb/UOZo0Zem8N+IzzkgoGkFafjXuT3BL5UPY2/H -6H+pPqVIRLOmrWImai359YyoKhFyo37Y6HPeU8QcZ+u2rS9geapIWfeuowIDAQAB -AoGAAqDLzFRR/BF1kpsiUfL4WFvTarCe9duhwj7ORc6fs785qAXuwUYAJ0Uvzmy6 -HqoGv3t3RfmeHDmjcpPHsbOKnsOQn2MgmthidQlPBMWtQMff5zdoYNUFiPS0XQBq -szNW4PRjaA9KkLQVTwnzdXGkBSkn/nGxkaVu7OR3vJOBoo0CQQDO4upypesnbe6p -9/xqfZ2uim8IwV1fLlFClV7WlCaER8tsQF4lEi0XSzRdXGUD/dilpY88Nb+xok/X -8Z8OvgAXAkEA+pcLsx1gN7kxnARxv54jdzQjC31uesJgMKQXjJ0h75aUZwTNHmZQ -vPxi6u62YiObrN5oivkixwFNncT9MxTxVQJBAMaWUm2SjlLe10UX4Zdm1MEB6OsC -kVoX37CGKO7YbtBzCfTzJGt5Mwc1DSLA2cYnGJqIfSFShptALlwedot0HikCQAJu -jNKEKnbf+TdGY8Q0SKvTebOW2Aeg80YFkaTvsXCdyXrmdQcifw4WdO9KucJiDhSz -Y9hVapz7ykEJtFtWjLECQQDIlfc63I5ZpXfg4/nN4IJXUW6AmPVOYIA5215itgki -cSlMYli1H9MEXH0pQMGv5Qyd0OYIx2DDg96mZ+aFvqSG ------END RSA PRIVATE KEY----- -EOF - close(KEYFILE); - - open(ADMINKEYFILE, ">$adminkeyfile"); - - print ADMINKEYFILE <<EOF; ------BEGIN RSA PRIVATE KEY----- -MIICXQIBAAKBgQD0+OL7TQBj0RejbIH1+g5GeRaWaM9xF43uE5y7jUHEsi5owhZF -5iIoHZeeL6cpDF5y1BZRs0JlA1VqMry1jjKlzFYVEMMFxB6esnXhl0Jpip1JkUMM -XLOP1m/0dqayuHBWozj9f/cdyCJr0wJIX1Z8Pr+EjYRGPn/MF0xdl3JRlwIDAQAB -AoGAP8mjCP628Ebc2eACQzOWjgEvwYCPK4qPmYOf1zJkArzG2t5XAGJ5WGrENRuB -cm3XFh1lpmaADl982UdW3gul4gXUy6w4XjKK4vVfhyHj0kZ/LgaXUK9BAGhroJ2L -osIOUsaC6jdx9EwSRctwdlF3wWJ8NK0g28AkvIk+FlolW4ECQQD7w5ouCDnf58CN -u4nARx4xv5XJXekBvOomkCQAmuOsdOb6b9wn3mm2E3au9fueITjb3soMR31AF6O4 -eAY126rXAkEA+RgHzybzZEP8jCuznMqoN2fq/Vrs6+W3M8/G9mzGEMgLLpaf2Jiz -I9tLZ0+OFk9tkRaoCHPfUOCrVWJZ7Y53QQJBAMhoA6rw0WDyUcyApD5yXg6rusf4 -ASpo/tqDkqUIpoL464Qe1tjFqtBM3gSXuhs9xsz+o0bzATirmJ+WqxrkKTECQHt2 -OLCpKqwAspU7N+w32kaUADoRLisCEdrhWklbwpQgwsIVsCaoEOpt0CLloJRYTANE -yoZeAErTALjyZYZEPcECQQDlUi0N8DFxQ/lOwWyR3Hailft+mPqoPCa8QHlQZnlG -+cfgNl57YHMTZFwgUVFRdJNpjH/WdZ5QxDcIVli0q+Ko ------END RSA PRIVATE KEY----- -EOF - - #generated with - # hxtool issue-certificate --self-signed --issue-ca \ - # --ca-private-key="FILE:$KEYFILE" \ - # --subject="CN=CA,DC=samba,DC=example,DC=com" \ - # --certificate="FILE:$CAFILE" --lifetime="25 years" - - open(CAFILE, ">$cafile"); - print CAFILE <<EOF; ------BEGIN CERTIFICATE----- -MIICcTCCAdqgAwIBAgIUaBPmjnPVqyFqR5foICmLmikJTzgwCwYJKoZIhvcNAQEFMFIxEzAR -BgoJkiaJk/IsZAEZDANjb20xFzAVBgoJkiaJk/IsZAEZDAdleGFtcGxlMRUwEwYKCZImiZPy -LGQBGQwFc2FtYmExCzAJBgNVBAMMAkNBMCIYDzIwMDgwMzAxMTIyMzEyWhgPMjAzMzAyMjQx -MjIzMTJaMFIxEzARBgoJkiaJk/IsZAEZDANjb20xFzAVBgoJkiaJk/IsZAEZDAdleGFtcGxl -MRUwEwYKCZImiZPyLGQBGQwFc2FtYmExCzAJBgNVBAMMAkNBMIGfMA0GCSqGSIb3DQEBAQUA -A4GNADCBiQKBgQDKg6pAwCHUMA1DfHDmWhZfd+F0C+9Jxcqvpw9ii9En3E1uflpcol3+S9/6 -I/uaTmJHZre+DF3dTzb/UOZo0Zem8N+IzzkgoGkFafjXuT3BL5UPY2/H6H+pPqVIRLOmrWIm -ai359YyoKhFyo37Y6HPeU8QcZ+u2rS9geapIWfeuowIDAQABo0IwQDAOBgNVHQ8BAf8EBAMC -AaYwHQYDVR0OBBYEFMLZufegDKLZs0VOyFXYK1L6M8oyMA8GA1UdEwEB/wQFMAMBAf8wDQYJ -KoZIhvcNAQEFBQADgYEAAZJbCAAkaqgFJ0xgNovn8Ydd0KswQPjicwiODPgw9ZPoD2HiOUVO -yYDRg/dhFF9y656OpcHk4N7qZ2sl3RlHkzDu+dseETW+CnKvQIoXNyeARRJSsSlwrwcoD4JR -HTLk2sGigsWwrJ2N99sG/cqSJLJ1MFwLrs6koweBnYU0f/g= ------END CERTIFICATE----- -EOF - - #generated with GNUTLS internally in Samba. - - open(CERTFILE, ">$certfile"); - print CERTFILE <<EOF; ------BEGIN CERTIFICATE----- -MIICYTCCAcygAwIBAgIE5M7SRDALBgkqhkiG9w0BAQUwZTEdMBsGA1UEChMUU2Ft -YmEgQWRtaW5pc3RyYXRpb24xNDAyBgNVBAsTK1NhbWJhIC0gdGVtcG9yYXJ5IGF1 -dG9nZW5lcmF0ZWQgY2VydGlmaWNhdGUxDjAMBgNVBAMTBVNhbWJhMB4XDTA2MDgw -NDA0MzY1MloXDTA4MDcwNDA0MzY1MlowZTEdMBsGA1UEChMUU2FtYmEgQWRtaW5p -c3RyYXRpb24xNDAyBgNVBAsTK1NhbWJhIC0gdGVtcG9yYXJ5IGF1dG9nZW5lcmF0 -ZWQgY2VydGlmaWNhdGUxDjAMBgNVBAMTBVNhbWJhMIGcMAsGCSqGSIb3DQEBAQOB -jAAwgYgCgYDKg6pAwCHUMA1DfHDmWhZfd+F0C+9Jxcqvpw9ii9En3E1uflpcol3+ -S9/6I/uaTmJHZre+DF3dTzb/UOZo0Zem8N+IzzkgoGkFafjXuT3BL5UPY2/H6H+p -PqVIRLOmrWImai359YyoKhFyo37Y6HPeU8QcZ+u2rS9geapIWfeuowIDAQABoyUw -IzAMBgNVHRMBAf8EAjAAMBMGA1UdJQQMMAoGCCsGAQUFBwMBMAsGCSqGSIb3DQEB -BQOBgQAmkN6XxvDnoMkGcWLCTwzxGfNNSVcYr7TtL2aJh285Xw9zaxcm/SAZBFyG -LYOChvh6hPU7joMdDwGfbiLrBnMag+BtGlmPLWwp/Kt1wNmrRhduyTQFhN3PP6fz -nBr9vVny2FewB2gHmelaPS//tXdxivSXKz3NFqqXLDJjq7P8wA== ------END CERTIFICATE----- -EOF - close(CERTFILE); - - #KDC certificate - # hxtool request-create \ - # --subject="CN=krbtgt,CN=users,DC=samba,DC=example,DC=com" \ - # --key="FILE:$KEYFILE" $KDCREQ - - # hxtool issue-certificate --ca-certificate=FILE:$CAFILE,$KEYFILE \ - # --type="pkinit-kdc" \ - # --pk-init-principal="krbtgt/SAMBA.EXAMPLE.COM@SAMBA.EXAMPLE.COM" \ - # --req="PKCS10:$KDCREQ" --certificate="FILE:$KDCCERTFILE" \ - # --lifetime="25 years" - - open(KDCCERTFILE, ">$kdccertfile"); - print KDCCERTFILE <<EOF; ------BEGIN CERTIFICATE----- -MIIDDDCCAnWgAwIBAgIUI2Tzj+JnMzMcdeabcNo30rovzFAwCwYJKoZIhvcNAQEFMFIxEzAR -BgoJkiaJk/IsZAEZDANjb20xFzAVBgoJkiaJk/IsZAEZDAdleGFtcGxlMRUwEwYKCZImiZPy -LGQBGQwFc2FtYmExCzAJBgNVBAMMAkNBMCIYDzIwMDgwMzAxMTMxOTIzWhgPMjAzMzAyMjQx -MzE5MjNaMGYxEzARBgoJkiaJk/IsZAEZDANjb20xFzAVBgoJkiaJk/IsZAEZDAdleGFtcGxl -MRUwEwYKCZImiZPyLGQBGQwFc2FtYmExDjAMBgNVBAMMBXVzZXJzMQ8wDQYDVQQDDAZrcmJ0 -Z3QwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAMqDqkDAIdQwDUN8cOZaFl934XQL70nF -yq+nD2KL0SfcTW5+WlyiXf5L3/oj+5pOYkdmt74MXd1PNv9Q5mjRl6bw34jPOSCgaQVp+Ne5 -PcEvlQ9jb8fof6k+pUhEs6atYiZqLfn1jKgqEXKjftjoc95TxBxn67atL2B5qkhZ966jAgMB -AAGjgcgwgcUwDgYDVR0PAQH/BAQDAgWgMBIGA1UdJQQLMAkGBysGAQUCAwUwVAYDVR0RBE0w -S6BJBgYrBgEFAgKgPzA9oBMbEVNBTUJBLkVYQU1QTEUuQ09NoSYwJKADAgEBoR0wGxsGa3Ji -dGd0GxFTQU1CQS5FWEFNUExFLkNPTTAfBgNVHSMEGDAWgBTC2bn3oAyi2bNFTshV2CtS+jPK -MjAdBgNVHQ4EFgQUwtm596AMotmzRU7IVdgrUvozyjIwCQYDVR0TBAIwADANBgkqhkiG9w0B -AQUFAAOBgQBmrVD5MCmZjfHp1nEnHqTIh8r7lSmVtDx4s9MMjxm9oNrzbKXynvdhwQYFVarc -ge4yRRDXtSebErOl71zVJI9CVeQQpwcH+tA85oGA7oeFtO/S7ls581RUU6tGgyxV4veD+lJv -KPH5LevUtgD+q9H4LU4Sq5N3iFwBaeryB0g2wg== ------END CERTIFICATE----- -EOF - - # hxtool request-create \ - # --subject="CN=Administrator,CN=users,DC=samba,DC=example,DC=com" \ - # --key="FILE:$ADMINKEYFILE" $ADMINREQFILE - - # hxtool issue-certificate --ca-certificate=FILE:$CAFILE,$KEYFILE \ - # --type="pkinit-client" \ - # --pk-init-principal="administrator@SAMBA.EXAMPLE.COM" \ - # --req="PKCS10:$ADMINREQFILE" --certificate="FILE:$ADMINCERTFILE" \ - # --lifetime="25 years" - - open(ADMINCERTFILE, ">$admincertfile"); - print ADMINCERTFILE <<EOF; ------BEGIN CERTIFICATE----- -MIIDHTCCAoagAwIBAgIUC0W5dW/N9kE+NgD0mKK34YgyqQ0wCwYJKoZIhvcNAQEFMFIxEzAR -BgoJkiaJk/IsZAEZDANjb20xFzAVBgoJkiaJk/IsZAEZDAdleGFtcGxlMRUwEwYKCZImiZPy -LGQBGQwFc2FtYmExCzAJBgNVBAMMAkNBMCIYDzIwMDgwMzAxMTMyMzAwWhgPMjAzMzAyMjQx -MzIzMDBaMG0xEzARBgoJkiaJk/IsZAEZDANjb20xFzAVBgoJkiaJk/IsZAEZDAdleGFtcGxl -MRUwEwYKCZImiZPyLGQBGQwFc2FtYmExDjAMBgNVBAMMBXVzZXJzMRYwFAYDVQQDDA1BZG1p -bmlzdHJhdG9yMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQD0+OL7TQBj0RejbIH1+g5G -eRaWaM9xF43uE5y7jUHEsi5owhZF5iIoHZeeL6cpDF5y1BZRs0JlA1VqMry1jjKlzFYVEMMF -xB6esnXhl0Jpip1JkUMMXLOP1m/0dqayuHBWozj9f/cdyCJr0wJIX1Z8Pr+EjYRGPn/MF0xd -l3JRlwIDAQABo4HSMIHPMA4GA1UdDwEB/wQEAwIFoDAoBgNVHSUEITAfBgcrBgEFAgMEBggr -BgEFBQcDAgYKKwYBBAGCNxQCAjBIBgNVHREEQTA/oD0GBisGAQUCAqAzMDGgExsRU0FNQkEu -RVhBTVBMRS5DT02hGjAYoAMCAQGhETAPGw1hZG1pbmlzdHJhdG9yMB8GA1UdIwQYMBaAFMLZ -ufegDKLZs0VOyFXYK1L6M8oyMB0GA1UdDgQWBBQg81bLyfCA88C2B/BDjXlGuaFaxjAJBgNV -HRMEAjAAMA0GCSqGSIb3DQEBBQUAA4GBAHsqSqul0hZCXn4t8Kfp3v/JLMiUMJihR1XOgzoa -ufLOQ1HNzFUHKuo1JEQ1+i5gHT/arLu/ZBF4BfQol7vW27gKIEt0fkRV8EvoPxXvSokHq0Ku -HCuPOhYNEP3wYiwB3g93NMCinWVlz0mh5aijEU7y/XrjlZxBKFFrTE+BJi1o ------END CERTIFICATE----- -EOF - close(ADMINCERTFILE); -} - -sub provision($$$$$$) -{ - my ($self, $prefix, $server_role, $netbiosname, $netbiosalias, $swiface, $password) = @_; - - my $server_loglevel = 1; - my $username = "administrator"; - my $domain = "SAMBADOMAIN"; - my $realm = "SAMBA.EXAMPLE.COM"; - my $dnsname = "samba.example.com"; - my $basedn = "dc=samba,dc=example,dc=com"; - my $unix_name = ($ENV{USER} or $ENV{LOGNAME} or `whoami`); - chomp $unix_name; - my $unix_uid = $>; - my $unix_gids_str = $); - my @unix_gids = split(" ", $unix_gids_str); - my $srcdir="$RealBin/.."; - -d $prefix or mkdir($prefix, 0777) or die("Unable to create $prefix"); - my $prefix_abs = abs_path($prefix); - my $tmpdir = "$prefix_abs/tmp"; - my $etcdir = "$prefix_abs/etc"; - my $piddir = "$prefix_abs/pid"; - my $conffile = "$etcdir/smb.conf"; - my $krb5_config = "$etcdir/krb5.conf"; - my $privatedir = "$prefix_abs/private"; - my $ncalrpcdir = "$prefix_abs/ncalrpc"; - my $lockdir = "$prefix_abs/lockdir"; - my $winbindd_socket_dir = "$prefix_abs/winbindd_socket"; - my $winbindd_privileged_socket_dir = "$prefix_abs/winbindd_privileged_socket"; - my $ntp_signd_socket_dir = "$prefix_abs/ntp_signd_socket"; - my $nsswrap_passwd = "$etcdir/passwd"; - my $nsswrap_group = "$etcdir/group"; - - my $configuration = "--configfile=$conffile"; - my $ldapdir = "$privatedir/ldap"; - - my $tlsdir = "$privatedir/tls"; - - my $ifaceipv4 = "127.0.0.$swiface"; - my $interfaces = "$ifaceipv4/8"; - - (system("rm -rf $prefix/*") == 0) or die("Unable to clean up"); - mkdir($_, 0777) foreach ($privatedir, $etcdir, $piddir, $ncalrpcdir, $lockdir, - $tmpdir, "$tmpdir/test1", "$tmpdir/test2"); - - - my $localbasedn = $basedn; - $localbasedn = "CN=$netbiosname" if $server_role eq "member server"; - - open(CONFFILE, ">$conffile"); - print CONFFILE " -[global] - netbios name = $netbiosname - netbios aliases = $netbiosalias - workgroup = $domain - realm = $realm - private dir = $privatedir - pid directory = $piddir - ncalrpc dir = $ncalrpcdir - lock dir = $lockdir - setup directory = $self->{setupdir} - modules dir = $self->{bindir}/modules - winbindd socket directory = $winbindd_socket_dir - winbindd privileged socket directory = $winbindd_privileged_socket_dir - ntp signd socket directory = $ntp_signd_socket_dir - winbind separator = / - name resolve order = bcast - interfaces = $interfaces - tls dh params file = $tlsdir/dhparms.pem - panic action = $srcdir/script/gdb_backtrace \%PID% \%PROG% - wins support = yes - server role = $server_role - max xmit = 32K - server max protocol = SMB2 - notify:inotify = false - ldb:nosync = true -#We don't want to pass our self-tests if the PAC code is wrong - gensec:require_pac = true - log level = $server_loglevel - -[tmp] - path = $tmpdir - read only = no - ntvfs handler = posix - posix:sharedelay = 100000 - posix:eadb = $lockdir/eadb.tdb - posix:oplocktimeout = 3 - posix:writetimeupdatedelay = 500000 - -[test1] - path = $tmpdir/test1 - read only = no - ntvfs handler = posix - posix:sharedelay = 100000 - posix:eadb = $lockdir/eadb.tdb - posix:oplocktimeout = 3 - posix:writetimeupdatedelay = 500000 - -[test2] - path = $tmpdir/test2 - read only = no - ntvfs handler = posix - posix:sharedelay = 100000 - posix:eadb = $lockdir/eadb.tdb - posix:oplocktimeout = 3 - posix:writetimeupdatedelay = 500000 - -[cifs] - read only = no - ntvfs handler = cifs - cifs:server = $netbiosname - cifs:share = tmp -#There is no username specified here, instead the client is expected -#to log in with kerberos, and the serverwill use delegated credentials. - -[simple] - path = $tmpdir - read only = no - ntvfs handler = simple - -[sysvol] - path = $lockdir/sysvol - read only = yes - -[netlogon] - path = $lockdir/sysvol/$dnsname/scripts - read only = no - -[cifsposix] - copy = simple - ntvfs handler = cifsposix -"; - close(CONFFILE); - - $self->mk_keyblobs($tlsdir); - - open(KRB5CONF, ">$krb5_config"); - print KRB5CONF " -#Generated krb5.conf for $realm - -[libdefaults] - default_realm = $realm - dns_lookup_realm = false - dns_lookup_kdc = false - ticket_lifetime = 24h - forwardable = yes - -[realms] - $realm = { - kdc = 127.0.0.1:88 - admin_server = 127.0.0.1:88 - default_domain = $dnsname - } - $dnsname = { - kdc = 127.0.0.1:88 - admin_server = 127.0.0.1:88 - default_domain = $dnsname - } - $domain = { - kdc = 127.0.0.1:88 - admin_server = 127.0.0.1:88 - default_domain = $dnsname - } - -[appdefaults] - pkinit_anchors = FILE:$tlsdir/ca.pem - -[kdc] - enable-pkinit = true - pkinit_identity = FILE:$tlsdir/kdc.pem,$tlsdir/key.pem - pkinit_anchors = FILE:$tlsdir/ca.pem - -[domain_realm] - .$dnsname = $realm -"; - close(KRB5CONF); - - open(PWD, ">$nsswrap_passwd"); - print PWD " -root:x:0:0:root gecos:$prefix_abs:/bin/false -$unix_name:x:$unix_uid:$unix_gids[0]:$unix_name gecos:$prefix_abs:/bin/false -nobody:x:65534:65533:nobody gecos:$prefix_abs:/bin/false -"; - close(PWD); - - open(GRP, ">$nsswrap_group"); - print GRP " -root:x:0: -wheel:x:10: -users:x:100: -nobody:x:65533: -nogroup:x:65534:nobody -"; - close(GRP); - -#Ensure the config file is valid before we start - if (system("$self->{bindir}/testparm $configuration -v --suppress-prompt >/dev/null 2>&1") != 0) { - system("$self->{bindir}/testparm -v --suppress-prompt $configuration >&2"); - die("Failed to create a valid smb.conf configuration!"); - } - - (system("($self->{bindir}/testparm $configuration -v --suppress-prompt --parameter-name=\"netbios name\" --section-name=global 2> /dev/null | grep -i \"^$netbiosname\" ) >/dev/null 2>&1") == 0) or die("Failed to create a valid smb.conf configuration! $self->{bindir}/testparm $configuration -v --suppress-prompt --parameter-name=\"netbios name\" --section-name=global"); - - my @provision_options = (); - push (@provision_options, "NSS_WRAPPER_PASSWD=\"$nsswrap_passwd\""); - push (@provision_options, "NSS_WRAPPER_GROUP=\"$nsswrap_group\""); - if (defined($ENV{GDB_PROVISION})) { - push (@provision_options, "gdb --args python"); - } - if (defined($ENV{VALGRIND_PROVISION})) { - push (@provision_options, "valgrind"); - } - push (@provision_options, "$self->{setupdir}/provision"); - push (@provision_options, split(' ', $configuration)); - push (@provision_options, "--host-name=$netbiosname"); - push (@provision_options, "--host-ip=$ifaceipv4"); - push (@provision_options, "--quiet"); - push (@provision_options, "--domain=$domain"); - push (@provision_options, "--realm=$realm"); - push (@provision_options, "--adminpass=$password"); - push (@provision_options, "--krbtgtpass=krbtgt$password"); - push (@provision_options, "--machinepass=machine$password"); - push (@provision_options, "--root=$unix_name"); - - push (@provision_options, "--server-role=\"$server_role\""); - - my $ldap_uri= "$ldapdir/ldapi"; - $ldap_uri =~ s|/|%2F|g; - $ldap_uri = "ldapi://$ldap_uri"; - - my $ret = { - KRB5_CONFIG => $krb5_config, - PIDDIR => $piddir, - SERVER => $netbiosname, - SERVER_IP => $ifaceipv4, - NETBIOSNAME => $netbiosname, - NETBIOSALIAS => $netbiosalias, - LDAP_URI => $ldap_uri, - DOMAIN => $domain, - USERNAME => $username, - REALM => $realm, - PASSWORD => $password, - LDAPDIR => $ldapdir, - WINBINDD_SOCKET_DIR => $winbindd_socket_dir, - NCALRPCDIR => $ncalrpcdir, - LOCKDIR => $lockdir, - CONFIGURATION => $configuration, - SOCKET_WRAPPER_DEFAULT_IFACE => $swiface, - NSS_WRAPPER_PASSWD => $nsswrap_passwd, - NSS_WRAPPER_GROUP => $nsswrap_group, - }; - - if (defined($self->{ldap})) { - - push (@provision_options, "--ldap-backend=$ldap_uri"); - system("$self->{setupdir}/provision-backend $configuration --ldap-admin-pass=$password --root=$unix_name --realm=$realm --domain=$domain --host-name=$netbiosname --ldap-backend-type=$self->{ldap}>&2") == 0 or die("backend provision failed"); - - push (@provision_options, "--password=$password"); - - if ($self->{ldap} eq "openldap") { - push (@provision_options, "--username=samba-admin"); - ($ret->{SLAPD_CONF}, $ret->{OPENLDAP_PIDFILE}) = $self->mk_openldap($ldapdir, $configuration) or die("Unable to create openldap directories"); - push (@provision_options, "--ldap-backend-type=openldap"); - } elsif ($self->{ldap} eq "fedora-ds") { - push (@provision_options, "--simple-bind-dn=cn=Manager,$localbasedn"); - ($ret->{FEDORA_DS_DIR}, $ret->{FEDORA_DS_PIDFILE}) = $self->mk_fedora_ds($ldapdir, $configuration) or die("Unable to create fedora ds directories"); - push (@provision_options, "--ldap-backend-type=fedora-ds"); - } - - $self->slapd_start($ret) or - die("couldn't start slapd"); - } - - my $provision_cmd = join(" ", @provision_options); - (system($provision_cmd) == 0) or die("Unable to provision: \n$provision_cmd\n"); - - if (defined($self->{ldap})) { - $self->slapd_stop($ret) or - die("couldn't stop slapd"); - } - - return $ret; -} - -sub provision_member($$$) -{ - my ($self, $prefix, $dcvars) = @_; - print "PROVISIONING MEMBER..."; - - my $ret = $self->provision($prefix, - "member server", - "localmember3", - "localmember", - 3, - "localmemberpass"); - - $ret or die("Unable to provision"); - - my $cmd = ""; - $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" "; - $cmd .= "KRB5_CONFIG=\"$ret->{KRB5_CONFIG}\" "; - $cmd .= "$self->{bindir}/net join $ret->{CONFIGURATION} $dcvars->{DOMAIN} member"; - $cmd .= " -U$dcvars->{USERNAME}\%$dcvars->{PASSWORD}"; - - system($cmd) == 0 or die("Join failed\n$cmd"); - - $ret->{SMBD_TEST_FIFO} = "$prefix/smbd_test.fifo"; - $ret->{SMBD_TEST_LOG} = "$prefix/smbd_test.log"; - $ret->{SMBD_TEST_LOG_POS} = 0; - - $ret->{DC_SERVER} = $dcvars->{SERVER}; - $ret->{DC_SERVER_IP} = $dcvars->{SERVER_IP}; - $ret->{DC_NETBIOSNAME} = $dcvars->{NETBIOSNAME}; - $ret->{DC_NETBIOSALIAS} = $dcvars->{NETBIOSALIAS}; - $ret->{DC_USERNAME} = $dcvars->{USERNAME}; - $ret->{DC_PASSWORD} = $dcvars->{PASSWORD}; - - return $ret; -} - -sub provision_dc($$) -{ - my ($self, $prefix) = @_; - - print "PROVISIONING DC..."; - my $ret = $self->provision($prefix, - "domain controller", - "localdc1", - "localdc", - 1, - "localdcpass"); - - $self->add_wins_config("$prefix/private") or - die("Unable to add wins configuration"); - - $ret->{SMBD_TEST_FIFO} = "$prefix/server_test.fifo"; - $ret->{SMBD_TEST_LOG} = "$prefix/server_test.log"; - $ret->{SMBD_TEST_LOG_POS} = 0; - return $ret; -} - -sub teardown_env($$) -{ - my ($self, $envvars) = @_; - my $pid; - - close(DATA); - - if (-f "$envvars->{PIDDIR}/samba.pid" ) { - open(IN, "<$envvars->{PIDDIR}/samba.pid") or die("unable to open server pid file"); - $pid = <IN>; - close(IN); - - # Give the process 20 seconds to exit. gcov needs - # this time to write out the covarge data - my $count = 0; - until (kill(0, $pid) == 0) { - # if no process sucessfully signalled, then we are done - sleep(1); - $count++; - last if $count > 20; - } - - # If it is still around, kill it - if ($count > 20) { - print "server process $pid took more than $count seconds to exit, killing\n"; - kill 9, $pid; - } - } - - my $failed = $? >> 8; - - $self->slapd_stop($envvars) if ($self->{ldap}); - - print $self->getlog_env($envvars); - - return $failed; -} - -sub getlog_env($$) -{ - my ($self, $envvars) = @_; - my $title = "SMBD LOG of: $envvars->{NETBIOSNAME}\n"; - my $out = $title; - - open(LOG, "<$envvars->{SMBD_TEST_LOG}"); - - seek(LOG, $envvars->{SMBD_TEST_LOG_POS}, SEEK_SET); - while (<LOG>) { - $out .= $_; - } - $envvars->{SMBD_TEST_LOG_POS} = tell(LOG); - close(LOG); - - return "" if $out eq $title; - - return $out; -} - -sub check_env($$) -{ - my ($self, $envvars) = @_; - - return 1 if (-p $envvars->{SMBD_TEST_FIFO}); - - print $self->getlog_env($envvars); - - return 0; -} - -sub setup_env($$$) -{ - my ($self, $envname, $path) = @_; - - if ($envname eq "dc") { - return $self->setup_dc("$path/dc"); - } elsif ($envname eq "member") { - if (not defined($self->{vars}->{dc})) { - $self->setup_dc("$path/dc"); - } - return $self->setup_member("$path/member", $self->{vars}->{dc}); - } else { - die("Samba4 can't provide environment '$envname'"); - } -} - -sub setup_member($$$$) -{ - my ($self, $path, $dc_vars) = @_; - - my $env = $self->provision_member($path, $dc_vars); - - $self->check_or_start($env, ($ENV{SMBD_MAXTIME} or 7500)); - - $self->wait_for_start($env); - - return $env; -} - -sub setup_dc($$) -{ - my ($self, $path) = @_; - - my $env = $self->provision_dc($path); - - $self->check_or_start($env, - ($ENV{SMBD_MAXTIME} or 7500)); - - $self->wait_for_start($env); - - $self->{vars}->{dc} = $env; - - return $env; -} - -sub stop($) -{ - my ($self) = @_; -} - -1; diff --git a/source4/selftest/target/Windows.pm b/source4/selftest/target/Windows.pm deleted file mode 100644 index d0c90d7f7b..0000000000 --- a/source4/selftest/target/Windows.pm +++ /dev/null @@ -1,40 +0,0 @@ -#!/usr/bin/perl -# Bootstrap Samba and run a number of tests against it. -# Copyright (C) 2005-2007 Jelmer Vernooij <jelmer@samba.org> -# Published under the GNU GPL, v3 or later. - -package Windows; - -use strict; -use FindBin qw($RealBin); -use POSIX; - -sub new($) -{ - my ($classname) = @_; - my $self = { }; - bless $self; - return $self; -} - -sub provision($$$) -{ - my ($self, $environment, $prefix) = @_; - - die ("Windows tests will not run without root privileges.") - if (`whoami` ne "root"); - - die("Environment variable WINTESTCONF has not been defined.\n". - "Windows tests will not run unconfigured.") if (not defined($ENV{WINTESTCONF})); - - die ("$ENV{WINTESTCONF} could not be read.") if (! -r $ENV{WINTESTCONF}); - - $ENV{WINTEST_DIR}="$ENV{SRCDIR}/selftest/win"; -} - -sub setup_env($$) -{ - my ($self, $name) = @_; -} - -1; diff --git a/source4/selftest/test_samba4.pl b/source4/selftest/test_samba4.pl deleted file mode 100755 index f2935be66b..0000000000 --- a/source4/selftest/test_samba4.pl +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/perl - -use Test::More tests => 3; -use FindBin qw($RealBin); -use lib $RealBin; -use Samba4; - -my $s = new Samba4($RealBin."/../bin", undef, $RealBin."/../setup"); - -ok($s); - -is($RealBin."/../bin", $s->{bindir}); - -ok($s->write_ldb_file("tmpldb", " -dn: a=b -a: b -c: d -")); - -unlink("tmpldb"); diff --git a/source4/selftest/test_subunit.pl b/source4/selftest/test_subunit.pl deleted file mode 100755 index 28522ed49f..0000000000 --- a/source4/selftest/test_subunit.pl +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/perl - -use Test::More tests => 0; -use FindBin qw($RealBin); -use lib $RealBin; -use Subunit qw(parse_results); - diff --git a/source4/selftest/samba4_tests.sh b/source4/selftest/tests.sh index 9fc71a104f..fa799f51ff 100755 --- a/source4/selftest/samba4_tests.sh +++ b/source4/selftest/tests.sh @@ -23,8 +23,6 @@ then PERL=perl fi -incdir=`dirname $0` - plantest() { name=$1 env=$2 @@ -56,9 +54,9 @@ plansmbtorturetest() { plantest "$modname" "$env" $cmdline } -$incdir/../bin/smbtorture -V +bin/smbtorture -V -samba4srcdir=$incdir/.. +samba4srcdir=. samba4bindir=$samba4srcdir/bin smb4torture="$samba4bindir/smbtorture $TORTURE_OPTIONS" @@ -263,7 +261,7 @@ fi # the API. These mainly test that the various command-line options of commands # work correctly. -bbdir=$incdir/../../testprogs/blackbox +bbdir=../testprogs/blackbox plantest "blackbox.ndrdump" none $samba4srcdir/librpc/tests/test_ndrdump.sh plantest "blackbox.net" dc $samba4srcdir/utils/tests/test_net.sh "\$SERVER" "\$USERNAME" "\$PASSWORD" "\$DOMAIN" diff --git a/source4/torture/auth/ntlmssp.c b/source4/torture/auth/ntlmssp.c index 739a048d29..1e8b339997 100644 --- a/source4/torture/auth/ntlmssp.c +++ b/source4/torture/auth/ntlmssp.c @@ -48,7 +48,7 @@ static bool torture_ntlmssp_self_check(struct torture_context *tctx) gensec_ntlmssp_state = (struct gensec_ntlmssp_state *)gensec_security->private_data; - gensec_ntlmssp_state->session_key = strhex_to_data_blob("0102030405060708090a0b0c0d0e0f00"); + gensec_ntlmssp_state->session_key = strhex_to_data_blob(tctx, "0102030405060708090a0b0c0d0e0f00"); dump_data_pw("NTLMSSP session key: \n", gensec_ntlmssp_state->session_key.data, gensec_ntlmssp_state->session_key.length); @@ -59,11 +59,11 @@ static bool torture_ntlmssp_self_check(struct torture_context *tctx) ntlmssp_sign_init(gensec_ntlmssp_state), "Failed to sign_init"); - data = strhex_to_data_blob("6a43494653"); + data = strhex_to_data_blob(tctx, "6a43494653"); gensec_ntlmssp_sign_packet(gensec_security, gensec_security, data.data, data.length, data.data, data.length, &sig); - expected_sig = strhex_to_data_blob("01000000e37f97f2544f4d7e00000000"); + expected_sig = strhex_to_data_blob(tctx, "01000000e37f97f2544f4d7e00000000"); dump_data_pw("NTLMSSP calc sig: ", sig.data, sig.length); dump_data_pw("NTLMSSP expected sig: ", expected_sig.data, expected_sig.length); @@ -103,7 +103,7 @@ static bool torture_ntlmssp_self_check(struct torture_context *tctx) gensec_ntlmssp_state = (struct gensec_ntlmssp_state *)gensec_security->private_data; - gensec_ntlmssp_state->session_key = strhex_to_data_blob("0102030405e538b0"); + gensec_ntlmssp_state->session_key = strhex_to_data_blob(tctx, "0102030405e538b0"); dump_data_pw("NTLMSSP session key: \n", gensec_ntlmssp_state->session_key.data, gensec_ntlmssp_state->session_key.length); @@ -114,11 +114,11 @@ static bool torture_ntlmssp_self_check(struct torture_context *tctx) ntlmssp_sign_init(gensec_ntlmssp_state), "Failed to sign_init"); - data = strhex_to_data_blob("6a43494653"); + data = strhex_to_data_blob(tctx, "6a43494653"); gensec_ntlmssp_sign_packet(gensec_security, gensec_security, data.data, data.length, data.data, data.length, &sig); - expected_sig = strhex_to_data_blob("0100000078010900397420fe0e5a0f89"); + expected_sig = strhex_to_data_blob(tctx, "0100000078010900397420fe0e5a0f89"); dump_data_pw("NTLMSSP calc sig: ", sig.data, sig.length); dump_data_pw("NTLMSSP expected sig: ", expected_sig.data, expected_sig.length); diff --git a/source4/torture/ndr/ndr.c b/source4/torture/ndr/ndr.c index 8d4d43b2a0..70bd070009 100644 --- a/source4/torture/ndr/ndr.c +++ b/source4/torture/ndr/ndr.c @@ -96,7 +96,7 @@ static bool test_check_string_terminator(struct torture_context *tctx) TALLOC_CTX *mem_ctx = tctx; /* Simple test */ - blob = strhex_to_data_blob("0000"); + blob = strhex_to_data_blob(tctx, "0000"); ndr = ndr_pull_init_blob(&blob, mem_ctx, lp_iconv_convenience(tctx->lp_ctx)); @@ -115,7 +115,7 @@ static bool test_check_string_terminator(struct torture_context *tctx) talloc_free(ndr); - blob = strhex_to_data_blob("11220000"); + blob = strhex_to_data_blob(tctx, "11220000"); ndr = ndr_pull_init_blob(&blob, mem_ctx, lp_iconv_convenience(tctx->lp_ctx)); torture_assert_ndr_success(tctx, diff --git a/source4/torture/rpc/drsuapi.c b/source4/torture/rpc/drsuapi.c index 0b4ce02a00..da6ce2b5f5 100644 --- a/source4/torture/rpc/drsuapi.c +++ b/source4/torture/rpc/drsuapi.c @@ -62,6 +62,8 @@ static bool test_DsGetDomainControllerInfo(struct dcerpc_pipe *p, struct torture { NTSTATUS status; struct drsuapi_DsGetDomainControllerInfo r; + union drsuapi_DsGetDCInfoCtr ctr; + int32_t level_out = 0; bool found = false; int i, j, k; @@ -91,16 +93,21 @@ static bool test_DsGetDomainControllerInfo(struct dcerpc_pipe *p, struct torture for (i=0; i < ARRAY_SIZE(levels); i++) { for (j=0; j < ARRAY_SIZE(names); j++) { + union drsuapi_DsGetDCInfoRequest req; level = levels[i]; r.in.bind_handle = &priv->bind_handle; r.in.level = 1; + r.in.req = &req; - r.in.req.req1.domain_name = names[j].name; - r.in.req.req1.level = level; + r.in.req->req1.domain_name = names[j].name; + r.in.req->req1.level = level; + + r.out.ctr = &ctr; + r.out.level_out = &level_out; torture_comment(torture, "testing DsGetDomainControllerInfo level %d on domainname '%s'\n", - r.in.req.req1.level, r.in.req.req1.domain_name); + r.in.req->req1.level, r.in.req->req1.domain_name); status = dcerpc_drsuapi_DsGetDomainControllerInfo(p, torture, &r); torture_assert_ntstatus_ok(torture, status, @@ -115,13 +122,13 @@ static bool test_DsGetDomainControllerInfo(struct dcerpc_pipe *p, struct torture } torture_assert_int_equal(torture, - r.in.req.req1.level, r.out.level_out, + r.in.req->req1.level, *r.out.level_out, "dcerpc_drsuapi_DsGetDomainControllerInfo level"); switch (level) { case 1: - for (k=0; k < r.out.ctr.ctr1.count; k++) { - if (strcasecmp_m(r.out.ctr.ctr1.array[k].netbios_name, + for (k=0; k < r.out.ctr->ctr1.count; k++) { + if (strcasecmp_m(r.out.ctr->ctr1.array[k].netbios_name, torture_join_netbios_name(priv->join)) == 0) { found = true; break; @@ -129,11 +136,11 @@ static bool test_DsGetDomainControllerInfo(struct dcerpc_pipe *p, struct torture } break; case 2: - for (k=0; k < r.out.ctr.ctr2.count; k++) { - if (strcasecmp_m(r.out.ctr.ctr2.array[k].netbios_name, + for (k=0; k < r.out.ctr->ctr2.count; k++) { + if (strcasecmp_m(r.out.ctr->ctr2.array[k].netbios_name, torture_join_netbios_name(priv->join)) == 0) { found = true; - priv->dcinfo = r.out.ctr.ctr2.array[k]; + priv->dcinfo = r.out.ctr->ctr2.array[k]; break; } } @@ -146,12 +153,15 @@ static bool test_DsGetDomainControllerInfo(struct dcerpc_pipe *p, struct torture r.in.bind_handle = &priv->bind_handle; r.in.level = 1; - - r.in.req.req1.domain_name = "__UNKNOWN_DOMAIN__"; /* This is clearly ignored for this level */ - r.in.req.req1.level = -1; + + r.out.ctr = &ctr; + r.out.level_out = &level_out; + + r.in.req->req1.domain_name = "__UNKNOWN_DOMAIN__"; /* This is clearly ignored for this level */ + r.in.req->req1.level = -1; printf("testing DsGetDomainControllerInfo level %d on domainname '%s'\n", - r.in.req.req1.level, r.in.req.req1.domain_name); + r.in.req->req1.level, r.in.req->req1.domain_name); status = dcerpc_drsuapi_DsGetDomainControllerInfo(p, torture, &r); @@ -164,8 +174,8 @@ static bool test_DsGetDomainControllerInfo(struct dcerpc_pipe *p, struct torture const char *dc_account = talloc_asprintf(torture, "%s\\%s$", torture_join_dom_netbios_name(priv->join), priv->dcinfo.netbios_name); - for (k=0; k < r.out.ctr.ctr01.count; k++) { - if (strcasecmp_m(r.out.ctr.ctr01.array[k].client_account, + for (k=0; k < r.out.ctr->ctr01.count; k++) { + if (strcasecmp_m(r.out.ctr->ctr01.array[k].client_account, dc_account)) { found = true; break; @@ -184,22 +194,29 @@ static bool test_DsWriteAccountSpn(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, { NTSTATUS status; struct drsuapi_DsWriteAccountSpn r; + union drsuapi_DsWriteAccountSpnRequest req; struct drsuapi_DsNameString names[2]; + union drsuapi_DsWriteAccountSpnResult res; + int32_t level_out; bool ret = true; r.in.bind_handle = &priv->bind_handle; r.in.level = 1; + r.in.req = &req; printf("testing DsWriteAccountSpn\n"); - r.in.req.req1.operation = DRSUAPI_DS_SPN_OPERATION_ADD; - r.in.req.req1.unknown1 = 0; - r.in.req.req1.object_dn = priv->dcinfo.computer_dn; - r.in.req.req1.count = 2; - r.in.req.req1.spn_names = names; + r.in.req->req1.operation = DRSUAPI_DS_SPN_OPERATION_ADD; + r.in.req->req1.unknown1 = 0; + r.in.req->req1.object_dn = priv->dcinfo.computer_dn; + r.in.req->req1.count = 2; + r.in.req->req1.spn_names = names; names[0].str = talloc_asprintf(mem_ctx, "smbtortureSPN/%s",priv->dcinfo.netbios_name); names[1].str = talloc_asprintf(mem_ctx, "smbtortureSPN/%s",priv->dcinfo.dns_name); + r.out.res = &res; + r.out.level_out = &level_out; + status = dcerpc_drsuapi_DsWriteAccountSpn(p, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { const char *errstr = nt_errstr(status); @@ -213,8 +230,8 @@ static bool test_DsWriteAccountSpn(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, ret = false; } - r.in.req.req1.operation = DRSUAPI_DS_SPN_OPERATION_DELETE; - r.in.req.req1.unknown1 = 0; + r.in.req->req1.operation = DRSUAPI_DS_SPN_OPERATION_DELETE; + r.in.req->req1.unknown1 = 0; status = dcerpc_drsuapi_DsWriteAccountSpn(p, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { @@ -508,6 +525,8 @@ static bool test_DsGetNCChanges(struct dcerpc_pipe *p, struct torture_context *t bool ret = true; int i; struct drsuapi_DsGetNCChanges r; + union drsuapi_DsGetNCChangesRequest req; + union drsuapi_DsGetNCChangesCtr ctr; struct drsuapi_DsReplicaObjectIdentifier nc; struct GUID null_guid; struct dom_sid null_sid; @@ -536,30 +555,32 @@ static bool test_DsGetNCChanges(struct dcerpc_pipe *p, struct torture_context *t array[i].level); r.in.bind_handle = &priv->bind_handle; - r.in.level = &array[i].level; - r.out.level = &level_out; + r.in.level = array[i].level; + r.out.level_out = &level_out; + r.out.ctr = &ctr; - switch (*r.in.level) { + switch (r.in.level) { case 5: nc.guid = null_guid; nc.sid = null_sid; nc.dn = priv->domain_obj_dn?priv->domain_obj_dn:""; - r.in.req.req5.destination_dsa_guid = GUID_random(); - r.in.req.req5.source_dsa_invocation_id = null_guid; - r.in.req.req5.naming_context = &nc; - r.in.req.req5.highwatermark.tmp_highest_usn = 0; - r.in.req.req5.highwatermark.reserved_usn = 0; - r.in.req.req5.highwatermark.highest_usn = 0; - r.in.req.req5.uptodateness_vector = NULL; - r.in.req.req5.replica_flags = 0; + r.in.req = &req; + r.in.req->req5.destination_dsa_guid = GUID_random(); + r.in.req->req5.source_dsa_invocation_id = null_guid; + r.in.req->req5.naming_context = &nc; + r.in.req->req5.highwatermark.tmp_highest_usn = 0; + r.in.req->req5.highwatermark.reserved_usn = 0; + r.in.req->req5.highwatermark.highest_usn = 0; + r.in.req->req5.uptodateness_vector = NULL; + r.in.req->req5.replica_flags = 0; if (lp_parm_bool(tctx->lp_ctx, NULL, "drsuapi","compression", false)) { - r.in.req.req5.replica_flags |= DRSUAPI_DS_REPLICA_NEIGHBOUR_COMPRESS_CHANGES; + r.in.req->req5.replica_flags |= DRSUAPI_DS_REPLICA_NEIGHBOUR_COMPRESS_CHANGES; } - r.in.req.req5.max_object_count = 0; - r.in.req.req5.max_ndr_size = 0; - r.in.req.req5.extended_op = DRSUAPI_EXOP_NONE; - r.in.req.req5.fsmo_info = 0; + r.in.req->req5.max_object_count = 0; + r.in.req->req5.max_ndr_size = 0; + r.in.req->req5.extended_op = DRSUAPI_EXOP_NONE; + r.in.req->req5.fsmo_info = 0; break; case 8: @@ -567,33 +588,34 @@ static bool test_DsGetNCChanges(struct dcerpc_pipe *p, struct torture_context *t nc.sid = null_sid; nc.dn = priv->domain_obj_dn?priv->domain_obj_dn:""; - r.in.req.req8.destination_dsa_guid = GUID_random(); - r.in.req.req8.source_dsa_invocation_id = null_guid; - r.in.req.req8.naming_context = &nc; - r.in.req.req8.highwatermark.tmp_highest_usn = 0; - r.in.req.req8.highwatermark.reserved_usn = 0; - r.in.req.req8.highwatermark.highest_usn = 0; - r.in.req.req8.uptodateness_vector = NULL; - r.in.req.req8.replica_flags = 0; + r.in.req = &req; + r.in.req->req8.destination_dsa_guid = GUID_random(); + r.in.req->req8.source_dsa_invocation_id = null_guid; + r.in.req->req8.naming_context = &nc; + r.in.req->req8.highwatermark.tmp_highest_usn = 0; + r.in.req->req8.highwatermark.reserved_usn = 0; + r.in.req->req8.highwatermark.highest_usn = 0; + r.in.req->req8.uptodateness_vector = NULL; + r.in.req->req8.replica_flags = 0; if (lp_parm_bool(tctx->lp_ctx, NULL, "drsuapi", "compression", false)) { - r.in.req.req8.replica_flags |= DRSUAPI_DS_REPLICA_NEIGHBOUR_COMPRESS_CHANGES; + r.in.req->req8.replica_flags |= DRSUAPI_DS_REPLICA_NEIGHBOUR_COMPRESS_CHANGES; } if (lp_parm_bool(tctx->lp_ctx, NULL, "drsuapi", "neighbour_writeable", true)) { - r.in.req.req8.replica_flags |= DRSUAPI_DS_REPLICA_NEIGHBOUR_WRITEABLE; + r.in.req->req8.replica_flags |= DRSUAPI_DS_REPLICA_NEIGHBOUR_WRITEABLE; } - r.in.req.req8.replica_flags |= DRSUAPI_DS_REPLICA_NEIGHBOUR_SYNC_ON_STARTUP + r.in.req->req8.replica_flags |= DRSUAPI_DS_REPLICA_NEIGHBOUR_SYNC_ON_STARTUP | DRSUAPI_DS_REPLICA_NEIGHBOUR_DO_SCHEDULED_SYNCS | DRSUAPI_DS_REPLICA_NEIGHBOUR_RETURN_OBJECT_PARENTS | DRSUAPI_DS_REPLICA_NEIGHBOUR_NEVER_SYNCED ; - r.in.req.req8.max_object_count = 402; - r.in.req.req8.max_ndr_size = 402116; - r.in.req.req8.extended_op = DRSUAPI_EXOP_NONE; - r.in.req.req8.fsmo_info = 0; - r.in.req.req8.partial_attribute_set = NULL; - r.in.req.req8.partial_attribute_set_ex = NULL; - r.in.req.req8.mapping_ctr.num_mappings = 0; - r.in.req.req8.mapping_ctr.mappings = NULL; + r.in.req->req8.max_object_count = 402; + r.in.req->req8.max_ndr_size = 402116; + r.in.req->req8.extended_op = DRSUAPI_EXOP_NONE; + r.in.req->req8.fsmo_info = 0; + r.in.req->req8.partial_attribute_set = NULL; + r.in.req->req8.partial_attribute_set_ex = NULL; + r.in.req->req8.mapping_ctr.num_mappings = 0; + r.in.req->req8.mapping_ctr.mappings = NULL; break; } diff --git a/source4/torture/rpc/drsuapi_cracknames.c b/source4/torture/rpc/drsuapi_cracknames.c index a9a614953d..dabd4125c7 100644 --- a/source4/torture/rpc/drsuapi_cracknames.c +++ b/source4/torture/rpc/drsuapi_cracknames.c @@ -38,6 +38,10 @@ static bool test_DsCrackNamesMatrix(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, NTSTATUS status; bool ret = true; struct drsuapi_DsCrackNames r; + union drsuapi_DsNameRequest req; + int32_t level_out; + union drsuapi_DsNameCtr ctr; + enum drsuapi_DsNameFormat formats[] = { DRSUAPI_DS_NAME_FORMAT_UNKNOWN, DRSUAPI_DS_NAME_FORMAT_FQDN_1779, @@ -60,17 +64,21 @@ static bool test_DsCrackNamesMatrix(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, ZERO_STRUCT(r); r.in.bind_handle = &priv->bind_handle; r.in.level = 1; - r.in.req.req1.codepage = 1252; /* german */ - r.in.req.req1.language = 0x00000407; /* german */ - r.in.req.req1.count = 1; - r.in.req.req1.names = names; - r.in.req.req1.format_flags = DRSUAPI_DS_NAME_FLAG_NO_FLAGS; + r.in.req = &req; + r.in.req->req1.codepage = 1252; /* german */ + r.in.req->req1.language = 0x00000407; /* german */ + r.in.req->req1.count = 1; + r.in.req->req1.names = names; + r.in.req->req1.format_flags = DRSUAPI_DS_NAME_FLAG_NO_FLAGS; + + r.out.level_out = &level_out; + r.out.ctr = &ctr; n_matrix[0][0] = dn; for (i = 0; i < ARRAY_SIZE(formats); i++) { - r.in.req.req1.format_offered = DRSUAPI_DS_NAME_FORMAT_FQDN_1779; - r.in.req.req1.format_desired = formats[i]; + r.in.req->req1.format_offered = DRSUAPI_DS_NAME_FORMAT_FQDN_1779; + r.in.req->req1.format_desired = formats[i]; names[0].str = dn; status = dcerpc_drsuapi_DsCrackNames(p, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { @@ -79,13 +87,13 @@ static bool test_DsCrackNamesMatrix(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); } printf("testing DsCrackNames (matrix prep) with name '%s' from format: %d desired format:%d ", - names[0].str, r.in.req.req1.format_offered, r.in.req.req1.format_desired); + names[0].str, r.in.req->req1.format_offered, r.in.req->req1.format_desired); printf("dcerpc_drsuapi_DsCrackNames failed - %s\n", errstr); ret = false; } else if (!W_ERROR_IS_OK(r.out.result)) { printf("testing DsCrackNames (matrix prep) with name '%s' from format: %d desired format:%d ", - names[0].str, r.in.req.req1.format_offered, r.in.req.req1.format_desired); + names[0].str, r.in.req->req1.format_offered, r.in.req->req1.format_desired); printf("DsCrackNames failed - %s\n", win_errstr(r.out.result)); ret = false; @@ -96,33 +104,33 @@ static bool test_DsCrackNamesMatrix(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, } switch (formats[i]) { case DRSUAPI_DS_NAME_FORMAT_SERVICE_PRINCIPAL: - if (r.out.ctr.ctr1->array[0].status != DRSUAPI_DS_NAME_STATUS_NOT_UNIQUE) { + if (r.out.ctr->ctr1->array[0].status != DRSUAPI_DS_NAME_STATUS_NOT_UNIQUE) { printf(__location__ ": Unexpected error (%d): This name lookup should fail\n", - r.out.ctr.ctr1->array[0].status); + r.out.ctr->ctr1->array[0].status); return false; } printf ("(expected) error\n"); break; case DRSUAPI_DS_NAME_FORMAT_USER_PRINCIPAL: - if (r.out.ctr.ctr1->array[0].status != DRSUAPI_DS_NAME_STATUS_NO_MAPPING) { + if (r.out.ctr->ctr1->array[0].status != DRSUAPI_DS_NAME_STATUS_NO_MAPPING) { printf(__location__ ": Unexpected error (%d): This name lookup should fail\n", - r.out.ctr.ctr1->array[0].status); + r.out.ctr->ctr1->array[0].status); return false; } printf ("(expected) error\n"); break; case DRSUAPI_DS_NAME_FORMAT_DNS_DOMAIN: case DRSUAPI_DS_NAME_FORMAT_SID_OR_SID_HISTORY: - if (r.out.ctr.ctr1->array[0].status != DRSUAPI_DS_NAME_STATUS_RESOLVE_ERROR) { + if (r.out.ctr->ctr1->array[0].status != DRSUAPI_DS_NAME_STATUS_RESOLVE_ERROR) { printf(__location__ ": Unexpected error (%d): This name lookup should fail\n", - r.out.ctr.ctr1->array[0].status); + r.out.ctr->ctr1->array[0].status); return false; } printf ("(expected) error\n"); break; default: - if (r.out.ctr.ctr1->array[0].status != DRSUAPI_DS_NAME_STATUS_OK) { - printf("Error: %d\n", r.out.ctr.ctr1->array[0].status); + if (r.out.ctr->ctr1->array[0].status != DRSUAPI_DS_NAME_STATUS_OK) { + printf("Error: %d\n", r.out.ctr->ctr1->array[0].status); return false; } } @@ -139,15 +147,15 @@ static bool test_DsCrackNamesMatrix(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, n_from[i] = NULL; break; default: - n_from[i] = r.out.ctr.ctr1->array[0].result_name; + n_from[i] = r.out.ctr->ctr1->array[0].result_name; printf("%s\n", n_from[i]); } } for (i = 0; i < ARRAY_SIZE(formats); i++) { for (j = 0; j < ARRAY_SIZE(formats); j++) { - r.in.req.req1.format_offered = formats[i]; - r.in.req.req1.format_desired = formats[j]; + r.in.req->req1.format_offered = formats[i]; + r.in.req->req1.format_desired = formats[j]; if (!n_from[i]) { n_matrix[i][j] = NULL; continue; @@ -160,11 +168,11 @@ static bool test_DsCrackNamesMatrix(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); } printf("testing DsCrackNames (matrix) with name '%s' from format: %d desired format:%d failed - %s", - names[0].str, r.in.req.req1.format_offered, r.in.req.req1.format_desired, errstr); + names[0].str, r.in.req->req1.format_offered, r.in.req->req1.format_desired, errstr); ret = false; } else if (!W_ERROR_IS_OK(r.out.result)) { printf("testing DsCrackNames (matrix) with name '%s' from format: %d desired format:%d failed - %s", - names[0].str, r.in.req.req1.format_offered, r.in.req.req1.format_desired, + names[0].str, r.in.req->req1.format_offered, r.in.req->req1.format_desired, win_errstr(r.out.result)); ret = false; } @@ -172,8 +180,8 @@ static bool test_DsCrackNamesMatrix(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, if (!ret) { return ret; } - if (r.out.ctr.ctr1->array[0].status == DRSUAPI_DS_NAME_STATUS_OK) { - n_matrix[i][j] = r.out.ctr.ctr1->array[0].result_name; + if (r.out.ctr->ctr1->array[0].status == DRSUAPI_DS_NAME_STATUS_OK) { + n_matrix[i][j] = r.out.ctr->ctr1->array[0].result_name; } else { n_matrix[i][j] = NULL; } @@ -211,6 +219,9 @@ bool test_DsCrackNames(struct torture_context *tctx, { NTSTATUS status; struct drsuapi_DsCrackNames r; + union drsuapi_DsNameRequest req; + int32_t level_out; + union drsuapi_DsNameCtr ctr; struct drsuapi_DsNameString names[1]; bool ret = true; const char *dns_domain; @@ -233,21 +244,25 @@ bool test_DsCrackNames(struct torture_context *tctx, ZERO_STRUCT(r); r.in.bind_handle = &priv->bind_handle; r.in.level = 1; - r.in.req.req1.codepage = 1252; /* german */ - r.in.req.req1.language = 0x00000407; /* german */ - r.in.req.req1.count = 1; - r.in.req.req1.names = names; - r.in.req.req1.format_flags = DRSUAPI_DS_NAME_FLAG_NO_FLAGS; + r.in.req = &req; + r.in.req->req1.codepage = 1252; /* german */ + r.in.req->req1.language = 0x00000407; /* german */ + r.in.req->req1.count = 1; + r.in.req->req1.names = names; + r.in.req->req1.format_flags = DRSUAPI_DS_NAME_FLAG_NO_FLAGS; + + r.in.req->req1.format_offered = DRSUAPI_DS_NAME_FORMAT_SID_OR_SID_HISTORY; + r.in.req->req1.format_desired = DRSUAPI_DS_NAME_FORMAT_NT4_ACCOUNT; - r.in.req.req1.format_offered = DRSUAPI_DS_NAME_FORMAT_SID_OR_SID_HISTORY; - r.in.req.req1.format_desired = DRSUAPI_DS_NAME_FORMAT_NT4_ACCOUNT; + r.out.level_out = &level_out; + r.out.ctr = &ctr; dom_sid = dom_sid_string(mem_ctx, torture_join_sid(priv->join)); names[0].str = dom_sid; printf("testing DsCrackNames with name '%s' desired format:%d\n", - names[0].str, r.in.req.req1.format_desired); + names[0].str, r.in.req->req1.format_desired); status = dcerpc_drsuapi_DsCrackNames(p, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { @@ -260,8 +275,8 @@ bool test_DsCrackNames(struct torture_context *tctx, } else if (!W_ERROR_IS_OK(r.out.result)) { printf("DsCrackNames failed - %s\n", win_errstr(r.out.result)); ret = false; - } else if (r.out.ctr.ctr1->array[0].status != DRSUAPI_DS_NAME_STATUS_OK) { - printf("DsCrackNames failed on name - %d\n", r.out.ctr.ctr1->array[0].status); + } else if (r.out.ctr->ctr1->array[0].status != DRSUAPI_DS_NAME_STATUS_OK) { + printf("DsCrackNames failed on name - %d\n", r.out.ctr->ctr1->array[0].status); ret = false; } @@ -269,13 +284,13 @@ bool test_DsCrackNames(struct torture_context *tctx, return ret; } - dns_domain = r.out.ctr.ctr1->array[0].dns_domain_name; - nt4_domain = r.out.ctr.ctr1->array[0].result_name; + dns_domain = r.out.ctr->ctr1->array[0].dns_domain_name; + nt4_domain = r.out.ctr->ctr1->array[0].result_name; - r.in.req.req1.format_desired = DRSUAPI_DS_NAME_FORMAT_GUID; + r.in.req->req1.format_desired = DRSUAPI_DS_NAME_FORMAT_GUID; printf("testing DsCrackNames with name '%s' desired format:%d\n", - names[0].str, r.in.req.req1.format_desired); + names[0].str, r.in.req->req1.format_desired); status = dcerpc_drsuapi_DsCrackNames(p, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { @@ -288,8 +303,8 @@ bool test_DsCrackNames(struct torture_context *tctx, } else if (!W_ERROR_IS_OK(r.out.result)) { printf("DsCrackNames failed - %s\n", win_errstr(r.out.result)); ret = false; - } else if (r.out.ctr.ctr1->array[0].status != DRSUAPI_DS_NAME_STATUS_OK) { - printf("DsCrackNames failed on name - %d\n", r.out.ctr.ctr1->array[0].status); + } else if (r.out.ctr->ctr1->array[0].status != DRSUAPI_DS_NAME_STATUS_OK) { + printf("DsCrackNames failed on name - %d\n", r.out.ctr->ctr1->array[0].status); ret = false; } @@ -297,14 +312,14 @@ bool test_DsCrackNames(struct torture_context *tctx, return ret; } - priv->domain_dns_name = r.out.ctr.ctr1->array[0].dns_domain_name; - priv->domain_guid_str = r.out.ctr.ctr1->array[0].result_name; + priv->domain_dns_name = r.out.ctr->ctr1->array[0].dns_domain_name; + priv->domain_guid_str = r.out.ctr->ctr1->array[0].result_name; GUID_from_string(priv->domain_guid_str, &priv->domain_guid); - r.in.req.req1.format_desired = DRSUAPI_DS_NAME_FORMAT_FQDN_1779; + r.in.req->req1.format_desired = DRSUAPI_DS_NAME_FORMAT_FQDN_1779; printf("testing DsCrackNames with name '%s' desired format:%d\n", - names[0].str, r.in.req.req1.format_desired); + names[0].str, r.in.req->req1.format_desired); status = dcerpc_drsuapi_DsCrackNames(p, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { @@ -317,8 +332,8 @@ bool test_DsCrackNames(struct torture_context *tctx, } else if (!W_ERROR_IS_OK(r.out.result)) { printf("DsCrackNames failed - %s\n", win_errstr(r.out.result)); ret = false; - } else if (r.out.ctr.ctr1->array[0].status != DRSUAPI_DS_NAME_STATUS_OK) { - printf("DsCrackNames failed on name - %d\n", r.out.ctr.ctr1->array[0].status); + } else if (r.out.ctr->ctr1->array[0].status != DRSUAPI_DS_NAME_STATUS_OK) { + printf("DsCrackNames failed on name - %d\n", r.out.ctr->ctr1->array[0].status); ret = false; } @@ -328,7 +343,7 @@ bool test_DsCrackNames(struct torture_context *tctx, ldb = ldb_init(mem_ctx, tctx->ev); - realm_dn_str = r.out.ctr.ctr1->array[0].result_name; + realm_dn_str = r.out.ctr->ctr1->array[0].result_name; realm_dn = ldb_dn_new(mem_ctx, ldb, realm_dn_str); realm_canonical = ldb_dn_canonical_string(mem_ctx, realm_dn); @@ -350,12 +365,12 @@ bool test_DsCrackNames(struct torture_context *tctx, return false; }; - r.in.req.req1.format_offered = DRSUAPI_DS_NAME_FORMAT_NT4_ACCOUNT; - r.in.req.req1.format_desired = DRSUAPI_DS_NAME_FORMAT_FQDN_1779; + r.in.req->req1.format_offered = DRSUAPI_DS_NAME_FORMAT_NT4_ACCOUNT; + r.in.req->req1.format_desired = DRSUAPI_DS_NAME_FORMAT_FQDN_1779; names[0].str = nt4_domain; printf("testing DsCrackNames with name '%s' desired format:%d\n", - names[0].str, r.in.req.req1.format_desired); + names[0].str, r.in.req->req1.format_desired); status = dcerpc_drsuapi_DsCrackNames(p, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { @@ -368,8 +383,8 @@ bool test_DsCrackNames(struct torture_context *tctx, } else if (!W_ERROR_IS_OK(r.out.result)) { printf("DsCrackNames failed - %s\n", win_errstr(r.out.result)); ret = false; - } else if (r.out.ctr.ctr1->array[0].status != DRSUAPI_DS_NAME_STATUS_OK) { - printf("DsCrackNames failed on name - %d\n", r.out.ctr.ctr1->array[0].status); + } else if (r.out.ctr->ctr1->array[0].status != DRSUAPI_DS_NAME_STATUS_OK) { + printf("DsCrackNames failed on name - %d\n", r.out.ctr->ctr1->array[0].status); ret = false; } @@ -377,14 +392,14 @@ bool test_DsCrackNames(struct torture_context *tctx, return ret; } - priv->domain_obj_dn = r.out.ctr.ctr1->array[0].result_name; + priv->domain_obj_dn = r.out.ctr->ctr1->array[0].result_name; - r.in.req.req1.format_offered = DRSUAPI_DS_NAME_FORMAT_NT4_ACCOUNT; - r.in.req.req1.format_desired = DRSUAPI_DS_NAME_FORMAT_FQDN_1779; + r.in.req->req1.format_offered = DRSUAPI_DS_NAME_FORMAT_NT4_ACCOUNT; + r.in.req->req1.format_desired = DRSUAPI_DS_NAME_FORMAT_FQDN_1779; names[0].str = talloc_asprintf(mem_ctx, "%s%s$", nt4_domain, test_dc); printf("testing DsCrackNames with name '%s' desired format:%d\n", - names[0].str, r.in.req.req1.format_desired); + names[0].str, r.in.req->req1.format_desired); status = dcerpc_drsuapi_DsCrackNames(p, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { @@ -397,8 +412,8 @@ bool test_DsCrackNames(struct torture_context *tctx, } else if (!W_ERROR_IS_OK(r.out.result)) { printf("DsCrackNames failed - %s\n", win_errstr(r.out.result)); ret = false; - } else if (r.out.ctr.ctr1->array[0].status != DRSUAPI_DS_NAME_STATUS_OK) { - printf("DsCrackNames failed on name - %d\n", r.out.ctr.ctr1->array[0].status); + } else if (r.out.ctr->ctr1->array[0].status != DRSUAPI_DS_NAME_STATUS_OK) { + printf("DsCrackNames failed on name - %d\n", r.out.ctr->ctr1->array[0].status); ret = false; } @@ -406,14 +421,14 @@ bool test_DsCrackNames(struct torture_context *tctx, return ret; } - FQDN_1779_name = r.out.ctr.ctr1->array[0].result_name; + FQDN_1779_name = r.out.ctr->ctr1->array[0].result_name; - r.in.req.req1.format_offered = DRSUAPI_DS_NAME_FORMAT_GUID; - r.in.req.req1.format_desired = DRSUAPI_DS_NAME_FORMAT_FQDN_1779; + r.in.req->req1.format_offered = DRSUAPI_DS_NAME_FORMAT_GUID; + r.in.req->req1.format_desired = DRSUAPI_DS_NAME_FORMAT_FQDN_1779; names[0].str = priv->domain_guid_str; printf("testing DsCrackNames with name '%s' desired format:%d\n", - names[0].str, r.in.req.req1.format_desired); + names[0].str, r.in.req->req1.format_desired); status = dcerpc_drsuapi_DsCrackNames(p, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { @@ -426,8 +441,8 @@ bool test_DsCrackNames(struct torture_context *tctx, } else if (!W_ERROR_IS_OK(r.out.result)) { printf("DsCrackNames failed - %s\n", win_errstr(r.out.result)); ret = false; - } else if (r.out.ctr.ctr1->array[0].status != DRSUAPI_DS_NAME_STATUS_OK) { - printf("DsCrackNames failed on name - %d\n", r.out.ctr.ctr1->array[0].status); + } else if (r.out.ctr->ctr1->array[0].status != DRSUAPI_DS_NAME_STATUS_OK) { + printf("DsCrackNames failed on name - %d\n", r.out.ctr->ctr1->array[0].status); ret = false; } @@ -435,8 +450,8 @@ bool test_DsCrackNames(struct torture_context *tctx, return ret; } - if (strcmp(priv->domain_dns_name, r.out.ctr.ctr1->array[0].dns_domain_name) != 0) { - printf("DsCrackNames failed to return same DNS name - expected %s got %s\n", priv->domain_dns_name, r.out.ctr.ctr1->array[0].dns_domain_name); + if (strcmp(priv->domain_dns_name, r.out.ctr->ctr1->array[0].dns_domain_name) != 0) { + printf("DsCrackNames failed to return same DNS name - expected %s got %s\n", priv->domain_dns_name, r.out.ctr->ctr1->array[0].dns_domain_name); return false; } @@ -920,17 +935,17 @@ bool test_DsCrackNames(struct torture_context *tctx, for (i=0; i < ARRAY_SIZE(crack); i++) { const char *comment; - r.in.req.req1.format_flags = crack[i].flags; - r.in.req.req1.format_offered = crack[i].format_offered; - r.in.req.req1.format_desired = crack[i].format_desired; + r.in.req->req1.format_flags = crack[i].flags; + r.in.req->req1.format_offered = crack[i].format_offered; + r.in.req->req1.format_desired = crack[i].format_desired; names[0].str = crack[i].str; if (crack[i].comment) { comment = talloc_asprintf(mem_ctx, "'%s' with name '%s' desired format:%d\n", - crack[i].comment, names[0].str, r.in.req.req1.format_desired); + crack[i].comment, names[0].str, r.in.req->req1.format_desired); } else { comment = talloc_asprintf(mem_ctx, "'%s' desired format:%d\n", - names[0].str, r.in.req.req1.format_desired); + names[0].str, r.in.req->req1.format_desired); } if (crack[i].skip) { printf("skipping: %s", comment); @@ -947,11 +962,11 @@ bool test_DsCrackNames(struct torture_context *tctx, } else if (!W_ERROR_IS_OK(r.out.result)) { printf("DsCrackNames failed - %s\n", win_errstr(r.out.result)); ret = false; - } else if (r.out.ctr.ctr1->array[0].status != crack[i].status) { + } else if (r.out.ctr->ctr1->array[0].status != crack[i].status) { if (crack[i].alternate_status) { - if (r.out.ctr.ctr1->array[0].status != crack[i].alternate_status) { + if (r.out.ctr->ctr1->array[0].status != crack[i].alternate_status) { printf("DsCrackNames unexpected status %d, wanted %d or %d on: %s\n", - r.out.ctr.ctr1->array[0].status, + r.out.ctr->ctr1->array[0].status, crack[i].status, crack[i].alternate_status, comment); @@ -959,30 +974,30 @@ bool test_DsCrackNames(struct torture_context *tctx, } } else { printf("DsCrackNames unexpected status %d, wanted %d on: %s\n", - r.out.ctr.ctr1->array[0].status, + r.out.ctr->ctr1->array[0].status, crack[i].status, comment); ret = false; } } else if (crack[i].expected_str - && (strcmp(r.out.ctr.ctr1->array[0].result_name, + && (strcmp(r.out.ctr->ctr1->array[0].result_name, crack[i].expected_str) != 0)) { - if (strcasecmp(r.out.ctr.ctr1->array[0].result_name, + if (strcasecmp(r.out.ctr->ctr1->array[0].result_name, crack[i].expected_str) != 0) { printf("DsCrackNames failed - got %s, expected %s on %s\n", - r.out.ctr.ctr1->array[0].result_name, + r.out.ctr->ctr1->array[0].result_name, crack[i].expected_str, comment); ret = false; } else { printf("(warning) DsCrackNames returned different case - got %s, expected %s on %s\n", - r.out.ctr.ctr1->array[0].result_name, + r.out.ctr->ctr1->array[0].result_name, crack[i].expected_str, comment); } } else if (crack[i].expected_dns - && (strcmp(r.out.ctr.ctr1->array[0].dns_domain_name, + && (strcmp(r.out.ctr->ctr1->array[0].dns_domain_name, crack[i].expected_dns) != 0)) { printf("DsCrackNames failed - got DNS name %s, expected %s on %s\n", - r.out.ctr.ctr1->array[0].result_name, + r.out.ctr->ctr1->array[0].result_name, crack[i].expected_str, comment); ret = false; } diff --git a/source4/torture/rpc/dssync.c b/source4/torture/rpc/dssync.c index 2070485a19..bee2658816 100644 --- a/source4/torture/rpc/dssync.c +++ b/source4/torture/rpc/dssync.c @@ -265,6 +265,9 @@ static bool test_GetInfo(struct torture_context *tctx, struct DsSyncTest *ctx) { NTSTATUS status; struct drsuapi_DsCrackNames r; + union drsuapi_DsNameRequest req; + union drsuapi_DsNameCtr ctr; + int32_t level_out = 0; struct drsuapi_DsNameString names[1]; bool ret = true; struct cldap_socket *cldap; @@ -274,15 +277,19 @@ static bool test_GetInfo(struct torture_context *tctx, struct DsSyncTest *ctx) r.in.bind_handle = &ctx->admin.drsuapi.bind_handle; r.in.level = 1; - r.in.req.req1.codepage = 1252; /* western european */ - r.in.req.req1.language = 0x00000407; /* german */ - r.in.req.req1.count = 1; - r.in.req.req1.names = names; - r.in.req.req1.format_flags = DRSUAPI_DS_NAME_FLAG_NO_FLAGS; - r.in.req.req1.format_offered = DRSUAPI_DS_NAME_FORMAT_NT4_ACCOUNT; - r.in.req.req1.format_desired = DRSUAPI_DS_NAME_FORMAT_FQDN_1779; + r.in.req = &req; + r.in.req->req1.codepage = 1252; /* western european */ + r.in.req->req1.language = 0x00000407; /* german */ + r.in.req->req1.count = 1; + r.in.req->req1.names = names; + r.in.req->req1.format_flags = DRSUAPI_DS_NAME_FLAG_NO_FLAGS; + r.in.req->req1.format_offered = DRSUAPI_DS_NAME_FORMAT_NT4_ACCOUNT; + r.in.req->req1.format_desired = DRSUAPI_DS_NAME_FORMAT_FQDN_1779; names[0].str = talloc_asprintf(ctx, "%s\\", lp_workgroup(tctx->lp_ctx)); + r.out.level_out = &level_out; + r.out.ctr = &ctr; + status = dcerpc_drsuapi_DsCrackNames(ctx->admin.drsuapi.pipe, ctx, &r); if (!NT_STATUS_IS_OK(status)) { const char *errstr = nt_errstr(status); @@ -296,7 +303,7 @@ static bool test_GetInfo(struct torture_context *tctx, struct DsSyncTest *ctx) return false; } - ctx->domain_dn = r.out.ctr.ctr1->array[0].result_name; + ctx->domain_dn = r.out.ctr->ctr1->array[0].result_name; ZERO_STRUCT(search); search.in.dest_address = ctx->drsuapi_binding->host; @@ -592,6 +599,7 @@ static bool test_FetchData(struct torture_context *tctx, struct DsSyncTest *ctx) uint64_t highest_usn = 0; const char *partition = NULL; struct drsuapi_DsGetNCChanges r; + union drsuapi_DsGetNCChangesRequest req; struct drsuapi_DsReplicaObjectIdentifier nc; struct drsuapi_DsGetNCChangesCtr1 *ctr1 = NULL; struct drsuapi_DsGetNCChangesCtr6 *ctr6 = NULL; @@ -642,37 +650,38 @@ static bool test_FetchData(struct torture_context *tctx, struct DsSyncTest *ctx) array[i].level); r.in.bind_handle = &ctx->new_dc.drsuapi.bind_handle; - r.in.level = &array[i].level; + r.in.level = array[i].level; - switch (*r.in.level) { + switch (r.in.level) { case 5: nc.guid = null_guid; nc.sid = null_sid; nc.dn = partition; - r.in.req.req5.destination_dsa_guid = ctx->new_dc.invocation_id; - r.in.req.req5.source_dsa_invocation_id = null_guid; - r.in.req.req5.naming_context = &nc; - r.in.req.req5.highwatermark.tmp_highest_usn = highest_usn; - r.in.req.req5.highwatermark.reserved_usn = 0; - r.in.req.req5.highwatermark.highest_usn = highest_usn; - r.in.req.req5.uptodateness_vector = NULL; - r.in.req.req5.replica_flags = 0; + r.in.req = &req; + r.in.req->req5.destination_dsa_guid = ctx->new_dc.invocation_id; + r.in.req->req5.source_dsa_invocation_id = null_guid; + r.in.req->req5.naming_context = &nc; + r.in.req->req5.highwatermark.tmp_highest_usn = highest_usn; + r.in.req->req5.highwatermark.reserved_usn = 0; + r.in.req->req5.highwatermark.highest_usn = highest_usn; + r.in.req->req5.uptodateness_vector = NULL; + r.in.req->req5.replica_flags = 0; if (lp_parm_bool(tctx->lp_ctx, NULL, "dssync", "compression", false)) { - r.in.req.req5.replica_flags |= DRSUAPI_DS_REPLICA_NEIGHBOUR_COMPRESS_CHANGES; + r.in.req->req5.replica_flags |= DRSUAPI_DS_REPLICA_NEIGHBOUR_COMPRESS_CHANGES; } if (lp_parm_bool(tctx->lp_ctx, NULL, "dssync", "neighbour_writeable", true)) { - r.in.req.req5.replica_flags |= DRSUAPI_DS_REPLICA_NEIGHBOUR_WRITEABLE; + r.in.req->req5.replica_flags |= DRSUAPI_DS_REPLICA_NEIGHBOUR_WRITEABLE; } - r.in.req.req5.replica_flags |= DRSUAPI_DS_REPLICA_NEIGHBOUR_SYNC_ON_STARTUP + r.in.req->req5.replica_flags |= DRSUAPI_DS_REPLICA_NEIGHBOUR_SYNC_ON_STARTUP | DRSUAPI_DS_REPLICA_NEIGHBOUR_DO_SCHEDULED_SYNCS | DRSUAPI_DS_REPLICA_NEIGHBOUR_RETURN_OBJECT_PARENTS | DRSUAPI_DS_REPLICA_NEIGHBOUR_NEVER_SYNCED ; - r.in.req.req5.max_object_count = 133; - r.in.req.req5.max_ndr_size = 1336770; - r.in.req.req5.extended_op = DRSUAPI_EXOP_NONE; - r.in.req.req5.fsmo_info = 0; + r.in.req->req5.max_object_count = 133; + r.in.req->req5.max_ndr_size = 1336770; + r.in.req->req5.extended_op = DRSUAPI_EXOP_NONE; + r.in.req->req5.fsmo_info = 0; break; case 8: @@ -680,35 +689,36 @@ static bool test_FetchData(struct torture_context *tctx, struct DsSyncTest *ctx) nc.sid = null_sid; nc.dn = partition; /* nc.dn can be set to any other ad partition */ - - r.in.req.req8.destination_dsa_guid = ctx->new_dc.invocation_id; - r.in.req.req8.source_dsa_invocation_id = null_guid; - r.in.req.req8.naming_context = &nc; - r.in.req.req8.highwatermark.tmp_highest_usn = highest_usn; - r.in.req.req8.highwatermark.reserved_usn = 0; - r.in.req.req8.highwatermark.highest_usn = highest_usn; - r.in.req.req8.uptodateness_vector = NULL; - r.in.req.req8.replica_flags = 0; + + r.in.req = &req; + r.in.req->req8.destination_dsa_guid = ctx->new_dc.invocation_id; + r.in.req->req8.source_dsa_invocation_id = null_guid; + r.in.req->req8.naming_context = &nc; + r.in.req->req8.highwatermark.tmp_highest_usn = highest_usn; + r.in.req->req8.highwatermark.reserved_usn = 0; + r.in.req->req8.highwatermark.highest_usn = highest_usn; + r.in.req->req8.uptodateness_vector = NULL; + r.in.req->req8.replica_flags = 0; if (lp_parm_bool(tctx->lp_ctx, NULL, "dssync", "compression", false)) { - r.in.req.req8.replica_flags |= DRSUAPI_DS_REPLICA_NEIGHBOUR_COMPRESS_CHANGES; + r.in.req->req8.replica_flags |= DRSUAPI_DS_REPLICA_NEIGHBOUR_COMPRESS_CHANGES; } if (lp_parm_bool(tctx->lp_ctx, NULL, "dssync", "neighbour_writeable", true)) { - r.in.req.req8.replica_flags |= DRSUAPI_DS_REPLICA_NEIGHBOUR_WRITEABLE; + r.in.req->req8.replica_flags |= DRSUAPI_DS_REPLICA_NEIGHBOUR_WRITEABLE; } - r.in.req.req8.replica_flags |= DRSUAPI_DS_REPLICA_NEIGHBOUR_SYNC_ON_STARTUP + r.in.req->req8.replica_flags |= DRSUAPI_DS_REPLICA_NEIGHBOUR_SYNC_ON_STARTUP | DRSUAPI_DS_REPLICA_NEIGHBOUR_DO_SCHEDULED_SYNCS | DRSUAPI_DS_REPLICA_NEIGHBOUR_RETURN_OBJECT_PARENTS | DRSUAPI_DS_REPLICA_NEIGHBOUR_NEVER_SYNCED ; - r.in.req.req8.max_object_count = 402; - r.in.req.req8.max_ndr_size = 402116; + r.in.req->req8.max_object_count = 402; + r.in.req->req8.max_ndr_size = 402116; - r.in.req.req8.extended_op = DRSUAPI_EXOP_NONE; - r.in.req.req8.fsmo_info = 0; - r.in.req.req8.partial_attribute_set = NULL; - r.in.req.req8.partial_attribute_set_ex = NULL; - r.in.req.req8.mapping_ctr.num_mappings = 0; - r.in.req.req8.mapping_ctr.mappings = NULL; + r.in.req->req8.extended_op = DRSUAPI_EXOP_NONE; + r.in.req->req8.fsmo_info = 0; + r.in.req->req8.partial_attribute_set = NULL; + r.in.req->req8.partial_attribute_set_ex = NULL; + r.in.req->req8.mapping_ctr.num_mappings = 0; + r.in.req->req8.mapping_ctr.mappings = NULL; break; } @@ -716,19 +726,23 @@ static bool test_FetchData(struct torture_context *tctx, struct DsSyncTest *ctx) printf("Dumping AD partition: %s\n", nc.dn); for (y=0; ;y++) { int32_t _level = 0; + union drsuapi_DsGetNCChangesCtr ctr; + ZERO_STRUCT(r.out); - r.out.level = &_level; - if (*r.in.level == 5) { + r.out.level_out = &_level; + r.out.ctr = &ctr; + + if (r.in.level == 5) { DEBUG(0,("start[%d] tmp_higest_usn: %llu , highest_usn: %llu\n",y, - (long long)r.in.req.req5.highwatermark.tmp_highest_usn, - (long long)r.in.req.req5.highwatermark.highest_usn)); + (long long)r.in.req->req5.highwatermark.tmp_highest_usn, + (long long)r.in.req->req5.highwatermark.highest_usn)); } - if (*r.in.level == 8) { + if (r.in.level == 8) { DEBUG(0,("start[%d] tmp_higest_usn: %llu , highest_usn: %llu\n",y, - (long long)r.in.req.req8.highwatermark.tmp_highest_usn, - (long long)r.in.req.req8.highwatermark.highest_usn)); + (long long)r.in.req->req8.highwatermark.tmp_highest_usn, + (long long)r.in.req->req8.highwatermark.highest_usn)); } status = dcerpc_drsuapi_DsGetNCChanges(ctx->new_dc.drsuapi.pipe, ctx, &r); @@ -744,13 +758,13 @@ static bool test_FetchData(struct torture_context *tctx, struct DsSyncTest *ctx) ret = false; } - if (ret == true && *r.out.level == 1) { + if (ret == true && *r.out.level_out == 1) { out_level = 1; - ctr1 = &r.out.ctr.ctr1; - } else if (ret == true && *r.out.level == 2 && - r.out.ctr.ctr2.mszip1.ts) { + ctr1 = &r.out.ctr->ctr1; + } else if (ret == true && *r.out.level_out == 2 && + r.out.ctr->ctr2.mszip1.ts) { out_level = 1; - ctr1 = &r.out.ctr.ctr2.mszip1.ts->ctr1; + ctr1 = &r.out.ctr->ctr2.mszip1.ts->ctr1; } if (out_level == 1) { @@ -761,26 +775,26 @@ static bool test_FetchData(struct torture_context *tctx, struct DsSyncTest *ctx) test_analyse_objects(tctx, ctx, &gensec_skey, ctr1->first_object); if (ctr1->more_data) { - r.in.req.req5.highwatermark = ctr1->new_highwatermark; + r.in.req->req5.highwatermark = ctr1->new_highwatermark; continue; } } - if (ret == true && *r.out.level == 6) { + if (ret == true && *r.out.level_out == 6) { out_level = 6; - ctr6 = &r.out.ctr.ctr6; - } else if (ret == true && *r.out.level == 7 - && r.out.ctr.ctr7.level == 6 - && r.out.ctr.ctr7.type == DRSUAPI_COMPRESSION_TYPE_MSZIP - && r.out.ctr.ctr7.ctr.mszip6.ts) { + ctr6 = &r.out.ctr->ctr6; + } else if (ret == true && *r.out.level_out == 7 + && r.out.ctr->ctr7.level == 6 + && r.out.ctr->ctr7.type == DRSUAPI_COMPRESSION_TYPE_MSZIP + && r.out.ctr->ctr7.ctr.mszip6.ts) { out_level = 6; - ctr6 = &r.out.ctr.ctr7.ctr.mszip6.ts->ctr6; - } else if (ret == true && *r.out.level == 7 - && r.out.ctr.ctr7.level == 6 - && r.out.ctr.ctr7.type == DRSUAPI_COMPRESSION_TYPE_XPRESS - && r.out.ctr.ctr7.ctr.xpress6.ts) { + ctr6 = &r.out.ctr->ctr7.ctr.mszip6.ts->ctr6; + } else if (ret == true && *r.out.level_out == 7 + && r.out.ctr->ctr7.level == 6 + && r.out.ctr->ctr7.type == DRSUAPI_COMPRESSION_TYPE_XPRESS + && r.out.ctr->ctr7.ctr.xpress6.ts) { out_level = 6; - ctr6 = &r.out.ctr.ctr7.ctr.xpress6.ts->ctr6; + ctr6 = &r.out.ctr->ctr7.ctr.xpress6.ts->ctr6; } if (out_level == 6) { @@ -791,7 +805,7 @@ static bool test_FetchData(struct torture_context *tctx, struct DsSyncTest *ctx) test_analyse_objects(tctx, ctx, &gensec_skey, ctr6->first_object); if (ctr6->more_data) { - r.in.req.req8.highwatermark = ctr6->new_highwatermark; + r.in.req->req8.highwatermark = ctr6->new_highwatermark; continue; } } diff --git a/source4/utils/ntlm_auth.c b/source4/utils/ntlm_auth.c index 6a6302837e..1ec87c6b42 100644 --- a/source4/utils/ntlm_auth.c +++ b/source4/utils/ntlm_auth.c @@ -869,7 +869,7 @@ static void manage_ntlm_server_1_request(enum stdio_helper_mode stdio_helper_mod } if (strequal(request, "LANMAN-Challenge")) { - challenge = strhex_to_data_blob(parameter); + challenge = strhex_to_data_blob(NULL, parameter); if (challenge.length != 8) { mux_printf(mux_id, "Error: hex decode of %s failed! (got %d bytes, expected 8)\n.\n", parameter, @@ -877,7 +877,7 @@ static void manage_ntlm_server_1_request(enum stdio_helper_mode stdio_helper_mod challenge = data_blob(NULL, 0); } } else if (strequal(request, "NT-Response")) { - nt_response = strhex_to_data_blob(parameter); + nt_response = strhex_to_data_blob(NULL, parameter); if (nt_response.length < 24) { mux_printf(mux_id, "Error: hex decode of %s failed! (only got %d bytes, needed at least 24)\n.\n", parameter, @@ -885,7 +885,7 @@ static void manage_ntlm_server_1_request(enum stdio_helper_mode stdio_helper_mod nt_response = data_blob(NULL, 0); } } else if (strequal(request, "LANMAN-Response")) { - lm_response = strhex_to_data_blob(parameter); + lm_response = strhex_to_data_blob(NULL, parameter); if (lm_response.length != 24) { mux_printf(mux_id, "Error: hex decode of %s failed! (got %d bytes, expected 24)\n.\n", parameter, |