From bfd8bded8ea8544683b4cc754c7e0fc8ab824776 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 13 Jul 2004 18:05:02 +0000 Subject: r1481: add idl file and torture test dummies for DRSUapi (the Active Directory Replication Protocol) I'll try to fill the idl file as part of a study project together with some other students... metze (This used to be commit 3fc9abcad712c4cc5c9879df0acaa5a19a3d8718) --- source4/torture/rpc/drsuapi.c | 230 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 230 insertions(+) create mode 100644 source4/torture/rpc/drsuapi.c (limited to 'source4/torture/rpc/drsuapi.c') diff --git a/source4/torture/rpc/drsuapi.c b/source4/torture/rpc/drsuapi.c new file mode 100644 index 0000000000..a2f3eb6104 --- /dev/null +++ b/source4/torture/rpc/drsuapi.c @@ -0,0 +1,230 @@ +/* + Unix SMB/CIFS implementation. + + DRSUapi tests + + Copyright (C) Andrew Tridgell 2003 + Copyright (C) Stefan (metze) Metzmacher 2004 + + 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 2 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, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#include "includes.h" + + +static void reopen(struct dcerpc_pipe **p, const struct dcerpc_interface_table *iface) +{ + NTSTATUS status; + + if (*p) { + dcerpc_pipe_close(*p); + } + + status = torture_rpc_connection(p, iface->endpoints->names[0], iface->uuid, iface->if_version); + if (!NT_STATUS_IS_OK(status)) { + printf("Failed to reopen '%s' - %s\n", iface->name, nt_errstr(status)); + exit(1); + } +} + +static void print_depth(int depth) +{ + int i; + for (i=0;ilength + n); + data_blob_clear(&stub_in); + memcpy(stub_in.data, base_in->data, insert_ofs); + memcpy(stub_in.data+insert_ofs+n, base_in->data+insert_ofs, base_in->length-insert_ofs); + + status = dcerpc_request(p, opnum, mem_ctx, &stub_in, &stub_out); + + if (!NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { + print_depth(depth); + printf("expand by %d gives %s\n", n, nt_errstr(status)); + if (n >= 4) { + test_ptr_scan(mem_ctx, iface, opnum, &stub_in, + insert_ofs, insert_ofs+n, depth+1); + } + return; + } else { +#if 0 + print_depth(depth); + printf("expand by %d gives fault 0x%x\n", n, p->last_fault_code); +#endif + } + if (p->last_fault_code == 5) { + reopen(&p, iface); + } + } + + dcerpc_pipe_close(p); +} + + +static void test_ptr_scan(TALLOC_CTX *mem_ctx, const struct dcerpc_interface_table *iface, + int opnum, DATA_BLOB *base_in, int min_ofs, int max_ofs, int depth) +{ + DATA_BLOB stub_in, stub_out; + int ofs; + NTSTATUS status; + struct dcerpc_pipe *p = NULL; + + reopen(&p, iface); + + stub_in = data_blob(NULL, base_in->length); + memcpy(stub_in.data, base_in->data, base_in->length); + + /* work out which elements are pointers */ + for (ofs=min_ofs;ofs<=max_ofs-4;ofs+=4) { + SIVAL(stub_in.data, ofs, 1); + status = dcerpc_request(p, opnum, mem_ctx, &stub_in, &stub_out); + + if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { + print_depth(depth); + printf("possible ptr at ofs %d - fault 0x%08x\n", + ofs-min_ofs, p->last_fault_code); + if (p->last_fault_code == 5) { + reopen(&p, iface); + } + if (depth == 0) { + try_expand(mem_ctx, iface, opnum, &stub_in, ofs+4, depth+1); + } else { + try_expand(mem_ctx, iface, opnum, &stub_in, max_ofs, depth+1); + } + SIVAL(stub_in.data, ofs, 0); + continue; + } + SIVAL(stub_in.data, ofs, 0); + } + + dcerpc_pipe_close(p); +} + + +static void test_scan_call(TALLOC_CTX *mem_ctx, const struct dcerpc_interface_table *iface, int opnum) +{ + DATA_BLOB stub_in, stub_out; + int i; + NTSTATUS status; + struct dcerpc_pipe *p = NULL; + + reopen(&p, iface); + + /* work out the minimum amount of input data */ + for (i=0;i<2000;i++) { + stub_in = data_blob(NULL, i); + data_blob_clear(&stub_in); + + + status = dcerpc_request(p, opnum, mem_ctx, &stub_in, &stub_out); + + if (NT_STATUS_IS_OK(status)) { + printf("opnum %d min_input %d - output %d\n", + opnum, stub_in.length, stub_out.length); + dump_data(0, stub_out.data, stub_out.length); + dcerpc_pipe_close(p); + test_ptr_scan(mem_ctx, iface, opnum, &stub_in, 0, stub_in.length, 0); + return; + } + + if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { + printf("opnum %d size %d fault 0x%08x\n", opnum, i, p->last_fault_code); + if (p->last_fault_code == 5) { + reopen(&p, iface); + } + continue; + } + + printf("opnum %d size %d error %s\n", opnum, i, nt_errstr(status)); + } + + printf("opnum %d minimum not found!?\n", opnum); + dcerpc_pipe_close(p); +} + + +static BOOL test_scan(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) +{ + test_scan_call(mem_ctx, &dcerpc_table_drsuapi, 0x0); + return True; +} + +static BOOL test_DRSBind(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) +{ + NTSTATUS status; + struct DRSUAPI_BIND r; + BOOL ret = True; + + ZERO_STRUCT(r.in.blob); + + status = dcerpc_DRSUAPI_BIND(p, mem_ctx, &r); + if (!NT_STATUS_IS_OK(status)) { + printf("DRSUAPI_BIND level failed - %s\n", nt_errstr(status)); + ret = False; + } + + return ret; +} + +BOOL torture_rpc_drsuapi(int dummy) +{ + NTSTATUS status; + struct dcerpc_pipe *p; + TALLOC_CTX *mem_ctx; + BOOL ret = True; + + mem_ctx = talloc_init("torture_rpc_srvsvc"); + + status = torture_rpc_connection(&p, + DCERPC_DRSUAPI_NAME, + DCERPC_DRSUAPI_UUID, + DCERPC_DRSUAPI_VERSION); + if (!NT_STATUS_IS_OK(status)) { + return False; + } + + if (!test_DRSBind(p, mem_ctx)) { + ret = False; + } + + if (!test_scan(p, mem_ctx)) { + ret = False; + } + + talloc_destroy(mem_ctx); + + torture_rpc_close(p); + + return ret; +} -- cgit From a0cb701b6fac6e75da691e239cd0407b9269533a Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 4 Aug 2004 09:33:41 +0000 Subject: r1649: do a join as dc and run this test as the machine account metze (This used to be commit 59de2b1f528fb82fbfcf9c3783dd733a36d3fb6c) --- source4/torture/rpc/drsuapi.c | 39 +++++++++++++++++++++++++++++++++------ 1 file changed, 33 insertions(+), 6 deletions(-) (limited to 'source4/torture/rpc/drsuapi.c') diff --git a/source4/torture/rpc/drsuapi.c b/source4/torture/rpc/drsuapi.c index a2f3eb6104..2938a1a744 100644 --- a/source4/torture/rpc/drsuapi.c +++ b/source4/torture/rpc/drsuapi.c @@ -23,7 +23,11 @@ #include "includes.h" +static const char *machine_password; +#define TEST_MACHINE_NAME "torturetest" + +#if 0 static void reopen(struct dcerpc_pipe **p, const struct dcerpc_interface_table *iface) { NTSTATUS status; @@ -179,6 +183,7 @@ static BOOL test_scan(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) test_scan_call(mem_ctx, &dcerpc_table_drsuapi, 0x0); return True; } +#endif static BOOL test_DRSBind(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) { @@ -203,28 +208,50 @@ BOOL torture_rpc_drsuapi(int dummy) struct dcerpc_pipe *p; TALLOC_CTX *mem_ctx; BOOL ret = True; + void *join_ctx; + const char *binding = lp_parm_string(-1, "torture", "binding"); + + if (!binding) { + printf("You must specify a ncacn binding string\n"); + return False; + } - mem_ctx = talloc_init("torture_rpc_srvsvc"); + lp_set_cmdline("netbios name", TEST_MACHINE_NAME); + + join_ctx = torture_join_domain(TEST_MACHINE_NAME, lp_workgroup(), ACB_SVRTRUST, + &machine_password); + if (!join_ctx) { + printf("Failed to join as BDC\n"); + return False; + } + + status = dcerpc_pipe_connect(&p, binding, + DCERPC_DRSUAPI_UUID, + DCERPC_DRSUAPI_VERSION, + lp_workgroup(), + TEST_MACHINE_NAME"$", + machine_password); - status = torture_rpc_connection(&p, - DCERPC_DRSUAPI_NAME, - DCERPC_DRSUAPI_UUID, - DCERPC_DRSUAPI_VERSION); if (!NT_STATUS_IS_OK(status)) { return False; } + mem_ctx = talloc_init("torture_rpc_drsuapi"); + if (!test_DRSBind(p, mem_ctx)) { ret = False; } +#if 0 if (!test_scan(p, mem_ctx)) { ret = False; } - +#endif talloc_destroy(mem_ctx); torture_rpc_close(p); + torture_leave_domain(join_ctx); + return ret; } -- cgit From 6766809ba8190f6b65921a42eaa3dc67fab67ce2 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 20 Aug 2004 15:00:22 +0000 Subject: r1961: print out the dcerpc fault code, when we got NT_STATUS_NET_WRITE_FAULT (this need to be done more generic for all dcerpc calls, but for now I just need it in this 2 places) metze (This used to be commit d965f84f69ada2a10e9159aa1743c0bee7790488) --- source4/torture/rpc/drsuapi.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'source4/torture/rpc/drsuapi.c') diff --git a/source4/torture/rpc/drsuapi.c b/source4/torture/rpc/drsuapi.c index 2938a1a744..5a12ef37f4 100644 --- a/source4/torture/rpc/drsuapi.c +++ b/source4/torture/rpc/drsuapi.c @@ -195,7 +195,11 @@ static BOOL test_DRSBind(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) status = dcerpc_DRSUAPI_BIND(p, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { - printf("DRSUAPI_BIND level failed - %s\n", nt_errstr(status)); + const char *errstr = nt_errstr(status); + if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { + errstr = dcerpc_errstr(p->last_fault_code); + } + printf("DRSUAPI_BIND level failed - %s\n", errstr); ret = False; } -- cgit From e7f36ff1a5ec909573ef398d215608e7c9aa71fe Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 30 Aug 2004 03:10:43 +0000 Subject: r2100: rework the dcerpc client side library so that it is async. We now generate a separate *_send() async function for every RPC call, and there is a single dcerpc_ndr_request_recv() call that processes the receive side of any rpc call. The caller can use dcerpc_event_context() to get a pointer to the event context for the pipe so that events can be waited for asynchronously. The only part that remains synchronous is the initial bind calls. These could also be made async if necessary, although I suspect most applications won't need them to be. (This used to be commit f5d004d8eb8c76c03342cace1976b27266cfa1f0) --- source4/torture/rpc/drsuapi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/torture/rpc/drsuapi.c') diff --git a/source4/torture/rpc/drsuapi.c b/source4/torture/rpc/drsuapi.c index 5a12ef37f4..d056ab92da 100644 --- a/source4/torture/rpc/drsuapi.c +++ b/source4/torture/rpc/drsuapi.c @@ -197,7 +197,7 @@ static BOOL test_DRSBind(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) if (!NT_STATUS_IS_OK(status)) { const char *errstr = nt_errstr(status); if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { - errstr = dcerpc_errstr(p->last_fault_code); + errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); } printf("DRSUAPI_BIND level failed - %s\n", errstr); ret = False; -- cgit From df2ed66bb0e592010b3b68734c508690c3f393ea Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 17 Sep 2004 10:44:28 +0000 Subject: r2382: considerably improved the Bind and Unbind IDL and test code. We can now do these two calls successfully against w2k3. note that you must use ncacn_ip_tcp, and must enable dcerpc sealing, otherwise w2k3 refuses the first DRSUAPI call. (This used to be commit 7d3e34742277f264e41739721dbf08036eebb598) --- source4/torture/rpc/drsuapi.c | 208 ++++++------------------------------------ 1 file changed, 30 insertions(+), 178 deletions(-) (limited to 'source4/torture/rpc/drsuapi.c') diff --git a/source4/torture/rpc/drsuapi.c b/source4/torture/rpc/drsuapi.c index d056ab92da..590e8b8f11 100644 --- a/source4/torture/rpc/drsuapi.c +++ b/source4/torture/rpc/drsuapi.c @@ -23,183 +23,47 @@ #include "includes.h" -static const char *machine_password; - #define TEST_MACHINE_NAME "torturetest" -#if 0 -static void reopen(struct dcerpc_pipe **p, const struct dcerpc_interface_table *iface) +static BOOL test_Bind(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, + struct policy_handle *handle) { NTSTATUS status; + struct drsuapi_Bind r; + BOOL ret = True; - if (*p) { - dcerpc_pipe_close(*p); - } + ZERO_STRUCT(r); + r.out.handle = handle; - status = torture_rpc_connection(p, iface->endpoints->names[0], iface->uuid, iface->if_version); + status = dcerpc_drsuapi_Bind(p, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { - printf("Failed to reopen '%s' - %s\n", iface->name, nt_errstr(status)); - exit(1); - } -} - -static void print_depth(int depth) -{ - int i; - for (i=0;ilength + n); - data_blob_clear(&stub_in); - memcpy(stub_in.data, base_in->data, insert_ofs); - memcpy(stub_in.data+insert_ofs+n, base_in->data+insert_ofs, base_in->length-insert_ofs); - - status = dcerpc_request(p, opnum, mem_ctx, &stub_in, &stub_out); - - if (!NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { - print_depth(depth); - printf("expand by %d gives %s\n", n, nt_errstr(status)); - if (n >= 4) { - test_ptr_scan(mem_ctx, iface, opnum, &stub_in, - insert_ofs, insert_ofs+n, depth+1); - } - return; - } else { -#if 0 - print_depth(depth); - printf("expand by %d gives fault 0x%x\n", n, p->last_fault_code); -#endif - } - if (p->last_fault_code == 5) { - reopen(&p, iface); - } - } - - dcerpc_pipe_close(p); -} - - -static void test_ptr_scan(TALLOC_CTX *mem_ctx, const struct dcerpc_interface_table *iface, - int opnum, DATA_BLOB *base_in, int min_ofs, int max_ofs, int depth) -{ - DATA_BLOB stub_in, stub_out; - int ofs; - NTSTATUS status; - struct dcerpc_pipe *p = NULL; - - reopen(&p, iface); - - stub_in = data_blob(NULL, base_in->length); - memcpy(stub_in.data, base_in->data, base_in->length); - - /* work out which elements are pointers */ - for (ofs=min_ofs;ofs<=max_ofs-4;ofs+=4) { - SIVAL(stub_in.data, ofs, 1); - status = dcerpc_request(p, opnum, mem_ctx, &stub_in, &stub_out); - - if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { - print_depth(depth); - printf("possible ptr at ofs %d - fault 0x%08x\n", - ofs-min_ofs, p->last_fault_code); - if (p->last_fault_code == 5) { - reopen(&p, iface); - } - if (depth == 0) { - try_expand(mem_ctx, iface, opnum, &stub_in, ofs+4, depth+1); - } else { - try_expand(mem_ctx, iface, opnum, &stub_in, max_ofs, depth+1); - } - SIVAL(stub_in.data, ofs, 0); - continue; - } - SIVAL(stub_in.data, ofs, 0); - } - - dcerpc_pipe_close(p); -} - - -static void test_scan_call(TALLOC_CTX *mem_ctx, const struct dcerpc_interface_table *iface, int opnum) -{ - DATA_BLOB stub_in, stub_out; - int i; - NTSTATUS status; - struct dcerpc_pipe *p = NULL; - - reopen(&p, iface); - - /* work out the minimum amount of input data */ - for (i=0;i<2000;i++) { - stub_in = data_blob(NULL, i); - data_blob_clear(&stub_in); - - - status = dcerpc_request(p, opnum, mem_ctx, &stub_in, &stub_out); - - if (NT_STATUS_IS_OK(status)) { - printf("opnum %d min_input %d - output %d\n", - opnum, stub_in.length, stub_out.length); - dump_data(0, stub_out.data, stub_out.length); - dcerpc_pipe_close(p); - test_ptr_scan(mem_ctx, iface, opnum, &stub_in, 0, stub_in.length, 0); - return; - } - + const char *errstr = nt_errstr(status); if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { - printf("opnum %d size %d fault 0x%08x\n", opnum, i, p->last_fault_code); - if (p->last_fault_code == 5) { - reopen(&p, iface); - } - continue; + errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); } - - printf("opnum %d size %d error %s\n", opnum, i, nt_errstr(status)); + printf("drsuapi_Bind level failed - %s\n", errstr); + ret = False; } - printf("opnum %d minimum not found!?\n", opnum); - dcerpc_pipe_close(p); -} - - -static BOOL test_scan(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) -{ - test_scan_call(mem_ctx, &dcerpc_table_drsuapi, 0x0); - return True; + return ret; } -#endif -static BOOL test_DRSBind(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) +static BOOL test_Unbind(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, + struct policy_handle *handle) { NTSTATUS status; - struct DRSUAPI_BIND r; + struct drsuapi_Unbind r; BOOL ret = True; - ZERO_STRUCT(r.in.blob); + r.in.handle = handle; - status = dcerpc_DRSUAPI_BIND(p, mem_ctx, &r); + status = dcerpc_drsuapi_Unbind(p, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { const char *errstr = nt_errstr(status); if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); } - printf("DRSUAPI_BIND level failed - %s\n", errstr); + printf("drsuapi_Unbind level failed - %s\n", errstr); ret = False; } @@ -212,37 +76,27 @@ BOOL torture_rpc_drsuapi(int dummy) struct dcerpc_pipe *p; TALLOC_CTX *mem_ctx; BOOL ret = True; - void *join_ctx; - const char *binding = lp_parm_string(-1, "torture", "binding"); + struct policy_handle handle; - if (!binding) { - printf("You must specify a ncacn binding string\n"); + status = torture_rpc_connection(&p, + DCERPC_DRSUAPI_NAME, + DCERPC_DRSUAPI_UUID, + DCERPC_DRSUAPI_VERSION); + if (!NT_STATUS_IS_OK(status)) { return False; } - lp_set_cmdline("netbios name", TEST_MACHINE_NAME); + printf("Connected to DRAUAPI pipe\n"); - join_ctx = torture_join_domain(TEST_MACHINE_NAME, lp_workgroup(), ACB_SVRTRUST, - &machine_password); - if (!join_ctx) { - printf("Failed to join as BDC\n"); - return False; - } + event_loop_once(p->transport.event_context(p)); - status = dcerpc_pipe_connect(&p, binding, - DCERPC_DRSUAPI_UUID, - DCERPC_DRSUAPI_VERSION, - lp_workgroup(), - TEST_MACHINE_NAME"$", - machine_password); + mem_ctx = talloc_init("torture_rpc_drsuapi"); - if (!NT_STATUS_IS_OK(status)) { - return False; + if (!test_Bind(p, mem_ctx, &handle)) { + ret = False; } - mem_ctx = talloc_init("torture_rpc_drsuapi"); - - if (!test_DRSBind(p, mem_ctx)) { + if (!test_Unbind(p, mem_ctx, &handle)) { ret = False; } @@ -255,7 +109,5 @@ BOOL torture_rpc_drsuapi(int dummy) torture_rpc_close(p); - torture_leave_domain(join_ctx); - return ret; } -- cgit From 7b65585eedeb65c8c16a81e60802da01470b7b58 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 17 Sep 2004 14:30:17 +0000 Subject: r2387: fix segfault seems that [in,out,ref] vars should be initialize the [in] and [out] part metze (This used to be commit 47e613a5a1063d8e93e831252db03f19cdb08590) --- source4/torture/rpc/drsuapi.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/torture/rpc/drsuapi.c') diff --git a/source4/torture/rpc/drsuapi.c b/source4/torture/rpc/drsuapi.c index 590e8b8f11..6d69270c40 100644 --- a/source4/torture/rpc/drsuapi.c +++ b/source4/torture/rpc/drsuapi.c @@ -56,6 +56,7 @@ static BOOL test_Unbind(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, BOOL ret = True; r.in.handle = handle; + r.out.handle = handle; status = dcerpc_drsuapi_Unbind(p, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { -- cgit From 8f85b3f77132279d8e79ff9a8a213515a3845fe0 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 20 Sep 2004 10:29:13 +0000 Subject: r2442: remove unused event_loop_once() call metze (This used to be commit 3cd63030b1433ddc3ae89e2f45c6f7a27b7d1756) --- source4/torture/rpc/drsuapi.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'source4/torture/rpc/drsuapi.c') diff --git a/source4/torture/rpc/drsuapi.c b/source4/torture/rpc/drsuapi.c index 6d69270c40..309427048f 100644 --- a/source4/torture/rpc/drsuapi.c +++ b/source4/torture/rpc/drsuapi.c @@ -89,8 +89,6 @@ BOOL torture_rpc_drsuapi(int dummy) printf("Connected to DRAUAPI pipe\n"); - event_loop_once(p->transport.event_context(p)); - mem_ctx = talloc_init("torture_rpc_drsuapi"); if (!test_Bind(p, mem_ctx, &handle)) { -- cgit From 594082233fda1e0fa82edaddd6584087d73b26c8 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sun, 10 Oct 2004 01:30:54 +0000 Subject: r2888: - add 'Ds' prefix to Bind and Unbind call on drsuapi - rename handle -> bind_handle - change function types to NTSTATUS metze (This used to be commit de73676342be8dbf39df8d3fe68817932ee71ccb) --- source4/torture/rpc/drsuapi.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'source4/torture/rpc/drsuapi.c') diff --git a/source4/torture/rpc/drsuapi.c b/source4/torture/rpc/drsuapi.c index 309427048f..907183083b 100644 --- a/source4/torture/rpc/drsuapi.c +++ b/source4/torture/rpc/drsuapi.c @@ -25,46 +25,46 @@ #define TEST_MACHINE_NAME "torturetest" -static BOOL test_Bind(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, - struct policy_handle *handle) +static BOOL test_DsBind(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, + struct policy_handle *bind_handle) { NTSTATUS status; - struct drsuapi_Bind r; + struct drsuapi_DsBind r; BOOL ret = True; ZERO_STRUCT(r); - r.out.handle = handle; + r.out.bind_handle = bind_handle; - status = dcerpc_drsuapi_Bind(p, mem_ctx, &r); + status = dcerpc_drsuapi_DsBind(p, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { const char *errstr = nt_errstr(status); if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); } - printf("drsuapi_Bind level failed - %s\n", errstr); + printf("drsuapi_DsBind failed - %s\n", errstr); ret = False; } return ret; } -static BOOL test_Unbind(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, - struct policy_handle *handle) +static BOOL test_DsUnbind(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, + struct policy_handle *bind_handle) { NTSTATUS status; - struct drsuapi_Unbind r; + struct drsuapi_DsUnbind r; BOOL ret = True; - r.in.handle = handle; - r.out.handle = handle; + r.in.bind_handle = bind_handle; + r.out.bind_handle = bind_handle; - status = dcerpc_drsuapi_Unbind(p, mem_ctx, &r); + status = dcerpc_drsuapi_DsUnbind(p, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { const char *errstr = nt_errstr(status); if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); } - printf("drsuapi_Unbind level failed - %s\n", errstr); + printf("drsuapi_DsUnbind failed - %s\n", errstr); ret = False; } @@ -77,7 +77,7 @@ BOOL torture_rpc_drsuapi(int dummy) struct dcerpc_pipe *p; TALLOC_CTX *mem_ctx; BOOL ret = True; - struct policy_handle handle; + struct policy_handle bind_handle; status = torture_rpc_connection(&p, DCERPC_DRSUAPI_NAME, @@ -91,11 +91,11 @@ BOOL torture_rpc_drsuapi(int dummy) mem_ctx = talloc_init("torture_rpc_drsuapi"); - if (!test_Bind(p, mem_ctx, &handle)) { + if (!test_DsBind(p, mem_ctx, &bind_handle)) { ret = False; } - if (!test_Unbind(p, mem_ctx, &handle)) { + if (!test_DsUnbind(p, mem_ctx, &bind_handle)) { ret = False; } -- cgit From 78e29c0491a36285ed1c09a684a9fc516aec4beb Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 13 Oct 2004 14:25:44 +0000 Subject: r2952: add idl and torture test for DsCrackNames (I need to find out what the fields mean but it works) metze (This used to be commit eff51fc623f2e7b57e7e53eb81760684815db2f4) --- source4/torture/rpc/drsuapi.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'source4/torture/rpc/drsuapi.c') diff --git a/source4/torture/rpc/drsuapi.c b/source4/torture/rpc/drsuapi.c index 907183083b..aed7f884d2 100644 --- a/source4/torture/rpc/drsuapi.c +++ b/source4/torture/rpc/drsuapi.c @@ -48,6 +48,40 @@ static BOOL test_DsBind(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, return ret; } +static BOOL test_DsCrackNames(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, + struct policy_handle *bind_handle) +{ + NTSTATUS status; + struct drsuapi_DsCrackNames r; + struct drsuapi_DsCrackNamesInInfo1Names names[1]; + BOOL ret = True; + + ZERO_STRUCT(r); + r.in.bind_handle = bind_handle; + r.in.level = 1; + r.in.in.info1.unknown1 = 0x000004e4; + r.in.in.info1.unknown2 = 0x00000407; + r.in.in.info1.unknown3 = 0x00000000; + r.in.in.info1.unknown4 = 0x00000007; + r.in.in.info1.unknown5 = 0x00000002; + r.in.in.info1.count = 1; + r.in.in.info1.names = names; + + names[0].str = talloc_asprintf(mem_ctx, "%s/", lp_realm()); + + status = dcerpc_drsuapi_DsCrackNames(p, mem_ctx, &r); + if (!NT_STATUS_IS_OK(status)) { + const char *errstr = nt_errstr(status); + if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { + errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); + } + printf("drsuapi_DsCrackNames failed - %s\n", errstr); + ret = False; + } + + return ret; +} + static BOOL test_DsUnbind(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct policy_handle *bind_handle) { @@ -95,6 +129,10 @@ BOOL torture_rpc_drsuapi(int dummy) ret = False; } + if (!test_DsCrackNames(p, mem_ctx, &bind_handle)) { + ret = False; + } + if (!test_DsUnbind(p, mem_ctx, &bind_handle)) { ret = False; } -- cgit From 64344b88d17fa92275f564f972566c4e600e7501 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 14 Oct 2004 09:56:04 +0000 Subject: r2970: - give somefields names and typdef enums for the possible values - do more crackname tests in the torture test - move server code for cracknames to a different file metze (This used to be commit 18050ea6037b3c0c7cfe975eb9c872368b9e3328) --- source4/torture/rpc/drsuapi.c | 155 +++++++++++++++++++++++++++++++++++++++--- 1 file changed, 144 insertions(+), 11 deletions(-) (limited to 'source4/torture/rpc/drsuapi.c') diff --git a/source4/torture/rpc/drsuapi.c b/source4/torture/rpc/drsuapi.c index aed7f884d2..562291c6de 100644 --- a/source4/torture/rpc/drsuapi.c +++ b/source4/torture/rpc/drsuapi.c @@ -53,20 +53,24 @@ static BOOL test_DsCrackNames(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, { NTSTATUS status; struct drsuapi_DsCrackNames r; - struct drsuapi_DsCrackNamesInInfo1Names names[1]; + struct drsuapi_DsNameString names[1]; BOOL ret = True; + const char *dns_domain; + const char *nt4_domain; + const char *FQDN_1779_domain; + const char *FQDN_1779_name; ZERO_STRUCT(r); - r.in.bind_handle = bind_handle; - r.in.level = 1; - r.in.in.info1.unknown1 = 0x000004e4; - r.in.in.info1.unknown2 = 0x00000407; - r.in.in.info1.unknown3 = 0x00000000; - r.in.in.info1.unknown4 = 0x00000007; - r.in.in.info1.unknown5 = 0x00000002; - r.in.in.info1.count = 1; - r.in.in.info1.names = names; - + r.in.bind_handle = bind_handle; + r.in.level = 1; + r.in.req.req1.unknown1 = 0x000004e4; + r.in.req.req1.unknown2 = 0x00000407; + 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_CANONICAL; + r.in.req.req1.format_desired = DRSUAPI_DS_NAME_FORMAT_NT4_ACCOUNT; names[0].str = talloc_asprintf(mem_ctx, "%s/", lp_realm()); status = dcerpc_drsuapi_DsCrackNames(p, mem_ctx, &r); @@ -79,6 +83,135 @@ static BOOL test_DsCrackNames(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, ret = False; } + if (!ret) { + return ret; + } + + 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_offered = DRSUAPI_DS_NAME_FORMAT_NT4_ACCOUNT; + r.in.req.req1.format_desired = DRSUAPI_DS_NAME_FORMAT_FQDN_1779; + names[0].str = nt4_domain; + + status = dcerpc_drsuapi_DsCrackNames(p, mem_ctx, &r); + if (!NT_STATUS_IS_OK(status)) { + const char *errstr = nt_errstr(status); + if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { + errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); + } + printf("drsuapi_DsCrackNames failed - %s\n", errstr); + ret = False; + } + + if (!ret) { + return ret; + } + + FQDN_1779_domain = 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; + names[0].str = talloc_asprintf(mem_ctx, "%s%s$", nt4_domain, dcerpc_server_name(p)); + + status = dcerpc_drsuapi_DsCrackNames(p, mem_ctx, &r); + if (!NT_STATUS_IS_OK(status)) { + const char *errstr = nt_errstr(status); + if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { + errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); + } + printf("drsuapi_DsCrackNames failed - %s\n", errstr); + ret = False; + } + + if (!ret) { + return ret; + } + + FQDN_1779_name = r.out.ctr.ctr1->array[0].result_name; + + r.in.req.req1.format_offered = DRSUAPI_DS_NAME_FORMAT_FQDN_1779; + r.in.req.req1.format_desired = DRSUAPI_DS_NAME_FORMAT_CANONICAL; + names[0].str = FQDN_1779_name; + + status = dcerpc_drsuapi_DsCrackNames(p, mem_ctx, &r); + if (!NT_STATUS_IS_OK(status)) { + const char *errstr = nt_errstr(status); + if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { + errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); + } + printf("drsuapi_DsCrackNames failed - %s\n", errstr); + ret = False; + } + + if (!ret) { + return ret; + } + + r.in.req.req1.format_desired = DRSUAPI_DS_NAME_FORMAT_DISPLAY; + + status = dcerpc_drsuapi_DsCrackNames(p, mem_ctx, &r); + if (!NT_STATUS_IS_OK(status)) { + const char *errstr = nt_errstr(status); + if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { + errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); + } + printf("drsuapi_DsCrackNames failed - %s\n", errstr); + ret = False; + } + + if (!ret) { + return ret; + } + + r.in.req.req1.format_desired = DRSUAPI_DS_NAME_FORMAT_GUID; + + status = dcerpc_drsuapi_DsCrackNames(p, mem_ctx, &r); + if (!NT_STATUS_IS_OK(status)) { + const char *errstr = nt_errstr(status); + if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { + errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); + } + printf("drsuapi_DsCrackNames failed - %s\n", errstr); + ret = False; + } + + if (!ret) { + return ret; + } + + r.in.req.req1.format_desired = DRSUAPI_DS_NAME_FORMAT_USER_PRINCIPAL; + + status = dcerpc_drsuapi_DsCrackNames(p, mem_ctx, &r); + if (!NT_STATUS_IS_OK(status)) { + const char *errstr = nt_errstr(status); + if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { + errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); + } + printf("drsuapi_DsCrackNames failed - %s\n", errstr); + ret = False; + } + + if (!ret) { + return ret; + } + + r.in.req.req1.format_desired = DRSUAPI_DS_NAME_FORMAT_SERVICE_PRINCIPAL; + + status = dcerpc_drsuapi_DsCrackNames(p, mem_ctx, &r); + if (!NT_STATUS_IS_OK(status)) { + const char *errstr = nt_errstr(status); + if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { + errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); + } + printf("drsuapi_DsCrackNames failed - %s\n", errstr); + ret = False; + } + + if (!ret) { + return ret; + } + return ret; } -- cgit From 20ed511c1b126d7e5a578001a24b68eefe356bac Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 14 Oct 2004 10:16:22 +0000 Subject: r2971: fix DsBind idl metze (This used to be commit 9e50b3214b9de84811640296c19d6068936dfd54) --- source4/torture/rpc/drsuapi.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source4/torture/rpc/drsuapi.c') diff --git a/source4/torture/rpc/drsuapi.c b/source4/torture/rpc/drsuapi.c index 562291c6de..4338950811 100644 --- a/source4/torture/rpc/drsuapi.c +++ b/source4/torture/rpc/drsuapi.c @@ -32,7 +32,8 @@ static BOOL test_DsBind(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct drsuapi_DsBind r; BOOL ret = True; - ZERO_STRUCT(r); + r.in.server_guid = NULL; + r.in.bind_info = NULL; r.out.bind_handle = bind_handle; status = dcerpc_drsuapi_DsBind(p, mem_ctx, &r); -- cgit From f4e4989cb79dfe7fb2317ca8072f34b66895a696 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 15 Oct 2004 09:48:40 +0000 Subject: r2991: add drsuapi_DsGetDomainControllerInfo() idl and torture test metze (This used to be commit 98ca7640c59aa8694abde03f5661b8908cf088bb) --- source4/torture/rpc/drsuapi.c | 86 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 84 insertions(+), 2 deletions(-) (limited to 'source4/torture/rpc/drsuapi.c') diff --git a/source4/torture/rpc/drsuapi.c b/source4/torture/rpc/drsuapi.c index 4338950811..a387aaa337 100644 --- a/source4/torture/rpc/drsuapi.c +++ b/source4/torture/rpc/drsuapi.c @@ -23,8 +23,6 @@ #include "includes.h" -#define TEST_MACHINE_NAME "torturetest" - static BOOL test_DsBind(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct policy_handle *bind_handle) { @@ -216,6 +214,86 @@ static BOOL test_DsCrackNames(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, return ret; } +static BOOL test_DsGetDCInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, + struct policy_handle *bind_handle) +{ + NTSTATUS status; + struct drsuapi_DsGetDomainControllerInfo r; + BOOL ret = True; + + r.in.bind_handle = bind_handle; + r.in.level = 1; + r.in.req.req1.domain_name = talloc_strdup(mem_ctx, lp_realm()); + r.in.req.req1.level = 1; + + status = dcerpc_drsuapi_DsGetDomainControllerInfo(p, mem_ctx, &r); + if (!NT_STATUS_IS_OK(status)) { + const char *errstr = nt_errstr(status); + if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { + errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); + } + printf("drsuapi_DsGetDomainControllerInfo failed - %s\n", errstr); + ret = False; + } + + r.in.req.req1.level = 2; + + status = dcerpc_drsuapi_DsGetDomainControllerInfo(p, mem_ctx, &r); + if (!NT_STATUS_IS_OK(status)) { + const char *errstr = nt_errstr(status); + if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { + errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); + } + printf("drsuapi_DsGetDomainControllerInfo failed - %s\n", errstr); + ret = False; + } + + r.in.req.req1.level = -1; + + status = dcerpc_drsuapi_DsGetDomainControllerInfo(p, mem_ctx, &r); + if (!NT_STATUS_IS_OK(status)) { + const char *errstr = nt_errstr(status); + if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { + errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); + } + printf("drsuapi_DsGetDomainControllerInfo failed - %s\n", errstr); + ret = False; + } + + r.in.req.req1.domain_name = talloc_strdup(mem_ctx, lp_workgroup()); + r.in.req.req1.level = 2; + + status = dcerpc_drsuapi_DsGetDomainControllerInfo(p, mem_ctx, &r); + if (!NT_STATUS_IS_OK(status)) { + const char *errstr = nt_errstr(status); + if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { + errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); + } + printf("drsuapi_DsGetDomainControllerInfo failed - %s\n", errstr); + ret = False; + } + + r.in.req.req1.domain_name = "__UNKNOWN_DOMAIN__"; + r.in.req.req1.level = 2; + + status = dcerpc_drsuapi_DsGetDomainControllerInfo(p, mem_ctx, &r); + if (!NT_STATUS_IS_OK(status)) { + const char *errstr = nt_errstr(status); + if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { + errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); + } + + if (!NT_STATUS_EQUAL(status, NT_STATUS(0x0000208d))) { + printf("drsuapi_DsGetDomainControllerInfo level %d with invalid domain name\n" + " - %s != NTSTATUS[0x0000208d]\n", + r.in.req.req1.level, errstr); + ret = False; + } + } + + return ret; +} + static BOOL test_DsUnbind(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct policy_handle *bind_handle) { @@ -263,6 +341,10 @@ BOOL torture_rpc_drsuapi(int dummy) ret = False; } + if (!test_DsGetDCInfo(p, mem_ctx, &bind_handle)) { + ret = False; + } + if (!test_DsCrackNames(p, mem_ctx, &bind_handle)) { ret = False; } -- cgit From 1890e6a6593d3ddb6bcbda8446e02169e97e9030 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 15 Oct 2004 11:08:14 +0000 Subject: r2992: drsuapi uses WERROR not NTSTATUS metze (This used to be commit 757f67c08b0b1309d8a0b900539111c7bc430b0e) --- source4/torture/rpc/drsuapi.c | 146 ++++++++++++++++++++++++++++++++++++------ 1 file changed, 125 insertions(+), 21 deletions(-) (limited to 'source4/torture/rpc/drsuapi.c') diff --git a/source4/torture/rpc/drsuapi.c b/source4/torture/rpc/drsuapi.c index a387aaa337..be1582e57f 100644 --- a/source4/torture/rpc/drsuapi.c +++ b/source4/torture/rpc/drsuapi.c @@ -34,13 +34,18 @@ static BOOL test_DsBind(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, r.in.bind_info = NULL; r.out.bind_handle = bind_handle; + printf("testing DsBind\n"); + status = dcerpc_drsuapi_DsBind(p, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { const char *errstr = nt_errstr(status); if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); } - printf("drsuapi_DsBind failed - %s\n", errstr); + printf("dcerpc_drsuapi_DsBind failed - %s\n", errstr); + ret = False; + } else if (!W_ERROR_IS_OK(r.out.result)) { + printf("DsBind failed - %s\n", win_errstr(r.out.result)); ret = False; } @@ -72,13 +77,19 @@ static BOOL test_DsCrackNames(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, r.in.req.req1.format_desired = DRSUAPI_DS_NAME_FORMAT_NT4_ACCOUNT; names[0].str = talloc_asprintf(mem_ctx, "%s/", lp_realm()); + printf("testing DsCrackNames with name '%s' desired format:%d\n", + names[0].str, r.in.req.req1.format_desired); + status = dcerpc_drsuapi_DsCrackNames(p, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { const char *errstr = nt_errstr(status); if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); } - printf("drsuapi_DsCrackNames failed - %s\n", errstr); + printf("dcerpc_drsuapi_DsCrackNames failed - %s\n", errstr); + ret = False; + } else if (!W_ERROR_IS_OK(r.out.result)) { + printf("DsCrackNames failed - %s\n", win_errstr(r.out.result)); ret = False; } @@ -93,13 +104,19 @@ static BOOL test_DsCrackNames(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, 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); + status = dcerpc_drsuapi_DsCrackNames(p, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { const char *errstr = nt_errstr(status); if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); } - printf("drsuapi_DsCrackNames failed - %s\n", errstr); + printf("dcerpc_drsuapi_DsCrackNames failed - %s\n", errstr); + ret = False; + } else if (!W_ERROR_IS_OK(r.out.result)) { + printf("DsCrackNames failed - %s\n", win_errstr(r.out.result)); ret = False; } @@ -113,13 +130,19 @@ static BOOL test_DsCrackNames(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, r.in.req.req1.format_desired = DRSUAPI_DS_NAME_FORMAT_FQDN_1779; names[0].str = talloc_asprintf(mem_ctx, "%s%s$", nt4_domain, dcerpc_server_name(p)); + printf("testing DsCrackNames with name '%s' desired format:%d\n", + names[0].str, r.in.req.req1.format_desired); + status = dcerpc_drsuapi_DsCrackNames(p, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { const char *errstr = nt_errstr(status); if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); } - printf("drsuapi_DsCrackNames failed - %s\n", errstr); + printf("dcerpc_drsuapi_DsCrackNames failed - %s\n", errstr); + ret = False; + } else if (!W_ERROR_IS_OK(r.out.result)) { + printf("DsCrackNames failed - %s\n", win_errstr(r.out.result)); ret = False; } @@ -133,13 +156,19 @@ static BOOL test_DsCrackNames(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, r.in.req.req1.format_desired = DRSUAPI_DS_NAME_FORMAT_CANONICAL; names[0].str = FQDN_1779_name; + printf("testing DsCrackNames with name '%s' desired format:%d\n", + names[0].str, r.in.req.req1.format_desired); + status = dcerpc_drsuapi_DsCrackNames(p, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { const char *errstr = nt_errstr(status); if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); } - printf("drsuapi_DsCrackNames failed - %s\n", errstr); + printf("dcerpc_drsuapi_DsCrackNames failed - %s\n", errstr); + ret = False; + } else if (!W_ERROR_IS_OK(r.out.result)) { + printf("DsCrackNames failed - %s\n", win_errstr(r.out.result)); ret = False; } @@ -149,13 +178,19 @@ static BOOL test_DsCrackNames(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, r.in.req.req1.format_desired = DRSUAPI_DS_NAME_FORMAT_DISPLAY; + printf("testing DsCrackNames with name '%s' desired format:%d\n", + names[0].str, r.in.req.req1.format_desired); + status = dcerpc_drsuapi_DsCrackNames(p, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { const char *errstr = nt_errstr(status); if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); } - printf("drsuapi_DsCrackNames failed - %s\n", errstr); + printf("dcerpc_drsuapi_DsCrackNames failed - %s\n", errstr); + ret = False; + } else if (!W_ERROR_IS_OK(r.out.result)) { + printf("DsCrackNames failed - %s\n", win_errstr(r.out.result)); ret = False; } @@ -165,13 +200,19 @@ static BOOL test_DsCrackNames(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, 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); + status = dcerpc_drsuapi_DsCrackNames(p, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { const char *errstr = nt_errstr(status); if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); } - printf("drsuapi_DsCrackNames failed - %s\n", errstr); + printf("dcerpc_drsuapi_DsCrackNames failed - %s\n", errstr); + ret = False; + } else if (!W_ERROR_IS_OK(r.out.result)) { + printf("DsCrackNames failed - %s\n", win_errstr(r.out.result)); ret = False; } @@ -181,13 +222,19 @@ static BOOL test_DsCrackNames(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, r.in.req.req1.format_desired = DRSUAPI_DS_NAME_FORMAT_USER_PRINCIPAL; + printf("testing DsCrackNames with name '%s' desired format:%d\n", + names[0].str, r.in.req.req1.format_desired); + status = dcerpc_drsuapi_DsCrackNames(p, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { const char *errstr = nt_errstr(status); if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); } - printf("drsuapi_DsCrackNames failed - %s\n", errstr); + printf("dcerpc_drsuapi_DsCrackNames failed - %s\n", errstr); + ret = False; + } else if (!W_ERROR_IS_OK(r.out.result)) { + printf("DsCrackNames failed - %s\n", win_errstr(r.out.result)); ret = False; } @@ -197,13 +244,19 @@ static BOOL test_DsCrackNames(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, r.in.req.req1.format_desired = DRSUAPI_DS_NAME_FORMAT_SERVICE_PRINCIPAL; + printf("testing DsCrackNames with name '%s' desired format:%d\n", + names[0].str, r.in.req.req1.format_desired); + status = dcerpc_drsuapi_DsCrackNames(p, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { const char *errstr = nt_errstr(status); if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); } - printf("drsuapi_DsCrackNames failed - %s\n", errstr); + printf("dcerpc_drsuapi_DsCrackNames failed - %s\n", errstr); + ret = False; + } else if (!W_ERROR_IS_OK(r.out.result)) { + printf("DsCrackNames failed - %s\n", win_errstr(r.out.result)); ret = False; } @@ -223,72 +276,118 @@ static BOOL test_DsGetDCInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, r.in.bind_handle = bind_handle; r.in.level = 1; + r.in.req.req1.domain_name = talloc_strdup(mem_ctx, lp_realm()); 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); + status = dcerpc_drsuapi_DsGetDomainControllerInfo(p, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { const char *errstr = nt_errstr(status); if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); } - printf("drsuapi_DsGetDomainControllerInfo failed - %s\n", errstr); + printf("dcerpc_drsuapi_DsGetDomainControllerInfo level %d\n" + " with dns domain failed - %s\n", + r.in.req.req1.level, errstr); + ret = False; + } else if (!W_ERROR_IS_OK(r.out.result)) { + printf("DsGetDomainControllerInfo level %d\n" + " with dns domain failed - %s\n", + r.in.req.req1.level, win_errstr(r.out.result)); ret = False; } r.in.req.req1.level = 2; + printf("testing DsGetDomainControllerInfo level %d on domainname '%s'\n", + r.in.req.req1.level, r.in.req.req1.domain_name); + status = dcerpc_drsuapi_DsGetDomainControllerInfo(p, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { const char *errstr = nt_errstr(status); if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); } - printf("drsuapi_DsGetDomainControllerInfo failed - %s\n", errstr); + printf("dcerpc_drsuapi_DsGetDomainControllerInfo level %d\n" + " with dns domain failed - %s\n", + r.in.req.req1.level, errstr); + ret = False; + } else if (!W_ERROR_IS_OK(r.out.result)) { + printf("DsGetDomainControllerInfo level %d\n" + " with dns domain failed - %s\n", + r.in.req.req1.level, win_errstr(r.out.result)); ret = False; } 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); + status = dcerpc_drsuapi_DsGetDomainControllerInfo(p, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { const char *errstr = nt_errstr(status); if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); } - printf("drsuapi_DsGetDomainControllerInfo failed - %s\n", errstr); + printf("dcerpc_drsuapi_DsGetDomainControllerInfo level %d\n" + " with dns domain failed - %s\n", + r.in.req.req1.level, errstr); + ret = False; + } else if (!W_ERROR_IS_OK(r.out.result)) { + printf("DsGetDomainControllerInfo level %d\n" + " with dns domain failed - %s\n", + r.in.req.req1.level, win_errstr(r.out.result)); ret = False; } r.in.req.req1.domain_name = talloc_strdup(mem_ctx, lp_workgroup()); r.in.req.req1.level = 2; + printf("testing DsGetDomainControllerInfo level %d on domainname '%s'\n", + r.in.req.req1.level, r.in.req.req1.domain_name); + status = dcerpc_drsuapi_DsGetDomainControllerInfo(p, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { const char *errstr = nt_errstr(status); if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); } - printf("drsuapi_DsGetDomainControllerInfo failed - %s\n", errstr); + printf("dcerpc_drsuapi_DsGetDomainControllerInfo level %d\n" + " with netbios domain failed - %s\n", + r.in.req.req1.level, errstr); + ret = False; + } else if (!W_ERROR_IS_OK(r.out.result)) { + printf("DsGetDomainControllerInfo level %d\n" + " with netbios domain failed - %s\n", + r.in.req.req1.level, win_errstr(r.out.result)); ret = False; } r.in.req.req1.domain_name = "__UNKNOWN_DOMAIN__"; r.in.req.req1.level = 2; + printf("testing DsGetDomainControllerInfo level %d on domainname '%s'\n", + r.in.req.req1.level, r.in.req.req1.domain_name); + status = dcerpc_drsuapi_DsGetDomainControllerInfo(p, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { const char *errstr = nt_errstr(status); if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); } - - if (!NT_STATUS_EQUAL(status, NT_STATUS(0x0000208d))) { - printf("drsuapi_DsGetDomainControllerInfo level %d with invalid domain name\n" - " - %s != NTSTATUS[0x0000208d]\n", - r.in.req.req1.level, errstr); - ret = False; - } + printf("dcerpc_drsuapi_DsGetDomainControllerInfo level %d\n" + " with invalid domain failed - %s\n", + r.in.req.req1.level, errstr); + ret = False; + } else if (!W_ERROR_EQUAL(r.out.result, WERR_DS_OBJ_NOT_FOUND)) { + printf("DsGetDomainControllerInfo level %d\n" + " with invalid domain not expected error (WERR_DS_OBJ_NOT_FOUND) - %s\n", + r.in.req.req1.level, win_errstr(r.out.result)); + ret = False; } return ret; @@ -304,13 +403,18 @@ static BOOL test_DsUnbind(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, r.in.bind_handle = bind_handle; r.out.bind_handle = bind_handle; + printf("testing DsUnbind\n"); + status = dcerpc_drsuapi_DsUnbind(p, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { const char *errstr = nt_errstr(status); if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); } - printf("drsuapi_DsUnbind failed - %s\n", errstr); + printf("dcerpc_drsuapi_DsUnbind failed - %s\n", errstr); + ret = False; + } else if (!W_ERROR_IS_OK(r.out.result)) { + printf("DsBind failed - %s\n", win_errstr(r.out.result)); ret = False; } -- cgit From ba6d5fcb97b9831dddf7dfe09fb02fbb23d864b4 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 28 Oct 2004 13:40:50 +0000 Subject: r3324: made the smbtorture code completely warning free (This used to be commit 7067bb9b52223cafa28470f264f0b60646a07a01) --- source4/torture/rpc/drsuapi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/torture/rpc/drsuapi.c') diff --git a/source4/torture/rpc/drsuapi.c b/source4/torture/rpc/drsuapi.c index be1582e57f..9981b24258 100644 --- a/source4/torture/rpc/drsuapi.c +++ b/source4/torture/rpc/drsuapi.c @@ -421,7 +421,7 @@ static BOOL test_DsUnbind(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, return ret; } -BOOL torture_rpc_drsuapi(int dummy) +BOOL torture_rpc_drsuapi(void) { NTSTATUS status; struct dcerpc_pipe *p; -- cgit From 90067934cd3195df80f8b1e614629d51fffcb38b Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 1 Nov 2004 10:30:34 +0000 Subject: r3428: switched to using minimal includes for the auto-generated RPC code. The thing that finally convinced me that minimal includes was worth pursuing for rpc was a compiler (tcc) that failed to build Samba due to reaching internal limits of the size of include files. Also the fact that includes.h.gch was 16MB, which really seems excessive. This patch brings it back to 12M, which is still too large, but better. Note that this patch speeds up compile times for both the pch and non-pch case. This change also includes the addition iof a "depends()" option in our IDL files, allowing you to specify that one IDL file depends on another. This capability was needed for the auto-includes generation. (This used to be commit b8f5fa8ac8e8725f3d321004f0aedf4246fc6b49) --- source4/torture/rpc/drsuapi.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/torture/rpc/drsuapi.c') diff --git a/source4/torture/rpc/drsuapi.c b/source4/torture/rpc/drsuapi.c index 9981b24258..1b4c0d2305 100644 --- a/source4/torture/rpc/drsuapi.c +++ b/source4/torture/rpc/drsuapi.c @@ -22,6 +22,7 @@ */ #include "includes.h" +#include "librpc/gen_ndr/ndr_drsuapi.h" static BOOL test_DsBind(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct policy_handle *bind_handle) -- cgit From e0e6e0f99d9c7645e1809a3bde1a6ab01843de67 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 3 Nov 2004 16:02:32 +0000 Subject: r3512: - support DsCrackName GUID strings ('{faedf4f9-0de8-4582-b8b6-c475efefbe5a}') - resolve the GUID's we got in DsGetDomainControllerInfo in the DsCrackNames test metze (This used to be commit f6310695821a7e750dd37936a6145232d81ab413) --- source4/torture/rpc/drsuapi.c | 134 +++++++++++++++++++++++++++++++++++++----- 1 file changed, 120 insertions(+), 14 deletions(-) (limited to 'source4/torture/rpc/drsuapi.c') diff --git a/source4/torture/rpc/drsuapi.c b/source4/torture/rpc/drsuapi.c index 1b4c0d2305..f8d25ada72 100644 --- a/source4/torture/rpc/drsuapi.c +++ b/source4/torture/rpc/drsuapi.c @@ -24,8 +24,17 @@ #include "includes.h" #include "librpc/gen_ndr/ndr_drsuapi.h" +struct DsPrivate { + struct policy_handle bind_handle; + struct GUID domain_guid; + struct GUID site_guid; + struct GUID computer_guid; + struct GUID server_guid; + struct GUID ntds_guid; +}; + static BOOL test_DsBind(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, - struct policy_handle *bind_handle) + struct DsPrivate *priv) { NTSTATUS status; struct drsuapi_DsBind r; @@ -33,7 +42,7 @@ static BOOL test_DsBind(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, r.in.server_guid = NULL; r.in.bind_info = NULL; - r.out.bind_handle = bind_handle; + r.out.bind_handle = &priv->bind_handle; printf("testing DsBind\n"); @@ -54,7 +63,7 @@ static BOOL test_DsBind(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, } static BOOL test_DsCrackNames(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, - struct policy_handle *bind_handle) + struct DsPrivate *priv) { NTSTATUS status; struct drsuapi_DsCrackNames r; @@ -66,7 +75,7 @@ static BOOL test_DsCrackNames(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, const char *FQDN_1779_name; ZERO_STRUCT(r); - r.in.bind_handle = bind_handle; + r.in.bind_handle = &priv->bind_handle; r.in.level = 1; r.in.req.req1.unknown1 = 0x000004e4; r.in.req.req1.unknown2 = 0x00000407; @@ -265,17 +274,107 @@ static BOOL test_DsCrackNames(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, return ret; } + 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 = GUID_string2(mem_ctx, &priv->site_guid); + + printf("testing DsCrackNames with Site GUID '%s' desired format:%d\n", + names[0].str, r.in.req.req1.format_desired); + + status = dcerpc_drsuapi_DsCrackNames(p, mem_ctx, &r); + if (!NT_STATUS_IS_OK(status)) { + const char *errstr = nt_errstr(status); + if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { + errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); + } + printf("dcerpc_drsuapi_DsCrackNames failed - %s\n", errstr); + ret = False; + } else if (!W_ERROR_IS_OK(r.out.result)) { + printf("DsCrackNames failed - %s\n", win_errstr(r.out.result)); + ret = False; + } + + if (!ret) { + return ret; + } + + names[0].str = GUID_string2(mem_ctx, &priv->computer_guid); + + printf("testing DsCrackNames with Computer GUID '%s' desired format:%d\n", + names[0].str, r.in.req.req1.format_desired); + + status = dcerpc_drsuapi_DsCrackNames(p, mem_ctx, &r); + if (!NT_STATUS_IS_OK(status)) { + const char *errstr = nt_errstr(status); + if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { + errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); + } + printf("dcerpc_drsuapi_DsCrackNames failed - %s\n", errstr); + ret = False; + } else if (!W_ERROR_IS_OK(r.out.result)) { + printf("DsCrackNames failed - %s\n", win_errstr(r.out.result)); + ret = False; + } + + if (!ret) { + return ret; + } + + names[0].str = GUID_string2(mem_ctx, &priv->server_guid); + + printf("testing DsCrackNames with Server GUID '%s' desired format:%d\n", + names[0].str, r.in.req.req1.format_desired); + + status = dcerpc_drsuapi_DsCrackNames(p, mem_ctx, &r); + if (!NT_STATUS_IS_OK(status)) { + const char *errstr = nt_errstr(status); + if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { + errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); + } + printf("dcerpc_drsuapi_DsCrackNames failed - %s\n", errstr); + ret = False; + } else if (!W_ERROR_IS_OK(r.out.result)) { + printf("DsCrackNames failed - %s\n", win_errstr(r.out.result)); + ret = False; + } + + if (!ret) { + return ret; + } + + names[0].str = GUID_string2(mem_ctx, &priv->ntds_guid); + + printf("testing DsCrackNames with NTDS GUID '%s' desired format:%d\n", + names[0].str, r.in.req.req1.format_desired); + + status = dcerpc_drsuapi_DsCrackNames(p, mem_ctx, &r); + if (!NT_STATUS_IS_OK(status)) { + const char *errstr = nt_errstr(status); + if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { + errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); + } + printf("dcerpc_drsuapi_DsCrackNames failed - %s\n", errstr); + ret = False; + } else if (!W_ERROR_IS_OK(r.out.result)) { + printf("DsCrackNames failed - %s\n", win_errstr(r.out.result)); + ret = False; + } + + if (!ret) { + return ret; + } + return ret; } static BOOL test_DsGetDCInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, - struct policy_handle *bind_handle) + struct DsPrivate *priv) { NTSTATUS status; struct drsuapi_DsGetDomainControllerInfo r; BOOL ret = True; - r.in.bind_handle = bind_handle; + r.in.bind_handle = &priv->bind_handle; r.in.level = 1; r.in.req.req1.domain_name = talloc_strdup(mem_ctx, lp_realm()); @@ -321,6 +420,13 @@ static BOOL test_DsGetDCInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, " with dns domain failed - %s\n", r.in.req.req1.level, win_errstr(r.out.result)); ret = False; + } else { + if (r.out.ctr.ctr2.count > 0) { + priv->site_guid = r.out.ctr.ctr2.array[0].site_guid; + priv->computer_guid = r.out.ctr.ctr2.array[0].computer_guid; + priv->server_guid = r.out.ctr.ctr2.array[0].server_guid; + priv->ntds_guid = r.out.ctr.ctr2.array[0].ntds_guid; + } } r.in.req.req1.level = -1; @@ -395,14 +501,14 @@ static BOOL test_DsGetDCInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, } static BOOL test_DsUnbind(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, - struct policy_handle *bind_handle) + struct DsPrivate *priv) { NTSTATUS status; struct drsuapi_DsUnbind r; BOOL ret = True; - r.in.bind_handle = bind_handle; - r.out.bind_handle = bind_handle; + r.in.bind_handle = &priv->bind_handle; + r.out.bind_handle = &priv->bind_handle; printf("testing DsUnbind\n"); @@ -428,7 +534,7 @@ BOOL torture_rpc_drsuapi(void) struct dcerpc_pipe *p; TALLOC_CTX *mem_ctx; BOOL ret = True; - struct policy_handle bind_handle; + struct DsPrivate priv; status = torture_rpc_connection(&p, DCERPC_DRSUAPI_NAME, @@ -442,19 +548,19 @@ BOOL torture_rpc_drsuapi(void) mem_ctx = talloc_init("torture_rpc_drsuapi"); - if (!test_DsBind(p, mem_ctx, &bind_handle)) { + if (!test_DsBind(p, mem_ctx, &priv)) { ret = False; } - if (!test_DsGetDCInfo(p, mem_ctx, &bind_handle)) { + if (!test_DsGetDCInfo(p, mem_ctx, &priv)) { ret = False; } - if (!test_DsCrackNames(p, mem_ctx, &bind_handle)) { + if (!test_DsCrackNames(p, mem_ctx, &priv)) { ret = False; } - if (!test_DsUnbind(p, mem_ctx, &bind_handle)) { + if (!test_DsUnbind(p, mem_ctx, &priv)) { ret = False; } -- cgit From ded4440335452f421ae3c21e66a1493959757db9 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 22 Nov 2004 17:30:32 +0000 Subject: r3915: a few updates to the DsCrackNames() torture test metze (This used to be commit 62d26e0b91703d667e94d016e7943b6883130579) --- source4/torture/rpc/drsuapi.c | 78 ++++++++++++++++++++++++++++++++----------- 1 file changed, 59 insertions(+), 19 deletions(-) (limited to 'source4/torture/rpc/drsuapi.c') diff --git a/source4/torture/rpc/drsuapi.c b/source4/torture/rpc/drsuapi.c index f8d25ada72..6696d12136 100644 --- a/source4/torture/rpc/drsuapi.c +++ b/source4/torture/rpc/drsuapi.c @@ -26,11 +26,8 @@ struct DsPrivate { struct policy_handle bind_handle; - struct GUID domain_guid; - struct GUID site_guid; - struct GUID computer_guid; - struct GUID server_guid; - struct GUID ntds_guid; + const char *domain_guid_str; + struct drsuapi_DsGetDCInfo2 dcinfo; }; static BOOL test_DsBind(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, @@ -110,6 +107,54 @@ static BOOL test_DsCrackNames(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, 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; + + printf("testing DsCrackNames with name '%s' desired format:%d\n", + names[0].str, r.in.req.req1.format_desired); + + status = dcerpc_drsuapi_DsCrackNames(p, mem_ctx, &r); + if (!NT_STATUS_IS_OK(status)) { + const char *errstr = nt_errstr(status); + if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { + errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); + } + printf("dcerpc_drsuapi_DsCrackNames failed - %s\n", errstr); + ret = False; + } else if (!W_ERROR_IS_OK(r.out.result)) { + printf("DsCrackNames failed - %s\n", win_errstr(r.out.result)); + ret = False; + } + + if (!ret) { + return ret; + } + + priv->domain_guid_str = 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_NT4_ACCOUNT; + 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); + + status = dcerpc_drsuapi_DsCrackNames(p, mem_ctx, &r); + if (!NT_STATUS_IS_OK(status)) { + const char *errstr = nt_errstr(status); + if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { + errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); + } + printf("dcerpc_drsuapi_DsCrackNames failed - %s\n", errstr); + ret = False; + } else if (!W_ERROR_IS_OK(r.out.result)) { + printf("DsCrackNames failed - %s\n", win_errstr(r.out.result)); + ret = False; + } + + if (!ret) { + return ret; + } + 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; @@ -138,7 +183,7 @@ static BOOL test_DsCrackNames(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, 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, dcerpc_server_name(p)); + names[0].str = talloc_asprintf(mem_ctx, "%s%s$", nt4_domain, priv->dcinfo.netbios_name); printf("testing DsCrackNames with name '%s' desired format:%d\n", names[0].str, r.in.req.req1.format_desired); @@ -276,7 +321,7 @@ static BOOL test_DsCrackNames(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, 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 = GUID_string2(mem_ctx, &priv->site_guid); + names[0].str = GUID_string2(mem_ctx, &priv->dcinfo.site_guid); printf("testing DsCrackNames with Site GUID '%s' desired format:%d\n", names[0].str, r.in.req.req1.format_desired); @@ -298,7 +343,8 @@ static BOOL test_DsCrackNames(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, return ret; } - names[0].str = GUID_string2(mem_ctx, &priv->computer_guid); + r.in.req.req1.format_desired = DRSUAPI_DS_NAME_FORMAT_NT4_ACCOUNT; + names[0].str = GUID_string2(mem_ctx, &priv->dcinfo.computer_guid); printf("testing DsCrackNames with Computer GUID '%s' desired format:%d\n", names[0].str, r.in.req.req1.format_desired); @@ -320,7 +366,7 @@ static BOOL test_DsCrackNames(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, return ret; } - names[0].str = GUID_string2(mem_ctx, &priv->server_guid); + names[0].str = GUID_string2(mem_ctx, &priv->dcinfo.server_guid); printf("testing DsCrackNames with Server GUID '%s' desired format:%d\n", names[0].str, r.in.req.req1.format_desired); @@ -342,7 +388,7 @@ static BOOL test_DsCrackNames(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, return ret; } - names[0].str = GUID_string2(mem_ctx, &priv->ntds_guid); + names[0].str = GUID_string2(mem_ctx, &priv->dcinfo.ntds_guid); printf("testing DsCrackNames with NTDS GUID '%s' desired format:%d\n", names[0].str, r.in.req.req1.format_desired); @@ -422,10 +468,7 @@ static BOOL test_DsGetDCInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, ret = False; } else { if (r.out.ctr.ctr2.count > 0) { - priv->site_guid = r.out.ctr.ctr2.array[0].site_guid; - priv->computer_guid = r.out.ctr.ctr2.array[0].computer_guid; - priv->server_guid = r.out.ctr.ctr2.array[0].server_guid; - priv->ntds_guid = r.out.ctr.ctr2.array[0].ntds_guid; + priv->dcinfo = r.out.ctr.ctr2.array[0]; } } @@ -548,6 +591,8 @@ BOOL torture_rpc_drsuapi(void) mem_ctx = talloc_init("torture_rpc_drsuapi"); + ZERO_STRUCT(priv); + if (!test_DsBind(p, mem_ctx, &priv)) { ret = False; } @@ -564,11 +609,6 @@ BOOL torture_rpc_drsuapi(void) ret = False; } -#if 0 - if (!test_scan(p, mem_ctx)) { - ret = False; - } -#endif talloc_destroy(mem_ctx); torture_rpc_close(p); -- cgit From 2f39a9fe621a0c80688fe06712bd5b0495ca7e65 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 23 Nov 2004 08:57:42 +0000 Subject: r3920: - it seem that we need to send a magic bind_guid in DsBind() to make DsWriteAccountSpn() work - add idl and torture test for DsWriteAccountSpn() metze (This used to be commit 625826ad9050c68407ae5e8abfee13699986303c) --- source4/torture/rpc/drsuapi.c | 90 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 89 insertions(+), 1 deletion(-) (limited to 'source4/torture/rpc/drsuapi.c') diff --git a/source4/torture/rpc/drsuapi.c b/source4/torture/rpc/drsuapi.c index 6696d12136..b6b1ddf6dc 100644 --- a/source4/torture/rpc/drsuapi.c +++ b/source4/torture/rpc/drsuapi.c @@ -26,6 +26,7 @@ struct DsPrivate { struct policy_handle bind_handle; + struct GUID bind_guid; const char *domain_guid_str; struct drsuapi_DsGetDCInfo2 dcinfo; }; @@ -37,7 +38,9 @@ static BOOL test_DsBind(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct drsuapi_DsBind r; BOOL ret = True; - r.in.server_guid = NULL; + GUID_from_string(DRSUAPI_DS_BIND_GUID, &priv->bind_guid); + + r.in.bind_guid = &priv->bind_guid; r.in.bind_info = NULL; r.out.bind_handle = &priv->bind_handle; @@ -366,6 +369,8 @@ static BOOL test_DsCrackNames(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, return ret; } + 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 = GUID_string2(mem_ctx, &priv->dcinfo.server_guid); printf("testing DsCrackNames with Server GUID '%s' desired format:%d\n", @@ -388,6 +393,8 @@ static BOOL test_DsCrackNames(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, return ret; } + 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 = GUID_string2(mem_ctx, &priv->dcinfo.ntds_guid); printf("testing DsCrackNames with NTDS GUID '%s' desired format:%d\n", @@ -410,6 +417,30 @@ static BOOL test_DsCrackNames(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, return ret; } + 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 = GUID_string2(mem_ctx, &priv->bind_guid); + + printf("testing DsCrackNames with NTDS GUID '%s' desired format:%d\n", + names[0].str, r.in.req.req1.format_desired); + + status = dcerpc_drsuapi_DsCrackNames(p, mem_ctx, &r); + if (!NT_STATUS_IS_OK(status)) { + const char *errstr = nt_errstr(status); + if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { + errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); + } + printf("dcerpc_drsuapi_DsCrackNames failed - %s\n", errstr); + ret = False; + } else if (!W_ERROR_IS_OK(r.out.result)) { + printf("DsCrackNames failed - %s\n", win_errstr(r.out.result)); + ret = False; + } + + if (!ret) { + return ret; + } + return ret; } @@ -543,6 +574,59 @@ static BOOL test_DsGetDCInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, return ret; } +static BOOL test_DsWriteAccountSpn(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, + struct DsPrivate *priv) +{ + NTSTATUS status; + struct drsuapi_DsWriteAccountSpn r; + struct drsuapi_DsNameString names[2]; + BOOL ret = True; + + r.in.bind_handle = &priv->bind_handle; + r.in.level = 1; + + 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; + 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); + + status = dcerpc_drsuapi_DsWriteAccountSpn(p, mem_ctx, &r); + if (!NT_STATUS_IS_OK(status)) { + const char *errstr = nt_errstr(status); + if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { + errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); + } + printf("dcerpc_drsuapi_DsWriteAccountSpn failed - %s\n", errstr); + ret = False; + } else if (!W_ERROR_IS_OK(r.out.result)) { + printf("DsWriteAccountSpn failed - %s\n", win_errstr(r.out.result)); + ret = False; + } + + 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)) { + const char *errstr = nt_errstr(status); + if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { + errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); + } + printf("dcerpc_drsuapi_DsWriteAccountSpn failed - %s\n", errstr); + ret = False; + } else if (!W_ERROR_IS_OK(r.out.result)) { + printf("DsWriteAccountSpn failed - %s\n", win_errstr(r.out.result)); + ret = False; + } + + return ret; +} + static BOOL test_DsUnbind(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct DsPrivate *priv) { @@ -605,6 +689,10 @@ BOOL torture_rpc_drsuapi(void) ret = False; } + if (!test_DsWriteAccountSpn(p, mem_ctx, &priv)) { + ret = False; + } + if (!test_DsUnbind(p, mem_ctx, &priv)) { ret = False; } -- cgit From 57314e0df30296291ef3b9698de44249fa1fc77e Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 7 Dec 2004 12:20:28 +0000 Subject: r4087: - add idl and torture tests for drsuapi_DsReplicaGetInfo() (NOTE: that the drsuapi_DsReplicaObjMetaData2 struct is not corrently parsed yet and there're some unknown fields left in someother infotypes) metze (This used to be commit 4fd57d5e7cff085a8c003ea82f282e26dc1346d9) --- source4/torture/rpc/drsuapi.c | 138 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 135 insertions(+), 3 deletions(-) (limited to 'source4/torture/rpc/drsuapi.c') diff --git a/source4/torture/rpc/drsuapi.c b/source4/torture/rpc/drsuapi.c index b6b1ddf6dc..e5b7e2ca0c 100644 --- a/source4/torture/rpc/drsuapi.c +++ b/source4/torture/rpc/drsuapi.c @@ -27,7 +27,9 @@ struct DsPrivate { struct policy_handle bind_handle; struct GUID bind_guid; + const char *domain_obj_dn; const char *domain_guid_str; + struct GUID domain_guid; struct drsuapi_DsGetDCInfo2 dcinfo; }; @@ -71,7 +73,6 @@ static BOOL test_DsCrackNames(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, BOOL ret = True; const char *dns_domain; const char *nt4_domain; - const char *FQDN_1779_domain; const char *FQDN_1779_name; ZERO_STRUCT(r); @@ -133,6 +134,8 @@ static BOOL test_DsCrackNames(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, } 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_offered = DRSUAPI_DS_NAME_FORMAT_GUID; r.in.req.req1.format_desired = DRSUAPI_DS_NAME_FORMAT_NT4_ACCOUNT; @@ -182,7 +185,7 @@ static BOOL test_DsCrackNames(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, return ret; } - FQDN_1779_domain = 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; @@ -421,7 +424,7 @@ static BOOL test_DsCrackNames(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, r.in.req.req1.format_desired = DRSUAPI_DS_NAME_FORMAT_FQDN_1779; names[0].str = GUID_string2(mem_ctx, &priv->bind_guid); - printf("testing DsCrackNames with NTDS GUID '%s' desired format:%d\n", + printf("testing DsCrackNames with BIND GUID '%s' desired format:%d\n", names[0].str, r.in.req.req1.format_desired); status = dcerpc_drsuapi_DsCrackNames(p, mem_ctx, &r); @@ -627,6 +630,131 @@ static BOOL test_DsWriteAccountSpn(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, return ret; } +static BOOL test_DsReplicaGetInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, + struct DsPrivate *priv) +{ + NTSTATUS status; + struct drsuapi_DsReplicaGetInfo r; + BOOL ret = True; + int i; + struct { + int32 level; + int32 infotype; + const char *obj_dn; + } array[] = { + { + DRSUAPI_DS_REPLICA_GET_INFO, + DRSUAPI_DS_REPLICA_INFO_NEIGHBORS, + NULL + },{ + DRSUAPI_DS_REPLICA_GET_INFO, + DRSUAPI_DS_REPLICA_INFO_CURSORS, + NULL + },{ + DRSUAPI_DS_REPLICA_GET_INFO, + DRSUAPI_DS_REPLICA_INFO_OBJ_METADATA, + NULL + },{ + DRSUAPI_DS_REPLICA_GET_INFO, + DRSUAPI_DS_REPLICA_INFO_KCC_DSA_CONNECT_FAILURES, + NULL + },{ + DRSUAPI_DS_REPLICA_GET_INFO, + DRSUAPI_DS_REPLICA_INFO_KCC_DSA_LINK_FAILURES, + NULL + },{ + DRSUAPI_DS_REPLICA_GET_INFO, + DRSUAPI_DS_REPLICA_INFO_PENDING_OPS, + NULL + },{ + DRSUAPI_DS_REPLICA_GET_INFO2, + DRSUAPI_DS_REPLICA_INFO_ATTRIBUTE_VALUE_METADATA, + NULL + },{ + DRSUAPI_DS_REPLICA_GET_INFO2, + DRSUAPI_DS_REPLICA_INFO_CURSORS2, + NULL + },{ + DRSUAPI_DS_REPLICA_GET_INFO2, + DRSUAPI_DS_REPLICA_INFO_CURSORS3, + NULL + },{ + DRSUAPI_DS_REPLICA_GET_INFO2, + DRSUAPI_DS_REPLICA_INFO_OBJ_METADATA2, + NULL + },{ + DRSUAPI_DS_REPLICA_GET_INFO2, + DRSUAPI_DS_REPLICA_INFO_ATTRIBUTE_VALUE_METADATA2, + NULL + },{ + DRSUAPI_DS_REPLICA_GET_INFO2, + DRSUAPI_DS_REPLICA_INFO_NEIGHBORS02, + NULL + },{ + DRSUAPI_DS_REPLICA_GET_INFO2, + DRSUAPI_DS_REPLICA_INFO_CONNECTIONS04, + "__IGNORED__" + },{ + DRSUAPI_DS_REPLICA_GET_INFO2, + DRSUAPI_DS_REPLICA_INFO_CURSURS05, + NULL + },{ + DRSUAPI_DS_REPLICA_GET_INFO2, + DRSUAPI_DS_REPLICA_INFO_06, + NULL + } + }; + + r.in.bind_handle = &priv->bind_handle; + + for (i=0; i < ARRAY_SIZE(array); i++) { + const char *object_dn; + + printf("testing DsReplicaGetInfo level %d infotype %d\n", + array[i].level, array[i].infotype); + + object_dn = (array[i].obj_dn ? array[i].obj_dn : priv->domain_obj_dn); + + r.in.level = array[i].level; + switch(r.in.level) { + case DRSUAPI_DS_REPLICA_GET_INFO: + r.in.req.req1.info_type = array[i].infotype; + r.in.req.req1.object_dn = object_dn; + ZERO_STRUCT(r.in.req.req1.guid1); + break; + case DRSUAPI_DS_REPLICA_GET_INFO2: + r.in.req.req2.info_type = array[i].infotype; + r.in.req.req2.object_dn = object_dn; + ZERO_STRUCT(r.in.req.req1.guid1); + r.in.req.req2.unknown1 = 0; + r.in.req.req2.string1 = NULL; + r.in.req.req2.string2 = NULL; + r.in.req.req2.unknown2 = 0; + break; + } + + status = dcerpc_drsuapi_DsReplicaGetInfo(p, mem_ctx, &r); + if (!NT_STATUS_IS_OK(status)) { + const char *errstr = nt_errstr(status); + if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { + errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); + } + if (p->last_fault_code != DCERPC_FAULT_INVALID_TAG) { + printf("dcerpc_drsuapi_DsReplicaGetInfo failed - %s\n", errstr); + ret = False; + } else { + printf("DsReplicaGetInfo level %d and/or infotype %d not supported by server\n", + array[i].level, array[i].infotype); + } + } else if (!W_ERROR_IS_OK(r.out.result)) { + printf("DsReplicaGetInfo failed - %s\n", win_errstr(r.out.result)); + ret = False; + } + } + + return ret; +} + static BOOL test_DsUnbind(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct DsPrivate *priv) { @@ -693,6 +821,10 @@ BOOL torture_rpc_drsuapi(void) ret = False; } + if (!test_DsReplicaGetInfo(p, mem_ctx, &priv)) { + ret = False; + } + if (!test_DsUnbind(p, mem_ctx, &priv)) { ret = False; } -- cgit From e08e2645de81a89902adcd84e405bfc5baf1fab6 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 13 Dec 2004 10:29:44 +0000 Subject: r4172: commit a DsReplicaSync() torture test this not make much sense as we don't send the correct nc_name but it shows that doesn't get a NDR_FAULT anymore, we just need handle the conformant strings in pidl metze (This used to be commit be449f628faf85a163852d18bc724984d3afefd2) --- source4/torture/rpc/drsuapi.c | 63 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) (limited to 'source4/torture/rpc/drsuapi.c') diff --git a/source4/torture/rpc/drsuapi.c b/source4/torture/rpc/drsuapi.c index e5b7e2ca0c..0b1377c740 100644 --- a/source4/torture/rpc/drsuapi.c +++ b/source4/torture/rpc/drsuapi.c @@ -755,6 +755,65 @@ static BOOL test_DsReplicaGetInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, return ret; } +static BOOL test_DsReplicaSync(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, + struct DsPrivate *priv) +{ + NTSTATUS status; + BOOL ret = True; + int i; + struct drsuapi_DsReplicaSync r; + struct drsuapi_DsReplicaSyncRequest1Info info1; + + struct { + int32 level; + } array[] = { + { + 1 + } + }; + + r.in.bind_handle = &priv->bind_handle; + + for (i=0; i < ARRAY_SIZE(array); i++) { + printf("testing DsReplicaGetInfo level %d\n", + array[i].level); + + r.in.level = array[i].level; + switch(r.in.level) { + case 1: { + uint16_t string[] = { 0x0064, 0x0063, 0x003d, 0x0073, 0x0039, 0x0000}; + ZERO_STRUCT(r.in.req.req1); + r.in.req.req1.info = &info1; + r.in.req.req1.info->unknown1 = 32; + r.in.req.req1.info->unknown2 = 120; + ZERO_STRUCT(r.in.req.req1.info->guid1); + ZERO_ARRAY(r.in.req.req1.info->unknown3); + r.in.req.req1.info->length = ARRAY_SIZE(string)-1; + r.in.req.req1.info->nc_dn = string;/*priv->domain_obj_dn*/; + r.in.req.req1.guid1 = priv->dcinfo.ntds_guid; + r.in.req.req1.string1 = NULL; + r.in.req.req1.unknown1 = 16; + break; + } + } + + status = dcerpc_drsuapi_DsReplicaSync(p, mem_ctx, &r); + if (!NT_STATUS_IS_OK(status)) { + const char *errstr = nt_errstr(status); + if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { + errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); + } + printf("dcerpc_drsuapi_DsReplicaSync failed - %s\n", errstr); + ret = False; + } else if (!W_ERROR_IS_OK(r.out.result)) { + printf("DsReplicaSync failed - %s\n", win_errstr(r.out.result)); + ret = False; + } + } + + return ret; +} + static BOOL test_DsUnbind(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct DsPrivate *priv) { @@ -825,6 +884,10 @@ BOOL torture_rpc_drsuapi(void) ret = False; } + if (!test_DsReplicaSync(p, mem_ctx, &priv)) { + ret = False; + } + if (!test_DsUnbind(p, mem_ctx, &priv)) { ret = False; } -- cgit From 985e86b04d4035c133a29a6a681523b9ca247a19 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 13 Dec 2004 11:34:57 +0000 Subject: r4176: I just remeber that I have already implement STR_CONFORMANT so use it in DsReplicaSync() metze (This used to be commit ca610da1fc3c059d35e17238e8cac5e5b38790c3) --- source4/torture/rpc/drsuapi.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'source4/torture/rpc/drsuapi.c') diff --git a/source4/torture/rpc/drsuapi.c b/source4/torture/rpc/drsuapi.c index 0b1377c740..7bef1e5360 100644 --- a/source4/torture/rpc/drsuapi.c +++ b/source4/torture/rpc/drsuapi.c @@ -780,22 +780,18 @@ static BOOL test_DsReplicaSync(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, r.in.level = array[i].level; switch(r.in.level) { - case 1: { - uint16_t string[] = { 0x0064, 0x0063, 0x003d, 0x0073, 0x0039, 0x0000}; - ZERO_STRUCT(r.in.req.req1); + case 1: r.in.req.req1.info = &info1; r.in.req.req1.info->unknown1 = 32; r.in.req.req1.info->unknown2 = 120; ZERO_STRUCT(r.in.req.req1.info->guid1); ZERO_ARRAY(r.in.req.req1.info->unknown3); - r.in.req.req1.info->length = ARRAY_SIZE(string)-1; - r.in.req.req1.info->nc_dn = string;/*priv->domain_obj_dn*/; + r.in.req.req1.info->nc_dn = priv->domain_obj_dn; r.in.req.req1.guid1 = priv->dcinfo.ntds_guid; r.in.req.req1.string1 = NULL; r.in.req.req1.unknown1 = 16; break; } - } status = dcerpc_drsuapi_DsReplicaSync(p, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { -- cgit From 15581d3e1ecbc0668a0c4552292b62afed2c0889 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 13 Dec 2004 12:24:57 +0000 Subject: r4179: - nicer code layout - and disable DsReplicaSync by default it kill lsass.exe on my w2k box metze (This used to be commit 8373b2d4c7decd49a361637e03b24b311aed302c) --- source4/torture/rpc/drsuapi.c | 30 ++++++++++-------------------- 1 file changed, 10 insertions(+), 20 deletions(-) (limited to 'source4/torture/rpc/drsuapi.c') diff --git a/source4/torture/rpc/drsuapi.c b/source4/torture/rpc/drsuapi.c index 7bef1e5360..bce1bbf9ac 100644 --- a/source4/torture/rpc/drsuapi.c +++ b/source4/torture/rpc/drsuapi.c @@ -860,33 +860,23 @@ BOOL torture_rpc_drsuapi(void) ZERO_STRUCT(priv); - if (!test_DsBind(p, mem_ctx, &priv)) { - ret = False; - } + ret &= test_DsBind(p, mem_ctx, &priv); - if (!test_DsGetDCInfo(p, mem_ctx, &priv)) { - ret = False; - } + ret &= test_DsGetDCInfo(p, mem_ctx, &priv); - if (!test_DsCrackNames(p, mem_ctx, &priv)) { - ret = False; - } + ret &= test_DsCrackNames(p, mem_ctx, &priv); - if (!test_DsWriteAccountSpn(p, mem_ctx, &priv)) { - ret = False; - } + ret &= test_DsWriteAccountSpn(p, mem_ctx, &priv); - if (!test_DsReplicaGetInfo(p, mem_ctx, &priv)) { - ret = False; - } + ret &= test_DsReplicaGetInfo(p, mem_ctx, &priv); - if (!test_DsReplicaSync(p, mem_ctx, &priv)) { - ret = False; + if (lp_parm_int(-1, "torture", "dangerous") == 1) { + ret &= test_DsReplicaSync(p, mem_ctx, &priv); + } else { + printf("DsReplicaSync disabled - enable dangerous tests to use\n"); } - if (!test_DsUnbind(p, mem_ctx, &priv)) { - ret = False; - } + ret &= test_DsUnbind(p, mem_ctx, &priv); talloc_destroy(mem_ctx); -- cgit From 3483fb70e991e3cef47824e54575a4a7feb943ff Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 13 Dec 2004 12:28:47 +0000 Subject: r4180: use the same syntax as the other torture tests metze (This used to be commit 00395ffcc3cc94216619ca827ff6a09b0cc28de1) --- source4/torture/rpc/drsuapi.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'source4/torture/rpc/drsuapi.c') diff --git a/source4/torture/rpc/drsuapi.c b/source4/torture/rpc/drsuapi.c index bce1bbf9ac..f44bf97568 100644 --- a/source4/torture/rpc/drsuapi.c +++ b/source4/torture/rpc/drsuapi.c @@ -772,6 +772,11 @@ static BOOL test_DsReplicaSync(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, } }; + if (lp_parm_int(-1, "torture", "dangerous") != 1) { + printf("DsReplicaSync disabled - enable dangerous tests to use\n"); + return True; + } + r.in.bind_handle = &priv->bind_handle; for (i=0; i < ARRAY_SIZE(array); i++) { @@ -870,11 +875,7 @@ BOOL torture_rpc_drsuapi(void) ret &= test_DsReplicaGetInfo(p, mem_ctx, &priv); - if (lp_parm_int(-1, "torture", "dangerous") == 1) { - ret &= test_DsReplicaSync(p, mem_ctx, &priv); - } else { - printf("DsReplicaSync disabled - enable dangerous tests to use\n"); - } + ret &= test_DsReplicaSync(p, mem_ctx, &priv); ret &= test_DsUnbind(p, mem_ctx, &priv); -- cgit From 00c7f9eed81866568abe1ec8a908fb4bc9274b59 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 31 Dec 2004 01:02:22 +0000 Subject: r4422: make lp_set_cmdline("torture:dangerous", "Yes") a bool parameter metze (This used to be commit 19482a2245abbf9154423ca8997957b56333fba2) --- source4/torture/rpc/drsuapi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/torture/rpc/drsuapi.c') diff --git a/source4/torture/rpc/drsuapi.c b/source4/torture/rpc/drsuapi.c index f44bf97568..2e3fe87bb4 100644 --- a/source4/torture/rpc/drsuapi.c +++ b/source4/torture/rpc/drsuapi.c @@ -772,7 +772,7 @@ static BOOL test_DsReplicaSync(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, } }; - if (lp_parm_int(-1, "torture", "dangerous") != 1) { + if (!lp_parm_bool(-1, "torture", "dangerous", False)) { printf("DsReplicaSync disabled - enable dangerous tests to use\n"); return True; } @@ -791,7 +791,7 @@ static BOOL test_DsReplicaSync(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, r.in.req.req1.info->unknown2 = 120; ZERO_STRUCT(r.in.req.req1.info->guid1); ZERO_ARRAY(r.in.req.req1.info->unknown3); - r.in.req.req1.info->nc_dn = priv->domain_obj_dn; + r.in.req.req1.info->nc_dn = priv->domain_obj_dn?priv->domain_obj_dn:""; r.in.req.req1.guid1 = priv->dcinfo.ntds_guid; r.in.req.req1.string1 = NULL; r.in.req.req1.unknown1 = 16; -- cgit From 3dd17f128831e09c230a8d56e34495d3b31dbacb Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 27 Jan 2005 06:16:59 +0000 Subject: r5034: - added a type mapping function in pidl, so the type names in our IDL files don't need to match the type names in the generated headers - with this type mapping we no longer need definitions for the deprecated "int32", "uint8" etc form of types. We can now force everyone to use the standard types int32_t, uint8_t etc. - fixed all the code that used the deprecated types - converted the IDL types "int64" and "uint64" to "dlong" and "udlong". These are the 4 byte aligned 64 bit integers that Microsoft internally define as two 32 bit integers in a structure. After discussions with Ronnie Sahlberg we decided that calling these "int64" was confusing, as it implied a true 8 byte aligned type - fixed all the cases where we incorrectly used things like "NTTIME_hyper" in our C code. The generated API now uses a NTTIME for those. The fact that it is hyper-aligned on the wire is not relevant to the API, and should remain just a IDL property (This used to be commit f86521677d7ff16bdc4815f9524e5286026f10f3) --- source4/torture/rpc/drsuapi.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source4/torture/rpc/drsuapi.c') diff --git a/source4/torture/rpc/drsuapi.c b/source4/torture/rpc/drsuapi.c index 2e3fe87bb4..4821d67d9c 100644 --- a/source4/torture/rpc/drsuapi.c +++ b/source4/torture/rpc/drsuapi.c @@ -638,8 +638,8 @@ static BOOL test_DsReplicaGetInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, BOOL ret = True; int i; struct { - int32 level; - int32 infotype; + int32_t level; + int32_t infotype; const char *obj_dn; } array[] = { { @@ -765,7 +765,7 @@ static BOOL test_DsReplicaSync(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct drsuapi_DsReplicaSyncRequest1Info info1; struct { - int32 level; + int32_t level; } array[] = { { 1 -- cgit From 759da3b915e2006d4c87b5ace47f399accd9ce91 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 27 Jan 2005 07:08:20 +0000 Subject: r5037: got rid of all of the TALLOC_DEPRECATED stuff. My apologies for the large commit. I thought this was worthwhile to get done for consistency. (This used to be commit ec32b22ed5ec224f6324f5e069d15e92e38e15c0) --- source4/torture/rpc/drsuapi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/torture/rpc/drsuapi.c') diff --git a/source4/torture/rpc/drsuapi.c b/source4/torture/rpc/drsuapi.c index 4821d67d9c..f386c84a91 100644 --- a/source4/torture/rpc/drsuapi.c +++ b/source4/torture/rpc/drsuapi.c @@ -879,7 +879,7 @@ BOOL torture_rpc_drsuapi(void) ret &= test_DsUnbind(p, mem_ctx, &priv); - talloc_destroy(mem_ctx); + talloc_free(mem_ctx); torture_rpc_close(p); -- cgit From 75ddf59ea110117578acd3a7b889549bfb40473c Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 10 Feb 2005 07:39:14 +0000 Subject: r5308: trimmed back a lot of the old macros from smb_macros.h (This used to be commit bf43c9bdcf9e654d123f6a2b29feb9189ca9e561) --- source4/torture/rpc/drsuapi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/torture/rpc/drsuapi.c') diff --git a/source4/torture/rpc/drsuapi.c b/source4/torture/rpc/drsuapi.c index f386c84a91..e10c088e36 100644 --- a/source4/torture/rpc/drsuapi.c +++ b/source4/torture/rpc/drsuapi.c @@ -790,7 +790,7 @@ static BOOL test_DsReplicaSync(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, r.in.req.req1.info->unknown1 = 32; r.in.req.req1.info->unknown2 = 120; ZERO_STRUCT(r.in.req.req1.info->guid1); - ZERO_ARRAY(r.in.req.req1.info->unknown3); + ZERO_STRUCT(r.in.req.req1.info->unknown3); r.in.req.req1.info->nc_dn = priv->domain_obj_dn?priv->domain_obj_dn:""; r.in.req.req1.guid1 = priv->dcinfo.ntds_guid; r.in.req.req1.string1 = NULL; -- cgit From 4b83366b6cf81a29fab0f9dac5e6074784c639a8 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 11 Mar 2005 12:15:50 +0000 Subject: r5742: - add torture test and idl for DsReplicaUpdateRefs() (the torture test currently only tests if the idl is correct) - add start for idl for DsGetNCChanges() (if someone didn't noticed the current ethereal trunk code can successful decrypt DCERPC and LDAP gsskrb5 encrypted blobs, when you provide a keytab and have compiled against heimdal :-) - add a view bitmaps and enum's for better debugging metze (This used to be commit cf7c1352ab2857b80256e02f70ab3fbd5177d596) --- source4/torture/rpc/drsuapi.c | 70 +++++++++++++++++++++++++++++++++++++++---- 1 file changed, 65 insertions(+), 5 deletions(-) (limited to 'source4/torture/rpc/drsuapi.c') diff --git a/source4/torture/rpc/drsuapi.c b/source4/torture/rpc/drsuapi.c index e10c088e36..a6c0f5b9c6 100644 --- a/source4/torture/rpc/drsuapi.c +++ b/source4/torture/rpc/drsuapi.c @@ -29,6 +29,7 @@ struct DsPrivate { struct GUID bind_guid; const char *domain_obj_dn; const char *domain_guid_str; + const char *domain_dns_name; struct GUID domain_guid; struct drsuapi_DsGetDCInfo2 dcinfo; }; @@ -133,6 +134,7 @@ static BOOL test_DsCrackNames(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, 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; GUID_from_string(priv->domain_guid_str, &priv->domain_guid); @@ -780,21 +782,20 @@ static BOOL test_DsReplicaSync(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, r.in.bind_handle = &priv->bind_handle; for (i=0; i < ARRAY_SIZE(array); i++) { - printf("testing DsReplicaGetInfo level %d\n", + printf("testing DsReplicaSync level %d\n", array[i].level); r.in.level = array[i].level; switch(r.in.level) { case 1: r.in.req.req1.info = &info1; - r.in.req.req1.info->unknown1 = 32; - r.in.req.req1.info->unknown2 = 120; + r.in.req.req1.info->unknown1 = 0; ZERO_STRUCT(r.in.req.req1.info->guid1); - ZERO_STRUCT(r.in.req.req1.info->unknown3); + ZERO_STRUCT(r.in.req.req1.info->byte_array); r.in.req.req1.info->nc_dn = priv->domain_obj_dn?priv->domain_obj_dn:""; r.in.req.req1.guid1 = priv->dcinfo.ntds_guid; r.in.req.req1.string1 = NULL; - r.in.req.req1.unknown1 = 16; + r.in.req.req1.options = 16; break; } @@ -815,6 +816,63 @@ static BOOL test_DsReplicaSync(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, return ret; } +static BOOL test_DsReplicaUpdateRefs(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, + struct DsPrivate *priv) +{ + NTSTATUS status; + BOOL ret = True; + int i; + struct drsuapi_DsReplicaUpdateRefs r; + struct GUID null_guid; + struct { + int32_t level; + } array[] = { + { + 1 + } + }; + + ZERO_STRUCT(null_guid); + + r.in.bind_handle = &priv->bind_handle; + + for (i=0; i < ARRAY_SIZE(array); i++) { + printf("testing DsReplicaUpdateRefs level %d\n", + array[i].level); + + r.in.level = array[i].level; + switch(r.in.level) { + case 1: + r.in.req.req1.unknown1 = 0; + r.in.req.req1.unknown2 = 0; + r.in.req.req1.dest_dsa_guid = null_guid; + r.in.req.req1.options = 0; + r.in.req.req1.sync_req_info1.unknown1 = 0; + r.in.req.req1.sync_req_info1.guid1 = null_guid; + ZERO_STRUCT(r.in.req.req1.sync_req_info1.byte_array); + r.in.req.req1.sync_req_info1.nc_dn = priv->domain_obj_dn?priv->domain_obj_dn:""; + r.in.req.req1.dest_dsa_dns_name = talloc_asprintf(mem_ctx, "__some_dest_dsa_guid_string._msdn.%s", + priv->domain_dns_name); + break; + } + + status = dcerpc_drsuapi_DsReplicaUpdateRefs(p, mem_ctx, &r); + if (!NT_STATUS_IS_OK(status)) { + const char *errstr = nt_errstr(status); + if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { + errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); + } + printf("dcerpc_drsuapi_DsReplicaUpdateRefs failed - %s\n", errstr); + ret = False; + } else if (!W_ERROR_IS_OK(r.out.result)) { + printf("DsReplicaUpdateRefs failed - %s\n", win_errstr(r.out.result)); + ret = False; + } + } + + return ret; +} + static BOOL test_DsUnbind(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct DsPrivate *priv) { @@ -877,6 +935,8 @@ BOOL torture_rpc_drsuapi(void) ret &= test_DsReplicaSync(p, mem_ctx, &priv); + ret &= test_DsReplicaUpdateRefs(p, mem_ctx, &priv); + ret &= test_DsUnbind(p, mem_ctx, &priv); talloc_free(mem_ctx); -- cgit From cead12981f86f8c30daf50995d61ff3af9439898 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 15 Mar 2005 14:42:09 +0000 Subject: r5799: more DsGetNCChanges updates, I'm starting to understand it... also add a really simple torture test for DsGetNCChanges metze (This used to be commit bcde67a7eff9ad82919e90fd64c02a17610c6f0e) --- source4/torture/rpc/drsuapi.c | 110 ++++++++++++++++++++++++++++++++++++------ 1 file changed, 94 insertions(+), 16 deletions(-) (limited to 'source4/torture/rpc/drsuapi.c') diff --git a/source4/torture/rpc/drsuapi.c b/source4/torture/rpc/drsuapi.c index a6c0f5b9c6..57382289a2 100644 --- a/source4/torture/rpc/drsuapi.c +++ b/source4/torture/rpc/drsuapi.c @@ -764,8 +764,9 @@ static BOOL test_DsReplicaSync(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, BOOL ret = True; int i; struct drsuapi_DsReplicaSync r; - struct drsuapi_DsReplicaSyncRequest1Info info1; - + struct drsuapi_DsReplicaObjectIdentifier nc; + struct GUID null_guid; + struct dom_sid null_sid; struct { int32_t level; } array[] = { @@ -779,6 +780,9 @@ static BOOL test_DsReplicaSync(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, return True; } + ZERO_STRUCT(null_guid); + ZERO_STRUCT(null_sid); + r.in.bind_handle = &priv->bind_handle; for (i=0; i < ARRAY_SIZE(array); i++) { @@ -788,11 +792,11 @@ static BOOL test_DsReplicaSync(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, r.in.level = array[i].level; switch(r.in.level) { case 1: - r.in.req.req1.info = &info1; - r.in.req.req1.info->unknown1 = 0; - ZERO_STRUCT(r.in.req.req1.info->guid1); - ZERO_STRUCT(r.in.req.req1.info->byte_array); - r.in.req.req1.info->nc_dn = priv->domain_obj_dn?priv->domain_obj_dn:""; + nc.guid = null_guid; + nc.sid = null_sid; + nc.dn = priv->domain_obj_dn?priv->domain_obj_dn:""; + + r.in.req.req1.naming_context = &nc; r.in.req.req1.guid1 = priv->dcinfo.ntds_guid; r.in.req.req1.string1 = NULL; r.in.req.req1.options = 16; @@ -823,7 +827,9 @@ static BOOL test_DsReplicaUpdateRefs(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, BOOL ret = True; int i; struct drsuapi_DsReplicaUpdateRefs r; + struct drsuapi_DsReplicaObjectIdentifier nc; struct GUID null_guid; + struct dom_sid null_sid; struct { int32_t level; } array[] = { @@ -833,6 +839,7 @@ static BOOL test_DsReplicaUpdateRefs(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, }; ZERO_STRUCT(null_guid); + ZERO_STRUCT(null_sid); r.in.bind_handle = &priv->bind_handle; @@ -843,16 +850,15 @@ static BOOL test_DsReplicaUpdateRefs(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, r.in.level = array[i].level; switch(r.in.level) { case 1: - r.in.req.req1.unknown1 = 0; - r.in.req.req1.unknown2 = 0; - r.in.req.req1.dest_dsa_guid = null_guid; - r.in.req.req1.options = 0; - r.in.req.req1.sync_req_info1.unknown1 = 0; - r.in.req.req1.sync_req_info1.guid1 = null_guid; - ZERO_STRUCT(r.in.req.req1.sync_req_info1.byte_array); - r.in.req.req1.sync_req_info1.nc_dn = priv->domain_obj_dn?priv->domain_obj_dn:""; - r.in.req.req1.dest_dsa_dns_name = talloc_asprintf(mem_ctx, "__some_dest_dsa_guid_string._msdn.%s", + nc.guid = null_guid; + nc.sid = null_sid; + nc.dn = priv->domain_obj_dn?priv->domain_obj_dn:""; + + r.in.req.req1.naming_context = &nc; + r.in.req.req1.dest_dsa_dns_name = talloc_asprintf(mem_ctx, "__some_dest_dsa_guid_string._msdn.%s", priv->domain_dns_name); + r.in.req.req1.dest_dsa_guid = null_guid; + r.in.req.req1.options = 0; break; } @@ -873,6 +879,76 @@ static BOOL test_DsReplicaUpdateRefs(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, return ret; } +static BOOL test_DsGetNCChanges(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, + struct DsPrivate *priv) +{ + NTSTATUS status; + BOOL ret = True; + int i; + struct drsuapi_DsGetNCChanges r; + struct drsuapi_DsReplicaObjectIdentifier nc; + struct GUID null_guid; + struct dom_sid null_sid; + struct { + int32_t level; + } array[] = { + { + 5 + }, + { + 8 + } + }; + + ZERO_STRUCT(null_guid); + ZERO_STRUCT(null_sid); + + for (i=0; i < ARRAY_SIZE(array); i++) { + printf("testing DsGetNCChanges level %d\n", + array[i].level); + + ZERO_STRUCT(r.in); + r.in.bind_handle = &priv->bind_handle; + r.in.level = array[i].level; + + switch (r.in.level) { + case 5: + nc.guid = null_guid; + nc.sid = null_sid; + nc.dn = talloc_asprintf(mem_ctx, "CN=Schema,CN=Configuration,%s", + priv->domain_obj_dn?priv->domain_obj_dn:""); + nc.dn = priv->domain_obj_dn?priv->domain_obj_dn:""; + + r.in.req.req5.naming_context = &nc; + r.in.req.req5.usn1.usn1 = 0; + break; + case 8: + nc.guid = null_guid; + nc.sid = null_sid; + nc.dn = priv->domain_obj_dn?priv->domain_obj_dn:""; + + r.in.req.req8.naming_context = &nc; + r.in.req.req8.usn1.usn1 = 0; + break; + } + + status = dcerpc_drsuapi_DsGetNCChanges(p, mem_ctx, &r); + if (!NT_STATUS_IS_OK(status)) { + const char *errstr = nt_errstr(status); + if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { + errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); + } + printf("dcerpc_drsuapi_DsGetNCChanges failed - %s\n", errstr); + ret = False; + } else if (!W_ERROR_IS_OK(r.out.result)) { + printf("DsGetNCChanges failed - %s\n", win_errstr(r.out.result)); + ret = False; + } + } + + return ret; +} + static BOOL test_DsUnbind(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct DsPrivate *priv) { @@ -937,6 +1013,8 @@ BOOL torture_rpc_drsuapi(void) ret &= test_DsReplicaUpdateRefs(p, mem_ctx, &priv); + ret &= test_DsGetNCChanges(p, mem_ctx, &priv); + ret &= test_DsUnbind(p, mem_ctx, &priv); talloc_free(mem_ctx); -- cgit From c638a8380defc9afc713886f3290d581ac37995d Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 16 Mar 2005 15:47:19 +0000 Subject: r5830: start to analyse the attribute values, depending on the attribute type metze (This used to be commit 63229b9503950847fbecd6ec22171d8c18d7ac91) --- source4/torture/rpc/drsuapi.c | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) (limited to 'source4/torture/rpc/drsuapi.c') diff --git a/source4/torture/rpc/drsuapi.c b/source4/torture/rpc/drsuapi.c index 57382289a2..c4dbe00958 100644 --- a/source4/torture/rpc/drsuapi.c +++ b/source4/torture/rpc/drsuapi.c @@ -907,7 +907,6 @@ static BOOL test_DsGetNCChanges(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, printf("testing DsGetNCChanges level %d\n", array[i].level); - ZERO_STRUCT(r.in); r.in.bind_handle = &priv->bind_handle; r.in.level = array[i].level; @@ -915,20 +914,44 @@ static BOOL test_DsGetNCChanges(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, case 5: nc.guid = null_guid; nc.sid = null_sid; - nc.dn = talloc_asprintf(mem_ctx, "CN=Schema,CN=Configuration,%s", - priv->domain_obj_dn?priv->domain_obj_dn:""); nc.dn = priv->domain_obj_dn?priv->domain_obj_dn:""; + r.in.req.req5.guid1 = null_guid; + r.in.req.req5.guid2 = null_guid; r.in.req.req5.naming_context = &nc; r.in.req.req5.usn1.usn1 = 0; + r.in.req.req5.usn1.usn2 = 0; + r.in.req.req5.usn1.usn3 = 0; + r.in.req.req5.coursor = NULL; + r.in.req.req5.unknown1 = 0;/*0x10201C70;*/ + r.in.req.req5.unknown2 = 0;/*402;*/ + r.in.req.req5.unknown3 = 0;/*402116;*/ + r.in.req.req5.unknown4 = 0; + r.in.req.req5.h1 = 0; + break; case 8: nc.guid = null_guid; nc.sid = null_sid; nc.dn = priv->domain_obj_dn?priv->domain_obj_dn:""; + r.in.req.req8.guid1 = null_guid; + r.in.req.req8.guid2 = null_guid; r.in.req.req8.naming_context = &nc; r.in.req.req8.usn1.usn1 = 0; + r.in.req.req8.usn1.usn2 = 0; + r.in.req.req8.usn1.usn3 = 0; + r.in.req.req8.coursor = NULL; + r.in.req.req8.unknown1 = 0;/*0x10201C70;*/ + r.in.req.req8.unknown2 = 0;/*402;*/ + r.in.req.req8.unknown3 = 0;/*402116;*/ + r.in.req.req8.unknown4 = 0; + r.in.req.req8.h1 = 0; + r.in.req.req8.unique_ptr1 = 0; + r.in.req.req8.unique_ptr2 = 0; + r.in.req.req8.ctr12.count = 0; + r.in.req.req8.ctr12.array = NULL; + break; } -- cgit From 645711c602313940dcf80ec786557920ecfbf884 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Tue, 22 Mar 2005 08:00:45 +0000 Subject: r5941: Commit this patch much earlier than I would normally prefer, but metze needs a working tree... The main volume of this patch was what I started working on today: - Cleans up memory handling around DCE/RPC pipes, to have a parent talloc context. - Uses sepereate inner loops for some of the DCE/RPC tests The other and more important part of this patch fixes issues surrounding the new credentials framwork: This makes the struct cli_credentials always a talloc() structure, rather than on the stack. Parts of the cli_credentials code already assumed this. There were other issues, particularly in the DCERPC over SMB handling, as well as little things that had to be tidied up before test_w2k3.sh would start to pass. Andrew Bartlett (This used to be commit 0453f9d05d2e336fba1f85dbf2718d01fa2bf778) --- source4/torture/rpc/drsuapi.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'source4/torture/rpc/drsuapi.c') diff --git a/source4/torture/rpc/drsuapi.c b/source4/torture/rpc/drsuapi.c index c4dbe00958..88ff85d8da 100644 --- a/source4/torture/rpc/drsuapi.c +++ b/source4/torture/rpc/drsuapi.c @@ -1008,18 +1008,20 @@ BOOL torture_rpc_drsuapi(void) BOOL ret = True; struct DsPrivate priv; - status = torture_rpc_connection(&p, + mem_ctx = talloc_init("torture_rpc_drsuapi"); + + status = torture_rpc_connection(mem_ctx, + &p, DCERPC_DRSUAPI_NAME, DCERPC_DRSUAPI_UUID, DCERPC_DRSUAPI_VERSION); if (!NT_STATUS_IS_OK(status)) { + talloc_free(mem_ctx); return False; } printf("Connected to DRAUAPI pipe\n"); - mem_ctx = talloc_init("torture_rpc_drsuapi"); - ZERO_STRUCT(priv); ret &= test_DsBind(p, mem_ctx, &priv); @@ -1042,7 +1044,5 @@ BOOL torture_rpc_drsuapi(void) talloc_free(mem_ctx); - torture_rpc_close(p); - return ret; } -- cgit From 1bb3e99d063332ac9d8af92cb3210465cfa66fb4 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 22 Mar 2005 14:49:11 +0000 Subject: r5949: give things more meaning, and reuse structs where it is possible to make things more clear metze (This used to be commit adefeeb4f362dba06cddacf6f58194ef1f967ec9) --- source4/torture/rpc/drsuapi.c | 72 +++++++++++++++++++++---------------------- 1 file changed, 36 insertions(+), 36 deletions(-) (limited to 'source4/torture/rpc/drsuapi.c') diff --git a/source4/torture/rpc/drsuapi.c b/source4/torture/rpc/drsuapi.c index 88ff85d8da..9774a92a8a 100644 --- a/source4/torture/rpc/drsuapi.c +++ b/source4/torture/rpc/drsuapi.c @@ -912,45 +912,45 @@ static BOOL test_DsGetNCChanges(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, 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.guid1 = null_guid; - r.in.req.req5.guid2 = null_guid; - r.in.req.req5.naming_context = &nc; - r.in.req.req5.usn1.usn1 = 0; - r.in.req.req5.usn1.usn2 = 0; - r.in.req.req5.usn1.usn3 = 0; - r.in.req.req5.coursor = NULL; - r.in.req.req5.unknown1 = 0;/*0x10201C70;*/ - r.in.req.req5.unknown2 = 0;/*402;*/ - r.in.req.req5.unknown3 = 0;/*402116;*/ - r.in.req.req5.unknown4 = 0; - r.in.req.req5.h1 = 0; + 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_guid = null_guid; + r.in.req.req5.naming_context = &nc; + r.in.req.req5.replication_state.tmp_highest_usn = 0; + r.in.req.req5.replication_state.reserved_usn = 0; + r.in.req.req5.replication_state.highest_usn = 0; + r.in.req.req5.highwatermark_vector = NULL; + r.in.req.req5.unknown1 = 0;/*0x10201C70;*/ + r.in.req.req5.unknown2 = 402; + r.in.req.req5.unknown3 = 402116; + r.in.req.req5.unknown4 = 0; + r.in.req.req5.h1 = 0; break; case 8: - nc.guid = null_guid; - nc.sid = null_sid; - nc.dn = priv->domain_obj_dn?priv->domain_obj_dn:""; - - r.in.req.req8.guid1 = null_guid; - r.in.req.req8.guid2 = null_guid; - r.in.req.req8.naming_context = &nc; - r.in.req.req8.usn1.usn1 = 0; - r.in.req.req8.usn1.usn2 = 0; - r.in.req.req8.usn1.usn3 = 0; - r.in.req.req8.coursor = NULL; - r.in.req.req8.unknown1 = 0;/*0x10201C70;*/ - r.in.req.req8.unknown2 = 0;/*402;*/ - r.in.req.req8.unknown3 = 0;/*402116;*/ - r.in.req.req8.unknown4 = 0; - r.in.req.req8.h1 = 0; - r.in.req.req8.unique_ptr1 = 0; - r.in.req.req8.unique_ptr2 = 0; - r.in.req.req8.ctr12.count = 0; - r.in.req.req8.ctr12.array = NULL; + nc.guid = null_guid; + 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_guid = null_guid; + r.in.req.req8.naming_context = &nc; + r.in.req.req8.replication_state.tmp_highest_usn = 0; + r.in.req.req8.replication_state.reserved_usn = 0; + r.in.req.req8.replication_state.highest_usn = 0; + r.in.req.req8.highwatermark_vector = NULL; + r.in.req.req8.unknown1 = 0x10201C70; + r.in.req.req8.unknown2 = 402; + r.in.req.req8.unknown3 = 402116; + r.in.req.req8.unknown4 = 0; + r.in.req.req8.h1 = 0; + r.in.req.req8.unique_ptr1 = 0; + r.in.req.req8.unique_ptr2 = 0; + r.in.req.req8.ctr12.count = 0; + r.in.req.req8.ctr12.array = NULL; break; } -- cgit From 01ab1128cedfe3381ba579445e6714152e29add8 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 23 Mar 2005 18:54:06 +0000 Subject: r5998: I was wrong with the highwater mark... I think I now understand how it works:-) metze (This used to be commit f8add2e66a56896d9bb18991091e1b17c29910b1) --- source4/torture/rpc/drsuapi.c | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) (limited to 'source4/torture/rpc/drsuapi.c') diff --git a/source4/torture/rpc/drsuapi.c b/source4/torture/rpc/drsuapi.c index 9774a92a8a..8b1cccd1e0 100644 --- a/source4/torture/rpc/drsuapi.c +++ b/source4/torture/rpc/drsuapi.c @@ -902,7 +902,7 @@ static BOOL test_DsGetNCChanges(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, ZERO_STRUCT(null_guid); ZERO_STRUCT(null_sid); - + for (i=0; i < ARRAY_SIZE(array); i++) { printf("testing DsGetNCChanges level %d\n", array[i].level); @@ -919,13 +919,13 @@ static BOOL test_DsGetNCChanges(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, r.in.req.req5.destination_dsa_guid = GUID_random(); r.in.req.req5.source_dsa_guid = null_guid; r.in.req.req5.naming_context = &nc; - r.in.req.req5.replication_state.tmp_highest_usn = 0; - r.in.req.req5.replication_state.reserved_usn = 0; - r.in.req.req5.replication_state.highest_usn = 0; - r.in.req.req5.highwatermark_vector = NULL; - r.in.req.req5.unknown1 = 0;/*0x10201C70;*/ - r.in.req.req5.unknown2 = 402; - r.in.req.req5.unknown3 = 402116; + r.in.req.req5.highwatermark.tmp_highest_usn = 167997; + 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.req5.unknown2 = 0; + r.in.req.req5.unknown3 = 0; r.in.req.req5.unknown4 = 0; r.in.req.req5.h1 = 0; @@ -938,11 +938,18 @@ static BOOL test_DsGetNCChanges(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, r.in.req.req8.destination_dsa_guid = GUID_random(); r.in.req.req8.source_dsa_guid = null_guid; r.in.req.req8.naming_context = &nc; - r.in.req.req8.replication_state.tmp_highest_usn = 0; - r.in.req.req8.replication_state.reserved_usn = 0; - r.in.req.req8.replication_state.highest_usn = 0; - r.in.req.req8.highwatermark_vector = NULL; - r.in.req.req8.unknown1 = 0x10201C70; + 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 + | DRSUAPI_DS_REPLICA_NEIGHBOUR_WRITEABLE + | 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 + | DRSUAPI_DS_REPLICA_NEIGHBOUR_COMPRESS_CHANGES + ; r.in.req.req8.unknown2 = 402; r.in.req.req8.unknown3 = 402116; r.in.req.req8.unknown4 = 0; -- cgit From 220f82e57071fd8385efe9ab6f6677cddf07d373 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 23 Mar 2005 18:55:12 +0000 Subject: r5999: ups, remove the testvalue that I used against my w2k3 server metze (This used to be commit 3d3e09af16c4f9a6bc8f6ae615f744a04f352ed0) --- source4/torture/rpc/drsuapi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/torture/rpc/drsuapi.c') diff --git a/source4/torture/rpc/drsuapi.c b/source4/torture/rpc/drsuapi.c index 8b1cccd1e0..e657cff3fe 100644 --- a/source4/torture/rpc/drsuapi.c +++ b/source4/torture/rpc/drsuapi.c @@ -919,7 +919,7 @@ static BOOL test_DsGetNCChanges(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, r.in.req.req5.destination_dsa_guid = GUID_random(); r.in.req.req5.source_dsa_guid = null_guid; r.in.req.req5.naming_context = &nc; - r.in.req.req5.highwatermark.tmp_highest_usn = 167997; + 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; -- cgit From 3ec2c008b83b71b9f7aa7e7bd33a94c9af39dbe9 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 23 Mar 2005 19:24:11 +0000 Subject: r6000: add some notes about the cases where compression (or what ever this is) is used, in the reply. metze (This used to be commit 618dadb7ef092af0f2c13c2e67874041f54f4e98) --- source4/torture/rpc/drsuapi.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'source4/torture/rpc/drsuapi.c') diff --git a/source4/torture/rpc/drsuapi.c b/source4/torture/rpc/drsuapi.c index e657cff3fe..f1d7e04b29 100644 --- a/source4/torture/rpc/drsuapi.c +++ b/source4/torture/rpc/drsuapi.c @@ -923,7 +923,11 @@ static BOOL test_DsGetNCChanges(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, 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.req5.replica_flags = 0 +#if 0 + | DRSUAPI_DS_REPLICA_NEIGHBOUR_COMPRESS_CHANGES +#endif + ; r.in.req.req5.unknown2 = 0; r.in.req.req5.unknown3 = 0; r.in.req.req5.unknown4 = 0; -- cgit From 64ad915111c685e203b26b0d0e669714a764a832 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 29 Mar 2005 06:19:44 +0000 Subject: r6109: nicer way to handle compression in the torture test metze (This used to be commit a3cec189e1f5d137ba2f2829def03b060b59f0e2) --- source4/torture/rpc/drsuapi.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'source4/torture/rpc/drsuapi.c') diff --git a/source4/torture/rpc/drsuapi.c b/source4/torture/rpc/drsuapi.c index f1d7e04b29..f76654be77 100644 --- a/source4/torture/rpc/drsuapi.c +++ b/source4/torture/rpc/drsuapi.c @@ -923,11 +923,10 @@ static BOOL test_DsGetNCChanges(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, 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 0 - | DRSUAPI_DS_REPLICA_NEIGHBOUR_COMPRESS_CHANGES -#endif - ; + r.in.req.req5.replica_flags = 0; + if (lp_parm_bool(-1, "drsuapi","compression", False)) { + r.in.req.req5.replica_flags |= DRSUAPI_DS_REPLICA_NEIGHBOUR_COMPRESS_CHANGES; + } r.in.req.req5.unknown2 = 0; r.in.req.req5.unknown3 = 0; r.in.req.req5.unknown4 = 0; -- cgit From 42d692efe74e6ff4753d2b1a62c61bf3811df4d0 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Tue, 23 Aug 2005 11:54:38 +0000 Subject: r9516: Try a full-on matrix test of all the combinations in DRSUAPI CrackNames. Andrew Bartlett (This used to be commit a82a419579872fc78b02c29972eaf55da22088c1) --- source4/torture/rpc/drsuapi.c | 125 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 123 insertions(+), 2 deletions(-) (limited to 'source4/torture/rpc/drsuapi.c') diff --git a/source4/torture/rpc/drsuapi.c b/source4/torture/rpc/drsuapi.c index f76654be77..69d9630209 100644 --- a/source4/torture/rpc/drsuapi.c +++ b/source4/torture/rpc/drsuapi.c @@ -65,6 +65,127 @@ static BOOL test_DsBind(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, return ret; } +static BOOL test_DsCrackNamesMatrix(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, + struct DsPrivate *priv, const char *dn) +{ + + + NTSTATUS status; + BOOL ret = True; + struct drsuapi_DsCrackNames r; + struct drsuapi_DsNameString names[1]; + enum drsuapi_DsNameFormat formats[] = { + DRSUAPI_DS_NAME_FORMAT_FQDN_1779, + DRSUAPI_DS_NAME_FORMAT_NT4_ACCOUNT, + DRSUAPI_DS_NAME_FORMAT_DISPLAY, + DRSUAPI_DS_NAME_FORMAT_GUID, + DRSUAPI_DS_NAME_FORMAT_CANONICAL, + DRSUAPI_DS_NAME_FORMAT_USER_PRINCIPAL, + DRSUAPI_DS_NAME_FORMAT_CANONICAL_EX, + DRSUAPI_DS_NAME_FORMAT_SERVICE_PRINCIPAL, + DRSUAPI_DS_NAME_FORMAT_SID_OR_SID_HISTORY, + DRSUAPI_DS_NAME_FORMAT_DNS_DOMAIN + }; + int i, j; + + const char *n_matrix[ARRAY_SIZE(formats)][ARRAY_SIZE(formats)]; + const char *n_from[ARRAY_SIZE(formats)]; + + ZERO_STRUCT(r); + r.in.bind_handle = &priv->bind_handle; + r.in.level = 1; + r.in.req.req1.unknown1 = 0x000004e4; + r.in.req.req1.unknown2 = 0x00000407; + r.in.req.req1.count = 1; + r.in.req.req1.names = names; + r.in.req.req1.format_flags = DRSUAPI_DS_NAME_FLAG_NO_FLAGS; + + 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]; + names[0].str = dn; + 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); + + status = dcerpc_drsuapi_DsCrackNames(p, mem_ctx, &r); + if (!NT_STATUS_IS_OK(status)) { + const char *errstr = nt_errstr(status); + if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { + errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); + } + printf("dcerpc_drsuapi_DsCrackNames failed - %s\n", errstr); + ret = False; + } else if (!W_ERROR_IS_OK(r.out.result)) { + printf("DsCrackNames failed - %s\n", win_errstr(r.out.result)); + ret = False; + } + + if (!ret) { + return ret; + } + if (r.out.ctr.ctr1->array[0].status == DRSUAPI_DS_NAME_STATUS_OK) { + n_from[i] = r.out.ctr.ctr1->array[0].result_name; + printf("%s\n", n_from[i]); + } else { + n_from[i] = NULL; + printf("Error\n"); + } + } + + 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]; + if (!n_from[i]) { + n_matrix[i][j] = NULL; + continue; + } + names[0].str = n_from[i]; + status = dcerpc_drsuapi_DsCrackNames(p, mem_ctx, &r); + if (!NT_STATUS_IS_OK(status)) { + const char *errstr = nt_errstr(status); + if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { + 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); + 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, + win_errstr(r.out.result)); + ret = False; + } + + 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; + } else { + n_matrix[i][j] = NULL; + } + } + } + + for (i = 0; i < ARRAY_SIZE(formats); i++) { + for (j = 0; j < ARRAY_SIZE(formats); j++) { + if (n_matrix[i][j] == n_from[j]) { + } else if (n_matrix[i][j] == NULL) { + } else if (n_matrix[i][j] != NULL && n_from[j] == NULL) { + printf("dcerpc_drsuapi_DsCrackNames mismatch - from %d to %d: %s should be %s\n", formats[i], formats[j], n_matrix[i][j], n_from[j]); + ret = False; + } else if (strcmp(n_matrix[i][j], n_from[j]) != 0) { + printf("dcerpc_drsuapi_DsCrackNames mismatch - from %d to %d: %s should be %s\n", formats[i], formats[j], n_matrix[i][j], n_from[j]); + ret = False; + } + } + } + return ret; +} + static BOOL test_DsCrackNames(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct DsPrivate *priv) { @@ -442,8 +563,8 @@ static BOOL test_DsCrackNames(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, ret = False; } - if (!ret) { - return ret; + if (ret) { + return test_DsCrackNamesMatrix(p, mem_ctx, priv, FQDN_1779_name); } return ret; -- cgit From 69578c8b8c7a28de11c4023ce57960425f22a558 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Tue, 23 Aug 2005 22:02:54 +0000 Subject: r9547: A pile more completeness testing for DsCrackNames. Andrew Bartlett (This used to be commit 01c4a970ec22b3915b8017da018bd500b4fffcbc) --- source4/torture/rpc/drsuapi.c | 157 ++++++++++++++++++++++++++++++++++++++---- 1 file changed, 143 insertions(+), 14 deletions(-) (limited to 'source4/torture/rpc/drsuapi.c') diff --git a/source4/torture/rpc/drsuapi.c b/source4/torture/rpc/drsuapi.c index 69d9630209..f4c608eb8c 100644 --- a/source4/torture/rpc/drsuapi.c +++ b/source4/torture/rpc/drsuapi.c @@ -66,7 +66,8 @@ static BOOL test_DsBind(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, } static BOOL test_DsCrackNamesMatrix(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, - struct DsPrivate *priv, const char *dn) + struct DsPrivate *priv, const char *dn, + const char *user_principal_name, const char *service_principal_name) { @@ -125,12 +126,38 @@ 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) { + switch (formats[i]) { + case DRSUAPI_DS_NAME_FORMAT_USER_PRINCIPAL: + case DRSUAPI_DS_NAME_FORMAT_SERVICE_PRINCIPAL: + case DRSUAPI_DS_NAME_FORMAT_SID_OR_SID_HISTORY: + case DRSUAPI_DS_NAME_FORMAT_DNS_DOMAIN: + if (r.out.ctr.ctr1->array[0].status == DRSUAPI_DS_NAME_STATUS_OK) { + printf("Unexpected success: This name lookup should fail\n"); + 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); + return False; + } + } + + switch (formats[i]) { + case DRSUAPI_DS_NAME_FORMAT_USER_PRINCIPAL: + n_from[i] = user_principal_name; + break; + case DRSUAPI_DS_NAME_FORMAT_SERVICE_PRINCIPAL: + n_from[i] = service_principal_name; + break; + case DRSUAPI_DS_NAME_FORMAT_SID_OR_SID_HISTORY: + case DRSUAPI_DS_NAME_FORMAT_DNS_DOMAIN: + n_from[i] = NULL; + break; + default: n_from[i] = r.out.ctr.ctr1->array[0].result_name; printf("%s\n", n_from[i]); - } else { - n_from[i] = NULL; - printf("Error\n"); } } @@ -173,7 +200,16 @@ static BOOL test_DsCrackNamesMatrix(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, for (i = 0; i < ARRAY_SIZE(formats); i++) { for (j = 0; j < ARRAY_SIZE(formats); j++) { if (n_matrix[i][j] == n_from[j]) { - } else if (n_matrix[i][j] == NULL) { + + /* We don't have a from name for these yet (and we can't map to them to find it out) */ + } else if (n_matrix[i][j] == NULL && n_from[i] == NULL) { + + /* we can't map to these two */ + } else if (n_matrix[i][j] == NULL && formats[j] == DRSUAPI_DS_NAME_FORMAT_USER_PRINCIPAL) { + } else if (n_matrix[i][j] == NULL && formats[j] == DRSUAPI_DS_NAME_FORMAT_SERVICE_PRINCIPAL) { + } else if (n_matrix[i][j] == NULL && n_from[j] != NULL) { + printf("dcerpc_drsuapi_DsCrackNames mismatch - from %d to %d: %s should be %s\n", formats[i], formats[j], n_matrix[i][j], n_from[j]); + ret = False; } else if (n_matrix[i][j] != NULL && n_from[j] == NULL) { printf("dcerpc_drsuapi_DsCrackNames mismatch - from %d to %d: %s should be %s\n", formats[i], formats[j], n_matrix[i][j], n_from[j]); ret = False; @@ -196,6 +232,8 @@ static BOOL test_DsCrackNames(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, const char *dns_domain; const char *nt4_domain; const char *FQDN_1779_name; + const char *user_principal_name; + const char *service_principal_name; ZERO_STRUCT(r); r.in.bind_handle = &priv->bind_handle; @@ -224,6 +262,9 @@ static BOOL test_DsCrackNames(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, } 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); + ret = False; } if (!ret) { @@ -249,6 +290,9 @@ static BOOL test_DsCrackNames(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, } 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); + ret = False; } if (!ret) { @@ -278,6 +322,9 @@ static BOOL test_DsCrackNames(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, } 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); + ret = False; } if (!ret) { @@ -302,6 +349,9 @@ static BOOL test_DsCrackNames(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, } 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); + ret = False; } if (!ret) { @@ -328,6 +378,9 @@ static BOOL test_DsCrackNames(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, } 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); + ret = False; } if (!ret) { @@ -336,9 +389,10 @@ static BOOL test_DsCrackNames(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, FQDN_1779_name = r.out.ctr.ctr1->array[0].result_name; - r.in.req.req1.format_offered = DRSUAPI_DS_NAME_FORMAT_FQDN_1779; - r.in.req.req1.format_desired = DRSUAPI_DS_NAME_FORMAT_CANONICAL; - names[0].str = FQDN_1779_name; + r.in.req.req1.format_offered = DRSUAPI_DS_NAME_FORMAT_USER_PRINCIPAL; + r.in.req.req1.format_desired = DRSUAPI_DS_NAME_FORMAT_FQDN_1779; + names[0].str = talloc_asprintf(mem_ctx, "%s$@%s", priv->dcinfo.netbios_name, dns_domain); + user_principal_name = names[0].str; printf("testing DsCrackNames with name '%s' desired format:%d\n", names[0].str, r.in.req.req1.format_desired); @@ -354,13 +408,24 @@ static BOOL test_DsCrackNames(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, } 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); + ret = False; } if (!ret) { return ret; } - r.in.req.req1.format_desired = DRSUAPI_DS_NAME_FORMAT_DISPLAY; + if (strcmp(r.out.ctr.ctr1->array[0].result_name, FQDN_1779_name) != 0) { + printf("DsCrackNames failed - %s != %s\n", r.out.ctr.ctr1->array[0].result_name, FQDN_1779_name); + return False; + } + + r.in.req.req1.format_offered = DRSUAPI_DS_NAME_FORMAT_SERVICE_PRINCIPAL; + r.in.req.req1.format_desired = DRSUAPI_DS_NAME_FORMAT_FQDN_1779; + names[0].str = talloc_asprintf(mem_ctx, "HOST/%s", priv->dcinfo.netbios_name); + service_principal_name = names[0].str; printf("testing DsCrackNames with name '%s' desired format:%d\n", names[0].str, r.in.req.req1.format_desired); @@ -376,13 +441,23 @@ static BOOL test_DsCrackNames(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, } 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); + ret = False; } if (!ret) { return ret; } - r.in.req.req1.format_desired = DRSUAPI_DS_NAME_FORMAT_GUID; + if (strcmp(r.out.ctr.ctr1->array[0].result_name, FQDN_1779_name) != 0) { + printf("DsCrackNames failed - %s != %s\n", r.out.ctr.ctr1->array[0].result_name, FQDN_1779_name); + return False; + } + + r.in.req.req1.format_offered = DRSUAPI_DS_NAME_FORMAT_SERVICE_PRINCIPAL; + r.in.req.req1.format_desired = DRSUAPI_DS_NAME_FORMAT_FQDN_1779; + names[0].str = talloc_asprintf(mem_ctx, "cifs/%s.%s", priv->dcinfo.netbios_name, dns_domain); printf("testing DsCrackNames with name '%s' desired format:%d\n", names[0].str, r.in.req.req1.format_desired); @@ -398,13 +473,23 @@ static BOOL test_DsCrackNames(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, } 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); + ret = False; } if (!ret) { return ret; } - r.in.req.req1.format_desired = DRSUAPI_DS_NAME_FORMAT_USER_PRINCIPAL; + if (strcmp(r.out.ctr.ctr1->array[0].result_name, FQDN_1779_name) != 0) { + printf("DsCrackNames failed - %s != %s\n", r.out.ctr.ctr1->array[0].result_name, FQDN_1779_name); + return False; + } + + r.in.req.req1.format_offered = DRSUAPI_DS_NAME_FORMAT_FQDN_1779; + r.in.req.req1.format_desired = DRSUAPI_DS_NAME_FORMAT_CANONICAL; + names[0].str = FQDN_1779_name; printf("testing DsCrackNames with name '%s' desired format:%d\n", names[0].str, r.in.req.req1.format_desired); @@ -426,7 +511,7 @@ static BOOL test_DsCrackNames(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, return ret; } - r.in.req.req1.format_desired = DRSUAPI_DS_NAME_FORMAT_SERVICE_PRINCIPAL; + r.in.req.req1.format_desired = DRSUAPI_DS_NAME_FORMAT_DISPLAY; printf("testing DsCrackNames with name '%s' desired format:%d\n", names[0].str, r.in.req.req1.format_desired); @@ -442,6 +527,34 @@ static BOOL test_DsCrackNames(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, } 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); + ret = False; + } + + if (!ret) { + return ret; + } + + 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); + + status = dcerpc_drsuapi_DsCrackNames(p, mem_ctx, &r); + if (!NT_STATUS_IS_OK(status)) { + const char *errstr = nt_errstr(status); + if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { + errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); + } + printf("dcerpc_drsuapi_DsCrackNames failed - %s\n", errstr); + ret = False; + } 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); + ret = False; } if (!ret) { @@ -466,6 +579,9 @@ static BOOL test_DsCrackNames(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, } 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); + ret = False; } if (!ret) { @@ -489,6 +605,9 @@ static BOOL test_DsCrackNames(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, } 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); + ret = False; } if (!ret) { @@ -513,6 +632,9 @@ static BOOL test_DsCrackNames(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, } 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); + ret = False; } if (!ret) { @@ -537,12 +659,16 @@ static BOOL test_DsCrackNames(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, } 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); + ret = False; } if (!ret) { return ret; } + /* NEGATIVE test. This should parse, but not succeed */ 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 = GUID_string2(mem_ctx, &priv->bind_guid); @@ -561,10 +687,13 @@ static BOOL test_DsCrackNames(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, } 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 succeeded on name - %d\n", r.out.ctr.ctr1->array[0].status); + ret = False; } if (ret) { - return test_DsCrackNamesMatrix(p, mem_ctx, priv, FQDN_1779_name); + return test_DsCrackNamesMatrix(p, mem_ctx, priv, FQDN_1779_name, user_principal_name, service_principal_name); } return ret; -- cgit From 1a316fd8c50e501b5d69bb47ff5d1d483b02b04e Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Mon, 29 Aug 2005 04:15:08 +0000 Subject: r9727: A simplier test I can aim at passing when I get the cracknames code done. Andrew Bartlett (This used to be commit b1b0e26e537677793a92af02464ff1e83fce9610) --- source4/torture/rpc/drsuapi.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'source4/torture/rpc/drsuapi.c') diff --git a/source4/torture/rpc/drsuapi.c b/source4/torture/rpc/drsuapi.c index f4c608eb8c..4e72a0f9b3 100644 --- a/source4/torture/rpc/drsuapi.c +++ b/source4/torture/rpc/drsuapi.c @@ -1306,3 +1306,40 @@ BOOL torture_rpc_drsuapi(void) return ret; } + +BOOL torture_rpc_drsuapi_cracknames(void) +{ + NTSTATUS status; + struct dcerpc_pipe *p; + TALLOC_CTX *mem_ctx; + BOOL ret = True; + struct DsPrivate priv; + + mem_ctx = talloc_init("torture_rpc_drsuapi"); + + status = torture_rpc_connection(mem_ctx, + &p, + DCERPC_DRSUAPI_NAME, + DCERPC_DRSUAPI_UUID, + DCERPC_DRSUAPI_VERSION); + if (!NT_STATUS_IS_OK(status)) { + talloc_free(mem_ctx); + return False; + } + + printf("Connected to DRAUAPI pipe\n"); + + ZERO_STRUCT(priv); + + ret &= test_DsBind(p, mem_ctx, &priv); + + ret &= test_DsGetDCInfo(p, mem_ctx, &priv); + + ret &= test_DsCrackNames(p, mem_ctx, &priv); + + ret &= test_DsUnbind(p, mem_ctx, &priv); + + talloc_free(mem_ctx); + + return ret; +} -- cgit From 4b9411896840bfd8b83f39f0ecfa1f16a28a8dcc Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Mon, 29 Aug 2005 12:16:49 +0000 Subject: r9733: Test conversion from known sids in CrackNames. Andrew Bartlett (This used to be commit ad60d4571568d5b3edd98199462812a2f30c36cd) --- source4/torture/rpc/drsuapi.c | 56 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) (limited to 'source4/torture/rpc/drsuapi.c') diff --git a/source4/torture/rpc/drsuapi.c b/source4/torture/rpc/drsuapi.c index 4e72a0f9b3..874e903db3 100644 --- a/source4/torture/rpc/drsuapi.c +++ b/source4/torture/rpc/drsuapi.c @@ -668,6 +668,62 @@ static BOOL test_DsCrackNames(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, return ret; } + r.in.req.req1.format_offered = DRSUAPI_DS_NAME_FORMAT_SID_OR_SID_HISTORY; + r.in.req.req1.format_desired = DRSUAPI_DS_NAME_FORMAT_FQDN_1779; + names[0].str = SID_BUILTIN; + + printf("testing DsCrackNames with SID '%s' desired format:%d\n", + names[0].str, r.in.req.req1.format_desired); + + status = dcerpc_drsuapi_DsCrackNames(p, mem_ctx, &r); + if (!NT_STATUS_IS_OK(status)) { + const char *errstr = nt_errstr(status); + if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { + errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); + } + printf("dcerpc_drsuapi_DsCrackNames failed - %s\n", errstr); + ret = False; + } 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); + ret = False; + } + + if (!ret) { + return ret; + } + + + r.in.req.req1.format_offered = DRSUAPI_DS_NAME_FORMAT_SID_OR_SID_HISTORY; + r.in.req.req1.format_desired = DRSUAPI_DS_NAME_FORMAT_FQDN_1779; + names[0].str = SID_BUILTIN_ADMINISTRATORS; + + printf("testing DsCrackNames with SID '%s' desired format:%d\n", + names[0].str, r.in.req.req1.format_desired); + + status = dcerpc_drsuapi_DsCrackNames(p, mem_ctx, &r); + if (!NT_STATUS_IS_OK(status)) { + const char *errstr = nt_errstr(status); + if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { + errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); + } + printf("dcerpc_drsuapi_DsCrackNames failed - %s\n", errstr); + ret = False; + } 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); + ret = False; + } + + if (!ret) { + return ret; + } + + /* NEGATIVE test. This should parse, but not succeed */ r.in.req.req1.format_offered = DRSUAPI_DS_NAME_FORMAT_GUID; r.in.req.req1.format_desired = DRSUAPI_DS_NAME_FORMAT_FQDN_1779; -- cgit From 24dd21c498efd67054620d900d3358bcf0085cab Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Tue, 30 Aug 2005 03:37:14 +0000 Subject: r9778: Test for particular error returns, rather than just OK/not OK. Andrew Bartlett (This used to be commit fccbc15555871059e62bf720f115b2307a171667) --- source4/torture/rpc/drsuapi.c | 110 +++++++++++++++++++++++++++++++++++++++--- 1 file changed, 103 insertions(+), 7 deletions(-) (limited to 'source4/torture/rpc/drsuapi.c') diff --git a/source4/torture/rpc/drsuapi.c b/source4/torture/rpc/drsuapi.c index 874e903db3..0d3a6920b0 100644 --- a/source4/torture/rpc/drsuapi.c +++ b/source4/torture/rpc/drsuapi.c @@ -127,12 +127,27 @@ static BOOL test_DsCrackNamesMatrix(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, return ret; } switch (formats[i]) { - case DRSUAPI_DS_NAME_FORMAT_USER_PRINCIPAL: case DRSUAPI_DS_NAME_FORMAT_SERVICE_PRINCIPAL: - case DRSUAPI_DS_NAME_FORMAT_SID_OR_SID_HISTORY: + 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); + 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) { + printf(__location__ ": Unexpected error (%d): This name lookup should fail\n", + r.out.ctr.ctr1->array[0].status); + return False; + } + printf ("(expected) error\n"); + break; case DRSUAPI_DS_NAME_FORMAT_DNS_DOMAIN: - if (r.out.ctr.ctr1->array[0].status == DRSUAPI_DS_NAME_STATUS_OK) { - printf("Unexpected success: This name lookup should fail\n"); + case DRSUAPI_DS_NAME_FORMAT_SID_OR_SID_HISTORY: + 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); return False; } printf ("(expected) error\n"); @@ -724,7 +739,65 @@ static BOOL test_DsCrackNames(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, } - /* NEGATIVE test. This should parse, but not succeed */ + /* NEGATIVE tests. This should parse, but not succeed */ + r.in.req.req1.format_offered = DRSUAPI_DS_NAME_FORMAT_SERVICE_PRINCIPAL; + r.in.req.req1.format_desired = DRSUAPI_DS_NAME_FORMAT_FQDN_1779; + names[0].str = talloc_asprintf(mem_ctx, "cifs/%s.%s@%s", + priv->dcinfo.netbios_name, dns_domain, + dns_domain); + + printf("testing DsCrackNames with Service Principal '%s' desired format:%d\n", + names[0].str, r.in.req.req1.format_desired); + + status = dcerpc_drsuapi_DsCrackNames(p, mem_ctx, &r); + if (!NT_STATUS_IS_OK(status)) { + const char *errstr = nt_errstr(status); + if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { + errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); + } + printf("dcerpc_drsuapi_DsCrackNames failed - %s\n", errstr); + ret = False; + } 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_DOMAIN_ONLY) { + printf("DsCrackNames incorrect error on name - %d\n", r.out.ctr.ctr1->array[0].status); + ret = False; + } + + if (!ret) { + return ret; + } + + /* NEGATIVE tests. This should parse, but not succeed */ + 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 = "NOT A GUID"; + + printf("testing DsCrackNames with BIND GUID '%s' desired format:%d\n", + names[0].str, r.in.req.req1.format_desired); + + status = dcerpc_drsuapi_DsCrackNames(p, mem_ctx, &r); + if (!NT_STATUS_IS_OK(status)) { + const char *errstr = nt_errstr(status); + if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { + errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); + } + printf("dcerpc_drsuapi_DsCrackNames failed - %s\n", errstr); + ret = False; + } 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_NOT_FOUND) { + printf("DsCrackNames incorrect error on name - %d\n", r.out.ctr.ctr1->array[0].status); + ret = False; + } + + if (!ret) { + return ret; + } + + /* NEGATIVE tests. This should parse, but not succeed */ 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 = GUID_string2(mem_ctx, &priv->bind_guid); @@ -743,8 +816,31 @@ static BOOL test_DsCrackNames(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, } 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 succeeded on name - %d\n", r.out.ctr.ctr1->array[0].status); + } else if (r.out.ctr.ctr1->array[0].status != DRSUAPI_DS_NAME_STATUS_NOT_FOUND) { + printf("DsCrackNames incorrect error on name - %d\n", r.out.ctr.ctr1->array[0].status); + ret = False; + } + + r.in.req.req1.format_offered = DRSUAPI_DS_NAME_FORMAT_USER_PRINCIPAL; + r.in.req.req1.format_desired = DRSUAPI_DS_NAME_FORMAT_FQDN_1779; + names[0].str = talloc_asprintf(mem_ctx, "%s$", priv->dcinfo.netbios_name); + + printf("testing DsCrackNames with user principal name '%s' desired format:%d\n", + names[0].str, r.in.req.req1.format_desired); + + status = dcerpc_drsuapi_DsCrackNames(p, mem_ctx, &r); + if (!NT_STATUS_IS_OK(status)) { + const char *errstr = nt_errstr(status); + if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { + errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); + } + printf("dcerpc_drsuapi_DsCrackNames failed - %s\n", errstr); + ret = False; + } 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_NOT_FOUND) { + printf("DsCrackNames incorrect error on name - %d\n", r.out.ctr.ctr1->array[0].status); ret = False; } -- cgit From cf9b91668a6465ba6890a9767e5248dbe66eb74a Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Thu, 1 Sep 2005 02:23:38 +0000 Subject: r9861: I need to convert this to table-driven, but anyway... More CrackNames testing Andrew Bartlett (This used to be commit 0913dec6a98e735e5e3157a2fceec94f57dd706c) --- source4/torture/rpc/drsuapi.c | 76 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 75 insertions(+), 1 deletion(-) (limited to 'source4/torture/rpc/drsuapi.c') diff --git a/source4/torture/rpc/drsuapi.c b/source4/torture/rpc/drsuapi.c index 0d3a6920b0..e7a4fb1709 100644 --- a/source4/torture/rpc/drsuapi.c +++ b/source4/torture/rpc/drsuapi.c @@ -774,7 +774,35 @@ static BOOL test_DsCrackNames(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, r.in.req.req1.format_desired = DRSUAPI_DS_NAME_FORMAT_FQDN_1779; names[0].str = "NOT A GUID"; - printf("testing DsCrackNames with BIND GUID '%s' desired format:%d\n", + printf("testing DsCrackNames with GUID '%s' desired format:%d\n", + names[0].str, r.in.req.req1.format_desired); + + status = dcerpc_drsuapi_DsCrackNames(p, mem_ctx, &r); + if (!NT_STATUS_IS_OK(status)) { + const char *errstr = nt_errstr(status); + if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { + errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); + } + printf("dcerpc_drsuapi_DsCrackNames failed - %s\n", errstr); + ret = False; + } 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_NOT_FOUND) { + printf("DsCrackNames incorrect error on name - %d\n", r.out.ctr.ctr1->array[0].status); + ret = False; + } + + if (!ret) { + return ret; + } + + /* NEGATIVE tests. This should parse, but not succeed */ + r.in.req.req1.format_offered = DRSUAPI_DS_NAME_FORMAT_SID_OR_SID_HISTORY; + r.in.req.req1.format_desired = DRSUAPI_DS_NAME_FORMAT_FQDN_1779; + names[0].str = "NOT A SID"; + + printf("testing DsCrackNames with SID '%s' desired format:%d\n", names[0].str, r.in.req.req1.format_desired); status = dcerpc_drsuapi_DsCrackNames(p, mem_ctx, &r); @@ -844,6 +872,52 @@ static BOOL test_DsCrackNames(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, ret = False; } + r.in.req.req1.format_offered = DRSUAPI_DS_NAME_FORMAT_SERVICE_PRINCIPAL; + r.in.req.req1.format_desired = DRSUAPI_DS_NAME_FORMAT_FQDN_1779; + names[0].str = talloc_asprintf(mem_ctx, "%s$", priv->dcinfo.netbios_name); + + printf("testing DsCrackNames with service principal name '%s' desired format:%d\n", + names[0].str, r.in.req.req1.format_desired); + + status = dcerpc_drsuapi_DsCrackNames(p, mem_ctx, &r); + if (!NT_STATUS_IS_OK(status)) { + const char *errstr = nt_errstr(status); + if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { + errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); + } + printf("dcerpc_drsuapi_DsCrackNames failed - %s\n", errstr); + ret = False; + } 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_NOT_FOUND) { + printf("DsCrackNames incorrect error on name - %d\n", r.out.ctr.ctr1->array[0].status); + ret = False; + } + + r.in.req.req1.format_offered = DRSUAPI_DS_NAME_FORMAT_USER_PRINCIPAL; + r.in.req.req1.format_desired = DRSUAPI_DS_NAME_FORMAT_FQDN_1779; + names[0].str = "foo@bar"; + + printf("testing DsCrackNames with user principal name '%s' desired format:%d\n", + names[0].str, r.in.req.req1.format_desired); + + status = dcerpc_drsuapi_DsCrackNames(p, mem_ctx, &r); + if (!NT_STATUS_IS_OK(status)) { + const char *errstr = nt_errstr(status); + if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { + errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); + } + printf("dcerpc_drsuapi_DsCrackNames failed - %s\n", errstr); + ret = False; + } 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_DOMAIN_ONLY) { + printf("DsCrackNames incorrect error on name - %d\n", r.out.ctr.ctr1->array[0].status); + ret = False; + } + if (ret) { return test_DsCrackNamesMatrix(p, mem_ctx, priv, FQDN_1779_name, user_principal_name, service_principal_name); } -- cgit From 9c8483dd123d75d768378a3a745b63e95a087f36 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Thu, 1 Sep 2005 07:07:00 +0000 Subject: r9878: This is getting a bit out of control, but a few more tests. Andrew Bartlett (This used to be commit a6597181f62e5b0ec95232a2dd69b5d85de845b8) --- source4/torture/rpc/drsuapi.c | 148 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 148 insertions(+) (limited to 'source4/torture/rpc/drsuapi.c') diff --git a/source4/torture/rpc/drsuapi.c b/source4/torture/rpc/drsuapi.c index e7a4fb1709..197157b2b2 100644 --- a/source4/torture/rpc/drsuapi.c +++ b/source4/torture/rpc/drsuapi.c @@ -825,6 +825,118 @@ static BOOL test_DsCrackNames(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, return ret; } + /* NEGATIVE tests. This should parse, but not succeed */ + 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 = "NOT AN NT4 NAME"; + + printf("testing DsCrackNames with NT4 Name '%s' desired format:%d\n", + names[0].str, r.in.req.req1.format_desired); + + status = dcerpc_drsuapi_DsCrackNames(p, mem_ctx, &r); + if (!NT_STATUS_IS_OK(status)) { + const char *errstr = nt_errstr(status); + if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { + errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); + } + printf("dcerpc_drsuapi_DsCrackNames failed - %s\n", errstr); + ret = False; + } 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_NOT_FOUND) { + printf("DsCrackNames incorrect error on name - %d\n", r.out.ctr.ctr1->array[0].status); + ret = False; + } + + if (!ret) { + return ret; + } + + /* NEGATIVE tests. This should parse, but not succeed */ + r.in.req.req1.format_offered = DRSUAPI_DS_NAME_FORMAT_FQDN_1779; + r.in.req.req1.format_desired = DRSUAPI_DS_NAME_FORMAT_GUID; + names[0].str = "NOT A DN"; + + printf("testing DsCrackNames with DN '%s' desired format:%d\n", + names[0].str, r.in.req.req1.format_desired); + + status = dcerpc_drsuapi_DsCrackNames(p, mem_ctx, &r); + if (!NT_STATUS_IS_OK(status)) { + const char *errstr = nt_errstr(status); + if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { + errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); + } + printf("dcerpc_drsuapi_DsCrackNames failed - %s\n", errstr); + ret = False; + } 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_NOT_FOUND) { + printf("DsCrackNames incorrect error on name - %d\n", r.out.ctr.ctr1->array[0].status); + ret = False; + } + + if (!ret) { + return ret; + } + + /* NEGATIVE tests. This should parse, but not succeed */ + r.in.req.req1.format_offered = DRSUAPI_DS_NAME_FORMAT_USER_PRINCIPAL; + r.in.req.req1.format_desired = DRSUAPI_DS_NAME_FORMAT_FQDN_1779; + names[0].str = "NOT A PRINCIPAL"; + + printf("testing DsCrackNames with user principal '%s' desired format:%d\n", + names[0].str, r.in.req.req1.format_desired); + + status = dcerpc_drsuapi_DsCrackNames(p, mem_ctx, &r); + if (!NT_STATUS_IS_OK(status)) { + const char *errstr = nt_errstr(status); + if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { + errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); + } + printf("dcerpc_drsuapi_DsCrackNames failed - %s\n", errstr); + ret = False; + } 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_NOT_FOUND) { + printf("DsCrackNames incorrect error on name - %d\n", r.out.ctr.ctr1->array[0].status); + ret = False; + } + + if (!ret) { + return ret; + } + + /* NEGATIVE tests. This should parse, but not succeed */ + r.in.req.req1.format_offered = DRSUAPI_DS_NAME_FORMAT_SERVICE_PRINCIPAL; + r.in.req.req1.format_desired = DRSUAPI_DS_NAME_FORMAT_FQDN_1779; + names[0].str = "NOT A SERVICE PRINCIPAL"; + + printf("testing DsCrackNames with service principal '%s' desired format:%d\n", + names[0].str, r.in.req.req1.format_desired); + + status = dcerpc_drsuapi_DsCrackNames(p, mem_ctx, &r); + if (!NT_STATUS_IS_OK(status)) { + const char *errstr = nt_errstr(status); + if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { + errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); + } + printf("dcerpc_drsuapi_DsCrackNames failed - %s\n", errstr); + ret = False; + } 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_NOT_FOUND) { + printf("DsCrackNames incorrect error on name - %d\n", r.out.ctr.ctr1->array[0].status); + ret = False; + } + + if (!ret) { + return ret; + } + /* NEGATIVE tests. This should parse, but not succeed */ r.in.req.req1.format_offered = DRSUAPI_DS_NAME_FORMAT_GUID; r.in.req.req1.format_desired = DRSUAPI_DS_NAME_FORMAT_FQDN_1779; @@ -849,6 +961,7 @@ static BOOL test_DsCrackNames(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, ret = False; } + /* NEGATIVE tests. This should parse, but not succeed */ r.in.req.req1.format_offered = DRSUAPI_DS_NAME_FORMAT_USER_PRINCIPAL; r.in.req.req1.format_desired = DRSUAPI_DS_NAME_FORMAT_FQDN_1779; names[0].str = talloc_asprintf(mem_ctx, "%s$", priv->dcinfo.netbios_name); @@ -872,6 +985,7 @@ static BOOL test_DsCrackNames(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, ret = False; } + /* NEGATIVE tests. This should parse, but not succeed */ r.in.req.req1.format_offered = DRSUAPI_DS_NAME_FORMAT_SERVICE_PRINCIPAL; r.in.req.req1.format_desired = DRSUAPI_DS_NAME_FORMAT_FQDN_1779; names[0].str = talloc_asprintf(mem_ctx, "%s$", priv->dcinfo.netbios_name); @@ -895,6 +1009,40 @@ static BOOL test_DsCrackNames(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, ret = False; } + + if (!ret) { + return ret; + } + + /* NEGATIVE tests. This should parse, but not succeed */ + 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\\", lp_realm()); + + printf("testing DsCrackNames with name '%s' desired format:%d\n", + names[0].str, r.in.req.req1.format_desired); + + status = dcerpc_drsuapi_DsCrackNames(p, mem_ctx, &r); + if (!NT_STATUS_IS_OK(status)) { + const char *errstr = nt_errstr(status); + if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { + errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); + } + printf("dcerpc_drsuapi_DsCrackNames failed - %s\n", errstr); + ret = False; + } 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_NOT_FOUND) { + printf("DsCrackNames incorrect error on name - %d\n", r.out.ctr.ctr1->array[0].status); + ret = False; + } + + if (!ret) { + return ret; + } + + /* NEGATIVE tests. This should parse, but not succeed */ r.in.req.req1.format_offered = DRSUAPI_DS_NAME_FORMAT_USER_PRINCIPAL; r.in.req.req1.format_desired = DRSUAPI_DS_NAME_FORMAT_FQDN_1779; names[0].str = "foo@bar"; -- cgit From b3c0dacd20c1d8002b02eceb21036dc74a684d36 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Fri, 2 Sep 2005 03:19:27 +0000 Subject: r9941: Update the CrackNames test, and provide a much improved server-side DRSUAPI CrackNames. We can't pass the full cracknames test until the initial provision is updated, the seperate DomainControllerInfo and canonical names support is added. Andrew Bartlett (This used to be commit ed24d88f0e8c6371acf6638a1c5f2112bc0bf285) --- source4/torture/rpc/drsuapi.c | 139 +++++++++++++++++++++++++++++------------- 1 file changed, 98 insertions(+), 41 deletions(-) (limited to 'source4/torture/rpc/drsuapi.c') diff --git a/source4/torture/rpc/drsuapi.c b/source4/torture/rpc/drsuapi.c index 197157b2b2..078b03710a 100644 --- a/source4/torture/rpc/drsuapi.c +++ b/source4/torture/rpc/drsuapi.c @@ -238,7 +238,7 @@ static BOOL test_DsCrackNamesMatrix(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, } static BOOL test_DsCrackNames(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, - struct DsPrivate *priv) + struct DsPrivate *priv, const char *test_dc) { NTSTATUS status; struct drsuapi_DsCrackNames r; @@ -323,7 +323,7 @@ static BOOL test_DsCrackNames(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, r.in.req.req1.format_desired = DRSUAPI_DS_NAME_FORMAT_NT4_ACCOUNT; names[0].str = priv->domain_guid_str; - printf("testing DsCrackNames with name '%s' desired format:%d\n", + printf("testing DsCrackNames with GUID '%s' desired format:%d\n", names[0].str, r.in.req.req1.format_desired); status = dcerpc_drsuapi_DsCrackNames(p, mem_ctx, &r); @@ -377,7 +377,7 @@ static BOOL test_DsCrackNames(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, 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, priv->dcinfo.netbios_name); + 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); @@ -406,7 +406,7 @@ static BOOL test_DsCrackNames(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, r.in.req.req1.format_offered = DRSUAPI_DS_NAME_FORMAT_USER_PRINCIPAL; r.in.req.req1.format_desired = DRSUAPI_DS_NAME_FORMAT_FQDN_1779; - names[0].str = talloc_asprintf(mem_ctx, "%s$@%s", priv->dcinfo.netbios_name, dns_domain); + names[0].str = talloc_asprintf(mem_ctx, "%s$@%s", test_dc, dns_domain); user_principal_name = names[0].str; printf("testing DsCrackNames with name '%s' desired format:%d\n", @@ -439,7 +439,7 @@ static BOOL test_DsCrackNames(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, r.in.req.req1.format_offered = DRSUAPI_DS_NAME_FORMAT_SERVICE_PRINCIPAL; r.in.req.req1.format_desired = DRSUAPI_DS_NAME_FORMAT_FQDN_1779; - names[0].str = talloc_asprintf(mem_ctx, "HOST/%s", priv->dcinfo.netbios_name); + names[0].str = talloc_asprintf(mem_ctx, "HOST/%s", test_dc); service_principal_name = names[0].str; printf("testing DsCrackNames with name '%s' desired format:%d\n", @@ -472,7 +472,7 @@ static BOOL test_DsCrackNames(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, r.in.req.req1.format_offered = DRSUAPI_DS_NAME_FORMAT_SERVICE_PRINCIPAL; r.in.req.req1.format_desired = DRSUAPI_DS_NAME_FORMAT_FQDN_1779; - names[0].str = talloc_asprintf(mem_ctx, "cifs/%s.%s", priv->dcinfo.netbios_name, dns_domain); + names[0].str = talloc_asprintf(mem_ctx, "cifs/%s.%s", test_dc, dns_domain); printf("testing DsCrackNames with name '%s' desired format:%d\n", names[0].str, r.in.req.req1.format_desired); @@ -520,6 +520,9 @@ static BOOL test_DsCrackNames(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, } 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); + ret = False; } if (!ret) { @@ -711,39 +714,11 @@ static BOOL test_DsCrackNames(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, } - r.in.req.req1.format_offered = DRSUAPI_DS_NAME_FORMAT_SID_OR_SID_HISTORY; - r.in.req.req1.format_desired = DRSUAPI_DS_NAME_FORMAT_FQDN_1779; - names[0].str = SID_BUILTIN_ADMINISTRATORS; - - printf("testing DsCrackNames with SID '%s' desired format:%d\n", - names[0].str, r.in.req.req1.format_desired); - - status = dcerpc_drsuapi_DsCrackNames(p, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - const char *errstr = nt_errstr(status); - if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { - errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); - } - printf("dcerpc_drsuapi_DsCrackNames failed - %s\n", errstr); - ret = False; - } 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); - ret = False; - } - - if (!ret) { - return ret; - } - - /* NEGATIVE tests. This should parse, but not succeed */ r.in.req.req1.format_offered = DRSUAPI_DS_NAME_FORMAT_SERVICE_PRINCIPAL; r.in.req.req1.format_desired = DRSUAPI_DS_NAME_FORMAT_FQDN_1779; names[0].str = talloc_asprintf(mem_ctx, "cifs/%s.%s@%s", - priv->dcinfo.netbios_name, dns_domain, + test_dc, dns_domain, dns_domain); printf("testing DsCrackNames with Service Principal '%s' desired format:%d\n", @@ -964,7 +939,7 @@ static BOOL test_DsCrackNames(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, /* NEGATIVE tests. This should parse, but not succeed */ r.in.req.req1.format_offered = DRSUAPI_DS_NAME_FORMAT_USER_PRINCIPAL; r.in.req.req1.format_desired = DRSUAPI_DS_NAME_FORMAT_FQDN_1779; - names[0].str = talloc_asprintf(mem_ctx, "%s$", priv->dcinfo.netbios_name); + names[0].str = talloc_asprintf(mem_ctx, "%s$", test_dc); printf("testing DsCrackNames with user principal name '%s' desired format:%d\n", names[0].str, r.in.req.req1.format_desired); @@ -988,7 +963,7 @@ static BOOL test_DsCrackNames(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, /* NEGATIVE tests. This should parse, but not succeed */ r.in.req.req1.format_offered = DRSUAPI_DS_NAME_FORMAT_SERVICE_PRINCIPAL; r.in.req.req1.format_desired = DRSUAPI_DS_NAME_FORMAT_FQDN_1779; - names[0].str = talloc_asprintf(mem_ctx, "%s$", priv->dcinfo.netbios_name); + names[0].str = talloc_asprintf(mem_ctx, "%s$", test_dc); printf("testing DsCrackNames with service principal name '%s' desired format:%d\n", names[0].str, r.in.req.req1.format_desired); @@ -1042,6 +1017,90 @@ static BOOL test_DsCrackNames(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, return ret; } + 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; + names[0].str = SID_BUILTIN; + + printf("testing DsCrackNames with SID '%s' desired format:%d\n", + names[0].str, r.in.req.req1.format_desired); + + status = dcerpc_drsuapi_DsCrackNames(p, mem_ctx, &r); + if (!NT_STATUS_IS_OK(status)) { + const char *errstr = nt_errstr(status); + if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { + errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); + } + printf("dcerpc_drsuapi_DsCrackNames failed - %s\n", errstr); + ret = False; + } 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); + ret = False; + } + + if (!ret) { + return ret; + } + + + r.in.req.req1.format_offered = DRSUAPI_DS_NAME_FORMAT_SID_OR_SID_HISTORY; + r.in.req.req1.format_desired = DRSUAPI_DS_NAME_FORMAT_FQDN_1779; + names[0].str = SID_BUILTIN_ADMINISTRATORS; + + printf("testing DsCrackNames with SID '%s' desired format:%d\n", + names[0].str, r.in.req.req1.format_desired); + + status = dcerpc_drsuapi_DsCrackNames(p, mem_ctx, &r); + if (!NT_STATUS_IS_OK(status)) { + const char *errstr = nt_errstr(status); + if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { + errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); + } + printf("dcerpc_drsuapi_DsCrackNames failed - %s\n", errstr); + ret = False; + } 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_NO_MAPPING) { + printf("DsCrackNames incorrect error on name - %d\n", r.out.ctr.ctr1->array[0].status); + ret = False; + } + + if (!ret) { + return ret; + } + + + 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; + names[0].str = SID_BUILTIN_ADMINISTRATORS; + + printf("testing DsCrackNames with SID '%s' desired format:%d\n", + names[0].str, r.in.req.req1.format_desired); + + status = dcerpc_drsuapi_DsCrackNames(p, mem_ctx, &r); + if (!NT_STATUS_IS_OK(status)) { + const char *errstr = nt_errstr(status); + if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { + errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); + } + printf("dcerpc_drsuapi_DsCrackNames failed - %s\n", errstr); + ret = False; + } 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_NO_MAPPING) { + printf("DsCrackNames incorrect error on name - %d\n", r.out.ctr.ctr1->array[0].status); + ret = False; + } + + if (!ret) { + return ret; + } + + /* NEGATIVE tests. This should parse, but not succeed */ r.in.req.req1.format_offered = DRSUAPI_DS_NAME_FORMAT_USER_PRINCIPAL; r.in.req.req1.format_desired = DRSUAPI_DS_NAME_FORMAT_FQDN_1779; @@ -1662,7 +1721,7 @@ BOOL torture_rpc_drsuapi(void) ret &= test_DsGetDCInfo(p, mem_ctx, &priv); - ret &= test_DsCrackNames(p, mem_ctx, &priv); + ret &= test_DsCrackNames(p, mem_ctx, &priv, priv.dcinfo.netbios_name); ret &= test_DsWriteAccountSpn(p, mem_ctx, &priv); @@ -1707,9 +1766,7 @@ BOOL torture_rpc_drsuapi_cracknames(void) ret &= test_DsBind(p, mem_ctx, &priv); - ret &= test_DsGetDCInfo(p, mem_ctx, &priv); - - ret &= test_DsCrackNames(p, mem_ctx, &priv); + ret &= test_DsCrackNames(p, mem_ctx, &priv, lp_parm_string(-1, "torture", "host")); ret &= test_DsUnbind(p, mem_ctx, &priv); -- cgit From f1b39f9b809ce767ddf16bb6b596649441f28f47 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Tue, 20 Sep 2005 09:57:30 +0000 Subject: r10345: Add more add-hock tests. Andrew Bartlett (This used to be commit e05e87b3fe1dae058e2a3588578d09ea1cfd2142) --- source4/torture/rpc/drsuapi.c | 107 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 107 insertions(+) (limited to 'source4/torture/rpc/drsuapi.c') diff --git a/source4/torture/rpc/drsuapi.c b/source4/torture/rpc/drsuapi.c index 078b03710a..100b3c903a 100644 --- a/source4/torture/rpc/drsuapi.c +++ b/source4/torture/rpc/drsuapi.c @@ -318,6 +318,30 @@ static BOOL test_DsCrackNames(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, 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; + + printf("testing DsCrackNames with name '%s' desired format:%d\n", + names[0].str, r.in.req.req1.format_desired); + + status = dcerpc_drsuapi_DsCrackNames(p, mem_ctx, &r); + if (!NT_STATUS_IS_OK(status)) { + const char *errstr = nt_errstr(status); + if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { + errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); + } + printf("dcerpc_drsuapi_DsCrackNames failed - %s\n", errstr); + ret = False; + } 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); + ret = False; + } + + if (!ret) { + return ret; + } r.in.req.req1.format_offered = DRSUAPI_DS_NAME_FORMAT_GUID; r.in.req.req1.format_desired = DRSUAPI_DS_NAME_FORMAT_NT4_ACCOUNT; @@ -502,6 +526,33 @@ static BOOL test_DsCrackNames(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, return False; } + r.in.req.req1.format_offered = DRSUAPI_DS_NAME_FORMAT_SERVICE_PRINCIPAL; + r.in.req.req1.format_desired = DRSUAPI_DS_NAME_FORMAT_FQDN_1779; + names[0].str = talloc_asprintf(mem_ctx, "krbtgt/%s", dns_domain); + + printf("testing DsCrackNames with name '%s' desired format:%d\n", + names[0].str, r.in.req.req1.format_desired); + + status = dcerpc_drsuapi_DsCrackNames(p, mem_ctx, &r); + if (!NT_STATUS_IS_OK(status)) { + const char *errstr = nt_errstr(status); + if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { + errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); + } + printf("dcerpc_drsuapi_DsCrackNames failed - %s\n", errstr); + ret = False; + } 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_DOMAIN_ONLY) { + printf("DsCrackNames failed on name - %d\n", r.out.ctr.ctr1->array[0].status); + ret = False; + } + + if (!ret) { + return ret; + } + r.in.req.req1.format_offered = DRSUAPI_DS_NAME_FORMAT_FQDN_1779; r.in.req.req1.format_desired = DRSUAPI_DS_NAME_FORMAT_CANONICAL; names[0].str = FQDN_1779_name; @@ -714,6 +765,62 @@ static BOOL test_DsCrackNames(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, } + /* NEGATIVE tests. This should parse, but not succeed */ + r.in.req.req1.format_offered = DRSUAPI_DS_NAME_FORMAT_SERVICE_PRINCIPAL; + r.in.req.req1.format_desired = DRSUAPI_DS_NAME_FORMAT_FQDN_1779; + names[0].str = talloc_asprintf(mem_ctx, "krbtgt/%s", dns_domain); + + printf("testing DsCrackNames with name '%s' desired format:%d\n", + names[0].str, r.in.req.req1.format_desired); + + status = dcerpc_drsuapi_DsCrackNames(p, mem_ctx, &r); + if (!NT_STATUS_IS_OK(status)) { + const char *errstr = nt_errstr(status); + if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { + errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); + } + printf("dcerpc_drsuapi_DsCrackNames failed - %s\n", errstr); + ret = False; + } 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_DOMAIN_ONLY) { + printf("DsCrackNames incorrect error on name - %d\n", r.out.ctr.ctr1->array[0].status); + ret = False; + } + + if (!ret) { + return ret; + } + + /* NEGATIVE tests. This should parse, but not succeed */ + r.in.req.req1.format_offered = DRSUAPI_DS_NAME_FORMAT_SERVICE_PRINCIPAL; + r.in.req.req1.format_desired = DRSUAPI_DS_NAME_FORMAT_FQDN_1779; + names[0].str = talloc_asprintf(mem_ctx, "krbtgt"); + + printf("testing DsCrackNames with name '%s' desired format:%d\n", + names[0].str, r.in.req.req1.format_desired); + + status = dcerpc_drsuapi_DsCrackNames(p, mem_ctx, &r); + if (!NT_STATUS_IS_OK(status)) { + const char *errstr = nt_errstr(status); + if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { + errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); + } + printf("dcerpc_drsuapi_DsCrackNames failed - %s\n", errstr); + ret = False; + } 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_NOT_FOUND) { + printf("DsCrackNames incorrect error on name - %d\n", r.out.ctr.ctr1->array[0].status); + ret = False; + } + + if (!ret) { + return ret; + } + /* NEGATIVE tests. This should parse, but not succeed */ r.in.req.req1.format_offered = DRSUAPI_DS_NAME_FORMAT_SERVICE_PRINCIPAL; r.in.req.req1.format_desired = DRSUAPI_DS_NAME_FORMAT_FQDN_1779; -- cgit From c6e683cc233681332361cde5c8354be0041c377f Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Fri, 7 Oct 2005 06:25:45 +0000 Subject: r10803: Remove a duplicate krbtgt test, and add a test looking for the 'support account'. This shows that we need to be searching on displayName, and probably CN too. Andrew Bartlett (This used to be commit 28194504951af22a76cf26f3de749cb448518bbc) --- source4/torture/rpc/drsuapi.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'source4/torture/rpc/drsuapi.c') diff --git a/source4/torture/rpc/drsuapi.c b/source4/torture/rpc/drsuapi.c index 100b3c903a..f6c23a4678 100644 --- a/source4/torture/rpc/drsuapi.c +++ b/source4/torture/rpc/drsuapi.c @@ -526,9 +526,9 @@ static BOOL test_DsCrackNames(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, return False; } - r.in.req.req1.format_offered = DRSUAPI_DS_NAME_FORMAT_SERVICE_PRINCIPAL; - r.in.req.req1.format_desired = DRSUAPI_DS_NAME_FORMAT_FQDN_1779; - names[0].str = talloc_asprintf(mem_ctx, "krbtgt/%s", dns_domain); + r.in.req.req1.format_offered = DRSUAPI_DS_NAME_FORMAT_FQDN_1779; + r.in.req.req1.format_desired = DRSUAPI_DS_NAME_FORMAT_CANONICAL; + names[0].str = FQDN_1779_name; printf("testing DsCrackNames with name '%s' desired format:%d\n", names[0].str, r.in.req.req1.format_desired); @@ -544,7 +544,7 @@ static BOOL test_DsCrackNames(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, } 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_DOMAIN_ONLY) { + } 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; } @@ -553,9 +553,7 @@ static BOOL test_DsCrackNames(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, return ret; } - r.in.req.req1.format_offered = DRSUAPI_DS_NAME_FORMAT_FQDN_1779; - r.in.req.req1.format_desired = DRSUAPI_DS_NAME_FORMAT_CANONICAL; - names[0].str = FQDN_1779_name; + r.in.req.req1.format_desired = DRSUAPI_DS_NAME_FORMAT_DISPLAY; printf("testing DsCrackNames with name '%s' desired format:%d\n", names[0].str, r.in.req.req1.format_desired); @@ -580,7 +578,7 @@ static BOOL test_DsCrackNames(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, return ret; } - r.in.req.req1.format_desired = DRSUAPI_DS_NAME_FORMAT_DISPLAY; + 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); @@ -605,9 +603,11 @@ static BOOL test_DsCrackNames(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, return ret; } - r.in.req.req1.format_desired = DRSUAPI_DS_NAME_FORMAT_GUID; + r.in.req.req1.format_offered = DRSUAPI_DS_NAME_FORMAT_DISPLAY; + r.in.req.req1.format_desired = DRSUAPI_DS_NAME_FORMAT_FQDN_1779; + names[0].str = "CN=Microsoft Corporation,L=Redmond,S=Washington,C=US"; - printf("testing DsCrackNames with name '%s' desired format:%d\n", + printf("testing DsCrackNames with DISPAY NAME '%s' desired format:%d\n", names[0].str, r.in.req.req1.format_desired); status = dcerpc_drsuapi_DsCrackNames(p, mem_ctx, &r); -- cgit From 89a63bf14bce4511a3ccdf90459240c262cc0374 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Fri, 7 Oct 2005 08:12:05 +0000 Subject: r10804: Move the DRSUAPI cracknames test into a seperate file, and collapse the file size by converting it to a table-driven system. Andrew Bartlett (This used to be commit f5499877722d6c4636036325efb75d35aa853cc4) --- source4/torture/rpc/drsuapi.c | 1280 ++--------------------------------------- 1 file changed, 32 insertions(+), 1248 deletions(-) (limited to 'source4/torture/rpc/drsuapi.c') diff --git a/source4/torture/rpc/drsuapi.c b/source4/torture/rpc/drsuapi.c index f6c23a4678..8f772f1861 100644 --- a/source4/torture/rpc/drsuapi.c +++ b/source4/torture/rpc/drsuapi.c @@ -5,1237 +5,55 @@ Copyright (C) Andrew Tridgell 2003 Copyright (C) Stefan (metze) Metzmacher 2004 - - 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 2 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, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*/ - -#include "includes.h" -#include "librpc/gen_ndr/ndr_drsuapi.h" - -struct DsPrivate { - struct policy_handle bind_handle; - struct GUID bind_guid; - const char *domain_obj_dn; - const char *domain_guid_str; - const char *domain_dns_name; - struct GUID domain_guid; - struct drsuapi_DsGetDCInfo2 dcinfo; -}; - -static BOOL test_DsBind(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, - struct DsPrivate *priv) -{ - NTSTATUS status; - struct drsuapi_DsBind r; - BOOL ret = True; - - GUID_from_string(DRSUAPI_DS_BIND_GUID, &priv->bind_guid); - - r.in.bind_guid = &priv->bind_guid; - r.in.bind_info = NULL; - r.out.bind_handle = &priv->bind_handle; - - printf("testing DsBind\n"); - - status = dcerpc_drsuapi_DsBind(p, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - const char *errstr = nt_errstr(status); - if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { - errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); - } - printf("dcerpc_drsuapi_DsBind failed - %s\n", errstr); - ret = False; - } else if (!W_ERROR_IS_OK(r.out.result)) { - printf("DsBind failed - %s\n", win_errstr(r.out.result)); - ret = False; - } - - return ret; -} - -static BOOL test_DsCrackNamesMatrix(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, - struct DsPrivate *priv, const char *dn, - const char *user_principal_name, const char *service_principal_name) -{ - - - NTSTATUS status; - BOOL ret = True; - struct drsuapi_DsCrackNames r; - struct drsuapi_DsNameString names[1]; - enum drsuapi_DsNameFormat formats[] = { - DRSUAPI_DS_NAME_FORMAT_FQDN_1779, - DRSUAPI_DS_NAME_FORMAT_NT4_ACCOUNT, - DRSUAPI_DS_NAME_FORMAT_DISPLAY, - DRSUAPI_DS_NAME_FORMAT_GUID, - DRSUAPI_DS_NAME_FORMAT_CANONICAL, - DRSUAPI_DS_NAME_FORMAT_USER_PRINCIPAL, - DRSUAPI_DS_NAME_FORMAT_CANONICAL_EX, - DRSUAPI_DS_NAME_FORMAT_SERVICE_PRINCIPAL, - DRSUAPI_DS_NAME_FORMAT_SID_OR_SID_HISTORY, - DRSUAPI_DS_NAME_FORMAT_DNS_DOMAIN - }; - int i, j; - - const char *n_matrix[ARRAY_SIZE(formats)][ARRAY_SIZE(formats)]; - const char *n_from[ARRAY_SIZE(formats)]; - - ZERO_STRUCT(r); - r.in.bind_handle = &priv->bind_handle; - r.in.level = 1; - r.in.req.req1.unknown1 = 0x000004e4; - r.in.req.req1.unknown2 = 0x00000407; - r.in.req.req1.count = 1; - r.in.req.req1.names = names; - r.in.req.req1.format_flags = DRSUAPI_DS_NAME_FLAG_NO_FLAGS; - - 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]; - names[0].str = dn; - 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); - - status = dcerpc_drsuapi_DsCrackNames(p, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - const char *errstr = nt_errstr(status); - if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { - errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); - } - printf("dcerpc_drsuapi_DsCrackNames failed - %s\n", errstr); - ret = False; - } else if (!W_ERROR_IS_OK(r.out.result)) { - printf("DsCrackNames failed - %s\n", win_errstr(r.out.result)); - ret = False; - } - - if (!ret) { - return ret; - } - switch (formats[i]) { - case DRSUAPI_DS_NAME_FORMAT_SERVICE_PRINCIPAL: - 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); - 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) { - printf(__location__ ": Unexpected error (%d): This name lookup should fail\n", - 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) { - printf(__location__ ": Unexpected error (%d): This name lookup should fail\n", - 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); - return False; - } - } - - switch (formats[i]) { - case DRSUAPI_DS_NAME_FORMAT_USER_PRINCIPAL: - n_from[i] = user_principal_name; - break; - case DRSUAPI_DS_NAME_FORMAT_SERVICE_PRINCIPAL: - n_from[i] = service_principal_name; - break; - case DRSUAPI_DS_NAME_FORMAT_SID_OR_SID_HISTORY: - case DRSUAPI_DS_NAME_FORMAT_DNS_DOMAIN: - n_from[i] = NULL; - break; - default: - 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]; - if (!n_from[i]) { - n_matrix[i][j] = NULL; - continue; - } - names[0].str = n_from[i]; - status = dcerpc_drsuapi_DsCrackNames(p, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - const char *errstr = nt_errstr(status); - if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { - 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); - 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, - win_errstr(r.out.result)); - ret = False; - } - - 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; - } else { - n_matrix[i][j] = NULL; - } - } - } - - for (i = 0; i < ARRAY_SIZE(formats); i++) { - for (j = 0; j < ARRAY_SIZE(formats); j++) { - if (n_matrix[i][j] == n_from[j]) { - - /* We don't have a from name for these yet (and we can't map to them to find it out) */ - } else if (n_matrix[i][j] == NULL && n_from[i] == NULL) { - - /* we can't map to these two */ - } else if (n_matrix[i][j] == NULL && formats[j] == DRSUAPI_DS_NAME_FORMAT_USER_PRINCIPAL) { - } else if (n_matrix[i][j] == NULL && formats[j] == DRSUAPI_DS_NAME_FORMAT_SERVICE_PRINCIPAL) { - } else if (n_matrix[i][j] == NULL && n_from[j] != NULL) { - printf("dcerpc_drsuapi_DsCrackNames mismatch - from %d to %d: %s should be %s\n", formats[i], formats[j], n_matrix[i][j], n_from[j]); - ret = False; - } else if (n_matrix[i][j] != NULL && n_from[j] == NULL) { - printf("dcerpc_drsuapi_DsCrackNames mismatch - from %d to %d: %s should be %s\n", formats[i], formats[j], n_matrix[i][j], n_from[j]); - ret = False; - } else if (strcmp(n_matrix[i][j], n_from[j]) != 0) { - printf("dcerpc_drsuapi_DsCrackNames mismatch - from %d to %d: %s should be %s\n", formats[i], formats[j], n_matrix[i][j], n_from[j]); - ret = False; - } - } - } - return ret; -} - -static BOOL test_DsCrackNames(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, - struct DsPrivate *priv, const char *test_dc) -{ - NTSTATUS status; - struct drsuapi_DsCrackNames r; - struct drsuapi_DsNameString names[1]; - BOOL ret = True; - const char *dns_domain; - const char *nt4_domain; - const char *FQDN_1779_name; - const char *user_principal_name; - const char *service_principal_name; - - ZERO_STRUCT(r); - r.in.bind_handle = &priv->bind_handle; - r.in.level = 1; - r.in.req.req1.unknown1 = 0x000004e4; - r.in.req.req1.unknown2 = 0x00000407; - 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_CANONICAL; - r.in.req.req1.format_desired = DRSUAPI_DS_NAME_FORMAT_NT4_ACCOUNT; - names[0].str = talloc_asprintf(mem_ctx, "%s/", lp_realm()); - - printf("testing DsCrackNames with name '%s' desired format:%d\n", - names[0].str, r.in.req.req1.format_desired); - - status = dcerpc_drsuapi_DsCrackNames(p, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - const char *errstr = nt_errstr(status); - if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { - errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); - } - printf("dcerpc_drsuapi_DsCrackNames failed - %s\n", errstr); - ret = False; - } 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); - ret = False; - } - - if (!ret) { - return ret; - } - - 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; - - printf("testing DsCrackNames with name '%s' desired format:%d\n", - names[0].str, r.in.req.req1.format_desired); - - status = dcerpc_drsuapi_DsCrackNames(p, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - const char *errstr = nt_errstr(status); - if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { - errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); - } - printf("dcerpc_drsuapi_DsCrackNames failed - %s\n", errstr); - ret = False; - } 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); - ret = False; - } - - if (!ret) { - 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; - GUID_from_string(priv->domain_guid_str, &priv->domain_guid); - - 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); - - status = dcerpc_drsuapi_DsCrackNames(p, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - const char *errstr = nt_errstr(status); - if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { - errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); - } - printf("dcerpc_drsuapi_DsCrackNames failed - %s\n", errstr); - ret = False; - } 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); - ret = False; - } - - if (!ret) { - return ret; - } - - r.in.req.req1.format_offered = DRSUAPI_DS_NAME_FORMAT_GUID; - r.in.req.req1.format_desired = DRSUAPI_DS_NAME_FORMAT_NT4_ACCOUNT; - names[0].str = priv->domain_guid_str; - - printf("testing DsCrackNames with GUID '%s' desired format:%d\n", - names[0].str, r.in.req.req1.format_desired); - - status = dcerpc_drsuapi_DsCrackNames(p, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - const char *errstr = nt_errstr(status); - if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { - errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); - } - printf("dcerpc_drsuapi_DsCrackNames failed - %s\n", errstr); - ret = False; - } 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); - ret = False; - } - - if (!ret) { - return ret; - } - - 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); - - status = dcerpc_drsuapi_DsCrackNames(p, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - const char *errstr = nt_errstr(status); - if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { - errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); - } - printf("dcerpc_drsuapi_DsCrackNames failed - %s\n", errstr); - ret = False; - } 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); - ret = False; - } - - if (!ret) { - return ret; - } - - 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; - 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); - - status = dcerpc_drsuapi_DsCrackNames(p, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - const char *errstr = nt_errstr(status); - if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { - errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); - } - printf("dcerpc_drsuapi_DsCrackNames failed - %s\n", errstr); - ret = False; - } 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); - ret = False; - } - - if (!ret) { - return ret; - } - - FQDN_1779_name = r.out.ctr.ctr1->array[0].result_name; - - r.in.req.req1.format_offered = DRSUAPI_DS_NAME_FORMAT_USER_PRINCIPAL; - r.in.req.req1.format_desired = DRSUAPI_DS_NAME_FORMAT_FQDN_1779; - names[0].str = talloc_asprintf(mem_ctx, "%s$@%s", test_dc, dns_domain); - user_principal_name = names[0].str; - - printf("testing DsCrackNames with name '%s' desired format:%d\n", - names[0].str, r.in.req.req1.format_desired); - - status = dcerpc_drsuapi_DsCrackNames(p, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - const char *errstr = nt_errstr(status); - if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { - errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); - } - printf("dcerpc_drsuapi_DsCrackNames failed - %s\n", errstr); - ret = False; - } 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); - ret = False; - } - - if (!ret) { - return ret; - } - - if (strcmp(r.out.ctr.ctr1->array[0].result_name, FQDN_1779_name) != 0) { - printf("DsCrackNames failed - %s != %s\n", r.out.ctr.ctr1->array[0].result_name, FQDN_1779_name); - return False; - } - - r.in.req.req1.format_offered = DRSUAPI_DS_NAME_FORMAT_SERVICE_PRINCIPAL; - r.in.req.req1.format_desired = DRSUAPI_DS_NAME_FORMAT_FQDN_1779; - names[0].str = talloc_asprintf(mem_ctx, "HOST/%s", test_dc); - service_principal_name = names[0].str; - - printf("testing DsCrackNames with name '%s' desired format:%d\n", - names[0].str, r.in.req.req1.format_desired); - - status = dcerpc_drsuapi_DsCrackNames(p, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - const char *errstr = nt_errstr(status); - if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { - errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); - } - printf("dcerpc_drsuapi_DsCrackNames failed - %s\n", errstr); - ret = False; - } 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); - ret = False; - } - - if (!ret) { - return ret; - } - - if (strcmp(r.out.ctr.ctr1->array[0].result_name, FQDN_1779_name) != 0) { - printf("DsCrackNames failed - %s != %s\n", r.out.ctr.ctr1->array[0].result_name, FQDN_1779_name); - return False; - } - - r.in.req.req1.format_offered = DRSUAPI_DS_NAME_FORMAT_SERVICE_PRINCIPAL; - r.in.req.req1.format_desired = DRSUAPI_DS_NAME_FORMAT_FQDN_1779; - names[0].str = talloc_asprintf(mem_ctx, "cifs/%s.%s", test_dc, dns_domain); - - printf("testing DsCrackNames with name '%s' desired format:%d\n", - names[0].str, r.in.req.req1.format_desired); - - status = dcerpc_drsuapi_DsCrackNames(p, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - const char *errstr = nt_errstr(status); - if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { - errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); - } - printf("dcerpc_drsuapi_DsCrackNames failed - %s\n", errstr); - ret = False; - } 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); - ret = False; - } - - if (!ret) { - return ret; - } - - if (strcmp(r.out.ctr.ctr1->array[0].result_name, FQDN_1779_name) != 0) { - printf("DsCrackNames failed - %s != %s\n", r.out.ctr.ctr1->array[0].result_name, FQDN_1779_name); - return False; - } - - r.in.req.req1.format_offered = DRSUAPI_DS_NAME_FORMAT_FQDN_1779; - r.in.req.req1.format_desired = DRSUAPI_DS_NAME_FORMAT_CANONICAL; - names[0].str = FQDN_1779_name; - - printf("testing DsCrackNames with name '%s' desired format:%d\n", - names[0].str, r.in.req.req1.format_desired); - - status = dcerpc_drsuapi_DsCrackNames(p, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - const char *errstr = nt_errstr(status); - if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { - errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); - } - printf("dcerpc_drsuapi_DsCrackNames failed - %s\n", errstr); - ret = False; - } 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); - ret = False; - } - - if (!ret) { - return ret; - } - - r.in.req.req1.format_desired = DRSUAPI_DS_NAME_FORMAT_DISPLAY; - - printf("testing DsCrackNames with name '%s' desired format:%d\n", - names[0].str, r.in.req.req1.format_desired); - - status = dcerpc_drsuapi_DsCrackNames(p, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - const char *errstr = nt_errstr(status); - if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { - errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); - } - printf("dcerpc_drsuapi_DsCrackNames failed - %s\n", errstr); - ret = False; - } 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); - ret = False; - } - - if (!ret) { - return ret; - } - - 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); - - status = dcerpc_drsuapi_DsCrackNames(p, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - const char *errstr = nt_errstr(status); - if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { - errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); - } - printf("dcerpc_drsuapi_DsCrackNames failed - %s\n", errstr); - ret = False; - } 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); - ret = False; - } - - if (!ret) { - return ret; - } - - r.in.req.req1.format_offered = DRSUAPI_DS_NAME_FORMAT_DISPLAY; - r.in.req.req1.format_desired = DRSUAPI_DS_NAME_FORMAT_FQDN_1779; - names[0].str = "CN=Microsoft Corporation,L=Redmond,S=Washington,C=US"; - - printf("testing DsCrackNames with DISPAY NAME '%s' desired format:%d\n", - names[0].str, r.in.req.req1.format_desired); - - status = dcerpc_drsuapi_DsCrackNames(p, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - const char *errstr = nt_errstr(status); - if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { - errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); - } - printf("dcerpc_drsuapi_DsCrackNames failed - %s\n", errstr); - ret = False; - } 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); - ret = False; - } - - if (!ret) { - return ret; - } - - 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 = GUID_string2(mem_ctx, &priv->dcinfo.site_guid); - - printf("testing DsCrackNames with Site GUID '%s' desired format:%d\n", - names[0].str, r.in.req.req1.format_desired); - - status = dcerpc_drsuapi_DsCrackNames(p, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - const char *errstr = nt_errstr(status); - if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { - errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); - } - printf("dcerpc_drsuapi_DsCrackNames failed - %s\n", errstr); - ret = False; - } 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); - ret = False; - } - - if (!ret) { - return ret; - } - - r.in.req.req1.format_desired = DRSUAPI_DS_NAME_FORMAT_NT4_ACCOUNT; - names[0].str = GUID_string2(mem_ctx, &priv->dcinfo.computer_guid); - - printf("testing DsCrackNames with Computer GUID '%s' desired format:%d\n", - names[0].str, r.in.req.req1.format_desired); - - status = dcerpc_drsuapi_DsCrackNames(p, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - const char *errstr = nt_errstr(status); - if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { - errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); - } - printf("dcerpc_drsuapi_DsCrackNames failed - %s\n", errstr); - ret = False; - } 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); - ret = False; - } - - if (!ret) { - return ret; - } - - 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 = GUID_string2(mem_ctx, &priv->dcinfo.server_guid); - - printf("testing DsCrackNames with Server GUID '%s' desired format:%d\n", - names[0].str, r.in.req.req1.format_desired); - - status = dcerpc_drsuapi_DsCrackNames(p, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - const char *errstr = nt_errstr(status); - if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { - errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); - } - printf("dcerpc_drsuapi_DsCrackNames failed - %s\n", errstr); - ret = False; - } 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); - ret = False; - } - - if (!ret) { - return ret; - } - - 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 = GUID_string2(mem_ctx, &priv->dcinfo.ntds_guid); - - printf("testing DsCrackNames with NTDS GUID '%s' desired format:%d\n", - names[0].str, r.in.req.req1.format_desired); - - status = dcerpc_drsuapi_DsCrackNames(p, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - const char *errstr = nt_errstr(status); - if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { - errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); - } - printf("dcerpc_drsuapi_DsCrackNames failed - %s\n", errstr); - ret = False; - } 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); - ret = False; - } - - if (!ret) { - return ret; - } - - r.in.req.req1.format_offered = DRSUAPI_DS_NAME_FORMAT_SID_OR_SID_HISTORY; - r.in.req.req1.format_desired = DRSUAPI_DS_NAME_FORMAT_FQDN_1779; - names[0].str = SID_BUILTIN; - - printf("testing DsCrackNames with SID '%s' desired format:%d\n", - names[0].str, r.in.req.req1.format_desired); - - status = dcerpc_drsuapi_DsCrackNames(p, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - const char *errstr = nt_errstr(status); - if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { - errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); - } - printf("dcerpc_drsuapi_DsCrackNames failed - %s\n", errstr); - ret = False; - } 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); - ret = False; - } - - if (!ret) { - return ret; - } - - - /* NEGATIVE tests. This should parse, but not succeed */ - r.in.req.req1.format_offered = DRSUAPI_DS_NAME_FORMAT_SERVICE_PRINCIPAL; - r.in.req.req1.format_desired = DRSUAPI_DS_NAME_FORMAT_FQDN_1779; - names[0].str = talloc_asprintf(mem_ctx, "krbtgt/%s", dns_domain); - - printf("testing DsCrackNames with name '%s' desired format:%d\n", - names[0].str, r.in.req.req1.format_desired); - - status = dcerpc_drsuapi_DsCrackNames(p, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - const char *errstr = nt_errstr(status); - if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { - errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); - } - printf("dcerpc_drsuapi_DsCrackNames failed - %s\n", errstr); - ret = False; - } 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_DOMAIN_ONLY) { - printf("DsCrackNames incorrect error on name - %d\n", r.out.ctr.ctr1->array[0].status); - ret = False; - } - - if (!ret) { - return ret; - } - - /* NEGATIVE tests. This should parse, but not succeed */ - r.in.req.req1.format_offered = DRSUAPI_DS_NAME_FORMAT_SERVICE_PRINCIPAL; - r.in.req.req1.format_desired = DRSUAPI_DS_NAME_FORMAT_FQDN_1779; - names[0].str = talloc_asprintf(mem_ctx, "krbtgt"); - - printf("testing DsCrackNames with name '%s' desired format:%d\n", - names[0].str, r.in.req.req1.format_desired); - - status = dcerpc_drsuapi_DsCrackNames(p, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - const char *errstr = nt_errstr(status); - if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { - errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); - } - printf("dcerpc_drsuapi_DsCrackNames failed - %s\n", errstr); - ret = False; - } 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_NOT_FOUND) { - printf("DsCrackNames incorrect error on name - %d\n", r.out.ctr.ctr1->array[0].status); - ret = False; - } - - if (!ret) { - return ret; - } - - /* NEGATIVE tests. This should parse, but not succeed */ - r.in.req.req1.format_offered = DRSUAPI_DS_NAME_FORMAT_SERVICE_PRINCIPAL; - r.in.req.req1.format_desired = DRSUAPI_DS_NAME_FORMAT_FQDN_1779; - names[0].str = talloc_asprintf(mem_ctx, "cifs/%s.%s@%s", - test_dc, dns_domain, - dns_domain); - - printf("testing DsCrackNames with Service Principal '%s' desired format:%d\n", - names[0].str, r.in.req.req1.format_desired); - - status = dcerpc_drsuapi_DsCrackNames(p, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - const char *errstr = nt_errstr(status); - if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { - errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); - } - printf("dcerpc_drsuapi_DsCrackNames failed - %s\n", errstr); - ret = False; - } 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_DOMAIN_ONLY) { - printf("DsCrackNames incorrect error on name - %d\n", r.out.ctr.ctr1->array[0].status); - ret = False; - } - - if (!ret) { - return ret; - } + Copyright (C) Andrew Bartlett 2005 - /* NEGATIVE tests. This should parse, but not succeed */ - 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 = "NOT A GUID"; - - printf("testing DsCrackNames with GUID '%s' desired format:%d\n", - names[0].str, r.in.req.req1.format_desired); - - status = dcerpc_drsuapi_DsCrackNames(p, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - const char *errstr = nt_errstr(status); - if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { - errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); - } - printf("dcerpc_drsuapi_DsCrackNames failed - %s\n", errstr); - ret = False; - } 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_NOT_FOUND) { - printf("DsCrackNames incorrect error on name - %d\n", r.out.ctr.ctr1->array[0].status); - ret = False; - } - - if (!ret) { - return ret; - } - - /* NEGATIVE tests. This should parse, but not succeed */ - r.in.req.req1.format_offered = DRSUAPI_DS_NAME_FORMAT_SID_OR_SID_HISTORY; - r.in.req.req1.format_desired = DRSUAPI_DS_NAME_FORMAT_FQDN_1779; - names[0].str = "NOT A SID"; - - printf("testing DsCrackNames with SID '%s' desired format:%d\n", - names[0].str, r.in.req.req1.format_desired); - - status = dcerpc_drsuapi_DsCrackNames(p, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - const char *errstr = nt_errstr(status); - if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { - errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); - } - printf("dcerpc_drsuapi_DsCrackNames failed - %s\n", errstr); - ret = False; - } 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_NOT_FOUND) { - printf("DsCrackNames incorrect error on name - %d\n", r.out.ctr.ctr1->array[0].status); - ret = False; - } - - if (!ret) { - return ret; - } - - /* NEGATIVE tests. This should parse, but not succeed */ - 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 = "NOT AN NT4 NAME"; - - printf("testing DsCrackNames with NT4 Name '%s' desired format:%d\n", - names[0].str, r.in.req.req1.format_desired); - - status = dcerpc_drsuapi_DsCrackNames(p, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - const char *errstr = nt_errstr(status); - if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { - errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); - } - printf("dcerpc_drsuapi_DsCrackNames failed - %s\n", errstr); - ret = False; - } 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_NOT_FOUND) { - printf("DsCrackNames incorrect error on name - %d\n", r.out.ctr.ctr1->array[0].status); - ret = False; - } - - if (!ret) { - return ret; - } - - /* NEGATIVE tests. This should parse, but not succeed */ - r.in.req.req1.format_offered = DRSUAPI_DS_NAME_FORMAT_FQDN_1779; - r.in.req.req1.format_desired = DRSUAPI_DS_NAME_FORMAT_GUID; - names[0].str = "NOT A DN"; - - printf("testing DsCrackNames with DN '%s' desired format:%d\n", - names[0].str, r.in.req.req1.format_desired); - - status = dcerpc_drsuapi_DsCrackNames(p, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - const char *errstr = nt_errstr(status); - if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { - errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); - } - printf("dcerpc_drsuapi_DsCrackNames failed - %s\n", errstr); - ret = False; - } 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_NOT_FOUND) { - printf("DsCrackNames incorrect error on name - %d\n", r.out.ctr.ctr1->array[0].status); - ret = False; - } - - if (!ret) { - return ret; - } - - /* NEGATIVE tests. This should parse, but not succeed */ - r.in.req.req1.format_offered = DRSUAPI_DS_NAME_FORMAT_USER_PRINCIPAL; - r.in.req.req1.format_desired = DRSUAPI_DS_NAME_FORMAT_FQDN_1779; - names[0].str = "NOT A PRINCIPAL"; - - printf("testing DsCrackNames with user principal '%s' desired format:%d\n", - names[0].str, r.in.req.req1.format_desired); - - status = dcerpc_drsuapi_DsCrackNames(p, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - const char *errstr = nt_errstr(status); - if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { - errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); - } - printf("dcerpc_drsuapi_DsCrackNames failed - %s\n", errstr); - ret = False; - } 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_NOT_FOUND) { - printf("DsCrackNames incorrect error on name - %d\n", r.out.ctr.ctr1->array[0].status); - ret = False; - } - - if (!ret) { - return ret; - } - - /* NEGATIVE tests. This should parse, but not succeed */ - r.in.req.req1.format_offered = DRSUAPI_DS_NAME_FORMAT_SERVICE_PRINCIPAL; - r.in.req.req1.format_desired = DRSUAPI_DS_NAME_FORMAT_FQDN_1779; - names[0].str = "NOT A SERVICE PRINCIPAL"; - - printf("testing DsCrackNames with service principal '%s' desired format:%d\n", - names[0].str, r.in.req.req1.format_desired); - - status = dcerpc_drsuapi_DsCrackNames(p, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - const char *errstr = nt_errstr(status); - if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { - errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); - } - printf("dcerpc_drsuapi_DsCrackNames failed - %s\n", errstr); - ret = False; - } 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_NOT_FOUND) { - printf("DsCrackNames incorrect error on name - %d\n", r.out.ctr.ctr1->array[0].status); - ret = False; - } - - if (!ret) { - return ret; - } - - /* NEGATIVE tests. This should parse, but not succeed */ - 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 = GUID_string2(mem_ctx, &priv->bind_guid); - - printf("testing DsCrackNames with BIND GUID '%s' desired format:%d\n", - names[0].str, r.in.req.req1.format_desired); - - status = dcerpc_drsuapi_DsCrackNames(p, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - const char *errstr = nt_errstr(status); - if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { - errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); - } - printf("dcerpc_drsuapi_DsCrackNames failed - %s\n", errstr); - ret = False; - } 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_NOT_FOUND) { - printf("DsCrackNames incorrect error on name - %d\n", r.out.ctr.ctr1->array[0].status); - ret = False; - } - - /* NEGATIVE tests. This should parse, but not succeed */ - r.in.req.req1.format_offered = DRSUAPI_DS_NAME_FORMAT_USER_PRINCIPAL; - r.in.req.req1.format_desired = DRSUAPI_DS_NAME_FORMAT_FQDN_1779; - names[0].str = talloc_asprintf(mem_ctx, "%s$", test_dc); - - printf("testing DsCrackNames with user principal name '%s' desired format:%d\n", - names[0].str, r.in.req.req1.format_desired); - - status = dcerpc_drsuapi_DsCrackNames(p, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - const char *errstr = nt_errstr(status); - if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { - errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); - } - printf("dcerpc_drsuapi_DsCrackNames failed - %s\n", errstr); - ret = False; - } 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_NOT_FOUND) { - printf("DsCrackNames incorrect error on name - %d\n", r.out.ctr.ctr1->array[0].status); - ret = False; - } - - /* NEGATIVE tests. This should parse, but not succeed */ - r.in.req.req1.format_offered = DRSUAPI_DS_NAME_FORMAT_SERVICE_PRINCIPAL; - r.in.req.req1.format_desired = DRSUAPI_DS_NAME_FORMAT_FQDN_1779; - names[0].str = talloc_asprintf(mem_ctx, "%s$", test_dc); - - printf("testing DsCrackNames with service principal name '%s' desired format:%d\n", - names[0].str, r.in.req.req1.format_desired); - - status = dcerpc_drsuapi_DsCrackNames(p, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - const char *errstr = nt_errstr(status); - if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { - errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); - } - printf("dcerpc_drsuapi_DsCrackNames failed - %s\n", errstr); - ret = False; - } 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_NOT_FOUND) { - printf("DsCrackNames incorrect error on name - %d\n", r.out.ctr.ctr1->array[0].status); - ret = False; - } - - - if (!ret) { - return ret; - } - - /* NEGATIVE tests. This should parse, but not succeed */ - 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\\", lp_realm()); - - printf("testing DsCrackNames with name '%s' desired format:%d\n", - names[0].str, r.in.req.req1.format_desired); - - status = dcerpc_drsuapi_DsCrackNames(p, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - const char *errstr = nt_errstr(status); - if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { - errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); - } - printf("dcerpc_drsuapi_DsCrackNames failed - %s\n", errstr); - ret = False; - } 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_NOT_FOUND) { - printf("DsCrackNames incorrect error on name - %d\n", r.out.ctr.ctr1->array[0].status); - ret = False; - } - - if (!ret) { - return ret; - } - - 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; - names[0].str = SID_BUILTIN; - - printf("testing DsCrackNames with SID '%s' desired format:%d\n", - names[0].str, r.in.req.req1.format_desired); - - status = dcerpc_drsuapi_DsCrackNames(p, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - const char *errstr = nt_errstr(status); - if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { - errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); - } - printf("dcerpc_drsuapi_DsCrackNames failed - %s\n", errstr); - ret = False; - } 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); - ret = False; - } - - if (!ret) { - return ret; - } - - - r.in.req.req1.format_offered = DRSUAPI_DS_NAME_FORMAT_SID_OR_SID_HISTORY; - r.in.req.req1.format_desired = DRSUAPI_DS_NAME_FORMAT_FQDN_1779; - names[0].str = SID_BUILTIN_ADMINISTRATORS; - - printf("testing DsCrackNames with SID '%s' desired format:%d\n", - names[0].str, r.in.req.req1.format_desired); - - status = dcerpc_drsuapi_DsCrackNames(p, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - const char *errstr = nt_errstr(status); - if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { - errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); - } - printf("dcerpc_drsuapi_DsCrackNames failed - %s\n", errstr); - ret = False; - } 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_NO_MAPPING) { - printf("DsCrackNames incorrect error on name - %d\n", r.out.ctr.ctr1->array[0].status); - ret = False; - } - - if (!ret) { - return ret; - } - - - 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; - names[0].str = SID_BUILTIN_ADMINISTRATORS; - - printf("testing DsCrackNames with SID '%s' desired format:%d\n", - names[0].str, r.in.req.req1.format_desired); + 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 2 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, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ - status = dcerpc_drsuapi_DsCrackNames(p, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - const char *errstr = nt_errstr(status); - if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { - errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); - } - printf("dcerpc_drsuapi_DsCrackNames failed - %s\n", errstr); - ret = False; - } 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_NO_MAPPING) { - printf("DsCrackNames incorrect error on name - %d\n", r.out.ctr.ctr1->array[0].status); - ret = False; - } +#include "includes.h" +#include "librpc/gen_ndr/ndr_drsuapi.h" +#include "torture/rpc/drsupai.h" - if (!ret) { - return ret; - } +static BOOL test_DsBind(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, + struct DsPrivate *priv) +{ + NTSTATUS status; + struct drsuapi_DsBind r; + BOOL ret = True; + GUID_from_string(DRSUAPI_DS_BIND_GUID, &priv->bind_guid); - /* NEGATIVE tests. This should parse, but not succeed */ - r.in.req.req1.format_offered = DRSUAPI_DS_NAME_FORMAT_USER_PRINCIPAL; - r.in.req.req1.format_desired = DRSUAPI_DS_NAME_FORMAT_FQDN_1779; - names[0].str = "foo@bar"; + r.in.bind_guid = &priv->bind_guid; + r.in.bind_info = NULL; + r.out.bind_handle = &priv->bind_handle; - printf("testing DsCrackNames with user principal name '%s' desired format:%d\n", - names[0].str, r.in.req.req1.format_desired); + printf("testing DsBind\n"); - status = dcerpc_drsuapi_DsCrackNames(p, mem_ctx, &r); + status = dcerpc_drsuapi_DsBind(p, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { const char *errstr = nt_errstr(status); if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); } - printf("dcerpc_drsuapi_DsCrackNames failed - %s\n", errstr); + printf("dcerpc_drsuapi_DsBind failed - %s\n", errstr); ret = False; } 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_DOMAIN_ONLY) { - printf("DsCrackNames incorrect error on name - %d\n", r.out.ctr.ctr1->array[0].status); + printf("DsBind failed - %s\n", win_errstr(r.out.result)); ret = False; } - if (ret) { - return test_DsCrackNamesMatrix(p, mem_ctx, priv, FQDN_1779_name, user_principal_name, service_principal_name); - } - return ret; } @@ -1847,37 +665,3 @@ BOOL torture_rpc_drsuapi(void) return ret; } -BOOL torture_rpc_drsuapi_cracknames(void) -{ - NTSTATUS status; - struct dcerpc_pipe *p; - TALLOC_CTX *mem_ctx; - BOOL ret = True; - struct DsPrivate priv; - - mem_ctx = talloc_init("torture_rpc_drsuapi"); - - status = torture_rpc_connection(mem_ctx, - &p, - DCERPC_DRSUAPI_NAME, - DCERPC_DRSUAPI_UUID, - DCERPC_DRSUAPI_VERSION); - if (!NT_STATUS_IS_OK(status)) { - talloc_free(mem_ctx); - return False; - } - - printf("Connected to DRAUAPI pipe\n"); - - ZERO_STRUCT(priv); - - ret &= test_DsBind(p, mem_ctx, &priv); - - ret &= test_DsCrackNames(p, mem_ctx, &priv, lp_parm_string(-1, "torture", "host")); - - ret &= test_DsUnbind(p, mem_ctx, &priv); - - talloc_free(mem_ctx); - - return ret; -} -- cgit From f1af78a5390e25c12c887a1fe8e5e4c6086ab06f Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Fri, 7 Oct 2005 09:19:59 +0000 Subject: r10807: Make the split-out files actually compile... Andrew Bartlett (This used to be commit a4282c14d5cf6b5eceb293d657c7cd5eaea89046) --- source4/torture/rpc/drsuapi.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'source4/torture/rpc/drsuapi.c') diff --git a/source4/torture/rpc/drsuapi.c b/source4/torture/rpc/drsuapi.c index 8f772f1861..1d47a58747 100644 --- a/source4/torture/rpc/drsuapi.c +++ b/source4/torture/rpc/drsuapi.c @@ -24,10 +24,10 @@ #include "includes.h" #include "librpc/gen_ndr/ndr_drsuapi.h" -#include "torture/rpc/drsupai.h" +#include "torture/rpc/drsuapi.h" -static BOOL test_DsBind(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, - struct DsPrivate *priv) +BOOL test_DsBind(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, + struct DsPrivate *priv) { NTSTATUS status; struct drsuapi_DsBind r; @@ -590,8 +590,8 @@ static BOOL test_DsGetNCChanges(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, return ret; } -static BOOL test_DsUnbind(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, - struct DsPrivate *priv) +BOOL test_DsUnbind(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, + struct DsPrivate *priv) { NTSTATUS status; struct drsuapi_DsUnbind r; -- cgit From 2d29354a355672261be356c2a8d9eff75b6a5c84 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 10 Oct 2005 09:33:06 +0000 Subject: r10865: merge branches/SOC/SAMBA_4_0 into main the main SAMBA_4_0 tree metze r8017@SERNOX: metze | 2005-06-30 13:44:23 +0200 create the SAMBA_4_0 branch for the Summer Of Code Project metze r8730@SERNOX: brad | 2005-07-24 03:09:48 +0200 Branching Samba 4 r8731@SERNOX: brad | 2005-07-24 06:39:00 +0200 added 'make installmisc' to howto.txt added existing 'compression' option to level8 drsuapi torture test added new 'neighbour_writeable' option to level8 drsuapi torture test r8732@SERNOX: brad | 2005-07-24 06:42:38 +0200 added metze's dssync patch as source/torture/rpc/dssync.c r8739@SERNOX: brad | 2005-07-25 00:24:46 +0200 added a test called RPC-DSSYNC to config.mk hacking at dssync.c in an attempt to make it compile r8754@SERNOX: brad | 2005-07-25 15:19:21 +0200 Changing dssync.c to use ldb routines for accessing ldap rather than raw ldap calls. r8765@SERNOX: brad | 2005-07-26 03:35:38 +0200 more ldb changes to test_CompleteJoin(), it mostly kind of almost works now! r8766@SERNOX: brad | 2005-07-26 03:56:00 +0200 Trying to fix the crazy nesting in the branch r8769@SERNOX: brad | 2005-07-26 04:48:29 +0200 merging latest changes r8770@SERNOX: brad | 2005-07-26 04:53:43 +0200 removing nested branch r8793@SERNOX: jerry | 2005-07-27 05:04:57 +0200 merging on of Brad missing changes from the nested 4.0 branch debacle r8794@SERNOX: jerry | 2005-07-27 05:14:42 +0200 syncing up with the main 4_0 branch for Brad r8842@SERNOX: brad | 2005-07-29 00:26:30 +0200 merging changes from branches/SAMBA_4_0 r8850@SERNOX: brad | 2005-07-29 21:07:57 +0200 Bringing my tree up to date r8851@SERNOX: brad | 2005-07-30 00:48:04 +0200 making dssync.c more ldb-centric, reverted samlogon.c from rev. 8845 to get my branch to compile again. r8856@SERNOX: brad | 2005-07-30 03:20:33 +0200 I think I have the ldb code down in test_CompleteJoin (not complete yet though) r8860@SERNOX: brad | 2005-07-30 07:08:13 +0200 Changed comments to C style /**/ (thanks Richard), some more changes to test_CompleteJoin(). r8862@SERNOX: brad | 2005-07-31 04:45:32 +0200 Bringing the SOC/SAMBA_4_0 branch up to date. r8863@SERNOX: brad | 2005-07-31 20:00:41 +0200 Updated some missing files from the branch r8864@SERNOX: brad | 2005-07-31 20:25:50 +0200 Removing autogenerated files from branch r8865@SERNOX: brad | 2005-07-31 20:43:58 +0200 last of the unneeded files in SOC/SAMBA_4_0 r9004@SERNOX: brad | 2005-08-03 18:51:23 +0200 r5214@buttercup: j0j0 | 2005-08-03 10:44:30 -0600 r@buttercup: j0j0 | 2005-08-02 22:54:13 -0600 creating a local branch of branches/SAMBA_4_0 r9013@SERNOX: brad | 2005-08-03 20:57:48 +0200 r5228@buttercup: j0j0 | 2005-08-03 13:00:11 -0600 Fixing differences between this branch and /branches/SAMBA_4_0 r9014@SERNOX: brad | 2005-08-03 21:18:05 +0200 r5231@buttercup: j0j0 | 2005-08-03 13:23:12 -0600 Updating config.mk so that smbtorture builds again r9061@SERNOX: brad | 2005-08-04 18:17:36 +0200 r5249@buttercup: j0j0 | 2005-08-03 21:01:02 -0600 Start using libnet_Join() for DC join. r9062@SERNOX: brad | 2005-08-04 18:17:47 +0200 r5250@buttercup: j0j0 | 2005-08-04 10:21:34 -0600 Some more work towards performing a dc join. r9064@SERNOX: brad | 2005-08-04 18:53:51 +0200 r5253@buttercup: j0j0 | 2005-08-04 10:53:00 -0600 Fixed a bug (passing a TALLOC_CTX to libnet_context_init() ) r9069@SERNOX: brad | 2005-08-04 21:59:55 +0200 r5279@buttercup: j0j0 | 2005-08-04 14:04:55 -0600 Some more work on the domain join r9117@SERNOX: brad | 2005-08-05 16:50:26 +0200 r5281@buttercup: j0j0 | 2005-08-05 08:55:58 -0600 Committing minor changes before merge r9180@SERNOX: brad | 2005-08-07 17:25:25 +0200 r5314@buttercup: j0j0 | 2005-08-07 09:30:12 -0600 Reworked libnet_join to use two join levels, AUTOMATIC and SPECIFIED. r9181@SERNOX: brad | 2005-08-07 17:25:36 +0200 r5315@buttercup: j0j0 | 2005-08-07 09:31:22 -0600 Working with libnet_Join(), code cleanup needed in the near future. r9192@SERNOX: brad | 2005-08-07 21:40:22 +0200 r5373@buttercup: j0j0 | 2005-08-07 13:46:09 -0600 Some code cleanup to make things a little more readable. r9249@SERNOX: brad | 2005-08-12 01:31:48 +0200 r5375@buttercup: j0j0 | 2005-08-11 17:38:44 -0600 Split libnet_JoinDomain() into libnet_JoinDomain() and libnet_JoinADSDomain(). r9256@SERNOX: brad | 2005-08-12 04:55:11 +0200 r5413@buttercup: j0j0 | 2005-08-11 21:02:27 -0600 Clean up libnet_JoinADSDomain() a little, added a comment to the test_join struct. r9314@SERNOX: brad | 2005-08-16 03:53:20 +0200 r5436@buttercup: j0j0 | 2005-08-15 20:01:21 -0600 libnet_JoinDomain() should honour LIBNET_JOIN_TORTURE now. torture_join_domain() should properly use libnet_JoinDomain(). dssync.c uses torture_join_domain() again. r9351@SERNOX: brad | 2005-08-17 07:15:31 +0200 r5438@buttercup: j0j0 | 2005-08-16 23:23:58 -0600 Removed LIBNET_JOIN_TORTURE level, as it became unnecessary once libnet_Join_primary_domain() handled netbios names better. Corrected libnet_JoinDomain() and libnet_JoinADSDomain(). r9352@SERNOX: brad | 2005-08-17 07:24:49 +0200 r5440@buttercup: j0j0 | 2005-08-16 23:33:25 -0600 Fixed a typo. r9354@SERNOX: metze | 2005-08-17 10:28:25 +0200 remove object files from svn metze r9376@SERNOX: brad | 2005-08-18 05:15:48 +0200 r5476@buttercup: j0j0 | 2005-08-17 21:24:33 -0600 Proof that I shouldn't code when i'm tired (silly bugfixes). r9405@SERNOX: brad | 2005-08-19 22:50:10 +0200 r5500@buttercup: j0j0 | 2005-08-19 14:56:25 -0600 Get dssync.c compiling again after merge (ldb_dn changes from rev. 9391). r9407@SERNOX: brad | 2005-08-20 03:22:42 +0200 r5502@buttercup: j0j0 | 2005-08-19 19:28:22 -0600 libnet/libnet_join.c Some more fixes so ldb uses ldb_dn's. torture/rpc/dssync.c Some debugging printf()'s. ldb_dn fixes. torture/rpc/testjoin.c Change torture_join_domain() to use libnet_JoinDomain() rather than libnet_Join(). Some more debugging statements. I'm not sure why, but GUID_all_zero(user_handle.uuid) is returning true in torture_leave_domain() when called it from torture_destroy_context() in torture/rpc/dssync.c. That's what i'm working out now. r9427@SERNOX: brad | 2005-08-20 18:38:29 +0200 r5504@buttercup: j0j0 | 2005-08-20 10:44:52 -0600 Some bugfixes. Removed a bunch of debugging code. torture_leave_domain() works again! not 100% perfect yet though... r9428@SERNOX: brad | 2005-08-20 19:09:26 +0200 r5506@buttercup: j0j0 | 2005-08-20 11:15:54 -0600 Restructure torture_join_domain() so that it joins itself, removes itself, and joins itself to the domain again to ensure that its account information is all current and as expected. r9452@SERNOX: brad | 2005-08-21 19:33:51 +0200 r5508@buttercup: j0j0 | 2005-08-21 11:40:36 -0600 Bugfixes, trying to get things straight between contexts. r9467@SERNOX: brad | 2005-08-22 04:00:48 +0200 r5510@buttercup: j0j0 | 2005-08-21 20:06:55 -0600 Another round of bugfixing. r9521@SERNOX: brad | 2005-08-23 15:26:44 +0200 r5596@buttercup: j0j0 | 2005-08-23 07:33:06 -0600 Merging changes r9524@SERNOX: metze | 2005-08-23 16:09:42 +0200 - fix the build caused by changes in the main samba4 tree, - add an option "dssync:german=yes" to allow me to run against my german w2k3 server this should be replaces by CLDAP calls to get the Default-First-Site-Name dynamicly - remove some temporary comments, as DsAddEntry works now metze r9528@SERNOX: metze | 2005-08-23 18:22:22 +0200 the RPC-DSSYNC test is now able to fetch the whole tree, including the unicodePwd, ntPwdHistory fields metze r9559@SERNOX: brad | 2005-08-24 04:11:47 +0200 r5612@buttercup: j0j0 | 2005-08-23 20:19:12 -0600 Some fixes around using talloc in a hierarchical fashion. Still not right, but better. r9564@SERNOX: brad | 2005-08-24 05:43:11 +0200 r5614@buttercup: j0j0 | 2005-08-23 21:50:38 -0600 Gave libnet_JoinADSDomain() its own tmp_ctx rather than passing it from libnet_JoinDomain() as a parameter (yuk). As a side effect, it proves that my bug lies in libnet_JoinDomain(), not libnet_JoinADSDomain(). r9565@SERNOX: brad | 2005-08-24 06:09:46 +0200 r5616@buttercup: j0j0 | 2005-08-23 22:17:12 -0600 Small fix, if r->out.error_string and r2->samr_handle.out.error_string weren't set to NULL, torture_join_domain() would segfault on the second join. r9630@SERNOX: brad | 2005-08-26 06:42:50 +0200 Commented out the parts of the dssync test which perform the dc join and create/remove associated ldap entries. Commented out the test for the 'german' dssync option, because now we detect the Site-Name using CLDAP. If cldap_netlogon() does not return ok, the code defaults to 'Default-First-Site-Name'. r9670@SERNOX: brad | 2005-08-27 02:30:11 +0200 Added a patch from metze. To showcase what i've learned today, i've created two new parameters which can be set at runtime, drsuapi:last_usn and drsuapi:partition. drsuapi:last_usn takes an integer representing the USN of the last recieved replication update for a particular partition (uses the domain dn if drsuapi:parition isn't set). That value is passed in the DsGetNCChanges() call so that only info which has been updated since that point in time is returned. If this option is not set, 0 is used by default, and all updates for that partition are returned. drsuapi:partition takes a string dn and uses that as the name of the AD partition to replicate. Some debugging output was also added. r9723@SERNOX: brad | 2005-08-29 01:07:51 +0200 Added some copyright notices. Changed some things in net_join.c to try and figure out why 'net join bdc' segfaults. It occurs when the last talloc_free() happens, so i'm sure it's something to do with the memory fiddling i'm doing in libnet_join. Added some drsuapi attribute ids that I figured out today. I put some (many, dry) notes together while doing that, so i'll try to put them up on a blog at samba.org a little later tonight. r9740@SERNOX: metze | 2005-08-29 16:58:03 +0200 fix up the DsGetNCchanges loop, and remove misleading comments metze r9743@SERNOX: metze | 2005-08-29 17:26:45 +0200 make the logic a bit clearer metze r9815@SERNOX: brad | 2005-08-31 02:36:21 +0200 Added cldap_netlogon() AD Site-Name lookup into libnet/libnet_join.c. Bugfixing rampage in libnet_join.c to resolve misunderstanding of talloc_steal(). libnet_join now creates the CN=,CN=Servers,CN=,CN=Sites,CN=Configuration, container on a dc join. r9858@SERNOX: brad | 2005-09-01 03:17:17 +0200 Removed extraneous NDR_ALL subsystem requirement from torture/config.mk. Added lots of error checking as per metze's advice. Removed commented out code. More bug chasing. r9863@SERNOX: brad | 2005-09-01 05:53:19 +0200 Cleaned up dssync.c, removed the unneeded DsCrackNames() call, removed DC join/leave related stuff. It no longer looks like my house does! r9887@SERNOX: metze | 2005-09-01 11:34:03 +0200 - fix dssync:highest_usn parameter handling - ask for LINKED_ATTRIBUTE replication metze r9891@SERNOX: metze | 2005-09-01 14:13:18 +0200 make the code more readable, and fix a few bugs metze r9911@SERNOX: brad | 2005-09-01 20:36:27 +0200 Bugfixes in libnet_join.c. Cleaned up comments. Added domain_dn_str and account_dn_str to struct libnet_JoinDomain. Removed struct dcerpc_pipe *samr_pipe and struct policy_handle user_handle from struct libnet_Join. r9920@SERNOX: brad | 2005-09-01 23:34:13 +0200 Added disclaimer (I can't seem to get libnet_JoinDomain() to keep the samr_pipe and u_handle open past the function call, grrrr....). r9921@SERNOX: brad | 2005-09-01 23:37:54 +0200 Added copyright statement. Cleaned up unneeded variables from torture_join_domain(). r9932@SERNOX: brad | 2005-09-02 01:49:42 +0200 Really rushed project notes. r10841@SERNOX: metze | 2005-10-08 20:01:45 +0200 remove diff to main SAMBA_4_0 branch metze r10862@SERNOX: metze | 2005-10-10 10:31:52 +0200 remove the differences between SAMBA_4_0 and SOC/SAMBA_4_0 metze r10863@SERNOX: metze | 2005-10-10 10:34:26 +0200 fix the build metze r10864@SERNOX: metze | 2005-10-10 11:10:08 +0200 remove README file to reduce, diffs to main SAMBA_4_0 branch: metze README: This project was centered around adding a torture test to Samba 4, which used drsuapi_DsGetNCChanges() to retrieve the contents of an Active Directory in the same manner as an Active Directory DC replication event. As the project unfolded, I also applied some changes to the functionality of the libnet library related to joining a machine account to a domain. One of the first things that I implemented in this project was a 'neighbour_writeable' option for the RPC-DRSUAPI torture test. The command line to execute this torture test is as follows: smbtorture --option=drsuapi:neighbour_writeable=True -W -U % ncacn_ip_tcp: RPC-DRSUAPI This option provides us with runtime control over the DRSUAPI_DS_REPLICA_NEIGHBOUR_WRITEABLE flag in the struct drsuapi_DsGetNCChanges.in.req.req.replica_flags, allowing us to easily test for differences in the behaviour of AD replication with the switch on or off. In the course of the project, I also implemented two more flags for the RPC-DSSYNC test. dssync:last_usn takes an integer representing the USN (Universal Serial Number) of the last recieved replication update for a particular partition (uses the domain DN if drsuapi:parition isn't set). That value is passed in the DsGetNCChanges() call so that only info which has been updated since that point in time is returned. If this option is not set, 0 is used by default, and all updates for that partition are returned. dssync:partition takes a string DN and uses that as the name of the AD partition to replicate. Based initially on a patch provided to me by one of my mentors, Stephan (metze) Metzmacher, the RPC-DSSYNC test was implemented for this project. Initially functionality was included to perform a DC join prior to initiating replication, but the code was removed when it was realized that replication could indeed take place without being a member of the domain in any way. It has been recently suggested that we may need a DC join after all to get all of the information we may want from the AD replication. This is probably best added using a torture_join_domain() call once the libnet code is able to keep the user policy handle and SAMR RPC pipe open. The DC join code was taken out of the RPC-DSSYNC and implemented for the most part in the libnet libraries. To test this, the RPC-NETLOGON test was modified to perform a domain join, leave and rejoin. Currently, the test has a fault in that it is unable to leave the domain using the same SAMR RPC pipe and user_policy information as was used for the first join. This is because I was unable to get the code working properly in libnet to provide that functionality. Currently missing from the DC join in libnet is the code to create the CN=NTDS Settings,CN=,CN=,CN=Sites,CN=Configuration, container using the dcerpc_drsuapi_DsAddEntry() call. I did not want to implement this functionality in libnet while there were still problems with the code. I also provided the ability in libnet and the RPC-DSSYNC test to look up the proper site name using the cldap library. In my investigations, I was unable to find out any information regarding the UnicodePwd attribute, except that the same password is represented differently for two different users in the same directory. I was also able to resolve and confirm the meaning of some DRSUAPI_ATTRIBUTE ID's. DRSUAPI_OBJECTCLASS_domain (0xA0042) DRSUAPI_OBJECTCLASS_domainDNS (0xA0043) wellKnownObjects (0x9026A) fSMORoleOwner (0x90171) name or dc (0x90001) whenCreated (0x20002) instanceType (0x20001) gPLink (0x9037B) These were added to the IDL for drsuapi (source/librpc/idl/drsuapi.idl). I would like to thank everyone on the Samba team who worked with me and assisted me with this project, specifically all the work done by Stephan Metzmacher, Andrew Bartlett and Jerry Carter. Working on this project with the Samba team really has been a life changing experience, as corny as that sounds. I've realized that I was born to be a systems developer, and it has helped confirm in my mind that Open Source (specifically Samba) development is exactly what i've been missing! I would also like to take this opportunity to thank Chris Dibona and Google for the amazing opportunity. I don't know if I would have taken the leap in other circumstances. I know these notes sound a little rushed, but it is 23:55 after all! :) (This used to be commit 55552b41cbaa8c57a30373a53176e7f3ae945290) --- source4/torture/rpc/drsuapi.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'source4/torture/rpc/drsuapi.c') diff --git a/source4/torture/rpc/drsuapi.c b/source4/torture/rpc/drsuapi.c index 1d47a58747..a3310e144f 100644 --- a/source4/torture/rpc/drsuapi.c +++ b/source4/torture/rpc/drsuapi.c @@ -553,13 +553,17 @@ static BOOL test_DsGetNCChanges(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, 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 - | DRSUAPI_DS_REPLICA_NEIGHBOUR_WRITEABLE - | DRSUAPI_DS_REPLICA_NEIGHBOUR_SYNC_ON_STARTUP + r.in.req.req8.replica_flags = 0; + if (lp_parm_bool(-1,"drsuapi","compression",False)) { + r.in.req.req8.replica_flags |= DRSUAPI_DS_REPLICA_NEIGHBOUR_COMPRESS_CHANGES; + } + if (lp_parm_bool(-1,"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_SYNC_ON_STARTUP | DRSUAPI_DS_REPLICA_NEIGHBOUR_DO_SCHEDULED_SYNCS | DRSUAPI_DS_REPLICA_NEIGHBOUR_RETURN_OBJECT_PARENTS | DRSUAPI_DS_REPLICA_NEIGHBOUR_NEVER_SYNCED - | DRSUAPI_DS_REPLICA_NEIGHBOUR_COMPRESS_CHANGES ; r.in.req.req8.unknown2 = 402; r.in.req.req8.unknown3 = 402116; -- cgit From acd6a086b341096fcbea1775ce748587fcc8020a Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 27 Dec 2005 14:28:01 +0000 Subject: r12510: Change the DCE/RPC interfaces to take a pointer to a dcerpc_interface_table struct rather then a tuple of interface name, UUID and version. This removes the requirement for having a global list of DCE/RPC interfaces, except for these parts of the code that use that list explicitly (ndrdump and the scanner torture test). This should also allow us to remove the hack that put the authservice parameter in the dcerpc_binding struct as it can now be read directly from dcerpc_interface_table. I will now modify some of these functions to take a dcerpc_syntax_id structure rather then a full dcerpc_interface_table. (This used to be commit 8aae0f168e54c01d0866ad6e0da141dbd828574f) --- source4/torture/rpc/drsuapi.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'source4/torture/rpc/drsuapi.c') diff --git a/source4/torture/rpc/drsuapi.c b/source4/torture/rpc/drsuapi.c index a3310e144f..9fbf0c21e6 100644 --- a/source4/torture/rpc/drsuapi.c +++ b/source4/torture/rpc/drsuapi.c @@ -634,9 +634,7 @@ BOOL torture_rpc_drsuapi(void) status = torture_rpc_connection(mem_ctx, &p, - DCERPC_DRSUAPI_NAME, - DCERPC_DRSUAPI_UUID, - DCERPC_DRSUAPI_VERSION); + &dcerpc_table_drsuapi); if (!NT_STATUS_IS_OK(status)) { talloc_free(mem_ctx); return False; -- cgit From 25bb00fbcd409572e1c19c05fdc42c883936780b Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 3 Jan 2006 13:41:17 +0000 Subject: r12693: Move core data structures out of smb.h into core.h torture prototypes in seperate header (This used to be commit 73610639b23ca3743077193fa0b1de7c7f65944d) --- source4/torture/rpc/drsuapi.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/torture/rpc/drsuapi.c') diff --git a/source4/torture/rpc/drsuapi.c b/source4/torture/rpc/drsuapi.c index 9fbf0c21e6..e9c2e9d049 100644 --- a/source4/torture/rpc/drsuapi.c +++ b/source4/torture/rpc/drsuapi.c @@ -23,6 +23,7 @@ */ #include "includes.h" +#include "torture/torture.h" #include "librpc/gen_ndr/ndr_drsuapi.h" #include "torture/rpc/drsuapi.h" -- cgit From 1a53c1dc927efbc6a594ed513feb9ab9247078e8 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sat, 4 Feb 2006 14:08:24 +0000 Subject: r13346: use private proto header files for the torture tests metze (This used to be commit 67837dbd2bcff8ec1917ba02884ee2eaa0776b46) --- source4/torture/rpc/drsuapi.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/torture/rpc/drsuapi.c') diff --git a/source4/torture/rpc/drsuapi.c b/source4/torture/rpc/drsuapi.c index e9c2e9d049..e63915992a 100644 --- a/source4/torture/rpc/drsuapi.c +++ b/source4/torture/rpc/drsuapi.c @@ -26,6 +26,7 @@ #include "torture/torture.h" #include "librpc/gen_ndr/ndr_drsuapi.h" #include "torture/rpc/drsuapi.h" +#include "torture/rpc/proto.h" BOOL test_DsBind(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct DsPrivate *priv) -- cgit From 3f16241a1d3243447d0244ebac05b447aec94df8 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 14 Mar 2006 01:29:56 +0000 Subject: r14363: Remove credentials.h from the global includes. (This used to be commit 98c4c3051391c6f89df5d133665f51bef66b1563) --- source4/torture/rpc/drsuapi.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/torture/rpc/drsuapi.c') diff --git a/source4/torture/rpc/drsuapi.c b/source4/torture/rpc/drsuapi.c index e63915992a..f23bb5586b 100644 --- a/source4/torture/rpc/drsuapi.c +++ b/source4/torture/rpc/drsuapi.c @@ -25,6 +25,7 @@ #include "includes.h" #include "torture/torture.h" #include "librpc/gen_ndr/ndr_drsuapi.h" +#include "auth/credentials/credentials.h" #include "torture/rpc/drsuapi.h" #include "torture/rpc/proto.h" -- cgit From eefe30b7d8e17ed744318417954669bacf2b3ac0 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 14 Mar 2006 15:02:05 +0000 Subject: r14379: Build torture/rpc/ as a seperate smbtorture module. Move helper functions for rpc out of torture/torture.c (This used to be commit 1d2d970f3b8aef3f36c2befb94b5dd72c0086639) --- source4/torture/rpc/drsuapi.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'source4/torture/rpc/drsuapi.c') diff --git a/source4/torture/rpc/drsuapi.c b/source4/torture/rpc/drsuapi.c index f23bb5586b..0b700a7ac4 100644 --- a/source4/torture/rpc/drsuapi.c +++ b/source4/torture/rpc/drsuapi.c @@ -25,9 +25,7 @@ #include "includes.h" #include "torture/torture.h" #include "librpc/gen_ndr/ndr_drsuapi.h" -#include "auth/credentials/credentials.h" -#include "torture/rpc/drsuapi.h" -#include "torture/rpc/proto.h" +#include "torture/rpc/rpc.h" BOOL test_DsBind(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct DsPrivate *priv) -- cgit From 1060f6b3f621cb70b075a879f129e57f10fdbf8a Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 14 Mar 2006 23:35:30 +0000 Subject: r14402: Generate seperate headers for RPC client functions. (This used to be commit 7054ebf0249930843a2baf4d023ae8f62cedb109) --- source4/torture/rpc/drsuapi.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/torture/rpc/drsuapi.c') diff --git a/source4/torture/rpc/drsuapi.c b/source4/torture/rpc/drsuapi.c index 0b700a7ac4..75efff89b3 100644 --- a/source4/torture/rpc/drsuapi.c +++ b/source4/torture/rpc/drsuapi.c @@ -25,6 +25,7 @@ #include "includes.h" #include "torture/torture.h" #include "librpc/gen_ndr/ndr_drsuapi.h" +#include "librpc/gen_ndr/ndr_drsuapi_c.h" #include "torture/rpc/rpc.h" BOOL test_DsBind(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, -- cgit From 4f1c8daa36a7a0372c5fd9eab51f3c16ee81c49d Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 16 Mar 2006 12:43:28 +0000 Subject: r14470: Remove some unnecessary headers. (This used to be commit f7312dab3b9aba2b2b82e8a6e0c483a32a03a63a) --- source4/torture/rpc/drsuapi.c | 1 - 1 file changed, 1 deletion(-) (limited to 'source4/torture/rpc/drsuapi.c') diff --git a/source4/torture/rpc/drsuapi.c b/source4/torture/rpc/drsuapi.c index 75efff89b3..a515df1847 100644 --- a/source4/torture/rpc/drsuapi.c +++ b/source4/torture/rpc/drsuapi.c @@ -24,7 +24,6 @@ #include "includes.h" #include "torture/torture.h" -#include "librpc/gen_ndr/ndr_drsuapi.h" #include "librpc/gen_ndr/ndr_drsuapi_c.h" #include "torture/rpc/rpc.h" -- cgit From 909b111f587705a45f63540b39968f1af58a9b5d Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 25 Mar 2006 16:01:28 +0000 Subject: r14720: Add torture_context argument to all torture tests (This used to be commit 3c7a5ce29108dd82210dc3e1f00414f545949e1d) --- source4/torture/rpc/drsuapi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/torture/rpc/drsuapi.c') diff --git a/source4/torture/rpc/drsuapi.c b/source4/torture/rpc/drsuapi.c index a515df1847..ffef717489 100644 --- a/source4/torture/rpc/drsuapi.c +++ b/source4/torture/rpc/drsuapi.c @@ -623,7 +623,7 @@ BOOL test_DsUnbind(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, return ret; } -BOOL torture_rpc_drsuapi(void) +BOOL torture_rpc_drsuapi(struct torture_context *torture) { NTSTATUS status; struct dcerpc_pipe *p; -- cgit From ce2d92c878ceb4c4f0f8948be2dc6ad7ecaf132c Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Fri, 17 Nov 2006 11:19:15 +0000 Subject: r19760: Create a DC account for the drsuapi tests to work on, rather than choosing an existing DC. Allow to skip some tests under Samba4. Andrew Bartlett (This used to be commit 705fbae325267fd0ed11f463f954f8e45802d6d5) --- source4/torture/rpc/drsuapi.c | 51 ++++++++++++++++++++++++++++++++++++++----- 1 file changed, 45 insertions(+), 6 deletions(-) (limited to 'source4/torture/rpc/drsuapi.c') diff --git a/source4/torture/rpc/drsuapi.c b/source4/torture/rpc/drsuapi.c index ffef717489..bcfb12de75 100644 --- a/source4/torture/rpc/drsuapi.c +++ b/source4/torture/rpc/drsuapi.c @@ -27,6 +27,8 @@ #include "librpc/gen_ndr/ndr_drsuapi_c.h" #include "torture/rpc/rpc.h" +#define TEST_MACHINE_NAME "torturetest" + BOOL test_DsBind(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct DsPrivate *priv) { @@ -65,6 +67,11 @@ static BOOL test_DsGetDCInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct drsuapi_DsGetDomainControllerInfo r; BOOL ret = True; + if (lp_parm_bool(-1, "torture", "samba4", False)) { + printf("skipping DsGetDCInfo test against Samba4\n"); + return True; + } + r.in.bind_handle = &priv->bind_handle; r.in.level = 1; @@ -189,7 +196,7 @@ static BOOL test_DsGetDCInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, } static BOOL test_DsWriteAccountSpn(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, - struct DsPrivate *priv) + struct DsPrivate *priv) { NTSTATUS status; struct drsuapi_DsWriteAccountSpn r; @@ -316,6 +323,11 @@ static BOOL test_DsReplicaGetInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, } }; + if (lp_parm_bool(-1, "torture", "samba4", False)) { + printf("skipping DsGetDCInfo test against Samba4\n"); + return True; + } + r.in.bind_handle = &priv->bind_handle; for (i=0; i < ARRAY_SIZE(array); i++) { @@ -389,6 +401,11 @@ static BOOL test_DsReplicaSync(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, return True; } + if (lp_parm_bool(-1, "torture", "samba4", False)) { + printf("skipping DsReplicaSync test against Samba4\n"); + return True; + } + ZERO_STRUCT(null_guid); ZERO_STRUCT(null_sid); @@ -447,6 +464,11 @@ static BOOL test_DsReplicaUpdateRefs(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, } }; + if (lp_parm_bool(-1, "torture", "samba4", False)) { + printf("skipping DsReplicaUpdateRefs test against Samba4\n"); + return True; + } + ZERO_STRUCT(null_guid); ZERO_STRUCT(null_sid); @@ -509,6 +531,11 @@ static BOOL test_DsGetNCChanges(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, } }; + if (lp_parm_bool(-1, "torture", "samba4", False)) { + printf("skipping DsGetNCChanges test against Samba4\n"); + return True; + } + ZERO_STRUCT(null_guid); ZERO_STRUCT(null_sid); @@ -630,26 +657,36 @@ BOOL torture_rpc_drsuapi(struct torture_context *torture) TALLOC_CTX *mem_ctx; BOOL ret = True; struct DsPrivate priv; + struct cli_credentials *machine_credentials; mem_ctx = talloc_init("torture_rpc_drsuapi"); + printf("Connected to DRAUAPI pipe\n"); + + ZERO_STRUCT(priv); + + priv.join = torture_join_domain(TEST_MACHINE_NAME, ACB_SVRTRUST, + &machine_credentials); + if (!priv.join) { + talloc_free(mem_ctx); + printf("Failed to join as BDC\n"); + return False; + } + status = torture_rpc_connection(mem_ctx, &p, &dcerpc_table_drsuapi); if (!NT_STATUS_IS_OK(status)) { + torture_leave_domain(priv.join); talloc_free(mem_ctx); return False; } - printf("Connected to DRAUAPI pipe\n"); - - ZERO_STRUCT(priv); - ret &= test_DsBind(p, mem_ctx, &priv); ret &= test_DsGetDCInfo(p, mem_ctx, &priv); - ret &= test_DsCrackNames(p, mem_ctx, &priv, priv.dcinfo.netbios_name); + ret &= test_DsCrackNames(p, mem_ctx, &priv, TEST_MACHINE_NAME); ret &= test_DsWriteAccountSpn(p, mem_ctx, &priv); @@ -665,6 +702,8 @@ BOOL torture_rpc_drsuapi(struct torture_context *torture) talloc_free(mem_ctx); + torture_leave_domain(priv.join); + return ret; } -- cgit From 99c3d9c3713369abe50bb86e7cd3b9d2fdbba565 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 30 Nov 2006 11:18:18 +0000 Subject: r19967: this unknowns are max_object_count and max_ndr_size metze (This used to be commit 3e6264d872e4fc39a8e0712293492ad413345de9) --- source4/torture/rpc/drsuapi.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source4/torture/rpc/drsuapi.c') diff --git a/source4/torture/rpc/drsuapi.c b/source4/torture/rpc/drsuapi.c index bcfb12de75..29b6b0633b 100644 --- a/source4/torture/rpc/drsuapi.c +++ b/source4/torture/rpc/drsuapi.c @@ -563,8 +563,8 @@ static BOOL test_DsGetNCChanges(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, if (lp_parm_bool(-1, "drsuapi","compression", False)) { r.in.req.req5.replica_flags |= DRSUAPI_DS_REPLICA_NEIGHBOUR_COMPRESS_CHANGES; } - r.in.req.req5.unknown2 = 0; - r.in.req.req5.unknown3 = 0; + r.in.req.req5.max_object_count = 0; + r.in.req.req5.max_ndr_size = 0; r.in.req.req5.unknown4 = 0; r.in.req.req5.h1 = 0; @@ -593,8 +593,8 @@ static BOOL test_DsGetNCChanges(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, | DRSUAPI_DS_REPLICA_NEIGHBOUR_RETURN_OBJECT_PARENTS | DRSUAPI_DS_REPLICA_NEIGHBOUR_NEVER_SYNCED ; - r.in.req.req8.unknown2 = 402; - r.in.req.req8.unknown3 = 402116; + r.in.req.req8.max_object_count = 402; + r.in.req.req8.max_ndr_size = 402116; r.in.req.req8.unknown4 = 0; r.in.req.req8.h1 = 0; r.in.req.req8.unique_ptr1 = 0; -- cgit From d3c9737e5b8da23165d65b42d37e16549a80ce70 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 8 Dec 2006 17:34:15 +0000 Subject: r20079: the 2nd guid is the source_dsa invocation_id not the objectGUID, this wasn't noticed because on the 1st dc in the forest both have the same value metze (This used to be commit 527bd9a0a361e19606e25e885b92da316e740bf9) --- source4/torture/rpc/drsuapi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/torture/rpc/drsuapi.c') diff --git a/source4/torture/rpc/drsuapi.c b/source4/torture/rpc/drsuapi.c index 29b6b0633b..ea7cf8d8bd 100644 --- a/source4/torture/rpc/drsuapi.c +++ b/source4/torture/rpc/drsuapi.c @@ -553,7 +553,7 @@ static BOOL test_DsGetNCChanges(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, 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_guid = null_guid; + 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; @@ -575,7 +575,7 @@ static BOOL test_DsGetNCChanges(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, 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_guid = null_guid; + 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; -- cgit From 334f78d206d37cbb5863af38cb5160d69fcd9183 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Mon, 11 Dec 2006 23:59:03 +0000 Subject: r20113: Update the DRSUAPI CrackNames test to explore a few more cases, and in particular to verify more expected results. Also return more details from the join process. Now we also return the machine account's GUID. Andrew Bartlett (This used to be commit 5b32f102af1fc7acb56bf7eaa40068d60a1ee396) --- source4/torture/rpc/drsuapi.c | 57 ++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 53 insertions(+), 4 deletions(-) (limited to 'source4/torture/rpc/drsuapi.c') diff --git a/source4/torture/rpc/drsuapi.c b/source4/torture/rpc/drsuapi.c index ea7cf8d8bd..fbe62ae7d4 100644 --- a/source4/torture/rpc/drsuapi.c +++ b/source4/torture/rpc/drsuapi.c @@ -60,7 +60,7 @@ BOOL test_DsBind(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, return ret; } -static BOOL test_DsGetDCInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +static BOOL test_DsGetDomainControllerInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct DsPrivate *priv) { NTSTATUS status; @@ -324,7 +324,7 @@ static BOOL test_DsReplicaGetInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, }; if (lp_parm_bool(-1, "torture", "samba4", False)) { - printf("skipping DsGetDCInfo test against Samba4\n"); + printf("skipping DsReplicaGetInfo test against Samba4\n"); return True; } @@ -684,9 +684,9 @@ BOOL torture_rpc_drsuapi(struct torture_context *torture) ret &= test_DsBind(p, mem_ctx, &priv); - ret &= test_DsGetDCInfo(p, mem_ctx, &priv); + ret &= test_DsGetDomainControllerInfo(p, mem_ctx, &priv); - ret &= test_DsCrackNames(p, mem_ctx, &priv, TEST_MACHINE_NAME); + ret &= test_DsCrackNames(p, mem_ctx, &priv); ret &= test_DsWriteAccountSpn(p, mem_ctx, &priv); @@ -707,3 +707,52 @@ BOOL torture_rpc_drsuapi(struct torture_context *torture) return ret; } + +BOOL torture_rpc_drsuapi_cracknames(struct torture_context *torture) +{ + NTSTATUS status; + struct dcerpc_pipe *p; + TALLOC_CTX *mem_ctx; + BOOL ret = True; + struct DsPrivate priv; + struct cli_credentials *machine_credentials; + + mem_ctx = talloc_init("torture_rpc_drsuapi"); + + printf("Connected to DRAUAPI pipe\n"); + + ZERO_STRUCT(priv); + + priv.join = torture_join_domain(TEST_MACHINE_NAME, ACB_SVRTRUST, + &machine_credentials); + if (!priv.join) { + talloc_free(mem_ctx); + printf("Failed to join as BDC\n"); + return False; + } + + status = torture_rpc_connection(mem_ctx, + &p, + &dcerpc_table_drsuapi); + if (!NT_STATUS_IS_OK(status)) { + torture_leave_domain(priv.join); + talloc_free(mem_ctx); + return False; + } + + ret &= test_DsBind(p, mem_ctx, &priv); + + if (ret) { + ret &= test_DsGetDomainControllerInfo(p, mem_ctx, &priv); + + ret &= test_DsCrackNames(p, mem_ctx, &priv); + + ret &= test_DsUnbind(p, mem_ctx, &priv); + } + talloc_free(mem_ctx); + + torture_leave_domain(priv.join); + + return ret; +} + -- cgit From 88ef4672826f05bd357a805673337ec22708d681 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 19 Dec 2006 13:38:42 +0000 Subject: r20251: I found out that the oid-prefix to uint32-id-prefix mapping is transferred in replication replies, but I don't know the exact encoding. for example the oids are transferred as: 2.5.4 => uint8_t v[] = { 0x55, 0x04 }; 2.5.5 => uint8_t v[] = { 0x55, 0x05 }; 2.5.6 => uint8_t v[] = { 0x55, 0x06 }; 2.5.18 => uint8_t v[] = { 0x55, 0x12 }; 2.5.20 => uint8_t v[] = { 0x55, 0x14 }; 2.5.21 => uint8_t v[] = { 0x55, 0x15 }; 1.2.840.113556.1.2 => uint8_t v[] = { 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x14, 0x01, 0x02 }; 1.2.840.113556.1.3 => uint8_t v[] = { 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x14, 0x01, 0x03 }; 1.2.840.113556.1.4 => uint8_t v[] = { 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x14, 0x01, 0x04 }; 1.2.840.113556.1.5 => uint8_t v[] = { 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x14, 0x01, 0x05 }; 1.2.840.113556.1.5.7000 => uint8_t v[] = { 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x14, 0x01, 0x05, 0xb6, 0x58 }; 1.2.840.113549.1.9 => uint8_t v[] = { 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x09 }; 2.16.840.1.113730.3 => uint8_t v[] = { 0x60, 0x86, 0x48, 0x01, 0x86, 0xf8, 0x42, 0x03 }; 2.16.840.1.113730.3.1 => uint8_t v[] = { 0x60, 0x86, 0x48, 0x01, 0x86, 0xf8, 0x42, 0x03, 0x01 }; 2.16.840.1.113730.3.2 => uint8_t v[] = { 0x60, 0x86, 0x48, 0x01, 0x86, 0xf8, 0x42, 0x03, 0x02 }; 0.9.2342.19200300.100.1 => uint8_t v[] = { 0x09, 0x92, 0x26, 0x89, 0x93, 0xf2, 0x2c, 0x64, 0x01 }; 0.9.2342.19200300.100.4 => uint8_t v[] = { 0x09, 0x92, 0x26, 0x89, 0x93, 0xf2, 0x2c, 0x64, 0x04 }; 1.3.6.1.4.1.250.1 => uint8_t v[] = { 0x2b, 0x06, 0x01, 0x04, 0x01, 0x81, 0x7a, 0x01 }; 1.3.6.1.4.1.1466.101.119=> uint8_t v[] = { 0x2b, 0x06, 0x01, 0x04, 0x01, 0x8b, 0x3a, 0x65, 0x77 }; if someone knows how the encoding works, please tell me:-) I assume some ASN.1 encoding... metze (This used to be commit aa720a15319392fee5c532959192d0df5bf4c718) --- source4/torture/rpc/drsuapi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/torture/rpc/drsuapi.c') diff --git a/source4/torture/rpc/drsuapi.c b/source4/torture/rpc/drsuapi.c index fbe62ae7d4..ef49b0443e 100644 --- a/source4/torture/rpc/drsuapi.c +++ b/source4/torture/rpc/drsuapi.c @@ -599,8 +599,8 @@ static BOOL test_DsGetNCChanges(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, r.in.req.req8.h1 = 0; r.in.req.req8.unique_ptr1 = 0; r.in.req.req8.unique_ptr2 = 0; - r.in.req.req8.ctr12.count = 0; - r.in.req.req8.ctr12.array = NULL; + r.in.req.req8.mapping_ctr.num_mappings = 0; + r.in.req.req8.mapping_ctr.mappings = NULL; break; } -- cgit From 400a56d6dd2f02569a626f4507ec06fa49cf0839 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Fri, 22 Dec 2006 07:04:06 +0000 Subject: r20315: Implement the server side of DsGetDomainControllerInfo. This is a supprisingly complex call... It turns out that the in/out parameter 'level' is not in/out, but set seperatly by the server-side code from r->req.req1.level. This commit also breaks out some common code from samldb into samdb. Andrew Bartlett (This used to be commit 2eb9e6445c64840399171f4f56b1e43786dbcfa7) --- source4/torture/rpc/drsuapi.c | 5 ----- 1 file changed, 5 deletions(-) (limited to 'source4/torture/rpc/drsuapi.c') diff --git a/source4/torture/rpc/drsuapi.c b/source4/torture/rpc/drsuapi.c index ef49b0443e..d876b079dd 100644 --- a/source4/torture/rpc/drsuapi.c +++ b/source4/torture/rpc/drsuapi.c @@ -67,11 +67,6 @@ static BOOL test_DsGetDomainControllerInfo(struct dcerpc_pipe *p, TALLOC_CTX *me struct drsuapi_DsGetDomainControllerInfo r; BOOL ret = True; - if (lp_parm_bool(-1, "torture", "samba4", False)) { - printf("skipping DsGetDCInfo test against Samba4\n"); - return True; - } - r.in.bind_handle = &priv->bind_handle; r.in.level = 1; -- cgit From ea4c64388bb00f41a083fb37a2689ae09f33399b Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Wed, 27 Dec 2006 02:01:38 +0000 Subject: r20353: Restructure the DRSUAPI DsGetDomainControllerInfo test, because as usual things are more complex than they appear. Also remove the incorrect server-side implementation, which blindly assumed some sense of consistancy across the API switch levels. Andrew Bartlett (This used to be commit 79941adbff843f5027dacd31b972deca4a1557ec) --- source4/torture/rpc/drsuapi.c | 222 ++++++++++++++++++++++++------------------ 1 file changed, 125 insertions(+), 97 deletions(-) (limited to 'source4/torture/rpc/drsuapi.c') diff --git a/source4/torture/rpc/drsuapi.c b/source4/torture/rpc/drsuapi.c index d876b079dd..3ce1d1053a 100644 --- a/source4/torture/rpc/drsuapi.c +++ b/source4/torture/rpc/drsuapi.c @@ -66,64 +66,119 @@ static BOOL test_DsGetDomainControllerInfo(struct dcerpc_pipe *p, TALLOC_CTX *me NTSTATUS status; struct drsuapi_DsGetDomainControllerInfo r; BOOL ret = True; + BOOL found = False; + int i, j, k; + + struct { + const char *name; + WERROR expected; + } names[] = { + { + .name = torture_join_dom_netbios_name(priv->join), + .expected = WERR_OK + }, + { + .name = torture_join_dom_dns_name(priv->join), + .expected = WERR_OK + }, + { + .name = "__UNKNOWN_DOMAIN__", + .expected = WERR_DS_OBJ_NOT_FOUND + }, + { + .name = "unknown.domain.samba.example.com", + .expected = WERR_DS_OBJ_NOT_FOUND + }, + }; + int levels[] = {1, 2}; + int level; + + for (i=0; i < ARRAY_SIZE(levels); i++) { + for (j=0; j < ARRAY_SIZE(names); j++) { + level = levels[i]; + r.in.bind_handle = &priv->bind_handle; + r.in.level = 1; + + r.in.req.req1.domain_name = names[j].name; + r.in.req.req1.level = level; + + printf("testing DsGetDomainControllerInfo level %d on domainname '%s'\n", + r.in.req.req1.level, r.in.req.req1.domain_name); + + status = dcerpc_drsuapi_DsGetDomainControllerInfo(p, mem_ctx, &r); + if (!NT_STATUS_IS_OK(status)) { + const char *errstr = nt_errstr(status); + if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { + errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); + } + printf("dcerpc_drsuapi_DsGetDomainControllerInfo level %d\n" + " with dns domain failed - %s\n", + r.in.req.req1.level, errstr); + ret = False; + } else if (!W_ERROR_EQUAL(r.out.result, names[j].expected)) { + printf("DsGetDomainControllerInfo level %d\n" + " with dns domain failed - %s, expected %s\n", + r.in.req.req1.level, win_errstr(r.out.result), + win_errstr(names[j].expected)); + ret = False; + } + + if (!W_ERROR_IS_OK(r.out.result)) { + /* If this was an error, we can't read the result structure */ + continue; + } - r.in.bind_handle = &priv->bind_handle; - r.in.level = 1; - - r.in.req.req1.domain_name = talloc_strdup(mem_ctx, lp_realm()); - 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); - - status = dcerpc_drsuapi_DsGetDomainControllerInfo(p, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - const char *errstr = nt_errstr(status); - if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { - errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); + if (r.in.req.req1.level != r.out.level_out) { + printf("dcerpc_drsuapi_DsGetDomainControllerInfo level in (%d) != out (%d)\n", + r.in.req.req1.level, r.out.level_out); + ret = False; + /* We can't safely read the result structure */ + continue; + } + 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, + torture_join_netbios_name(priv->join))) { + found = True; + } + } + break; + case 2: + if (r.out.ctr.ctr2.count > 0) { + priv->dcinfo = r.out.ctr.ctr2.array[0]; + } + 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))) { + found = True; + } + } + break; + } + if (!found) { + printf("dcerpc_drsuapi_DsGetDomainControllerInfo level %d: Failed to find the domain controller (%s) we just created during the join\n", + r.in.req.req1.level, + torture_join_netbios_name(priv->join)); + ret = False; + } } - printf("dcerpc_drsuapi_DsGetDomainControllerInfo level %d\n" - " with dns domain failed - %s\n", - r.in.req.req1.level, errstr); - ret = False; - } else if (!W_ERROR_IS_OK(r.out.result)) { - printf("DsGetDomainControllerInfo level %d\n" - " with dns domain failed - %s\n", - r.in.req.req1.level, win_errstr(r.out.result)); - ret = False; } - r.in.req.req1.level = 2; - - printf("testing DsGetDomainControllerInfo level %d on domainname '%s'\n", - r.in.req.req1.level, r.in.req.req1.domain_name); - - status = dcerpc_drsuapi_DsGetDomainControllerInfo(p, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - const char *errstr = nt_errstr(status); - if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { - errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); - } - printf("dcerpc_drsuapi_DsGetDomainControllerInfo level %d\n" - " with dns domain failed - %s\n", - r.in.req.req1.level, errstr); - ret = False; - } else if (!W_ERROR_IS_OK(r.out.result)) { - printf("DsGetDomainControllerInfo level %d\n" - " with dns domain failed - %s\n", - r.in.req.req1.level, win_errstr(r.out.result)); - ret = False; - } else { - if (r.out.ctr.ctr2.count > 0) { - priv->dcinfo = r.out.ctr.ctr2.array[0]; - } + if (lp_parm_bool(-1, "torture", "samba4", False)) { + printf("skipping DsGetDomainControllerInfo level -1 test against Samba4\n"); + return ret; } + 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; - + 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, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { const char *errstr = nt_errstr(status); @@ -131,62 +186,35 @@ static BOOL test_DsGetDomainControllerInfo(struct dcerpc_pipe *p, TALLOC_CTX *me errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); } printf("dcerpc_drsuapi_DsGetDomainControllerInfo level %d\n" - " with dns domain failed - %s\n", - r.in.req.req1.level, errstr); + " with dns domain failed - %s\n", + r.in.req.req1.level, errstr); ret = False; } else if (!W_ERROR_IS_OK(r.out.result)) { printf("DsGetDomainControllerInfo level %d\n" - " with dns domain failed - %s\n", - r.in.req.req1.level, win_errstr(r.out.result)); + " with dns domain failed - %s\n", + r.in.req.req1.level, win_errstr(r.out.result)); ret = False; } - - r.in.req.req1.domain_name = talloc_strdup(mem_ctx, lp_workgroup()); - r.in.req.req1.level = 2; - - printf("testing DsGetDomainControllerInfo level %d on domainname '%s'\n", - r.in.req.req1.level, r.in.req.req1.domain_name); - - status = dcerpc_drsuapi_DsGetDomainControllerInfo(p, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - const char *errstr = nt_errstr(status); - if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { - errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); + + { + const char *dc_account = talloc_asprintf(mem_ctx, "%s\\%s$", + torture_join_dom_netbios_name(priv->join), + priv->dcinfo.netbios_name); + for (k=0; k < r.out.ctr.ctr1.count; k++) { + if (strcasecmp_m(r.out.ctr.ctr01.array[k].nt4_account, + dc_account)) { + found = True; + } } - printf("dcerpc_drsuapi_DsGetDomainControllerInfo level %d\n" - " with netbios domain failed - %s\n", - r.in.req.req1.level, errstr); - ret = False; - } else if (!W_ERROR_IS_OK(r.out.result)) { - printf("DsGetDomainControllerInfo level %d\n" - " with netbios domain failed - %s\n", - r.in.req.req1.level, win_errstr(r.out.result)); - ret = False; - } - - r.in.req.req1.domain_name = "__UNKNOWN_DOMAIN__"; - r.in.req.req1.level = 2; - - printf("testing DsGetDomainControllerInfo level %d on domainname '%s'\n", - r.in.req.req1.level, r.in.req.req1.domain_name); - - status = dcerpc_drsuapi_DsGetDomainControllerInfo(p, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - const char *errstr = nt_errstr(status); - if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { - errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); + if (!found) { + printf("dcerpc_drsuapi_DsGetDomainControllerInfo level %d: Failed to find the domain controller (%s) in last logon records\n", + r.in.req.req1.level, + dc_account); + ret = False; } - printf("dcerpc_drsuapi_DsGetDomainControllerInfo level %d\n" - " with invalid domain failed - %s\n", - r.in.req.req1.level, errstr); - ret = False; - } else if (!W_ERROR_EQUAL(r.out.result, WERR_DS_OBJ_NOT_FOUND)) { - printf("DsGetDomainControllerInfo level %d\n" - " with invalid domain not expected error (WERR_DS_OBJ_NOT_FOUND) - %s\n", - r.in.req.req1.level, win_errstr(r.out.result)); - ret = False; } + return ret; } -- cgit From c70a3f6706c9f7ec45ec805052687dd70eb89c6b Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 27 Dec 2006 17:57:20 +0000 Subject: r20359: level -1 of DsGetDomainControllerInfo gives back a list of all active connections to the Directory Service Agent (DSA) (This can be LDAP or DRSUAPI connections) abartlet: you had just luck by using flag(BIG_ENDIAN) as BIG_ENDIAN is defined in , it should be flag(NDR_BIG_ENDIAN)... metze (This used to be commit c7e639763de1f8ddccfb954227feeaddb7386edc) --- source4/torture/rpc/drsuapi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/torture/rpc/drsuapi.c') diff --git a/source4/torture/rpc/drsuapi.c b/source4/torture/rpc/drsuapi.c index 3ce1d1053a..9a306e7392 100644 --- a/source4/torture/rpc/drsuapi.c +++ b/source4/torture/rpc/drsuapi.c @@ -200,8 +200,8 @@ static BOOL test_DsGetDomainControllerInfo(struct dcerpc_pipe *p, TALLOC_CTX *me const char *dc_account = talloc_asprintf(mem_ctx, "%s\\%s$", torture_join_dom_netbios_name(priv->join), priv->dcinfo.netbios_name); - for (k=0; k < r.out.ctr.ctr1.count; k++) { - if (strcasecmp_m(r.out.ctr.ctr01.array[k].nt4_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; } -- cgit From d0bc792dba8d4ae1da92abfeca5fb4be5a23b909 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Wed, 27 Dec 2006 23:54:40 +0000 Subject: r20369: Remember to break if we find a match. Andrew Bartlett (This used to be commit 4bd8dbcf41f04be28e2f5d6e15a22f08ba80b948) --- source4/torture/rpc/drsuapi.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'source4/torture/rpc/drsuapi.c') diff --git a/source4/torture/rpc/drsuapi.c b/source4/torture/rpc/drsuapi.c index 9a306e7392..ed4bc1b175 100644 --- a/source4/torture/rpc/drsuapi.c +++ b/source4/torture/rpc/drsuapi.c @@ -5,7 +5,7 @@ Copyright (C) Andrew Tridgell 2003 Copyright (C) Stefan (metze) Metzmacher 2004 - Copyright (C) Andrew Bartlett 2005 + Copyright (C) Andrew Bartlett 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 @@ -152,6 +152,7 @@ static BOOL test_DsGetDomainControllerInfo(struct dcerpc_pipe *p, TALLOC_CTX *me if (strcasecmp_m(r.out.ctr.ctr2.array[k].netbios_name, torture_join_netbios_name(priv->join))) { found = True; + break; } } break; @@ -204,6 +205,7 @@ static BOOL test_DsGetDomainControllerInfo(struct dcerpc_pipe *p, TALLOC_CTX *me if (strcasecmp_m(r.out.ctr.ctr01.array[k].client_account, dc_account)) { found = True; + break; } } if (!found) { -- cgit From bc32b30011ec0b35d40f659675f9e4cc28ec3c79 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 3 Jan 2007 15:18:17 +0000 Subject: r20510: fix spelling metze (This used to be commit 58066e2252001b7689705d296a16438733cfdfc4) --- source4/torture/rpc/drsuapi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/torture/rpc/drsuapi.c') diff --git a/source4/torture/rpc/drsuapi.c b/source4/torture/rpc/drsuapi.c index ed4bc1b175..619c0c2970 100644 --- a/source4/torture/rpc/drsuapi.c +++ b/source4/torture/rpc/drsuapi.c @@ -339,7 +339,7 @@ static BOOL test_DsReplicaGetInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, "__IGNORED__" },{ DRSUAPI_DS_REPLICA_GET_INFO2, - DRSUAPI_DS_REPLICA_INFO_CURSURS05, + DRSUAPI_DS_REPLICA_INFO_CURSORS05, NULL },{ DRSUAPI_DS_REPLICA_GET_INFO2, -- cgit From e8d2437cd570d8cbfaca7c07305831c29e260450 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 11 Jan 2007 04:12:35 +0000 Subject: r20676: Add ref pointer to fix warning. (This used to be commit 1afcf850679b6752935455a8f9198679649922b8) --- source4/torture/rpc/drsuapi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/torture/rpc/drsuapi.c') diff --git a/source4/torture/rpc/drsuapi.c b/source4/torture/rpc/drsuapi.c index 619c0c2970..0f849e5586 100644 --- a/source4/torture/rpc/drsuapi.c +++ b/source4/torture/rpc/drsuapi.c @@ -569,9 +569,9 @@ static BOOL test_DsGetNCChanges(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, array[i].level); r.in.bind_handle = &priv->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; -- cgit From d0f989628a777943c7c0b1f306e967cc4ba7a63f Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 13 Mar 2007 11:10:48 +0000 Subject: r21817: give fields a meaning metze (This used to be commit 521355b57b74dbdccc6ae15738345e1d989ce262) --- source4/torture/rpc/drsuapi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/torture/rpc/drsuapi.c') diff --git a/source4/torture/rpc/drsuapi.c b/source4/torture/rpc/drsuapi.c index 0f849e5586..c0ed2953f2 100644 --- a/source4/torture/rpc/drsuapi.c +++ b/source4/torture/rpc/drsuapi.c @@ -448,8 +448,8 @@ static BOOL test_DsReplicaSync(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, nc.dn = priv->domain_obj_dn?priv->domain_obj_dn:""; r.in.req.req1.naming_context = &nc; - r.in.req.req1.guid1 = priv->dcinfo.ntds_guid; - r.in.req.req1.string1 = NULL; + r.in.req.req1.source_dsa_guid = priv->dcinfo.ntds_guid; + r.in.req.req1.other_info = NULL; r.in.req.req1.options = 16; break; } -- cgit From d0179f164a498f23b1acd726ba7e806afee4c15b Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Sat, 7 Apr 2007 05:14:23 +0000 Subject: r22120: Expand the RPC-CRACKNAMES test, to test more values and expose patterns. Fix up our server side implementation to pass almost all the tests (a couple are skipped). Don't require the DsGetDomainControllerInfo calls to pass, just get some info from them. Andrew Bartlett (This used to be commit a29eb8f7e541d2021726601faf52355e312c916b) --- source4/torture/rpc/drsuapi.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'source4/torture/rpc/drsuapi.c') diff --git a/source4/torture/rpc/drsuapi.c b/source4/torture/rpc/drsuapi.c index c0ed2953f2..0129fe9b63 100644 --- a/source4/torture/rpc/drsuapi.c +++ b/source4/torture/rpc/drsuapi.c @@ -686,8 +686,6 @@ BOOL torture_rpc_drsuapi(struct torture_context *torture) mem_ctx = talloc_init("torture_rpc_drsuapi"); - printf("Connected to DRAUAPI pipe\n"); - ZERO_STRUCT(priv); priv.join = torture_join_domain(TEST_MACHINE_NAME, ACB_SVRTRUST, @@ -768,7 +766,8 @@ BOOL torture_rpc_drsuapi_cracknames(struct torture_context *torture) ret &= test_DsBind(p, mem_ctx, &priv); if (ret) { - ret &= test_DsGetDomainControllerInfo(p, mem_ctx, &priv); + /* We don't care if this fails, we just need some info from it */ + test_DsGetDomainControllerInfo(p, mem_ctx, &priv); ret &= test_DsCrackNames(p, mem_ctx, &priv); -- cgit From 5a616802ff076814f0a105d64a469365aea6910a Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 27 Apr 2007 17:35:15 +0000 Subject: r22538: same day late at night in au...:-) fix the strcasecmp_m() returns 0 for a match also use the correct array element to fill priv->dcinfo the fixes the problems where ldb changes the order of the search results when changing the main dc netbios name from "localhost" to "localtest" metze (This used to be commit 25fffe385ea039ae19f25730cba6c7ea8684860b) --- source4/torture/rpc/drsuapi.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'source4/torture/rpc/drsuapi.c') diff --git a/source4/torture/rpc/drsuapi.c b/source4/torture/rpc/drsuapi.c index 0129fe9b63..338d2ad759 100644 --- a/source4/torture/rpc/drsuapi.c +++ b/source4/torture/rpc/drsuapi.c @@ -139,19 +139,18 @@ static BOOL test_DsGetDomainControllerInfo(struct dcerpc_pipe *p, TALLOC_CTX *me case 1: 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))) { + torture_join_netbios_name(priv->join)) == 0) { found = True; + break; } } break; case 2: - if (r.out.ctr.ctr2.count > 0) { - priv->dcinfo = r.out.ctr.ctr2.array[0]; - } 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))) { + torture_join_netbios_name(priv->join)) == 0) { found = True; + priv->dcinfo = r.out.ctr.ctr2.array[k]; break; } } -- cgit From 4d1a21f24d9d2f4326e380cadb24c842c2dfb688 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Wed, 30 May 2007 09:54:19 +0000 Subject: r23239: Fill in drsuapi_QuerySitesByCost. Guenther (This used to be commit cf953d04813d193da5e9714ceebb7826dc7e4d0b) --- source4/torture/rpc/drsuapi.c | 59 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 58 insertions(+), 1 deletion(-) (limited to 'source4/torture/rpc/drsuapi.c') diff --git a/source4/torture/rpc/drsuapi.c b/source4/torture/rpc/drsuapi.c index 338d2ad759..37c566020b 100644 --- a/source4/torture/rpc/drsuapi.c +++ b/source4/torture/rpc/drsuapi.c @@ -646,6 +646,61 @@ static BOOL test_DsGetNCChanges(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, return ret; } +BOOL test_QuerySitesByCost(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, + struct DsPrivate *priv) +{ + NTSTATUS status; + struct drsuapi_QuerySitesByCost r; + BOOL ret = True; + + const char *my_site = "Default-First-Site-Name"; + const char *remote_site1 = "smbtorture-nonexisting-site1"; + const char *remote_site2 = "smbtorture-nonexisting-site2"; + + r.in.bind_handle = &priv->bind_handle; + r.in.level = 1; + r.in.req.req1.site_from = talloc_strdup(mem_ctx, my_site); + r.in.req.req1.num_req = 2; + r.in.req.req1.site_to = talloc_zero_array(mem_ctx, const char *, r.in.req.req1.num_req); + r.in.req.req1.site_to[0] = talloc_strdup(mem_ctx, remote_site1); + r.in.req.req1.site_to[1] = talloc_strdup(mem_ctx, remote_site2); + r.in.req.req1.flags = 0; + + status = dcerpc_drsuapi_QuerySitesByCost(p, mem_ctx, &r); + if (!NT_STATUS_IS_OK(status)) { + const char *errstr = nt_errstr(status); + if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { + errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); + } + printf("drsuapi_QuerySitesByCost - %s\n", errstr); + ret = False; + } else if (!W_ERROR_IS_OK(r.out.result)) { + printf("QuerySitesByCost failed - %s\n", win_errstr(r.out.result)); + ret = False; + } + + if (W_ERROR_IS_OK(r.out.result)) { + + if (!W_ERROR_EQUAL(r.out.ctr.ctr1.info[0].error_code, WERR_DS_OBJ_NOT_FOUND) || + !W_ERROR_EQUAL(r.out.ctr.ctr1.info[1].error_code, WERR_DS_OBJ_NOT_FOUND)) { + printf("expected error_code WERR_DS_OBJ_NOT_FOUND, got %s\n", + win_errstr(r.out.ctr.ctr1.info[0].error_code)); + ret = False; + } + + if ((r.out.ctr.ctr1.info[0].site_cost != (uint32_t) -1) || + (r.out.ctr.ctr1.info[1].site_cost != (uint32_t) -1)) { + printf("expected site_cost %d, got %d\n", + (uint32_t) -1, r.out.ctr.ctr1.info[0].site_cost); + ret = False; + } + } + + return ret; + + +} + BOOL test_DsUnbind(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct DsPrivate *priv) { @@ -705,7 +760,9 @@ BOOL torture_rpc_drsuapi(struct torture_context *torture) } ret &= test_DsBind(p, mem_ctx, &priv); - +#if 0 + ret &= test_QuerySitesByCost(p, mem_ctx, &priv); +#endif ret &= test_DsGetDomainControllerInfo(p, mem_ctx, &priv); ret &= test_DsCrackNames(p, mem_ctx, &priv); -- cgit From 0479a2f1cbae51fcd8dbdc3c148c808421fb4d25 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 10 Jul 2007 02:07:03 +0000 Subject: r23792: convert Samba4 to GPLv3 There are still a few tidyups of old FSF addresses to come (in both s3 and s4). More commits soon. (This used to be commit fcf38a38ac691abd0fa51b89dc951a08e89fdafa) --- source4/torture/rpc/drsuapi.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'source4/torture/rpc/drsuapi.c') diff --git a/source4/torture/rpc/drsuapi.c b/source4/torture/rpc/drsuapi.c index 37c566020b..5b2e92cf36 100644 --- a/source4/torture/rpc/drsuapi.c +++ b/source4/torture/rpc/drsuapi.c @@ -9,7 +9,7 @@ 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 2 of the License, or + 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, @@ -18,8 +18,7 @@ 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, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + along with this program. If not, see . */ #include "includes.h" -- cgit From f14bd1a90ab47a418c0ec2492990a417a0bb3bf6 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sun, 19 Aug 2007 21:23:03 +0000 Subject: r24557: rename 'dcerpc_table_' -> 'ndr_table_' metze (This used to be commit 84651aee81aaabbebf52ffc3fbcbabb2eec6eed5) --- source4/torture/rpc/drsuapi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/torture/rpc/drsuapi.c') diff --git a/source4/torture/rpc/drsuapi.c b/source4/torture/rpc/drsuapi.c index 5b2e92cf36..5e4ac3321f 100644 --- a/source4/torture/rpc/drsuapi.c +++ b/source4/torture/rpc/drsuapi.c @@ -751,7 +751,7 @@ BOOL torture_rpc_drsuapi(struct torture_context *torture) status = torture_rpc_connection(mem_ctx, &p, - &dcerpc_table_drsuapi); + &ndr_table_drsuapi); if (!NT_STATUS_IS_OK(status)) { torture_leave_domain(priv.join); talloc_free(mem_ctx); @@ -811,7 +811,7 @@ BOOL torture_rpc_drsuapi_cracknames(struct torture_context *torture) status = torture_rpc_connection(mem_ctx, &p, - &dcerpc_table_drsuapi); + &ndr_table_drsuapi); if (!NT_STATUS_IS_OK(status)) { torture_leave_domain(priv.join); talloc_free(mem_ctx); -- cgit From 919aa6b27e5fe49b70c814210aa026c19be66e8a Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 28 Aug 2007 12:54:27 +0000 Subject: r24735: Use torture API in more places. (This used to be commit 1319d88c099496be29dd9214fa2492c81e848369) --- source4/torture/rpc/drsuapi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/torture/rpc/drsuapi.c') diff --git a/source4/torture/rpc/drsuapi.c b/source4/torture/rpc/drsuapi.c index 5e4ac3321f..606240993f 100644 --- a/source4/torture/rpc/drsuapi.c +++ b/source4/torture/rpc/drsuapi.c @@ -749,7 +749,7 @@ BOOL torture_rpc_drsuapi(struct torture_context *torture) return False; } - status = torture_rpc_connection(mem_ctx, + status = torture_rpc_connection(torture, &p, &ndr_table_drsuapi); if (!NT_STATUS_IS_OK(status)) { @@ -809,7 +809,7 @@ BOOL torture_rpc_drsuapi_cracknames(struct torture_context *torture) return False; } - status = torture_rpc_connection(mem_ctx, + status = torture_rpc_connection(torture, &p, &ndr_table_drsuapi); if (!NT_STATUS_IS_OK(status)) { -- cgit From 2a8ff00eea6c1e5e0565306435a3b454903dcbb4 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 31 Aug 2007 13:30:47 +0000 Subject: r24835: Put all RPC tests in the list (skipping when necessary), warn if tests aren't there. (This used to be commit 1ff13ae254288afc56a3b19d00c7a20120eb4c74) --- source4/torture/rpc/drsuapi.c | 165 ++++++++++++++---------------------------- 1 file changed, 55 insertions(+), 110 deletions(-) (limited to 'source4/torture/rpc/drsuapi.c') diff --git a/source4/torture/rpc/drsuapi.c b/source4/torture/rpc/drsuapi.c index 606240993f..509bdad353 100644 --- a/source4/torture/rpc/drsuapi.c +++ b/source4/torture/rpc/drsuapi.c @@ -28,12 +28,11 @@ #define TEST_MACHINE_NAME "torturetest" -BOOL test_DsBind(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +bool test_DsBind(struct dcerpc_pipe *p, struct torture_context *tctx, struct DsPrivate *priv) { NTSTATUS status; struct drsuapi_DsBind r; - BOOL ret = True; GUID_from_string(DRSUAPI_DS_BIND_GUID, &priv->bind_guid); @@ -41,30 +40,27 @@ BOOL test_DsBind(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, r.in.bind_info = NULL; r.out.bind_handle = &priv->bind_handle; - printf("testing DsBind\n"); + torture_comment(tctx, "testing DsBind\n"); - status = dcerpc_drsuapi_DsBind(p, mem_ctx, &r); + status = dcerpc_drsuapi_DsBind(p, tctx, &r); if (!NT_STATUS_IS_OK(status)) { const char *errstr = nt_errstr(status); if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { - errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); + errstr = dcerpc_errstr(tctx, p->last_fault_code); } - printf("dcerpc_drsuapi_DsBind failed - %s\n", errstr); - ret = False; + torture_fail(tctx, "dcerpc_drsuapi_DsBind failed"); } else if (!W_ERROR_IS_OK(r.out.result)) { - printf("DsBind failed - %s\n", win_errstr(r.out.result)); - ret = False; + torture_fail(tctx, "DsBind failed"); } - return ret; + return true; } -static BOOL test_DsGetDomainControllerInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +static bool test_DsGetDomainControllerInfo(struct dcerpc_pipe *p, struct torture_context *torture, struct DsPrivate *priv) { NTSTATUS status; struct drsuapi_DsGetDomainControllerInfo r; - BOOL ret = True; BOOL found = False; int i, j, k; @@ -101,39 +97,26 @@ static BOOL test_DsGetDomainControllerInfo(struct dcerpc_pipe *p, TALLOC_CTX *me r.in.req.req1.domain_name = names[j].name; r.in.req.req1.level = level; - printf("testing DsGetDomainControllerInfo level %d on domainname '%s'\n", + torture_comment(torture, + "testing DsGetDomainControllerInfo level %d on domainname '%s'\n", r.in.req.req1.level, r.in.req.req1.domain_name); - status = dcerpc_drsuapi_DsGetDomainControllerInfo(p, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - const char *errstr = nt_errstr(status); - if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { - errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); - } - printf("dcerpc_drsuapi_DsGetDomainControllerInfo level %d\n" - " with dns domain failed - %s\n", - r.in.req.req1.level, errstr); - ret = False; - } else if (!W_ERROR_EQUAL(r.out.result, names[j].expected)) { - printf("DsGetDomainControllerInfo level %d\n" - " with dns domain failed - %s, expected %s\n", - r.in.req.req1.level, win_errstr(r.out.result), - win_errstr(names[j].expected)); - ret = False; - } + status = dcerpc_drsuapi_DsGetDomainControllerInfo(p, torture, &r); + torture_assert_ntstatus_ok(torture, status, + "dcerpc_drsuapi_DsGetDomainControllerInfo with dns domain failed"); + torture_assert_werr_equal(torture, + r.out.result, names[j].expected, + "DsGetDomainControllerInfo level with dns domain failed"); if (!W_ERROR_IS_OK(r.out.result)) { /* If this was an error, we can't read the result structure */ continue; } - if (r.in.req.req1.level != r.out.level_out) { - printf("dcerpc_drsuapi_DsGetDomainControllerInfo level in (%d) != out (%d)\n", - r.in.req.req1.level, r.out.level_out); - ret = False; - /* We can't safely read the result structure */ - continue; - } + torture_assert_int_equal(torture, + 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++) { @@ -155,20 +138,11 @@ static BOOL test_DsGetDomainControllerInfo(struct dcerpc_pipe *p, TALLOC_CTX *me } break; } - if (!found) { - printf("dcerpc_drsuapi_DsGetDomainControllerInfo level %d: Failed to find the domain controller (%s) we just created during the join\n", - r.in.req.req1.level, - torture_join_netbios_name(priv->join)); - ret = False; - } + torture_assert(torture, found, + "dcerpc_drsuapi_DsGetDomainControllerInfo: Failed to find the domain controller we just created during the join"); } } - if (lp_parm_bool(-1, "torture", "samba4", False)) { - printf("skipping DsGetDomainControllerInfo level -1 test against Samba4\n"); - return ret; - } - r.in.bind_handle = &priv->bind_handle; r.in.level = 1; @@ -178,25 +152,15 @@ static BOOL test_DsGetDomainControllerInfo(struct dcerpc_pipe *p, TALLOC_CTX *me printf("testing DsGetDomainControllerInfo level %d on domainname '%s'\n", r.in.req.req1.level, r.in.req.req1.domain_name); - status = dcerpc_drsuapi_DsGetDomainControllerInfo(p, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - const char *errstr = nt_errstr(status); - if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { - errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); - } - printf("dcerpc_drsuapi_DsGetDomainControllerInfo level %d\n" - " with dns domain failed - %s\n", - r.in.req.req1.level, errstr); - ret = False; - } else if (!W_ERROR_IS_OK(r.out.result)) { - printf("DsGetDomainControllerInfo level %d\n" - " with dns domain failed - %s\n", - r.in.req.req1.level, win_errstr(r.out.result)); - ret = False; - } + status = dcerpc_drsuapi_DsGetDomainControllerInfo(p, torture, &r); + + torture_assert_ntstatus_ok(torture, status, + "dcerpc_drsuapi_DsGetDomainControllerInfo with dns domain failed"); + torture_assert_werr_ok(torture, r.out.result, + "DsGetDomainControllerInfo with dns domain failed"); { - const char *dc_account = talloc_asprintf(mem_ctx, "%s\\%s$", + 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++) { @@ -206,16 +170,12 @@ static BOOL test_DsGetDomainControllerInfo(struct dcerpc_pipe *p, TALLOC_CTX *me break; } } - if (!found) { - printf("dcerpc_drsuapi_DsGetDomainControllerInfo level %d: Failed to find the domain controller (%s) in last logon records\n", - r.in.req.req1.level, - dc_account); - ret = False; - } + torture_assert(torture, found, + "dcerpc_drsuapi_DsGetDomainControllerInfo level: Failed to find the domain controller in last logon records"); } - return ret; + return true; } static BOOL test_DsWriteAccountSpn(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, @@ -728,25 +688,20 @@ BOOL test_DsUnbind(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, return ret; } -BOOL torture_rpc_drsuapi(struct torture_context *torture) +bool torture_rpc_drsuapi(struct torture_context *torture) { NTSTATUS status; struct dcerpc_pipe *p; - TALLOC_CTX *mem_ctx; - BOOL ret = True; + bool ret = true; struct DsPrivate priv; struct cli_credentials *machine_credentials; - mem_ctx = talloc_init("torture_rpc_drsuapi"); - ZERO_STRUCT(priv); priv.join = torture_join_domain(TEST_MACHINE_NAME, ACB_SVRTRUST, &machine_credentials); if (!priv.join) { - talloc_free(mem_ctx); - printf("Failed to join as BDC\n"); - return False; + torture_fail(torture, "Failed to join as BDC"); } status = torture_rpc_connection(torture, @@ -754,31 +709,28 @@ BOOL torture_rpc_drsuapi(struct torture_context *torture) &ndr_table_drsuapi); if (!NT_STATUS_IS_OK(status)) { torture_leave_domain(priv.join); - talloc_free(mem_ctx); - return False; + torture_fail(torture, "Unable to connect to DRSUAPI pipe"); } - ret &= test_DsBind(p, mem_ctx, &priv); + ret &= test_DsBind(p, torture, &priv); #if 0 - ret &= test_QuerySitesByCost(p, mem_ctx, &priv); + ret &= test_QuerySitesByCost(p, torture, &priv); #endif - ret &= test_DsGetDomainControllerInfo(p, mem_ctx, &priv); - - ret &= test_DsCrackNames(p, mem_ctx, &priv); + ret &= test_DsGetDomainControllerInfo(p, torture, &priv); - ret &= test_DsWriteAccountSpn(p, mem_ctx, &priv); + ret &= test_DsCrackNames(p, torture, &priv); - ret &= test_DsReplicaGetInfo(p, mem_ctx, &priv); + ret &= test_DsWriteAccountSpn(p, torture, &priv); - ret &= test_DsReplicaSync(p, mem_ctx, &priv); + ret &= test_DsReplicaGetInfo(p, torture, &priv); - ret &= test_DsReplicaUpdateRefs(p, mem_ctx, &priv); + ret &= test_DsReplicaSync(p, torture, &priv); - ret &= test_DsGetNCChanges(p, mem_ctx, &priv); + ret &= test_DsReplicaUpdateRefs(p, torture, &priv); - ret &= test_DsUnbind(p, mem_ctx, &priv); + ret &= test_DsGetNCChanges(p, torture, &priv); - talloc_free(mem_ctx); + ret &= test_DsUnbind(p, torture, &priv); torture_leave_domain(priv.join); @@ -786,27 +738,22 @@ BOOL torture_rpc_drsuapi(struct torture_context *torture) } -BOOL torture_rpc_drsuapi_cracknames(struct torture_context *torture) +bool torture_rpc_drsuapi_cracknames(struct torture_context *torture) { NTSTATUS status; struct dcerpc_pipe *p; - TALLOC_CTX *mem_ctx; - BOOL ret = True; + bool ret = true; struct DsPrivate priv; struct cli_credentials *machine_credentials; - mem_ctx = talloc_init("torture_rpc_drsuapi"); - - printf("Connected to DRAUAPI pipe\n"); + torture_comment(torture, "Connected to DRSUAPI pipe\n"); ZERO_STRUCT(priv); priv.join = torture_join_domain(TEST_MACHINE_NAME, ACB_SVRTRUST, &machine_credentials); if (!priv.join) { - talloc_free(mem_ctx); - printf("Failed to join as BDC\n"); - return False; + torture_fail(torture, "Failed to join as BDC\n"); } status = torture_rpc_connection(torture, @@ -814,21 +761,19 @@ BOOL torture_rpc_drsuapi_cracknames(struct torture_context *torture) &ndr_table_drsuapi); if (!NT_STATUS_IS_OK(status)) { torture_leave_domain(priv.join); - talloc_free(mem_ctx); - return False; + torture_fail(torture, "Unable to connect to DRSUAPI pipe"); } - ret &= test_DsBind(p, mem_ctx, &priv); + ret &= test_DsBind(p, torture, &priv); if (ret) { /* We don't care if this fails, we just need some info from it */ - test_DsGetDomainControllerInfo(p, mem_ctx, &priv); + test_DsGetDomainControllerInfo(p, torture, &priv); - ret &= test_DsCrackNames(p, mem_ctx, &priv); + ret &= test_DsCrackNames(p, torture, &priv); - ret &= test_DsUnbind(p, mem_ctx, &priv); + ret &= test_DsUnbind(p, torture, &priv); } - talloc_free(mem_ctx); torture_leave_domain(priv.join); -- cgit From 9e35f00c63462c7e43ade2d3b770b6247b083a46 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 31 Aug 2007 15:29:38 +0000 Subject: r24844: Convert to torture API in preparation of helper functions for domain member RPC tests. (This used to be commit c2521453a902ea5fd4f894a21af711ac2b2cbd40) --- source4/torture/rpc/drsuapi.c | 275 ++++++++++++++---------------------------- 1 file changed, 91 insertions(+), 184 deletions(-) (limited to 'source4/torture/rpc/drsuapi.c') diff --git a/source4/torture/rpc/drsuapi.c b/source4/torture/rpc/drsuapi.c index 509bdad353..a9c7adc70b 100644 --- a/source4/torture/rpc/drsuapi.c +++ b/source4/torture/rpc/drsuapi.c @@ -56,8 +56,9 @@ bool test_DsBind(struct dcerpc_pipe *p, struct torture_context *tctx, return true; } -static bool test_DsGetDomainControllerInfo(struct dcerpc_pipe *p, struct torture_context *torture, - struct DsPrivate *priv) +static bool test_DsGetDomainControllerInfo(struct dcerpc_pipe *p, + struct torture_context *torture, + struct DsPrivate *priv) { NTSTATUS status; struct drsuapi_DsGetDomainControllerInfo r; @@ -114,8 +115,8 @@ static bool test_DsGetDomainControllerInfo(struct dcerpc_pipe *p, struct torture } torture_assert_int_equal(torture, - r.in.req.req1.level, r.out.level_out, - "dcerpc_drsuapi_DsGetDomainControllerInfo level"); + r.in.req.req1.level, r.out.level_out, + "dcerpc_drsuapi_DsGetDomainControllerInfo level"); switch (level) { case 1: @@ -149,7 +150,8 @@ static bool test_DsGetDomainControllerInfo(struct dcerpc_pipe *p, struct torture 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", + torture_comment(torture, + "testing DsGetDomainControllerInfo level %d on domainname '%s'\n", r.in.req.req1.level, r.in.req.req1.domain_name); status = dcerpc_drsuapi_DsGetDomainControllerInfo(p, torture, &r); @@ -178,65 +180,49 @@ static bool test_DsGetDomainControllerInfo(struct dcerpc_pipe *p, struct torture return true; } -static BOOL test_DsWriteAccountSpn(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +static bool test_DsWriteAccountSpn(struct dcerpc_pipe *p, + struct torture_context *tctx, struct DsPrivate *priv) { NTSTATUS status; struct drsuapi_DsWriteAccountSpn r; struct drsuapi_DsNameString names[2]; - BOOL ret = True; r.in.bind_handle = &priv->bind_handle; r.in.level = 1; - printf("testing DsWriteAccountSpn\n"); + torture_comment(tctx, "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; - 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); + names[0].str = talloc_asprintf(tctx, "smbtortureSPN/%s",priv->dcinfo.netbios_name); + names[1].str = talloc_asprintf(tctx, "smbtortureSPN/%s",priv->dcinfo.dns_name); - status = dcerpc_drsuapi_DsWriteAccountSpn(p, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - const char *errstr = nt_errstr(status); - if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { - errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); - } - printf("dcerpc_drsuapi_DsWriteAccountSpn failed - %s\n", errstr); - ret = False; - } else if (!W_ERROR_IS_OK(r.out.result)) { - printf("DsWriteAccountSpn failed - %s\n", win_errstr(r.out.result)); - ret = False; - } + status = dcerpc_drsuapi_DsWriteAccountSpn(p, tctx, &r); + torture_assert_ntstatus_ok(tctx, status, + "dcerpc_drsuapi_DsWriteAccountSpn failed"); + torture_assert_werr_ok(tctx, r.out.result, "DsWriteAccountSpn failed"); 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)) { - const char *errstr = nt_errstr(status); - if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { - errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); - } - printf("dcerpc_drsuapi_DsWriteAccountSpn failed - %s\n", errstr); - ret = False; - } else if (!W_ERROR_IS_OK(r.out.result)) { - printf("DsWriteAccountSpn failed - %s\n", win_errstr(r.out.result)); - ret = False; - } + status = dcerpc_drsuapi_DsWriteAccountSpn(p, tctx, &r); + torture_assert_ntstatus_ok(tctx, status, + "dcerpc_drsuapi_DsWriteAccountSpn failed"); + torture_assert_werr_ok(tctx, r.out.result, "DsWriteAccountSpn failed"); - return ret; + return true; } -static BOOL test_DsReplicaGetInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, - struct DsPrivate *priv) +static bool test_DsReplicaGetInfo(struct dcerpc_pipe *p, + struct torture_context *tctx, + struct DsPrivate *priv) { NTSTATUS status; struct drsuapi_DsReplicaGetInfo r; - BOOL ret = True; int i; struct { int32_t level; @@ -306,17 +292,13 @@ static BOOL test_DsReplicaGetInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, } }; - if (lp_parm_bool(-1, "torture", "samba4", False)) { - printf("skipping DsReplicaGetInfo test against Samba4\n"); - return True; - } - r.in.bind_handle = &priv->bind_handle; for (i=0; i < ARRAY_SIZE(array); i++) { const char *object_dn; - printf("testing DsReplicaGetInfo level %d infotype %d\n", + torture_comment(tctx, + "testing DsReplicaGetInfo level %d infotype %d\n", array[i].level, array[i].infotype); object_dn = (array[i].obj_dn ? array[i].obj_dn : priv->domain_obj_dn); @@ -339,33 +321,21 @@ static BOOL test_DsReplicaGetInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, break; } - status = dcerpc_drsuapi_DsReplicaGetInfo(p, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - const char *errstr = nt_errstr(status); - if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { - errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); - } - if (p->last_fault_code != DCERPC_FAULT_INVALID_TAG) { - printf("dcerpc_drsuapi_DsReplicaGetInfo failed - %s\n", errstr); - ret = False; - } else { - printf("DsReplicaGetInfo level %d and/or infotype %d not supported by server\n", - array[i].level, array[i].infotype); - } - } else if (!W_ERROR_IS_OK(r.out.result)) { - printf("DsReplicaGetInfo failed - %s\n", win_errstr(r.out.result)); - ret = False; - } + status = dcerpc_drsuapi_DsReplicaGetInfo(p, tctx, &r); + torture_assert_ntstatus_ok(tctx, status, + "dcerpc_drsuapi_DsReplicaGetInfo failed"); + torture_assert_werr_ok(tctx, r.out.result, + "DsReplicaGetInfo failed"); } - return ret; + return true; } -static BOOL test_DsReplicaSync(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, - struct DsPrivate *priv) +static bool test_DsReplicaSync(struct dcerpc_pipe *p, + struct torture_context *tctx, + struct DsPrivate *priv) { NTSTATUS status; - BOOL ret = True; int i; struct drsuapi_DsReplicaSync r; struct drsuapi_DsReplicaObjectIdentifier nc; @@ -379,15 +349,8 @@ static BOOL test_DsReplicaSync(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, } }; - if (!lp_parm_bool(-1, "torture", "dangerous", False)) { - printf("DsReplicaSync disabled - enable dangerous tests to use\n"); - return True; - } - - if (lp_parm_bool(-1, "torture", "samba4", False)) { - printf("skipping DsReplicaSync test against Samba4\n"); - return True; - } + if (torture_setting_bool(tctx, "dangerous", false)) + torture_skip(tctx, "DsReplicaSync disabled - enable dangerous tests to use"); ZERO_STRUCT(null_guid); ZERO_STRUCT(null_sid); @@ -395,8 +358,8 @@ static BOOL test_DsReplicaSync(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, r.in.bind_handle = &priv->bind_handle; for (i=0; i < ARRAY_SIZE(array); i++) { - printf("testing DsReplicaSync level %d\n", - array[i].level); + torture_comment(tctx, "testing DsReplicaSync level %d\n", + array[i].level); r.in.level = array[i].level; switch(r.in.level) { @@ -412,28 +375,21 @@ static BOOL test_DsReplicaSync(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, break; } - status = dcerpc_drsuapi_DsReplicaSync(p, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - const char *errstr = nt_errstr(status); - if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { - errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); - } - printf("dcerpc_drsuapi_DsReplicaSync failed - %s\n", errstr); - ret = False; - } else if (!W_ERROR_IS_OK(r.out.result)) { - printf("DsReplicaSync failed - %s\n", win_errstr(r.out.result)); - ret = False; - } + status = dcerpc_drsuapi_DsReplicaSync(p, tctx, &r); + torture_assert_ntstatus_ok(tctx, status, + "dcerpc_drsuapi_DsReplicaSync failed"); + torture_assert_werr_ok(tctx, r.out.result, + "DsReplicaSync failed"); } - return ret; + return true; } -static BOOL test_DsReplicaUpdateRefs(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, - struct DsPrivate *priv) +static bool test_DsReplicaUpdateRefs(struct dcerpc_pipe *p, + struct torture_context *tctx, + struct DsPrivate *priv) { NTSTATUS status; - BOOL ret = True; int i; struct drsuapi_DsReplicaUpdateRefs r; struct drsuapi_DsReplicaObjectIdentifier nc; @@ -469,35 +425,28 @@ static BOOL test_DsReplicaUpdateRefs(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, nc.dn = priv->domain_obj_dn?priv->domain_obj_dn:""; r.in.req.req1.naming_context = &nc; - r.in.req.req1.dest_dsa_dns_name = talloc_asprintf(mem_ctx, "__some_dest_dsa_guid_string._msdn.%s", + r.in.req.req1.dest_dsa_dns_name = talloc_asprintf(tctx, "__some_dest_dsa_guid_string._msdn.%s", priv->domain_dns_name); r.in.req.req1.dest_dsa_guid = null_guid; r.in.req.req1.options = 0; break; } - status = dcerpc_drsuapi_DsReplicaUpdateRefs(p, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - const char *errstr = nt_errstr(status); - if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { - errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); - } - printf("dcerpc_drsuapi_DsReplicaUpdateRefs failed - %s\n", errstr); - ret = False; - } else if (!W_ERROR_IS_OK(r.out.result)) { - printf("DsReplicaUpdateRefs failed - %s\n", win_errstr(r.out.result)); - ret = False; - } + status = dcerpc_drsuapi_DsReplicaUpdateRefs(p, tctx, &r); + torture_assert_ntstatus_ok(tctx, status, + "dcerpc_drsuapi_DsReplicaUpdateRefs failed"); + torture_assert_werr_ok(tctx, r.out.result, + "DsReplicaUpdateRefs failed"); } - return ret; + return true; } -static BOOL test_DsGetNCChanges(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, - struct DsPrivate *priv) +static bool test_DsGetNCChanges(struct dcerpc_pipe *p, + struct torture_context *tctx, + struct DsPrivate *priv) { NTSTATUS status; - BOOL ret = True; int i; struct drsuapi_DsGetNCChanges r; struct drsuapi_DsReplicaObjectIdentifier nc; @@ -514,16 +463,11 @@ static BOOL test_DsGetNCChanges(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, } }; - if (lp_parm_bool(-1, "torture", "samba4", False)) { - printf("skipping DsGetNCChanges test against Samba4\n"); - return True; - } - ZERO_STRUCT(null_guid); ZERO_STRUCT(null_sid); for (i=0; i < ARRAY_SIZE(array); i++) { - printf("testing DsGetNCChanges level %d\n", + torture_comment(tctx, "testing DsGetNCChanges level %d\n", array[i].level); r.in.bind_handle = &priv->bind_handle; @@ -543,7 +487,7 @@ static BOOL test_DsGetNCChanges(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, 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(-1, "drsuapi","compression", False)) { + if (lp_parm_bool(-1, "drsuapi", "compression", False)) { r.in.req.req5.replica_flags |= DRSUAPI_DS_REPLICA_NEIGHBOUR_COMPRESS_CHANGES; } r.in.req.req5.max_object_count = 0; @@ -565,10 +509,10 @@ static BOOL test_DsGetNCChanges(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, 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(-1,"drsuapi","compression",False)) { + if (lp_parm_bool(-1, "drsuapi", "compression", false)) { r.in.req.req8.replica_flags |= DRSUAPI_DS_REPLICA_NEIGHBOUR_COMPRESS_CHANGES; } - if (lp_parm_bool(-1,"drsuapi","neighbour_writeable",True)) { + if (lp_parm_bool(-1, "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_SYNC_ON_STARTUP @@ -588,29 +532,21 @@ static BOOL test_DsGetNCChanges(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, break; } - status = dcerpc_drsuapi_DsGetNCChanges(p, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - const char *errstr = nt_errstr(status); - if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { - errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); - } - printf("dcerpc_drsuapi_DsGetNCChanges failed - %s\n", errstr); - ret = False; - } else if (!W_ERROR_IS_OK(r.out.result)) { - printf("DsGetNCChanges failed - %s\n", win_errstr(r.out.result)); - ret = False; - } + status = dcerpc_drsuapi_DsGetNCChanges(p, tctx, &r); + torture_assert_ntstatus_ok(tctx, status, + "dcerpc_drsuapi_DsGetNCChanges failed"); + torture_assert_werr_ok(tctx, r.out.result, + "DsGetNCChanges failed"); } - return ret; + return true; } -BOOL test_QuerySitesByCost(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +bool test_QuerySitesByCost(struct dcerpc_pipe *p, struct torture_context *tctx, struct DsPrivate *priv) { NTSTATUS status; struct drsuapi_QuerySitesByCost r; - BOOL ret = True; const char *my_site = "Default-First-Site-Name"; const char *remote_site1 = "smbtorture-nonexisting-site1"; @@ -618,74 +554,46 @@ BOOL test_QuerySitesByCost(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, r.in.bind_handle = &priv->bind_handle; r.in.level = 1; - r.in.req.req1.site_from = talloc_strdup(mem_ctx, my_site); + r.in.req.req1.site_from = talloc_strdup(tctx, my_site); r.in.req.req1.num_req = 2; - r.in.req.req1.site_to = talloc_zero_array(mem_ctx, const char *, r.in.req.req1.num_req); - r.in.req.req1.site_to[0] = talloc_strdup(mem_ctx, remote_site1); - r.in.req.req1.site_to[1] = talloc_strdup(mem_ctx, remote_site2); + r.in.req.req1.site_to = talloc_zero_array(tctx, const char *, r.in.req.req1.num_req); + r.in.req.req1.site_to[0] = talloc_strdup(tctx, remote_site1); + r.in.req.req1.site_to[1] = talloc_strdup(tctx, remote_site2); r.in.req.req1.flags = 0; - status = dcerpc_drsuapi_QuerySitesByCost(p, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - const char *errstr = nt_errstr(status); - if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { - errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); - } - printf("drsuapi_QuerySitesByCost - %s\n", errstr); - ret = False; - } else if (!W_ERROR_IS_OK(r.out.result)) { - printf("QuerySitesByCost failed - %s\n", win_errstr(r.out.result)); - ret = False; - } - - if (W_ERROR_IS_OK(r.out.result)) { + status = dcerpc_drsuapi_QuerySitesByCost(p, tctx, &r); + torture_assert_ntstatus_ok(tctx, status, "drsuapi_QuerySitesByCost"); + torture_assert_werr_ok(tctx, r.out.result, "QuerySitesByCost failed"); - if (!W_ERROR_EQUAL(r.out.ctr.ctr1.info[0].error_code, WERR_DS_OBJ_NOT_FOUND) || - !W_ERROR_EQUAL(r.out.ctr.ctr1.info[1].error_code, WERR_DS_OBJ_NOT_FOUND)) { - printf("expected error_code WERR_DS_OBJ_NOT_FOUND, got %s\n", - win_errstr(r.out.ctr.ctr1.info[0].error_code)); - ret = False; - } - - if ((r.out.ctr.ctr1.info[0].site_cost != (uint32_t) -1) || - (r.out.ctr.ctr1.info[1].site_cost != (uint32_t) -1)) { - printf("expected site_cost %d, got %d\n", - (uint32_t) -1, r.out.ctr.ctr1.info[0].site_cost); - ret = False; - } - } - - return ret; + torture_assert_werr_equal(tctx, r.out.ctr.ctr1.info[0].error_code, WERR_DS_OBJ_NOT_FOUND, "expected not found error"); + torture_assert_werr_equal(tctx, r.out.ctr.ctr1.info[1].error_code, WERR_DS_OBJ_NOT_FOUND, "expected not found error"); + torture_assert_int_equal(tctx, r.out.ctr.ctr1.info[0].site_cost, + (uint32_t) -1, "unexpected site cost"); + + torture_assert_int_equal(tctx, r.out.ctr.ctr1.info[1].site_cost, + (uint32_t) -1, "unexpected site cost"); + return true; } -BOOL test_DsUnbind(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +bool test_DsUnbind(struct dcerpc_pipe *p, struct torture_context *tctx, struct DsPrivate *priv) { NTSTATUS status; struct drsuapi_DsUnbind r; - BOOL ret = True; r.in.bind_handle = &priv->bind_handle; r.out.bind_handle = &priv->bind_handle; - printf("testing DsUnbind\n"); + torture_comment(tctx, "testing DsUnbind\n"); - status = dcerpc_drsuapi_DsUnbind(p, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - const char *errstr = nt_errstr(status); - if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { - errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); - } - printf("dcerpc_drsuapi_DsUnbind failed - %s\n", errstr); - ret = False; - } else if (!W_ERROR_IS_OK(r.out.result)) { - printf("DsBind failed - %s\n", win_errstr(r.out.result)); - ret = False; - } + status = dcerpc_drsuapi_DsUnbind(p, tctx, &r); + torture_assert_ntstatus_ok(tctx, status, + "dcerpc_drsuapi_DsUnbind failed"); + torture_assert_werr_ok(tctx, r.out.result, "DsBind failed"); - return ret; + return true; } bool torture_rpc_drsuapi(struct torture_context *torture) @@ -737,7 +645,6 @@ bool torture_rpc_drsuapi(struct torture_context *torture) return ret; } - bool torture_rpc_drsuapi_cracknames(struct torture_context *torture) { NTSTATUS status; -- cgit From 7fd416bd3e0d9cf602f441c9d4a1750544cba8e5 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 31 Aug 2007 22:34:52 +0000 Subject: r24855: Convert RPC-DRSUAPI, RPC-SCHANNEL to use the torture API. (This used to be commit dadcc4708e1813c0b657f1d357c2ae202ea4ec5a) --- source4/torture/rpc/drsuapi.c | 262 +++++++++++++++++++----------------------- 1 file changed, 118 insertions(+), 144 deletions(-) (limited to 'source4/torture/rpc/drsuapi.c') diff --git a/source4/torture/rpc/drsuapi.c b/source4/torture/rpc/drsuapi.c index a9c7adc70b..08420d0d17 100644 --- a/source4/torture/rpc/drsuapi.c +++ b/source4/torture/rpc/drsuapi.c @@ -25,6 +25,7 @@ #include "torture/torture.h" #include "librpc/gen_ndr/ndr_drsuapi_c.h" #include "torture/rpc/rpc.h" +#include "dlinklist.h" #define TEST_MACHINE_NAME "torturetest" @@ -33,6 +34,7 @@ bool test_DsBind(struct dcerpc_pipe *p, struct torture_context *tctx, { NTSTATUS status; struct drsuapi_DsBind r; + struct torture_rpc_tcase_data *rpc_tcase; GUID_from_string(DRSUAPI_DS_BIND_GUID, &priv->bind_guid); @@ -40,29 +42,87 @@ bool test_DsBind(struct dcerpc_pipe *p, struct torture_context *tctx, r.in.bind_info = NULL; r.out.bind_handle = &priv->bind_handle; - torture_comment(tctx, "testing DsBind\n"); - status = dcerpc_drsuapi_DsBind(p, tctx, &r); - if (!NT_STATUS_IS_OK(status)) { - const char *errstr = nt_errstr(status); - if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { - errstr = dcerpc_errstr(tctx, p->last_fault_code); - } - torture_fail(tctx, "dcerpc_drsuapi_DsBind failed"); - } else if (!W_ERROR_IS_OK(r.out.result)) { - torture_fail(tctx, "DsBind failed"); - } + torture_assert_ntstatus_ok(tctx, status, "DsBind"); + torture_assert_werr_ok(tctx, r.out.result, "DsBind"); + + rpc_tcase = (struct torture_rpc_tcase_data *)tctx->active_tcase->data; + + priv->join = rpc_tcase->join_ctx; + + return true; +} + +bool test_DsUnbind(struct dcerpc_pipe *p, struct torture_context *tctx, + struct DsPrivate *priv) +{ + NTSTATUS status; + struct drsuapi_DsUnbind r; + + r.in.bind_handle = &priv->bind_handle; + r.out.bind_handle = &priv->bind_handle; + + status = dcerpc_drsuapi_DsUnbind(p, tctx, &r); + torture_assert_ntstatus_ok(tctx, status, + "dcerpc_drsuapi_DsUnbind failed"); + torture_assert_werr_ok(tctx, r.out.result, "DsBind failed"); return true; } -static bool test_DsGetDomainControllerInfo(struct dcerpc_pipe *p, - struct torture_context *torture, +static bool wrap_test_drsuapi(struct torture_context *tctx, + struct torture_tcase *tcase, + struct torture_test *test) +{ + bool (*fn) (struct torture_context *, struct dcerpc_pipe *, struct DsPrivate *); + struct torture_rpc_tcase_data *tcase_data = + (struct torture_rpc_tcase_data *)tcase->data; + bool ret; + struct DsPrivate priv; + + ZERO_STRUCT(priv); + + fn = test->fn; + + if (!test_DsBind(tcase_data->pipe, tctx, &priv)) + return false; + + ret = fn(tctx, tcase_data->pipe, &priv); + + if (!test_DsUnbind(tcase_data->pipe, tctx, &priv)) + return false; + + return ret; +} + +static struct torture_test *torture_rpc_tcase_add_drsuapi_test( + struct torture_rpc_tcase *tcase, + const char *name, + bool (*fn) (struct torture_context *, struct dcerpc_pipe *, struct DsPrivate *priv)) +{ + struct torture_test *test; + + test = talloc(tcase, struct torture_test); + + test->name = talloc_strdup(test, name); + test->description = NULL; + test->run = wrap_test_drsuapi; + test->dangerous = false; + test->data = NULL; + test->fn = fn; + + DLIST_ADD(tcase->tcase.tests, test); + + return test; +} + +static bool test_DsGetDomainControllerInfo(struct torture_context *torture, + struct dcerpc_pipe *p, struct DsPrivate *priv) { NTSTATUS status; struct drsuapi_DsGetDomainControllerInfo r; - BOOL found = False; + bool found = false; int i, j, k; struct { @@ -123,7 +183,7 @@ static bool test_DsGetDomainControllerInfo(struct dcerpc_pipe *p, 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; + found = true; break; } } @@ -132,7 +192,7 @@ static bool test_DsGetDomainControllerInfo(struct dcerpc_pipe *p, 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; + found = true; priv->dcinfo = r.out.ctr.ctr2.array[k]; break; } @@ -168,7 +228,7 @@ static bool test_DsGetDomainControllerInfo(struct dcerpc_pipe *p, 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; + found = true; break; } } @@ -180,8 +240,8 @@ static bool test_DsGetDomainControllerInfo(struct dcerpc_pipe *p, return true; } -static bool test_DsWriteAccountSpn(struct dcerpc_pipe *p, - struct torture_context *tctx, +static bool test_DsWriteAccountSpn(struct torture_context *tctx, + struct dcerpc_pipe *p, struct DsPrivate *priv) { NTSTATUS status; @@ -191,8 +251,6 @@ static bool test_DsWriteAccountSpn(struct dcerpc_pipe *p, r.in.bind_handle = &priv->bind_handle; r.in.level = 1; - torture_comment(tctx, "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; @@ -217,8 +275,8 @@ static bool test_DsWriteAccountSpn(struct dcerpc_pipe *p, return true; } -static bool test_DsReplicaGetInfo(struct dcerpc_pipe *p, - struct torture_context *tctx, +static bool test_DsReplicaGetInfo(struct torture_context *tctx, + struct dcerpc_pipe *p, struct DsPrivate *priv) { NTSTATUS status; @@ -331,8 +389,8 @@ static bool test_DsReplicaGetInfo(struct dcerpc_pipe *p, return true; } -static bool test_DsReplicaSync(struct dcerpc_pipe *p, - struct torture_context *tctx, +static bool test_DsReplicaSync(struct torture_context *tctx, + struct dcerpc_pipe *p, struct DsPrivate *priv) { NTSTATUS status; @@ -349,9 +407,6 @@ static bool test_DsReplicaSync(struct dcerpc_pipe *p, } }; - if (torture_setting_bool(tctx, "dangerous", false)) - torture_skip(tctx, "DsReplicaSync disabled - enable dangerous tests to use"); - ZERO_STRUCT(null_guid); ZERO_STRUCT(null_sid); @@ -385,8 +440,8 @@ static bool test_DsReplicaSync(struct dcerpc_pipe *p, return true; } -static bool test_DsReplicaUpdateRefs(struct dcerpc_pipe *p, - struct torture_context *tctx, +static bool test_DsReplicaUpdateRefs(struct torture_context *tctx, + struct dcerpc_pipe *p, struct DsPrivate *priv) { NTSTATUS status; @@ -403,18 +458,13 @@ static bool test_DsReplicaUpdateRefs(struct dcerpc_pipe *p, } }; - if (lp_parm_bool(-1, "torture", "samba4", False)) { - printf("skipping DsReplicaUpdateRefs test against Samba4\n"); - return True; - } - ZERO_STRUCT(null_guid); ZERO_STRUCT(null_sid); r.in.bind_handle = &priv->bind_handle; for (i=0; i < ARRAY_SIZE(array); i++) { - printf("testing DsReplicaUpdateRefs level %d\n", + torture_comment(tctx, "testing DsReplicaUpdateRefs level %d\n", array[i].level); r.in.level = array[i].level; @@ -442,8 +492,8 @@ static bool test_DsReplicaUpdateRefs(struct dcerpc_pipe *p, return true; } -static bool test_DsGetNCChanges(struct dcerpc_pipe *p, - struct torture_context *tctx, +static bool test_DsGetNCChanges(struct torture_context *tctx, + struct dcerpc_pipe *p, struct DsPrivate *priv) { NTSTATUS status; @@ -487,7 +537,7 @@ static bool test_DsGetNCChanges(struct dcerpc_pipe *p, 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(-1, "drsuapi", "compression", False)) { + if (lp_parm_bool(-1, "drsuapi", "compression", false)) { r.in.req.req5.replica_flags |= DRSUAPI_DS_REPLICA_NEIGHBOUR_COMPRESS_CHANGES; } r.in.req.req5.max_object_count = 0; @@ -542,7 +592,7 @@ static bool test_DsGetNCChanges(struct dcerpc_pipe *p, return true; } -bool test_QuerySitesByCost(struct dcerpc_pipe *p, struct torture_context *tctx, +bool test_QuerySitesByCost(struct torture_context *tctx, struct dcerpc_pipe *p, struct DsPrivate *priv) { NTSTATUS status; @@ -565,8 +615,10 @@ bool test_QuerySitesByCost(struct dcerpc_pipe *p, struct torture_context *tctx, torture_assert_ntstatus_ok(tctx, status, "drsuapi_QuerySitesByCost"); torture_assert_werr_ok(tctx, r.out.result, "QuerySitesByCost failed"); - torture_assert_werr_equal(tctx, r.out.ctr.ctr1.info[0].error_code, WERR_DS_OBJ_NOT_FOUND, "expected not found error"); - torture_assert_werr_equal(tctx, r.out.ctr.ctr1.info[1].error_code, WERR_DS_OBJ_NOT_FOUND, "expected not found error"); + torture_assert_werr_equal(tctx, r.out.ctr.ctr1.info[0].error_code, + WERR_DS_OBJ_NOT_FOUND, "expected not found error"); + torture_assert_werr_equal(tctx, r.out.ctr.ctr1.info[1].error_code, + WERR_DS_OBJ_NOT_FOUND, "expected not found error"); torture_assert_int_equal(tctx, r.out.ctr.ctr1.info[0].site_cost, (uint32_t) -1, "unexpected site cost"); @@ -577,113 +629,35 @@ bool test_QuerySitesByCost(struct dcerpc_pipe *p, struct torture_context *tctx, return true; } -bool test_DsUnbind(struct dcerpc_pipe *p, struct torture_context *tctx, - struct DsPrivate *priv) -{ - NTSTATUS status; - struct drsuapi_DsUnbind r; - - r.in.bind_handle = &priv->bind_handle; - r.out.bind_handle = &priv->bind_handle; - - torture_comment(tctx, "testing DsUnbind\n"); - - status = dcerpc_drsuapi_DsUnbind(p, tctx, &r); - torture_assert_ntstatus_ok(tctx, status, - "dcerpc_drsuapi_DsUnbind failed"); - torture_assert_werr_ok(tctx, r.out.result, "DsBind failed"); - - return true; -} - -bool torture_rpc_drsuapi(struct torture_context *torture) +struct torture_suite *torture_rpc_drsuapi(TALLOC_CTX *mem_ctx) { - NTSTATUS status; - struct dcerpc_pipe *p; - bool ret = true; - struct DsPrivate priv; - struct cli_credentials *machine_credentials; - - ZERO_STRUCT(priv); - - priv.join = torture_join_domain(TEST_MACHINE_NAME, ACB_SVRTRUST, - &machine_credentials); - if (!priv.join) { - torture_fail(torture, "Failed to join as BDC"); - } - - status = torture_rpc_connection(torture, - &p, - &ndr_table_drsuapi); - if (!NT_STATUS_IS_OK(status)) { - torture_leave_domain(priv.join); - torture_fail(torture, "Unable to connect to DRSUAPI pipe"); - } - - ret &= test_DsBind(p, torture, &priv); -#if 0 - ret &= test_QuerySitesByCost(p, torture, &priv); -#endif - ret &= test_DsGetDomainControllerInfo(p, torture, &priv); - - ret &= test_DsCrackNames(p, torture, &priv); - - ret &= test_DsWriteAccountSpn(p, torture, &priv); - - ret &= test_DsReplicaGetInfo(p, torture, &priv); - - ret &= test_DsReplicaSync(p, torture, &priv); - - ret &= test_DsReplicaUpdateRefs(p, torture, &priv); - - ret &= test_DsGetNCChanges(p, torture, &priv); - - ret &= test_DsUnbind(p, torture, &priv); - - torture_leave_domain(priv.join); - - return ret; + struct torture_suite *suite = torture_suite_create(mem_ctx, "DRSUAPI"); + struct torture_test *test; + struct torture_rpc_tcase *tcase = torture_suite_add_machine_rpc_iface_tcase(suite, "drsuapi", + &ndr_table_drsuapi, TEST_MACHINE_NAME); + + torture_rpc_tcase_add_drsuapi_test(tcase, "QuerySitesByCost", test_QuerySitesByCost); + torture_rpc_tcase_add_drsuapi_test(tcase, "DsGetDomainControllerInfo", test_DsGetDomainControllerInfo); + torture_rpc_tcase_add_drsuapi_test(tcase, "DsCrackNames", test_DsCrackNames); + torture_rpc_tcase_add_drsuapi_test(tcase, "DsWriteAccountSpn", test_DsWriteAccountSpn); + torture_rpc_tcase_add_drsuapi_test(tcase, "DsReplicaGetInfo", test_DsReplicaGetInfo); + test = torture_rpc_tcase_add_drsuapi_test(tcase, "DsReplicaSync", test_DsReplicaSync); + test->dangerous = true; + torture_rpc_tcase_add_drsuapi_test(tcase, "DsReplicaUpdateRefs", test_DsReplicaUpdateRefs); + torture_rpc_tcase_add_drsuapi_test(tcase, "DsGetNCChange", test_DsGetNCChanges); + + return suite; } -bool torture_rpc_drsuapi_cracknames(struct torture_context *torture) +struct torture_suite *torture_rpc_drsuapi_cracknames(TALLOC_CTX *mem_ctx) { - NTSTATUS status; - struct dcerpc_pipe *p; - bool ret = true; - struct DsPrivate priv; - struct cli_credentials *machine_credentials; - - torture_comment(torture, "Connected to DRSUAPI pipe\n"); + struct torture_suite *suite = torture_suite_create(mem_ctx, "CRACKNAMES"); + struct torture_rpc_tcase *tcase = torture_suite_add_machine_rpc_iface_tcase(suite, "drsuapi", + &ndr_table_drsuapi, TEST_MACHINE_NAME); - ZERO_STRUCT(priv); - - priv.join = torture_join_domain(TEST_MACHINE_NAME, ACB_SVRTRUST, - &machine_credentials); - if (!priv.join) { - torture_fail(torture, "Failed to join as BDC\n"); - } - - status = torture_rpc_connection(torture, - &p, - &ndr_table_drsuapi); - if (!NT_STATUS_IS_OK(status)) { - torture_leave_domain(priv.join); - torture_fail(torture, "Unable to connect to DRSUAPI pipe"); - } - - ret &= test_DsBind(p, torture, &priv); + torture_rpc_tcase_add_drsuapi_test(tcase, "DsGetDomainControllerInfo", test_DsGetDomainControllerInfo); + torture_rpc_tcase_add_drsuapi_test(tcase, "DsCrackNames", test_DsCrackNames); - if (ret) { - /* We don't care if this fails, we just need some info from it */ - test_DsGetDomainControllerInfo(p, torture, &priv); - - ret &= test_DsCrackNames(p, torture, &priv); - - ret &= test_DsUnbind(p, torture, &priv); - } - - torture_leave_domain(priv.join); - - return ret; + return suite; } -- cgit From ffeee68e4b72dd94fee57366bd8d38b8c284c3d4 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 8 Sep 2007 12:42:09 +0000 Subject: r25026: Move param/param.h out of includes.h (This used to be commit abe8349f9b4387961ff3665d8c589d61cd2edf31) --- source4/torture/rpc/drsuapi.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/torture/rpc/drsuapi.c') diff --git a/source4/torture/rpc/drsuapi.c b/source4/torture/rpc/drsuapi.c index 08420d0d17..c3ec54cbcd 100644 --- a/source4/torture/rpc/drsuapi.c +++ b/source4/torture/rpc/drsuapi.c @@ -26,6 +26,7 @@ #include "librpc/gen_ndr/ndr_drsuapi_c.h" #include "torture/rpc/rpc.h" #include "dlinklist.h" +#include "param/param.h" #define TEST_MACHINE_NAME "torturetest" -- cgit From 98b57d5eb61094a9c88e2f7d90d3e21b7e74e9d8 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 8 Sep 2007 16:46:30 +0000 Subject: r25035: Fix some more warnings, use service pointer rather than service number in more places. (This used to be commit df9cebcb97e20564359097148665bd519f31bc6f) --- source4/torture/rpc/drsuapi.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source4/torture/rpc/drsuapi.c') diff --git a/source4/torture/rpc/drsuapi.c b/source4/torture/rpc/drsuapi.c index c3ec54cbcd..3f59f1d56d 100644 --- a/source4/torture/rpc/drsuapi.c +++ b/source4/torture/rpc/drsuapi.c @@ -538,7 +538,7 @@ static bool test_DsGetNCChanges(struct torture_context *tctx, 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(-1, "drsuapi", "compression", false)) { + if (lp_parm_bool(NULL, "drsuapi", "compression", false)) { r.in.req.req5.replica_flags |= DRSUAPI_DS_REPLICA_NEIGHBOUR_COMPRESS_CHANGES; } r.in.req.req5.max_object_count = 0; @@ -560,10 +560,10 @@ static bool test_DsGetNCChanges(struct torture_context *tctx, 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(-1, "drsuapi", "compression", false)) { + if (lp_parm_bool(NULL, "drsuapi", "compression", false)) { r.in.req.req8.replica_flags |= DRSUAPI_DS_REPLICA_NEIGHBOUR_COMPRESS_CHANGES; } - if (lp_parm_bool(-1, "drsuapi", "neighbour_writeable",true)) { + if (lp_parm_bool(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_SYNC_ON_STARTUP -- cgit From 45d0b9a0a3750bfe98e274df456d6d50631a91ed Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 10 Sep 2007 23:47:29 +0000 Subject: r25070: Revert DRSUAPI conversion to new API, as it broke some tests. (This used to be commit cfb33df2d0eb36704d4702948a78102153663131) --- source4/torture/rpc/drsuapi.c | 487 ++++++++++++++++++++++++++---------------- 1 file changed, 303 insertions(+), 184 deletions(-) (limited to 'source4/torture/rpc/drsuapi.c') diff --git a/source4/torture/rpc/drsuapi.c b/source4/torture/rpc/drsuapi.c index 3f59f1d56d..42c0cc8bda 100644 --- a/source4/torture/rpc/drsuapi.c +++ b/source4/torture/rpc/drsuapi.c @@ -25,7 +25,6 @@ #include "torture/torture.h" #include "librpc/gen_ndr/ndr_drsuapi_c.h" #include "torture/rpc/rpc.h" -#include "dlinklist.h" #include "param/param.h" #define TEST_MACHINE_NAME "torturetest" @@ -35,7 +34,6 @@ bool test_DsBind(struct dcerpc_pipe *p, struct torture_context *tctx, { NTSTATUS status; struct drsuapi_DsBind r; - struct torture_rpc_tcase_data *rpc_tcase; GUID_from_string(DRSUAPI_DS_BIND_GUID, &priv->bind_guid); @@ -43,87 +41,28 @@ bool test_DsBind(struct dcerpc_pipe *p, struct torture_context *tctx, r.in.bind_info = NULL; r.out.bind_handle = &priv->bind_handle; - status = dcerpc_drsuapi_DsBind(p, tctx, &r); - torture_assert_ntstatus_ok(tctx, status, "DsBind"); - torture_assert_werr_ok(tctx, r.out.result, "DsBind"); - - rpc_tcase = (struct torture_rpc_tcase_data *)tctx->active_tcase->data; + torture_comment(tctx, "testing DsBind\n"); - priv->join = rpc_tcase->join_ctx; + status = dcerpc_drsuapi_DsBind(p, tctx, &r); + if (!NT_STATUS_IS_OK(status)) { + const char *errstr = nt_errstr(status); + if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { + errstr = dcerpc_errstr(tctx, p->last_fault_code); + } + torture_fail(tctx, "dcerpc_drsuapi_DsBind failed"); + } else if (!W_ERROR_IS_OK(r.out.result)) { + torture_fail(tctx, "DsBind failed"); + } return true; } -bool test_DsUnbind(struct dcerpc_pipe *p, struct torture_context *tctx, - struct DsPrivate *priv) -{ - NTSTATUS status; - struct drsuapi_DsUnbind r; - - r.in.bind_handle = &priv->bind_handle; - r.out.bind_handle = &priv->bind_handle; - - status = dcerpc_drsuapi_DsUnbind(p, tctx, &r); - torture_assert_ntstatus_ok(tctx, status, - "dcerpc_drsuapi_DsUnbind failed"); - torture_assert_werr_ok(tctx, r.out.result, "DsBind failed"); - - return true; -} - -static bool wrap_test_drsuapi(struct torture_context *tctx, - struct torture_tcase *tcase, - struct torture_test *test) -{ - bool (*fn) (struct torture_context *, struct dcerpc_pipe *, struct DsPrivate *); - struct torture_rpc_tcase_data *tcase_data = - (struct torture_rpc_tcase_data *)tcase->data; - bool ret; - struct DsPrivate priv; - - ZERO_STRUCT(priv); - - fn = test->fn; - - if (!test_DsBind(tcase_data->pipe, tctx, &priv)) - return false; - - ret = fn(tctx, tcase_data->pipe, &priv); - - if (!test_DsUnbind(tcase_data->pipe, tctx, &priv)) - return false; - - return ret; -} - -static struct torture_test *torture_rpc_tcase_add_drsuapi_test( - struct torture_rpc_tcase *tcase, - const char *name, - bool (*fn) (struct torture_context *, struct dcerpc_pipe *, struct DsPrivate *priv)) -{ - struct torture_test *test; - - test = talloc(tcase, struct torture_test); - - test->name = talloc_strdup(test, name); - test->description = NULL; - test->run = wrap_test_drsuapi; - test->dangerous = false; - test->data = NULL; - test->fn = fn; - - DLIST_ADD(tcase->tcase.tests, test); - - return test; -} - -static bool test_DsGetDomainControllerInfo(struct torture_context *torture, - struct dcerpc_pipe *p, - struct DsPrivate *priv) +static bool test_DsGetDomainControllerInfo(struct dcerpc_pipe *p, struct torture_context *torture, + struct DsPrivate *priv) { NTSTATUS status; struct drsuapi_DsGetDomainControllerInfo r; - bool found = false; + BOOL found = False; int i, j, k; struct { @@ -176,15 +115,15 @@ static bool test_DsGetDomainControllerInfo(struct torture_context *torture, } torture_assert_int_equal(torture, - r.in.req.req1.level, r.out.level_out, - "dcerpc_drsuapi_DsGetDomainControllerInfo level"); + 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, torture_join_netbios_name(priv->join)) == 0) { - found = true; + found = True; break; } } @@ -193,7 +132,7 @@ static bool test_DsGetDomainControllerInfo(struct torture_context *torture, 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; + found = True; priv->dcinfo = r.out.ctr.ctr2.array[k]; break; } @@ -211,8 +150,7 @@ static bool test_DsGetDomainControllerInfo(struct torture_context *torture, r.in.req.req1.domain_name = "__UNKNOWN_DOMAIN__"; /* This is clearly ignored for this level */ r.in.req.req1.level = -1; - torture_comment(torture, - "testing DsGetDomainControllerInfo level %d on domainname '%s'\n", + printf("testing DsGetDomainControllerInfo level %d on domainname '%s'\n", r.in.req.req1.level, r.in.req.req1.domain_name); status = dcerpc_drsuapi_DsGetDomainControllerInfo(p, torture, &r); @@ -229,7 +167,7 @@ static bool test_DsGetDomainControllerInfo(struct torture_context *torture, 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; + found = True; break; } } @@ -241,47 +179,65 @@ static bool test_DsGetDomainControllerInfo(struct torture_context *torture, return true; } -static bool test_DsWriteAccountSpn(struct torture_context *tctx, - struct dcerpc_pipe *p, +static BOOL test_DsWriteAccountSpn(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct DsPrivate *priv) { NTSTATUS status; struct drsuapi_DsWriteAccountSpn r; struct drsuapi_DsNameString names[2]; + BOOL ret = True; r.in.bind_handle = &priv->bind_handle; r.in.level = 1; + 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; - names[0].str = talloc_asprintf(tctx, "smbtortureSPN/%s",priv->dcinfo.netbios_name); - names[1].str = talloc_asprintf(tctx, "smbtortureSPN/%s",priv->dcinfo.dns_name); - - status = dcerpc_drsuapi_DsWriteAccountSpn(p, tctx, &r); - torture_assert_ntstatus_ok(tctx, status, - "dcerpc_drsuapi_DsWriteAccountSpn failed"); - torture_assert_werr_ok(tctx, r.out.result, "DsWriteAccountSpn failed"); + 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); + + status = dcerpc_drsuapi_DsWriteAccountSpn(p, mem_ctx, &r); + if (!NT_STATUS_IS_OK(status)) { + const char *errstr = nt_errstr(status); + if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { + errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); + } + printf("dcerpc_drsuapi_DsWriteAccountSpn failed - %s\n", errstr); + ret = False; + } else if (!W_ERROR_IS_OK(r.out.result)) { + printf("DsWriteAccountSpn failed - %s\n", win_errstr(r.out.result)); + ret = False; + } r.in.req.req1.operation = DRSUAPI_DS_SPN_OPERATION_DELETE; r.in.req.req1.unknown1 = 0; - status = dcerpc_drsuapi_DsWriteAccountSpn(p, tctx, &r); - torture_assert_ntstatus_ok(tctx, status, - "dcerpc_drsuapi_DsWriteAccountSpn failed"); - torture_assert_werr_ok(tctx, r.out.result, "DsWriteAccountSpn failed"); + status = dcerpc_drsuapi_DsWriteAccountSpn(p, mem_ctx, &r); + if (!NT_STATUS_IS_OK(status)) { + const char *errstr = nt_errstr(status); + if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { + errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); + } + printf("dcerpc_drsuapi_DsWriteAccountSpn failed - %s\n", errstr); + ret = False; + } else if (!W_ERROR_IS_OK(r.out.result)) { + printf("DsWriteAccountSpn failed - %s\n", win_errstr(r.out.result)); + ret = False; + } - return true; + return ret; } -static bool test_DsReplicaGetInfo(struct torture_context *tctx, - struct dcerpc_pipe *p, - struct DsPrivate *priv) +static BOOL test_DsReplicaGetInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, + struct DsPrivate *priv) { NTSTATUS status; struct drsuapi_DsReplicaGetInfo r; + BOOL ret = True; int i; struct { int32_t level; @@ -351,13 +307,17 @@ static bool test_DsReplicaGetInfo(struct torture_context *tctx, } }; + if (lp_parm_bool(NULL, "torture", "samba4", False)) { + printf("skipping DsReplicaGetInfo test against Samba4\n"); + return True; + } + r.in.bind_handle = &priv->bind_handle; for (i=0; i < ARRAY_SIZE(array); i++) { const char *object_dn; - torture_comment(tctx, - "testing DsReplicaGetInfo level %d infotype %d\n", + printf("testing DsReplicaGetInfo level %d infotype %d\n", array[i].level, array[i].infotype); object_dn = (array[i].obj_dn ? array[i].obj_dn : priv->domain_obj_dn); @@ -380,21 +340,33 @@ static bool test_DsReplicaGetInfo(struct torture_context *tctx, break; } - status = dcerpc_drsuapi_DsReplicaGetInfo(p, tctx, &r); - torture_assert_ntstatus_ok(tctx, status, - "dcerpc_drsuapi_DsReplicaGetInfo failed"); - torture_assert_werr_ok(tctx, r.out.result, - "DsReplicaGetInfo failed"); + status = dcerpc_drsuapi_DsReplicaGetInfo(p, mem_ctx, &r); + if (!NT_STATUS_IS_OK(status)) { + const char *errstr = nt_errstr(status); + if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { + errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); + } + if (p->last_fault_code != DCERPC_FAULT_INVALID_TAG) { + printf("dcerpc_drsuapi_DsReplicaGetInfo failed - %s\n", errstr); + ret = False; + } else { + printf("DsReplicaGetInfo level %d and/or infotype %d not supported by server\n", + array[i].level, array[i].infotype); + } + } else if (!W_ERROR_IS_OK(r.out.result)) { + printf("DsReplicaGetInfo failed - %s\n", win_errstr(r.out.result)); + ret = False; + } } - return true; + return ret; } -static bool test_DsReplicaSync(struct torture_context *tctx, - struct dcerpc_pipe *p, - struct DsPrivate *priv) +static BOOL test_DsReplicaSync(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, + struct DsPrivate *priv) { NTSTATUS status; + BOOL ret = True; int i; struct drsuapi_DsReplicaSync r; struct drsuapi_DsReplicaObjectIdentifier nc; @@ -408,14 +380,24 @@ static bool test_DsReplicaSync(struct torture_context *tctx, } }; + if (!lp_parm_bool(NULL, "torture", "dangerous", False)) { + printf("DsReplicaSync disabled - enable dangerous tests to use\n"); + return True; + } + + if (lp_parm_bool(NULL, "torture", "samba4", False)) { + printf("skipping DsReplicaSync test against Samba4\n"); + return True; + } + ZERO_STRUCT(null_guid); ZERO_STRUCT(null_sid); r.in.bind_handle = &priv->bind_handle; for (i=0; i < ARRAY_SIZE(array); i++) { - torture_comment(tctx, "testing DsReplicaSync level %d\n", - array[i].level); + printf("testing DsReplicaSync level %d\n", + array[i].level); r.in.level = array[i].level; switch(r.in.level) { @@ -431,21 +413,28 @@ static bool test_DsReplicaSync(struct torture_context *tctx, break; } - status = dcerpc_drsuapi_DsReplicaSync(p, tctx, &r); - torture_assert_ntstatus_ok(tctx, status, - "dcerpc_drsuapi_DsReplicaSync failed"); - torture_assert_werr_ok(tctx, r.out.result, - "DsReplicaSync failed"); + status = dcerpc_drsuapi_DsReplicaSync(p, mem_ctx, &r); + if (!NT_STATUS_IS_OK(status)) { + const char *errstr = nt_errstr(status); + if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { + errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); + } + printf("dcerpc_drsuapi_DsReplicaSync failed - %s\n", errstr); + ret = False; + } else if (!W_ERROR_IS_OK(r.out.result)) { + printf("DsReplicaSync failed - %s\n", win_errstr(r.out.result)); + ret = False; + } } - return true; + return ret; } -static bool test_DsReplicaUpdateRefs(struct torture_context *tctx, - struct dcerpc_pipe *p, - struct DsPrivate *priv) +static BOOL test_DsReplicaUpdateRefs(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, + struct DsPrivate *priv) { NTSTATUS status; + BOOL ret = True; int i; struct drsuapi_DsReplicaUpdateRefs r; struct drsuapi_DsReplicaObjectIdentifier nc; @@ -459,13 +448,18 @@ static bool test_DsReplicaUpdateRefs(struct torture_context *tctx, } }; + if (lp_parm_bool(NULL, "torture", "samba4", False)) { + printf("skipping DsReplicaUpdateRefs test against Samba4\n"); + return True; + } + ZERO_STRUCT(null_guid); ZERO_STRUCT(null_sid); r.in.bind_handle = &priv->bind_handle; for (i=0; i < ARRAY_SIZE(array); i++) { - torture_comment(tctx, "testing DsReplicaUpdateRefs level %d\n", + printf("testing DsReplicaUpdateRefs level %d\n", array[i].level); r.in.level = array[i].level; @@ -476,28 +470,35 @@ static bool test_DsReplicaUpdateRefs(struct torture_context *tctx, nc.dn = priv->domain_obj_dn?priv->domain_obj_dn:""; r.in.req.req1.naming_context = &nc; - r.in.req.req1.dest_dsa_dns_name = talloc_asprintf(tctx, "__some_dest_dsa_guid_string._msdn.%s", + r.in.req.req1.dest_dsa_dns_name = talloc_asprintf(mem_ctx, "__some_dest_dsa_guid_string._msdn.%s", priv->domain_dns_name); r.in.req.req1.dest_dsa_guid = null_guid; r.in.req.req1.options = 0; break; } - status = dcerpc_drsuapi_DsReplicaUpdateRefs(p, tctx, &r); - torture_assert_ntstatus_ok(tctx, status, - "dcerpc_drsuapi_DsReplicaUpdateRefs failed"); - torture_assert_werr_ok(tctx, r.out.result, - "DsReplicaUpdateRefs failed"); + status = dcerpc_drsuapi_DsReplicaUpdateRefs(p, mem_ctx, &r); + if (!NT_STATUS_IS_OK(status)) { + const char *errstr = nt_errstr(status); + if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { + errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); + } + printf("dcerpc_drsuapi_DsReplicaUpdateRefs failed - %s\n", errstr); + ret = False; + } else if (!W_ERROR_IS_OK(r.out.result)) { + printf("DsReplicaUpdateRefs failed - %s\n", win_errstr(r.out.result)); + ret = False; + } } - return true; + return ret; } -static bool test_DsGetNCChanges(struct torture_context *tctx, - struct dcerpc_pipe *p, - struct DsPrivate *priv) +static BOOL test_DsGetNCChanges(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, + struct DsPrivate *priv) { NTSTATUS status; + BOOL ret = True; int i; struct drsuapi_DsGetNCChanges r; struct drsuapi_DsReplicaObjectIdentifier nc; @@ -514,11 +515,16 @@ static bool test_DsGetNCChanges(struct torture_context *tctx, } }; + if (lp_parm_bool(NULL, "torture", "samba4", False)) { + printf("skipping DsGetNCChanges test against Samba4\n"); + return True; + } + ZERO_STRUCT(null_guid); ZERO_STRUCT(null_sid); for (i=0; i < ARRAY_SIZE(array); i++) { - torture_comment(tctx, "testing DsGetNCChanges level %d\n", + printf("testing DsGetNCChanges level %d\n", array[i].level); r.in.bind_handle = &priv->bind_handle; @@ -538,7 +544,7 @@ static bool test_DsGetNCChanges(struct torture_context *tctx, 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(NULL, "drsuapi", "compression", false)) { + if (lp_parm_bool(NULL, "drsuapi","compression", False)) { r.in.req.req5.replica_flags |= DRSUAPI_DS_REPLICA_NEIGHBOUR_COMPRESS_CHANGES; } r.in.req.req5.max_object_count = 0; @@ -560,10 +566,10 @@ static bool test_DsGetNCChanges(struct torture_context *tctx, 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(NULL, "drsuapi", "compression", false)) { + if (lp_parm_bool(NULL,"drsuapi","compression",False)) { r.in.req.req8.replica_flags |= DRSUAPI_DS_REPLICA_NEIGHBOUR_COMPRESS_CHANGES; } - if (lp_parm_bool(NULL, "drsuapi", "neighbour_writeable",true)) { + if (lp_parm_bool(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_SYNC_ON_STARTUP @@ -583,21 +589,29 @@ static bool test_DsGetNCChanges(struct torture_context *tctx, break; } - status = dcerpc_drsuapi_DsGetNCChanges(p, tctx, &r); - torture_assert_ntstatus_ok(tctx, status, - "dcerpc_drsuapi_DsGetNCChanges failed"); - torture_assert_werr_ok(tctx, r.out.result, - "DsGetNCChanges failed"); + status = dcerpc_drsuapi_DsGetNCChanges(p, mem_ctx, &r); + if (!NT_STATUS_IS_OK(status)) { + const char *errstr = nt_errstr(status); + if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { + errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); + } + printf("dcerpc_drsuapi_DsGetNCChanges failed - %s\n", errstr); + ret = False; + } else if (!W_ERROR_IS_OK(r.out.result)) { + printf("DsGetNCChanges failed - %s\n", win_errstr(r.out.result)); + ret = False; + } } - return true; + return ret; } -bool test_QuerySitesByCost(struct torture_context *tctx, struct dcerpc_pipe *p, +BOOL test_QuerySitesByCost(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct DsPrivate *priv) { NTSTATUS status; struct drsuapi_QuerySitesByCost r; + BOOL ret = True; const char *my_site = "Default-First-Site-Name"; const char *remote_site1 = "smbtorture-nonexisting-site1"; @@ -605,60 +619,165 @@ bool test_QuerySitesByCost(struct torture_context *tctx, struct dcerpc_pipe *p, r.in.bind_handle = &priv->bind_handle; r.in.level = 1; - r.in.req.req1.site_from = talloc_strdup(tctx, my_site); + r.in.req.req1.site_from = talloc_strdup(mem_ctx, my_site); r.in.req.req1.num_req = 2; - r.in.req.req1.site_to = talloc_zero_array(tctx, const char *, r.in.req.req1.num_req); - r.in.req.req1.site_to[0] = talloc_strdup(tctx, remote_site1); - r.in.req.req1.site_to[1] = talloc_strdup(tctx, remote_site2); + r.in.req.req1.site_to = talloc_zero_array(mem_ctx, const char *, r.in.req.req1.num_req); + r.in.req.req1.site_to[0] = talloc_strdup(mem_ctx, remote_site1); + r.in.req.req1.site_to[1] = talloc_strdup(mem_ctx, remote_site2); r.in.req.req1.flags = 0; - status = dcerpc_drsuapi_QuerySitesByCost(p, tctx, &r); - torture_assert_ntstatus_ok(tctx, status, "drsuapi_QuerySitesByCost"); - torture_assert_werr_ok(tctx, r.out.result, "QuerySitesByCost failed"); + status = dcerpc_drsuapi_QuerySitesByCost(p, mem_ctx, &r); + if (!NT_STATUS_IS_OK(status)) { + const char *errstr = nt_errstr(status); + if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { + errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); + } + printf("drsuapi_QuerySitesByCost - %s\n", errstr); + ret = False; + } else if (!W_ERROR_IS_OK(r.out.result)) { + printf("QuerySitesByCost failed - %s\n", win_errstr(r.out.result)); + ret = False; + } - torture_assert_werr_equal(tctx, r.out.ctr.ctr1.info[0].error_code, - WERR_DS_OBJ_NOT_FOUND, "expected not found error"); - torture_assert_werr_equal(tctx, r.out.ctr.ctr1.info[1].error_code, - WERR_DS_OBJ_NOT_FOUND, "expected not found error"); + if (W_ERROR_IS_OK(r.out.result)) { + + if (!W_ERROR_EQUAL(r.out.ctr.ctr1.info[0].error_code, WERR_DS_OBJ_NOT_FOUND) || + !W_ERROR_EQUAL(r.out.ctr.ctr1.info[1].error_code, WERR_DS_OBJ_NOT_FOUND)) { + printf("expected error_code WERR_DS_OBJ_NOT_FOUND, got %s\n", + win_errstr(r.out.ctr.ctr1.info[0].error_code)); + ret = False; + } + + if ((r.out.ctr.ctr1.info[0].site_cost != (uint32_t) -1) || + (r.out.ctr.ctr1.info[1].site_cost != (uint32_t) -1)) { + printf("expected site_cost %d, got %d\n", + (uint32_t) -1, r.out.ctr.ctr1.info[0].site_cost); + ret = False; + } + } + + return ret; - torture_assert_int_equal(tctx, r.out.ctr.ctr1.info[0].site_cost, - (uint32_t) -1, "unexpected site cost"); - - torture_assert_int_equal(tctx, r.out.ctr.ctr1.info[1].site_cost, - (uint32_t) -1, "unexpected site cost"); - return true; } -struct torture_suite *torture_rpc_drsuapi(TALLOC_CTX *mem_ctx) +BOOL test_DsUnbind(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, + struct DsPrivate *priv) { - struct torture_suite *suite = torture_suite_create(mem_ctx, "DRSUAPI"); - struct torture_test *test; - struct torture_rpc_tcase *tcase = torture_suite_add_machine_rpc_iface_tcase(suite, "drsuapi", - &ndr_table_drsuapi, TEST_MACHINE_NAME); - - torture_rpc_tcase_add_drsuapi_test(tcase, "QuerySitesByCost", test_QuerySitesByCost); - torture_rpc_tcase_add_drsuapi_test(tcase, "DsGetDomainControllerInfo", test_DsGetDomainControllerInfo); - torture_rpc_tcase_add_drsuapi_test(tcase, "DsCrackNames", test_DsCrackNames); - torture_rpc_tcase_add_drsuapi_test(tcase, "DsWriteAccountSpn", test_DsWriteAccountSpn); - torture_rpc_tcase_add_drsuapi_test(tcase, "DsReplicaGetInfo", test_DsReplicaGetInfo); - test = torture_rpc_tcase_add_drsuapi_test(tcase, "DsReplicaSync", test_DsReplicaSync); - test->dangerous = true; - torture_rpc_tcase_add_drsuapi_test(tcase, "DsReplicaUpdateRefs", test_DsReplicaUpdateRefs); - torture_rpc_tcase_add_drsuapi_test(tcase, "DsGetNCChange", test_DsGetNCChanges); - - return suite; + NTSTATUS status; + struct drsuapi_DsUnbind r; + BOOL ret = True; + + r.in.bind_handle = &priv->bind_handle; + r.out.bind_handle = &priv->bind_handle; + + printf("testing DsUnbind\n"); + + status = dcerpc_drsuapi_DsUnbind(p, mem_ctx, &r); + if (!NT_STATUS_IS_OK(status)) { + const char *errstr = nt_errstr(status); + if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { + errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); + } + printf("dcerpc_drsuapi_DsUnbind failed - %s\n", errstr); + ret = False; + } else if (!W_ERROR_IS_OK(r.out.result)) { + printf("DsBind failed - %s\n", win_errstr(r.out.result)); + ret = False; + } + + return ret; } -struct torture_suite *torture_rpc_drsuapi_cracknames(TALLOC_CTX *mem_ctx) +bool torture_rpc_drsuapi(struct torture_context *torture) { - struct torture_suite *suite = torture_suite_create(mem_ctx, "CRACKNAMES"); - struct torture_rpc_tcase *tcase = torture_suite_add_machine_rpc_iface_tcase(suite, "drsuapi", - &ndr_table_drsuapi, TEST_MACHINE_NAME); + NTSTATUS status; + struct dcerpc_pipe *p; + bool ret = true; + struct DsPrivate priv; + struct cli_credentials *machine_credentials; + + ZERO_STRUCT(priv); - torture_rpc_tcase_add_drsuapi_test(tcase, "DsGetDomainControllerInfo", test_DsGetDomainControllerInfo); - torture_rpc_tcase_add_drsuapi_test(tcase, "DsCrackNames", test_DsCrackNames); + priv.join = torture_join_domain(TEST_MACHINE_NAME, ACB_SVRTRUST, + &machine_credentials); + if (!priv.join) { + torture_fail(torture, "Failed to join as BDC"); + } - return suite; + status = torture_rpc_connection(torture, + &p, + &ndr_table_drsuapi); + if (!NT_STATUS_IS_OK(status)) { + torture_leave_domain(priv.join); + torture_fail(torture, "Unable to connect to DRSUAPI pipe"); + } + + ret &= test_DsBind(p, torture, &priv); +#if 0 + ret &= test_QuerySitesByCost(p, torture, &priv); +#endif + ret &= test_DsGetDomainControllerInfo(p, torture, &priv); + + ret &= test_DsCrackNames(p, torture, &priv); + + ret &= test_DsWriteAccountSpn(p, torture, &priv); + + ret &= test_DsReplicaGetInfo(p, torture, &priv); + + ret &= test_DsReplicaSync(p, torture, &priv); + + ret &= test_DsReplicaUpdateRefs(p, torture, &priv); + + ret &= test_DsGetNCChanges(p, torture, &priv); + + ret &= test_DsUnbind(p, torture, &priv); + + torture_leave_domain(priv.join); + + return ret; +} + + +bool torture_rpc_drsuapi_cracknames(struct torture_context *torture) +{ + NTSTATUS status; + struct dcerpc_pipe *p; + bool ret = true; + struct DsPrivate priv; + struct cli_credentials *machine_credentials; + + torture_comment(torture, "Connected to DRSUAPI pipe\n"); + + ZERO_STRUCT(priv); + + priv.join = torture_join_domain(TEST_MACHINE_NAME, ACB_SVRTRUST, + &machine_credentials); + if (!priv.join) { + torture_fail(torture, "Failed to join as BDC\n"); + } + + status = torture_rpc_connection(torture, + &p, + &ndr_table_drsuapi); + if (!NT_STATUS_IS_OK(status)) { + torture_leave_domain(priv.join); + torture_fail(torture, "Unable to connect to DRSUAPI pipe"); + } + + ret &= test_DsBind(p, torture, &priv); + + if (ret) { + /* We don't care if this fails, we just need some info from it */ + test_DsGetDomainControllerInfo(p, torture, &priv); + + ret &= test_DsCrackNames(p, torture, &priv); + + ret &= test_DsUnbind(p, torture, &priv); + } + + torture_leave_domain(priv.join); + + return ret; } -- cgit From 60a1046c5c5783799bd64fe18e03534670f83d82 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 29 Sep 2007 18:00:19 +0000 Subject: r25430: Add the loadparm context to all parametric options. (This used to be commit fd697d77c9fe67a00939a1f04b35c451316fff58) --- source4/torture/rpc/drsuapi.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'source4/torture/rpc/drsuapi.c') diff --git a/source4/torture/rpc/drsuapi.c b/source4/torture/rpc/drsuapi.c index 42c0cc8bda..770f73871a 100644 --- a/source4/torture/rpc/drsuapi.c +++ b/source4/torture/rpc/drsuapi.c @@ -307,7 +307,7 @@ static BOOL test_DsReplicaGetInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, } }; - if (lp_parm_bool(NULL, "torture", "samba4", False)) { + if (lp_parm_bool(global_loadparm, NULL, "torture", "samba4", False)) { printf("skipping DsReplicaGetInfo test against Samba4\n"); return True; } @@ -380,12 +380,12 @@ static BOOL test_DsReplicaSync(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, } }; - if (!lp_parm_bool(NULL, "torture", "dangerous", False)) { + if (!lp_parm_bool(global_loadparm, NULL, "torture", "dangerous", False)) { printf("DsReplicaSync disabled - enable dangerous tests to use\n"); return True; } - if (lp_parm_bool(NULL, "torture", "samba4", False)) { + if (lp_parm_bool(global_loadparm, NULL, "torture", "samba4", False)) { printf("skipping DsReplicaSync test against Samba4\n"); return True; } @@ -448,7 +448,7 @@ static BOOL test_DsReplicaUpdateRefs(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, } }; - if (lp_parm_bool(NULL, "torture", "samba4", False)) { + if (lp_parm_bool(global_loadparm, NULL, "torture", "samba4", False)) { printf("skipping DsReplicaUpdateRefs test against Samba4\n"); return True; } @@ -515,7 +515,7 @@ static BOOL test_DsGetNCChanges(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, } }; - if (lp_parm_bool(NULL, "torture", "samba4", False)) { + if (lp_parm_bool(global_loadparm, NULL, "torture", "samba4", False)) { printf("skipping DsGetNCChanges test against Samba4\n"); return True; } @@ -544,7 +544,7 @@ static BOOL test_DsGetNCChanges(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, 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(NULL, "drsuapi","compression", False)) { + if (lp_parm_bool(global_loadparm, NULL, "drsuapi","compression", False)) { r.in.req.req5.replica_flags |= DRSUAPI_DS_REPLICA_NEIGHBOUR_COMPRESS_CHANGES; } r.in.req.req5.max_object_count = 0; @@ -566,10 +566,10 @@ static BOOL test_DsGetNCChanges(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, 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(NULL,"drsuapi","compression",False)) { + if (lp_parm_bool(global_loadparm, NULL,"drsuapi","compression",False)) { r.in.req.req8.replica_flags |= DRSUAPI_DS_REPLICA_NEIGHBOUR_COMPRESS_CHANGES; } - if (lp_parm_bool(NULL,"drsuapi","neighbour_writeable",True)) { + if (lp_parm_bool(global_loadparm, 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_SYNC_ON_STARTUP -- cgit From 2151cde58014ea2e822c13d2f8a369b45dc19ca8 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 6 Oct 2007 22:28:14 +0000 Subject: r25554: Convert last instances of BOOL, True and False to the standard types. (This used to be commit 566aa14139510788548a874e9213d91317f83ca9) --- source4/torture/rpc/drsuapi.c | 98 +++++++++++++++++++++---------------------- 1 file changed, 49 insertions(+), 49 deletions(-) (limited to 'source4/torture/rpc/drsuapi.c') diff --git a/source4/torture/rpc/drsuapi.c b/source4/torture/rpc/drsuapi.c index 770f73871a..3407e49565 100644 --- a/source4/torture/rpc/drsuapi.c +++ b/source4/torture/rpc/drsuapi.c @@ -62,7 +62,7 @@ static bool test_DsGetDomainControllerInfo(struct dcerpc_pipe *p, struct torture { NTSTATUS status; struct drsuapi_DsGetDomainControllerInfo r; - BOOL found = False; + bool found = false; int i, j, k; struct { @@ -123,7 +123,7 @@ static bool test_DsGetDomainControllerInfo(struct dcerpc_pipe *p, struct torture 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; + found = true; break; } } @@ -132,7 +132,7 @@ static bool test_DsGetDomainControllerInfo(struct dcerpc_pipe *p, struct torture 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; + found = true; priv->dcinfo = r.out.ctr.ctr2.array[k]; break; } @@ -167,7 +167,7 @@ static bool test_DsGetDomainControllerInfo(struct dcerpc_pipe *p, struct torture 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; + found = true; break; } } @@ -179,13 +179,13 @@ static bool test_DsGetDomainControllerInfo(struct dcerpc_pipe *p, struct torture return true; } -static BOOL test_DsWriteAccountSpn(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +static bool test_DsWriteAccountSpn(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct DsPrivate *priv) { NTSTATUS status; struct drsuapi_DsWriteAccountSpn r; struct drsuapi_DsNameString names[2]; - BOOL ret = True; + bool ret = true; r.in.bind_handle = &priv->bind_handle; r.in.level = 1; @@ -207,10 +207,10 @@ static BOOL test_DsWriteAccountSpn(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); } printf("dcerpc_drsuapi_DsWriteAccountSpn failed - %s\n", errstr); - ret = False; + ret = false; } else if (!W_ERROR_IS_OK(r.out.result)) { printf("DsWriteAccountSpn failed - %s\n", win_errstr(r.out.result)); - ret = False; + ret = false; } r.in.req.req1.operation = DRSUAPI_DS_SPN_OPERATION_DELETE; @@ -223,21 +223,21 @@ static BOOL test_DsWriteAccountSpn(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); } printf("dcerpc_drsuapi_DsWriteAccountSpn failed - %s\n", errstr); - ret = False; + ret = false; } else if (!W_ERROR_IS_OK(r.out.result)) { printf("DsWriteAccountSpn failed - %s\n", win_errstr(r.out.result)); - ret = False; + ret = false; } return ret; } -static BOOL test_DsReplicaGetInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +static bool test_DsReplicaGetInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct DsPrivate *priv) { NTSTATUS status; struct drsuapi_DsReplicaGetInfo r; - BOOL ret = True; + bool ret = true; int i; struct { int32_t level; @@ -307,9 +307,9 @@ static BOOL test_DsReplicaGetInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, } }; - if (lp_parm_bool(global_loadparm, NULL, "torture", "samba4", False)) { + if (lp_parm_bool(global_loadparm, NULL, "torture", "samba4", false)) { printf("skipping DsReplicaGetInfo test against Samba4\n"); - return True; + return true; } r.in.bind_handle = &priv->bind_handle; @@ -348,25 +348,25 @@ static BOOL test_DsReplicaGetInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, } if (p->last_fault_code != DCERPC_FAULT_INVALID_TAG) { printf("dcerpc_drsuapi_DsReplicaGetInfo failed - %s\n", errstr); - ret = False; + ret = false; } else { printf("DsReplicaGetInfo level %d and/or infotype %d not supported by server\n", array[i].level, array[i].infotype); } } else if (!W_ERROR_IS_OK(r.out.result)) { printf("DsReplicaGetInfo failed - %s\n", win_errstr(r.out.result)); - ret = False; + ret = false; } } return ret; } -static BOOL test_DsReplicaSync(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +static bool test_DsReplicaSync(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct DsPrivate *priv) { NTSTATUS status; - BOOL ret = True; + bool ret = true; int i; struct drsuapi_DsReplicaSync r; struct drsuapi_DsReplicaObjectIdentifier nc; @@ -380,14 +380,14 @@ static BOOL test_DsReplicaSync(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, } }; - if (!lp_parm_bool(global_loadparm, NULL, "torture", "dangerous", False)) { + if (!lp_parm_bool(global_loadparm, NULL, "torture", "dangerous", false)) { printf("DsReplicaSync disabled - enable dangerous tests to use\n"); - return True; + return true; } - if (lp_parm_bool(global_loadparm, NULL, "torture", "samba4", False)) { + if (lp_parm_bool(global_loadparm, NULL, "torture", "samba4", false)) { printf("skipping DsReplicaSync test against Samba4\n"); - return True; + return true; } ZERO_STRUCT(null_guid); @@ -420,21 +420,21 @@ static BOOL test_DsReplicaSync(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); } printf("dcerpc_drsuapi_DsReplicaSync failed - %s\n", errstr); - ret = False; + ret = false; } else if (!W_ERROR_IS_OK(r.out.result)) { printf("DsReplicaSync failed - %s\n", win_errstr(r.out.result)); - ret = False; + ret = false; } } return ret; } -static BOOL test_DsReplicaUpdateRefs(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +static bool test_DsReplicaUpdateRefs(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct DsPrivate *priv) { NTSTATUS status; - BOOL ret = True; + bool ret = true; int i; struct drsuapi_DsReplicaUpdateRefs r; struct drsuapi_DsReplicaObjectIdentifier nc; @@ -448,9 +448,9 @@ static BOOL test_DsReplicaUpdateRefs(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, } }; - if (lp_parm_bool(global_loadparm, NULL, "torture", "samba4", False)) { + if (lp_parm_bool(global_loadparm, NULL, "torture", "samba4", false)) { printf("skipping DsReplicaUpdateRefs test against Samba4\n"); - return True; + return true; } ZERO_STRUCT(null_guid); @@ -484,21 +484,21 @@ static BOOL test_DsReplicaUpdateRefs(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); } printf("dcerpc_drsuapi_DsReplicaUpdateRefs failed - %s\n", errstr); - ret = False; + ret = false; } else if (!W_ERROR_IS_OK(r.out.result)) { printf("DsReplicaUpdateRefs failed - %s\n", win_errstr(r.out.result)); - ret = False; + ret = false; } } return ret; } -static BOOL test_DsGetNCChanges(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +static bool test_DsGetNCChanges(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct DsPrivate *priv) { NTSTATUS status; - BOOL ret = True; + bool ret = true; int i; struct drsuapi_DsGetNCChanges r; struct drsuapi_DsReplicaObjectIdentifier nc; @@ -515,9 +515,9 @@ static BOOL test_DsGetNCChanges(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, } }; - if (lp_parm_bool(global_loadparm, NULL, "torture", "samba4", False)) { + if (lp_parm_bool(global_loadparm, NULL, "torture", "samba4", false)) { printf("skipping DsGetNCChanges test against Samba4\n"); - return True; + return true; } ZERO_STRUCT(null_guid); @@ -544,7 +544,7 @@ static BOOL test_DsGetNCChanges(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, 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(global_loadparm, NULL, "drsuapi","compression", False)) { + if (lp_parm_bool(global_loadparm, NULL, "drsuapi","compression", false)) { r.in.req.req5.replica_flags |= DRSUAPI_DS_REPLICA_NEIGHBOUR_COMPRESS_CHANGES; } r.in.req.req5.max_object_count = 0; @@ -566,10 +566,10 @@ static BOOL test_DsGetNCChanges(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, 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(global_loadparm, NULL,"drsuapi","compression",False)) { + if (lp_parm_bool(global_loadparm, NULL, "drsuapi", "compression", false)) { r.in.req.req8.replica_flags |= DRSUAPI_DS_REPLICA_NEIGHBOUR_COMPRESS_CHANGES; } - if (lp_parm_bool(global_loadparm, NULL,"drsuapi","neighbour_writeable",True)) { + if (lp_parm_bool(global_loadparm, 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_SYNC_ON_STARTUP @@ -596,22 +596,22 @@ static BOOL test_DsGetNCChanges(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); } printf("dcerpc_drsuapi_DsGetNCChanges failed - %s\n", errstr); - ret = False; + ret = false; } else if (!W_ERROR_IS_OK(r.out.result)) { printf("DsGetNCChanges failed - %s\n", win_errstr(r.out.result)); - ret = False; + ret = false; } } return ret; } -BOOL test_QuerySitesByCost(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +bool test_QuerySitesByCost(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct DsPrivate *priv) { NTSTATUS status; struct drsuapi_QuerySitesByCost r; - BOOL ret = True; + bool ret = true; const char *my_site = "Default-First-Site-Name"; const char *remote_site1 = "smbtorture-nonexisting-site1"; @@ -633,10 +633,10 @@ BOOL test_QuerySitesByCost(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); } printf("drsuapi_QuerySitesByCost - %s\n", errstr); - ret = False; + ret = false; } else if (!W_ERROR_IS_OK(r.out.result)) { printf("QuerySitesByCost failed - %s\n", win_errstr(r.out.result)); - ret = False; + ret = false; } if (W_ERROR_IS_OK(r.out.result)) { @@ -645,14 +645,14 @@ BOOL test_QuerySitesByCost(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, !W_ERROR_EQUAL(r.out.ctr.ctr1.info[1].error_code, WERR_DS_OBJ_NOT_FOUND)) { printf("expected error_code WERR_DS_OBJ_NOT_FOUND, got %s\n", win_errstr(r.out.ctr.ctr1.info[0].error_code)); - ret = False; + ret = false; } if ((r.out.ctr.ctr1.info[0].site_cost != (uint32_t) -1) || (r.out.ctr.ctr1.info[1].site_cost != (uint32_t) -1)) { printf("expected site_cost %d, got %d\n", (uint32_t) -1, r.out.ctr.ctr1.info[0].site_cost); - ret = False; + ret = false; } } @@ -661,12 +661,12 @@ BOOL test_QuerySitesByCost(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, } -BOOL test_DsUnbind(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +bool test_DsUnbind(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct DsPrivate *priv) { NTSTATUS status; struct drsuapi_DsUnbind r; - BOOL ret = True; + bool ret = true; r.in.bind_handle = &priv->bind_handle; r.out.bind_handle = &priv->bind_handle; @@ -680,10 +680,10 @@ BOOL test_DsUnbind(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); } printf("dcerpc_drsuapi_DsUnbind failed - %s\n", errstr); - ret = False; + ret = false; } else if (!W_ERROR_IS_OK(r.out.result)) { printf("DsBind failed - %s\n", win_errstr(r.out.result)); - ret = False; + ret = false; } return ret; -- cgit From bbdfbf8d9d486aee51117976b8f825759a4c4a37 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 3 Dec 2007 00:28:22 +0100 Subject: r26238: Add a loadparm context parameter to torture_context, remove more uses of global_loadparm. (This used to be commit a33a5530545086b81a3b205aa109dff11c546926) --- source4/torture/rpc/drsuapi.c | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) (limited to 'source4/torture/rpc/drsuapi.c') diff --git a/source4/torture/rpc/drsuapi.c b/source4/torture/rpc/drsuapi.c index 3407e49565..ee752c6568 100644 --- a/source4/torture/rpc/drsuapi.c +++ b/source4/torture/rpc/drsuapi.c @@ -232,7 +232,7 @@ static bool test_DsWriteAccountSpn(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, return ret; } -static bool test_DsReplicaGetInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +static bool test_DsReplicaGetInfo(struct dcerpc_pipe *p, struct torture_context *tctx, struct DsPrivate *priv) { NTSTATUS status; @@ -307,7 +307,7 @@ static bool test_DsReplicaGetInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, } }; - if (lp_parm_bool(global_loadparm, NULL, "torture", "samba4", false)) { + if (torture_setting_bool(tctx, "samba4", false)) { printf("skipping DsReplicaGetInfo test against Samba4\n"); return true; } @@ -340,11 +340,11 @@ static bool test_DsReplicaGetInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, break; } - status = dcerpc_drsuapi_DsReplicaGetInfo(p, mem_ctx, &r); + status = dcerpc_drsuapi_DsReplicaGetInfo(p, tctx, &r); if (!NT_STATUS_IS_OK(status)) { const char *errstr = nt_errstr(status); if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { - errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); + errstr = dcerpc_errstr(tctx, p->last_fault_code); } if (p->last_fault_code != DCERPC_FAULT_INVALID_TAG) { printf("dcerpc_drsuapi_DsReplicaGetInfo failed - %s\n", errstr); @@ -362,7 +362,7 @@ static bool test_DsReplicaGetInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, return ret; } -static bool test_DsReplicaSync(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +static bool test_DsReplicaSync(struct dcerpc_pipe *p, struct torture_context *tctx, struct DsPrivate *priv) { NTSTATUS status; @@ -380,12 +380,12 @@ static bool test_DsReplicaSync(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, } }; - if (!lp_parm_bool(global_loadparm, NULL, "torture", "dangerous", false)) { + if (!torture_setting_bool(tctx, "dangerous", false)) { printf("DsReplicaSync disabled - enable dangerous tests to use\n"); return true; } - if (lp_parm_bool(global_loadparm, NULL, "torture", "samba4", false)) { + if (torture_setting_bool(tctx, "samba4", false)) { printf("skipping DsReplicaSync test against Samba4\n"); return true; } @@ -413,11 +413,11 @@ static bool test_DsReplicaSync(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, break; } - status = dcerpc_drsuapi_DsReplicaSync(p, mem_ctx, &r); + status = dcerpc_drsuapi_DsReplicaSync(p, tctx, &r); if (!NT_STATUS_IS_OK(status)) { const char *errstr = nt_errstr(status); if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { - errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); + errstr = dcerpc_errstr(tctx, p->last_fault_code); } printf("dcerpc_drsuapi_DsReplicaSync failed - %s\n", errstr); ret = false; @@ -430,7 +430,7 @@ static bool test_DsReplicaSync(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, return ret; } -static bool test_DsReplicaUpdateRefs(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +static bool test_DsReplicaUpdateRefs(struct dcerpc_pipe *p, struct torture_context *tctx, struct DsPrivate *priv) { NTSTATUS status; @@ -448,7 +448,7 @@ static bool test_DsReplicaUpdateRefs(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, } }; - if (lp_parm_bool(global_loadparm, NULL, "torture", "samba4", false)) { + if (torture_setting_bool(tctx, "samba4", false)) { printf("skipping DsReplicaUpdateRefs test against Samba4\n"); return true; } @@ -470,18 +470,18 @@ static bool test_DsReplicaUpdateRefs(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, nc.dn = priv->domain_obj_dn?priv->domain_obj_dn:""; r.in.req.req1.naming_context = &nc; - r.in.req.req1.dest_dsa_dns_name = talloc_asprintf(mem_ctx, "__some_dest_dsa_guid_string._msdn.%s", + r.in.req.req1.dest_dsa_dns_name = talloc_asprintf(tctx, "__some_dest_dsa_guid_string._msdn.%s", priv->domain_dns_name); r.in.req.req1.dest_dsa_guid = null_guid; r.in.req.req1.options = 0; break; } - status = dcerpc_drsuapi_DsReplicaUpdateRefs(p, mem_ctx, &r); + status = dcerpc_drsuapi_DsReplicaUpdateRefs(p, tctx, &r); if (!NT_STATUS_IS_OK(status)) { const char *errstr = nt_errstr(status); if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { - errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); + errstr = dcerpc_errstr(tctx, p->last_fault_code); } printf("dcerpc_drsuapi_DsReplicaUpdateRefs failed - %s\n", errstr); ret = false; @@ -494,7 +494,7 @@ static bool test_DsReplicaUpdateRefs(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, return ret; } -static bool test_DsGetNCChanges(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +static bool test_DsGetNCChanges(struct dcerpc_pipe *p, struct torture_context *tctx, struct DsPrivate *priv) { NTSTATUS status; @@ -515,7 +515,7 @@ static bool test_DsGetNCChanges(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, } }; - if (lp_parm_bool(global_loadparm, NULL, "torture", "samba4", false)) { + if (torture_setting_bool(tctx, "samba4", false)) { printf("skipping DsGetNCChanges test against Samba4\n"); return true; } @@ -589,11 +589,11 @@ static bool test_DsGetNCChanges(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, break; } - status = dcerpc_drsuapi_DsGetNCChanges(p, mem_ctx, &r); + status = dcerpc_drsuapi_DsGetNCChanges(p, tctx, &r); if (!NT_STATUS_IS_OK(status)) { const char *errstr = nt_errstr(status); if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { - errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); + errstr = dcerpc_errstr(tctx, p->last_fault_code); } printf("dcerpc_drsuapi_DsGetNCChanges failed - %s\n", errstr); ret = false; -- cgit From ab69eb8d8901d23794c6a298718e67656ef4820e Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 3 Dec 2007 15:53:17 +0100 Subject: r26250: Avoid global_loadparm in a couple more places. (This used to be commit 2c6b755309fdf685cd0b0564272bf83038574a43) --- source4/torture/rpc/drsuapi.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'source4/torture/rpc/drsuapi.c') diff --git a/source4/torture/rpc/drsuapi.c b/source4/torture/rpc/drsuapi.c index ee752c6568..7fc2406bbf 100644 --- a/source4/torture/rpc/drsuapi.c +++ b/source4/torture/rpc/drsuapi.c @@ -544,7 +544,7 @@ static bool test_DsGetNCChanges(struct dcerpc_pipe *p, struct torture_context *t 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(global_loadparm, NULL, "drsuapi","compression", false)) { + 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.max_object_count = 0; @@ -566,10 +566,10 @@ static bool test_DsGetNCChanges(struct dcerpc_pipe *p, struct torture_context *t 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(global_loadparm, NULL, "drsuapi", "compression", false)) { + if (lp_parm_bool(tctx->lp_ctx, NULL, "drsuapi", "compression", false)) { r.in.req.req8.replica_flags |= DRSUAPI_DS_REPLICA_NEIGHBOUR_COMPRESS_CHANGES; } - if (lp_parm_bool(global_loadparm, NULL, "drsuapi", "neighbour_writeable", true)) { + 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_SYNC_ON_STARTUP @@ -699,7 +699,7 @@ bool torture_rpc_drsuapi(struct torture_context *torture) ZERO_STRUCT(priv); - priv.join = torture_join_domain(TEST_MACHINE_NAME, ACB_SVRTRUST, + priv.join = torture_join_domain(torture, TEST_MACHINE_NAME, ACB_SVRTRUST, &machine_credentials); if (!priv.join) { torture_fail(torture, "Failed to join as BDC"); @@ -751,7 +751,7 @@ bool torture_rpc_drsuapi_cracknames(struct torture_context *torture) ZERO_STRUCT(priv); - priv.join = torture_join_domain(TEST_MACHINE_NAME, ACB_SVRTRUST, + priv.join = torture_join_domain(torture, TEST_MACHINE_NAME, ACB_SVRTRUST, &machine_credentials); if (!priv.join) { torture_fail(torture, "Failed to join as BDC\n"); -- cgit From 509e82e402d64c79f27c9a10d75b100a1ac5fefa Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 3 Dec 2007 23:33:22 +0100 Subject: r26272: Remove global_loadparm in some more places. (This used to be commit 1ab76ecc5311fa863e5d04899b6f110899818f55) --- source4/torture/rpc/drsuapi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/torture/rpc/drsuapi.c') diff --git a/source4/torture/rpc/drsuapi.c b/source4/torture/rpc/drsuapi.c index 7fc2406bbf..5e01c2050c 100644 --- a/source4/torture/rpc/drsuapi.c +++ b/source4/torture/rpc/drsuapi.c @@ -719,7 +719,7 @@ bool torture_rpc_drsuapi(struct torture_context *torture) #endif ret &= test_DsGetDomainControllerInfo(p, torture, &priv); - ret &= test_DsCrackNames(p, torture, &priv); + ret &= test_DsCrackNames(torture, p, torture, &priv); ret &= test_DsWriteAccountSpn(p, torture, &priv); @@ -771,7 +771,7 @@ bool torture_rpc_drsuapi_cracknames(struct torture_context *torture) /* We don't care if this fails, we just need some info from it */ test_DsGetDomainControllerInfo(p, torture, &priv); - ret &= test_DsCrackNames(p, torture, &priv); + ret &= test_DsCrackNames(torture, p, torture, &priv); ret &= test_DsUnbind(p, torture, &priv); } -- cgit From 929adc9efa5cf985f0585214d30d18521aa1a821 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Sat, 14 Jun 2008 11:24:17 -0400 Subject: Make up the right dependencies now that ldb depends on libevents (This used to be commit 3b8eec7ca334528cad3cdcd5e3fc5ee555d8d0e0) --- source4/torture/rpc/drsuapi.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source4/torture/rpc/drsuapi.c') diff --git a/source4/torture/rpc/drsuapi.c b/source4/torture/rpc/drsuapi.c index 5e01c2050c..bbdb73ed55 100644 --- a/source4/torture/rpc/drsuapi.c +++ b/source4/torture/rpc/drsuapi.c @@ -709,7 +709,7 @@ bool torture_rpc_drsuapi(struct torture_context *torture) &p, &ndr_table_drsuapi); if (!NT_STATUS_IS_OK(status)) { - torture_leave_domain(priv.join); + torture_leave_domain(torture, priv.join); torture_fail(torture, "Unable to connect to DRSUAPI pipe"); } @@ -733,7 +733,7 @@ bool torture_rpc_drsuapi(struct torture_context *torture) ret &= test_DsUnbind(p, torture, &priv); - torture_leave_domain(priv.join); + torture_leave_domain(torture, priv.join); return ret; } @@ -761,7 +761,7 @@ bool torture_rpc_drsuapi_cracknames(struct torture_context *torture) &p, &ndr_table_drsuapi); if (!NT_STATUS_IS_OK(status)) { - torture_leave_domain(priv.join); + torture_leave_domain(torture, priv.join); torture_fail(torture, "Unable to connect to DRSUAPI pipe"); } @@ -776,7 +776,7 @@ bool torture_rpc_drsuapi_cracknames(struct torture_context *torture) ret &= test_DsUnbind(p, torture, &priv); } - torture_leave_domain(priv.join); + torture_leave_domain(torture, priv.join); return ret; } -- cgit From c88ec856bd88a22e281cd9cf99ad2828d4bbbe2b Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 30 Jun 2008 13:03:17 +0200 Subject: drsuapi.idl: remove some unknows from DsGetNCChanges() (update samba4 callers) metze (This used to be commit d41b3dd6ffc4fd894bc05798dbc2ff4b53933a06) --- source4/torture/rpc/drsuapi.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'source4/torture/rpc/drsuapi.c') diff --git a/source4/torture/rpc/drsuapi.c b/source4/torture/rpc/drsuapi.c index bbdb73ed55..e5cb3d7ddf 100644 --- a/source4/torture/rpc/drsuapi.c +++ b/source4/torture/rpc/drsuapi.c @@ -549,8 +549,8 @@ static bool test_DsGetNCChanges(struct dcerpc_pipe *p, struct torture_context *t } r.in.req.req5.max_object_count = 0; r.in.req.req5.max_ndr_size = 0; - r.in.req.req5.unknown4 = 0; - r.in.req.req5.h1 = 0; + r.in.req.req5.extended_op = DRSUAPI_EXOP_NONE; + r.in.req.req5.fsmo_info = 0; break; case 8: @@ -579,10 +579,10 @@ static bool test_DsGetNCChanges(struct dcerpc_pipe *p, struct torture_context *t ; r.in.req.req8.max_object_count = 402; r.in.req.req8.max_ndr_size = 402116; - r.in.req.req8.unknown4 = 0; - r.in.req.req8.h1 = 0; - r.in.req.req8.unique_ptr1 = 0; - r.in.req.req8.unique_ptr2 = 0; + 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; -- cgit