Add new script for building IDL files in librpc/idl, generating both
[sfrench/samba-autobuild/.git] / librpc / gen_ndr / ndr_security.c
1 /* parser auto-generated by pidl */
2
3 #include "includes.h"
4 #include "../librpc/gen_ndr/ndr_security.h"
5
6 #include "librpc/gen_ndr/ndr_misc.h"
7 _PUBLIC_ enum ndr_err_code ndr_push_security_ace_flags(struct ndr_push *ndr, int ndr_flags, uint8_t r)
8 {
9         NDR_CHECK(ndr_push_uint8(ndr, NDR_SCALARS, r));
10         return NDR_ERR_SUCCESS;
11 }
12
13 _PUBLIC_ enum ndr_err_code ndr_pull_security_ace_flags(struct ndr_pull *ndr, int ndr_flags, uint8_t *r)
14 {
15         uint8_t v;
16         NDR_CHECK(ndr_pull_uint8(ndr, NDR_SCALARS, &v));
17         *r = v;
18         return NDR_ERR_SUCCESS;
19 }
20
21 _PUBLIC_ void ndr_print_security_ace_flags(struct ndr_print *ndr, const char *name, uint8_t r)
22 {
23         ndr_print_uint8(ndr, name, r);
24         ndr->depth++;
25         ndr_print_bitmap_flag(ndr, sizeof(uint8_t), "SEC_ACE_FLAG_OBJECT_INHERIT", SEC_ACE_FLAG_OBJECT_INHERIT, r);
26         ndr_print_bitmap_flag(ndr, sizeof(uint8_t), "SEC_ACE_FLAG_CONTAINER_INHERIT", SEC_ACE_FLAG_CONTAINER_INHERIT, r);
27         ndr_print_bitmap_flag(ndr, sizeof(uint8_t), "SEC_ACE_FLAG_NO_PROPAGATE_INHERIT", SEC_ACE_FLAG_NO_PROPAGATE_INHERIT, r);
28         ndr_print_bitmap_flag(ndr, sizeof(uint8_t), "SEC_ACE_FLAG_INHERIT_ONLY", SEC_ACE_FLAG_INHERIT_ONLY, r);
29         ndr_print_bitmap_flag(ndr, sizeof(uint8_t), "SEC_ACE_FLAG_INHERITED_ACE", SEC_ACE_FLAG_INHERITED_ACE, r);
30         ndr_print_bitmap_flag(ndr, sizeof(uint8_t), "SEC_ACE_FLAG_VALID_INHERIT", SEC_ACE_FLAG_VALID_INHERIT, r);
31         ndr_print_bitmap_flag(ndr, sizeof(uint8_t), "SEC_ACE_FLAG_SUCCESSFUL_ACCESS", SEC_ACE_FLAG_SUCCESSFUL_ACCESS, r);
32         ndr_print_bitmap_flag(ndr, sizeof(uint8_t), "SEC_ACE_FLAG_FAILED_ACCESS", SEC_ACE_FLAG_FAILED_ACCESS, r);
33         ndr->depth--;
34 }
35
36 _PUBLIC_ enum ndr_err_code ndr_push_security_ace_type(struct ndr_push *ndr, int ndr_flags, enum security_ace_type r)
37 {
38         NDR_CHECK(ndr_push_uint8(ndr, NDR_SCALARS, r));
39         return NDR_ERR_SUCCESS;
40 }
41
42 _PUBLIC_ enum ndr_err_code ndr_pull_security_ace_type(struct ndr_pull *ndr, int ndr_flags, enum security_ace_type *r)
43 {
44         uint8_t v;
45         NDR_CHECK(ndr_pull_uint8(ndr, NDR_SCALARS, &v));
46         *r = v;
47         return NDR_ERR_SUCCESS;
48 }
49
50 _PUBLIC_ void ndr_print_security_ace_type(struct ndr_print *ndr, const char *name, enum security_ace_type r)
51 {
52         const char *val = NULL;
53
54         switch (r) {
55                 case SEC_ACE_TYPE_ACCESS_ALLOWED: val = "SEC_ACE_TYPE_ACCESS_ALLOWED"; break;
56                 case SEC_ACE_TYPE_ACCESS_DENIED: val = "SEC_ACE_TYPE_ACCESS_DENIED"; break;
57                 case SEC_ACE_TYPE_SYSTEM_AUDIT: val = "SEC_ACE_TYPE_SYSTEM_AUDIT"; break;
58                 case SEC_ACE_TYPE_SYSTEM_ALARM: val = "SEC_ACE_TYPE_SYSTEM_ALARM"; break;
59                 case SEC_ACE_TYPE_ALLOWED_COMPOUND: val = "SEC_ACE_TYPE_ALLOWED_COMPOUND"; break;
60                 case SEC_ACE_TYPE_ACCESS_ALLOWED_OBJECT: val = "SEC_ACE_TYPE_ACCESS_ALLOWED_OBJECT"; break;
61                 case SEC_ACE_TYPE_ACCESS_DENIED_OBJECT: val = "SEC_ACE_TYPE_ACCESS_DENIED_OBJECT"; break;
62                 case SEC_ACE_TYPE_SYSTEM_AUDIT_OBJECT: val = "SEC_ACE_TYPE_SYSTEM_AUDIT_OBJECT"; break;
63                 case SEC_ACE_TYPE_SYSTEM_ALARM_OBJECT: val = "SEC_ACE_TYPE_SYSTEM_ALARM_OBJECT"; break;
64         }
65         ndr_print_enum(ndr, name, "ENUM", val, r);
66 }
67
68 static enum ndr_err_code ndr_push_security_ace_object_flags(struct ndr_push *ndr, int ndr_flags, uint32_t r)
69 {
70         NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r));
71         return NDR_ERR_SUCCESS;
72 }
73
74 static enum ndr_err_code ndr_pull_security_ace_object_flags(struct ndr_pull *ndr, int ndr_flags, uint32_t *r)
75 {
76         uint32_t v;
77         NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &v));
78         *r = v;
79         return NDR_ERR_SUCCESS;
80 }
81
82 _PUBLIC_ void ndr_print_security_ace_object_flags(struct ndr_print *ndr, const char *name, uint32_t r)
83 {
84         ndr_print_uint32(ndr, name, r);
85         ndr->depth++;
86         ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "SEC_ACE_OBJECT_TYPE_PRESENT", SEC_ACE_OBJECT_TYPE_PRESENT, r);
87         ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "SEC_ACE_INHERITED_OBJECT_TYPE_PRESENT", SEC_ACE_INHERITED_OBJECT_TYPE_PRESENT, r);
88         ndr->depth--;
89 }
90
91 static enum ndr_err_code ndr_push_security_ace_object_type(struct ndr_push *ndr, int ndr_flags, const union security_ace_object_type *r)
92 {
93         if (ndr_flags & NDR_SCALARS) {
94                 int level = ndr_push_get_switch_value(ndr, r);
95                 switch (level) {
96                         case SEC_ACE_OBJECT_TYPE_PRESENT: {
97                                 NDR_CHECK(ndr_push_GUID(ndr, NDR_SCALARS, &r->type));
98                         break; }
99
100                         default: {
101                         break; }
102
103                 }
104         }
105         if (ndr_flags & NDR_BUFFERS) {
106                 int level = ndr_push_get_switch_value(ndr, r);
107                 switch (level) {
108                         case SEC_ACE_OBJECT_TYPE_PRESENT:
109                         break;
110
111                         default:
112                         break;
113
114                 }
115         }
116         return NDR_ERR_SUCCESS;
117 }
118
119 static enum ndr_err_code ndr_pull_security_ace_object_type(struct ndr_pull *ndr, int ndr_flags, union security_ace_object_type *r)
120 {
121         int level;
122         level = ndr_pull_get_switch_value(ndr, r);
123         if (ndr_flags & NDR_SCALARS) {
124                 switch (level) {
125                         case SEC_ACE_OBJECT_TYPE_PRESENT: {
126                                 NDR_CHECK(ndr_pull_GUID(ndr, NDR_SCALARS, &r->type));
127                         break; }
128
129                         default: {
130                         break; }
131
132                 }
133         }
134         if (ndr_flags & NDR_BUFFERS) {
135                 switch (level) {
136                         case SEC_ACE_OBJECT_TYPE_PRESENT:
137                         break;
138
139                         default:
140                         break;
141
142                 }
143         }
144         return NDR_ERR_SUCCESS;
145 }
146
147 _PUBLIC_ void ndr_print_security_ace_object_type(struct ndr_print *ndr, const char *name, const union security_ace_object_type *r)
148 {
149         int level;
150         level = ndr_print_get_switch_value(ndr, r);
151         ndr_print_union(ndr, name, level, "security_ace_object_type");
152         switch (level) {
153                 case SEC_ACE_OBJECT_TYPE_PRESENT:
154                         ndr_print_GUID(ndr, "type", &r->type);
155                 break;
156
157                 default:
158                 break;
159
160         }
161 }
162
163 static enum ndr_err_code ndr_push_security_ace_object_inherited_type(struct ndr_push *ndr, int ndr_flags, const union security_ace_object_inherited_type *r)
164 {
165         if (ndr_flags & NDR_SCALARS) {
166                 int level = ndr_push_get_switch_value(ndr, r);
167                 switch (level) {
168                         case SEC_ACE_INHERITED_OBJECT_TYPE_PRESENT: {
169                                 NDR_CHECK(ndr_push_GUID(ndr, NDR_SCALARS, &r->inherited_type));
170                         break; }
171
172                         default: {
173                         break; }
174
175                 }
176         }
177         if (ndr_flags & NDR_BUFFERS) {
178                 int level = ndr_push_get_switch_value(ndr, r);
179                 switch (level) {
180                         case SEC_ACE_INHERITED_OBJECT_TYPE_PRESENT:
181                         break;
182
183                         default:
184                         break;
185
186                 }
187         }
188         return NDR_ERR_SUCCESS;
189 }
190
191 static enum ndr_err_code ndr_pull_security_ace_object_inherited_type(struct ndr_pull *ndr, int ndr_flags, union security_ace_object_inherited_type *r)
192 {
193         int level;
194         level = ndr_pull_get_switch_value(ndr, r);
195         if (ndr_flags & NDR_SCALARS) {
196                 switch (level) {
197                         case SEC_ACE_INHERITED_OBJECT_TYPE_PRESENT: {
198                                 NDR_CHECK(ndr_pull_GUID(ndr, NDR_SCALARS, &r->inherited_type));
199                         break; }
200
201                         default: {
202                         break; }
203
204                 }
205         }
206         if (ndr_flags & NDR_BUFFERS) {
207                 switch (level) {
208                         case SEC_ACE_INHERITED_OBJECT_TYPE_PRESENT:
209                         break;
210
211                         default:
212                         break;
213
214                 }
215         }
216         return NDR_ERR_SUCCESS;
217 }
218
219 _PUBLIC_ void ndr_print_security_ace_object_inherited_type(struct ndr_print *ndr, const char *name, const union security_ace_object_inherited_type *r)
220 {
221         int level;
222         level = ndr_print_get_switch_value(ndr, r);
223         ndr_print_union(ndr, name, level, "security_ace_object_inherited_type");
224         switch (level) {
225                 case SEC_ACE_INHERITED_OBJECT_TYPE_PRESENT:
226                         ndr_print_GUID(ndr, "inherited_type", &r->inherited_type);
227                 break;
228
229                 default:
230                 break;
231
232         }
233 }
234
235 static enum ndr_err_code ndr_push_security_ace_object(struct ndr_push *ndr, int ndr_flags, const struct security_ace_object *r)
236 {
237         if (ndr_flags & NDR_SCALARS) {
238                 NDR_CHECK(ndr_push_align(ndr, 4));
239                 NDR_CHECK(ndr_push_security_ace_object_flags(ndr, NDR_SCALARS, r->flags));
240                 NDR_CHECK(ndr_push_set_switch_value(ndr, &r->type, r->flags & SEC_ACE_OBJECT_TYPE_PRESENT));
241                 NDR_CHECK(ndr_push_security_ace_object_type(ndr, NDR_SCALARS, &r->type));
242                 NDR_CHECK(ndr_push_set_switch_value(ndr, &r->inherited_type, r->flags & SEC_ACE_INHERITED_OBJECT_TYPE_PRESENT));
243                 NDR_CHECK(ndr_push_security_ace_object_inherited_type(ndr, NDR_SCALARS, &r->inherited_type));
244         }
245         if (ndr_flags & NDR_BUFFERS) {
246                 NDR_CHECK(ndr_push_security_ace_object_type(ndr, NDR_BUFFERS, &r->type));
247                 NDR_CHECK(ndr_push_security_ace_object_inherited_type(ndr, NDR_BUFFERS, &r->inherited_type));
248         }
249         return NDR_ERR_SUCCESS;
250 }
251
252 static enum ndr_err_code ndr_pull_security_ace_object(struct ndr_pull *ndr, int ndr_flags, struct security_ace_object *r)
253 {
254         if (ndr_flags & NDR_SCALARS) {
255                 NDR_CHECK(ndr_pull_align(ndr, 4));
256                 NDR_CHECK(ndr_pull_security_ace_object_flags(ndr, NDR_SCALARS, &r->flags));
257                 NDR_CHECK(ndr_pull_set_switch_value(ndr, &r->type, r->flags & SEC_ACE_OBJECT_TYPE_PRESENT));
258                 NDR_CHECK(ndr_pull_security_ace_object_type(ndr, NDR_SCALARS, &r->type));
259                 NDR_CHECK(ndr_pull_set_switch_value(ndr, &r->inherited_type, r->flags & SEC_ACE_INHERITED_OBJECT_TYPE_PRESENT));
260                 NDR_CHECK(ndr_pull_security_ace_object_inherited_type(ndr, NDR_SCALARS, &r->inherited_type));
261         }
262         if (ndr_flags & NDR_BUFFERS) {
263                 NDR_CHECK(ndr_pull_security_ace_object_type(ndr, NDR_BUFFERS, &r->type));
264                 NDR_CHECK(ndr_pull_security_ace_object_inherited_type(ndr, NDR_BUFFERS, &r->inherited_type));
265         }
266         return NDR_ERR_SUCCESS;
267 }
268
269 _PUBLIC_ void ndr_print_security_ace_object(struct ndr_print *ndr, const char *name, const struct security_ace_object *r)
270 {
271         ndr_print_struct(ndr, name, "security_ace_object");
272         ndr->depth++;
273         ndr_print_security_ace_object_flags(ndr, "flags", r->flags);
274         ndr_print_set_switch_value(ndr, &r->type, r->flags & SEC_ACE_OBJECT_TYPE_PRESENT);
275         ndr_print_security_ace_object_type(ndr, "type", &r->type);
276         ndr_print_set_switch_value(ndr, &r->inherited_type, r->flags & SEC_ACE_INHERITED_OBJECT_TYPE_PRESENT);
277         ndr_print_security_ace_object_inherited_type(ndr, "inherited_type", &r->inherited_type);
278         ndr->depth--;
279 }
280
281 _PUBLIC_ enum ndr_err_code ndr_push_security_ace_object_ctr(struct ndr_push *ndr, int ndr_flags, const union security_ace_object_ctr *r)
282 {
283         if (ndr_flags & NDR_SCALARS) {
284                 int level = ndr_push_get_switch_value(ndr, r);
285                 switch (level) {
286                         case SEC_ACE_TYPE_ACCESS_ALLOWED_OBJECT: {
287                                 NDR_CHECK(ndr_push_security_ace_object(ndr, NDR_SCALARS, &r->object));
288                         break; }
289
290                         case SEC_ACE_TYPE_ACCESS_DENIED_OBJECT: {
291                                 NDR_CHECK(ndr_push_security_ace_object(ndr, NDR_SCALARS, &r->object));
292                         break; }
293
294                         case SEC_ACE_TYPE_SYSTEM_AUDIT_OBJECT: {
295                                 NDR_CHECK(ndr_push_security_ace_object(ndr, NDR_SCALARS, &r->object));
296                         break; }
297
298                         case SEC_ACE_TYPE_SYSTEM_ALARM_OBJECT: {
299                                 NDR_CHECK(ndr_push_security_ace_object(ndr, NDR_SCALARS, &r->object));
300                         break; }
301
302                         default: {
303                         break; }
304
305                 }
306         }
307         if (ndr_flags & NDR_BUFFERS) {
308                 int level = ndr_push_get_switch_value(ndr, r);
309                 switch (level) {
310                         case SEC_ACE_TYPE_ACCESS_ALLOWED_OBJECT:
311                                 NDR_CHECK(ndr_push_security_ace_object(ndr, NDR_BUFFERS, &r->object));
312                         break;
313
314                         case SEC_ACE_TYPE_ACCESS_DENIED_OBJECT:
315                                 NDR_CHECK(ndr_push_security_ace_object(ndr, NDR_BUFFERS, &r->object));
316                         break;
317
318                         case SEC_ACE_TYPE_SYSTEM_AUDIT_OBJECT:
319                                 NDR_CHECK(ndr_push_security_ace_object(ndr, NDR_BUFFERS, &r->object));
320                         break;
321
322                         case SEC_ACE_TYPE_SYSTEM_ALARM_OBJECT:
323                                 NDR_CHECK(ndr_push_security_ace_object(ndr, NDR_BUFFERS, &r->object));
324                         break;
325
326                         default:
327                         break;
328
329                 }
330         }
331         return NDR_ERR_SUCCESS;
332 }
333
334 _PUBLIC_ enum ndr_err_code ndr_pull_security_ace_object_ctr(struct ndr_pull *ndr, int ndr_flags, union security_ace_object_ctr *r)
335 {
336         int level;
337         level = ndr_pull_get_switch_value(ndr, r);
338         if (ndr_flags & NDR_SCALARS) {
339                 switch (level) {
340                         case SEC_ACE_TYPE_ACCESS_ALLOWED_OBJECT: {
341                                 NDR_CHECK(ndr_pull_security_ace_object(ndr, NDR_SCALARS, &r->object));
342                         break; }
343
344                         case SEC_ACE_TYPE_ACCESS_DENIED_OBJECT: {
345                                 NDR_CHECK(ndr_pull_security_ace_object(ndr, NDR_SCALARS, &r->object));
346                         break; }
347
348                         case SEC_ACE_TYPE_SYSTEM_AUDIT_OBJECT: {
349                                 NDR_CHECK(ndr_pull_security_ace_object(ndr, NDR_SCALARS, &r->object));
350                         break; }
351
352                         case SEC_ACE_TYPE_SYSTEM_ALARM_OBJECT: {
353                                 NDR_CHECK(ndr_pull_security_ace_object(ndr, NDR_SCALARS, &r->object));
354                         break; }
355
356                         default: {
357                         break; }
358
359                 }
360         }
361         if (ndr_flags & NDR_BUFFERS) {
362                 switch (level) {
363                         case SEC_ACE_TYPE_ACCESS_ALLOWED_OBJECT:
364                                 NDR_CHECK(ndr_pull_security_ace_object(ndr, NDR_BUFFERS, &r->object));
365                         break;
366
367                         case SEC_ACE_TYPE_ACCESS_DENIED_OBJECT:
368                                 NDR_CHECK(ndr_pull_security_ace_object(ndr, NDR_BUFFERS, &r->object));
369                         break;
370
371                         case SEC_ACE_TYPE_SYSTEM_AUDIT_OBJECT:
372                                 NDR_CHECK(ndr_pull_security_ace_object(ndr, NDR_BUFFERS, &r->object));
373                         break;
374
375                         case SEC_ACE_TYPE_SYSTEM_ALARM_OBJECT:
376                                 NDR_CHECK(ndr_pull_security_ace_object(ndr, NDR_BUFFERS, &r->object));
377                         break;
378
379                         default:
380                         break;
381
382                 }
383         }
384         return NDR_ERR_SUCCESS;
385 }
386
387 _PUBLIC_ void ndr_print_security_ace_object_ctr(struct ndr_print *ndr, const char *name, const union security_ace_object_ctr *r)
388 {
389         int level;
390         level = ndr_print_get_switch_value(ndr, r);
391         ndr_print_union(ndr, name, level, "security_ace_object_ctr");
392         switch (level) {
393                 case SEC_ACE_TYPE_ACCESS_ALLOWED_OBJECT:
394                         ndr_print_security_ace_object(ndr, "object", &r->object);
395                 break;
396
397                 case SEC_ACE_TYPE_ACCESS_DENIED_OBJECT:
398                         ndr_print_security_ace_object(ndr, "object", &r->object);
399                 break;
400
401                 case SEC_ACE_TYPE_SYSTEM_AUDIT_OBJECT:
402                         ndr_print_security_ace_object(ndr, "object", &r->object);
403                 break;
404
405                 case SEC_ACE_TYPE_SYSTEM_ALARM_OBJECT:
406                         ndr_print_security_ace_object(ndr, "object", &r->object);
407                 break;
408
409                 default:
410                 break;
411
412         }
413 }
414
415 _PUBLIC_ enum ndr_err_code ndr_push_security_ace(struct ndr_push *ndr, int ndr_flags, const struct security_ace *r)
416 {
417         if (ndr_flags & NDR_SCALARS) {
418                 NDR_CHECK(ndr_push_align(ndr, 4));
419                 NDR_CHECK(ndr_push_security_ace_type(ndr, NDR_SCALARS, r->type));
420                 NDR_CHECK(ndr_push_security_ace_flags(ndr, NDR_SCALARS, r->flags));
421                 NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, ndr_size_security_ace(r, ndr->flags)));
422                 NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->access_mask));
423                 NDR_CHECK(ndr_push_set_switch_value(ndr, &r->object, r->type));
424                 NDR_CHECK(ndr_push_security_ace_object_ctr(ndr, NDR_SCALARS, &r->object));
425                 NDR_CHECK(ndr_push_dom_sid(ndr, NDR_SCALARS, &r->trustee));
426         }
427         if (ndr_flags & NDR_BUFFERS) {
428                 NDR_CHECK(ndr_push_security_ace_object_ctr(ndr, NDR_BUFFERS, &r->object));
429         }
430         return NDR_ERR_SUCCESS;
431 }
432
433 _PUBLIC_ void ndr_print_security_ace(struct ndr_print *ndr, const char *name, const struct security_ace *r)
434 {
435         ndr_print_struct(ndr, name, "security_ace");
436         ndr->depth++;
437         ndr_print_security_ace_type(ndr, "type", r->type);
438         ndr_print_security_ace_flags(ndr, "flags", r->flags);
439         ndr_print_uint16(ndr, "size", (ndr->flags & LIBNDR_PRINT_SET_VALUES)?ndr_size_security_ace(r, ndr->flags):r->size);
440         ndr_print_uint32(ndr, "access_mask", r->access_mask);
441         ndr_print_set_switch_value(ndr, &r->object, r->type);
442         ndr_print_security_ace_object_ctr(ndr, "object", &r->object);
443         ndr_print_dom_sid(ndr, "trustee", &r->trustee);
444         ndr->depth--;
445 }
446
447 static enum ndr_err_code ndr_push_security_acl_revision(struct ndr_push *ndr, int ndr_flags, enum security_acl_revision r)
448 {
449         NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r));
450         return NDR_ERR_SUCCESS;
451 }
452
453 static enum ndr_err_code ndr_pull_security_acl_revision(struct ndr_pull *ndr, int ndr_flags, enum security_acl_revision *r)
454 {
455         uint16_t v;
456         NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &v));
457         *r = v;
458         return NDR_ERR_SUCCESS;
459 }
460
461 _PUBLIC_ void ndr_print_security_acl_revision(struct ndr_print *ndr, const char *name, enum security_acl_revision r)
462 {
463         const char *val = NULL;
464
465         switch (r) {
466                 case SECURITY_ACL_REVISION_NT4: val = "SECURITY_ACL_REVISION_NT4"; break;
467                 case SECURITY_ACL_REVISION_ADS: val = "SECURITY_ACL_REVISION_ADS"; break;
468         }
469         ndr_print_enum(ndr, name, "ENUM", val, r);
470 }
471
472 _PUBLIC_ enum ndr_err_code ndr_push_security_acl(struct ndr_push *ndr, int ndr_flags, const struct security_acl *r)
473 {
474         uint32_t cntr_aces_0;
475         if (ndr_flags & NDR_SCALARS) {
476                 NDR_CHECK(ndr_push_align(ndr, 4));
477                 NDR_CHECK(ndr_push_security_acl_revision(ndr, NDR_SCALARS, r->revision));
478                 NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, ndr_size_security_acl(r, ndr->flags)));
479                 NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->num_aces));
480                 for (cntr_aces_0 = 0; cntr_aces_0 < r->num_aces; cntr_aces_0++) {
481                         NDR_CHECK(ndr_push_security_ace(ndr, NDR_SCALARS, &r->aces[cntr_aces_0]));
482                 }
483         }
484         if (ndr_flags & NDR_BUFFERS) {
485                 for (cntr_aces_0 = 0; cntr_aces_0 < r->num_aces; cntr_aces_0++) {
486                         NDR_CHECK(ndr_push_security_ace(ndr, NDR_BUFFERS, &r->aces[cntr_aces_0]));
487                 }
488         }
489         return NDR_ERR_SUCCESS;
490 }
491
492 _PUBLIC_ enum ndr_err_code ndr_pull_security_acl(struct ndr_pull *ndr, int ndr_flags, struct security_acl *r)
493 {
494         uint32_t cntr_aces_0;
495         TALLOC_CTX *_mem_save_aces_0;
496         if (ndr_flags & NDR_SCALARS) {
497                 NDR_CHECK(ndr_pull_align(ndr, 4));
498                 NDR_CHECK(ndr_pull_security_acl_revision(ndr, NDR_SCALARS, &r->revision));
499                 NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->size));
500                 NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->num_aces));
501                 if (r->num_aces < 0 || r->num_aces > 1000) {
502                         return ndr_pull_error(ndr, NDR_ERR_RANGE, "value out of range");
503                 }
504                 NDR_PULL_ALLOC_N(ndr, r->aces, r->num_aces);
505                 _mem_save_aces_0 = NDR_PULL_GET_MEM_CTX(ndr);
506                 NDR_PULL_SET_MEM_CTX(ndr, r->aces, 0);
507                 for (cntr_aces_0 = 0; cntr_aces_0 < r->num_aces; cntr_aces_0++) {
508                         NDR_CHECK(ndr_pull_security_ace(ndr, NDR_SCALARS, &r->aces[cntr_aces_0]));
509                 }
510                 NDR_PULL_SET_MEM_CTX(ndr, _mem_save_aces_0, 0);
511         }
512         if (ndr_flags & NDR_BUFFERS) {
513                 _mem_save_aces_0 = NDR_PULL_GET_MEM_CTX(ndr);
514                 NDR_PULL_SET_MEM_CTX(ndr, r->aces, 0);
515                 for (cntr_aces_0 = 0; cntr_aces_0 < r->num_aces; cntr_aces_0++) {
516                         NDR_CHECK(ndr_pull_security_ace(ndr, NDR_BUFFERS, &r->aces[cntr_aces_0]));
517                 }
518                 NDR_PULL_SET_MEM_CTX(ndr, _mem_save_aces_0, 0);
519         }
520         return NDR_ERR_SUCCESS;
521 }
522
523 _PUBLIC_ void ndr_print_security_acl(struct ndr_print *ndr, const char *name, const struct security_acl *r)
524 {
525         uint32_t cntr_aces_0;
526         ndr_print_struct(ndr, name, "security_acl");
527         ndr->depth++;
528         ndr_print_security_acl_revision(ndr, "revision", r->revision);
529         ndr_print_uint16(ndr, "size", (ndr->flags & LIBNDR_PRINT_SET_VALUES)?ndr_size_security_acl(r, ndr->flags):r->size);
530         ndr_print_uint32(ndr, "num_aces", r->num_aces);
531         ndr->print(ndr, "%s: ARRAY(%d)", "aces", (int)r->num_aces);
532         ndr->depth++;
533         for (cntr_aces_0=0;cntr_aces_0<r->num_aces;cntr_aces_0++) {
534                 char *idx_0=NULL;
535                 if (asprintf(&idx_0, "[%d]", cntr_aces_0) != -1) {
536                         ndr_print_security_ace(ndr, "aces", &r->aces[cntr_aces_0]);
537                         free(idx_0);
538                 }
539         }
540         ndr->depth--;
541         ndr->depth--;
542 }
543
544 static enum ndr_err_code ndr_push_security_descriptor_revision(struct ndr_push *ndr, int ndr_flags, enum security_descriptor_revision r)
545 {
546         NDR_CHECK(ndr_push_uint8(ndr, NDR_SCALARS, r));
547         return NDR_ERR_SUCCESS;
548 }
549
550 static enum ndr_err_code ndr_pull_security_descriptor_revision(struct ndr_pull *ndr, int ndr_flags, enum security_descriptor_revision *r)
551 {
552         uint8_t v;
553         NDR_CHECK(ndr_pull_uint8(ndr, NDR_SCALARS, &v));
554         *r = v;
555         return NDR_ERR_SUCCESS;
556 }
557
558 _PUBLIC_ void ndr_print_security_descriptor_revision(struct ndr_print *ndr, const char *name, enum security_descriptor_revision r)
559 {
560         const char *val = NULL;
561
562         switch (r) {
563                 case SECURITY_DESCRIPTOR_REVISION_1: val = "SECURITY_DESCRIPTOR_REVISION_1"; break;
564         }
565         ndr_print_enum(ndr, name, "ENUM", val, r);
566 }
567
568 static enum ndr_err_code ndr_push_security_descriptor_type(struct ndr_push *ndr, int ndr_flags, uint16_t r)
569 {
570         NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r));
571         return NDR_ERR_SUCCESS;
572 }
573
574 static enum ndr_err_code ndr_pull_security_descriptor_type(struct ndr_pull *ndr, int ndr_flags, uint16_t *r)
575 {
576         uint16_t v;
577         NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &v));
578         *r = v;
579         return NDR_ERR_SUCCESS;
580 }
581
582 _PUBLIC_ void ndr_print_security_descriptor_type(struct ndr_print *ndr, const char *name, uint16_t r)
583 {
584         ndr_print_uint16(ndr, name, r);
585         ndr->depth++;
586         ndr_print_bitmap_flag(ndr, sizeof(uint16_t), "SEC_DESC_OWNER_DEFAULTED", SEC_DESC_OWNER_DEFAULTED, r);
587         ndr_print_bitmap_flag(ndr, sizeof(uint16_t), "SEC_DESC_GROUP_DEFAULTED", SEC_DESC_GROUP_DEFAULTED, r);
588         ndr_print_bitmap_flag(ndr, sizeof(uint16_t), "SEC_DESC_DACL_PRESENT", SEC_DESC_DACL_PRESENT, r);
589         ndr_print_bitmap_flag(ndr, sizeof(uint16_t), "SEC_DESC_DACL_DEFAULTED", SEC_DESC_DACL_DEFAULTED, r);
590         ndr_print_bitmap_flag(ndr, sizeof(uint16_t), "SEC_DESC_SACL_PRESENT", SEC_DESC_SACL_PRESENT, r);
591         ndr_print_bitmap_flag(ndr, sizeof(uint16_t), "SEC_DESC_SACL_DEFAULTED", SEC_DESC_SACL_DEFAULTED, r);
592         ndr_print_bitmap_flag(ndr, sizeof(uint16_t), "SEC_DESC_DACL_TRUSTED", SEC_DESC_DACL_TRUSTED, r);
593         ndr_print_bitmap_flag(ndr, sizeof(uint16_t), "SEC_DESC_SERVER_SECURITY", SEC_DESC_SERVER_SECURITY, r);
594         ndr_print_bitmap_flag(ndr, sizeof(uint16_t), "SEC_DESC_DACL_AUTO_INHERIT_REQ", SEC_DESC_DACL_AUTO_INHERIT_REQ, r);
595         ndr_print_bitmap_flag(ndr, sizeof(uint16_t), "SEC_DESC_SACL_AUTO_INHERIT_REQ", SEC_DESC_SACL_AUTO_INHERIT_REQ, r);
596         ndr_print_bitmap_flag(ndr, sizeof(uint16_t), "SEC_DESC_DACL_AUTO_INHERITED", SEC_DESC_DACL_AUTO_INHERITED, r);
597         ndr_print_bitmap_flag(ndr, sizeof(uint16_t), "SEC_DESC_SACL_AUTO_INHERITED", SEC_DESC_SACL_AUTO_INHERITED, r);
598         ndr_print_bitmap_flag(ndr, sizeof(uint16_t), "SEC_DESC_DACL_PROTECTED", SEC_DESC_DACL_PROTECTED, r);
599         ndr_print_bitmap_flag(ndr, sizeof(uint16_t), "SEC_DESC_SACL_PROTECTED", SEC_DESC_SACL_PROTECTED, r);
600         ndr_print_bitmap_flag(ndr, sizeof(uint16_t), "SEC_DESC_RM_CONTROL_VALID", SEC_DESC_RM_CONTROL_VALID, r);
601         ndr_print_bitmap_flag(ndr, sizeof(uint16_t), "SEC_DESC_SELF_RELATIVE", SEC_DESC_SELF_RELATIVE, r);
602         ndr->depth--;
603 }
604
605 _PUBLIC_ enum ndr_err_code ndr_push_security_descriptor(struct ndr_push *ndr, int ndr_flags, const struct security_descriptor *r)
606 {
607         {
608                 uint32_t _flags_save_STRUCT = ndr->flags;
609                 ndr_set_flags(&ndr->flags, LIBNDR_FLAG_LITTLE_ENDIAN);
610                 if (ndr_flags & NDR_SCALARS) {
611                         NDR_CHECK(ndr_push_align(ndr, 4));
612                         NDR_CHECK(ndr_push_security_descriptor_revision(ndr, NDR_SCALARS, r->revision));
613                         NDR_CHECK(ndr_push_security_descriptor_type(ndr, NDR_SCALARS, r->type));
614                         NDR_CHECK(ndr_push_relative_ptr1(ndr, r->owner_sid));
615                         NDR_CHECK(ndr_push_relative_ptr1(ndr, r->group_sid));
616                         NDR_CHECK(ndr_push_relative_ptr1(ndr, r->sacl));
617                         NDR_CHECK(ndr_push_relative_ptr1(ndr, r->dacl));
618                 }
619                 if (ndr_flags & NDR_BUFFERS) {
620                         if (r->owner_sid) {
621                                 NDR_CHECK(ndr_push_relative_ptr2(ndr, r->owner_sid));
622                                 NDR_CHECK(ndr_push_dom_sid(ndr, NDR_SCALARS, r->owner_sid));
623                         }
624                         if (r->group_sid) {
625                                 NDR_CHECK(ndr_push_relative_ptr2(ndr, r->group_sid));
626                                 NDR_CHECK(ndr_push_dom_sid(ndr, NDR_SCALARS, r->group_sid));
627                         }
628                         if (r->sacl) {
629                                 NDR_CHECK(ndr_push_relative_ptr2(ndr, r->sacl));
630                                 NDR_CHECK(ndr_push_security_acl(ndr, NDR_SCALARS|NDR_BUFFERS, r->sacl));
631                         }
632                         if (r->dacl) {
633                                 NDR_CHECK(ndr_push_relative_ptr2(ndr, r->dacl));
634                                 NDR_CHECK(ndr_push_security_acl(ndr, NDR_SCALARS|NDR_BUFFERS, r->dacl));
635                         }
636                 }
637                 ndr->flags = _flags_save_STRUCT;
638         }
639         return NDR_ERR_SUCCESS;
640 }
641
642 _PUBLIC_ enum ndr_err_code ndr_pull_security_descriptor(struct ndr_pull *ndr, int ndr_flags, struct security_descriptor *r)
643 {
644         uint32_t _ptr_owner_sid;
645         TALLOC_CTX *_mem_save_owner_sid_0;
646         uint32_t _ptr_group_sid;
647         TALLOC_CTX *_mem_save_group_sid_0;
648         uint32_t _ptr_sacl;
649         TALLOC_CTX *_mem_save_sacl_0;
650         uint32_t _ptr_dacl;
651         TALLOC_CTX *_mem_save_dacl_0;
652         {
653                 uint32_t _flags_save_STRUCT = ndr->flags;
654                 ndr_set_flags(&ndr->flags, LIBNDR_FLAG_LITTLE_ENDIAN);
655                 if (ndr_flags & NDR_SCALARS) {
656                         NDR_CHECK(ndr_pull_align(ndr, 4));
657                         NDR_CHECK(ndr_pull_security_descriptor_revision(ndr, NDR_SCALARS, &r->revision));
658                         NDR_CHECK(ndr_pull_security_descriptor_type(ndr, NDR_SCALARS, &r->type));
659                         NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_owner_sid));
660                         if (_ptr_owner_sid) {
661                                 NDR_PULL_ALLOC(ndr, r->owner_sid);
662                                 NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->owner_sid, _ptr_owner_sid));
663                         } else {
664                                 r->owner_sid = NULL;
665                         }
666                         NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_group_sid));
667                         if (_ptr_group_sid) {
668                                 NDR_PULL_ALLOC(ndr, r->group_sid);
669                                 NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->group_sid, _ptr_group_sid));
670                         } else {
671                                 r->group_sid = NULL;
672                         }
673                         NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_sacl));
674                         if (_ptr_sacl) {
675                                 NDR_PULL_ALLOC(ndr, r->sacl);
676                                 NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->sacl, _ptr_sacl));
677                         } else {
678                                 r->sacl = NULL;
679                         }
680                         NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_dacl));
681                         if (_ptr_dacl) {
682                                 NDR_PULL_ALLOC(ndr, r->dacl);
683                                 NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->dacl, _ptr_dacl));
684                         } else {
685                                 r->dacl = NULL;
686                         }
687                 }
688                 if (ndr_flags & NDR_BUFFERS) {
689                         if (r->owner_sid) {
690                                 uint32_t _relative_save_offset;
691                                 _relative_save_offset = ndr->offset;
692                                 NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->owner_sid));
693                                 _mem_save_owner_sid_0 = NDR_PULL_GET_MEM_CTX(ndr);
694                                 NDR_PULL_SET_MEM_CTX(ndr, r->owner_sid, 0);
695                                 NDR_CHECK(ndr_pull_dom_sid(ndr, NDR_SCALARS, r->owner_sid));
696                                 NDR_PULL_SET_MEM_CTX(ndr, _mem_save_owner_sid_0, 0);
697                                 ndr->offset = _relative_save_offset;
698                         }
699                         if (r->group_sid) {
700                                 uint32_t _relative_save_offset;
701                                 _relative_save_offset = ndr->offset;
702                                 NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->group_sid));
703                                 _mem_save_group_sid_0 = NDR_PULL_GET_MEM_CTX(ndr);
704                                 NDR_PULL_SET_MEM_CTX(ndr, r->group_sid, 0);
705                                 NDR_CHECK(ndr_pull_dom_sid(ndr, NDR_SCALARS, r->group_sid));
706                                 NDR_PULL_SET_MEM_CTX(ndr, _mem_save_group_sid_0, 0);
707                                 ndr->offset = _relative_save_offset;
708                         }
709                         if (r->sacl) {
710                                 uint32_t _relative_save_offset;
711                                 _relative_save_offset = ndr->offset;
712                                 NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->sacl));
713                                 _mem_save_sacl_0 = NDR_PULL_GET_MEM_CTX(ndr);
714                                 NDR_PULL_SET_MEM_CTX(ndr, r->sacl, 0);
715                                 NDR_CHECK(ndr_pull_security_acl(ndr, NDR_SCALARS|NDR_BUFFERS, r->sacl));
716                                 NDR_PULL_SET_MEM_CTX(ndr, _mem_save_sacl_0, 0);
717                                 ndr->offset = _relative_save_offset;
718                         }
719                         if (r->dacl) {
720                                 uint32_t _relative_save_offset;
721                                 _relative_save_offset = ndr->offset;
722                                 NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->dacl));
723                                 _mem_save_dacl_0 = NDR_PULL_GET_MEM_CTX(ndr);
724                                 NDR_PULL_SET_MEM_CTX(ndr, r->dacl, 0);
725                                 NDR_CHECK(ndr_pull_security_acl(ndr, NDR_SCALARS|NDR_BUFFERS, r->dacl));
726                                 NDR_PULL_SET_MEM_CTX(ndr, _mem_save_dacl_0, 0);
727                                 ndr->offset = _relative_save_offset;
728                         }
729                 }
730                 ndr->flags = _flags_save_STRUCT;
731         }
732         return NDR_ERR_SUCCESS;
733 }
734
735 _PUBLIC_ void ndr_print_security_descriptor(struct ndr_print *ndr, const char *name, const struct security_descriptor *r)
736 {
737         ndr_print_struct(ndr, name, "security_descriptor");
738         {
739                 uint32_t _flags_save_STRUCT = ndr->flags;
740                 ndr_set_flags(&ndr->flags, LIBNDR_FLAG_LITTLE_ENDIAN);
741                 ndr->depth++;
742                 ndr_print_security_descriptor_revision(ndr, "revision", r->revision);
743                 ndr_print_security_descriptor_type(ndr, "type", r->type);
744                 ndr_print_ptr(ndr, "owner_sid", r->owner_sid);
745                 ndr->depth++;
746                 if (r->owner_sid) {
747                         ndr_print_dom_sid(ndr, "owner_sid", r->owner_sid);
748                 }
749                 ndr->depth--;
750                 ndr_print_ptr(ndr, "group_sid", r->group_sid);
751                 ndr->depth++;
752                 if (r->group_sid) {
753                         ndr_print_dom_sid(ndr, "group_sid", r->group_sid);
754                 }
755                 ndr->depth--;
756                 ndr_print_ptr(ndr, "sacl", r->sacl);
757                 ndr->depth++;
758                 if (r->sacl) {
759                         ndr_print_security_acl(ndr, "sacl", r->sacl);
760                 }
761                 ndr->depth--;
762                 ndr_print_ptr(ndr, "dacl", r->dacl);
763                 ndr->depth++;
764                 if (r->dacl) {
765                         ndr_print_security_acl(ndr, "dacl", r->dacl);
766                 }
767                 ndr->depth--;
768                 ndr->depth--;
769                 ndr->flags = _flags_save_STRUCT;
770         }
771 }
772
773 _PUBLIC_ enum ndr_err_code ndr_push_sec_desc_buf(struct ndr_push *ndr, int ndr_flags, const struct sec_desc_buf *r)
774 {
775         if (ndr_flags & NDR_SCALARS) {
776                 NDR_CHECK(ndr_push_align(ndr, 4));
777                 NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_size_security_descriptor(r->sd, ndr->flags)));
778                 NDR_CHECK(ndr_push_unique_ptr(ndr, r->sd));
779         }
780         if (ndr_flags & NDR_BUFFERS) {
781                 if (r->sd) {
782                         {
783                                 struct ndr_push *_ndr_sd;
784                                 NDR_CHECK(ndr_push_subcontext_start(ndr, &_ndr_sd, 4, -1));
785                                 NDR_CHECK(ndr_push_security_descriptor(_ndr_sd, NDR_SCALARS|NDR_BUFFERS, r->sd));
786                                 NDR_CHECK(ndr_push_subcontext_end(ndr, _ndr_sd, 4, -1));
787                         }
788                 }
789         }
790         return NDR_ERR_SUCCESS;
791 }
792
793 _PUBLIC_ enum ndr_err_code ndr_pull_sec_desc_buf(struct ndr_pull *ndr, int ndr_flags, struct sec_desc_buf *r)
794 {
795         uint32_t _ptr_sd;
796         TALLOC_CTX *_mem_save_sd_0;
797         if (ndr_flags & NDR_SCALARS) {
798                 NDR_CHECK(ndr_pull_align(ndr, 4));
799                 NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->sd_size));
800                 if (r->sd_size < 0 || r->sd_size > 0x40000) {
801                         return ndr_pull_error(ndr, NDR_ERR_RANGE, "value out of range");
802                 }
803                 NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_sd));
804                 if (_ptr_sd) {
805                         NDR_PULL_ALLOC(ndr, r->sd);
806                 } else {
807                         r->sd = NULL;
808                 }
809         }
810         if (ndr_flags & NDR_BUFFERS) {
811                 if (r->sd) {
812                         _mem_save_sd_0 = NDR_PULL_GET_MEM_CTX(ndr);
813                         NDR_PULL_SET_MEM_CTX(ndr, r->sd, 0);
814                         {
815                                 struct ndr_pull *_ndr_sd;
816                                 NDR_CHECK(ndr_pull_subcontext_start(ndr, &_ndr_sd, 4, -1));
817                                 NDR_CHECK(ndr_pull_security_descriptor(_ndr_sd, NDR_SCALARS|NDR_BUFFERS, r->sd));
818                                 NDR_CHECK(ndr_pull_subcontext_end(ndr, _ndr_sd, 4, -1));
819                         }
820                         NDR_PULL_SET_MEM_CTX(ndr, _mem_save_sd_0, 0);
821                 }
822         }
823         return NDR_ERR_SUCCESS;
824 }
825
826 _PUBLIC_ void ndr_print_sec_desc_buf(struct ndr_print *ndr, const char *name, const struct sec_desc_buf *r)
827 {
828         ndr_print_struct(ndr, name, "sec_desc_buf");
829         ndr->depth++;
830         ndr_print_uint32(ndr, "sd_size", (ndr->flags & LIBNDR_PRINT_SET_VALUES)?ndr_size_security_descriptor(r->sd, ndr->flags):r->sd_size);
831         ndr_print_ptr(ndr, "sd", r->sd);
832         ndr->depth++;
833         if (r->sd) {
834                 ndr_print_security_descriptor(ndr, "sd", r->sd);
835         }
836         ndr->depth--;
837         ndr->depth--;
838 }
839
840 _PUBLIC_ enum ndr_err_code ndr_push_security_token(struct ndr_push *ndr, int ndr_flags, const struct security_token *r)
841 {
842         uint32_t cntr_sids_0;
843         if (ndr_flags & NDR_SCALARS) {
844                 NDR_CHECK(ndr_push_align(ndr, 4));
845                 NDR_CHECK(ndr_push_unique_ptr(ndr, r->user_sid));
846                 NDR_CHECK(ndr_push_unique_ptr(ndr, r->group_sid));
847                 NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->num_sids));
848                 NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->num_sids));
849                 for (cntr_sids_0 = 0; cntr_sids_0 < r->num_sids; cntr_sids_0++) {
850                         NDR_CHECK(ndr_push_unique_ptr(ndr, r->sids[cntr_sids_0]));
851                 }
852                 NDR_CHECK(ndr_push_udlong(ndr, NDR_SCALARS, r->privilege_mask));
853         }
854         if (ndr_flags & NDR_BUFFERS) {
855                 if (r->user_sid) {
856                         NDR_CHECK(ndr_push_dom_sid(ndr, NDR_SCALARS, r->user_sid));
857                 }
858                 if (r->group_sid) {
859                         NDR_CHECK(ndr_push_dom_sid(ndr, NDR_SCALARS, r->group_sid));
860                 }
861                 for (cntr_sids_0 = 0; cntr_sids_0 < r->num_sids; cntr_sids_0++) {
862                         if (r->sids[cntr_sids_0]) {
863                                 NDR_CHECK(ndr_push_dom_sid(ndr, NDR_SCALARS, r->sids[cntr_sids_0]));
864                         }
865                 }
866         }
867         return NDR_ERR_SUCCESS;
868 }
869
870 _PUBLIC_ enum ndr_err_code ndr_pull_security_token(struct ndr_pull *ndr, int ndr_flags, struct security_token *r)
871 {
872         uint32_t _ptr_user_sid;
873         TALLOC_CTX *_mem_save_user_sid_0;
874         uint32_t _ptr_group_sid;
875         TALLOC_CTX *_mem_save_group_sid_0;
876         uint32_t _ptr_sids;
877         uint32_t cntr_sids_0;
878         TALLOC_CTX *_mem_save_sids_0;
879         TALLOC_CTX *_mem_save_sids_1;
880         if (ndr_flags & NDR_SCALARS) {
881                 NDR_CHECK(ndr_pull_align(ndr, 4));
882                 NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_user_sid));
883                 if (_ptr_user_sid) {
884                         NDR_PULL_ALLOC(ndr, r->user_sid);
885                 } else {
886                         r->user_sid = NULL;
887                 }
888                 NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_group_sid));
889                 if (_ptr_group_sid) {
890                         NDR_PULL_ALLOC(ndr, r->group_sid);
891                 } else {
892                         r->group_sid = NULL;
893                 }
894                 NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->num_sids));
895                 NDR_CHECK(ndr_pull_array_size(ndr, &r->sids));
896                 NDR_PULL_ALLOC_N(ndr, r->sids, ndr_get_array_size(ndr, &r->sids));
897                 _mem_save_sids_0 = NDR_PULL_GET_MEM_CTX(ndr);
898                 NDR_PULL_SET_MEM_CTX(ndr, r->sids, 0);
899                 for (cntr_sids_0 = 0; cntr_sids_0 < r->num_sids; cntr_sids_0++) {
900                         NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_sids));
901                         if (_ptr_sids) {
902                                 NDR_PULL_ALLOC(ndr, r->sids[cntr_sids_0]);
903                         } else {
904                                 r->sids[cntr_sids_0] = NULL;
905                         }
906                 }
907                 NDR_PULL_SET_MEM_CTX(ndr, _mem_save_sids_0, 0);
908                 NDR_CHECK(ndr_pull_udlong(ndr, NDR_SCALARS, &r->privilege_mask));
909                 if (r->sids) {
910                         NDR_CHECK(ndr_check_array_size(ndr, (void*)&r->sids, r->num_sids));
911                 }
912         }
913         if (ndr_flags & NDR_BUFFERS) {
914                 if (r->user_sid) {
915                         _mem_save_user_sid_0 = NDR_PULL_GET_MEM_CTX(ndr);
916                         NDR_PULL_SET_MEM_CTX(ndr, r->user_sid, 0);
917                         NDR_CHECK(ndr_pull_dom_sid(ndr, NDR_SCALARS, r->user_sid));
918                         NDR_PULL_SET_MEM_CTX(ndr, _mem_save_user_sid_0, 0);
919                 }
920                 if (r->group_sid) {
921                         _mem_save_group_sid_0 = NDR_PULL_GET_MEM_CTX(ndr);
922                         NDR_PULL_SET_MEM_CTX(ndr, r->group_sid, 0);
923                         NDR_CHECK(ndr_pull_dom_sid(ndr, NDR_SCALARS, r->group_sid));
924                         NDR_PULL_SET_MEM_CTX(ndr, _mem_save_group_sid_0, 0);
925                 }
926                 _mem_save_sids_0 = NDR_PULL_GET_MEM_CTX(ndr);
927                 NDR_PULL_SET_MEM_CTX(ndr, r->sids, 0);
928                 for (cntr_sids_0 = 0; cntr_sids_0 < r->num_sids; cntr_sids_0++) {
929                         if (r->sids[cntr_sids_0]) {
930                                 _mem_save_sids_1 = NDR_PULL_GET_MEM_CTX(ndr);
931                                 NDR_PULL_SET_MEM_CTX(ndr, r->sids[cntr_sids_0], 0);
932                                 NDR_CHECK(ndr_pull_dom_sid(ndr, NDR_SCALARS, r->sids[cntr_sids_0]));
933                                 NDR_PULL_SET_MEM_CTX(ndr, _mem_save_sids_1, 0);
934                         }
935                 }
936                 NDR_PULL_SET_MEM_CTX(ndr, _mem_save_sids_0, 0);
937         }
938         return NDR_ERR_SUCCESS;
939 }
940
941 _PUBLIC_ void ndr_print_security_token(struct ndr_print *ndr, const char *name, const struct security_token *r)
942 {
943         uint32_t cntr_sids_0;
944         ndr_print_struct(ndr, name, "security_token");
945         ndr->depth++;
946         ndr_print_ptr(ndr, "user_sid", r->user_sid);
947         ndr->depth++;
948         if (r->user_sid) {
949                 ndr_print_dom_sid(ndr, "user_sid", r->user_sid);
950         }
951         ndr->depth--;
952         ndr_print_ptr(ndr, "group_sid", r->group_sid);
953         ndr->depth++;
954         if (r->group_sid) {
955                 ndr_print_dom_sid(ndr, "group_sid", r->group_sid);
956         }
957         ndr->depth--;
958         ndr_print_uint32(ndr, "num_sids", r->num_sids);
959         ndr->print(ndr, "%s: ARRAY(%d)", "sids", (int)r->num_sids);
960         ndr->depth++;
961         for (cntr_sids_0=0;cntr_sids_0<r->num_sids;cntr_sids_0++) {
962                 char *idx_0=NULL;
963                 if (asprintf(&idx_0, "[%d]", cntr_sids_0) != -1) {
964                         ndr_print_ptr(ndr, "sids", r->sids[cntr_sids_0]);
965                         ndr->depth++;
966                         if (r->sids[cntr_sids_0]) {
967                                 ndr_print_dom_sid(ndr, "sids", r->sids[cntr_sids_0]);
968                         }
969                         ndr->depth--;
970                         free(idx_0);
971                 }
972         }
973         ndr->depth--;
974         ndr_print_udlong(ndr, "privilege_mask", r->privilege_mask);
975         ndr->depth--;
976 }
977
978 _PUBLIC_ enum ndr_err_code ndr_push_security_secinfo(struct ndr_push *ndr, int ndr_flags, uint32_t r)
979 {
980         NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r));
981         return NDR_ERR_SUCCESS;
982 }
983
984 _PUBLIC_ enum ndr_err_code ndr_pull_security_secinfo(struct ndr_pull *ndr, int ndr_flags, uint32_t *r)
985 {
986         uint32_t v;
987         NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &v));
988         *r = v;
989         return NDR_ERR_SUCCESS;
990 }
991
992 _PUBLIC_ void ndr_print_security_secinfo(struct ndr_print *ndr, const char *name, uint32_t r)
993 {
994         ndr_print_uint32(ndr, name, r);
995         ndr->depth++;
996         ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "SECINFO_OWNER", SECINFO_OWNER, r);
997         ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "SECINFO_GROUP", SECINFO_GROUP, r);
998         ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "SECINFO_DACL", SECINFO_DACL, r);
999         ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "SECINFO_SACL", SECINFO_SACL, r);
1000         ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "SECINFO_UNPROTECTED_SACL", SECINFO_UNPROTECTED_SACL, r);
1001         ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "SECINFO_UNPROTECTED_DACL", SECINFO_UNPROTECTED_DACL, r);
1002         ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "SECINFO_PROTECTED_SACL", SECINFO_PROTECTED_SACL, r);
1003         ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "SECINFO_PROTECTED_DACL", SECINFO_PROTECTED_DACL, r);
1004         ndr->depth--;
1005 }
1006
1007 _PUBLIC_ enum ndr_err_code ndr_push_kerb_EncTypes(struct ndr_push *ndr, int ndr_flags, uint32_t r)
1008 {
1009         NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r));
1010         return NDR_ERR_SUCCESS;
1011 }
1012
1013 _PUBLIC_ enum ndr_err_code ndr_pull_kerb_EncTypes(struct ndr_pull *ndr, int ndr_flags, uint32_t *r)
1014 {
1015         uint32_t v;
1016         NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &v));
1017         *r = v;
1018         return NDR_ERR_SUCCESS;
1019 }
1020
1021 _PUBLIC_ void ndr_print_kerb_EncTypes(struct ndr_print *ndr, const char *name, uint32_t r)
1022 {
1023         ndr_print_uint32(ndr, name, r);
1024         ndr->depth++;
1025         ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "KERB_ENCTYPE_DES_CBC_CRC", KERB_ENCTYPE_DES_CBC_CRC, r);
1026         ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "KERB_ENCTYPE_DES_CBC_MD5", KERB_ENCTYPE_DES_CBC_MD5, r);
1027         ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "KERB_ENCTYPE_RC4_HMAC_MD5", KERB_ENCTYPE_RC4_HMAC_MD5, r);
1028         ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "KERB_ENCTYPE_AES128_CTS_HMAC_SHA1_96", KERB_ENCTYPE_AES128_CTS_HMAC_SHA1_96, r);
1029         ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "KERB_ENCTYPE_AES256_CTS_HMAC_SHA1_96", KERB_ENCTYPE_AES256_CTS_HMAC_SHA1_96, r);
1030         ndr->depth--;
1031 }
1032