bug-fixing against:
[samba.git] / source / rpc_parse / parse_lsa.c
1 /* 
2  *  Unix SMB/Netbios implementation.
3  *  Version 1.9.
4  *  RPC Pipe client / server routines
5  *  Copyright (C) Andrew Tridgell              1992-1997,
6  *  Copyright (C) Luke Kenneth Casson Leighton 1996-1997,
7  *  Copyright (C) Paul Ashton                       1997.
8  *  
9  *  This program is free software; you can redistribute it and/or modify
10  *  it under the terms of the GNU General Public License as published by
11  *  the Free Software Foundation; either version 2 of the License, or
12  *  (at your option) any later version.
13  *  
14  *  This program is distributed in the hope that it will be useful,
15  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  *  GNU General Public License for more details.
18  *  
19  *  You should have received a copy of the GNU General Public License
20  *  along with this program; if not, write to the Free Software
21  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22  */
23
24 #include "includes.h"
25 #include "nterr.h"
26
27 extern int DEBUGLEVEL;
28
29 static void lsa_io_trans_names(char *desc, LSA_TRANS_NAME_ENUM *trn, prs_struct *ps, int depth);
30
31 /*******************************************************************
32 creates a LSA_TRANS_NAME structure.
33 ********************************************************************/
34 void make_lsa_trans_name(LSA_TRANS_NAME *trn, uint32 sid_name_use, char *name, uint32 idx)
35 {
36         int len_name = strlen(name);
37
38         trn->sid_name_use = sid_name_use;
39         make_uni_hdr(&(trn->hdr_name), len_name, len_name, len_name != 0);
40         trn->domain_idx = idx;
41 }
42
43 /*******************************************************************
44 reads or writes a LSA_TRANS_NAME structure.
45 ********************************************************************/
46 static void lsa_io_trans_name(char *desc, LSA_TRANS_NAME *trn, prs_struct *ps, int depth)
47 {
48         if (trn == NULL) return;
49
50         prs_debug(ps, depth, desc, "lsa_io_trans_name");
51         depth++;
52
53         prs_align(ps);
54         
55         prs_uint32("sid_name_use", ps, depth, &(trn->sid_name_use));
56         smb_io_unihdr ("hdr_name", &(trn->hdr_name), ps, depth);
57         prs_uint32("domain_idx  ", ps, depth, &(trn->domain_idx  ));
58 }
59
60 /*******************************************************************
61 reads or writes a DOM_R_REF structure.
62 ********************************************************************/
63 static void lsa_io_dom_r_ref(char *desc,  DOM_R_REF *r_r, prs_struct *ps, int depth)
64 {
65         int i, s, n;
66
67         prs_debug(ps, depth, desc, "smb_io_dom_r_ref");
68         depth++;
69
70         if (r_r == NULL) return;
71
72         prs_align(ps);
73         
74         prs_uint32("undoc_buffer  ", ps, depth, &(r_r->undoc_buffer  )); /* undocumented buffer pointer. */
75         prs_uint32("num_ref_doms_1", ps, depth, &(r_r->num_ref_doms_1)); /* num referenced domains? */
76         prs_uint32("undoc_buffer2 ", ps, depth, &(r_r->undoc_buffer2 )); /* undocumented buffer pointer. */
77         prs_uint32("max_entries   ", ps, depth, &(r_r->max_entries   )); /* 32 - max number of entries */
78         prs_uint32("num_ref_doms_2", ps, depth, &(r_r->num_ref_doms_2)); /* 4 - num referenced domains? */
79
80         SMB_ASSERT_ARRAY(r_r->hdr_ref_dom, r_r->num_ref_doms_1-1);
81         SMB_ASSERT_ARRAY(r_r->ref_dom, r_r->num_ref_doms_2);
82
83         for (i = 0; i < r_r->num_ref_doms_1; i++)
84         {
85                 fstring t;
86
87                 slprintf(t, sizeof(t) - 1, "dom_ref[%d] ", i);
88                 smb_io_unihdr(t, &(r_r->hdr_ref_dom[i].hdr_dom_name), ps, depth);
89
90                 slprintf(t, sizeof(t) - 1, "sid_ptr[%d] ", i);
91                 prs_uint32(t, ps, depth, &(r_r->hdr_ref_dom[i].ptr_dom_sid));
92         }
93
94         for (i = 0, n = 0, s = 0; i < r_r->num_ref_doms_2; i++)
95         {
96                 fstring t;
97
98                 if (r_r->hdr_ref_dom[i].hdr_dom_name.buffer != 0)
99                 {
100                         slprintf(t, sizeof(t) - 1, "dom_ref[%d] ", i);
101                         smb_io_unistr2(t, &(r_r->ref_dom[n].uni_dom_name), True, ps, depth); /* domain name unicode string */
102                         n++;
103                 }
104
105                 if (r_r->hdr_ref_dom[i].ptr_dom_sid != 0)
106                 {
107                         slprintf(t, sizeof(t) - 1, "sid_ptr[%d] ", i);
108                         smb_io_dom_sid2("", &(r_r->ref_dom[s].ref_dom), ps, depth); /* referenced domain SIDs */
109                         s++;
110                 }
111         }
112 }
113
114
115 /*******************************************************************
116 makes an LSA_SEC_QOS structure.
117 ********************************************************************/
118 void make_lsa_sec_qos(LSA_SEC_QOS *qos, uint16 imp_lev, uint8 ctxt, uint8 eff,
119                                 uint32 unknown)
120 {
121         if (qos == NULL) return;
122
123         DEBUG(5,("make_lsa_sec_qos\n"));
124
125         qos->len = 0x0c; /* length of quality of service block, in bytes */
126         qos->sec_imp_level = imp_lev;
127         qos->sec_ctxt_mode = ctxt;
128         qos->effective_only = eff;
129         qos->unknown = unknown;
130 }
131
132 /*******************************************************************
133 reads or writes an LSA_SEC_QOS structure.
134 ********************************************************************/
135 static void lsa_io_sec_qos(char *desc,  LSA_SEC_QOS *qos, prs_struct *ps, int depth)
136 {
137         int start;
138
139         if (qos == NULL) return;
140
141         prs_debug(ps, depth, desc, "lsa_io_obj_qos");
142         depth++;
143
144         prs_align(ps);
145         
146         start = ps->offset;
147
148         /* these pointers had _better_ be zero, because we don't know
149            what they point to!
150          */
151         prs_uint32("len           ", ps, depth, &(qos->len           )); /* 0x18 - length (in bytes) inc. the length field. */
152         prs_uint16("sec_imp_level ", ps, depth, &(qos->sec_imp_level )); 
153         prs_uint8 ("sec_ctxt_mode ", ps, depth, &(qos->sec_ctxt_mode )); 
154         prs_uint8 ("effective_only", ps, depth, &(qos->effective_only)); 
155         prs_uint32("unknown       ", ps, depth, &(qos->unknown       )); 
156
157         if (qos->len != ps->offset - start)
158         {
159                 DEBUG(3,("lsa_io_sec_qos: length %x does not match size %x\n",
160                          qos->len, ps->offset - start));
161         }
162 }
163
164
165 /*******************************************************************
166 makes an LSA_OBJ_ATTR structure.
167 ********************************************************************/
168 void make_lsa_obj_attr(LSA_OBJ_ATTR *attr, uint32 attributes, LSA_SEC_QOS *qos)
169 {
170         if (attr == NULL) return;
171
172         DEBUG(5,("make_lsa_obj_attr\n"));
173
174         attr->len = 0x18; /* length of object attribute block, in bytes */
175         attr->ptr_root_dir = 0;
176         attr->ptr_obj_name = 0;
177         attr->attributes = attributes;
178         attr->ptr_sec_desc = 0;
179         
180         if (qos != NULL)
181         {
182                 attr->ptr_sec_qos = 1;
183                 attr->sec_qos = qos;
184         }
185         else
186         {
187                 attr->ptr_sec_qos = 0;
188                 attr->sec_qos = NULL;
189         }
190 }
191
192 /*******************************************************************
193 reads or writes an LSA_OBJ_ATTR structure.
194 ********************************************************************/
195 static void lsa_io_obj_attr(char *desc,  LSA_OBJ_ATTR *attr, prs_struct *ps, int depth)
196 {
197         int start;
198
199         if (attr == NULL) return;
200
201         prs_debug(ps, depth, desc, "lsa_io_obj_attr");
202         depth++;
203
204         prs_align(ps);
205         
206         start = ps->offset;
207
208         /* these pointers had _better_ be zero, because we don't know
209            what they point to!
210          */
211         prs_uint32("len         ", ps, depth, &(attr->len         )); /* 0x18 - length (in bytes) inc. the length field. */
212         prs_uint32("ptr_root_dir", ps, depth, &(attr->ptr_root_dir)); /* 0 - root directory (pointer) */
213         prs_uint32("ptr_obj_name", ps, depth, &(attr->ptr_obj_name)); /* 0 - object name (pointer) */
214         prs_uint32("attributes  ", ps, depth, &(attr->attributes  )); /* 0 - attributes (undocumented) */
215         prs_uint32("ptr_sec_desc", ps, depth, &(attr->ptr_sec_desc)); /* 0 - security descriptior (pointer) */
216         prs_uint32("ptr_sec_qos ", ps, depth, &(attr->ptr_sec_qos )); /* security quality of service (pointer) */
217
218         if (attr->len != ps->offset - start)
219         {
220                 DEBUG(3,("lsa_io_obj_attr: length %x does not match size %x\n",
221                          attr->len, ps->offset - start));
222         }
223
224         if (attr->ptr_sec_qos != 0 && attr->sec_qos != NULL)
225         {
226                 lsa_io_sec_qos("sec_qos", attr->sec_qos, ps, depth);
227         }
228 }
229
230
231 /*******************************************************************
232 makes an LSA_Q_OPEN_POL structure.
233 ********************************************************************/
234 void make_q_open_pol(LSA_Q_OPEN_POL *r_q, uint16 system_name,
235                         uint32 attributes,
236                         uint32 desired_access,
237                         LSA_SEC_QOS *qos)
238 {
239         if (r_q == NULL) return;
240
241         DEBUG(5,("make_open_pol: attr:%d da:%d\n", attributes, desired_access));
242
243         r_q->ptr = 1; /* undocumented pointer */
244
245         if (qos == NULL)
246         {
247                 r_q->des_access = desired_access;
248         }
249
250         r_q->system_name = system_name;
251         make_lsa_obj_attr(&(r_q->attr           ), attributes, qos);
252 }
253
254 /*******************************************************************
255 reads or writes an LSA_Q_OPEN_POL structure.
256 ********************************************************************/
257 void lsa_io_q_open_pol(char *desc,  LSA_Q_OPEN_POL *r_q, prs_struct *ps, int depth)
258 {
259         if (r_q == NULL) return;
260
261         prs_debug(ps, depth, desc, "lsa_io_q_open_pol");
262         depth++;
263
264         prs_uint32("ptr       ", ps, depth, &(r_q->ptr       ));
265         prs_uint16("system_name", ps, depth, &(r_q->system_name ));
266         prs_align ( ps );
267
268         lsa_io_obj_attr("", &(r_q->attr           ), ps, depth);
269
270         if (r_q->attr.ptr_sec_qos == 0)
271         {
272                 prs_uint32("des_access", ps, depth, &(r_q->des_access));
273         }
274 }
275
276 /*******************************************************************
277 reads or writes an LSA_R_OPEN_POL structure.
278 ********************************************************************/
279 void lsa_io_r_open_pol(char *desc,  LSA_R_OPEN_POL *r_p, prs_struct *ps, int depth)
280 {
281         if (r_p == NULL) return;
282
283         prs_debug(ps, depth, desc, "lsa_io_r_open_pol");
284         depth++;
285
286         smb_io_pol_hnd("", &(r_p->pol), ps, depth);
287
288         prs_uint32("status", ps, depth, &(r_p->status));
289 }
290
291 /*******************************************************************
292 makes an LSA_Q_OPEN_POL2 structure.
293 ********************************************************************/
294 void make_q_open_pol2(LSA_Q_OPEN_POL2 *r_q, char *server_name,
295                         uint32 attributes,
296                         uint32 desired_access,
297                         LSA_SEC_QOS *qos)
298 {
299         if (r_q == NULL) return;
300
301         DEBUG(5,("make_open_pol2: attr:%d da:%d\n", attributes, desired_access));
302
303         r_q->ptr = 1; /* undocumented pointer */
304
305         if (qos == NULL)
306         {
307                 r_q->des_access = desired_access;
308         }
309
310         make_unistr2     (&(r_q->uni_server_name), server_name, strlen(server_name));
311         make_lsa_obj_attr(&(r_q->attr           ), attributes, qos);
312 }
313
314 /*******************************************************************
315 reads or writes an LSA_Q_OPEN_POL2 structure.
316 ********************************************************************/
317 void lsa_io_q_open_pol2(char *desc,  LSA_Q_OPEN_POL2 *r_q, prs_struct *ps, int depth)
318 {
319         if (r_q == NULL) return;
320
321         prs_debug(ps, depth, desc, "lsa_io_q_open_pol2");
322         depth++;
323
324         prs_uint32("ptr       ", ps, depth, &(r_q->ptr       ));
325
326         smb_io_unistr2 ("", &(r_q->uni_server_name), r_q->ptr, ps, depth);
327         lsa_io_obj_attr("", &(r_q->attr           ), ps, depth);
328
329         if (r_q->attr.ptr_sec_qos == 0)
330         {
331                 prs_uint32("des_access", ps, depth, &(r_q->des_access));
332         }
333 }
334
335 /*******************************************************************
336 reads or writes an LSA_R_OPEN_POL2 structure.
337 ********************************************************************/
338 void lsa_io_r_open_pol2(char *desc,  LSA_R_OPEN_POL2 *r_p, prs_struct *ps, int depth)
339 {
340         if (r_p == NULL) return;
341
342         prs_debug(ps, depth, desc, "lsa_io_r_open_pol2");
343         depth++;
344
345         smb_io_pol_hnd("", &(r_p->pol), ps, depth);
346
347         prs_uint32("status", ps, depth, &(r_p->status));
348 }
349
350 /*******************************************************************
351 makes an LSA_Q_QUERY_INFO structure.
352 ********************************************************************/
353 void make_q_query(LSA_Q_QUERY_INFO *q_q, POLICY_HND *hnd, uint16 info_class)
354 {
355         if (q_q == NULL || hnd == NULL) return;
356
357         DEBUG(5,("make_q_query\n"));
358
359         memcpy(&(q_q->pol), hnd, sizeof(q_q->pol));
360
361         q_q->info_class = info_class;
362 }
363
364 /*******************************************************************
365 reads or writes an LSA_Q_QUERY_INFO structure.
366 ********************************************************************/
367 void lsa_io_q_query(char *desc,  LSA_Q_QUERY_INFO *q_q, prs_struct *ps, int depth)
368 {
369         if (q_q == NULL) return;
370
371         prs_debug(ps, depth, desc, "lsa_io_q_query");
372         depth++;
373
374         smb_io_pol_hnd("", &(q_q->pol), ps, depth);
375
376         prs_uint16("info_class", ps, depth, &(q_q->info_class));
377 }
378
379 /*******************************************************************
380 reads or writes an LSA_Q_ENUM_TRUST_DOM structure.
381 ********************************************************************/
382 void lsa_io_q_enum_trust_dom(char *desc,  LSA_Q_ENUM_TRUST_DOM *q_e, prs_struct *ps, int depth)
383 {
384         if (q_e == NULL) return;
385
386         prs_debug(ps, depth, desc, "lsa_io_q_enum_trust_dom");
387         depth++;
388
389
390         smb_io_pol_hnd("", &(q_e->pol), ps, depth);
391
392         prs_uint32("enum_context ", ps, depth, &(q_e->enum_context ));
393         prs_uint32("preferred_len", ps, depth, &(q_e->preferred_len));
394 }
395
396 /*******************************************************************
397 makes an LSA_R_ENUM_TRUST_DOM structure.
398 ********************************************************************/
399 void make_r_enum_trust_dom(LSA_R_ENUM_TRUST_DOM *r_e,
400                            uint32 enum_context, char *domain_name, DOM_SID *domain_sid,
401                            uint32 status)
402 {
403         if (r_e == NULL) return;
404
405         DEBUG(5,("make_r_enum_trust_dom\n"));
406
407         r_e->enum_context = enum_context;
408
409         if (status == 0)
410         {
411                 int len_domain_name = strlen(domain_name);
412
413                 r_e->num_domains  = 1;
414                 r_e->ptr_enum_domains = 1;
415                 r_e->num_domains2 = 1;
416
417                 make_uni_hdr2(&(r_e->hdr_domain_name ), len_domain_name, len_domain_name, 4);
418                 make_unistr2 (&(r_e->uni_domain_name ), domain_name, len_domain_name);
419                 make_dom_sid2(&(r_e->other_domain_sid), domain_sid);
420         }
421         else
422         {
423                 r_e->num_domains = 0;
424                 r_e->ptr_enum_domains = 0;
425         }
426
427         r_e->status = status;
428 }
429
430 /*******************************************************************
431 reads or writes an LSA_R_ENUM_TRUST_DOM structure.
432 ********************************************************************/
433 void lsa_io_r_enum_trust_dom(char *desc,  LSA_R_ENUM_TRUST_DOM *r_e, prs_struct *ps, int depth)
434 {
435         if (r_e == NULL) return;
436
437         prs_debug(ps, depth, desc, "lsa_io_r_enum_trust_dom");
438         depth++;
439
440         prs_uint32("enum_context    ", ps, depth, &(r_e->enum_context    ));
441         prs_uint32("num_domains     ", ps, depth, &(r_e->num_domains     ));
442         prs_uint32("ptr_enum_domains", ps, depth, &(r_e->ptr_enum_domains));
443
444         if (r_e->ptr_enum_domains != 0)
445         {
446                 prs_uint32("num_domains2", ps, depth, &(r_e->num_domains2));
447                 smb_io_unihdr2 ("", &(r_e->hdr_domain_name ), ps, depth);
448                 smb_io_unistr2 ("", &(r_e->uni_domain_name ), r_e->hdr_domain_name.buffer, ps, depth);
449                 smb_io_dom_sid2("", &(r_e->other_domain_sid), ps, depth);
450         }
451
452         prs_uint32("status", ps, depth, &(r_e->status));
453 }
454
455 /*******************************************************************
456 reads or writes an LSA_Q_QUERY_INFO structure.
457 ********************************************************************/
458 void lsa_io_r_query(char *desc,  LSA_R_QUERY_INFO *r_q, prs_struct *ps, int depth)
459 {
460         if (r_q == NULL) return;
461
462         prs_debug(ps, depth, desc, "lsa_io_r_query");
463         depth++;
464
465         prs_uint32("undoc_buffer", ps, depth, &(r_q->undoc_buffer));
466
467         if (r_q->undoc_buffer != 0)
468         {
469                 prs_uint16("info_class", ps, depth, &(r_q->info_class));
470
471                 switch (r_q->info_class)
472                 {
473                         case 3:
474                         {
475                                 smb_io_dom_query_3("", &(r_q->dom.id3), ps, depth);
476                                 break;
477                         }
478                         case 5:
479                         {
480                                 smb_io_dom_query_5("", &(r_q->dom.id3), ps, depth);
481                                 break;
482                         }
483                         default:
484                         {
485                                 /* PANIC! */
486                                 break;
487                         }
488                 }
489         }
490
491         prs_uint32("status", ps, depth, &(r_q->status));
492 }
493
494 /*******************************************************************
495 makes a LSA_SID_ENUM structure.
496 ********************************************************************/
497 void make_lsa_sid_enum(LSA_SID_ENUM *sen, int num_entries, DOM_SID **sids)
498 {
499         int i, i2;
500         if (sen == NULL || sids == NULL) return;
501
502         DEBUG(5,("make_lsa_sid_enum\n"));
503
504         sen->num_entries  = num_entries;
505         sen->ptr_sid_enum = num_entries != 0 ? 1 : 0;
506         sen->num_entries2 = num_entries;
507
508         SMB_ASSERT_ARRAY(sen->sid, sen->num_entries);
509
510         for (i = 0, i2 = 0; i < num_entries; i++)
511         {
512                 if (sids[i] != NULL)
513                 {
514                         sen->ptr_sid[i] = 1;
515                         make_dom_sid2(&(sen->sid[i2]), sids[i]);
516                         i2++;
517                 }
518                 else
519                 {
520                         sen->ptr_sid[i] = 0;
521                 }
522         }
523 }
524
525 /*******************************************************************
526 reads or writes a LSA_SID_ENUM structure.
527 ********************************************************************/
528 static void lsa_io_sid_enum(char *desc, LSA_SID_ENUM *sen,
529                                 prs_struct *ps, int depth)
530 {
531         int i;
532
533         if (sen == NULL) return;
534
535         prs_debug(ps, depth, desc, "lsa_io_sid_enum");
536         depth++;
537
538         prs_align(ps);
539         
540         prs_uint32("num_entries ", ps, depth, &(sen->num_entries));
541         prs_uint32("ptr_sid_enum", ps, depth, &(sen->ptr_sid_enum)); 
542         prs_uint32("num_entries2", ps, depth, &(sen->num_entries2)); 
543
544         SMB_ASSERT_ARRAY(sen->ptr_sid, sen->num_entries);
545
546         for (i = 0; i < sen->num_entries; i++)
547         {       
548                 fstring temp;
549                 slprintf(temp, sizeof(temp) - 1, "ptr_sid[%d]", i);
550                 prs_uint32(temp, ps, depth, &(sen->ptr_sid[i])); /* domain SID pointers to be looked up. */
551         }
552
553         SMB_ASSERT_ARRAY(sen->sid, sen->num_entries);
554
555         for (i = 0; i < sen->num_entries; i++)
556         {
557                 fstring temp;
558                 slprintf(temp, sizeof(temp) - 1, "sid[%d]", i);
559                 smb_io_dom_sid2(temp, &(sen->sid[i]), ps, depth); /* domain SIDs to be looked up. */
560         }
561 }
562
563 /*******************************************************************
564 makes an LSA_R_ENUM_TRUST_DOM structure.
565 ********************************************************************/
566 void make_q_lookup_sids(LSA_Q_LOOKUP_SIDS *q_l, POLICY_HND *hnd,
567                                 int num_sids, DOM_SID **sids,
568                                 uint16 level)
569 {
570         if (q_l == NULL) return;
571
572         DEBUG(5,("make_r_enum_trust_dom\n"));
573
574         memcpy(&(q_l->pol), hnd, sizeof(q_l->pol));
575         make_lsa_sid_enum(&(q_l->sids), num_sids, sids);
576
577         q_l->names.num_entries     = 0;
578         q_l->names.ptr_trans_names = 0;
579         q_l->names.num_entries2    = 0;
580
581         q_l->level.value = level;
582 }
583
584 /*******************************************************************
585 reads or writes a LSA_Q_LOOKUP_SIDS structure.
586 ********************************************************************/
587 void lsa_io_q_lookup_sids(char *desc, LSA_Q_LOOKUP_SIDS *q_s, prs_struct *ps, int depth)
588 {
589         if (q_s == NULL) return;
590
591         prs_debug(ps, depth, desc, "lsa_io_q_lookup_sids");
592         depth++;
593
594         prs_align(ps);
595         
596         smb_io_pol_hnd     ("pol_hnd", &(q_s->pol), ps, depth); /* policy handle */
597         lsa_io_sid_enum    ("sids   ", &(q_s->sids   ), ps, depth); /* sids to be looked up */
598         lsa_io_trans_names ("names  ", &(q_s->names  ), ps, depth); /* translated names */
599         smb_io_lookup_level("switch ", &(q_s->level  ), ps, depth); /* lookup level */
600
601         prs_uint32("mapped_count", ps, depth, &(q_s->mapped_count));
602 }
603
604 /*******************************************************************
605 reads or writes a structure.
606 ********************************************************************/
607 static void lsa_io_trans_names(char *desc, LSA_TRANS_NAME_ENUM *trn,
608                                 prs_struct *ps, int depth)
609 {
610         int i;
611         int i2;
612
613         if (trn == NULL) return;
614
615         prs_debug(ps, depth, desc, "lsa_io_trans_names");
616         depth++;
617
618         prs_align(ps);
619         
620         prs_uint32("num_entries    ", ps, depth, &(trn->num_entries));
621         prs_uint32("ptr_trans_names", ps, depth, &(trn->ptr_trans_names));
622
623         if (trn->ptr_trans_names != 0)
624         {
625                 prs_uint32("num_entries2   ", ps, depth, &(trn->num_entries2));
626
627                 SMB_ASSERT_ARRAY(trn->name, trn->num_entries);
628
629                 for (i = 0, i2 = 0; i < trn->num_entries2; i++)
630                 {
631                         fstring t;
632                         slprintf(t, sizeof(t) - 1, "name[%d] ", i);
633
634                         lsa_io_trans_name(t, &(trn->name[i]), ps, depth); /* translated name */
635
636                         if (trn->name[i].hdr_name.buffer != 0)
637                         {
638                                 smb_io_unistr2(t, &(trn->uni_name[i2]), 1, ps, depth);
639                                 prs_align(ps);
640                                 i2++;
641                         }
642                 }
643         }
644 }
645
646 /*******************************************************************
647 reads or writes a structure.
648 ********************************************************************/
649 void lsa_io_r_lookup_sids(char *desc,  LSA_R_LOOKUP_SIDS *r_s, prs_struct *ps, int depth)
650 {
651         if (r_s == NULL) return;
652
653         prs_debug(ps, depth, desc, "lsa_io_r_lookup_sids");
654         depth++;
655
656         prs_align(ps);
657         
658         lsa_io_dom_r_ref  ("dom_ref", r_s->dom_ref, ps, depth); /* domain reference info */
659         lsa_io_trans_names("names  ", r_s->names  , ps, depth); /* translated names */
660
661         prs_align(ps);
662
663         prs_uint32("mapped_count", ps, depth, &(r_s->mapped_count));
664
665         prs_uint32("status      ", ps, depth, &(r_s->status));
666 }
667
668 /*******************************************************************
669 reads or writes a structure.
670 ********************************************************************/
671 void lsa_io_q_lookup_rids(char *desc,  LSA_Q_LOOKUP_RIDS *q_r, prs_struct *ps, int depth)
672 {
673         int i;
674
675         if (q_r == NULL) return;
676
677         prs_debug(ps, depth, desc, "lsa_io_q_lookup_rids");
678         depth++;
679
680         prs_align(ps);
681         
682         smb_io_pol_hnd("", &(q_r->pol), ps, depth); /* policy handle */
683
684         prs_uint32("num_entries    ", ps, depth, &(q_r->num_entries));
685         prs_uint32("num_entries2   ", ps, depth, &(q_r->num_entries2));
686         prs_uint32("buffer_dom_sid ", ps, depth, &(q_r->buffer_dom_sid)); /* undocumented domain SID buffer pointer */
687         prs_uint32("buffer_dom_name", ps, depth, &(q_r->buffer_dom_name)); /* undocumented domain name buffer pointer */
688
689         SMB_ASSERT_ARRAY(q_r->lookup_name, q_r->num_entries);
690
691         for (i = 0; i < q_r->num_entries; i++)
692         {
693                 smb_io_dom_name("", &(q_r->lookup_name[i]), ps, depth); /* names to be looked up */
694         }
695
696         prs_uint8s (False, "undoc          ", ps, depth, q_r->undoc, UNKNOWN_LEN);
697 }
698
699 /*******************************************************************
700 reads or writes a structure.
701 ********************************************************************/
702 void lsa_io_r_lookup_rids(char *desc,  LSA_R_LOOKUP_RIDS *r_r, prs_struct *ps, int depth)
703 {
704         int i;
705
706         if (r_r == NULL) return;
707
708         prs_debug(ps, depth, desc, "lsa_io_r_lookup_rids");
709         depth++;
710
711         prs_align(ps);
712         
713         lsa_io_dom_r_ref("", &(r_r->dom_ref), ps, depth); /* domain reference info */
714
715         prs_uint32("num_entries ", ps, depth, &(r_r->num_entries));
716         prs_uint32("undoc_buffer", ps, depth, &(r_r->undoc_buffer));
717         prs_uint32("num_entries2", ps, depth, &(r_r->num_entries2));
718
719         SMB_ASSERT_ARRAY(r_r->dom_rid, r_r->num_entries2);
720
721         for (i = 0; i < r_r->num_entries2; i++)
722         {
723                 smb_io_dom_rid2("", &(r_r->dom_rid[i]), ps, depth); /* domain RIDs being looked up */
724         }
725
726         prs_uint32("num_entries3", ps, depth, &(r_r->num_entries3));
727
728         prs_uint32("status      ", ps, depth, &(r_r->status));
729 }
730
731
732 /*******************************************************************
733 makes an LSA_Q_CLOSE structure.
734 ********************************************************************/
735 void make_lsa_q_close(LSA_Q_CLOSE *q_c, POLICY_HND *hnd)
736 {
737         if (q_c == NULL || hnd == NULL) return;
738
739         DEBUG(5,("make_lsa_q_close\n"));
740
741         memcpy(&(q_c->pol), hnd, sizeof(q_c->pol));
742 }
743
744 /*******************************************************************
745 reads or writes an LSA_Q_CLOSE structure.
746 ********************************************************************/
747 void lsa_io_q_close(char *desc,  LSA_Q_CLOSE *q_c, prs_struct *ps, int depth)
748 {
749         if (q_c == NULL) return;
750
751         prs_debug(ps, depth, desc, "lsa_io_q_close");
752         depth++;
753
754         smb_io_pol_hnd("", &(q_c->pol), ps, depth);
755 }
756
757 /*******************************************************************
758 reads or writes an LSA_R_CLOSE structure.
759 ********************************************************************/
760 void lsa_io_r_close(char *desc,  LSA_R_CLOSE *r_c, prs_struct *ps, int depth)
761 {
762         if (r_c == NULL) return;
763
764         prs_debug(ps, depth, desc, "lsa_io_r_close");
765         depth++;
766
767         smb_io_pol_hnd("", &(r_c->pol), ps, depth);
768
769         prs_uint32("status", ps, depth, &(r_c->status));
770 }
771