1 | /*
|
---|
2 | Unix SMB/CIFS implementation.
|
---|
3 |
|
---|
4 | dcerpc binding handle functions
|
---|
5 |
|
---|
6 | Copyright (C) Stefan Metzmacher 2010
|
---|
7 |
|
---|
8 | This program is free software; you can redistribute it and/or modify
|
---|
9 | it under the terms of the GNU General Public License as published by
|
---|
10 | the Free Software Foundation; either version 3 of the License, or
|
---|
11 | (at your option) any later version.
|
---|
12 |
|
---|
13 | This program is distributed in the hope that it will be useful,
|
---|
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
16 | GNU General Public License for more details.
|
---|
17 |
|
---|
18 | You should have received a copy of the GNU General Public License
|
---|
19 | along with this program. If not, see <http://www.gnu.org/licenses/>.
|
---|
20 | */
|
---|
21 |
|
---|
22 | #include "includes.h"
|
---|
23 | #include <tevent.h>
|
---|
24 | #include "../lib/util/tevent_ntstatus.h"
|
---|
25 | #include "librpc/rpc/dcerpc.h"
|
---|
26 | #include "rpc_common.h"
|
---|
27 |
|
---|
28 | struct dcerpc_binding_handle {
|
---|
29 | void *private_data;
|
---|
30 | const struct dcerpc_binding_handle_ops *ops;
|
---|
31 | const char *location;
|
---|
32 | const struct GUID *object;
|
---|
33 | const struct ndr_interface_table *table;
|
---|
34 | struct tevent_context *sync_ev;
|
---|
35 | };
|
---|
36 |
|
---|
37 | static int dcerpc_binding_handle_destructor(struct dcerpc_binding_handle *b)
|
---|
38 | {
|
---|
39 | return 0;
|
---|
40 | }
|
---|
41 |
|
---|
42 | struct dcerpc_binding_handle *_dcerpc_binding_handle_create(TALLOC_CTX *mem_ctx,
|
---|
43 | const struct dcerpc_binding_handle_ops *ops,
|
---|
44 | const struct GUID *object,
|
---|
45 | const struct ndr_interface_table *table,
|
---|
46 | void *pstate,
|
---|
47 | size_t psize,
|
---|
48 | const char *type,
|
---|
49 | const char *location)
|
---|
50 | {
|
---|
51 | struct dcerpc_binding_handle *h;
|
---|
52 | void **ppstate = (void **)pstate;
|
---|
53 | void *state;
|
---|
54 |
|
---|
55 | h = talloc_zero(mem_ctx, struct dcerpc_binding_handle);
|
---|
56 | if (h == NULL) {
|
---|
57 | return NULL;
|
---|
58 | }
|
---|
59 | h->ops = ops;
|
---|
60 | h->location = location;
|
---|
61 | h->object = object;
|
---|
62 | h->table = table;
|
---|
63 |
|
---|
64 | state = talloc_zero_size(h, psize);
|
---|
65 | if (state == NULL) {
|
---|
66 | talloc_free(h);
|
---|
67 | return NULL;
|
---|
68 | }
|
---|
69 | talloc_set_name_const(state, type);
|
---|
70 |
|
---|
71 | h->private_data = state;
|
---|
72 |
|
---|
73 | talloc_set_destructor(h, dcerpc_binding_handle_destructor);
|
---|
74 |
|
---|
75 | *ppstate = state;
|
---|
76 | return h;
|
---|
77 | }
|
---|
78 |
|
---|
79 | void *_dcerpc_binding_handle_data(struct dcerpc_binding_handle *h)
|
---|
80 | {
|
---|
81 | return h->private_data;
|
---|
82 | }
|
---|
83 |
|
---|
84 | void dcerpc_binding_handle_set_sync_ev(struct dcerpc_binding_handle *h,
|
---|
85 | struct tevent_context *ev)
|
---|
86 | {
|
---|
87 | h->sync_ev = ev;
|
---|
88 | }
|
---|
89 |
|
---|
90 | bool dcerpc_binding_handle_is_connected(struct dcerpc_binding_handle *h)
|
---|
91 | {
|
---|
92 | return h->ops->is_connected(h);
|
---|
93 | }
|
---|
94 |
|
---|
95 | uint32_t dcerpc_binding_handle_set_timeout(struct dcerpc_binding_handle *h,
|
---|
96 | uint32_t timeout)
|
---|
97 | {
|
---|
98 | return h->ops->set_timeout(h, timeout);
|
---|
99 | }
|
---|
100 |
|
---|
101 | void dcerpc_binding_handle_auth_info(struct dcerpc_binding_handle *h,
|
---|
102 | enum dcerpc_AuthType *auth_type,
|
---|
103 | enum dcerpc_AuthLevel *auth_level)
|
---|
104 | {
|
---|
105 | enum dcerpc_AuthType _auth_type;
|
---|
106 | enum dcerpc_AuthLevel _auth_level;
|
---|
107 |
|
---|
108 | if (auth_type == NULL) {
|
---|
109 | auth_type = &_auth_type;
|
---|
110 | }
|
---|
111 |
|
---|
112 | if (auth_level == NULL) {
|
---|
113 | auth_level = &_auth_level;
|
---|
114 | }
|
---|
115 |
|
---|
116 | *auth_type = DCERPC_AUTH_TYPE_NONE;
|
---|
117 | *auth_level = DCERPC_AUTH_LEVEL_NONE;
|
---|
118 |
|
---|
119 | if (h->ops->auth_info == NULL) {
|
---|
120 | return;
|
---|
121 | }
|
---|
122 |
|
---|
123 | h->ops->auth_info(h, auth_type, auth_level);
|
---|
124 | }
|
---|
125 |
|
---|
126 | struct dcerpc_binding_handle_raw_call_state {
|
---|
127 | const struct dcerpc_binding_handle_ops *ops;
|
---|
128 | uint8_t *out_data;
|
---|
129 | size_t out_length;
|
---|
130 | uint32_t out_flags;
|
---|
131 | };
|
---|
132 |
|
---|
133 | static void dcerpc_binding_handle_raw_call_done(struct tevent_req *subreq);
|
---|
134 |
|
---|
135 | struct tevent_req *dcerpc_binding_handle_raw_call_send(TALLOC_CTX *mem_ctx,
|
---|
136 | struct tevent_context *ev,
|
---|
137 | struct dcerpc_binding_handle *h,
|
---|
138 | const struct GUID *object,
|
---|
139 | uint32_t opnum,
|
---|
140 | uint32_t in_flags,
|
---|
141 | const uint8_t *in_data,
|
---|
142 | size_t in_length)
|
---|
143 | {
|
---|
144 | struct tevent_req *req;
|
---|
145 | struct dcerpc_binding_handle_raw_call_state *state;
|
---|
146 | struct tevent_req *subreq;
|
---|
147 |
|
---|
148 | req = tevent_req_create(mem_ctx, &state,
|
---|
149 | struct dcerpc_binding_handle_raw_call_state);
|
---|
150 | if (req == NULL) {
|
---|
151 | return NULL;
|
---|
152 | }
|
---|
153 | state->ops = h->ops;
|
---|
154 | state->out_data = NULL;
|
---|
155 | state->out_length = 0;
|
---|
156 | state->out_flags = 0;
|
---|
157 |
|
---|
158 | subreq = state->ops->raw_call_send(state, ev, h,
|
---|
159 | object, opnum,
|
---|
160 | in_flags, in_data, in_length);
|
---|
161 | if (tevent_req_nomem(subreq, req)) {
|
---|
162 | return tevent_req_post(req, ev);
|
---|
163 | }
|
---|
164 | tevent_req_set_callback(subreq, dcerpc_binding_handle_raw_call_done, req);
|
---|
165 |
|
---|
166 | return req;
|
---|
167 | }
|
---|
168 |
|
---|
169 | static void dcerpc_binding_handle_raw_call_done(struct tevent_req *subreq)
|
---|
170 | {
|
---|
171 | struct tevent_req *req = tevent_req_callback_data(subreq,
|
---|
172 | struct tevent_req);
|
---|
173 | struct dcerpc_binding_handle_raw_call_state *state =
|
---|
174 | tevent_req_data(req,
|
---|
175 | struct dcerpc_binding_handle_raw_call_state);
|
---|
176 | NTSTATUS error;
|
---|
177 |
|
---|
178 | error = state->ops->raw_call_recv(subreq, state,
|
---|
179 | &state->out_data,
|
---|
180 | &state->out_length,
|
---|
181 | &state->out_flags);
|
---|
182 | TALLOC_FREE(subreq);
|
---|
183 | if (tevent_req_nterror(req, error)) {
|
---|
184 | return;
|
---|
185 | }
|
---|
186 |
|
---|
187 | tevent_req_done(req);
|
---|
188 | }
|
---|
189 |
|
---|
190 | NTSTATUS dcerpc_binding_handle_raw_call_recv(struct tevent_req *req,
|
---|
191 | TALLOC_CTX *mem_ctx,
|
---|
192 | uint8_t **out_data,
|
---|
193 | size_t *out_length,
|
---|
194 | uint32_t *out_flags)
|
---|
195 | {
|
---|
196 | struct dcerpc_binding_handle_raw_call_state *state =
|
---|
197 | tevent_req_data(req,
|
---|
198 | struct dcerpc_binding_handle_raw_call_state);
|
---|
199 | NTSTATUS error;
|
---|
200 |
|
---|
201 | if (tevent_req_is_nterror(req, &error)) {
|
---|
202 | tevent_req_received(req);
|
---|
203 | return error;
|
---|
204 | }
|
---|
205 |
|
---|
206 | *out_data = talloc_move(mem_ctx, &state->out_data);
|
---|
207 | *out_length = state->out_length;
|
---|
208 | *out_flags = state->out_flags;
|
---|
209 | tevent_req_received(req);
|
---|
210 | return NT_STATUS_OK;
|
---|
211 | }
|
---|
212 |
|
---|
213 | NTSTATUS dcerpc_binding_handle_raw_call(struct dcerpc_binding_handle *h,
|
---|
214 | const struct GUID *object,
|
---|
215 | uint32_t opnum,
|
---|
216 | uint32_t in_flags,
|
---|
217 | const uint8_t *in_data,
|
---|
218 | size_t in_length,
|
---|
219 | TALLOC_CTX *mem_ctx,
|
---|
220 | uint8_t **out_data,
|
---|
221 | size_t *out_length,
|
---|
222 | uint32_t *out_flags)
|
---|
223 | {
|
---|
224 | TALLOC_CTX *frame = talloc_stackframe();
|
---|
225 | struct tevent_context *ev;
|
---|
226 | struct tevent_req *subreq;
|
---|
227 | NTSTATUS status = NT_STATUS_NO_MEMORY;
|
---|
228 |
|
---|
229 | /*
|
---|
230 | * TODO: allow only one sync call
|
---|
231 | */
|
---|
232 |
|
---|
233 | if (h->sync_ev) {
|
---|
234 | ev = h->sync_ev;
|
---|
235 | } else {
|
---|
236 | ev = samba_tevent_context_init(frame);
|
---|
237 | }
|
---|
238 | if (ev == NULL) {
|
---|
239 | goto fail;
|
---|
240 | }
|
---|
241 |
|
---|
242 | subreq = dcerpc_binding_handle_raw_call_send(frame, ev,
|
---|
243 | h, object, opnum,
|
---|
244 | in_flags,
|
---|
245 | in_data,
|
---|
246 | in_length);
|
---|
247 | if (subreq == NULL) {
|
---|
248 | goto fail;
|
---|
249 | }
|
---|
250 |
|
---|
251 | if (!tevent_req_poll_ntstatus(subreq, ev, &status)) {
|
---|
252 | goto fail;
|
---|
253 | }
|
---|
254 |
|
---|
255 | status = dcerpc_binding_handle_raw_call_recv(subreq,
|
---|
256 | mem_ctx,
|
---|
257 | out_data,
|
---|
258 | out_length,
|
---|
259 | out_flags);
|
---|
260 | fail:
|
---|
261 | TALLOC_FREE(frame);
|
---|
262 | return status;
|
---|
263 | }
|
---|
264 |
|
---|
265 | struct dcerpc_binding_handle_disconnect_state {
|
---|
266 | const struct dcerpc_binding_handle_ops *ops;
|
---|
267 | };
|
---|
268 |
|
---|
269 | static void dcerpc_binding_handle_disconnect_done(struct tevent_req *subreq);
|
---|
270 |
|
---|
271 | struct tevent_req *dcerpc_binding_handle_disconnect_send(TALLOC_CTX *mem_ctx,
|
---|
272 | struct tevent_context *ev,
|
---|
273 | struct dcerpc_binding_handle *h)
|
---|
274 | {
|
---|
275 | struct tevent_req *req;
|
---|
276 | struct dcerpc_binding_handle_disconnect_state *state;
|
---|
277 | struct tevent_req *subreq;
|
---|
278 |
|
---|
279 | req = tevent_req_create(mem_ctx, &state,
|
---|
280 | struct dcerpc_binding_handle_disconnect_state);
|
---|
281 | if (req == NULL) {
|
---|
282 | return NULL;
|
---|
283 | }
|
---|
284 |
|
---|
285 | state->ops = h->ops;
|
---|
286 |
|
---|
287 | subreq = state->ops->disconnect_send(state, ev, h);
|
---|
288 | if (tevent_req_nomem(subreq, req)) {
|
---|
289 | return tevent_req_post(req, ev);
|
---|
290 | }
|
---|
291 | tevent_req_set_callback(subreq, dcerpc_binding_handle_disconnect_done, req);
|
---|
292 |
|
---|
293 | return req;
|
---|
294 | }
|
---|
295 |
|
---|
296 | static void dcerpc_binding_handle_disconnect_done(struct tevent_req *subreq)
|
---|
297 | {
|
---|
298 | struct tevent_req *req = tevent_req_callback_data(subreq,
|
---|
299 | struct tevent_req);
|
---|
300 | struct dcerpc_binding_handle_disconnect_state *state =
|
---|
301 | tevent_req_data(req,
|
---|
302 | struct dcerpc_binding_handle_disconnect_state);
|
---|
303 | NTSTATUS error;
|
---|
304 |
|
---|
305 | error = state->ops->disconnect_recv(subreq);
|
---|
306 | TALLOC_FREE(subreq);
|
---|
307 | if (tevent_req_nterror(req, error)) {
|
---|
308 | return;
|
---|
309 | }
|
---|
310 |
|
---|
311 | tevent_req_done(req);
|
---|
312 | }
|
---|
313 |
|
---|
314 | NTSTATUS dcerpc_binding_handle_disconnect_recv(struct tevent_req *req)
|
---|
315 | {
|
---|
316 | NTSTATUS error;
|
---|
317 |
|
---|
318 | if (tevent_req_is_nterror(req, &error)) {
|
---|
319 | tevent_req_received(req);
|
---|
320 | return error;
|
---|
321 | }
|
---|
322 |
|
---|
323 | tevent_req_received(req);
|
---|
324 | return NT_STATUS_OK;
|
---|
325 | }
|
---|
326 |
|
---|
327 | struct dcerpc_binding_handle_call_state {
|
---|
328 | struct dcerpc_binding_handle *h;
|
---|
329 | const struct ndr_interface_call *call;
|
---|
330 | TALLOC_CTX *r_mem;
|
---|
331 | void *r_ptr;
|
---|
332 | struct ndr_push *push;
|
---|
333 | DATA_BLOB request;
|
---|
334 | DATA_BLOB response;
|
---|
335 | struct ndr_pull *pull;
|
---|
336 | };
|
---|
337 |
|
---|
338 | static void dcerpc_binding_handle_call_done(struct tevent_req *subreq);
|
---|
339 |
|
---|
340 | struct tevent_req *dcerpc_binding_handle_call_send(TALLOC_CTX *mem_ctx,
|
---|
341 | struct tevent_context *ev,
|
---|
342 | struct dcerpc_binding_handle *h,
|
---|
343 | const struct GUID *object,
|
---|
344 | const struct ndr_interface_table *table,
|
---|
345 | uint32_t opnum,
|
---|
346 | TALLOC_CTX *r_mem,
|
---|
347 | void *r_ptr)
|
---|
348 | {
|
---|
349 | struct tevent_req *req;
|
---|
350 | struct dcerpc_binding_handle_call_state *state;
|
---|
351 | struct tevent_req *subreq;
|
---|
352 | enum ndr_err_code ndr_err;
|
---|
353 |
|
---|
354 | req = tevent_req_create(mem_ctx, &state,
|
---|
355 | struct dcerpc_binding_handle_call_state);
|
---|
356 | if (req == NULL) {
|
---|
357 | return NULL;
|
---|
358 | }
|
---|
359 |
|
---|
360 | #if 0 /* TODO: activate this when the callers are fixed */
|
---|
361 | if (table != h->table) {
|
---|
362 | tevent_req_nterror(req, NT_STATUS_INVALID_HANDLE);
|
---|
363 | return tevent_req_post(req, ev);
|
---|
364 | }
|
---|
365 | #endif
|
---|
366 |
|
---|
367 | if (opnum >= table->num_calls) {
|
---|
368 | tevent_req_nterror(req, NT_STATUS_INTERNAL_ERROR);
|
---|
369 | return tevent_req_post(req, ev);
|
---|
370 | }
|
---|
371 |
|
---|
372 | state->h = h;
|
---|
373 | state->call = &table->calls[opnum];
|
---|
374 |
|
---|
375 | state->r_mem = r_mem;
|
---|
376 | state->r_ptr = r_ptr;
|
---|
377 |
|
---|
378 | /* setup for a ndr_push_* call */
|
---|
379 | state->push = ndr_push_init_ctx(state);
|
---|
380 | if (tevent_req_nomem(state->push, req)) {
|
---|
381 | return tevent_req_post(req, ev);
|
---|
382 | }
|
---|
383 |
|
---|
384 | if (h->ops->ref_alloc && h->ops->ref_alloc(h)) {
|
---|
385 | state->push->flags |= LIBNDR_FLAG_REF_ALLOC;
|
---|
386 | }
|
---|
387 |
|
---|
388 | if (h->ops->push_bigendian && h->ops->push_bigendian(h)) {
|
---|
389 | state->push->flags |= LIBNDR_FLAG_BIGENDIAN;
|
---|
390 | }
|
---|
391 |
|
---|
392 | if (h->ops->use_ndr64 && h->ops->use_ndr64(h)) {
|
---|
393 | state->push->flags |= LIBNDR_FLAG_NDR64;
|
---|
394 | }
|
---|
395 |
|
---|
396 | if (h->ops->do_ndr_print) {
|
---|
397 | h->ops->do_ndr_print(h, NDR_IN | NDR_SET_VALUES,
|
---|
398 | state->r_ptr, state->call);
|
---|
399 | }
|
---|
400 |
|
---|
401 | /* push the structure into a blob */
|
---|
402 | ndr_err = state->call->ndr_push(state->push, NDR_IN, state->r_ptr);
|
---|
403 | if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
|
---|
404 | NTSTATUS error;
|
---|
405 | error = ndr_map_error2ntstatus(ndr_err);
|
---|
406 | if (h->ops->ndr_push_failed) {
|
---|
407 | h->ops->ndr_push_failed(h, error,
|
---|
408 | state->r_ptr,
|
---|
409 | state->call);
|
---|
410 | }
|
---|
411 | tevent_req_nterror(req, error);
|
---|
412 | return tevent_req_post(req, ev);
|
---|
413 | }
|
---|
414 |
|
---|
415 | /* retrieve the blob */
|
---|
416 | state->request = ndr_push_blob(state->push);
|
---|
417 |
|
---|
418 | if (h->ops->ndr_validate_in) {
|
---|
419 | NTSTATUS error;
|
---|
420 | error = h->ops->ndr_validate_in(h, state,
|
---|
421 | &state->request,
|
---|
422 | state->call);
|
---|
423 | if (!NT_STATUS_IS_OK(error)) {
|
---|
424 | tevent_req_nterror(req, error);
|
---|
425 | return tevent_req_post(req, ev);
|
---|
426 | }
|
---|
427 | }
|
---|
428 |
|
---|
429 | subreq = dcerpc_binding_handle_raw_call_send(state, ev,
|
---|
430 | h, object, opnum,
|
---|
431 | state->push->flags,
|
---|
432 | state->request.data,
|
---|
433 | state->request.length);
|
---|
434 | if (tevent_req_nomem(subreq, req)) {
|
---|
435 | return tevent_req_post(req, ev);
|
---|
436 | }
|
---|
437 | tevent_req_set_callback(subreq, dcerpc_binding_handle_call_done, req);
|
---|
438 |
|
---|
439 | return req;
|
---|
440 | }
|
---|
441 |
|
---|
442 | static void dcerpc_binding_handle_call_done(struct tevent_req *subreq)
|
---|
443 | {
|
---|
444 | struct tevent_req *req = tevent_req_callback_data(subreq,
|
---|
445 | struct tevent_req);
|
---|
446 | struct dcerpc_binding_handle_call_state *state =
|
---|
447 | tevent_req_data(req,
|
---|
448 | struct dcerpc_binding_handle_call_state);
|
---|
449 | struct dcerpc_binding_handle *h = state->h;
|
---|
450 | NTSTATUS error;
|
---|
451 | uint32_t out_flags = 0;
|
---|
452 | enum ndr_err_code ndr_err;
|
---|
453 |
|
---|
454 | error = dcerpc_binding_handle_raw_call_recv(subreq, state,
|
---|
455 | &state->response.data,
|
---|
456 | &state->response.length,
|
---|
457 | &out_flags);
|
---|
458 | TALLOC_FREE(subreq);
|
---|
459 | if (tevent_req_nterror(req, error)) {
|
---|
460 | return;
|
---|
461 | }
|
---|
462 |
|
---|
463 | state->pull = ndr_pull_init_blob(&state->response, state);
|
---|
464 | if (tevent_req_nomem(state->pull, req)) {
|
---|
465 | return;
|
---|
466 | }
|
---|
467 | state->pull->flags = state->push->flags;
|
---|
468 |
|
---|
469 | if (out_flags & LIBNDR_FLAG_BIGENDIAN) {
|
---|
470 | state->pull->flags |= LIBNDR_FLAG_BIGENDIAN;
|
---|
471 | } else {
|
---|
472 | state->pull->flags &= ~LIBNDR_FLAG_BIGENDIAN;
|
---|
473 | }
|
---|
474 |
|
---|
475 | state->pull->current_mem_ctx = state->r_mem;
|
---|
476 |
|
---|
477 | /* pull the structure from the blob */
|
---|
478 | ndr_err = state->call->ndr_pull(state->pull, NDR_OUT, state->r_ptr);
|
---|
479 | if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
|
---|
480 | error = ndr_map_error2ntstatus(ndr_err);
|
---|
481 | if (h->ops->ndr_pull_failed) {
|
---|
482 | h->ops->ndr_pull_failed(h, error,
|
---|
483 | &state->response,
|
---|
484 | state->call);
|
---|
485 | }
|
---|
486 | tevent_req_nterror(req, error);
|
---|
487 | return;
|
---|
488 | }
|
---|
489 |
|
---|
490 | if (h->ops->do_ndr_print) {
|
---|
491 | h->ops->do_ndr_print(h, NDR_OUT,
|
---|
492 | state->r_ptr, state->call);
|
---|
493 | }
|
---|
494 |
|
---|
495 | if (h->ops->ndr_validate_out) {
|
---|
496 | error = h->ops->ndr_validate_out(h,
|
---|
497 | state->pull,
|
---|
498 | state->r_ptr,
|
---|
499 | state->call);
|
---|
500 | if (!NT_STATUS_IS_OK(error)) {
|
---|
501 | tevent_req_nterror(req, error);
|
---|
502 | return;
|
---|
503 | }
|
---|
504 | }
|
---|
505 |
|
---|
506 | tevent_req_done(req);
|
---|
507 | }
|
---|
508 |
|
---|
509 | NTSTATUS dcerpc_binding_handle_call_recv(struct tevent_req *req)
|
---|
510 | {
|
---|
511 | return tevent_req_simple_recv_ntstatus(req);
|
---|
512 | }
|
---|
513 |
|
---|
514 | NTSTATUS dcerpc_binding_handle_call(struct dcerpc_binding_handle *h,
|
---|
515 | const struct GUID *object,
|
---|
516 | const struct ndr_interface_table *table,
|
---|
517 | uint32_t opnum,
|
---|
518 | TALLOC_CTX *r_mem,
|
---|
519 | void *r_ptr)
|
---|
520 | {
|
---|
521 | TALLOC_CTX *frame = talloc_stackframe();
|
---|
522 | struct tevent_context *ev;
|
---|
523 | struct tevent_req *subreq;
|
---|
524 | NTSTATUS status = NT_STATUS_NO_MEMORY;
|
---|
525 |
|
---|
526 | /*
|
---|
527 | * TODO: allow only one sync call
|
---|
528 | */
|
---|
529 |
|
---|
530 | if (h->sync_ev) {
|
---|
531 | ev = h->sync_ev;
|
---|
532 | } else {
|
---|
533 | ev = samba_tevent_context_init(frame);
|
---|
534 | }
|
---|
535 | if (ev == NULL) {
|
---|
536 | goto fail;
|
---|
537 | }
|
---|
538 |
|
---|
539 | subreq = dcerpc_binding_handle_call_send(frame, ev,
|
---|
540 | h, object, table,
|
---|
541 | opnum, r_mem, r_ptr);
|
---|
542 | if (subreq == NULL) {
|
---|
543 | goto fail;
|
---|
544 | }
|
---|
545 |
|
---|
546 | if (!tevent_req_poll_ntstatus(subreq, ev, &status)) {
|
---|
547 | goto fail;
|
---|
548 | }
|
---|
549 |
|
---|
550 | status = dcerpc_binding_handle_call_recv(subreq);
|
---|
551 | fail:
|
---|
552 | TALLOC_FREE(frame);
|
---|
553 | return status;
|
---|
554 | }
|
---|