From 6d3c74a67b935f348777feb3fac7653a9c4277a8 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 3 Nov 2004 20:32:28 +0000 Subject: r3513: Add (the infrastructure for) DCOM support. Contents: - Support for sending over the object UUID in DCERPC calls - Simple torture test for the DCOM "Simple" object - Generate extra argument for "object" interfaces in pidl - Some stubs for common DCOM functions (This used to be commit c052f2e1edd816206d8974af3140cec7ef97a70c) --- source4/torture/config.m4 | 2 ++ source4/torture/config.mk | 11 ++++++ source4/torture/dcom/simple.c | 75 ++++++++++++++++++++++++++++++++++++++++ source4/torture/rpc/autoidl.c | 8 ++--- source4/torture/rpc/countcalls.c | 2 +- source4/torture/rpc/eventlog.c | 2 +- source4/torture/rpc/remact.c | 1 + source4/torture/rpc/scanner.c | 2 +- source4/torture/torture.c | 3 ++ 9 files changed, 99 insertions(+), 7 deletions(-) create mode 100644 source4/torture/dcom/simple.c (limited to 'source4/torture') diff --git a/source4/torture/config.m4 b/source4/torture/config.m4 index fdd5be1355..a1f9cdac68 100644 --- a/source4/torture/config.m4 +++ b/source4/torture/config.m4 @@ -4,6 +4,8 @@ SMB_SUBSYSTEM_MK(TORTURE_BASIC,torture/config.mk) SMB_SUBSYSTEM_MK(TORTURE_RAW,torture/config.mk) +SMB_SUBSYSTEM_MK(TORTURE_DCOM,torture/config.mk) + SMB_SUBSYSTEM_MK(TORTURE_RPC,torture/config.mk) SMB_SUBSYSTEM_MK(TORTURE_RAP,torture/config.mk) diff --git a/source4/torture/config.mk b/source4/torture/config.mk index 1c22506b07..aa77238ec5 100644 --- a/source4/torture/config.mk +++ b/source4/torture/config.mk @@ -49,6 +49,16 @@ REQUIRED_SUBSYSTEMS = \ # End SUBSYSTEM TORTURE_RAW ################################# +################################# +# Start SUBSYSTEM TORTURE_DCOM +[SUBSYSTEM::TORTURE_DCOM] +ADD_OBJ_FILES = \ + torture/dcom/simple.o +REQUIRED_SUBSYSTEMS = \ + LIBDCOM +# End SUBSYSTEM TORTURE_DCOM +################################# + ################################# # Start SUBSYSTEM TORTURE_RPC [SUBSYSTEM::TORTURE_RPC] @@ -147,6 +157,7 @@ REQUIRED_SUBSYSTEMS = \ TORTURE_BASIC \ TORTURE_RAW \ TORTURE_RPC \ + TORTURE_DCOM \ TORTURE_RAP \ TORTURE_AUTH \ TORTURE_LOCAL \ diff --git a/source4/torture/dcom/simple.c b/source4/torture/dcom/simple.c new file mode 100644 index 0000000000..b52733e1f6 --- /dev/null +++ b/source4/torture/dcom/simple.c @@ -0,0 +1,75 @@ +/* + Unix SMB/CIFS implementation. + run the "simple" example DCOM program + + Copyright (C) Jelmer Vernooij 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_dcom.h" +#include "librpc/gen_ndr/ndr_oxidresolver.h" + +#define CLSID_SIMPLE "5e9ddec7-5767-11cf-beab-00aa006c3606" +#define DEFAULT_TRANS 4096 + +BOOL torture_dcom_simple(void) +{ + NTSTATUS status; + struct dcerpc_pipe *p; + TALLOC_CTX *mem_ctx; + BOOL ret = True; + struct GUID IID[2]; + struct GUID clsid; + WERROR error; + char pv[DEFAULT_TRANS]; + struct dcom_interface *interfaces; + struct IStream_Read r_read; + struct IStream_Write r_write; + + mem_ctx = talloc_init("torture_dcom_simple"); + + GUID_from_string(DCERPC_ISTREAM_UUID, &IID[0]); + GUID_from_string(DCERPC_IUNKNOWN_UUID, &IID[1]); + GUID_from_string(CLSID_SIMPLE, &clsid); + error = dcom_create_object(mem_ctx, &clsid, "192.168.4.28", 2, IID, &interfaces); + + if (!W_ERROR_IS_OK(error)) { + printf("dcom_create_object failed - %s\n", win_errstr(error)); + return False; + } + + ZERO_STRUCT(r_read); + status = dcerpc_IStream_Read(interfaces[0].pipe, &interfaces[0].ipid, mem_ctx, &r_read); + if (NT_STATUS_IS_ERR(error)) { + printf("IStream::Read() failed - %s\n", win_errstr(error)); + return False; + } + + + status = dcerpc_IStream_Write(interfaces[0].pipe, &interfaces[0].ipid, mem_ctx, &r_write); + if (NT_STATUS_IS_ERR(error)) { + printf("IStream::Write() failed - %s\n", win_errstr(error)); + return False; + } + + /*FIXME: dcerpc_IUnknown_Release();*/ + + talloc_destroy(mem_ctx); + + torture_rpc_close(p); + return ret; +} diff --git a/source4/torture/rpc/autoidl.c b/source4/torture/rpc/autoidl.c index 619779302b..49d0a5bcb8 100644 --- a/source4/torture/rpc/autoidl.c +++ b/source4/torture/rpc/autoidl.c @@ -127,7 +127,7 @@ static void try_expand(TALLOC_CTX *mem_ctx, const struct dcerpc_interface_table 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); + status = dcerpc_request(p, NULL, opnum, mem_ctx, &stub_in, &stub_out); if (!NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { print_depth(depth); @@ -168,7 +168,7 @@ static void test_ptr_scan(TALLOC_CTX *mem_ctx, const struct dcerpc_interface_tab /* 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); + status = dcerpc_request(p, NULL, opnum, mem_ctx, &stub_in, &stub_out); if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { print_depth(depth); @@ -210,7 +210,7 @@ static void test_scan_call(TALLOC_CTX *mem_ctx, const struct dcerpc_interface_ta data_blob_clear(&stub_in); - status = dcerpc_request(p, opnum, mem_ctx, &stub_in, &stub_out); + status = dcerpc_request(p, NULL, opnum, mem_ctx, &stub_in, &stub_out); if (NT_STATUS_IS_OK(status)) { printf("opnum %d min_input %d - output %d\n", @@ -223,7 +223,7 @@ static void test_scan_call(TALLOC_CTX *mem_ctx, const struct dcerpc_interface_ta fill_blob_handle(&stub_in, mem_ctx, &handle); - status = dcerpc_request(p, opnum, mem_ctx, &stub_in, &stub_out); + status = dcerpc_request(p, NULL, opnum, mem_ctx, &stub_in, &stub_out); if (NT_STATUS_IS_OK(status)) { printf("opnum %d min_input %d - output %d (with handle)\n", diff --git a/source4/torture/rpc/countcalls.c b/source4/torture/rpc/countcalls.c index c914622061..4d3e729980 100644 --- a/source4/torture/rpc/countcalls.c +++ b/source4/torture/rpc/countcalls.c @@ -56,7 +56,7 @@ BOOL torture_rpc_countcalls(void) printf("\nScanning pipe '%s'\n", iface->name); for (i=0;i<5000;i++) { - status = dcerpc_request(p, i, p, &stub_in, &stub_out); + status = dcerpc_request(p, NULL, i, p, &stub_in, &stub_out); if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT) && p->last_fault_code == DCERPC_FAULT_OP_RNG_ERROR) break; } diff --git a/source4/torture/rpc/eventlog.c b/source4/torture/rpc/eventlog.c index a98b3e9e79..91e012cdec 100644 --- a/source4/torture/rpc/eventlog.c +++ b/source4/torture/rpc/eventlog.c @@ -93,7 +93,7 @@ static BOOL test_ReadEventLog(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct return True; } -BOOL test_CloseEventLog(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +static BOOL test_CloseEventLog(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct policy_handle *handle) { NTSTATUS status; diff --git a/source4/torture/rpc/remact.c b/source4/torture/rpc/remact.c index b28be9222f..073b8177c6 100644 --- a/source4/torture/rpc/remact.c +++ b/source4/torture/rpc/remact.c @@ -67,6 +67,7 @@ static int test_RemoteActivation(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) return 0; } + GUID_from_string(DCERPC_ICLASSFACTORY_UUID, &iids[0]); r.in.Mode = MODE_GET_CLASS_OBJECT; status = dcerpc_RemoteActivation(p, mem_ctx, &r); diff --git a/source4/torture/rpc/scanner.c b/source4/torture/rpc/scanner.c index 134272271c..4a1210119c 100644 --- a/source4/torture/rpc/scanner.c +++ b/source4/torture/rpc/scanner.c @@ -53,7 +53,7 @@ static BOOL test_num_calls(const struct dcerpc_interface_table *iface, memset(stub_in.data, 0xFF, stub_in.length); for (i=0;i<200;i++) { - status = dcerpc_request(p, i, mem_ctx, &stub_in, &stub_out); + status = dcerpc_request(p, NULL, i, mem_ctx, &stub_in, &stub_out); if (!NT_STATUS_IS_OK(status) && p->last_fault_code == DCERPC_FAULT_OP_RNG_ERROR) { break; diff --git a/source4/torture/torture.c b/source4/torture/torture.c index 19dc311dd9..86796c67d7 100644 --- a/source4/torture/torture.c +++ b/source4/torture/torture.c @@ -2506,6 +2506,9 @@ static struct { {"RPC-MULTIBIND", torture_multi_bind, 0}, {"RPC-DRSUAPI", torture_rpc_drsuapi, 0}, + /* Distributed COM testers */ + {"DCOM-SIMPLE", torture_dcom_simple, 0}, + /* local (no server) testers */ {"LOCAL-NTLMSSP", torture_ntlmssp_self_check, 0}, {"LOCAL-ICONV", torture_local_iconv, 0}, -- cgit