From 12649343f903c98dd658724d1765b1db62eeb928 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 31 Oct 2004 18:40:08 +0000 Subject: r3414: RemoteActivation torture test (This used to be commit bcb89806fe45db50988f241db51989d90aa2289c) --- source4/torture/rpc/epmapper.c | 71 +++++++++++++++++++++----------- source4/torture/rpc/remact.c | 92 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 139 insertions(+), 24 deletions(-) create mode 100644 source4/torture/rpc/remact.c (limited to 'source4/torture/rpc') diff --git a/source4/torture/rpc/epmapper.c b/source4/torture/rpc/epmapper.c index 6382800cec..b1076e64c6 100644 --- a/source4/torture/rpc/epmapper.c +++ b/source4/torture/rpc/epmapper.c @@ -130,8 +130,7 @@ static BOOL test_Map(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct GUID uuid; const char *uuid_str; struct policy_handle handle; - int i, j; - const char *test_bindings[] = { "ncacn_np:", "ncacn_ip_tcp:", "ncalrpc:", "ncadg_ip_udp:" }; + int i; ZERO_STRUCT(uuid); ZERO_STRUCT(handle); @@ -147,34 +146,58 @@ static BOOL test_Map(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, printf("epm_Map results for '%s':\n", idl_pipe_name(uuid_str, twr->tower.floors[0].lhs.info.uuid.version)); - for (i = 0; i < ARRAY_SIZE(test_bindings); i++) - { - struct dcerpc_binding binding; - status = dcerpc_parse_binding(mem_ctx, test_bindings[i], &binding); + twr->tower.floors[2].lhs.protocol = EPM_PROTOCOL_NCACN; + twr->tower.floors[2].lhs.info.lhs_data = data_blob(NULL, 0); + twr->tower.floors[2].rhs.ncacn.minor_version = 0; + + twr->tower.floors[3].lhs.protocol = EPM_PROTOCOL_TCP; + twr->tower.floors[3].lhs.info.lhs_data = data_blob(NULL, 0); + twr->tower.floors[3].rhs.tcp.port = 0; - if (NT_STATUS_IS_ERR(status)) { - printf("Error parsing binding string '%s'\n", test_bindings[i]); - return False; + twr->tower.floors[4].lhs.protocol = EPM_PROTOCOL_IP; + twr->tower.floors[4].lhs.info.lhs_data = data_blob(NULL, 0); + twr->tower.floors[4].rhs.ip.address = 0; + + status = dcerpc_epm_Map(p, mem_ctx, &r); + if (NT_STATUS_IS_OK(status) && r.out.result == 0) { + for (i=0;itower); + } } + } + + twr->tower.floors[3].lhs.protocol = EPM_PROTOCOL_HTTP; + twr->tower.floors[3].lhs.info.lhs_data = data_blob(NULL, 0); + twr->tower.floors[3].rhs.http.port = 0; - binding.object = twr->tower.floors[0].lhs.info.uuid.uuid; - binding.object_version = twr->tower.floors[0].lhs.info.uuid.version; - - status = dcerpc_binding_build_tower(mem_ctx, &binding, &twr->tower); - if (NT_STATUS_IS_ERR(status)) { - printf("Error parsing binding string '%s'\n", test_bindings[i]); - return False; - } - - status = dcerpc_epm_Map(p, mem_ctx, &r); - if (NT_STATUS_IS_OK(status) && r.out.result == 0) { - for (j=0;jtower); - } + status = dcerpc_epm_Map(p, mem_ctx, &r); + if (NT_STATUS_IS_OK(status) && r.out.result == 0) { + for (i=0;itower); } } } + + twr->tower.floors[3].lhs.protocol = EPM_PROTOCOL_SMB; + twr->tower.floors[3].lhs.info.lhs_data = data_blob(NULL, 0); + twr->tower.floors[3].rhs.smb.unc = ""; + + twr->tower.floors[4].lhs.protocol = EPM_PROTOCOL_NETBIOS; + twr->tower.floors[4].lhs.info.lhs_data = data_blob(NULL, 0); + twr->tower.floors[4].rhs.netbios.name = ""; + + status = dcerpc_epm_Map(p, mem_ctx, &r); + if (NT_STATUS_IS_OK(status) && r.out.result == 0) { + for (i=0;itower); + } + } + } + + /* FIXME: Extend to do other protocols as well (ncacn_unix_stream, ncalrpc) */ return True; } diff --git a/source4/torture/rpc/remact.c b/source4/torture/rpc/remact.c new file mode 100644 index 0000000000..c2f206c863 --- /dev/null +++ b/source4/torture/rpc/remact.c @@ -0,0 +1,92 @@ +/* + Unix SMB/CIFS implementation. + test suite for remoteactivation operations + + 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" + +#define CLSID_TEST "00000316-0000-0000-C000-000000000046" +#define CLSID_SIMPLE "5e9ddec7-5767-11cf-beab-00aa006c3606" +#define CLSID_COFFEEMACHINE "DB7C21F8-FE33-4C11-AEA5-CEB56F076FBB" + +static int test_RemoteActivation(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) +{ + struct RemoteActivation r; + NTSTATUS status; + struct GUID iids[2]; + uint16 protseq[2] = { EPM_PROTOCOL_TCP, EPM_PROTOCOL_NCALRPC }; + + ZERO_STRUCT(r.in); + r.in.this.version.MajorVersion = 5; + r.in.this.version.MinorVersion = 1; + uuid_generate_random(&r.in.this.cid); + GUID_from_string(CLSID_SIMPLE, &r.in.Clsid); + r.in.num_protseqs = 1; + r.in.ClientImpLevel = RPC_C_IMP_LEVEL_IDENTIFY; + r.in.protseq = protseq; + r.in.Interfaces = 1; + GUID_from_string(DCERPC_IUNKNOWN_UUID, &iids[0]); + r.in.pIIDs = iids; + + status = dcerpc_RemoteActivation(p, mem_ctx, &r); + if(NT_STATUS_IS_ERR(status)) { + fprintf(stderr, "RemoteActivation: %s\n", nt_errstr(status)); + return 0; + } + + if(!W_ERROR_IS_OK(r.out.result)) { + fprintf(stderr, "RemoteActivation: %s\n", win_errstr(r.out.result)); + return 0; + } + + if(!W_ERROR_IS_OK(W_ERROR(r.out.phr))) { + fprintf(stderr, "RemoteActivation: %s\n", win_errstr(W_ERROR(r.out.phr))); + return 0; + } + + return 1; +} + +BOOL torture_rpc_remact(void) +{ + NTSTATUS status; + struct dcerpc_pipe *p; + TALLOC_CTX *mem_ctx; + BOOL ret = True; + + mem_ctx = talloc_init("torture_rpc_remact"); + + status = torture_rpc_connection(&p, + DCERPC_IREMOTEACTIVATION_NAME, + DCERPC_IREMOTEACTIVATION_UUID, + DCERPC_IREMOTEACTIVATION_VERSION); + + if (!NT_STATUS_IS_OK(status)) { + return False; + } + + if(!test_RemoteActivation(p, mem_ctx)) + ret = False; + + talloc_destroy(mem_ctx); + + torture_rpc_close(p); + + return ret; +} -- cgit