/* [<][>][^][v][top][bottom][index][help] */
DEFINITIONS
This source file includes following definitions.
- test_PNP_GetVersion
- test_PNP_GetDeviceListSize
- test_PNP_GetDeviceList
- test_PNP_GetDeviceRegProp
- torture_rpc_ntsvcs
1 /*
2 Unix SMB/CIFS implementation.
3 test suite for rpc ntsvcs operations
4
5 Copyright (C) Guenther Deschner 2008
6
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 3 of the License, or
10 (at your option) any later version.
11
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.
16
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.
20 */
21
22 #include "includes.h"
23 #include "lib/torture/torture.h"
24 #include "torture/rpc/rpc.h"
25 #include "librpc/gen_ndr/ndr_ntsvcs_c.h"
26 #include "torture/util.h"
27 #include "param/param.h"
28
29 static bool test_PNP_GetVersion(struct torture_context *tctx,
/* [<][>][^][v][top][bottom][index][help] */
30 struct dcerpc_pipe *p)
31 {
32 NTSTATUS status;
33 struct PNP_GetVersion r;
34 uint16_t version = 0;
35
36 r.out.version = &version;
37
38 status = dcerpc_PNP_GetVersion(p, tctx, &r);
39
40 torture_assert_ntstatus_ok(tctx, status, "PNP_GetVersion");
41 torture_assert_werr_ok(tctx, r.out.result, "PNP_GetVersion");
42 torture_assert_int_equal(tctx, version, 0x400, "invalid version");
43
44 return true;
45 }
46
47 static bool test_PNP_GetDeviceListSize(struct torture_context *tctx,
/* [<][>][^][v][top][bottom][index][help] */
48 struct dcerpc_pipe *p)
49 {
50 struct PNP_GetDeviceListSize r;
51 uint32_t size = 0;
52
53 r.in.devicename = NULL;
54 r.in.flags = CM_GETIDLIST_FILTER_SERVICE;
55 r.out.size = &size;
56
57 torture_assert_ntstatus_ok(tctx,
58 dcerpc_PNP_GetDeviceListSize(p, tctx, &r),
59 "PNP_GetDeviceListSize");
60 torture_assert_werr_equal(tctx, r.out.result, WERR_CM_INVALID_POINTER,
61 "PNP_GetDeviceListSize");
62
63 r.in.devicename = "Spooler";
64
65 torture_assert_ntstatus_ok(tctx,
66 dcerpc_PNP_GetDeviceListSize(p, tctx, &r),
67 "PNP_GetDeviceListSize");
68 torture_assert_werr_ok(tctx, r.out.result,
69 "PNP_GetDeviceListSize");
70
71 return true;
72 }
73
74 static bool test_PNP_GetDeviceList(struct torture_context *tctx,
/* [<][>][^][v][top][bottom][index][help] */
75 struct dcerpc_pipe *p)
76 {
77 struct PNP_GetDeviceList r;
78 uint16_t *buffer = NULL;
79 uint32_t length = 0;
80
81 buffer = talloc_array(tctx, uint16_t, 0);
82
83 r.in.filter = NULL;
84 r.in.flags = CM_GETIDLIST_FILTER_SERVICE;
85 r.in.length = &length;
86 r.out.length = &length;
87 r.out.buffer = buffer;
88
89 torture_assert_ntstatus_ok(tctx,
90 dcerpc_PNP_GetDeviceList(p, tctx, &r),
91 "PNP_GetDeviceList failed");
92 torture_assert_werr_equal(tctx, r.out.result, WERR_CM_INVALID_POINTER,
93 "PNP_GetDeviceList failed");
94
95 r.in.filter = "Spooler";
96
97 torture_assert_ntstatus_ok(tctx,
98 dcerpc_PNP_GetDeviceList(p, tctx, &r),
99 "PNP_GetDeviceList failed");
100
101 if (W_ERROR_EQUAL(r.out.result, WERR_CM_BUFFER_SMALL)) {
102 struct PNP_GetDeviceListSize s;
103
104 s.in.devicename = "Spooler";
105 s.in.flags = CM_GETIDLIST_FILTER_SERVICE;
106 s.out.size = &length;
107
108 torture_assert_ntstatus_ok(tctx,
109 dcerpc_PNP_GetDeviceListSize(p, tctx, &s),
110 "PNP_GetDeviceListSize failed");
111 torture_assert_werr_ok(tctx, s.out.result,
112 "PNP_GetDeviceListSize failed");
113 }
114
115 buffer = talloc_array(tctx, uint16_t, length);
116
117 r.in.length = &length;
118 r.out.length = &length;
119 r.out.buffer = buffer;
120
121 torture_assert_ntstatus_ok(tctx,
122 dcerpc_PNP_GetDeviceList(p, tctx, &r),
123 "PNP_GetDeviceList failed");
124
125 torture_assert_werr_ok(tctx, r.out.result,
126 "PNP_GetDeviceList failed");
127
128 return true;
129 }
130
131 static bool test_PNP_GetDeviceRegProp(struct torture_context *tctx,
/* [<][>][^][v][top][bottom][index][help] */
132 struct dcerpc_pipe *p)
133 {
134 NTSTATUS status;
135 struct PNP_GetDeviceRegProp r;
136
137 enum winreg_Type reg_data_type = REG_NONE;
138 uint32_t buffer_size = 0;
139 uint32_t needed = 0;
140 uint8_t *buffer;
141
142 buffer = talloc(tctx, uint8_t);
143
144 r.in.devicepath = "ACPI\\ACPI0003\\1";
145 r.in.property = DEV_REGPROP_DESC;
146 r.in.flags = 0;
147 r.in.reg_data_type = ®_data_type;
148 r.in.buffer_size = &buffer_size;
149 r.in.needed = &needed;
150 r.out.buffer = buffer;
151 r.out.reg_data_type = ®_data_type;
152 r.out.buffer_size = &buffer_size;
153 r.out.needed = &needed;
154
155 status = dcerpc_PNP_GetDeviceRegProp(p, tctx, &r);
156 torture_assert_ntstatus_ok(tctx, status, "PNP_GetDeviceRegProp");
157
158 if (W_ERROR_EQUAL(r.out.result, WERR_CM_BUFFER_SMALL)) {
159
160 buffer = talloc_array(tctx, uint8_t, needed);
161 r.in.buffer_size = &needed;
162
163 status = dcerpc_PNP_GetDeviceRegProp(p, tctx, &r);
164 torture_assert_ntstatus_ok(tctx, status, "PNP_GetDeviceRegProp");
165 }
166
167 return true;
168 }
169
170 struct torture_suite *torture_rpc_ntsvcs(TALLOC_CTX *mem_ctx)
/* [<][>][^][v][top][bottom][index][help] */
171 {
172 struct torture_rpc_tcase *tcase;
173 struct torture_suite *suite = torture_suite_create(mem_ctx, "NTSVCS");
174 struct torture_test *test;
175
176 tcase = torture_suite_add_rpc_iface_tcase(suite, "ntsvcs",
177 &ndr_table_ntsvcs);
178
179 test = torture_rpc_tcase_add_test(tcase, "PNP_GetDeviceRegProp",
180 test_PNP_GetDeviceRegProp);
181 test = torture_rpc_tcase_add_test(tcase, "PNP_GetDeviceList",
182 test_PNP_GetDeviceList);
183 test = torture_rpc_tcase_add_test(tcase, "PNP_GetDeviceListSize",
184 test_PNP_GetDeviceListSize);
185 test = torture_rpc_tcase_add_test(tcase, "PNP_GetVersion",
186 test_PNP_GetVersion);
187
188 return suite;
189 }