2 Unix SMB/CIFS implementation.
3 test suite for winreg rpc operations
5 Copyright (C) Tim Potter 2003
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 static BOOL test_GetVersion(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
25 struct policy_handle *handle)
28 struct winreg_GetVersion r;
30 printf("\ntesting GetVersion\n");
34 status = dcerpc_winreg_GetVersion(p, mem_ctx, &r);
36 if (!NT_STATUS_IS_OK(status)) {
37 printf("GetVersion failed - %s\n", nt_errstr(status));
44 static BOOL test_CloseKey(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
45 struct policy_handle *handle)
48 struct winreg_CloseKey r;
50 printf("\ntesting CloseKey\n");
52 r.in.handle = r.out.handle = handle;
54 status = dcerpc_winreg_CloseKey(p, mem_ctx, &r);
56 if (!NT_STATUS_IS_OK(status)) {
57 printf("CloseKey failed - %s\n", nt_errstr(status));
64 static BOOL test_OpenHKLM(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
67 struct winreg_OpenHKLM r;
68 struct winreg_OpenHKLMUnknown unknown;
69 struct policy_handle handle;
72 printf("\ntesting OpenHKLM\n");
74 unknown.unknown0 = 0x84e0;
75 unknown.unknown1 = 0x0000;
76 r.in.unknown = &unknown;
77 r.in.access_required = SEC_RIGHTS_MAXIMUM_ALLOWED;
78 r.out.handle = &handle;
80 status = dcerpc_winreg_OpenHKLM(p, mem_ctx, &r);
82 if (!NT_STATUS_IS_OK(status)) {
83 printf("OpenHKLM failed - %s\n", nt_errstr(status));
87 if (!test_GetVersion(p, mem_ctx, &handle)) {
91 if (!test_CloseKey(p, mem_ctx, &handle)) {
98 BOOL torture_rpc_winreg(int dummy)
101 struct dcerpc_pipe *p;
105 mem_ctx = talloc_init("torture_rpc_winreg");
107 status = torture_rpc_connection(&p,
110 DCERPC_WINREG_VERSION);
111 if (!NT_STATUS_IS_OK(status)) {
115 p->flags |= DCERPC_DEBUG_PRINT_BOTH;
117 if (!test_OpenHKLM(p, mem_ctx)) {
121 torture_rpc_close(p);