summaryrefslogtreecommitdiff
path: root/source4/torture/rpc/remact.c
blob: 1136f680252009289644fcb7565e9225e0c26564 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
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.ClientImpLevel = RPC_C_IMP_LEVEL_IDENTIFY;
	r.in.num_protseqs = 2;
	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.hr))) {
		fprintf(stderr, "RemoteActivation: %s\n", win_errstr(W_ERROR(r.out.hr)));
		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;
}