2bdfc43a2a7eb5f8cbb0a1300bd63a4f0c9961ef
[metze/samba/wip.git] / source3 / librpc / gen_ndr / ndr_unixinfo_c.c
1 /* client functions auto-generated by pidl */
2
3 #include "includes.h"
4 #include <tevent.h>
5 #include "lib/util/tevent_ntstatus.h"
6 #include "librpc/gen_ndr/ndr_unixinfo.h"
7 #include "librpc/gen_ndr/ndr_unixinfo_c.h"
8
9 /* unixinfo - client functions generated by pidl */
10
11 struct dcerpc_unixinfo_SidToUid_r_state {
12         TALLOC_CTX *out_mem_ctx;
13 };
14
15 static void dcerpc_unixinfo_SidToUid_r_done(struct tevent_req *subreq);
16
17 struct tevent_req *dcerpc_unixinfo_SidToUid_r_send(TALLOC_CTX *mem_ctx,
18         struct tevent_context *ev,
19         struct dcerpc_binding_handle *h,
20         struct unixinfo_SidToUid *r)
21 {
22         struct tevent_req *req;
23         struct dcerpc_unixinfo_SidToUid_r_state *state;
24         struct tevent_req *subreq;
25
26         req = tevent_req_create(mem_ctx, &state,
27                                 struct dcerpc_unixinfo_SidToUid_r_state);
28         if (req == NULL) {
29                 return NULL;
30         }
31
32         state->out_mem_ctx = talloc_new(state);
33         if (tevent_req_nomem(state->out_mem_ctx, req)) {
34                 return tevent_req_post(req, ev);
35         }
36
37         subreq = dcerpc_binding_handle_call_send(state, ev, h,
38                         NULL, &ndr_table_unixinfo,
39                         NDR_UNIXINFO_SIDTOUID, state->out_mem_ctx, r);
40         if (tevent_req_nomem(subreq, req)) {
41                 return tevent_req_post(req, ev);
42         }
43         tevent_req_set_callback(subreq, dcerpc_unixinfo_SidToUid_r_done, req);
44
45         return req;
46 }
47
48 static void dcerpc_unixinfo_SidToUid_r_done(struct tevent_req *subreq)
49 {
50         struct tevent_req *req =
51                 tevent_req_callback_data(subreq,
52                 struct tevent_req);
53         NTSTATUS status;
54
55         status = dcerpc_binding_handle_call_recv(subreq);
56         if (!NT_STATUS_IS_OK(status)) {
57                 tevent_req_nterror(req, status);
58                 return;
59         }
60
61         tevent_req_done(req);
62 }
63
64 NTSTATUS dcerpc_unixinfo_SidToUid_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
65 {
66         struct dcerpc_unixinfo_SidToUid_r_state *state =
67                 tevent_req_data(req,
68                 struct dcerpc_unixinfo_SidToUid_r_state);
69         NTSTATUS status;
70
71         if (tevent_req_is_nterror(req, &status)) {
72                 tevent_req_received(req);
73                 return status;
74         }
75
76         talloc_steal(mem_ctx, state->out_mem_ctx);
77
78         tevent_req_received(req);
79         return NT_STATUS_OK;
80 }
81
82 NTSTATUS dcerpc_unixinfo_SidToUid_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct unixinfo_SidToUid *r)
83 {
84         NTSTATUS status;
85
86         status = dcerpc_binding_handle_call(h,
87                         NULL, &ndr_table_unixinfo,
88                         NDR_UNIXINFO_SIDTOUID, mem_ctx, r);
89
90         return status;
91 }
92
93 NTSTATUS dcerpc_unixinfo_SidToUid_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct unixinfo_SidToUid *r)
94 {
95         NTSTATUS status;
96
97         status = dcerpc_unixinfo_SidToUid_r(p->binding_handle, mem_ctx, r);
98
99         if (NT_STATUS_IS_RPC(status)) {
100                 status = NT_STATUS_NET_WRITE_FAULT;
101         }
102
103         if (NT_STATUS_IS_OK(status)) {
104                 status = r->out.result;
105         }
106
107         return status;
108 }
109
110 struct dcerpc_unixinfo_SidToUid_state {
111         struct unixinfo_SidToUid orig;
112         struct unixinfo_SidToUid tmp;
113         TALLOC_CTX *out_mem_ctx;
114 };
115
116 static void dcerpc_unixinfo_SidToUid_done(struct tevent_req *subreq);
117
118 struct tevent_req *dcerpc_unixinfo_SidToUid_send(TALLOC_CTX *mem_ctx,
119                                                  struct tevent_context *ev,
120                                                  struct dcerpc_binding_handle *h,
121                                                  struct dom_sid _sid /* [in]  */,
122                                                  uint64_t *_uid /* [out] [ref] */)
123 {
124         struct tevent_req *req;
125         struct dcerpc_unixinfo_SidToUid_state *state;
126         struct tevent_req *subreq;
127
128         req = tevent_req_create(mem_ctx, &state,
129                                 struct dcerpc_unixinfo_SidToUid_state);
130         if (req == NULL) {
131                 return NULL;
132         }
133         state->out_mem_ctx = NULL;
134
135         /* In parameters */
136         state->orig.in.sid = _sid;
137
138         /* Out parameters */
139         state->orig.out.uid = _uid;
140
141         /* Result */
142         ZERO_STRUCT(state->orig.out.result);
143
144         state->out_mem_ctx = talloc_named_const(state, 0,
145                              "dcerpc_unixinfo_SidToUid_out_memory");
146         if (tevent_req_nomem(state->out_mem_ctx, req)) {
147                 return tevent_req_post(req, ev);
148         }
149
150         /* make a temporary copy, that we pass to the dispatch function */
151         state->tmp = state->orig;
152
153         subreq = dcerpc_unixinfo_SidToUid_r_send(state, ev, h, &state->tmp);
154         if (tevent_req_nomem(subreq, req)) {
155                 return tevent_req_post(req, ev);
156         }
157         tevent_req_set_callback(subreq, dcerpc_unixinfo_SidToUid_done, req);
158         return req;
159 }
160
161 static void dcerpc_unixinfo_SidToUid_done(struct tevent_req *subreq)
162 {
163         struct tevent_req *req = tevent_req_callback_data(
164                 subreq, struct tevent_req);
165         struct dcerpc_unixinfo_SidToUid_state *state = tevent_req_data(
166                 req, struct dcerpc_unixinfo_SidToUid_state);
167         NTSTATUS status;
168         TALLOC_CTX *mem_ctx;
169
170         if (state->out_mem_ctx) {
171                 mem_ctx = state->out_mem_ctx;
172         } else {
173                 mem_ctx = state;
174         }
175
176         status = dcerpc_unixinfo_SidToUid_r_recv(subreq, mem_ctx);
177         TALLOC_FREE(subreq);
178         if (!NT_STATUS_IS_OK(status)) {
179                 tevent_req_nterror(req, status);
180                 return;
181         }
182
183         /* Copy out parameters */
184         *state->orig.out.uid = *state->tmp.out.uid;
185
186         /* Copy result */
187         state->orig.out.result = state->tmp.out.result;
188
189         /* Reset temporary structure */
190         ZERO_STRUCT(state->tmp);
191
192         tevent_req_done(req);
193 }
194
195 NTSTATUS dcerpc_unixinfo_SidToUid_recv(struct tevent_req *req,
196                                        TALLOC_CTX *mem_ctx,
197                                        NTSTATUS *result)
198 {
199         struct dcerpc_unixinfo_SidToUid_state *state = tevent_req_data(
200                 req, struct dcerpc_unixinfo_SidToUid_state);
201         NTSTATUS status;
202
203         if (tevent_req_is_nterror(req, &status)) {
204                 tevent_req_received(req);
205                 return status;
206         }
207
208         /* Steal possible out parameters to the callers context */
209         talloc_steal(mem_ctx, state->out_mem_ctx);
210
211         /* Return result */
212         *result = state->orig.out.result;
213
214         tevent_req_received(req);
215         return NT_STATUS_OK;
216 }
217
218 NTSTATUS dcerpc_unixinfo_SidToUid(struct dcerpc_binding_handle *h,
219                                   TALLOC_CTX *mem_ctx,
220                                   struct dom_sid _sid /* [in]  */,
221                                   uint64_t *_uid /* [out] [ref] */,
222                                   NTSTATUS *result)
223 {
224         struct unixinfo_SidToUid r;
225         NTSTATUS status;
226
227         /* In parameters */
228         r.in.sid = _sid;
229
230         status = dcerpc_unixinfo_SidToUid_r(h, mem_ctx, &r);
231         if (!NT_STATUS_IS_OK(status)) {
232                 return status;
233         }
234
235         /* Return variables */
236         *_uid = *r.out.uid;
237
238         /* Return result */
239         *result = r.out.result;
240
241         return NT_STATUS_OK;
242 }
243
244 struct dcerpc_unixinfo_UidToSid_r_state {
245         TALLOC_CTX *out_mem_ctx;
246 };
247
248 static void dcerpc_unixinfo_UidToSid_r_done(struct tevent_req *subreq);
249
250 struct tevent_req *dcerpc_unixinfo_UidToSid_r_send(TALLOC_CTX *mem_ctx,
251         struct tevent_context *ev,
252         struct dcerpc_binding_handle *h,
253         struct unixinfo_UidToSid *r)
254 {
255         struct tevent_req *req;
256         struct dcerpc_unixinfo_UidToSid_r_state *state;
257         struct tevent_req *subreq;
258
259         req = tevent_req_create(mem_ctx, &state,
260                                 struct dcerpc_unixinfo_UidToSid_r_state);
261         if (req == NULL) {
262                 return NULL;
263         }
264
265         state->out_mem_ctx = talloc_new(state);
266         if (tevent_req_nomem(state->out_mem_ctx, req)) {
267                 return tevent_req_post(req, ev);
268         }
269
270         subreq = dcerpc_binding_handle_call_send(state, ev, h,
271                         NULL, &ndr_table_unixinfo,
272                         NDR_UNIXINFO_UIDTOSID, state->out_mem_ctx, r);
273         if (tevent_req_nomem(subreq, req)) {
274                 return tevent_req_post(req, ev);
275         }
276         tevent_req_set_callback(subreq, dcerpc_unixinfo_UidToSid_r_done, req);
277
278         return req;
279 }
280
281 static void dcerpc_unixinfo_UidToSid_r_done(struct tevent_req *subreq)
282 {
283         struct tevent_req *req =
284                 tevent_req_callback_data(subreq,
285                 struct tevent_req);
286         NTSTATUS status;
287
288         status = dcerpc_binding_handle_call_recv(subreq);
289         if (!NT_STATUS_IS_OK(status)) {
290                 tevent_req_nterror(req, status);
291                 return;
292         }
293
294         tevent_req_done(req);
295 }
296
297 NTSTATUS dcerpc_unixinfo_UidToSid_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
298 {
299         struct dcerpc_unixinfo_UidToSid_r_state *state =
300                 tevent_req_data(req,
301                 struct dcerpc_unixinfo_UidToSid_r_state);
302         NTSTATUS status;
303
304         if (tevent_req_is_nterror(req, &status)) {
305                 tevent_req_received(req);
306                 return status;
307         }
308
309         talloc_steal(mem_ctx, state->out_mem_ctx);
310
311         tevent_req_received(req);
312         return NT_STATUS_OK;
313 }
314
315 NTSTATUS dcerpc_unixinfo_UidToSid_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct unixinfo_UidToSid *r)
316 {
317         NTSTATUS status;
318
319         status = dcerpc_binding_handle_call(h,
320                         NULL, &ndr_table_unixinfo,
321                         NDR_UNIXINFO_UIDTOSID, mem_ctx, r);
322
323         return status;
324 }
325
326 NTSTATUS dcerpc_unixinfo_UidToSid_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct unixinfo_UidToSid *r)
327 {
328         NTSTATUS status;
329
330         status = dcerpc_unixinfo_UidToSid_r(p->binding_handle, mem_ctx, r);
331
332         if (NT_STATUS_IS_RPC(status)) {
333                 status = NT_STATUS_NET_WRITE_FAULT;
334         }
335
336         if (NT_STATUS_IS_OK(status)) {
337                 status = r->out.result;
338         }
339
340         return status;
341 }
342
343 struct dcerpc_unixinfo_UidToSid_state {
344         struct unixinfo_UidToSid orig;
345         struct unixinfo_UidToSid tmp;
346         TALLOC_CTX *out_mem_ctx;
347 };
348
349 static void dcerpc_unixinfo_UidToSid_done(struct tevent_req *subreq);
350
351 struct tevent_req *dcerpc_unixinfo_UidToSid_send(TALLOC_CTX *mem_ctx,
352                                                  struct tevent_context *ev,
353                                                  struct dcerpc_binding_handle *h,
354                                                  uint64_t _uid /* [in]  */,
355                                                  struct dom_sid *_sid /* [out] [ref] */)
356 {
357         struct tevent_req *req;
358         struct dcerpc_unixinfo_UidToSid_state *state;
359         struct tevent_req *subreq;
360
361         req = tevent_req_create(mem_ctx, &state,
362                                 struct dcerpc_unixinfo_UidToSid_state);
363         if (req == NULL) {
364                 return NULL;
365         }
366         state->out_mem_ctx = NULL;
367
368         /* In parameters */
369         state->orig.in.uid = _uid;
370
371         /* Out parameters */
372         state->orig.out.sid = _sid;
373
374         /* Result */
375         ZERO_STRUCT(state->orig.out.result);
376
377         state->out_mem_ctx = talloc_named_const(state, 0,
378                              "dcerpc_unixinfo_UidToSid_out_memory");
379         if (tevent_req_nomem(state->out_mem_ctx, req)) {
380                 return tevent_req_post(req, ev);
381         }
382
383         /* make a temporary copy, that we pass to the dispatch function */
384         state->tmp = state->orig;
385
386         subreq = dcerpc_unixinfo_UidToSid_r_send(state, ev, h, &state->tmp);
387         if (tevent_req_nomem(subreq, req)) {
388                 return tevent_req_post(req, ev);
389         }
390         tevent_req_set_callback(subreq, dcerpc_unixinfo_UidToSid_done, req);
391         return req;
392 }
393
394 static void dcerpc_unixinfo_UidToSid_done(struct tevent_req *subreq)
395 {
396         struct tevent_req *req = tevent_req_callback_data(
397                 subreq, struct tevent_req);
398         struct dcerpc_unixinfo_UidToSid_state *state = tevent_req_data(
399                 req, struct dcerpc_unixinfo_UidToSid_state);
400         NTSTATUS status;
401         TALLOC_CTX *mem_ctx;
402
403         if (state->out_mem_ctx) {
404                 mem_ctx = state->out_mem_ctx;
405         } else {
406                 mem_ctx = state;
407         }
408
409         status = dcerpc_unixinfo_UidToSid_r_recv(subreq, mem_ctx);
410         TALLOC_FREE(subreq);
411         if (!NT_STATUS_IS_OK(status)) {
412                 tevent_req_nterror(req, status);
413                 return;
414         }
415
416         /* Copy out parameters */
417         *state->orig.out.sid = *state->tmp.out.sid;
418
419         /* Copy result */
420         state->orig.out.result = state->tmp.out.result;
421
422         /* Reset temporary structure */
423         ZERO_STRUCT(state->tmp);
424
425         tevent_req_done(req);
426 }
427
428 NTSTATUS dcerpc_unixinfo_UidToSid_recv(struct tevent_req *req,
429                                        TALLOC_CTX *mem_ctx,
430                                        NTSTATUS *result)
431 {
432         struct dcerpc_unixinfo_UidToSid_state *state = tevent_req_data(
433                 req, struct dcerpc_unixinfo_UidToSid_state);
434         NTSTATUS status;
435
436         if (tevent_req_is_nterror(req, &status)) {
437                 tevent_req_received(req);
438                 return status;
439         }
440
441         /* Steal possible out parameters to the callers context */
442         talloc_steal(mem_ctx, state->out_mem_ctx);
443
444         /* Return result */
445         *result = state->orig.out.result;
446
447         tevent_req_received(req);
448         return NT_STATUS_OK;
449 }
450
451 NTSTATUS dcerpc_unixinfo_UidToSid(struct dcerpc_binding_handle *h,
452                                   TALLOC_CTX *mem_ctx,
453                                   uint64_t _uid /* [in]  */,
454                                   struct dom_sid *_sid /* [out] [ref] */,
455                                   NTSTATUS *result)
456 {
457         struct unixinfo_UidToSid r;
458         NTSTATUS status;
459
460         /* In parameters */
461         r.in.uid = _uid;
462
463         status = dcerpc_unixinfo_UidToSid_r(h, mem_ctx, &r);
464         if (!NT_STATUS_IS_OK(status)) {
465                 return status;
466         }
467
468         /* Return variables */
469         *_sid = *r.out.sid;
470
471         /* Return result */
472         *result = r.out.result;
473
474         return NT_STATUS_OK;
475 }
476
477 struct dcerpc_unixinfo_SidToGid_r_state {
478         TALLOC_CTX *out_mem_ctx;
479 };
480
481 static void dcerpc_unixinfo_SidToGid_r_done(struct tevent_req *subreq);
482
483 struct tevent_req *dcerpc_unixinfo_SidToGid_r_send(TALLOC_CTX *mem_ctx,
484         struct tevent_context *ev,
485         struct dcerpc_binding_handle *h,
486         struct unixinfo_SidToGid *r)
487 {
488         struct tevent_req *req;
489         struct dcerpc_unixinfo_SidToGid_r_state *state;
490         struct tevent_req *subreq;
491
492         req = tevent_req_create(mem_ctx, &state,
493                                 struct dcerpc_unixinfo_SidToGid_r_state);
494         if (req == NULL) {
495                 return NULL;
496         }
497
498         state->out_mem_ctx = talloc_new(state);
499         if (tevent_req_nomem(state->out_mem_ctx, req)) {
500                 return tevent_req_post(req, ev);
501         }
502
503         subreq = dcerpc_binding_handle_call_send(state, ev, h,
504                         NULL, &ndr_table_unixinfo,
505                         NDR_UNIXINFO_SIDTOGID, state->out_mem_ctx, r);
506         if (tevent_req_nomem(subreq, req)) {
507                 return tevent_req_post(req, ev);
508         }
509         tevent_req_set_callback(subreq, dcerpc_unixinfo_SidToGid_r_done, req);
510
511         return req;
512 }
513
514 static void dcerpc_unixinfo_SidToGid_r_done(struct tevent_req *subreq)
515 {
516         struct tevent_req *req =
517                 tevent_req_callback_data(subreq,
518                 struct tevent_req);
519         NTSTATUS status;
520
521         status = dcerpc_binding_handle_call_recv(subreq);
522         if (!NT_STATUS_IS_OK(status)) {
523                 tevent_req_nterror(req, status);
524                 return;
525         }
526
527         tevent_req_done(req);
528 }
529
530 NTSTATUS dcerpc_unixinfo_SidToGid_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
531 {
532         struct dcerpc_unixinfo_SidToGid_r_state *state =
533                 tevent_req_data(req,
534                 struct dcerpc_unixinfo_SidToGid_r_state);
535         NTSTATUS status;
536
537         if (tevent_req_is_nterror(req, &status)) {
538                 tevent_req_received(req);
539                 return status;
540         }
541
542         talloc_steal(mem_ctx, state->out_mem_ctx);
543
544         tevent_req_received(req);
545         return NT_STATUS_OK;
546 }
547
548 NTSTATUS dcerpc_unixinfo_SidToGid_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct unixinfo_SidToGid *r)
549 {
550         NTSTATUS status;
551
552         status = dcerpc_binding_handle_call(h,
553                         NULL, &ndr_table_unixinfo,
554                         NDR_UNIXINFO_SIDTOGID, mem_ctx, r);
555
556         return status;
557 }
558
559 NTSTATUS dcerpc_unixinfo_SidToGid_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct unixinfo_SidToGid *r)
560 {
561         NTSTATUS status;
562
563         status = dcerpc_unixinfo_SidToGid_r(p->binding_handle, mem_ctx, r);
564
565         if (NT_STATUS_IS_RPC(status)) {
566                 status = NT_STATUS_NET_WRITE_FAULT;
567         }
568
569         if (NT_STATUS_IS_OK(status)) {
570                 status = r->out.result;
571         }
572
573         return status;
574 }
575
576 struct dcerpc_unixinfo_SidToGid_state {
577         struct unixinfo_SidToGid orig;
578         struct unixinfo_SidToGid tmp;
579         TALLOC_CTX *out_mem_ctx;
580 };
581
582 static void dcerpc_unixinfo_SidToGid_done(struct tevent_req *subreq);
583
584 struct tevent_req *dcerpc_unixinfo_SidToGid_send(TALLOC_CTX *mem_ctx,
585                                                  struct tevent_context *ev,
586                                                  struct dcerpc_binding_handle *h,
587                                                  struct dom_sid _sid /* [in]  */,
588                                                  uint64_t *_gid /* [out] [ref] */)
589 {
590         struct tevent_req *req;
591         struct dcerpc_unixinfo_SidToGid_state *state;
592         struct tevent_req *subreq;
593
594         req = tevent_req_create(mem_ctx, &state,
595                                 struct dcerpc_unixinfo_SidToGid_state);
596         if (req == NULL) {
597                 return NULL;
598         }
599         state->out_mem_ctx = NULL;
600
601         /* In parameters */
602         state->orig.in.sid = _sid;
603
604         /* Out parameters */
605         state->orig.out.gid = _gid;
606
607         /* Result */
608         ZERO_STRUCT(state->orig.out.result);
609
610         state->out_mem_ctx = talloc_named_const(state, 0,
611                              "dcerpc_unixinfo_SidToGid_out_memory");
612         if (tevent_req_nomem(state->out_mem_ctx, req)) {
613                 return tevent_req_post(req, ev);
614         }
615
616         /* make a temporary copy, that we pass to the dispatch function */
617         state->tmp = state->orig;
618
619         subreq = dcerpc_unixinfo_SidToGid_r_send(state, ev, h, &state->tmp);
620         if (tevent_req_nomem(subreq, req)) {
621                 return tevent_req_post(req, ev);
622         }
623         tevent_req_set_callback(subreq, dcerpc_unixinfo_SidToGid_done, req);
624         return req;
625 }
626
627 static void dcerpc_unixinfo_SidToGid_done(struct tevent_req *subreq)
628 {
629         struct tevent_req *req = tevent_req_callback_data(
630                 subreq, struct tevent_req);
631         struct dcerpc_unixinfo_SidToGid_state *state = tevent_req_data(
632                 req, struct dcerpc_unixinfo_SidToGid_state);
633         NTSTATUS status;
634         TALLOC_CTX *mem_ctx;
635
636         if (state->out_mem_ctx) {
637                 mem_ctx = state->out_mem_ctx;
638         } else {
639                 mem_ctx = state;
640         }
641
642         status = dcerpc_unixinfo_SidToGid_r_recv(subreq, mem_ctx);
643         TALLOC_FREE(subreq);
644         if (!NT_STATUS_IS_OK(status)) {
645                 tevent_req_nterror(req, status);
646                 return;
647         }
648
649         /* Copy out parameters */
650         *state->orig.out.gid = *state->tmp.out.gid;
651
652         /* Copy result */
653         state->orig.out.result = state->tmp.out.result;
654
655         /* Reset temporary structure */
656         ZERO_STRUCT(state->tmp);
657
658         tevent_req_done(req);
659 }
660
661 NTSTATUS dcerpc_unixinfo_SidToGid_recv(struct tevent_req *req,
662                                        TALLOC_CTX *mem_ctx,
663                                        NTSTATUS *result)
664 {
665         struct dcerpc_unixinfo_SidToGid_state *state = tevent_req_data(
666                 req, struct dcerpc_unixinfo_SidToGid_state);
667         NTSTATUS status;
668
669         if (tevent_req_is_nterror(req, &status)) {
670                 tevent_req_received(req);
671                 return status;
672         }
673
674         /* Steal possible out parameters to the callers context */
675         talloc_steal(mem_ctx, state->out_mem_ctx);
676
677         /* Return result */
678         *result = state->orig.out.result;
679
680         tevent_req_received(req);
681         return NT_STATUS_OK;
682 }
683
684 NTSTATUS dcerpc_unixinfo_SidToGid(struct dcerpc_binding_handle *h,
685                                   TALLOC_CTX *mem_ctx,
686                                   struct dom_sid _sid /* [in]  */,
687                                   uint64_t *_gid /* [out] [ref] */,
688                                   NTSTATUS *result)
689 {
690         struct unixinfo_SidToGid r;
691         NTSTATUS status;
692
693         /* In parameters */
694         r.in.sid = _sid;
695
696         status = dcerpc_unixinfo_SidToGid_r(h, mem_ctx, &r);
697         if (!NT_STATUS_IS_OK(status)) {
698                 return status;
699         }
700
701         /* Return variables */
702         *_gid = *r.out.gid;
703
704         /* Return result */
705         *result = r.out.result;
706
707         return NT_STATUS_OK;
708 }
709
710 struct dcerpc_unixinfo_GidToSid_r_state {
711         TALLOC_CTX *out_mem_ctx;
712 };
713
714 static void dcerpc_unixinfo_GidToSid_r_done(struct tevent_req *subreq);
715
716 struct tevent_req *dcerpc_unixinfo_GidToSid_r_send(TALLOC_CTX *mem_ctx,
717         struct tevent_context *ev,
718         struct dcerpc_binding_handle *h,
719         struct unixinfo_GidToSid *r)
720 {
721         struct tevent_req *req;
722         struct dcerpc_unixinfo_GidToSid_r_state *state;
723         struct tevent_req *subreq;
724
725         req = tevent_req_create(mem_ctx, &state,
726                                 struct dcerpc_unixinfo_GidToSid_r_state);
727         if (req == NULL) {
728                 return NULL;
729         }
730
731         state->out_mem_ctx = talloc_new(state);
732         if (tevent_req_nomem(state->out_mem_ctx, req)) {
733                 return tevent_req_post(req, ev);
734         }
735
736         subreq = dcerpc_binding_handle_call_send(state, ev, h,
737                         NULL, &ndr_table_unixinfo,
738                         NDR_UNIXINFO_GIDTOSID, state->out_mem_ctx, r);
739         if (tevent_req_nomem(subreq, req)) {
740                 return tevent_req_post(req, ev);
741         }
742         tevent_req_set_callback(subreq, dcerpc_unixinfo_GidToSid_r_done, req);
743
744         return req;
745 }
746
747 static void dcerpc_unixinfo_GidToSid_r_done(struct tevent_req *subreq)
748 {
749         struct tevent_req *req =
750                 tevent_req_callback_data(subreq,
751                 struct tevent_req);
752         NTSTATUS status;
753
754         status = dcerpc_binding_handle_call_recv(subreq);
755         if (!NT_STATUS_IS_OK(status)) {
756                 tevent_req_nterror(req, status);
757                 return;
758         }
759
760         tevent_req_done(req);
761 }
762
763 NTSTATUS dcerpc_unixinfo_GidToSid_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
764 {
765         struct dcerpc_unixinfo_GidToSid_r_state *state =
766                 tevent_req_data(req,
767                 struct dcerpc_unixinfo_GidToSid_r_state);
768         NTSTATUS status;
769
770         if (tevent_req_is_nterror(req, &status)) {
771                 tevent_req_received(req);
772                 return status;
773         }
774
775         talloc_steal(mem_ctx, state->out_mem_ctx);
776
777         tevent_req_received(req);
778         return NT_STATUS_OK;
779 }
780
781 NTSTATUS dcerpc_unixinfo_GidToSid_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct unixinfo_GidToSid *r)
782 {
783         NTSTATUS status;
784
785         status = dcerpc_binding_handle_call(h,
786                         NULL, &ndr_table_unixinfo,
787                         NDR_UNIXINFO_GIDTOSID, mem_ctx, r);
788
789         return status;
790 }
791
792 NTSTATUS dcerpc_unixinfo_GidToSid_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct unixinfo_GidToSid *r)
793 {
794         NTSTATUS status;
795
796         status = dcerpc_unixinfo_GidToSid_r(p->binding_handle, mem_ctx, r);
797
798         if (NT_STATUS_IS_RPC(status)) {
799                 status = NT_STATUS_NET_WRITE_FAULT;
800         }
801
802         if (NT_STATUS_IS_OK(status)) {
803                 status = r->out.result;
804         }
805
806         return status;
807 }
808
809 struct dcerpc_unixinfo_GidToSid_state {
810         struct unixinfo_GidToSid orig;
811         struct unixinfo_GidToSid tmp;
812         TALLOC_CTX *out_mem_ctx;
813 };
814
815 static void dcerpc_unixinfo_GidToSid_done(struct tevent_req *subreq);
816
817 struct tevent_req *dcerpc_unixinfo_GidToSid_send(TALLOC_CTX *mem_ctx,
818                                                  struct tevent_context *ev,
819                                                  struct dcerpc_binding_handle *h,
820                                                  uint64_t _gid /* [in]  */,
821                                                  struct dom_sid *_sid /* [out] [ref] */)
822 {
823         struct tevent_req *req;
824         struct dcerpc_unixinfo_GidToSid_state *state;
825         struct tevent_req *subreq;
826
827         req = tevent_req_create(mem_ctx, &state,
828                                 struct dcerpc_unixinfo_GidToSid_state);
829         if (req == NULL) {
830                 return NULL;
831         }
832         state->out_mem_ctx = NULL;
833
834         /* In parameters */
835         state->orig.in.gid = _gid;
836
837         /* Out parameters */
838         state->orig.out.sid = _sid;
839
840         /* Result */
841         ZERO_STRUCT(state->orig.out.result);
842
843         state->out_mem_ctx = talloc_named_const(state, 0,
844                              "dcerpc_unixinfo_GidToSid_out_memory");
845         if (tevent_req_nomem(state->out_mem_ctx, req)) {
846                 return tevent_req_post(req, ev);
847         }
848
849         /* make a temporary copy, that we pass to the dispatch function */
850         state->tmp = state->orig;
851
852         subreq = dcerpc_unixinfo_GidToSid_r_send(state, ev, h, &state->tmp);
853         if (tevent_req_nomem(subreq, req)) {
854                 return tevent_req_post(req, ev);
855         }
856         tevent_req_set_callback(subreq, dcerpc_unixinfo_GidToSid_done, req);
857         return req;
858 }
859
860 static void dcerpc_unixinfo_GidToSid_done(struct tevent_req *subreq)
861 {
862         struct tevent_req *req = tevent_req_callback_data(
863                 subreq, struct tevent_req);
864         struct dcerpc_unixinfo_GidToSid_state *state = tevent_req_data(
865                 req, struct dcerpc_unixinfo_GidToSid_state);
866         NTSTATUS status;
867         TALLOC_CTX *mem_ctx;
868
869         if (state->out_mem_ctx) {
870                 mem_ctx = state->out_mem_ctx;
871         } else {
872                 mem_ctx = state;
873         }
874
875         status = dcerpc_unixinfo_GidToSid_r_recv(subreq, mem_ctx);
876         TALLOC_FREE(subreq);
877         if (!NT_STATUS_IS_OK(status)) {
878                 tevent_req_nterror(req, status);
879                 return;
880         }
881
882         /* Copy out parameters */
883         *state->orig.out.sid = *state->tmp.out.sid;
884
885         /* Copy result */
886         state->orig.out.result = state->tmp.out.result;
887
888         /* Reset temporary structure */
889         ZERO_STRUCT(state->tmp);
890
891         tevent_req_done(req);
892 }
893
894 NTSTATUS dcerpc_unixinfo_GidToSid_recv(struct tevent_req *req,
895                                        TALLOC_CTX *mem_ctx,
896                                        NTSTATUS *result)
897 {
898         struct dcerpc_unixinfo_GidToSid_state *state = tevent_req_data(
899                 req, struct dcerpc_unixinfo_GidToSid_state);
900         NTSTATUS status;
901
902         if (tevent_req_is_nterror(req, &status)) {
903                 tevent_req_received(req);
904                 return status;
905         }
906
907         /* Steal possible out parameters to the callers context */
908         talloc_steal(mem_ctx, state->out_mem_ctx);
909
910         /* Return result */
911         *result = state->orig.out.result;
912
913         tevent_req_received(req);
914         return NT_STATUS_OK;
915 }
916
917 NTSTATUS dcerpc_unixinfo_GidToSid(struct dcerpc_binding_handle *h,
918                                   TALLOC_CTX *mem_ctx,
919                                   uint64_t _gid /* [in]  */,
920                                   struct dom_sid *_sid /* [out] [ref] */,
921                                   NTSTATUS *result)
922 {
923         struct unixinfo_GidToSid r;
924         NTSTATUS status;
925
926         /* In parameters */
927         r.in.gid = _gid;
928
929         status = dcerpc_unixinfo_GidToSid_r(h, mem_ctx, &r);
930         if (!NT_STATUS_IS_OK(status)) {
931                 return status;
932         }
933
934         /* Return variables */
935         *_sid = *r.out.sid;
936
937         /* Return result */
938         *result = r.out.result;
939
940         return NT_STATUS_OK;
941 }
942
943 struct dcerpc_unixinfo_GetPWUid_r_state {
944         TALLOC_CTX *out_mem_ctx;
945 };
946
947 static void dcerpc_unixinfo_GetPWUid_r_done(struct tevent_req *subreq);
948
949 struct tevent_req *dcerpc_unixinfo_GetPWUid_r_send(TALLOC_CTX *mem_ctx,
950         struct tevent_context *ev,
951         struct dcerpc_binding_handle *h,
952         struct unixinfo_GetPWUid *r)
953 {
954         struct tevent_req *req;
955         struct dcerpc_unixinfo_GetPWUid_r_state *state;
956         struct tevent_req *subreq;
957
958         req = tevent_req_create(mem_ctx, &state,
959                                 struct dcerpc_unixinfo_GetPWUid_r_state);
960         if (req == NULL) {
961                 return NULL;
962         }
963
964         state->out_mem_ctx = talloc_new(state);
965         if (tevent_req_nomem(state->out_mem_ctx, req)) {
966                 return tevent_req_post(req, ev);
967         }
968
969         subreq = dcerpc_binding_handle_call_send(state, ev, h,
970                         NULL, &ndr_table_unixinfo,
971                         NDR_UNIXINFO_GETPWUID, state->out_mem_ctx, r);
972         if (tevent_req_nomem(subreq, req)) {
973                 return tevent_req_post(req, ev);
974         }
975         tevent_req_set_callback(subreq, dcerpc_unixinfo_GetPWUid_r_done, req);
976
977         return req;
978 }
979
980 static void dcerpc_unixinfo_GetPWUid_r_done(struct tevent_req *subreq)
981 {
982         struct tevent_req *req =
983                 tevent_req_callback_data(subreq,
984                 struct tevent_req);
985         NTSTATUS status;
986
987         status = dcerpc_binding_handle_call_recv(subreq);
988         if (!NT_STATUS_IS_OK(status)) {
989                 tevent_req_nterror(req, status);
990                 return;
991         }
992
993         tevent_req_done(req);
994 }
995
996 NTSTATUS dcerpc_unixinfo_GetPWUid_r_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx)
997 {
998         struct dcerpc_unixinfo_GetPWUid_r_state *state =
999                 tevent_req_data(req,
1000                 struct dcerpc_unixinfo_GetPWUid_r_state);
1001         NTSTATUS status;
1002
1003         if (tevent_req_is_nterror(req, &status)) {
1004                 tevent_req_received(req);
1005                 return status;
1006         }
1007
1008         talloc_steal(mem_ctx, state->out_mem_ctx);
1009
1010         tevent_req_received(req);
1011         return NT_STATUS_OK;
1012 }
1013
1014 NTSTATUS dcerpc_unixinfo_GetPWUid_r(struct dcerpc_binding_handle *h, TALLOC_CTX *mem_ctx, struct unixinfo_GetPWUid *r)
1015 {
1016         NTSTATUS status;
1017
1018         status = dcerpc_binding_handle_call(h,
1019                         NULL, &ndr_table_unixinfo,
1020                         NDR_UNIXINFO_GETPWUID, mem_ctx, r);
1021
1022         return status;
1023 }
1024
1025 NTSTATUS dcerpc_unixinfo_GetPWUid_compat(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct unixinfo_GetPWUid *r)
1026 {
1027         NTSTATUS status;
1028
1029         status = dcerpc_unixinfo_GetPWUid_r(p->binding_handle, mem_ctx, r);
1030
1031         if (NT_STATUS_IS_RPC(status)) {
1032                 status = NT_STATUS_NET_WRITE_FAULT;
1033         }
1034
1035         if (NT_STATUS_IS_OK(status)) {
1036                 status = r->out.result;
1037         }
1038
1039         return status;
1040 }
1041
1042 struct dcerpc_unixinfo_GetPWUid_state {
1043         struct unixinfo_GetPWUid orig;
1044         struct unixinfo_GetPWUid tmp;
1045         TALLOC_CTX *out_mem_ctx;
1046 };
1047
1048 static void dcerpc_unixinfo_GetPWUid_done(struct tevent_req *subreq);
1049
1050 struct tevent_req *dcerpc_unixinfo_GetPWUid_send(TALLOC_CTX *mem_ctx,
1051                                                  struct tevent_context *ev,
1052                                                  struct dcerpc_binding_handle *h,
1053                                                  uint32_t *_count /* [in,out] [ref,range(0,1023)] */,
1054                                                  uint64_t *_uids /* [in] [size_is(*count)] */,
1055                                                  struct unixinfo_GetPWUidInfo *_infos /* [out] [size_is(*count)] */)
1056 {
1057         struct tevent_req *req;
1058         struct dcerpc_unixinfo_GetPWUid_state *state;
1059         struct tevent_req *subreq;
1060
1061         req = tevent_req_create(mem_ctx, &state,
1062                                 struct dcerpc_unixinfo_GetPWUid_state);
1063         if (req == NULL) {
1064                 return NULL;
1065         }
1066         state->out_mem_ctx = NULL;
1067
1068         /* In parameters */
1069         state->orig.in.count = _count;
1070         state->orig.in.uids = _uids;
1071
1072         /* Out parameters */
1073         state->orig.out.count = _count;
1074         state->orig.out.infos = _infos;
1075
1076         /* Result */
1077         ZERO_STRUCT(state->orig.out.result);
1078
1079         state->out_mem_ctx = talloc_named_const(state, 0,
1080                              "dcerpc_unixinfo_GetPWUid_out_memory");
1081         if (tevent_req_nomem(state->out_mem_ctx, req)) {
1082                 return tevent_req_post(req, ev);
1083         }
1084
1085         /* make a temporary copy, that we pass to the dispatch function */
1086         state->tmp = state->orig;
1087
1088         subreq = dcerpc_unixinfo_GetPWUid_r_send(state, ev, h, &state->tmp);
1089         if (tevent_req_nomem(subreq, req)) {
1090                 return tevent_req_post(req, ev);
1091         }
1092         tevent_req_set_callback(subreq, dcerpc_unixinfo_GetPWUid_done, req);
1093         return req;
1094 }
1095
1096 static void dcerpc_unixinfo_GetPWUid_done(struct tevent_req *subreq)
1097 {
1098         struct tevent_req *req = tevent_req_callback_data(
1099                 subreq, struct tevent_req);
1100         struct dcerpc_unixinfo_GetPWUid_state *state = tevent_req_data(
1101                 req, struct dcerpc_unixinfo_GetPWUid_state);
1102         NTSTATUS status;
1103         TALLOC_CTX *mem_ctx;
1104
1105         if (state->out_mem_ctx) {
1106                 mem_ctx = state->out_mem_ctx;
1107         } else {
1108                 mem_ctx = state;
1109         }
1110
1111         status = dcerpc_unixinfo_GetPWUid_r_recv(subreq, mem_ctx);
1112         TALLOC_FREE(subreq);
1113         if (!NT_STATUS_IS_OK(status)) {
1114                 tevent_req_nterror(req, status);
1115                 return;
1116         }
1117
1118         /* Copy out parameters */
1119         *state->orig.out.count = *state->tmp.out.count;
1120         if ((*state->tmp.out.count) > (*state->tmp.in.count)) {
1121                 tevent_req_nterror(req, NT_STATUS_INVALID_NETWORK_RESPONSE);
1122                 return;
1123         }
1124         memcpy(state->orig.out.infos, state->tmp.out.infos, (*state->tmp.out.count) * sizeof(*state->orig.out.infos));
1125
1126         /* Copy result */
1127         state->orig.out.result = state->tmp.out.result;
1128
1129         /* Reset temporary structure */
1130         ZERO_STRUCT(state->tmp);
1131
1132         tevent_req_done(req);
1133 }
1134
1135 NTSTATUS dcerpc_unixinfo_GetPWUid_recv(struct tevent_req *req,
1136                                        TALLOC_CTX *mem_ctx,
1137                                        NTSTATUS *result)
1138 {
1139         struct dcerpc_unixinfo_GetPWUid_state *state = tevent_req_data(
1140                 req, struct dcerpc_unixinfo_GetPWUid_state);
1141         NTSTATUS status;
1142
1143         if (tevent_req_is_nterror(req, &status)) {
1144                 tevent_req_received(req);
1145                 return status;
1146         }
1147
1148         /* Steal possible out parameters to the callers context */
1149         talloc_steal(mem_ctx, state->out_mem_ctx);
1150
1151         /* Return result */
1152         *result = state->orig.out.result;
1153
1154         tevent_req_received(req);
1155         return NT_STATUS_OK;
1156 }
1157
1158 NTSTATUS dcerpc_unixinfo_GetPWUid(struct dcerpc_binding_handle *h,
1159                                   TALLOC_CTX *mem_ctx,
1160                                   uint32_t *_count /* [in,out] [ref,range(0,1023)] */,
1161                                   uint64_t *_uids /* [in] [size_is(*count)] */,
1162                                   struct unixinfo_GetPWUidInfo *_infos /* [out] [size_is(*count)] */,
1163                                   NTSTATUS *result)
1164 {
1165         struct unixinfo_GetPWUid r;
1166         NTSTATUS status;
1167
1168         /* In parameters */
1169         r.in.count = _count;
1170         r.in.uids = _uids;
1171
1172         status = dcerpc_unixinfo_GetPWUid_r(h, mem_ctx, &r);
1173         if (!NT_STATUS_IS_OK(status)) {
1174                 return status;
1175         }
1176
1177         /* Return variables */
1178         *_count = *r.out.count;
1179         if ((*r.out.count) > (*r.in.count)) {
1180                 return NT_STATUS_INVALID_NETWORK_RESPONSE;
1181         }
1182         memcpy(_infos, r.out.infos, (*r.out.count) * sizeof(*_infos));
1183
1184         /* Return result */
1185         *result = r.out.result;
1186
1187         return NT_STATUS_OK;
1188 }
1189