Line data Source code
1 : /* s3 compat server functions auto-generated by pidl */
2 : #include "bin/default/librpc/gen_ndr/ndr_dfs.h"
3 : #include "bin/default/librpc/gen_ndr/ndr_dfs_scompat.h"
4 : #include <librpc/rpc/dcesrv_core.h>
5 : #include <rpc_server/rpc_config.h>
6 : #include <rpc_server/rpc_server.h>
7 : #include <util/debug.h>
8 :
9 : enum s3compat_rpc_dispatch {
10 : S3COMPAT_RPC_DISPATCH_EXTERNAL = 0x00000001,
11 : S3COMPAT_RPC_DISPATCH_INTERNAL = 0x00000002,
12 : };
13 :
14 : /* netdfs - dcerpc server boilerplate generated by pidl */
15 8 : static NTSTATUS netdfs__op_bind(struct dcesrv_connection_context *context, const struct dcesrv_interface *iface)
16 : {
17 : #ifdef DCESRV_INTERFACE_NETDFS_BIND
18 : return DCESRV_INTERFACE_NETDFS_BIND(context,iface);
19 : #else
20 8 : return NT_STATUS_OK;
21 : #endif
22 : }
23 :
24 8 : static void netdfs__op_unbind(struct dcesrv_connection_context *context, const struct dcesrv_interface *iface)
25 : {
26 : #ifdef DCESRV_INTERFACE_NETDFS_UNBIND
27 : DCESRV_INTERFACE_NETDFS_UNBIND(context, iface);
28 : #else
29 8 : return;
30 : #endif
31 : }
32 :
33 6 : NTSTATUS netdfs__op_ndr_pull(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct ndr_pull *pull, void **r)
34 : {
35 0 : enum ndr_err_code ndr_err;
36 6 : uint16_t opnum = dce_call->pkt.u.request.opnum;
37 :
38 6 : dce_call->fault_code = 0;
39 :
40 6 : if (opnum >= ndr_table_netdfs.num_calls) {
41 0 : dce_call->fault_code = DCERPC_FAULT_OP_RNG_ERROR;
42 0 : return NT_STATUS_NET_WRITE_FAULT;
43 : }
44 :
45 6 : *r = talloc_named(mem_ctx, ndr_table_netdfs.calls[opnum].struct_size, "struct %s", ndr_table_netdfs.calls[opnum].name);
46 6 : NT_STATUS_HAVE_NO_MEMORY(*r);
47 :
48 : /* unravel the NDR for the packet */
49 6 : ndr_err = ndr_table_netdfs.calls[opnum].ndr_pull(pull, NDR_IN, *r);
50 6 : if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
51 0 : dce_call->fault_code = DCERPC_FAULT_NDR;
52 0 : return NT_STATUS_NET_WRITE_FAULT;
53 : }
54 :
55 6 : return NT_STATUS_OK;
56 : }
57 :
58 6 : static NTSTATUS netdfs__op_dispatch_internal(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, void *r, enum s3compat_rpc_dispatch dispatch)
59 : {
60 6 : uint16_t opnum = dce_call->pkt.u.request.opnum;
61 6 : struct pipes_struct *p = NULL;
62 6 : NTSTATUS status = NT_STATUS_OK;
63 6 : bool impersonated = false;
64 :
65 : /* Retrieve pipes struct */
66 6 : p = dcesrv_get_pipes_struct(dce_call->conn);
67 6 : p->dce_call = dce_call;
68 6 : p->mem_ctx = mem_ctx;
69 : /* Reset pipes struct fault state */
70 6 : p->fault_state = 0;
71 :
72 : /* Impersonate */
73 6 : if (dispatch == S3COMPAT_RPC_DISPATCH_EXTERNAL) {
74 6 : impersonated = become_authenticated_pipe_user(dce_call->auth_state->session_info);
75 6 : if (!impersonated) {
76 0 : dce_call->fault_code = DCERPC_FAULT_ACCESS_DENIED;
77 0 : status = NT_STATUS_NET_WRITE_FAULT;
78 0 : goto fail;
79 : }
80 : }
81 :
82 6 : switch (opnum) {
83 2 : case 0: { /* dfs_GetManagerVersion */
84 2 : struct dfs_GetManagerVersion *r2 = (struct dfs_GetManagerVersion *)r;
85 2 : if (DEBUGLEVEL >= 10) {
86 0 : NDR_PRINT_FUNCTION_DEBUG(dfs_GetManagerVersion, NDR_IN, r2);
87 : }
88 2 : NDR_ZERO_STRUCT(r2->out);
89 2 : r2->out.version = talloc_zero(r2, enum dfs_ManagerVersion);
90 2 : if (r2->out.version == NULL) {
91 0 : status = NT_STATUS_NO_MEMORY;
92 0 : p->fault_state = DCERPC_FAULT_CANT_PERFORM;
93 0 : goto fail;
94 : }
95 :
96 2 : _dfs_GetManagerVersion(p, r2);
97 2 : break;
98 : }
99 0 : case 1: { /* dfs_Add */
100 0 : struct dfs_Add *r2 = (struct dfs_Add *)r;
101 0 : if (DEBUGLEVEL >= 10) {
102 0 : NDR_PRINT_FUNCTION_DEBUG(dfs_Add, NDR_IN, r2);
103 : }
104 0 : r2->out.result = _dfs_Add(p, r2);
105 0 : break;
106 : }
107 0 : case 2: { /* dfs_Remove */
108 0 : struct dfs_Remove *r2 = (struct dfs_Remove *)r;
109 0 : if (DEBUGLEVEL >= 10) {
110 0 : NDR_PRINT_FUNCTION_DEBUG(dfs_Remove, NDR_IN, r2);
111 : }
112 0 : r2->out.result = _dfs_Remove(p, r2);
113 0 : break;
114 : }
115 0 : case 3: { /* dfs_SetInfo */
116 0 : struct dfs_SetInfo *r2 = (struct dfs_SetInfo *)r;
117 0 : if (DEBUGLEVEL >= 10) {
118 0 : NDR_PRINT_FUNCTION_DEBUG(dfs_SetInfo, NDR_IN, r2);
119 : }
120 0 : r2->out.result = _dfs_SetInfo(p, r2);
121 0 : break;
122 : }
123 2 : case 4: { /* dfs_GetInfo */
124 2 : struct dfs_GetInfo *r2 = (struct dfs_GetInfo *)r;
125 2 : if (DEBUGLEVEL >= 10) {
126 0 : NDR_PRINT_FUNCTION_DEBUG(dfs_GetInfo, NDR_IN, r2);
127 : }
128 2 : NDR_ZERO_STRUCT(r2->out);
129 2 : r2->out.info = talloc_zero(r2, union dfs_Info);
130 2 : if (r2->out.info == NULL) {
131 0 : status = NT_STATUS_NO_MEMORY;
132 0 : p->fault_state = DCERPC_FAULT_CANT_PERFORM;
133 0 : goto fail;
134 : }
135 :
136 2 : r2->out.result = _dfs_GetInfo(p, r2);
137 2 : break;
138 : }
139 0 : case 5: { /* dfs_Enum */
140 0 : struct dfs_Enum *r2 = (struct dfs_Enum *)r;
141 0 : if (DEBUGLEVEL >= 10) {
142 0 : NDR_PRINT_FUNCTION_DEBUG(dfs_Enum, NDR_IN, r2);
143 : }
144 0 : NDR_ZERO_STRUCT(r2->out);
145 0 : r2->out.info = r2->in.info;
146 0 : r2->out.total = r2->in.total;
147 0 : r2->out.result = _dfs_Enum(p, r2);
148 0 : break;
149 : }
150 0 : case 6: { /* dfs_Rename */
151 0 : struct dfs_Rename *r2 = (struct dfs_Rename *)r;
152 0 : if (DEBUGLEVEL >= 10) {
153 0 : NDR_PRINT_FUNCTION_DEBUG(dfs_Rename, NDR_IN, r2);
154 : }
155 0 : r2->out.result = _dfs_Rename(p, r2);
156 0 : break;
157 : }
158 0 : case 7: { /* dfs_Move */
159 0 : struct dfs_Move *r2 = (struct dfs_Move *)r;
160 0 : if (DEBUGLEVEL >= 10) {
161 0 : NDR_PRINT_FUNCTION_DEBUG(dfs_Move, NDR_IN, r2);
162 : }
163 0 : r2->out.result = _dfs_Move(p, r2);
164 0 : break;
165 : }
166 0 : case 8: { /* dfs_ManagerGetConfigInfo */
167 0 : struct dfs_ManagerGetConfigInfo *r2 = (struct dfs_ManagerGetConfigInfo *)r;
168 0 : if (DEBUGLEVEL >= 10) {
169 0 : NDR_PRINT_FUNCTION_DEBUG(dfs_ManagerGetConfigInfo, NDR_IN, r2);
170 : }
171 0 : r2->out.result = _dfs_ManagerGetConfigInfo(p, r2);
172 0 : break;
173 : }
174 0 : case 9: { /* dfs_ManagerSendSiteInfo */
175 0 : struct dfs_ManagerSendSiteInfo *r2 = (struct dfs_ManagerSendSiteInfo *)r;
176 0 : if (DEBUGLEVEL >= 10) {
177 0 : NDR_PRINT_FUNCTION_DEBUG(dfs_ManagerSendSiteInfo, NDR_IN, r2);
178 : }
179 0 : r2->out.result = _dfs_ManagerSendSiteInfo(p, r2);
180 0 : break;
181 : }
182 0 : case 10: { /* dfs_AddFtRoot */
183 0 : struct dfs_AddFtRoot *r2 = (struct dfs_AddFtRoot *)r;
184 0 : if (DEBUGLEVEL >= 10) {
185 0 : NDR_PRINT_FUNCTION_DEBUG(dfs_AddFtRoot, NDR_IN, r2);
186 : }
187 0 : NDR_ZERO_STRUCT(r2->out);
188 0 : r2->out.unknown2 = r2->in.unknown2;
189 0 : r2->out.result = _dfs_AddFtRoot(p, r2);
190 0 : break;
191 : }
192 0 : case 11: { /* dfs_RemoveFtRoot */
193 0 : struct dfs_RemoveFtRoot *r2 = (struct dfs_RemoveFtRoot *)r;
194 0 : if (DEBUGLEVEL >= 10) {
195 0 : NDR_PRINT_FUNCTION_DEBUG(dfs_RemoveFtRoot, NDR_IN, r2);
196 : }
197 0 : NDR_ZERO_STRUCT(r2->out);
198 0 : r2->out.unknown = r2->in.unknown;
199 0 : r2->out.result = _dfs_RemoveFtRoot(p, r2);
200 0 : break;
201 : }
202 0 : case 12: { /* dfs_AddStdRoot */
203 0 : struct dfs_AddStdRoot *r2 = (struct dfs_AddStdRoot *)r;
204 0 : if (DEBUGLEVEL >= 10) {
205 0 : NDR_PRINT_FUNCTION_DEBUG(dfs_AddStdRoot, NDR_IN, r2);
206 : }
207 0 : r2->out.result = _dfs_AddStdRoot(p, r2);
208 0 : break;
209 : }
210 0 : case 13: { /* dfs_RemoveStdRoot */
211 0 : struct dfs_RemoveStdRoot *r2 = (struct dfs_RemoveStdRoot *)r;
212 0 : if (DEBUGLEVEL >= 10) {
213 0 : NDR_PRINT_FUNCTION_DEBUG(dfs_RemoveStdRoot, NDR_IN, r2);
214 : }
215 0 : r2->out.result = _dfs_RemoveStdRoot(p, r2);
216 0 : break;
217 : }
218 0 : case 14: { /* dfs_ManagerInitialize */
219 0 : struct dfs_ManagerInitialize *r2 = (struct dfs_ManagerInitialize *)r;
220 0 : if (DEBUGLEVEL >= 10) {
221 0 : NDR_PRINT_FUNCTION_DEBUG(dfs_ManagerInitialize, NDR_IN, r2);
222 : }
223 0 : r2->out.result = _dfs_ManagerInitialize(p, r2);
224 0 : break;
225 : }
226 0 : case 15: { /* dfs_AddStdRootForced */
227 0 : struct dfs_AddStdRootForced *r2 = (struct dfs_AddStdRootForced *)r;
228 0 : if (DEBUGLEVEL >= 10) {
229 0 : NDR_PRINT_FUNCTION_DEBUG(dfs_AddStdRootForced, NDR_IN, r2);
230 : }
231 0 : r2->out.result = _dfs_AddStdRootForced(p, r2);
232 0 : break;
233 : }
234 0 : case 16: { /* dfs_GetDcAddress */
235 0 : struct dfs_GetDcAddress *r2 = (struct dfs_GetDcAddress *)r;
236 0 : if (DEBUGLEVEL >= 10) {
237 0 : NDR_PRINT_FUNCTION_DEBUG(dfs_GetDcAddress, NDR_IN, r2);
238 : }
239 0 : NDR_ZERO_STRUCT(r2->out);
240 0 : r2->out.server_fullname = r2->in.server_fullname;
241 0 : r2->out.is_root = r2->in.is_root;
242 0 : r2->out.ttl = r2->in.ttl;
243 0 : r2->out.result = _dfs_GetDcAddress(p, r2);
244 0 : break;
245 : }
246 0 : case 17: { /* dfs_SetDcAddress */
247 0 : struct dfs_SetDcAddress *r2 = (struct dfs_SetDcAddress *)r;
248 0 : if (DEBUGLEVEL >= 10) {
249 0 : NDR_PRINT_FUNCTION_DEBUG(dfs_SetDcAddress, NDR_IN, r2);
250 : }
251 0 : r2->out.result = _dfs_SetDcAddress(p, r2);
252 0 : break;
253 : }
254 0 : case 18: { /* dfs_FlushFtTable */
255 0 : struct dfs_FlushFtTable *r2 = (struct dfs_FlushFtTable *)r;
256 0 : if (DEBUGLEVEL >= 10) {
257 0 : NDR_PRINT_FUNCTION_DEBUG(dfs_FlushFtTable, NDR_IN, r2);
258 : }
259 0 : r2->out.result = _dfs_FlushFtTable(p, r2);
260 0 : break;
261 : }
262 0 : case 19: { /* dfs_Add2 */
263 0 : struct dfs_Add2 *r2 = (struct dfs_Add2 *)r;
264 0 : if (DEBUGLEVEL >= 10) {
265 0 : NDR_PRINT_FUNCTION_DEBUG(dfs_Add2, NDR_IN, r2);
266 : }
267 0 : r2->out.result = _dfs_Add2(p, r2);
268 0 : break;
269 : }
270 0 : case 20: { /* dfs_Remove2 */
271 0 : struct dfs_Remove2 *r2 = (struct dfs_Remove2 *)r;
272 0 : if (DEBUGLEVEL >= 10) {
273 0 : NDR_PRINT_FUNCTION_DEBUG(dfs_Remove2, NDR_IN, r2);
274 : }
275 0 : r2->out.result = _dfs_Remove2(p, r2);
276 0 : break;
277 : }
278 2 : case 21: { /* dfs_EnumEx */
279 2 : struct dfs_EnumEx *r2 = (struct dfs_EnumEx *)r;
280 2 : if (DEBUGLEVEL >= 10) {
281 0 : NDR_PRINT_FUNCTION_DEBUG(dfs_EnumEx, NDR_IN, r2);
282 : }
283 2 : NDR_ZERO_STRUCT(r2->out);
284 2 : r2->out.info = r2->in.info;
285 2 : r2->out.total = r2->in.total;
286 2 : r2->out.result = _dfs_EnumEx(p, r2);
287 2 : break;
288 : }
289 0 : case 22: { /* dfs_SetInfo2 */
290 0 : struct dfs_SetInfo2 *r2 = (struct dfs_SetInfo2 *)r;
291 0 : if (DEBUGLEVEL >= 10) {
292 0 : NDR_PRINT_FUNCTION_DEBUG(dfs_SetInfo2, NDR_IN, r2);
293 : }
294 0 : r2->out.result = _dfs_SetInfo2(p, r2);
295 0 : break;
296 : }
297 0 : default:
298 0 : dce_call->fault_code = DCERPC_FAULT_OP_RNG_ERROR;
299 0 : break;
300 : }
301 :
302 6 : fail:
303 : /* Unimpersonate */
304 6 : if (impersonated) {
305 6 : unbecome_authenticated_pipe_user();
306 : }
307 :
308 6 : p->dce_call = NULL;
309 6 : p->mem_ctx = NULL;
310 : /* Check pipes struct fault state */
311 6 : if (p->fault_state != 0) {
312 2 : dce_call->fault_code = p->fault_state;
313 : }
314 6 : if (dce_call->fault_code != 0) {
315 2 : status = NT_STATUS_NET_WRITE_FAULT;
316 : }
317 :
318 6 : return status;
319 : }
320 :
321 6 : NTSTATUS netdfs__op_dispatch(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, void *r)
322 : {
323 6 : return netdfs__op_dispatch_internal(dce_call, mem_ctx, r, S3COMPAT_RPC_DISPATCH_EXTERNAL);
324 : }
325 :
326 4 : NTSTATUS netdfs__op_reply(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, void *r)
327 : {
328 4 : uint16_t opnum = dce_call->pkt.u.request.opnum;
329 :
330 4 : switch (opnum) {
331 2 : case 0: { /* dfs_GetManagerVersion */
332 2 : struct dfs_GetManagerVersion *r2 = (struct dfs_GetManagerVersion *)r;
333 2 : if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
334 0 : DEBUG(5,("function dfs_GetManagerVersion replied async\n"));
335 : }
336 2 : if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
337 0 : NDR_PRINT_FUNCTION_DEBUG(dfs_GetManagerVersion, NDR_OUT | NDR_SET_VALUES, r2);
338 : }
339 2 : if (dce_call->fault_code != 0) {
340 0 : DBG_WARNING("dcerpc_fault %s in dfs_GetManagerVersion\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
341 : }
342 2 : break;
343 : }
344 0 : case 1: { /* dfs_Add */
345 0 : struct dfs_Add *r2 = (struct dfs_Add *)r;
346 0 : if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
347 0 : DEBUG(5,("function dfs_Add replied async\n"));
348 : }
349 0 : if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
350 0 : NDR_PRINT_FUNCTION_DEBUG(dfs_Add, NDR_OUT | NDR_SET_VALUES, r2);
351 : }
352 0 : if (dce_call->fault_code != 0) {
353 0 : DBG_WARNING("dcerpc_fault %s in dfs_Add\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
354 : }
355 0 : break;
356 : }
357 0 : case 2: { /* dfs_Remove */
358 0 : struct dfs_Remove *r2 = (struct dfs_Remove *)r;
359 0 : if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
360 0 : DEBUG(5,("function dfs_Remove replied async\n"));
361 : }
362 0 : if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
363 0 : NDR_PRINT_FUNCTION_DEBUG(dfs_Remove, NDR_OUT | NDR_SET_VALUES, r2);
364 : }
365 0 : if (dce_call->fault_code != 0) {
366 0 : DBG_WARNING("dcerpc_fault %s in dfs_Remove\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
367 : }
368 0 : break;
369 : }
370 0 : case 3: { /* dfs_SetInfo */
371 0 : struct dfs_SetInfo *r2 = (struct dfs_SetInfo *)r;
372 0 : if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
373 0 : DEBUG(5,("function dfs_SetInfo replied async\n"));
374 : }
375 0 : if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
376 0 : NDR_PRINT_FUNCTION_DEBUG(dfs_SetInfo, NDR_OUT | NDR_SET_VALUES, r2);
377 : }
378 0 : if (dce_call->fault_code != 0) {
379 0 : DBG_WARNING("dcerpc_fault %s in dfs_SetInfo\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
380 : }
381 0 : break;
382 : }
383 2 : case 4: { /* dfs_GetInfo */
384 2 : struct dfs_GetInfo *r2 = (struct dfs_GetInfo *)r;
385 2 : if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
386 0 : DEBUG(5,("function dfs_GetInfo replied async\n"));
387 : }
388 2 : if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
389 0 : NDR_PRINT_FUNCTION_DEBUG(dfs_GetInfo, NDR_OUT | NDR_SET_VALUES, r2);
390 : }
391 2 : if (dce_call->fault_code != 0) {
392 0 : DBG_WARNING("dcerpc_fault %s in dfs_GetInfo\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
393 : }
394 2 : break;
395 : }
396 0 : case 5: { /* dfs_Enum */
397 0 : struct dfs_Enum *r2 = (struct dfs_Enum *)r;
398 0 : if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
399 0 : DEBUG(5,("function dfs_Enum replied async\n"));
400 : }
401 0 : if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
402 0 : NDR_PRINT_FUNCTION_DEBUG(dfs_Enum, NDR_OUT | NDR_SET_VALUES, r2);
403 : }
404 0 : if (dce_call->fault_code != 0) {
405 0 : DBG_WARNING("dcerpc_fault %s in dfs_Enum\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
406 : }
407 0 : break;
408 : }
409 0 : case 6: { /* dfs_Rename */
410 0 : struct dfs_Rename *r2 = (struct dfs_Rename *)r;
411 0 : if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
412 0 : DEBUG(5,("function dfs_Rename replied async\n"));
413 : }
414 0 : if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
415 0 : NDR_PRINT_FUNCTION_DEBUG(dfs_Rename, NDR_OUT | NDR_SET_VALUES, r2);
416 : }
417 0 : if (dce_call->fault_code != 0) {
418 0 : DBG_WARNING("dcerpc_fault %s in dfs_Rename\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
419 : }
420 0 : break;
421 : }
422 0 : case 7: { /* dfs_Move */
423 0 : struct dfs_Move *r2 = (struct dfs_Move *)r;
424 0 : if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
425 0 : DEBUG(5,("function dfs_Move replied async\n"));
426 : }
427 0 : if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
428 0 : NDR_PRINT_FUNCTION_DEBUG(dfs_Move, NDR_OUT | NDR_SET_VALUES, r2);
429 : }
430 0 : if (dce_call->fault_code != 0) {
431 0 : DBG_WARNING("dcerpc_fault %s in dfs_Move\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
432 : }
433 0 : break;
434 : }
435 0 : case 8: { /* dfs_ManagerGetConfigInfo */
436 0 : struct dfs_ManagerGetConfigInfo *r2 = (struct dfs_ManagerGetConfigInfo *)r;
437 0 : if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
438 0 : DEBUG(5,("function dfs_ManagerGetConfigInfo replied async\n"));
439 : }
440 0 : if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
441 0 : NDR_PRINT_FUNCTION_DEBUG(dfs_ManagerGetConfigInfo, NDR_OUT | NDR_SET_VALUES, r2);
442 : }
443 0 : if (dce_call->fault_code != 0) {
444 0 : DBG_WARNING("dcerpc_fault %s in dfs_ManagerGetConfigInfo\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
445 : }
446 0 : break;
447 : }
448 0 : case 9: { /* dfs_ManagerSendSiteInfo */
449 0 : struct dfs_ManagerSendSiteInfo *r2 = (struct dfs_ManagerSendSiteInfo *)r;
450 0 : if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
451 0 : DEBUG(5,("function dfs_ManagerSendSiteInfo replied async\n"));
452 : }
453 0 : if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
454 0 : NDR_PRINT_FUNCTION_DEBUG(dfs_ManagerSendSiteInfo, NDR_OUT | NDR_SET_VALUES, r2);
455 : }
456 0 : if (dce_call->fault_code != 0) {
457 0 : DBG_WARNING("dcerpc_fault %s in dfs_ManagerSendSiteInfo\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
458 : }
459 0 : break;
460 : }
461 0 : case 10: { /* dfs_AddFtRoot */
462 0 : struct dfs_AddFtRoot *r2 = (struct dfs_AddFtRoot *)r;
463 0 : if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
464 0 : DEBUG(5,("function dfs_AddFtRoot replied async\n"));
465 : }
466 0 : if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
467 0 : NDR_PRINT_FUNCTION_DEBUG(dfs_AddFtRoot, NDR_OUT | NDR_SET_VALUES, r2);
468 : }
469 0 : if (dce_call->fault_code != 0) {
470 0 : DBG_WARNING("dcerpc_fault %s in dfs_AddFtRoot\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
471 : }
472 0 : break;
473 : }
474 0 : case 11: { /* dfs_RemoveFtRoot */
475 0 : struct dfs_RemoveFtRoot *r2 = (struct dfs_RemoveFtRoot *)r;
476 0 : if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
477 0 : DEBUG(5,("function dfs_RemoveFtRoot replied async\n"));
478 : }
479 0 : if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
480 0 : NDR_PRINT_FUNCTION_DEBUG(dfs_RemoveFtRoot, NDR_OUT | NDR_SET_VALUES, r2);
481 : }
482 0 : if (dce_call->fault_code != 0) {
483 0 : DBG_WARNING("dcerpc_fault %s in dfs_RemoveFtRoot\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
484 : }
485 0 : break;
486 : }
487 0 : case 12: { /* dfs_AddStdRoot */
488 0 : struct dfs_AddStdRoot *r2 = (struct dfs_AddStdRoot *)r;
489 0 : if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
490 0 : DEBUG(5,("function dfs_AddStdRoot replied async\n"));
491 : }
492 0 : if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
493 0 : NDR_PRINT_FUNCTION_DEBUG(dfs_AddStdRoot, NDR_OUT | NDR_SET_VALUES, r2);
494 : }
495 0 : if (dce_call->fault_code != 0) {
496 0 : DBG_WARNING("dcerpc_fault %s in dfs_AddStdRoot\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
497 : }
498 0 : break;
499 : }
500 0 : case 13: { /* dfs_RemoveStdRoot */
501 0 : struct dfs_RemoveStdRoot *r2 = (struct dfs_RemoveStdRoot *)r;
502 0 : if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
503 0 : DEBUG(5,("function dfs_RemoveStdRoot replied async\n"));
504 : }
505 0 : if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
506 0 : NDR_PRINT_FUNCTION_DEBUG(dfs_RemoveStdRoot, NDR_OUT | NDR_SET_VALUES, r2);
507 : }
508 0 : if (dce_call->fault_code != 0) {
509 0 : DBG_WARNING("dcerpc_fault %s in dfs_RemoveStdRoot\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
510 : }
511 0 : break;
512 : }
513 0 : case 14: { /* dfs_ManagerInitialize */
514 0 : struct dfs_ManagerInitialize *r2 = (struct dfs_ManagerInitialize *)r;
515 0 : if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
516 0 : DEBUG(5,("function dfs_ManagerInitialize replied async\n"));
517 : }
518 0 : if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
519 0 : NDR_PRINT_FUNCTION_DEBUG(dfs_ManagerInitialize, NDR_OUT | NDR_SET_VALUES, r2);
520 : }
521 0 : if (dce_call->fault_code != 0) {
522 0 : DBG_WARNING("dcerpc_fault %s in dfs_ManagerInitialize\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
523 : }
524 0 : break;
525 : }
526 0 : case 15: { /* dfs_AddStdRootForced */
527 0 : struct dfs_AddStdRootForced *r2 = (struct dfs_AddStdRootForced *)r;
528 0 : if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
529 0 : DEBUG(5,("function dfs_AddStdRootForced replied async\n"));
530 : }
531 0 : if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
532 0 : NDR_PRINT_FUNCTION_DEBUG(dfs_AddStdRootForced, NDR_OUT | NDR_SET_VALUES, r2);
533 : }
534 0 : if (dce_call->fault_code != 0) {
535 0 : DBG_WARNING("dcerpc_fault %s in dfs_AddStdRootForced\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
536 : }
537 0 : break;
538 : }
539 0 : case 16: { /* dfs_GetDcAddress */
540 0 : struct dfs_GetDcAddress *r2 = (struct dfs_GetDcAddress *)r;
541 0 : if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
542 0 : DEBUG(5,("function dfs_GetDcAddress replied async\n"));
543 : }
544 0 : if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
545 0 : NDR_PRINT_FUNCTION_DEBUG(dfs_GetDcAddress, NDR_OUT | NDR_SET_VALUES, r2);
546 : }
547 0 : if (dce_call->fault_code != 0) {
548 0 : DBG_WARNING("dcerpc_fault %s in dfs_GetDcAddress\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
549 : }
550 0 : break;
551 : }
552 0 : case 17: { /* dfs_SetDcAddress */
553 0 : struct dfs_SetDcAddress *r2 = (struct dfs_SetDcAddress *)r;
554 0 : if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
555 0 : DEBUG(5,("function dfs_SetDcAddress replied async\n"));
556 : }
557 0 : if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
558 0 : NDR_PRINT_FUNCTION_DEBUG(dfs_SetDcAddress, NDR_OUT | NDR_SET_VALUES, r2);
559 : }
560 0 : if (dce_call->fault_code != 0) {
561 0 : DBG_WARNING("dcerpc_fault %s in dfs_SetDcAddress\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
562 : }
563 0 : break;
564 : }
565 0 : case 18: { /* dfs_FlushFtTable */
566 0 : struct dfs_FlushFtTable *r2 = (struct dfs_FlushFtTable *)r;
567 0 : if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
568 0 : DEBUG(5,("function dfs_FlushFtTable replied async\n"));
569 : }
570 0 : if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
571 0 : NDR_PRINT_FUNCTION_DEBUG(dfs_FlushFtTable, NDR_OUT | NDR_SET_VALUES, r2);
572 : }
573 0 : if (dce_call->fault_code != 0) {
574 0 : DBG_WARNING("dcerpc_fault %s in dfs_FlushFtTable\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
575 : }
576 0 : break;
577 : }
578 0 : case 19: { /* dfs_Add2 */
579 0 : struct dfs_Add2 *r2 = (struct dfs_Add2 *)r;
580 0 : if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
581 0 : DEBUG(5,("function dfs_Add2 replied async\n"));
582 : }
583 0 : if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
584 0 : NDR_PRINT_FUNCTION_DEBUG(dfs_Add2, NDR_OUT | NDR_SET_VALUES, r2);
585 : }
586 0 : if (dce_call->fault_code != 0) {
587 0 : DBG_WARNING("dcerpc_fault %s in dfs_Add2\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
588 : }
589 0 : break;
590 : }
591 0 : case 20: { /* dfs_Remove2 */
592 0 : struct dfs_Remove2 *r2 = (struct dfs_Remove2 *)r;
593 0 : if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
594 0 : DEBUG(5,("function dfs_Remove2 replied async\n"));
595 : }
596 0 : if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
597 0 : NDR_PRINT_FUNCTION_DEBUG(dfs_Remove2, NDR_OUT | NDR_SET_VALUES, r2);
598 : }
599 0 : if (dce_call->fault_code != 0) {
600 0 : DBG_WARNING("dcerpc_fault %s in dfs_Remove2\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
601 : }
602 0 : break;
603 : }
604 0 : case 21: { /* dfs_EnumEx */
605 0 : struct dfs_EnumEx *r2 = (struct dfs_EnumEx *)r;
606 0 : if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
607 0 : DEBUG(5,("function dfs_EnumEx replied async\n"));
608 : }
609 0 : if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
610 0 : NDR_PRINT_FUNCTION_DEBUG(dfs_EnumEx, NDR_OUT | NDR_SET_VALUES, r2);
611 : }
612 0 : if (dce_call->fault_code != 0) {
613 0 : DBG_WARNING("dcerpc_fault %s in dfs_EnumEx\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
614 : }
615 0 : break;
616 : }
617 0 : case 22: { /* dfs_SetInfo2 */
618 0 : struct dfs_SetInfo2 *r2 = (struct dfs_SetInfo2 *)r;
619 0 : if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
620 0 : DEBUG(5,("function dfs_SetInfo2 replied async\n"));
621 : }
622 0 : if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
623 0 : NDR_PRINT_FUNCTION_DEBUG(dfs_SetInfo2, NDR_OUT | NDR_SET_VALUES, r2);
624 : }
625 0 : if (dce_call->fault_code != 0) {
626 0 : DBG_WARNING("dcerpc_fault %s in dfs_SetInfo2\n", dcerpc_errstr(mem_ctx, dce_call->fault_code));
627 : }
628 0 : break;
629 : }
630 0 : default:
631 0 : dce_call->fault_code = DCERPC_FAULT_OP_RNG_ERROR;
632 0 : break;
633 : }
634 :
635 4 : if (dce_call->fault_code != 0) {
636 0 : return NT_STATUS_NET_WRITE_FAULT;
637 : }
638 :
639 4 : return NT_STATUS_OK;
640 : }
641 :
642 4 : NTSTATUS netdfs__op_ndr_push(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct ndr_push *push, const void *r)
643 : {
644 0 : enum ndr_err_code ndr_err;
645 4 : uint16_t opnum = dce_call->pkt.u.request.opnum;
646 :
647 4 : ndr_err = ndr_table_netdfs.calls[opnum].ndr_push(push, NDR_OUT, r);
648 4 : if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
649 0 : dce_call->fault_code = DCERPC_FAULT_NDR;
650 0 : return NT_STATUS_NET_WRITE_FAULT;
651 : }
652 :
653 4 : return NT_STATUS_OK;
654 : }
655 :
656 0 : NTSTATUS netdfs__op_local(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, void *r)
657 : {
658 0 : return netdfs__op_dispatch_internal(dce_call, mem_ctx, r, S3COMPAT_RPC_DISPATCH_INTERNAL);
659 : }
660 :
661 : static const struct dcesrv_interface dcesrv_netdfs_interface = {
662 : .name = "netdfs",
663 : .syntax_id = {{0x4fc742e0,0x4a10,0x11cf,{0x82,0x73},{0x00,0xaa,0x00,0x4a,0xe6,0x73}},3.0},
664 : .bind = netdfs__op_bind,
665 : .unbind = netdfs__op_unbind,
666 : .ndr_pull = netdfs__op_ndr_pull,
667 : .dispatch = netdfs__op_dispatch,
668 : .reply = netdfs__op_reply,
669 : .ndr_push = netdfs__op_ndr_push,
670 : .local = netdfs__op_local,
671 : #ifdef DCESRV_INTERFACE_NETDFS_FLAGS
672 : .flags = DCESRV_INTERFACE_NETDFS_FLAGS
673 : #else
674 : .flags = 0
675 : #endif
676 : };
677 :
678 126 : static NTSTATUS netdfs__op_init_server(struct dcesrv_context *dce_ctx, const struct dcesrv_endpoint_server *ep_server)
679 : {
680 0 : uint32_t i;
681 0 : NTSTATUS ret;
682 :
683 : #ifdef DCESRV_INTERFACE_NETDFS_NCACN_NP_SECONDARY_ENDPOINT
684 : const char *ncacn_np_secondary_endpoint = DCESRV_INTERFACE_NETDFS_NCACN_NP_SECONDARY_ENDPOINT;
685 : #else
686 126 : const char *ncacn_np_secondary_endpoint = NULL;
687 : #endif
688 :
689 504 : for (i=0;i<ndr_table_netdfs.endpoints->count;i++) {
690 378 : const char *name = ndr_table_netdfs.endpoints->names[i];
691 :
692 378 : ret = dcesrv_interface_register(dce_ctx, name, ncacn_np_secondary_endpoint, &dcesrv_netdfs_interface, NULL);
693 378 : if (!NT_STATUS_IS_OK(ret)) {
694 0 : DBG_ERR("Failed to register endpoint '%s'\n",name);
695 0 : return ret;
696 : }
697 : }
698 :
699 126 : return NT_STATUS_OK;
700 : }
701 :
702 126 : static NTSTATUS netdfs__op_shutdown_server(struct dcesrv_context *dce_ctx, const struct dcesrv_endpoint_server *ep_server)
703 : {
704 126 : return NT_STATUS_OK;
705 : }
706 :
707 0 : static bool netdfs__op_interface_by_uuid(struct dcesrv_interface *iface, const struct GUID *uuid, uint32_t if_version)
708 : {
709 0 : if (dcesrv_netdfs_interface.syntax_id.if_version == if_version && GUID_equal(&dcesrv_netdfs_interface.syntax_id.uuid, uuid)) {
710 0 : memcpy(iface,&dcesrv_netdfs_interface, sizeof(*iface));
711 0 : return true;
712 : }
713 :
714 0 : return false;
715 : }
716 :
717 0 : static bool netdfs__op_interface_by_name(struct dcesrv_interface *iface, const char *name)
718 : {
719 0 : if (strcmp(dcesrv_netdfs_interface.name, name)==0) {
720 0 : memcpy(iface, &dcesrv_netdfs_interface, sizeof(*iface));
721 0 : return true;
722 : }
723 :
724 0 : return false;
725 : }
726 :
727 : static const struct dcesrv_endpoint_server netdfs_ep_server = {
728 : /* fill in our name */
729 : .name = "netdfs",
730 :
731 : /* Initialization flag */
732 : .initialized = false,
733 :
734 : /* fill in all the operations */
735 : #ifdef DCESRV_INTERFACE_NETDFS_INIT_SERVER
736 : .init_server = DCESRV_INTERFACE_NETDFS_INIT_SERVER,
737 : #else
738 : .init_server = netdfs__op_init_server,
739 : #endif
740 : #ifdef DCESRV_INTERFACE_NETDFS_SHUTDOWN_SERVER
741 : .shutdown_server = DCESRV_INTERFACE_NETDFS_SHUTDOWN_SERVER,
742 : #else
743 : .shutdown_server = netdfs__op_shutdown_server,
744 : #endif
745 : .interface_by_uuid = netdfs__op_interface_by_uuid,
746 : .interface_by_name = netdfs__op_interface_by_name
747 : };
748 :
749 126 : const struct dcesrv_endpoint_server *netdfs_get_ep_server(void)
750 : {
751 126 : return &netdfs_ep_server;
752 : }
|