2 * Unix SMB/CIFS implementation.
3 * RPC Pipe client / server routines
4 * Copyright (C) Andrew Tridgell 1992-1997,
5 * Copyright (C) Luke Kenneth Casson Leighton 1996-1997,
6 * Copyright (C) Paul Ashton 1997,
7 * Copyright (C) Andrew Bartlett 2002,
8 * Copyright (C) Jim McDonough <jmcd@us.ibm.com> 2002.
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
28 #define DBGC_CLASS DBGC_RPC_PARSE
30 static BOOL lsa_io_trans_names(const char *desc, LSA_TRANS_NAME_ENUM *trn, prs_struct *ps, int depth);
32 /*******************************************************************
33 Inits a LSA_TRANS_NAME structure.
34 ********************************************************************/
36 void init_lsa_trans_name(LSA_TRANS_NAME *trn, UNISTR2 *uni_name,
37 uint16 sid_name_use, const char *name, uint32 idx)
39 trn->sid_name_use = sid_name_use;
40 init_unistr2(uni_name, name, UNI_FLAGS_NONE);
41 init_uni_hdr(&trn->hdr_name, uni_name);
42 trn->domain_idx = idx;
45 /*******************************************************************
46 Reads or writes a LSA_TRANS_NAME structure.
47 ********************************************************************/
49 static BOOL lsa_io_trans_name(const char *desc, LSA_TRANS_NAME *trn, prs_struct *ps,
52 prs_debug(ps, depth, desc, "lsa_io_trans_name");
58 if(!prs_uint16("sid_name_use", ps, depth, &trn->sid_name_use))
63 if(!smb_io_unihdr ("hdr_name", &trn->hdr_name, ps, depth))
65 if(!prs_uint32("domain_idx ", ps, depth, &trn->domain_idx))
71 /*******************************************************************
72 Reads or writes a DOM_R_REF structure.
73 ********************************************************************/
75 static BOOL lsa_io_dom_r_ref(const char *desc, DOM_R_REF *r_r, prs_struct *ps,
80 prs_debug(ps, depth, desc, "lsa_io_dom_r_ref");
86 if(!prs_uint32("num_ref_doms_1", ps, depth, &r_r->num_ref_doms_1)) /* num referenced domains? */
88 if(!prs_uint32("ptr_ref_dom ", ps, depth, &r_r->ptr_ref_dom)) /* undocumented buffer pointer. */
90 if(!prs_uint32("max_entries ", ps, depth, &r_r->max_entries)) /* 32 - max number of entries */
93 SMB_ASSERT_ARRAY(r_r->hdr_ref_dom, r_r->num_ref_doms_1);
95 if (r_r->ptr_ref_dom != 0) {
97 if(!prs_uint32("num_ref_doms_2", ps, depth, &r_r->num_ref_doms_2)) /* 4 - num referenced domains? */
100 SMB_ASSERT_ARRAY(r_r->ref_dom, r_r->num_ref_doms_2);
102 for (i = 0; i < r_r->num_ref_doms_1; i++) {
105 slprintf(t, sizeof(t) - 1, "dom_ref[%d] ", i);
106 if(!smb_io_unihdr(t, &r_r->hdr_ref_dom[i].hdr_dom_name, ps, depth))
109 slprintf(t, sizeof(t) - 1, "sid_ptr[%d] ", i);
110 if(!prs_uint32(t, ps, depth, &r_r->hdr_ref_dom[i].ptr_dom_sid))
114 for (i = 0; i < r_r->num_ref_doms_2; i++) {
117 if (r_r->hdr_ref_dom[i].hdr_dom_name.buffer != 0) {
118 slprintf(t, sizeof(t) - 1, "dom_ref[%d] ", i);
119 if(!smb_io_unistr2(t, &r_r->ref_dom[i].uni_dom_name, True, ps, depth)) /* domain name unicode string */
125 if (r_r->hdr_ref_dom[i].ptr_dom_sid != 0) {
126 slprintf(t, sizeof(t) - 1, "sid_ptr[%d] ", i);
127 if(!smb_io_dom_sid2(t, &r_r->ref_dom[i].ref_dom, ps, depth)) /* referenced domain SIDs */
136 /*******************************************************************
137 Inits an LSA_SEC_QOS structure.
138 ********************************************************************/
140 void init_lsa_sec_qos(LSA_SEC_QOS *qos, uint16 imp_lev, uint8 ctxt, uint8 eff)
142 DEBUG(5, ("init_lsa_sec_qos\n"));
144 qos->len = 0x0c; /* length of quality of service block, in bytes */
145 qos->sec_imp_level = imp_lev;
146 qos->sec_ctxt_mode = ctxt;
147 qos->effective_only = eff;
150 /*******************************************************************
151 Reads or writes an LSA_SEC_QOS structure.
152 ********************************************************************/
154 static BOOL lsa_io_sec_qos(const char *desc, LSA_SEC_QOS *qos, prs_struct *ps,
159 prs_debug(ps, depth, desc, "lsa_io_obj_qos");
165 start = prs_offset(ps);
167 /* these pointers had _better_ be zero, because we don't know
170 if(!prs_uint32("len ", ps, depth, &qos->len)) /* 0x18 - length (in bytes) inc. the length field. */
172 if(!prs_uint16("sec_imp_level ", ps, depth, &qos->sec_imp_level ))
174 if(!prs_uint8 ("sec_ctxt_mode ", ps, depth, &qos->sec_ctxt_mode ))
176 if(!prs_uint8 ("effective_only", ps, depth, &qos->effective_only))
179 if (qos->len != prs_offset(ps) - start) {
180 DEBUG(3,("lsa_io_sec_qos: length %x does not match size %x\n",
181 qos->len, prs_offset(ps) - start));
187 /*******************************************************************
188 Inits an LSA_OBJ_ATTR structure.
189 ********************************************************************/
191 static void init_lsa_obj_attr(LSA_OBJ_ATTR *attr, uint32 attributes, LSA_SEC_QOS *qos)
193 DEBUG(5, ("init_lsa_obj_attr\n"));
195 attr->len = 0x18; /* length of object attribute block, in bytes */
196 attr->ptr_root_dir = 0;
197 attr->ptr_obj_name = 0;
198 attr->attributes = attributes;
199 attr->ptr_sec_desc = 0;
202 attr->ptr_sec_qos = 1;
205 attr->ptr_sec_qos = 0;
206 attr->sec_qos = NULL;
210 /*******************************************************************
211 Reads or writes an LSA_OBJ_ATTR structure.
212 ********************************************************************/
214 static BOOL lsa_io_obj_attr(const char *desc, LSA_OBJ_ATTR *attr, prs_struct *ps,
219 prs_debug(ps, depth, desc, "lsa_io_obj_attr");
225 start = prs_offset(ps);
227 /* these pointers had _better_ be zero, because we don't know
230 if(!prs_uint32("len ", ps, depth, &attr->len)) /* 0x18 - length (in bytes) inc. the length field. */
232 if(!prs_uint32("ptr_root_dir", ps, depth, &attr->ptr_root_dir)) /* 0 - root directory (pointer) */
234 if(!prs_uint32("ptr_obj_name", ps, depth, &attr->ptr_obj_name)) /* 0 - object name (pointer) */
236 if(!prs_uint32("attributes ", ps, depth, &attr->attributes)) /* 0 - attributes (undocumented) */
238 if(!prs_uint32("ptr_sec_desc", ps, depth, &attr->ptr_sec_desc)) /* 0 - security descriptior (pointer) */
240 if(!prs_uint32("ptr_sec_qos ", ps, depth, &attr->ptr_sec_qos )) /* security quality of service (pointer) */
243 /* code commented out as it's not necessary true (tested with hyena). JFM, 11/22/2001 */
245 if (attr->len != prs_offset(ps) - start) {
246 DEBUG(3,("lsa_io_obj_attr: length %x does not match size %x\n",
247 attr->len, prs_offset(ps) - start));
252 if (attr->ptr_sec_qos != 0) {
253 if (UNMARSHALLING(ps))
254 if (!(attr->sec_qos = (LSA_SEC_QOS *)prs_alloc_mem(ps,sizeof(LSA_SEC_QOS))))
257 if(!lsa_io_sec_qos("sec_qos", attr->sec_qos, ps, depth))
265 /*******************************************************************
266 Inits an LSA_Q_OPEN_POL structure.
267 ********************************************************************/
269 void init_q_open_pol(LSA_Q_OPEN_POL *r_q, uint16 system_name,
270 uint32 attributes, uint32 desired_access,
273 DEBUG(5, ("init_open_pol: attr:%d da:%d\n", attributes,
276 r_q->ptr = 1; /* undocumented pointer */
278 r_q->des_access = desired_access;
280 r_q->system_name = system_name;
281 init_lsa_obj_attr(&r_q->attr, attributes, qos);
284 /*******************************************************************
285 Reads or writes an LSA_Q_OPEN_POL structure.
286 ********************************************************************/
288 BOOL lsa_io_q_open_pol(const char *desc, LSA_Q_OPEN_POL *r_q, prs_struct *ps,
291 prs_debug(ps, depth, desc, "lsa_io_q_open_pol");
294 if(!prs_uint32("ptr ", ps, depth, &r_q->ptr))
296 if(!prs_uint16("system_name", ps, depth, &r_q->system_name))
301 if(!lsa_io_obj_attr("", &r_q->attr, ps, depth))
304 if(!prs_uint32("des_access", ps, depth, &r_q->des_access))
310 /*******************************************************************
311 Reads or writes an LSA_R_OPEN_POL structure.
312 ********************************************************************/
314 BOOL lsa_io_r_open_pol(const char *desc, LSA_R_OPEN_POL *r_p, prs_struct *ps,
317 prs_debug(ps, depth, desc, "lsa_io_r_open_pol");
320 if(!smb_io_pol_hnd("", &r_p->pol, ps, depth))
323 if(!prs_ntstatus("status", ps, depth, &r_p->status))
329 /*******************************************************************
330 Inits an LSA_Q_OPEN_POL2 structure.
331 ********************************************************************/
333 void init_q_open_pol2(LSA_Q_OPEN_POL2 *r_q, const char *server_name,
334 uint32 attributes, uint32 desired_access,
337 DEBUG(5, ("init_q_open_pol2: attr:%d da:%d\n", attributes,
340 r_q->ptr = 1; /* undocumented pointer */
342 r_q->des_access = desired_access;
344 init_unistr2(&r_q->uni_server_name, server_name, UNI_STR_TERMINATE);
346 init_lsa_obj_attr(&r_q->attr, attributes, qos);
349 /*******************************************************************
350 Reads or writes an LSA_Q_OPEN_POL2 structure.
351 ********************************************************************/
353 BOOL lsa_io_q_open_pol2(const char *desc, LSA_Q_OPEN_POL2 *r_q, prs_struct *ps,
356 prs_debug(ps, depth, desc, "lsa_io_q_open_pol2");
359 if(!prs_uint32("ptr ", ps, depth, &r_q->ptr))
362 if(!smb_io_unistr2 ("", &r_q->uni_server_name, r_q->ptr, ps, depth))
364 if(!lsa_io_obj_attr("", &r_q->attr, ps, depth))
367 if(!prs_uint32("des_access", ps, depth, &r_q->des_access))
373 /*******************************************************************
374 Reads or writes an LSA_R_OPEN_POL2 structure.
375 ********************************************************************/
377 BOOL lsa_io_r_open_pol2(const char *desc, LSA_R_OPEN_POL2 *r_p, prs_struct *ps,
380 prs_debug(ps, depth, desc, "lsa_io_r_open_pol2");
383 if(!smb_io_pol_hnd("", &r_p->pol, ps, depth))
386 if(!prs_ntstatus("status", ps, depth, &r_p->status))
392 /*******************************************************************
393 makes an LSA_Q_QUERY_SEC_OBJ structure.
394 ********************************************************************/
396 void init_q_query_sec_obj(LSA_Q_QUERY_SEC_OBJ *q_q, const POLICY_HND *hnd,
399 DEBUG(5, ("init_q_query_sec_obj\n"));
402 q_q->sec_info = sec_info;
407 /*******************************************************************
408 Reads or writes an LSA_Q_QUERY_SEC_OBJ structure.
409 ********************************************************************/
411 BOOL lsa_io_q_query_sec_obj(const char *desc, LSA_Q_QUERY_SEC_OBJ *q_q,
412 prs_struct *ps, int depth)
414 prs_debug(ps, depth, desc, "lsa_io_q_query_sec_obj");
417 if (!smb_io_pol_hnd("", &q_q->pol, ps, depth))
420 if (!prs_uint32("sec_info", ps, depth, &q_q->sec_info))
426 /*******************************************************************
427 Reads or writes a LSA_R_QUERY_SEC_OBJ structure.
428 ********************************************************************/
430 BOOL lsa_io_r_query_sec_obj(const char *desc, LSA_R_QUERY_SEC_OBJ *r_u,
431 prs_struct *ps, int depth)
433 prs_debug(ps, depth, desc, "lsa_io_r_query_sec_obj");
439 if (!prs_uint32("ptr", ps, depth, &r_u->ptr))
443 if (!sec_io_desc_buf("sec", &r_u->buf, ps, depth))
447 if (!prs_ntstatus("status", ps, depth, &r_u->status))
453 /*******************************************************************
454 Inits an LSA_Q_QUERY_INFO structure.
455 ********************************************************************/
457 void init_q_query(LSA_Q_QUERY_INFO *q_q, POLICY_HND *hnd, uint16 info_class)
459 DEBUG(5, ("init_q_query\n"));
461 memcpy(&q_q->pol, hnd, sizeof(q_q->pol));
463 q_q->info_class = info_class;
466 /*******************************************************************
467 Reads or writes an LSA_Q_QUERY_INFO structure.
468 ********************************************************************/
470 BOOL lsa_io_q_query(const char *desc, LSA_Q_QUERY_INFO *q_q, prs_struct *ps,
473 prs_debug(ps, depth, desc, "lsa_io_q_query");
476 if(!smb_io_pol_hnd("", &q_q->pol, ps, depth))
479 if(!prs_uint16("info_class", ps, depth, &q_q->info_class))
485 /*******************************************************************
486 makes an LSA_Q_ENUM_TRUST_DOM structure.
487 ********************************************************************/
488 BOOL init_q_enum_trust_dom(LSA_Q_ENUM_TRUST_DOM * q_e, POLICY_HND *pol,
489 uint32 enum_context, uint32 preferred_len)
491 DEBUG(5, ("init_q_enum_trust_dom\n"));
494 q_e->enum_context = enum_context;
495 q_e->preferred_len = preferred_len;
500 /*******************************************************************
501 Reads or writes an LSA_Q_ENUM_TRUST_DOM structure.
502 ********************************************************************/
504 BOOL lsa_io_q_enum_trust_dom(const char *desc, LSA_Q_ENUM_TRUST_DOM *q_e,
505 prs_struct *ps, int depth)
507 prs_debug(ps, depth, desc, "lsa_io_q_enum_trust_dom");
510 if(!smb_io_pol_hnd("", &q_e->pol, ps, depth))
513 if(!prs_uint32("enum_context ", ps, depth, &q_e->enum_context))
515 if(!prs_uint32("preferred_len", ps, depth, &q_e->preferred_len))
521 /*******************************************************************
522 Inits an LSA_R_ENUM_TRUST_DOM structure.
523 ********************************************************************/
525 void init_r_enum_trust_dom(TALLOC_CTX *ctx, LSA_R_ENUM_TRUST_DOM *r_e, uint32 enum_context,
526 uint32 req_num_domains, uint32 num_domains, TRUSTDOM **td)
530 DEBUG(5, ("init_r_enum_trust_dom\n"));
532 r_e->enum_context = enum_context;
533 r_e->num_domains = num_domains;
534 r_e->ptr_enum_domains = 0;
535 r_e->num_domains2 = num_domains;
537 if (num_domains != 0) {
540 * allocating empty arrays of unicode headers, strings
541 * and sids of enumerated trusted domains
543 if (!(r_e->hdr_domain_name = (UNIHDR2 *)talloc(ctx,sizeof(UNIHDR2) * num_domains))) {
544 r_e->status = NT_STATUS_NO_MEMORY;
548 if (!(r_e->uni_domain_name = (UNISTR2 *)talloc(ctx,sizeof(UNISTR2) * num_domains))) {
549 r_e->status = NT_STATUS_NO_MEMORY;
553 if (!(r_e->domain_sid = (DOM_SID2 *)talloc(ctx,sizeof(DOM_SID2) * num_domains))) {
554 r_e->status = NT_STATUS_NO_MEMORY;
558 for (i = 0; i < num_domains; i++) {
560 /* don't know what actually is this for */
561 r_e->ptr_enum_domains = 1;
563 init_dom_sid2(&r_e->domain_sid[i], &(td[i])->sid);
565 init_unistr2_w(ctx, &r_e->uni_domain_name[i], (td[i])->name);
566 init_uni_hdr2(&r_e->hdr_domain_name[i], &r_e->uni_domain_name[i]);
573 /*******************************************************************
574 Reads or writes an LSA_R_ENUM_TRUST_DOM structure.
575 ********************************************************************/
577 BOOL lsa_io_r_enum_trust_dom(const char *desc, LSA_R_ENUM_TRUST_DOM *r_e,
578 prs_struct *ps, int depth)
580 prs_debug(ps, depth, desc, "lsa_io_r_enum_trust_dom");
583 if(!prs_uint32("enum_context ", ps, depth, &r_e->enum_context))
585 if(!prs_uint32("num_domains ", ps, depth, &r_e->num_domains))
587 if(!prs_uint32("ptr_enum_domains", ps, depth, &r_e->ptr_enum_domains))
590 if (r_e->ptr_enum_domains) {
593 if(!prs_uint32("num_domains2", ps, depth, &r_e->num_domains2))
596 num_domains = r_e->num_domains2;
598 if (UNMARSHALLING(ps)) {
599 if (!(r_e->hdr_domain_name = (UNIHDR2 *)prs_alloc_mem(ps,sizeof(UNIHDR2) * num_domains)))
602 if (!(r_e->uni_domain_name = (UNISTR2 *)prs_alloc_mem(ps,sizeof(UNISTR2) * num_domains)))
605 if (!(r_e->domain_sid = (DOM_SID2 *)prs_alloc_mem(ps,sizeof(DOM_SID2) * num_domains)))
609 for (i = 0; i < num_domains; i++) {
610 if(!smb_io_unihdr2 ("", &r_e->hdr_domain_name[i], ps,
615 for (i = 0; i < num_domains; i++) {
616 if(!smb_io_unistr2 ("", &r_e->uni_domain_name[i],
617 r_e->hdr_domain_name[i].buffer,
620 if(!smb_io_dom_sid2("", &r_e->domain_sid[i], ps,
626 if(!prs_ntstatus("status", ps, depth, &r_e->status))
632 /*******************************************************************
633 reads or writes a dom query structure.
634 ********************************************************************/
636 static BOOL lsa_io_dom_query(const char *desc, DOM_QUERY *d_q, prs_struct *ps, int depth)
641 prs_debug(ps, depth, desc, "lsa_io_dom_query");
647 if(!prs_uint16("uni_dom_max_len", ps, depth, &d_q->uni_dom_max_len)) /* domain name string length * 2 */
649 if(!prs_uint16("uni_dom_str_len", ps, depth, &d_q->uni_dom_str_len)) /* domain name string length * 2 */
652 if(!prs_uint32("buffer_dom_name", ps, depth, &d_q->buffer_dom_name)) /* undocumented domain name string buffer pointer */
654 if(!prs_uint32("buffer_dom_sid ", ps, depth, &d_q->buffer_dom_sid)) /* undocumented domain SID string buffer pointer */
657 if(!smb_io_unistr2("unistr2", &d_q->uni_domain_name, d_q->buffer_dom_name, ps, depth)) /* domain name (unicode string) */
663 if (d_q->buffer_dom_sid != 0) {
664 if(!smb_io_dom_sid2("", &d_q->dom_sid, ps, depth)) /* domain SID */
667 memset((char *)&d_q->dom_sid, '\0', sizeof(d_q->dom_sid));
673 /*******************************************************************
674 reads or writes a structure.
675 ********************************************************************/
677 static BOOL lsa_io_dom_query_2(const char *desc, DOM_QUERY_2 *d_q, prs_struct *ps, int depth)
684 prs_debug(ps, depth, desc, "lsa_io_dom_query_2");
690 if (!prs_uint32("auditing_enabled", ps, depth, &d_q->auditing_enabled))
692 if (!prs_uint32("ptr ", ps, depth, &ptr))
694 if (!prs_uint32("count1", ps, depth, &d_q->count1))
696 if (!prs_uint32("count2", ps, depth, &d_q->count2))
699 if (UNMARSHALLING(ps)) {
700 d_q->auditsettings = (uint32 *)talloc_zero(ps->mem_ctx, d_q->count2 * sizeof(uint32));
703 if (d_q->auditsettings == NULL) {
704 DEBUG(1, ("lsa_io_dom_query_2: NULL auditsettings!\n"));
708 if (!prs_uint32s(False, "auditsettings", ps, depth, d_q->auditsettings, d_q->count2))
714 /*******************************************************************
715 Reads or writes a dom query structure.
716 ********************************************************************/
718 static BOOL lsa_io_dom_query_3(const char *desc, DOM_QUERY_3 *d_q, prs_struct *ps, int depth)
720 return lsa_io_dom_query("", d_q, ps, depth);
723 /*******************************************************************
724 Reads or writes a dom query structure.
725 ********************************************************************/
727 static BOOL lsa_io_dom_query_5(const char *desc, DOM_QUERY_5 *d_q, prs_struct *ps, int depth)
729 return lsa_io_dom_query("", d_q, ps, depth);
732 /*******************************************************************
733 Reads or writes a dom query structure.
734 ********************************************************************/
736 static BOOL lsa_io_dom_query_6(const char *desc, DOM_QUERY_6 *d_q, prs_struct *ps, int depth)
741 prs_debug(ps, depth, desc, "lsa_io_dom_query_6");
744 if (!prs_uint16("server_role", ps, depth, &d_q->server_role))
750 /*******************************************************************
751 Reads or writes an LSA_R_QUERY_INFO structure.
752 ********************************************************************/
754 BOOL lsa_io_r_query(const char *desc, LSA_R_QUERY_INFO *r_q, prs_struct *ps,
757 prs_debug(ps, depth, desc, "lsa_io_r_query");
760 if(!prs_uint32("undoc_buffer", ps, depth, &r_q->undoc_buffer))
763 if (r_q->undoc_buffer != 0) {
764 if(!prs_uint16("info_class", ps, depth, &r_q->info_class))
770 switch (r_q->info_class) {
772 if(!lsa_io_dom_query_2("", &r_q->dom.id2, ps, depth))
776 if(!lsa_io_dom_query_3("", &r_q->dom.id3, ps, depth))
780 if(!lsa_io_dom_query_5("", &r_q->dom.id5, ps, depth))
784 if(!lsa_io_dom_query_6("", &r_q->dom.id6, ps, depth))
796 if(!prs_ntstatus("status", ps, depth, &r_q->status))
802 /*******************************************************************
803 Inits a LSA_SID_ENUM structure.
804 ********************************************************************/
806 static void init_lsa_sid_enum(TALLOC_CTX *mem_ctx, LSA_SID_ENUM *sen,
807 int num_entries, DOM_SID *sids)
811 DEBUG(5, ("init_lsa_sid_enum\n"));
813 sen->num_entries = num_entries;
814 sen->ptr_sid_enum = (num_entries != 0);
815 sen->num_entries2 = num_entries;
817 /* Allocate memory for sids and sid pointers */
819 if (num_entries == 0) return;
821 if ((sen->ptr_sid = (uint32 *)talloc_zero(mem_ctx, num_entries *
822 sizeof(uint32))) == NULL) {
823 DEBUG(3, ("init_lsa_sid_enum(): out of memory for ptr_sid\n"));
827 if ((sen->sid = (DOM_SID2 *)talloc_zero(mem_ctx, num_entries *
828 sizeof(DOM_SID2))) == NULL) {
829 DEBUG(3, ("init_lsa_sid_enum(): out of memory for sids\n"));
833 /* Copy across SIDs and SID pointers */
835 for (i = 0; i < num_entries; i++) {
837 init_dom_sid2(&sen->sid[i], &sids[i]);
841 /*******************************************************************
842 Reads or writes a LSA_SID_ENUM structure.
843 ********************************************************************/
845 static BOOL lsa_io_sid_enum(const char *desc, LSA_SID_ENUM *sen, prs_struct *ps,
850 prs_debug(ps, depth, desc, "lsa_io_sid_enum");
856 if(!prs_uint32("num_entries ", ps, depth, &sen->num_entries))
858 if(!prs_uint32("ptr_sid_enum", ps, depth, &sen->ptr_sid_enum))
862 if the ptr is NULL, leave here. checked from a real w2k trace.
866 if (sen->ptr_sid_enum==0)
869 if(!prs_uint32("num_entries2", ps, depth, &sen->num_entries2))
872 /* Mallocate memory if we're unpacking from the wire */
874 if (UNMARSHALLING(ps)) {
875 if ((sen->ptr_sid = (uint32 *)prs_alloc_mem( ps,
876 sen->num_entries * sizeof(uint32))) == NULL) {
877 DEBUG(3, ("init_lsa_sid_enum(): out of memory for "
882 if ((sen->sid = (DOM_SID2 *)prs_alloc_mem( ps,
883 sen->num_entries * sizeof(DOM_SID2))) == NULL) {
884 DEBUG(3, ("init_lsa_sid_enum(): out of memory for "
890 for (i = 0; i < sen->num_entries; i++) {
893 slprintf(temp, sizeof(temp) - 1, "ptr_sid[%d]", i);
894 if(!prs_uint32(temp, ps, depth, &sen->ptr_sid[i])) {
899 for (i = 0; i < sen->num_entries; i++) {
902 slprintf(temp, sizeof(temp) - 1, "sid[%d]", i);
903 if(!smb_io_dom_sid2(temp, &sen->sid[i], ps, depth)) {
911 /*******************************************************************
912 Inits an LSA_R_ENUM_TRUST_DOM structure.
913 ********************************************************************/
915 void init_q_lookup_sids(TALLOC_CTX *mem_ctx, LSA_Q_LOOKUP_SIDS *q_l,
916 POLICY_HND *hnd, int num_sids, DOM_SID *sids,
919 DEBUG(5, ("init_q_lookup_sids\n"));
923 memcpy(&q_l->pol, hnd, sizeof(q_l->pol));
924 init_lsa_sid_enum(mem_ctx, &q_l->sids, num_sids, sids);
926 q_l->level.value = level;
929 /*******************************************************************
930 Reads or writes a LSA_Q_LOOKUP_SIDS structure.
931 ********************************************************************/
933 BOOL lsa_io_q_lookup_sids(const char *desc, LSA_Q_LOOKUP_SIDS *q_s, prs_struct *ps,
936 prs_debug(ps, depth, desc, "lsa_io_q_lookup_sids");
942 if(!smb_io_pol_hnd("pol_hnd", &q_s->pol, ps, depth)) /* policy handle */
944 if(!lsa_io_sid_enum("sids ", &q_s->sids, ps, depth)) /* sids to be looked up */
946 if(!lsa_io_trans_names("names ", &q_s->names, ps, depth)) /* translated names */
948 if(!smb_io_lookup_level("switch ", &q_s->level, ps, depth)) /* lookup level */
951 if(!prs_uint32("mapped_count", ps, depth, &q_s->mapped_count))
957 /*******************************************************************
958 Reads or writes a structure.
959 ********************************************************************/
961 static BOOL lsa_io_trans_names(const char *desc, LSA_TRANS_NAME_ENUM *trn,
962 prs_struct *ps, int depth)
966 prs_debug(ps, depth, desc, "lsa_io_trans_names");
972 if(!prs_uint32("num_entries ", ps, depth, &trn->num_entries))
974 if(!prs_uint32("ptr_trans_names", ps, depth, &trn->ptr_trans_names))
977 if (trn->ptr_trans_names != 0) {
978 if(!prs_uint32("num_entries2 ", ps, depth,
982 if (UNMARSHALLING(ps)) {
983 if ((trn->name = (LSA_TRANS_NAME *)
984 prs_alloc_mem(ps, trn->num_entries *
985 sizeof(LSA_TRANS_NAME))) == NULL) {
989 if ((trn->uni_name = (UNISTR2 *)
990 prs_alloc_mem(ps, trn->num_entries *
991 sizeof(UNISTR2))) == NULL) {
996 for (i = 0; i < trn->num_entries2; i++) {
998 slprintf(t, sizeof(t) - 1, "name[%d] ", i);
1000 if(!lsa_io_trans_name(t, &trn->name[i], ps, depth)) /* translated name */
1004 for (i = 0; i < trn->num_entries2; i++) {
1006 slprintf(t, sizeof(t) - 1, "name[%d] ", i);
1008 if(!smb_io_unistr2(t, &trn->uni_name[i], trn->name[i].hdr_name.buffer, ps, depth))
1018 /*******************************************************************
1019 Reads or writes a structure.
1020 ********************************************************************/
1022 BOOL lsa_io_r_lookup_sids(const char *desc, LSA_R_LOOKUP_SIDS *r_s,
1023 prs_struct *ps, int depth)
1025 prs_debug(ps, depth, desc, "lsa_io_r_lookup_sids");
1031 if(!prs_uint32("ptr_dom_ref", ps, depth, &r_s->ptr_dom_ref))
1034 if (r_s->ptr_dom_ref != 0)
1035 if(!lsa_io_dom_r_ref ("dom_ref", r_s->dom_ref, ps, depth)) /* domain reference info */
1038 if(!lsa_io_trans_names("names ", r_s->names, ps, depth)) /* translated names */
1044 if(!prs_uint32("mapped_count", ps, depth, &r_s->mapped_count))
1047 if(!prs_ntstatus("status ", ps, depth, &r_s->status))
1053 /*******************************************************************
1055 ********************************************************************/
1057 void init_q_lookup_names(TALLOC_CTX *mem_ctx, LSA_Q_LOOKUP_NAMES *q_l,
1058 POLICY_HND *hnd, int num_names, const char **names)
1062 DEBUG(5, ("init_q_lookup_names\n"));
1067 q_l->num_entries = num_names;
1068 q_l->num_entries2 = num_names;
1069 q_l->lookup_level = 1;
1071 if ((q_l->uni_name = (UNISTR2 *)talloc_zero(
1072 mem_ctx, num_names * sizeof(UNISTR2))) == NULL) {
1073 DEBUG(3, ("init_q_lookup_names(): out of memory\n"));
1077 if ((q_l->hdr_name = (UNIHDR *)talloc_zero(
1078 mem_ctx, num_names * sizeof(UNIHDR))) == NULL) {
1079 DEBUG(3, ("init_q_lookup_names(): out of memory\n"));
1083 for (i = 0; i < num_names; i++) {
1084 init_unistr2(&q_l->uni_name[i], names[i], UNI_FLAGS_NONE);
1085 init_uni_hdr(&q_l->hdr_name[i], &q_l->uni_name[i]);
1089 /*******************************************************************
1090 reads or writes a structure.
1091 ********************************************************************/
1093 BOOL lsa_io_q_lookup_names(const char *desc, LSA_Q_LOOKUP_NAMES *q_r,
1094 prs_struct *ps, int depth)
1098 prs_debug(ps, depth, desc, "lsa_io_q_lookup_names");
1104 if(!smb_io_pol_hnd("", &q_r->pol, ps, depth)) /* policy handle */
1109 if(!prs_uint32("num_entries ", ps, depth, &q_r->num_entries))
1111 if(!prs_uint32("num_entries2 ", ps, depth, &q_r->num_entries2))
1114 if (UNMARSHALLING(ps)) {
1115 if (q_r->num_entries) {
1116 if ((q_r->hdr_name = (UNIHDR *)prs_alloc_mem(ps,
1117 q_r->num_entries * sizeof(UNIHDR))) == NULL)
1119 if ((q_r->uni_name = (UNISTR2 *)prs_alloc_mem(ps,
1120 q_r->num_entries * sizeof(UNISTR2))) == NULL)
1125 for (i = 0; i < q_r->num_entries; i++) {
1128 if(!smb_io_unihdr("hdr_name", &q_r->hdr_name[i], ps, depth)) /* pointer names */
1132 for (i = 0; i < q_r->num_entries; i++) {
1135 if(!smb_io_unistr2("dom_name", &q_r->uni_name[i], q_r->hdr_name[i].buffer, ps, depth)) /* names to be looked up */
1141 if(!prs_uint32("num_trans_entries ", ps, depth, &q_r->num_trans_entries))
1143 if(!prs_uint32("ptr_trans_sids ", ps, depth, &q_r->ptr_trans_sids))
1145 if(!prs_uint32("lookup_level ", ps, depth, &q_r->lookup_level))
1147 if(!prs_uint32("mapped_count ", ps, depth, &q_r->mapped_count))
1153 /*******************************************************************
1154 reads or writes a structure.
1155 ********************************************************************/
1157 BOOL lsa_io_r_lookup_names(const char *desc, LSA_R_LOOKUP_NAMES *r_r,
1158 prs_struct *ps, int depth)
1162 prs_debug(ps, depth, desc, "lsa_io_r_lookup_names");
1168 if(!prs_uint32("ptr_dom_ref", ps, depth, &r_r->ptr_dom_ref))
1171 if (r_r->ptr_dom_ref != 0)
1172 if(!lsa_io_dom_r_ref("", r_r->dom_ref, ps, depth))
1175 if(!prs_uint32("num_entries", ps, depth, &r_r->num_entries))
1177 if(!prs_uint32("ptr_entries", ps, depth, &r_r->ptr_entries))
1180 if (r_r->ptr_entries != 0) {
1181 if(!prs_uint32("num_entries2", ps, depth, &r_r->num_entries2))
1184 if (r_r->num_entries2 != r_r->num_entries) {
1189 if (UNMARSHALLING(ps)) {
1190 if ((r_r->dom_rid = (DOM_RID2 *)prs_alloc_mem(ps, r_r->num_entries2 * sizeof(DOM_RID2)))
1192 DEBUG(3, ("lsa_io_r_lookup_names(): out of memory\n"));
1197 for (i = 0; i < r_r->num_entries2; i++)
1198 if(!smb_io_dom_rid2("", &r_r->dom_rid[i], ps, depth)) /* domain RIDs being looked up */
1202 if(!prs_uint32("mapped_count", ps, depth, &r_r->mapped_count))
1205 if(!prs_ntstatus("status ", ps, depth, &r_r->status))
1212 /*******************************************************************
1213 Inits an LSA_Q_CLOSE structure.
1214 ********************************************************************/
1216 void init_lsa_q_close(LSA_Q_CLOSE *q_c, POLICY_HND *hnd)
1218 DEBUG(5, ("init_lsa_q_close\n"));
1220 memcpy(&q_c->pol, hnd, sizeof(q_c->pol));
1223 /*******************************************************************
1224 Reads or writes an LSA_Q_CLOSE structure.
1225 ********************************************************************/
1227 BOOL lsa_io_q_close(const char *desc, LSA_Q_CLOSE *q_c, prs_struct *ps, int depth)
1229 prs_debug(ps, depth, desc, "lsa_io_q_close");
1232 if(!smb_io_pol_hnd("", &q_c->pol, ps, depth))
1238 /*******************************************************************
1239 Reads or writes an LSA_R_CLOSE structure.
1240 ********************************************************************/
1242 BOOL lsa_io_r_close(const char *desc, LSA_R_CLOSE *r_c, prs_struct *ps, int depth)
1244 prs_debug(ps, depth, desc, "lsa_io_r_close");
1247 if(!smb_io_pol_hnd("", &r_c->pol, ps, depth))
1250 if(!prs_ntstatus("status", ps, depth, &r_c->status))
1256 /*******************************************************************
1257 Reads or writes an LSA_Q_OPEN_SECRET structure.
1258 ********************************************************************/
1260 BOOL lsa_io_q_open_secret(const char *desc, LSA_Q_OPEN_SECRET *q_c, prs_struct *ps, int depth)
1262 prs_debug(ps, depth, desc, "lsa_io_q_open_secret");
1265 /* Don't bother to read or write at present... */
1269 /*******************************************************************
1270 Reads or writes an LSA_R_OPEN_SECRET structure.
1271 ********************************************************************/
1273 BOOL lsa_io_r_open_secret(const char *desc, LSA_R_OPEN_SECRET *r_c, prs_struct *ps, int depth)
1275 prs_debug(ps, depth, desc, "lsa_io_r_open_secret");
1281 if(!prs_uint32("dummy1", ps, depth, &r_c->dummy1))
1283 if(!prs_uint32("dummy2", ps, depth, &r_c->dummy2))
1285 if(!prs_uint32("dummy3", ps, depth, &r_c->dummy3))
1287 if(!prs_uint32("dummy4", ps, depth, &r_c->dummy4))
1289 if(!prs_ntstatus("status", ps, depth, &r_c->status))
1295 /*******************************************************************
1296 Inits an LSA_Q_ENUM_PRIVS structure.
1297 ********************************************************************/
1299 void init_q_enum_privs(LSA_Q_ENUM_PRIVS *q_q, POLICY_HND *hnd, uint32 enum_context, uint32 pref_max_length)
1301 DEBUG(5, ("init_q_enum_privs\n"));
1303 memcpy(&q_q->pol, hnd, sizeof(q_q->pol));
1305 q_q->enum_context = enum_context;
1306 q_q->pref_max_length = pref_max_length;
1309 /*******************************************************************
1310 reads or writes a structure.
1311 ********************************************************************/
1312 BOOL lsa_io_q_enum_privs(const char *desc, LSA_Q_ENUM_PRIVS *q_q, prs_struct *ps, int depth)
1317 prs_debug(ps, depth, desc, "lsa_io_q_enum_privs");
1320 if (!smb_io_pol_hnd("", &q_q->pol, ps, depth))
1323 if(!prs_uint32("enum_context ", ps, depth, &q_q->enum_context))
1325 if(!prs_uint32("pref_max_length", ps, depth, &q_q->pref_max_length))
1331 /*******************************************************************
1332 reads or writes a structure.
1333 ********************************************************************/
1334 static BOOL lsa_io_priv_entries(const char *desc, LSA_PRIV_ENTRY *entries, uint32 count, prs_struct *ps, int depth)
1338 if (entries == NULL)
1341 prs_debug(ps, depth, desc, "lsa_io_priv_entries");
1347 for (i = 0; i < count; i++) {
1348 if (!smb_io_unihdr("", &entries[i].hdr_name, ps, depth))
1350 if(!prs_uint32("luid_low ", ps, depth, &entries[i].luid_low))
1352 if(!prs_uint32("luid_high", ps, depth, &entries[i].luid_high))
1356 for (i = 0; i < count; i++)
1357 if (!smb_io_unistr2("", &entries[i].name, entries[i].hdr_name.buffer, ps, depth))
1363 /*******************************************************************
1364 Inits an LSA_R_ENUM_PRIVS structure.
1365 ********************************************************************/
1367 void init_lsa_r_enum_privs(LSA_R_ENUM_PRIVS *r_u, uint32 enum_context,
1368 uint32 count, LSA_PRIV_ENTRY *entries)
1370 DEBUG(5, ("init_lsa_r_enum_privs\n"));
1372 r_u->enum_context=enum_context;
1375 if (entries!=NULL) {
1386 /*******************************************************************
1387 reads or writes a structure.
1388 ********************************************************************/
1389 BOOL lsa_io_r_enum_privs(const char *desc, LSA_R_ENUM_PRIVS *r_q, prs_struct *ps, int depth)
1394 prs_debug(ps, depth, desc, "lsa_io_r_enum_privs");
1400 if(!prs_uint32("enum_context", ps, depth, &r_q->enum_context))
1402 if(!prs_uint32("count", ps, depth, &r_q->count))
1404 if(!prs_uint32("ptr", ps, depth, &r_q->ptr))
1408 if(!prs_uint32("count1", ps, depth, &r_q->count1))
1411 if (UNMARSHALLING(ps))
1412 if (!(r_q->privs = (LSA_PRIV_ENTRY *)prs_alloc_mem(ps, sizeof(LSA_PRIV_ENTRY) * r_q->count1)))
1415 if (!lsa_io_priv_entries("", r_q->privs, r_q->count1, ps, depth))
1422 if(!prs_ntstatus("status", ps, depth, &r_q->status))
1428 void init_lsa_priv_get_dispname(LSA_Q_PRIV_GET_DISPNAME *trn, POLICY_HND *hnd, const char *name, uint16 lang_id, uint16 lang_id_sys)
1430 memcpy(&trn->pol, hnd, sizeof(trn->pol));
1432 init_unistr2(&trn->name, name, UNI_FLAGS_NONE);
1433 init_uni_hdr(&trn->hdr_name, &trn->name);
1434 trn->lang_id = lang_id;
1435 trn->lang_id_sys = lang_id_sys;
1438 /*******************************************************************
1439 reads or writes a structure.
1440 ********************************************************************/
1441 BOOL lsa_io_q_priv_get_dispname(const char *desc, LSA_Q_PRIV_GET_DISPNAME *q_q, prs_struct *ps, int depth)
1446 prs_debug(ps, depth, desc, "lsa_io_q_priv_get_dispname");
1452 if (!smb_io_pol_hnd("", &q_q->pol, ps, depth))
1455 if (!smb_io_unihdr("hdr_name", &q_q->hdr_name, ps, depth))
1458 if (!smb_io_unistr2("name", &q_q->name, q_q->hdr_name.buffer, ps, depth))
1461 if(!prs_uint16("lang_id ", ps, depth, &q_q->lang_id))
1463 if(!prs_uint16("lang_id_sys", ps, depth, &q_q->lang_id_sys))
1469 /*******************************************************************
1470 reads or writes a structure.
1471 ********************************************************************/
1472 BOOL lsa_io_r_priv_get_dispname(const char *desc, LSA_R_PRIV_GET_DISPNAME *r_q, prs_struct *ps, int depth)
1477 prs_debug(ps, depth, desc, "lsa_io_r_priv_get_dispname");
1483 if (!prs_uint32("ptr_info", ps, depth, &r_q->ptr_info))
1487 if (!smb_io_unihdr("hdr_name", &r_q->hdr_desc, ps, depth))
1490 if (!smb_io_unistr2("desc", &r_q->desc, r_q->hdr_desc.buffer, ps, depth))
1497 if(!prs_uint16("lang_id", ps, depth, &r_q->lang_id))
1502 if(!prs_ntstatus("status", ps, depth, &r_q->status))
1509 initialise a LSA_Q_ENUM_ACCOUNTS structure
1511 void init_lsa_q_enum_accounts(LSA_Q_ENUM_ACCOUNTS *trn, POLICY_HND *hnd, uint32 enum_context, uint32 pref_max_length)
1513 memcpy(&trn->pol, hnd, sizeof(trn->pol));
1515 trn->enum_context = enum_context;
1516 trn->pref_max_length = pref_max_length;
1519 /*******************************************************************
1520 reads or writes a structure.
1521 ********************************************************************/
1522 BOOL lsa_io_q_enum_accounts(const char *desc, LSA_Q_ENUM_ACCOUNTS *q_q, prs_struct *ps, int depth)
1527 prs_debug(ps, depth, desc, "lsa_io_q_enum_accounts");
1530 if (!smb_io_pol_hnd("", &q_q->pol, ps, depth))
1533 if(!prs_uint32("enum_context ", ps, depth, &q_q->enum_context))
1535 if(!prs_uint32("pref_max_length", ps, depth, &q_q->pref_max_length))
1542 /*******************************************************************
1543 Inits an LSA_R_ENUM_PRIVS structure.
1544 ********************************************************************/
1546 void init_lsa_r_enum_accounts(LSA_R_ENUM_ACCOUNTS *r_u, uint32 enum_context)
1548 DEBUG(5, ("init_lsa_r_enum_accounts\n"));
1550 r_u->enum_context=enum_context;
1551 if (r_u->enum_context!=0) {
1552 r_u->sids.num_entries=enum_context;
1553 r_u->sids.ptr_sid_enum=1;
1554 r_u->sids.num_entries2=enum_context;
1556 r_u->sids.num_entries=0;
1557 r_u->sids.ptr_sid_enum=0;
1558 r_u->sids.num_entries2=0;
1562 /*******************************************************************
1563 reads or writes a structure.
1564 ********************************************************************/
1565 BOOL lsa_io_r_enum_accounts(const char *desc, LSA_R_ENUM_ACCOUNTS *r_q, prs_struct *ps, int depth)
1570 prs_debug(ps, depth, desc, "lsa_io_r_enum_accounts");
1576 if(!prs_uint32("enum_context", ps, depth, &r_q->enum_context))
1579 if (!lsa_io_sid_enum("sids", &r_q->sids, ps, depth))
1585 if(!prs_ntstatus("status", ps, depth, &r_q->status))
1592 /*******************************************************************
1593 Reads or writes an LSA_Q_UNK_GET_CONNUSER structure.
1594 ********************************************************************/
1596 BOOL lsa_io_q_unk_get_connuser(const char *desc, LSA_Q_UNK_GET_CONNUSER *q_c, prs_struct *ps, int depth)
1598 prs_debug(ps, depth, desc, "lsa_io_q_unk_get_connuser");
1604 if(!prs_uint32("ptr_srvname", ps, depth, &q_c->ptr_srvname))
1607 if(!smb_io_unistr2("uni2_srvname", &q_c->uni2_srvname, q_c->ptr_srvname, ps, depth)) /* server name to be looked up */
1613 if(!prs_uint32("unk1", ps, depth, &q_c->unk1))
1615 if(!prs_uint32("unk2", ps, depth, &q_c->unk2))
1617 if(!prs_uint32("unk3", ps, depth, &q_c->unk3))
1620 /* Don't bother to read or write at present... */
1624 /*******************************************************************
1625 Reads or writes an LSA_R_UNK_GET_CONNUSER structure.
1626 ********************************************************************/
1628 BOOL lsa_io_r_unk_get_connuser(const char *desc, LSA_R_UNK_GET_CONNUSER *r_c, prs_struct *ps, int depth)
1630 prs_debug(ps, depth, desc, "lsa_io_r_unk_get_connuser");
1636 if(!prs_uint32("ptr_user_name", ps, depth, &r_c->ptr_user_name))
1638 if(!smb_io_unihdr("hdr_user_name", &r_c->hdr_user_name, ps, depth))
1640 if(!smb_io_unistr2("uni2_user_name", &r_c->uni2_user_name, r_c->ptr_user_name, ps, depth))
1646 if(!prs_uint32("unk1", ps, depth, &r_c->unk1))
1649 if(!prs_uint32("ptr_dom_name", ps, depth, &r_c->ptr_dom_name))
1651 if(!smb_io_unihdr("hdr_dom_name", &r_c->hdr_dom_name, ps, depth))
1653 if(!smb_io_unistr2("uni2_dom_name", &r_c->uni2_dom_name, r_c->ptr_dom_name, ps, depth))
1659 if(!prs_ntstatus("status", ps, depth, &r_c->status))
1665 void init_lsa_q_open_account(LSA_Q_OPENACCOUNT *trn, POLICY_HND *hnd, DOM_SID *sid, uint32 desired_access)
1667 memcpy(&trn->pol, hnd, sizeof(trn->pol));
1669 init_dom_sid2(&trn->sid, sid);
1670 trn->access = desired_access;
1673 /*******************************************************************
1674 Reads or writes an LSA_Q_OPENACCOUNT structure.
1675 ********************************************************************/
1677 BOOL lsa_io_q_open_account(const char *desc, LSA_Q_OPENACCOUNT *r_c, prs_struct *ps, int depth)
1679 prs_debug(ps, depth, desc, "lsa_io_q_open_account");
1685 if(!smb_io_pol_hnd("pol", &r_c->pol, ps, depth))
1688 if(!smb_io_dom_sid2("sid", &r_c->sid, ps, depth)) /* domain SID */
1691 if(!prs_uint32("access", ps, depth, &r_c->access))
1697 /*******************************************************************
1698 Reads or writes an LSA_R_OPENACCOUNT structure.
1699 ********************************************************************/
1701 BOOL lsa_io_r_open_account(const char *desc, LSA_R_OPENACCOUNT *r_c, prs_struct *ps, int depth)
1703 prs_debug(ps, depth, desc, "lsa_io_r_open_account");
1709 if(!smb_io_pol_hnd("pol", &r_c->pol, ps, depth))
1712 if(!prs_ntstatus("status", ps, depth, &r_c->status))
1719 void init_lsa_q_enum_privsaccount(LSA_Q_ENUMPRIVSACCOUNT *trn, POLICY_HND *hnd)
1721 memcpy(&trn->pol, hnd, sizeof(trn->pol));
1725 /*******************************************************************
1726 Reads or writes an LSA_Q_ENUMPRIVSACCOUNT structure.
1727 ********************************************************************/
1729 BOOL lsa_io_q_enum_privsaccount(const char *desc, LSA_Q_ENUMPRIVSACCOUNT *r_c, prs_struct *ps, int depth)
1731 prs_debug(ps, depth, desc, "lsa_io_q_enum_privsaccount");
1737 if(!smb_io_pol_hnd("pol", &r_c->pol, ps, depth))
1743 /*******************************************************************
1744 Reads or writes an LUID structure.
1745 ********************************************************************/
1747 static BOOL lsa_io_luid(const char *desc, LUID *r_c, prs_struct *ps, int depth)
1749 prs_debug(ps, depth, desc, "lsa_io_luid");
1755 if(!prs_uint32("low", ps, depth, &r_c->low))
1758 if(!prs_uint32("high", ps, depth, &r_c->high))
1764 /*******************************************************************
1765 Reads or writes an LUID_ATTR structure.
1766 ********************************************************************/
1768 static BOOL lsa_io_luid_attr(const char *desc, LUID_ATTR *r_c, prs_struct *ps, int depth)
1770 prs_debug(ps, depth, desc, "lsa_io_luid_attr");
1776 if (!lsa_io_luid(desc, &r_c->luid, ps, depth))
1779 if(!prs_uint32("attr", ps, depth, &r_c->attr))
1785 /*******************************************************************
1786 Reads or writes an PRIVILEGE_SET structure.
1787 ********************************************************************/
1789 static BOOL lsa_io_privilege_set(const char *desc, PRIVILEGE_SET *r_c, prs_struct *ps, int depth)
1793 prs_debug(ps, depth, desc, "lsa_io_privilege_set");
1799 if(!prs_uint32("count", ps, depth, &r_c->count))
1801 if(!prs_uint32("control", ps, depth, &r_c->control))
1804 for (i=0; i<r_c->count; i++) {
1805 if (!lsa_io_luid_attr(desc, &r_c->set[i], ps, depth))
1812 NTSTATUS init_lsa_r_enum_privsaccount(TALLOC_CTX *mem_ctx, LSA_R_ENUMPRIVSACCOUNT *r_u, LUID_ATTR *set, uint32 count, uint32 control)
1814 NTSTATUS ret = NT_STATUS_OK;
1819 if (!NT_STATUS_IS_OK(ret = init_priv_with_ctx(mem_ctx, &(r_u->set))))
1822 if (!NT_STATUS_IS_OK(ret = dupalloc_luid_attr(r_u->set->mem_ctx, &(r_u->set->set), set)))
1825 DEBUG(10,("init_lsa_r_enum_privsaccount: %d %d privileges\n", r_u->count, r_u->set->count));
1830 /*******************************************************************
1831 Reads or writes an LSA_R_ENUMPRIVSACCOUNT structure.
1832 ********************************************************************/
1834 BOOL lsa_io_r_enum_privsaccount(const char *desc, LSA_R_ENUMPRIVSACCOUNT *r_c, prs_struct *ps, int depth)
1836 prs_debug(ps, depth, desc, "lsa_io_r_enum_privsaccount");
1842 if(!prs_uint32("ptr", ps, depth, &r_c->ptr))
1846 if(!prs_uint32("count", ps, depth, &r_c->count))
1849 /* malloc memory if unmarshalling here */
1851 if (UNMARSHALLING(ps) && r_c->count != 0) {
1852 if (!NT_STATUS_IS_OK(init_priv_with_ctx(ps->mem_ctx, &(r_c->set))))
1855 if (!(r_c->set->set = (LUID_ATTR *)prs_alloc_mem(ps,sizeof(LUID_ATTR) * r_c->count)))
1860 if(!lsa_io_privilege_set(desc, r_c->set, ps, depth))
1864 if(!prs_ntstatus("status", ps, depth, &r_c->status))
1872 /*******************************************************************
1873 Reads or writes an LSA_Q_GETSYSTEMACCOUNTstructure.
1874 ********************************************************************/
1876 BOOL lsa_io_q_getsystemaccount(const char *desc, LSA_Q_GETSYSTEMACCOUNT *r_c, prs_struct *ps, int depth)
1878 prs_debug(ps, depth, desc, "lsa_io_q_getsystemaccount");
1884 if(!smb_io_pol_hnd("pol", &r_c->pol, ps, depth))
1890 /*******************************************************************
1891 Reads or writes an LSA_R_GETSYSTEMACCOUNTstructure.
1892 ********************************************************************/
1894 BOOL lsa_io_r_getsystemaccount(const char *desc, LSA_R_GETSYSTEMACCOUNT *r_c, prs_struct *ps, int depth)
1896 prs_debug(ps, depth, desc, "lsa_io_r_getsystemaccount");
1902 if(!prs_uint32("access", ps, depth, &r_c->access))
1905 if(!prs_ntstatus("status", ps, depth, &r_c->status))
1912 /*******************************************************************
1913 Reads or writes an LSA_Q_SETSYSTEMACCOUNT structure.
1914 ********************************************************************/
1916 BOOL lsa_io_q_setsystemaccount(const char *desc, LSA_Q_SETSYSTEMACCOUNT *r_c, prs_struct *ps, int depth)
1918 prs_debug(ps, depth, desc, "lsa_io_q_setsystemaccount");
1924 if(!smb_io_pol_hnd("pol", &r_c->pol, ps, depth))
1927 if(!prs_uint32("access", ps, depth, &r_c->access))
1933 /*******************************************************************
1934 Reads or writes an LSA_R_SETSYSTEMACCOUNT structure.
1935 ********************************************************************/
1937 BOOL lsa_io_r_setsystemaccount(const char *desc, LSA_R_SETSYSTEMACCOUNT *r_c, prs_struct *ps, int depth)
1939 prs_debug(ps, depth, desc, "lsa_io_r_setsystemaccount");
1945 if(!prs_ntstatus("status", ps, depth, &r_c->status))
1952 void init_lsa_q_lookupprivvalue(LSA_Q_LOOKUPPRIVVALUE *trn, POLICY_HND *hnd, const char *name)
1954 memcpy(&trn->pol, hnd, sizeof(trn->pol));
1955 init_unistr2(&trn->uni2_right, name, UNI_FLAGS_NONE);
1956 init_uni_hdr(&trn->hdr_right, &trn->uni2_right);
1959 /*******************************************************************
1960 Reads or writes an LSA_Q_LOOKUPPRIVVALUE structure.
1961 ********************************************************************/
1963 BOOL lsa_io_q_lookupprivvalue(const char *desc, LSA_Q_LOOKUPPRIVVALUE *r_c, prs_struct *ps, int depth)
1965 prs_debug(ps, depth, desc, "lsa_io_q_lookupprivvalue");
1971 if(!smb_io_pol_hnd("pol", &r_c->pol, ps, depth))
1973 if(!smb_io_unihdr ("hdr_name", &r_c->hdr_right, ps, depth))
1975 if(!smb_io_unistr2("uni2_right", &r_c->uni2_right, r_c->hdr_right.buffer, ps, depth))
1981 /*******************************************************************
1982 Reads or writes an LSA_R_LOOKUPPRIVVALUE structure.
1983 ********************************************************************/
1985 BOOL lsa_io_r_lookupprivvalue(const char *desc, LSA_R_LOOKUPPRIVVALUE *r_c, prs_struct *ps, int depth)
1987 prs_debug(ps, depth, desc, "lsa_io_r_lookupprivvalue");
1993 if(!lsa_io_luid("luid", &r_c->luid, ps, depth))
1996 if(!prs_ntstatus("status", ps, depth, &r_c->status))
2003 /*******************************************************************
2004 Reads or writes an LSA_Q_ADDPRIVS structure.
2005 ********************************************************************/
2007 BOOL lsa_io_q_addprivs(const char *desc, LSA_Q_ADDPRIVS *r_c, prs_struct *ps, int depth)
2009 prs_debug(ps, depth, desc, "lsa_io_q_addprivs");
2015 if(!smb_io_pol_hnd("pol", &r_c->pol, ps, depth))
2018 if(!prs_uint32("count", ps, depth, &r_c->count))
2021 if (UNMARSHALLING(ps) && r_c->count!=0) {
2022 if (!NT_STATUS_IS_OK(init_priv_with_ctx(ps->mem_ctx, &(r_c->set))))
2025 if (!(r_c->set->set = (LUID_ATTR *)prs_alloc_mem(ps, sizeof(LUID_ATTR) * r_c->count)))
2029 if(!lsa_io_privilege_set(desc, r_c->set, ps, depth))
2035 /*******************************************************************
2036 Reads or writes an LSA_R_ADDPRIVS structure.
2037 ********************************************************************/
2039 BOOL lsa_io_r_addprivs(const char *desc, LSA_R_ADDPRIVS *r_c, prs_struct *ps, int depth)
2041 prs_debug(ps, depth, desc, "lsa_io_r_addprivs");
2047 if(!prs_ntstatus("status", ps, depth, &r_c->status))
2053 /*******************************************************************
2054 Reads or writes an LSA_Q_REMOVEPRIVS structure.
2055 ********************************************************************/
2057 BOOL lsa_io_q_removeprivs(const char *desc, LSA_Q_REMOVEPRIVS *r_c, prs_struct *ps, int depth)
2059 prs_debug(ps, depth, desc, "lsa_io_q_removeprivs");
2065 if(!smb_io_pol_hnd("pol", &r_c->pol, ps, depth))
2068 if(!prs_uint32("allrights", ps, depth, &r_c->allrights))
2071 if(!prs_uint32("ptr", ps, depth, &r_c->ptr))
2075 * JFM: I'm not sure at all if the count is inside the ptr
2076 * never seen one with ptr=0
2080 if(!prs_uint32("count", ps, depth, &r_c->count))
2083 if (UNMARSHALLING(ps) && r_c->count!=0) {
2084 if (!NT_STATUS_IS_OK(init_priv_with_ctx(ps->mem_ctx, &(r_c->set))))
2087 if (!(r_c->set->set = (LUID_ATTR *)prs_alloc_mem(ps, sizeof(LUID_ATTR) * r_c->count)))
2091 if(!lsa_io_privilege_set(desc, r_c->set, ps, depth))
2098 /*******************************************************************
2099 Reads or writes an LSA_R_REMOVEPRIVS structure.
2100 ********************************************************************/
2102 BOOL lsa_io_r_removeprivs(const char *desc, LSA_R_REMOVEPRIVS *r_c, prs_struct *ps, int depth)
2104 prs_debug(ps, depth, desc, "lsa_io_r_removeprivs");
2110 if(!prs_ntstatus("status", ps, depth, &r_c->status))
2116 BOOL policy_handle_is_valid(const POLICY_HND *hnd)
2118 POLICY_HND zero_pol;
2120 ZERO_STRUCT(zero_pol);
2121 return ((memcmp(&zero_pol, hnd, sizeof(POLICY_HND)) == 0) ? False : True );
2124 /*******************************************************************
2125 Reads or writes an LSA_DNS_DOM_INFO structure.
2126 ********************************************************************/
2128 BOOL lsa_io_dns_dom_info(const char *desc, LSA_DNS_DOM_INFO *info,
2129 prs_struct *ps, int depth)
2131 prs_debug(ps, depth, desc, "lsa_io_dns_dom_info");
2136 if(!smb_io_unihdr("nb_name", &info->hdr_nb_dom_name, ps, depth))
2138 if(!smb_io_unihdr("dns_name", &info->hdr_dns_dom_name, ps, depth))
2140 if(!smb_io_unihdr("forest", &info->hdr_forest_name, ps, depth))
2145 if ( !smb_io_uuid("dom_guid", &info->dom_guid, ps, depth) )
2150 if(!prs_uint32("dom_sid", ps, depth, &info->ptr_dom_sid))
2153 if(!smb_io_unistr2("nb_name", &info->uni_nb_dom_name,
2154 info->hdr_nb_dom_name.buffer, ps, depth))
2156 if(!smb_io_unistr2("dns_name", &info->uni_dns_dom_name,
2157 info->hdr_dns_dom_name.buffer, ps, depth))
2159 if(!smb_io_unistr2("forest", &info->uni_forest_name,
2160 info->hdr_forest_name.buffer, ps, depth))
2163 if(!smb_io_dom_sid2("dom_sid", &info->dom_sid, ps, depth))
2170 /*******************************************************************
2171 Inits an LSA_Q_QUERY_INFO2 structure.
2172 ********************************************************************/
2174 void init_q_query2(LSA_Q_QUERY_INFO2 *q_q, POLICY_HND *hnd, uint16 info_class)
2176 DEBUG(5, ("init_q_query2\n"));
2178 memcpy(&q_q->pol, hnd, sizeof(q_q->pol));
2180 q_q->info_class = info_class;
2183 /*******************************************************************
2184 Reads or writes an LSA_Q_QUERY_DNSDOMINFO structure.
2185 ********************************************************************/
2187 BOOL lsa_io_q_query_info2(const char *desc, LSA_Q_QUERY_INFO2 *q_c,
2188 prs_struct *ps, int depth)
2190 prs_debug(ps, depth, desc, "lsa_io_q_query_info2");
2196 if(!smb_io_pol_hnd("pol", &q_c->pol, ps, depth))
2199 if(!prs_uint16("info_class", ps, depth, &q_c->info_class))
2205 /*******************************************************************
2206 Reads or writes an LSA_R_QUERY_DNSDOMINFO structure.
2207 ********************************************************************/
2209 BOOL lsa_io_r_query_info2(const char *desc, LSA_R_QUERY_INFO2 *r_c,
2210 prs_struct *ps, int depth)
2212 prs_debug(ps, depth, desc, "lsa_io_r_query_info2");
2218 if(!prs_uint32("ptr", ps, depth, &r_c->ptr))
2220 if(!prs_uint16("info_class", ps, depth, &r_c->info_class))
2222 switch(r_c->info_class) {
2224 if (!lsa_io_dns_dom_info("info12", &r_c->info.dns_dom_info,
2229 DEBUG(0,("lsa_io_r_query_info2: unknown info class %d\n",
2236 if(!prs_ntstatus("status", ps, depth, &r_c->status))
2243 /*******************************************************************
2244 Inits an LSA_Q_ENUM_ACCT_RIGHTS structure.
2245 ********************************************************************/
2246 void init_q_enum_acct_rights(LSA_Q_ENUM_ACCT_RIGHTS *q_q,
2251 DEBUG(5, ("init_q_enum_acct_rights\n"));
2254 init_dom_sid2(&q_q->sid, sid);
2257 /*******************************************************************
2258 reads or writes a LSA_Q_ENUM_ACCT_RIGHTS structure.
2259 ********************************************************************/
2260 BOOL lsa_io_q_enum_acct_rights(const char *desc, LSA_Q_ENUM_ACCT_RIGHTS *q_q, prs_struct *ps, int depth)
2266 prs_debug(ps, depth, desc, "lsa_io_q_enum_acct_rights");
2269 if (!smb_io_pol_hnd("", &q_q->pol, ps, depth))
2272 if(!smb_io_dom_sid2("sid", &q_q->sid, ps, depth))
2279 /*******************************************************************
2280 reads or writes a LSA_R_ENUM_ACCT_RIGHTS structure.
2281 ********************************************************************/
2282 BOOL lsa_io_r_enum_acct_rights(const char *desc, LSA_R_ENUM_ACCT_RIGHTS *r_c, prs_struct *ps, int depth)
2284 prs_debug(ps, depth, desc, "lsa_io_r_enum_acct_rights");
2287 if(!prs_uint32("count ", ps, depth, &r_c->count))
2290 if(!smb_io_unistr2_array("rights", &r_c->rights, ps, depth))
2296 if(!prs_ntstatus("status", ps, depth, &r_c->status))
2303 /*******************************************************************
2304 Inits an LSA_Q_ADD_ACCT_RIGHTS structure.
2305 ********************************************************************/
2306 void init_q_add_acct_rights(LSA_Q_ADD_ACCT_RIGHTS *q_q,
2310 const char **rights)
2312 DEBUG(5, ("init_q_add_acct_rights\n"));
2315 init_dom_sid2(&q_q->sid, sid);
2316 init_unistr2_array(&q_q->rights, count, rights);
2321 /*******************************************************************
2322 reads or writes a LSA_Q_ADD_ACCT_RIGHTS structure.
2323 ********************************************************************/
2324 BOOL lsa_io_q_add_acct_rights(const char *desc, LSA_Q_ADD_ACCT_RIGHTS *q_q, prs_struct *ps, int depth)
2326 prs_debug(ps, depth, desc, "lsa_io_q_add_acct_rights");
2329 if (!smb_io_pol_hnd("", &q_q->pol, ps, depth))
2332 if(!smb_io_dom_sid2("sid", &q_q->sid, ps, depth))
2335 if(!prs_uint32("count", ps, depth, &q_q->rights.count))
2338 if(!smb_io_unistr2_array("rights", &q_q->rights, ps, depth))
2344 /*******************************************************************
2345 reads or writes a LSA_R_ENUM_ACCT_RIGHTS structure.
2346 ********************************************************************/
2347 BOOL lsa_io_r_add_acct_rights(const char *desc, LSA_R_ADD_ACCT_RIGHTS *r_c, prs_struct *ps, int depth)
2349 prs_debug(ps, depth, desc, "lsa_io_r_add_acct_rights");
2352 if(!prs_ntstatus("status", ps, depth, &r_c->status))
2359 /*******************************************************************
2360 Inits an LSA_Q_REMOVE_ACCT_RIGHTS structure.
2361 ********************************************************************/
2362 void init_q_remove_acct_rights(LSA_Q_REMOVE_ACCT_RIGHTS *q_q,
2367 const char **rights)
2369 DEBUG(5, ("init_q_remove_acct_rights\n"));
2372 init_dom_sid2(&q_q->sid, sid);
2373 q_q->removeall = removeall;
2374 init_unistr2_array(&q_q->rights, count, rights);
2379 /*******************************************************************
2380 reads or writes a LSA_Q_REMOVE_ACCT_RIGHTS structure.
2381 ********************************************************************/
2382 BOOL lsa_io_q_remove_acct_rights(const char *desc, LSA_Q_REMOVE_ACCT_RIGHTS *q_q, prs_struct *ps, int depth)
2384 prs_debug(ps, depth, desc, "lsa_io_q_remove_acct_rights");
2387 if (!smb_io_pol_hnd("", &q_q->pol, ps, depth))
2390 if(!smb_io_dom_sid2("sid", &q_q->sid, ps, depth))
2393 if(!prs_uint32("removeall", ps, depth, &q_q->removeall))
2396 if(!prs_uint32("count", ps, depth, &q_q->rights.count))
2399 if(!smb_io_unistr2_array("rights", &q_q->rights, ps, depth))
2405 /*******************************************************************
2406 reads or writes a LSA_R_ENUM_ACCT_RIGHTS structure.
2407 ********************************************************************/
2408 BOOL lsa_io_r_remove_acct_rights(const char *desc, LSA_R_REMOVE_ACCT_RIGHTS *r_c, prs_struct *ps, int depth)
2410 prs_debug(ps, depth, desc, "lsa_io_r_remove_acct_rights");
2413 if(!prs_ntstatus("status", ps, depth, &r_c->status))