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.
9 * Copyright (C) Gerald )Jerry) Carter 2005
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 3 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, see <http://www.gnu.org/licenses/>.
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);
31 static bool lsa_io_trans_names2(const char *desc, LSA_TRANS_NAME_ENUM2 *trn, prs_struct *ps, int depth);
33 /*******************************************************************
34 Inits a LSA_TRANS_NAME structure.
35 ********************************************************************/
37 void init_lsa_trans_name(LSA_TRANS_NAME *trn, UNISTR2 *uni_name,
38 uint16 sid_name_use, const char *name, uint32 idx)
40 trn->sid_name_use = sid_name_use;
41 init_unistr2(uni_name, name, UNI_FLAGS_NONE);
42 init_uni_hdr(&trn->hdr_name, uni_name);
43 trn->domain_idx = idx;
46 /*******************************************************************
47 Reads or writes a LSA_TRANS_NAME structure.
48 ********************************************************************/
50 static bool lsa_io_trans_name(const char *desc, LSA_TRANS_NAME *trn, prs_struct *ps,
53 prs_debug(ps, depth, desc, "lsa_io_trans_name");
59 if(!prs_uint16("sid_name_use", ps, depth, &trn->sid_name_use))
64 if(!smb_io_unihdr ("hdr_name", &trn->hdr_name, ps, depth))
66 if(!prs_uint32("domain_idx ", ps, depth, &trn->domain_idx))
72 /*******************************************************************
73 Inits a LSA_TRANS_NAME2 structure.
74 ********************************************************************/
76 void init_lsa_trans_name2(LSA_TRANS_NAME2 *trn, UNISTR2 *uni_name,
77 uint16 sid_name_use, const char *name, uint32 idx)
79 trn->sid_name_use = sid_name_use;
80 init_unistr2(uni_name, name, UNI_FLAGS_NONE);
81 init_uni_hdr(&trn->hdr_name, uni_name);
82 trn->domain_idx = idx;
86 /*******************************************************************
87 Reads or writes a LSA_TRANS_NAME2 structure.
88 ********************************************************************/
90 static bool lsa_io_trans_name2(const char *desc, LSA_TRANS_NAME2 *trn, prs_struct *ps,
93 prs_debug(ps, depth, desc, "lsa_io_trans_name2");
99 if(!prs_uint16("sid_name_use", ps, depth, &trn->sid_name_use))
104 if(!smb_io_unihdr ("hdr_name", &trn->hdr_name, ps, depth))
106 if(!prs_uint32("domain_idx ", ps, depth, &trn->domain_idx))
108 if(!prs_uint32("unknown ", ps, depth, &trn->unknown))
114 /*******************************************************************
115 Reads or writes a DOM_R_REF structure.
116 ********************************************************************/
118 static bool lsa_io_dom_r_ref(const char *desc, DOM_R_REF *dom, prs_struct *ps, int depth)
122 prs_debug(ps, depth, desc, "lsa_io_dom_r_ref");
128 if(!prs_uint32("num_ref_doms_1", ps, depth, &dom->num_ref_doms_1)) /* num referenced domains? */
130 if(!prs_uint32("ptr_ref_dom ", ps, depth, &dom->ptr_ref_dom)) /* undocumented buffer pointer. */
132 if(!prs_uint32("max_entries ", ps, depth, &dom->max_entries)) /* 32 - max number of entries */
135 SMB_ASSERT_ARRAY(dom->hdr_ref_dom, dom->num_ref_doms_1);
137 if (dom->ptr_ref_dom != 0) {
139 if(!prs_uint32("num_ref_doms_2", ps, depth, &dom->num_ref_doms_2)) /* 4 - num referenced domains? */
142 SMB_ASSERT_ARRAY(dom->ref_dom, dom->num_ref_doms_2);
144 for (i = 0; i < dom->num_ref_doms_1; i++) {
147 slprintf(t, sizeof(t) - 1, "dom_ref[%d] ", i);
148 if(!smb_io_unihdr(t, &dom->hdr_ref_dom[i].hdr_dom_name, ps, depth))
151 slprintf(t, sizeof(t) - 1, "sid_ptr[%d] ", i);
152 if(!prs_uint32(t, ps, depth, &dom->hdr_ref_dom[i].ptr_dom_sid))
156 for (i = 0; i < dom->num_ref_doms_2; i++) {
159 if (dom->hdr_ref_dom[i].hdr_dom_name.buffer != 0) {
160 slprintf(t, sizeof(t) - 1, "dom_ref[%d] ", i);
161 if(!smb_io_unistr2(t, &dom->ref_dom[i].uni_dom_name, True, ps, depth)) /* domain name unicode string */
167 if (dom->hdr_ref_dom[i].ptr_dom_sid != 0) {
168 slprintf(t, sizeof(t) - 1, "sid_ptr[%d] ", i);
169 if(!smb_io_dom_sid2(t, &dom->ref_dom[i].ref_dom, ps, depth)) /* referenced domain SIDs */
178 /*******************************************************************
179 Inits an LSA_SEC_QOS structure.
180 ********************************************************************/
182 void init_lsa_sec_qos(LSA_SEC_QOS *qos, uint16 imp_lev, uint8 ctxt, uint8 eff)
184 DEBUG(5, ("init_lsa_sec_qos\n"));
186 qos->len = 0x0c; /* length of quality of service block, in bytes */
187 qos->sec_imp_level = imp_lev;
188 qos->sec_ctxt_mode = ctxt;
189 qos->effective_only = eff;
192 /*******************************************************************
193 Reads or writes an LSA_SEC_QOS structure.
194 ********************************************************************/
196 static bool lsa_io_sec_qos(const char *desc, LSA_SEC_QOS *qos, prs_struct *ps,
201 prs_debug(ps, depth, desc, "lsa_io_obj_qos");
207 start = prs_offset(ps);
209 /* these pointers had _better_ be zero, because we don't know
212 if(!prs_uint32("len ", ps, depth, &qos->len)) /* 0x18 - length (in bytes) inc. the length field. */
214 if(!prs_uint16("sec_imp_level ", ps, depth, &qos->sec_imp_level ))
216 if(!prs_uint8 ("sec_ctxt_mode ", ps, depth, &qos->sec_ctxt_mode ))
218 if(!prs_uint8 ("effective_only", ps, depth, &qos->effective_only))
221 if (qos->len != prs_offset(ps) - start) {
222 DEBUG(3,("lsa_io_sec_qos: length %x does not match size %x\n",
223 qos->len, prs_offset(ps) - start));
229 /*******************************************************************
230 Inits an LSA_OBJ_ATTR structure.
231 ********************************************************************/
233 static void init_lsa_obj_attr(LSA_OBJ_ATTR *attr, uint32 attributes, LSA_SEC_QOS *qos)
235 DEBUG(5, ("init_lsa_obj_attr\n"));
237 attr->len = 0x18; /* length of object attribute block, in bytes */
238 attr->ptr_root_dir = 0;
239 attr->ptr_obj_name = 0;
240 attr->attributes = attributes;
241 attr->ptr_sec_desc = 0;
244 attr->ptr_sec_qos = 1;
247 attr->ptr_sec_qos = 0;
248 attr->sec_qos = NULL;
252 /*******************************************************************
253 Reads or writes an LSA_OBJ_ATTR structure.
254 ********************************************************************/
256 static bool lsa_io_obj_attr(const char *desc, LSA_OBJ_ATTR *attr, prs_struct *ps,
259 prs_debug(ps, depth, desc, "lsa_io_obj_attr");
265 /* these pointers had _better_ be zero, because we don't know
268 if(!prs_uint32("len ", ps, depth, &attr->len)) /* 0x18 - length (in bytes) inc. the length field. */
270 if(!prs_uint32("ptr_root_dir", ps, depth, &attr->ptr_root_dir)) /* 0 - root directory (pointer) */
272 if(!prs_uint32("ptr_obj_name", ps, depth, &attr->ptr_obj_name)) /* 0 - object name (pointer) */
274 if(!prs_uint32("attributes ", ps, depth, &attr->attributes)) /* 0 - attributes (undocumented) */
276 if(!prs_uint32("ptr_sec_desc", ps, depth, &attr->ptr_sec_desc)) /* 0 - security descriptior (pointer) */
278 if(!prs_uint32("ptr_sec_qos ", ps, depth, &attr->ptr_sec_qos )) /* security quality of service (pointer) */
281 if (attr->ptr_sec_qos != 0) {
282 if (UNMARSHALLING(ps))
283 if (!(attr->sec_qos = PRS_ALLOC_MEM(ps,LSA_SEC_QOS,1)))
286 if(!lsa_io_sec_qos("sec_qos", attr->sec_qos, ps, depth))
294 /*******************************************************************
295 Inits an LSA_Q_OPEN_POL structure.
296 ********************************************************************/
298 void init_q_open_pol(LSA_Q_OPEN_POL *in, uint16 system_name,
299 uint32 attributes, uint32 desired_access,
302 DEBUG(5, ("init_open_pol: attr:%d da:%d\n", attributes,
305 in->ptr = 1; /* undocumented pointer */
307 in->des_access = desired_access;
309 in->system_name = system_name;
310 init_lsa_obj_attr(&in->attr, attributes, qos);
313 /*******************************************************************
314 Reads or writes an LSA_Q_OPEN_POL structure.
315 ********************************************************************/
317 bool lsa_io_q_open_pol(const char *desc, LSA_Q_OPEN_POL *in, prs_struct *ps,
320 prs_debug(ps, depth, desc, "lsa_io_q_open_pol");
323 if(!prs_uint32("ptr ", ps, depth, &in->ptr))
325 if(!prs_uint16("system_name", ps, depth, &in->system_name))
330 if(!lsa_io_obj_attr("", &in->attr, ps, depth))
333 if(!prs_uint32("des_access", ps, depth, &in->des_access))
339 /*******************************************************************
340 Reads or writes an LSA_R_OPEN_POL structure.
341 ********************************************************************/
343 bool lsa_io_r_open_pol(const char *desc, LSA_R_OPEN_POL *out, prs_struct *ps,
346 prs_debug(ps, depth, desc, "lsa_io_r_open_pol");
349 if(!smb_io_pol_hnd("", &out->pol, ps, depth))
352 if(!prs_ntstatus("status", ps, depth, &out->status))
358 /*******************************************************************
359 Inits an LSA_Q_OPEN_POL2 structure.
360 ********************************************************************/
362 void init_q_open_pol2(LSA_Q_OPEN_POL2 *in, const char *server_name,
363 uint32 attributes, uint32 desired_access,
366 DEBUG(5, ("init_q_open_pol2: attr:%d da:%d\n", attributes,
369 in->ptr = 1; /* undocumented pointer */
371 in->des_access = desired_access;
373 init_unistr2(&in->uni_server_name, server_name, UNI_STR_TERMINATE);
375 init_lsa_obj_attr(&in->attr, attributes, qos);
378 /*******************************************************************
379 Reads or writes an LSA_Q_OPEN_POL2 structure.
380 ********************************************************************/
382 bool lsa_io_q_open_pol2(const char *desc, LSA_Q_OPEN_POL2 *in, prs_struct *ps,
385 prs_debug(ps, depth, desc, "lsa_io_q_open_pol2");
388 if(!prs_uint32("ptr ", ps, depth, &in->ptr))
391 if(!smb_io_unistr2 ("", &in->uni_server_name, in->ptr, ps, depth))
393 if(!lsa_io_obj_attr("", &in->attr, ps, depth))
396 if(!prs_uint32("des_access", ps, depth, &in->des_access))
402 /*******************************************************************
403 Reads or writes an LSA_R_OPEN_POL2 structure.
404 ********************************************************************/
406 bool lsa_io_r_open_pol2(const char *desc, LSA_R_OPEN_POL2 *out, prs_struct *ps,
409 prs_debug(ps, depth, desc, "lsa_io_r_open_pol2");
412 if(!smb_io_pol_hnd("", &out->pol, ps, depth))
415 if(!prs_ntstatus("status", ps, depth, &out->status))
421 /*******************************************************************
422 makes an LSA_Q_ENUM_TRUST_DOM structure.
423 ********************************************************************/
424 bool init_q_enum_trust_dom(LSA_Q_ENUM_TRUST_DOM * q_e, POLICY_HND *pol,
425 uint32 enum_context, uint32 preferred_len)
427 DEBUG(5, ("init_q_enum_trust_dom\n"));
430 q_e->enum_context = enum_context;
431 q_e->preferred_len = preferred_len;
436 /*******************************************************************
437 Reads or writes an LSA_Q_ENUM_TRUST_DOM structure.
438 ********************************************************************/
440 bool lsa_io_q_enum_trust_dom(const char *desc, LSA_Q_ENUM_TRUST_DOM *q_e,
441 prs_struct *ps, int depth)
443 prs_debug(ps, depth, desc, "lsa_io_q_enum_trust_dom");
446 if(!smb_io_pol_hnd("", &q_e->pol, ps, depth))
449 if(!prs_uint32("enum_context ", ps, depth, &q_e->enum_context))
451 if(!prs_uint32("preferred_len", ps, depth, &q_e->preferred_len))
457 /*******************************************************************
458 Inits an LSA_R_ENUM_TRUST_DOM structure.
459 ********************************************************************/
461 void init_r_enum_trust_dom(TALLOC_CTX *ctx, LSA_R_ENUM_TRUST_DOM *out,
462 uint32 enum_context, uint32 num_domains,
463 struct trustdom_info **td)
467 DEBUG(5, ("init_r_enum_trust_dom\n"));
469 out->enum_context = enum_context;
470 out->count = num_domains;
472 if ( num_domains != 0 ) {
474 /* allocate container memory */
476 out->domlist = TALLOC_P( ctx, DOMAIN_LIST );
478 if ( !out->domlist ) {
479 out->status = NT_STATUS_NO_MEMORY;
484 out->domlist->domains = TALLOC_ARRAY( ctx, DOMAIN_INFO,
486 if ( !out->domlist->domains ) {
487 out->status = NT_STATUS_NO_MEMORY;
491 out->domlist->domains = NULL;
494 out->domlist->count = out->count;
496 /* initialize the list of domains and their sid */
498 for (i = 0; i < num_domains; i++) {
500 if ( !(out->domlist->domains[i].sid =
501 TALLOC_P(ctx, DOM_SID2)) ) {
502 out->status = NT_STATUS_NO_MEMORY;
506 init_dom_sid2(out->domlist->domains[i].sid,
508 if (push_ucs2_talloc(ctx, &name, (td[i])->name) == (size_t)-1){
509 out->status = NT_STATUS_NO_MEMORY;
512 init_unistr4_w(ctx, &out->domlist->domains[i].name,
519 /*******************************************************************
520 ********************************************************************/
522 bool lsa_io_domain_list( const char *desc, prs_struct *ps, int depth, DOMAIN_LIST *domlist )
526 prs_debug(ps, depth, desc, "lsa_io_domain_list");
529 if(!prs_uint32("count", ps, depth, &domlist->count))
532 if ( domlist->count == 0 )
535 if ( UNMARSHALLING(ps) ) {
536 if ( !(domlist->domains = PRS_ALLOC_MEM( ps, DOMAIN_INFO, domlist->count )) )
542 for ( i=0; i<domlist->count; i++ ) {
543 if ( !prs_unistr4_hdr("name_header", ps, depth, &domlist->domains[i].name) )
545 if ( !smb_io_dom_sid2_p("sid_header", ps, depth, &domlist->domains[i].sid) )
551 for ( i=0; i<domlist->count; i++ ) {
552 if ( !prs_unistr4_str("name", ps, depth, &domlist->domains[i].name) )
554 if( !smb_io_dom_sid2("sid", domlist->domains[i].sid, ps, depth) )
561 /*******************************************************************
562 Reads or writes an LSA_R_ENUM_TRUST_DOM structure.
563 ********************************************************************/
565 bool lsa_io_r_enum_trust_dom(const char *desc, LSA_R_ENUM_TRUST_DOM *out,
566 prs_struct *ps, int depth)
568 prs_debug(ps, depth, desc, "lsa_io_r_enum_trust_dom");
571 if(!prs_uint32("enum_context", ps, depth, &out->enum_context))
574 if(!prs_uint32("count", ps, depth, &out->count))
577 if ( !prs_pointer("trusted_domains", ps, depth, (void*)&out->domlist, sizeof(DOMAIN_LIST), (PRS_POINTER_CAST)lsa_io_domain_list))
580 if(!prs_ntstatus("status", ps, depth, &out->status))
586 /*******************************************************************
587 Inits a LSA_SID_ENUM structure.
588 ********************************************************************/
590 static void init_lsa_sid_enum(TALLOC_CTX *mem_ctx, LSA_SID_ENUM *sen,
591 int num_entries, const DOM_SID *sids)
595 DEBUG(5, ("init_lsa_sid_enum\n"));
597 sen->num_entries = num_entries;
598 sen->ptr_sid_enum = (num_entries != 0);
599 sen->num_entries2 = num_entries;
601 /* Allocate memory for sids and sid pointers */
604 if ((sen->ptr_sid = TALLOC_ZERO_ARRAY(mem_ctx, uint32, num_entries )) == NULL) {
605 DEBUG(3, ("init_lsa_sid_enum(): out of memory for ptr_sid\n"));
609 if ((sen->sid = TALLOC_ZERO_ARRAY(mem_ctx, DOM_SID2, num_entries)) == NULL) {
610 DEBUG(3, ("init_lsa_sid_enum(): out of memory for sids\n"));
615 /* Copy across SIDs and SID pointers */
617 for (i = 0; i < num_entries; i++) {
619 init_dom_sid2(&sen->sid[i], &sids[i]);
623 /*******************************************************************
624 Reads or writes a LSA_SID_ENUM structure.
625 ********************************************************************/
627 static bool lsa_io_sid_enum(const char *desc, LSA_SID_ENUM *sen, prs_struct *ps,
632 prs_debug(ps, depth, desc, "lsa_io_sid_enum");
638 if(!prs_uint32("num_entries ", ps, depth, &sen->num_entries))
640 if(!prs_uint32("ptr_sid_enum", ps, depth, &sen->ptr_sid_enum))
644 if the ptr is NULL, leave here. checked from a real w2k trace.
648 if (sen->ptr_sid_enum==0)
651 if(!prs_uint32("num_entries2", ps, depth, &sen->num_entries2))
654 /* Mallocate memory if we're unpacking from the wire */
656 if (UNMARSHALLING(ps) && sen->num_entries) {
657 if ((sen->ptr_sid = PRS_ALLOC_MEM( ps, uint32, sen->num_entries)) == NULL) {
658 DEBUG(3, ("init_lsa_sid_enum(): out of memory for "
663 if ((sen->sid = PRS_ALLOC_MEM( ps, DOM_SID2, sen->num_entries)) == NULL) {
664 DEBUG(3, ("init_lsa_sid_enum(): out of memory for "
670 for (i = 0; i < sen->num_entries; i++) {
673 slprintf(temp, sizeof(temp) - 1, "ptr_sid[%d]", i);
674 if(!prs_uint32(temp, ps, depth, &sen->ptr_sid[i])) {
679 for (i = 0; i < sen->num_entries; i++) {
682 slprintf(temp, sizeof(temp) - 1, "sid[%d]", i);
683 if(!smb_io_dom_sid2(temp, &sen->sid[i], ps, depth)) {
691 /*******************************************************************
692 Inits an LSA_R_ENUM_TRUST_DOM structure.
693 ********************************************************************/
695 void init_q_lookup_sids(TALLOC_CTX *mem_ctx, LSA_Q_LOOKUP_SIDS *q_l,
696 POLICY_HND *hnd, int num_sids, const DOM_SID *sids,
699 DEBUG(5, ("init_q_lookup_sids\n"));
703 memcpy(&q_l->pol, hnd, sizeof(q_l->pol));
704 init_lsa_sid_enum(mem_ctx, &q_l->sids, num_sids, sids);
709 /*******************************************************************
710 Reads or writes a LSA_Q_LOOKUP_SIDS structure.
711 ********************************************************************/
713 bool lsa_io_q_lookup_sids(const char *desc, LSA_Q_LOOKUP_SIDS *q_s, prs_struct *ps,
716 prs_debug(ps, depth, desc, "lsa_io_q_lookup_sids");
722 if(!smb_io_pol_hnd("pol_hnd", &q_s->pol, ps, depth)) /* policy handle */
724 if(!lsa_io_sid_enum("sids ", &q_s->sids, ps, depth)) /* sids to be looked up */
726 if(!lsa_io_trans_names("names ", &q_s->names, ps, depth)) /* translated names */
729 if(!prs_uint16("level", ps, depth, &q_s->level)) /* lookup level */
734 if(!prs_uint32("mapped_count", ps, depth, &q_s->mapped_count))
740 /*******************************************************************
741 Reads or writes a LSA_Q_LOOKUP_SIDS2 structure.
742 ********************************************************************/
744 bool lsa_io_q_lookup_sids2(const char *desc, LSA_Q_LOOKUP_SIDS2 *q_s, prs_struct *ps,
747 prs_debug(ps, depth, desc, "lsa_io_q_lookup_sids2");
753 if(!smb_io_pol_hnd("pol_hnd", &q_s->pol, ps, depth)) /* policy handle */
755 if(!lsa_io_sid_enum("sids ", &q_s->sids, ps, depth)) /* sids to be looked up */
757 if(!lsa_io_trans_names2("names ", &q_s->names, ps, depth)) /* translated names */
760 if(!prs_uint16("level", ps, depth, &q_s->level)) /* lookup level */
765 if(!prs_uint32("mapped_count", ps, depth, &q_s->mapped_count))
767 if(!prs_uint32("unknown1", ps, depth, &q_s->unknown1))
769 if(!prs_uint32("unknown2", ps, depth, &q_s->unknown2))
775 /*******************************************************************
776 Reads or writes a LSA_Q_LOOKUP_SIDS3 structure.
777 ********************************************************************/
779 bool lsa_io_q_lookup_sids3(const char *desc, LSA_Q_LOOKUP_SIDS3 *q_s, prs_struct *ps,
782 prs_debug(ps, depth, desc, "lsa_io_q_lookup_sids3");
788 if(!lsa_io_sid_enum("sids ", &q_s->sids, ps, depth)) /* sids to be looked up */
790 if(!lsa_io_trans_names2("names ", &q_s->names, ps, depth)) /* translated names */
793 if(!prs_uint16("level", ps, depth, &q_s->level)) /* lookup level */
798 if(!prs_uint32("mapped_count", ps, depth, &q_s->mapped_count))
800 if(!prs_uint32("unknown1", ps, depth, &q_s->unknown1))
802 if(!prs_uint32("unknown2", ps, depth, &q_s->unknown2))
809 /*******************************************************************
810 Reads or writes a structure.
811 ********************************************************************/
813 static bool lsa_io_trans_names(const char *desc, LSA_TRANS_NAME_ENUM *trn,
814 prs_struct *ps, int depth)
818 prs_debug(ps, depth, desc, "lsa_io_trans_names");
824 if(!prs_uint32("num_entries ", ps, depth, &trn->num_entries))
826 if(!prs_uint32("ptr_trans_names", ps, depth, &trn->ptr_trans_names))
829 if (trn->ptr_trans_names != 0) {
830 if(!prs_uint32("num_entries2 ", ps, depth,
834 if (trn->num_entries2 != trn->num_entries) {
839 if (UNMARSHALLING(ps) && trn->num_entries2) {
840 if ((trn->name = PRS_ALLOC_MEM(ps, LSA_TRANS_NAME, trn->num_entries2)) == NULL) {
844 if ((trn->uni_name = PRS_ALLOC_MEM(ps, UNISTR2, trn->num_entries2)) == NULL) {
849 for (i = 0; i < trn->num_entries2; i++) {
851 slprintf(t, sizeof(t) - 1, "name[%d] ", i);
853 if(!lsa_io_trans_name(t, &trn->name[i], ps, depth)) /* translated name */
857 for (i = 0; i < trn->num_entries2; i++) {
859 slprintf(t, sizeof(t) - 1, "name[%d] ", i);
861 if(!smb_io_unistr2(t, &trn->uni_name[i], trn->name[i].hdr_name.buffer, ps, depth))
871 /*******************************************************************
872 Reads or writes a structure.
873 ********************************************************************/
875 static bool lsa_io_trans_names2(const char *desc, LSA_TRANS_NAME_ENUM2 *trn,
876 prs_struct *ps, int depth)
880 prs_debug(ps, depth, desc, "lsa_io_trans_names2");
886 if(!prs_uint32("num_entries ", ps, depth, &trn->num_entries))
888 if(!prs_uint32("ptr_trans_names", ps, depth, &trn->ptr_trans_names))
891 if (trn->ptr_trans_names != 0) {
892 if(!prs_uint32("num_entries2 ", ps, depth,
896 if (trn->num_entries2 != trn->num_entries) {
901 if (UNMARSHALLING(ps) && trn->num_entries2) {
902 if ((trn->name = PRS_ALLOC_MEM(ps, LSA_TRANS_NAME2, trn->num_entries2)) == NULL) {
906 if ((trn->uni_name = PRS_ALLOC_MEM(ps, UNISTR2, trn->num_entries2)) == NULL) {
911 for (i = 0; i < trn->num_entries2; i++) {
913 slprintf(t, sizeof(t) - 1, "name[%d] ", i);
915 if(!lsa_io_trans_name2(t, &trn->name[i], ps, depth)) /* translated name */
919 for (i = 0; i < trn->num_entries2; i++) {
921 slprintf(t, sizeof(t) - 1, "name[%d] ", i);
923 if(!smb_io_unistr2(t, &trn->uni_name[i], trn->name[i].hdr_name.buffer, ps, depth))
934 /*******************************************************************
935 Reads or writes a structure.
936 ********************************************************************/
938 bool lsa_io_r_lookup_sids(const char *desc, LSA_R_LOOKUP_SIDS *r_s,
939 prs_struct *ps, int depth)
941 prs_debug(ps, depth, desc, "lsa_io_r_lookup_sids");
947 if(!prs_uint32("ptr_dom_ref", ps, depth, &r_s->ptr_dom_ref))
950 if (r_s->ptr_dom_ref != 0)
951 if(!lsa_io_dom_r_ref ("dom_ref", r_s->dom_ref, ps, depth)) /* domain reference info */
954 if(!lsa_io_trans_names("names ", &r_s->names, ps, depth)) /* translated names */
960 if(!prs_uint32("mapped_count", ps, depth, &r_s->mapped_count))
963 if(!prs_ntstatus("status ", ps, depth, &r_s->status))
969 /*******************************************************************
970 Reads or writes a structure.
971 ********************************************************************/
973 bool lsa_io_r_lookup_sids2(const char *desc, LSA_R_LOOKUP_SIDS2 *r_s,
974 prs_struct *ps, int depth)
976 prs_debug(ps, depth, desc, "lsa_io_r_lookup_sids2");
982 if(!prs_uint32("ptr_dom_ref", ps, depth, &r_s->ptr_dom_ref))
985 if (r_s->ptr_dom_ref != 0)
986 if(!lsa_io_dom_r_ref ("dom_ref", r_s->dom_ref, ps, depth)) /* domain reference info */
989 if(!lsa_io_trans_names2("names ", &r_s->names, ps, depth)) /* translated names */
995 if(!prs_uint32("mapped_count", ps, depth, &r_s->mapped_count))
998 if(!prs_ntstatus("status ", ps, depth, &r_s->status))
1005 /*******************************************************************
1006 Reads or writes a structure.
1007 ********************************************************************/
1009 bool lsa_io_r_lookup_sids3(const char *desc, LSA_R_LOOKUP_SIDS3 *r_s,
1010 prs_struct *ps, int depth)
1012 prs_debug(ps, depth, desc, "lsa_io_r_lookup_sids3");
1018 if(!prs_uint32("ptr_dom_ref", ps, depth, &r_s->ptr_dom_ref))
1021 if (r_s->ptr_dom_ref != 0)
1022 if(!lsa_io_dom_r_ref ("dom_ref", r_s->dom_ref, ps, depth)) /* domain reference info */
1025 if(!lsa_io_trans_names2("names ", &r_s->names, ps, depth)) /* translated names */
1031 if(!prs_uint32("mapped_count", ps, depth, &r_s->mapped_count))
1034 if(!prs_ntstatus("status ", ps, depth, &r_s->status))
1040 /*******************************************************************
1042 ********************************************************************/
1044 void init_q_lookup_names(TALLOC_CTX *mem_ctx, LSA_Q_LOOKUP_NAMES *q_l,
1045 POLICY_HND *hnd, int num_names, const char **names,
1050 DEBUG(5, ("init_q_lookup_names\n"));
1055 q_l->num_entries = num_names;
1056 q_l->num_entries2 = num_names;
1057 q_l->lookup_level = level;
1060 if ((q_l->uni_name = TALLOC_ZERO_ARRAY(mem_ctx, UNISTR2, num_names)) == NULL) {
1061 DEBUG(3, ("init_q_lookup_names(): out of memory\n"));
1065 if ((q_l->hdr_name = TALLOC_ZERO_ARRAY(mem_ctx, UNIHDR, num_names)) == NULL) {
1066 DEBUG(3, ("init_q_lookup_names(): out of memory\n"));
1070 q_l->uni_name = NULL;
1071 q_l->hdr_name = NULL;
1074 for (i = 0; i < num_names; i++) {
1075 init_unistr2(&q_l->uni_name[i], names[i], UNI_FLAGS_NONE);
1076 init_uni_hdr(&q_l->hdr_name[i], &q_l->uni_name[i]);
1080 /*******************************************************************
1081 reads or writes a structure.
1082 ********************************************************************/
1084 bool lsa_io_q_lookup_names(const char *desc, LSA_Q_LOOKUP_NAMES *q_r,
1085 prs_struct *ps, int depth)
1089 prs_debug(ps, depth, desc, "lsa_io_q_lookup_names");
1095 if(!smb_io_pol_hnd("", &q_r->pol, ps, depth)) /* policy handle */
1100 if(!prs_uint32("num_entries ", ps, depth, &q_r->num_entries))
1102 if(!prs_uint32("num_entries2 ", ps, depth, &q_r->num_entries2))
1105 if (UNMARSHALLING(ps)) {
1106 if (q_r->num_entries) {
1107 if ((q_r->hdr_name = PRS_ALLOC_MEM(ps, UNIHDR, q_r->num_entries)) == NULL)
1109 if ((q_r->uni_name = PRS_ALLOC_MEM(ps, UNISTR2, q_r->num_entries)) == NULL)
1114 for (i = 0; i < q_r->num_entries; i++) {
1117 if(!smb_io_unihdr("hdr_name", &q_r->hdr_name[i], ps, depth)) /* pointer names */
1121 for (i = 0; i < q_r->num_entries; i++) {
1124 if(!smb_io_unistr2("dom_name", &q_r->uni_name[i], q_r->hdr_name[i].buffer, ps, depth)) /* names to be looked up */
1130 if(!prs_uint32("num_trans_entries ", ps, depth, &q_r->num_trans_entries))
1132 if(!prs_uint32("ptr_trans_sids ", ps, depth, &q_r->ptr_trans_sids))
1134 if(!prs_uint16("lookup_level ", ps, depth, &q_r->lookup_level))
1138 if(!prs_uint32("mapped_count ", ps, depth, &q_r->mapped_count))
1144 /*******************************************************************
1145 reads or writes a structure.
1146 ********************************************************************/
1148 bool lsa_io_r_lookup_names(const char *desc, LSA_R_LOOKUP_NAMES *out, prs_struct *ps, int depth)
1152 prs_debug(ps, depth, desc, "lsa_io_r_lookup_names");
1158 if(!prs_uint32("ptr_dom_ref", ps, depth, &out->ptr_dom_ref))
1161 if (out->ptr_dom_ref != 0)
1162 if(!lsa_io_dom_r_ref("", out->dom_ref, ps, depth))
1165 if(!prs_uint32("num_entries", ps, depth, &out->num_entries))
1167 if(!prs_uint32("ptr_entries", ps, depth, &out->ptr_entries))
1170 if (out->ptr_entries != 0) {
1171 if(!prs_uint32("num_entries2", ps, depth, &out->num_entries2))
1174 if (out->num_entries2 != out->num_entries) {
1179 if (UNMARSHALLING(ps) && out->num_entries2) {
1180 if ((out->dom_rid = PRS_ALLOC_MEM(ps, DOM_RID, out->num_entries2))
1182 DEBUG(3, ("lsa_io_r_lookup_names(): out of memory\n"));
1187 for (i = 0; i < out->num_entries2; i++)
1188 if(!smb_io_dom_rid("", &out->dom_rid[i], ps, depth)) /* domain RIDs being looked up */
1192 if(!prs_uint32("mapped_count", ps, depth, &out->mapped_count))
1195 if(!prs_ntstatus("status ", ps, depth, &out->status))
1201 /*******************************************************************
1202 reads or writes a structure.
1203 ********************************************************************/
1205 bool lsa_io_q_lookup_names2(const char *desc, LSA_Q_LOOKUP_NAMES2 *q_r,
1206 prs_struct *ps, int depth)
1210 prs_debug(ps, depth, desc, "lsa_io_q_lookup_names2");
1216 if(!smb_io_pol_hnd("", &q_r->pol, ps, depth)) /* policy handle */
1221 if(!prs_uint32("num_entries ", ps, depth, &q_r->num_entries))
1223 if(!prs_uint32("num_entries2 ", ps, depth, &q_r->num_entries2))
1226 if (UNMARSHALLING(ps)) {
1227 if (q_r->num_entries) {
1228 if ((q_r->hdr_name = PRS_ALLOC_MEM(ps, UNIHDR, q_r->num_entries)) == NULL)
1230 if ((q_r->uni_name = PRS_ALLOC_MEM(ps, UNISTR2, q_r->num_entries)) == NULL)
1235 for (i = 0; i < q_r->num_entries; i++) {
1238 if(!smb_io_unihdr("hdr_name", &q_r->hdr_name[i], ps, depth)) /* pointer names */
1242 for (i = 0; i < q_r->num_entries; i++) {
1245 if(!smb_io_unistr2("dom_name", &q_r->uni_name[i], q_r->hdr_name[i].buffer, ps, depth)) /* names to be looked up */
1251 if(!prs_uint32("num_trans_entries ", ps, depth, &q_r->num_trans_entries))
1253 if(!prs_uint32("ptr_trans_sids ", ps, depth, &q_r->ptr_trans_sids))
1255 if(!prs_uint16("lookup_level ", ps, depth, &q_r->lookup_level))
1259 if(!prs_uint32("mapped_count ", ps, depth, &q_r->mapped_count))
1261 if(!prs_uint32("unknown1 ", ps, depth, &q_r->unknown1))
1263 if(!prs_uint32("unknown2 ", ps, depth, &q_r->unknown2))
1269 /*******************************************************************
1270 reads or writes a structure.
1271 ********************************************************************/
1273 bool lsa_io_r_lookup_names2(const char *desc, LSA_R_LOOKUP_NAMES2 *out, prs_struct *ps, int depth)
1277 prs_debug(ps, depth, desc, "lsa_io_r_lookup_names2");
1283 if(!prs_uint32("ptr_dom_ref", ps, depth, &out->ptr_dom_ref))
1286 if (out->ptr_dom_ref != 0)
1287 if(!lsa_io_dom_r_ref("", out->dom_ref, ps, depth))
1290 if(!prs_uint32("num_entries", ps, depth, &out->num_entries))
1292 if(!prs_uint32("ptr_entries", ps, depth, &out->ptr_entries))
1295 if (out->ptr_entries != 0) {
1296 if(!prs_uint32("num_entries2", ps, depth, &out->num_entries2))
1299 if (out->num_entries2 != out->num_entries) {
1304 if (UNMARSHALLING(ps) && out->num_entries2) {
1305 if ((out->dom_rid = PRS_ALLOC_MEM(ps, DOM_RID2, out->num_entries2))
1307 DEBUG(3, ("lsa_io_r_lookup_names2(): out of memory\n"));
1312 for (i = 0; i < out->num_entries2; i++)
1313 if(!smb_io_dom_rid2("", &out->dom_rid[i], ps, depth)) /* domain RIDs being looked up */
1317 if(!prs_uint32("mapped_count", ps, depth, &out->mapped_count))
1320 if(!prs_ntstatus("status ", ps, depth, &out->status))
1326 /*******************************************************************
1327 Internal lsa data type io.
1328 Following pass must read DOM_SID2 types.
1329 ********************************************************************/
1331 bool smb_io_lsa_translated_sids3(const char *desc, LSA_TRANSLATED_SID3 *q_r,
1332 prs_struct *ps, int depth)
1334 prs_debug(ps, depth, desc, "smb_io_lsa_translated_sids3");
1339 if(!prs_uint8 ("sid_type ", ps, depth, &q_r->sid_type ))
1343 /* Second pass will read/write these. */
1344 if (!smb_io_dom_sid2_p("sid_header", ps, depth, &q_r->sid2))
1346 if(!prs_uint32("sid_idx ", ps, depth, &q_r->sid_idx ))
1348 if(!prs_uint32("unknown ", ps, depth, &q_r->unknown ))
1354 /*******************************************************************
1355 Identical to lsa_io_q_lookup_names2.
1356 ********************************************************************/
1358 bool lsa_io_q_lookup_names3(const char *desc, LSA_Q_LOOKUP_NAMES3 *q_r,
1359 prs_struct *ps, int depth)
1363 prs_debug(ps, depth, desc, "lsa_io_q_lookup_names3");
1369 if(!smb_io_pol_hnd("", &q_r->pol, ps, depth)) /* policy handle */
1374 if(!prs_uint32("num_entries ", ps, depth, &q_r->num_entries))
1376 if(!prs_uint32("num_entries2 ", ps, depth, &q_r->num_entries2))
1379 if (UNMARSHALLING(ps)) {
1380 if (q_r->num_entries) {
1381 if ((q_r->hdr_name = PRS_ALLOC_MEM(ps, UNIHDR, q_r->num_entries)) == NULL)
1383 if ((q_r->uni_name = PRS_ALLOC_MEM(ps, UNISTR2, q_r->num_entries)) == NULL)
1388 for (i = 0; i < q_r->num_entries; i++) {
1391 if(!smb_io_unihdr("hdr_name", &q_r->hdr_name[i], ps, depth)) /* pointer names */
1395 for (i = 0; i < q_r->num_entries; i++) {
1398 if(!smb_io_unistr2("dom_name", &q_r->uni_name[i], q_r->hdr_name[i].buffer, ps, depth)) /* names to be looked up */
1404 if(!prs_uint32("num_trans_entries ", ps, depth, &q_r->num_trans_entries))
1406 if(!prs_uint32("ptr_trans_sids ", ps, depth, &q_r->ptr_trans_sids))
1408 if(!prs_uint16("lookup_level ", ps, depth, &q_r->lookup_level))
1412 if(!prs_uint32("mapped_count ", ps, depth, &q_r->mapped_count))
1414 if(!prs_uint32("unknown1 ", ps, depth, &q_r->unknown1))
1416 if(!prs_uint32("unknown2 ", ps, depth, &q_r->unknown2))
1422 /*******************************************************************
1423 reads or writes a structure.
1424 ********************************************************************/
1426 bool lsa_io_r_lookup_names3(const char *desc, LSA_R_LOOKUP_NAMES3 *out, prs_struct *ps, int depth)
1430 prs_debug(ps, depth, desc, "lsa_io_r_lookup_names3");
1436 if(!prs_uint32("ptr_dom_ref", ps, depth, &out->ptr_dom_ref))
1439 if (out->ptr_dom_ref != 0)
1440 if(!lsa_io_dom_r_ref("", out->dom_ref, ps, depth))
1443 if(!prs_uint32("num_entries", ps, depth, &out->num_entries))
1445 if(!prs_uint32("ptr_entries", ps, depth, &out->ptr_entries))
1448 if (out->ptr_entries != 0) {
1449 if(!prs_uint32("num_entries2", ps, depth, &out->num_entries2))
1452 if (out->num_entries2 != out->num_entries) {
1457 if (UNMARSHALLING(ps) && out->num_entries2) {
1458 if ((out->trans_sids = PRS_ALLOC_MEM(ps, LSA_TRANSLATED_SID3, out->num_entries2))
1460 DEBUG(3, ("lsa_io_r_lookup_names3(): out of memory\n"));
1465 for (i = 0; i < out->num_entries2; i++) {
1466 if(!smb_io_lsa_translated_sids3("", &out->trans_sids[i], ps, depth)) {
1470 /* Now process the DOM_SID2 entries. */
1471 for (i = 0; i < out->num_entries2; i++) {
1472 if (out->trans_sids[i].sid2) {
1473 if( !smb_io_dom_sid2("sid2", out->trans_sids[i].sid2, ps, depth) ) {
1480 if(!prs_uint32("mapped_count", ps, depth, &out->mapped_count))
1483 if(!prs_ntstatus("status ", ps, depth, &out->status))
1489 /*******************************************************************
1490 ********************************************************************/
1492 bool lsa_io_q_lookup_names4(const char *desc, LSA_Q_LOOKUP_NAMES4 *q_r,
1493 prs_struct *ps, int depth)
1497 prs_debug(ps, depth, desc, "lsa_io_q_lookup_names4");
1503 if(!prs_uint32("num_entries ", ps, depth, &q_r->num_entries))
1505 if(!prs_uint32("num_entries2 ", ps, depth, &q_r->num_entries2))
1508 if (UNMARSHALLING(ps)) {
1509 if (q_r->num_entries) {
1510 if ((q_r->hdr_name = PRS_ALLOC_MEM(ps, UNIHDR, q_r->num_entries)) == NULL)
1512 if ((q_r->uni_name = PRS_ALLOC_MEM(ps, UNISTR2, q_r->num_entries)) == NULL)
1517 for (i = 0; i < q_r->num_entries; i++) {
1520 if(!smb_io_unihdr("hdr_name", &q_r->hdr_name[i], ps, depth)) /* pointer names */
1524 for (i = 0; i < q_r->num_entries; i++) {
1527 if(!smb_io_unistr2("dom_name", &q_r->uni_name[i], q_r->hdr_name[i].buffer, ps, depth)) /* names to be looked up */
1533 if(!prs_uint32("num_trans_entries ", ps, depth, &q_r->num_trans_entries))
1535 if(!prs_uint32("ptr_trans_sids ", ps, depth, &q_r->ptr_trans_sids))
1537 if(!prs_uint16("lookup_level ", ps, depth, &q_r->lookup_level))
1541 if(!prs_uint32("mapped_count ", ps, depth, &q_r->mapped_count))
1543 if(!prs_uint32("unknown1 ", ps, depth, &q_r->unknown1))
1545 if(!prs_uint32("unknown2 ", ps, depth, &q_r->unknown2))
1551 /*******************************************************************
1552 Identical to lsa_io_r_lookup_names3.
1553 ********************************************************************/
1555 bool lsa_io_r_lookup_names4(const char *desc, LSA_R_LOOKUP_NAMES4 *out, prs_struct *ps, int depth)
1559 prs_debug(ps, depth, desc, "lsa_io_r_lookup_names4");
1565 if(!prs_uint32("ptr_dom_ref", ps, depth, &out->ptr_dom_ref))
1568 if (out->ptr_dom_ref != 0)
1569 if(!lsa_io_dom_r_ref("", out->dom_ref, ps, depth))
1572 if(!prs_uint32("num_entries", ps, depth, &out->num_entries))
1574 if(!prs_uint32("ptr_entries", ps, depth, &out->ptr_entries))
1577 if (out->ptr_entries != 0) {
1578 if(!prs_uint32("num_entries2", ps, depth, &out->num_entries2))
1581 if (out->num_entries2 != out->num_entries) {
1586 if (UNMARSHALLING(ps) && out->num_entries2) {
1587 if ((out->trans_sids = PRS_ALLOC_MEM(ps, LSA_TRANSLATED_SID3, out->num_entries2))
1589 DEBUG(3, ("lsa_io_r_lookup_names4(): out of memory\n"));
1594 for (i = 0; i < out->num_entries2; i++) {
1595 if(!smb_io_lsa_translated_sids3("", &out->trans_sids[i], ps, depth)) {
1599 /* Now process the DOM_SID2 entries. */
1600 for (i = 0; i < out->num_entries2; i++) {
1601 if (out->trans_sids[i].sid2) {
1602 if( !smb_io_dom_sid2("sid2", out->trans_sids[i].sid2, ps, depth) ) {
1609 if(!prs_uint32("mapped_count", ps, depth, &out->mapped_count))
1612 if(!prs_ntstatus("status ", ps, depth, &out->status))
1618 /*******************************************************************
1619 Inits an LSA_Q_ENUM_PRIVS structure.
1620 ********************************************************************/
1622 void init_q_enum_privs(LSA_Q_ENUM_PRIVS *in, POLICY_HND *hnd, uint32 enum_context, uint32 pref_max_length)
1624 DEBUG(5, ("init_q_enum_privs\n"));
1626 memcpy(&in->pol, hnd, sizeof(in->pol));
1628 in->enum_context = enum_context;
1629 in->pref_max_length = pref_max_length;
1632 /*******************************************************************
1633 reads or writes a structure.
1634 ********************************************************************/
1635 bool lsa_io_q_enum_privs(const char *desc, LSA_Q_ENUM_PRIVS *in, prs_struct *ps, int depth)
1640 prs_debug(ps, depth, desc, "lsa_io_q_enum_privs");
1643 if (!smb_io_pol_hnd("", &in->pol, ps, depth))
1646 if(!prs_uint32("enum_context ", ps, depth, &in->enum_context))
1648 if(!prs_uint32("pref_max_length", ps, depth, &in->pref_max_length))
1654 /*******************************************************************
1655 reads or writes a structure.
1656 ********************************************************************/
1657 static bool lsa_io_priv_entries(const char *desc, LSA_PRIV_ENTRY *entries, uint32 count, prs_struct *ps, int depth)
1661 if (entries == NULL)
1664 prs_debug(ps, depth, desc, "lsa_io_priv_entries");
1670 for (i = 0; i < count; i++) {
1671 if (!smb_io_unihdr("", &entries[i].hdr_name, ps, depth))
1673 if(!prs_uint32("luid_low ", ps, depth, &entries[i].luid_low))
1675 if(!prs_uint32("luid_high", ps, depth, &entries[i].luid_high))
1679 for (i = 0; i < count; i++)
1680 if (!smb_io_unistr2("", &entries[i].name, entries[i].hdr_name.buffer, ps, depth))
1686 /*******************************************************************
1687 Inits an LSA_R_ENUM_PRIVS structure.
1688 ********************************************************************/
1690 void init_lsa_r_enum_privs(LSA_R_ENUM_PRIVS *out, uint32 enum_context,
1691 uint32 count, LSA_PRIV_ENTRY *entries)
1693 DEBUG(5, ("init_lsa_r_enum_privs\n"));
1695 out->enum_context=enum_context;
1698 if (entries!=NULL) {
1709 /*******************************************************************
1710 reads or writes a structure.
1711 ********************************************************************/
1712 bool lsa_io_r_enum_privs(const char *desc, LSA_R_ENUM_PRIVS *out, prs_struct *ps, int depth)
1717 prs_debug(ps, depth, desc, "lsa_io_r_enum_privs");
1723 if(!prs_uint32("enum_context", ps, depth, &out->enum_context))
1725 if(!prs_uint32("count", ps, depth, &out->count))
1727 if(!prs_uint32("ptr", ps, depth, &out->ptr))
1731 if(!prs_uint32("count1", ps, depth, &out->count1))
1734 if (UNMARSHALLING(ps) && out->count1)
1735 if (!(out->privs = PRS_ALLOC_MEM(ps, LSA_PRIV_ENTRY, out->count1)))
1738 if (!lsa_io_priv_entries("", out->privs, out->count1, ps, depth))
1745 if(!prs_ntstatus("status", ps, depth, &out->status))
1751 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)
1753 memcpy(&trn->pol, hnd, sizeof(trn->pol));
1755 init_unistr2(&trn->name, name, UNI_FLAGS_NONE);
1756 init_uni_hdr(&trn->hdr_name, &trn->name);
1757 trn->lang_id = lang_id;
1758 trn->lang_id_sys = lang_id_sys;
1761 /*******************************************************************
1762 reads or writes a structure.
1763 ********************************************************************/
1764 bool lsa_io_q_priv_get_dispname(const char *desc, LSA_Q_PRIV_GET_DISPNAME *in, prs_struct *ps, int depth)
1769 prs_debug(ps, depth, desc, "lsa_io_q_priv_get_dispname");
1775 if (!smb_io_pol_hnd("", &in->pol, ps, depth))
1778 if (!smb_io_unihdr("hdr_name", &in->hdr_name, ps, depth))
1781 if (!smb_io_unistr2("name", &in->name, in->hdr_name.buffer, ps, depth))
1784 if(!prs_uint16("lang_id ", ps, depth, &in->lang_id))
1786 if(!prs_uint16("lang_id_sys", ps, depth, &in->lang_id_sys))
1792 /*******************************************************************
1793 reads or writes a structure.
1794 ********************************************************************/
1795 bool lsa_io_r_priv_get_dispname(const char *desc, LSA_R_PRIV_GET_DISPNAME *out, prs_struct *ps, int depth)
1800 prs_debug(ps, depth, desc, "lsa_io_r_priv_get_dispname");
1806 if (!prs_uint32("ptr_info", ps, depth, &out->ptr_info))
1810 if (!smb_io_unihdr("hdr_name", &out->hdr_desc, ps, depth))
1813 if (!smb_io_unistr2("desc", &out->desc, out->hdr_desc.buffer, ps, depth))
1820 if(!prs_uint16("lang_id", ps, depth, &out->lang_id))
1825 if(!prs_ntstatus("status", ps, depth, &out->status))
1832 initialise a LSA_Q_ENUM_ACCOUNTS structure
1834 void init_lsa_q_enum_accounts(LSA_Q_ENUM_ACCOUNTS *trn, POLICY_HND *hnd, uint32 enum_context, uint32 pref_max_length)
1836 memcpy(&trn->pol, hnd, sizeof(trn->pol));
1838 trn->enum_context = enum_context;
1839 trn->pref_max_length = pref_max_length;
1842 /*******************************************************************
1843 reads or writes a structure.
1844 ********************************************************************/
1845 bool lsa_io_q_enum_accounts(const char *desc, LSA_Q_ENUM_ACCOUNTS *in, prs_struct *ps, int depth)
1850 prs_debug(ps, depth, desc, "lsa_io_q_enum_accounts");
1853 if (!smb_io_pol_hnd("", &in->pol, ps, depth))
1856 if(!prs_uint32("enum_context ", ps, depth, &in->enum_context))
1858 if(!prs_uint32("pref_max_length", ps, depth, &in->pref_max_length))
1865 /*******************************************************************
1866 Inits an LSA_R_ENUM_PRIVS structure.
1867 ********************************************************************/
1869 void init_lsa_r_enum_accounts(LSA_R_ENUM_ACCOUNTS *out, uint32 enum_context)
1871 DEBUG(5, ("init_lsa_r_enum_accounts\n"));
1873 out->enum_context=enum_context;
1874 if (out->enum_context!=0) {
1875 out->sids.num_entries=enum_context;
1876 out->sids.ptr_sid_enum=1;
1877 out->sids.num_entries2=enum_context;
1879 out->sids.num_entries=0;
1880 out->sids.ptr_sid_enum=0;
1881 out->sids.num_entries2=0;
1885 /*******************************************************************
1886 reads or writes a structure.
1887 ********************************************************************/
1888 bool lsa_io_r_enum_accounts(const char *desc, LSA_R_ENUM_ACCOUNTS *out, prs_struct *ps, int depth)
1893 prs_debug(ps, depth, desc, "lsa_io_r_enum_accounts");
1899 if(!prs_uint32("enum_context", ps, depth, &out->enum_context))
1902 if (!lsa_io_sid_enum("sids", &out->sids, ps, depth))
1908 if(!prs_ntstatus("status", ps, depth, &out->status))
1915 /*******************************************************************
1916 Reads or writes an LSA_Q_UNK_GET_CONNUSER structure.
1917 ********************************************************************/
1919 bool lsa_io_q_unk_get_connuser(const char *desc, LSA_Q_UNK_GET_CONNUSER *in, prs_struct *ps, int depth)
1921 prs_debug(ps, depth, desc, "lsa_io_q_unk_get_connuser");
1927 if(!prs_uint32("ptr_srvname", ps, depth, &in->ptr_srvname))
1930 if(!smb_io_unistr2("uni2_srvname", &in->uni2_srvname, in->ptr_srvname, ps, depth)) /* server name to be looked up */
1936 if(!prs_uint32("unk1", ps, depth, &in->unk1))
1938 if(!prs_uint32("unk2", ps, depth, &in->unk2))
1940 if(!prs_uint32("unk3", ps, depth, &in->unk3))
1943 /* Don't bother to read or write at present... */
1947 /*******************************************************************
1948 Reads or writes an LSA_R_UNK_GET_CONNUSER structure.
1949 ********************************************************************/
1951 bool lsa_io_r_unk_get_connuser(const char *desc, LSA_R_UNK_GET_CONNUSER *out, prs_struct *ps, int depth)
1953 prs_debug(ps, depth, desc, "lsa_io_r_unk_get_connuser");
1959 if(!prs_uint32("ptr_user_name", ps, depth, &out->ptr_user_name))
1961 if(!smb_io_unihdr("hdr_user_name", &out->hdr_user_name, ps, depth))
1963 if(!smb_io_unistr2("uni2_user_name", &out->uni2_user_name, out->ptr_user_name, ps, depth))
1969 if(!prs_uint32("unk1", ps, depth, &out->unk1))
1972 if(!prs_uint32("ptr_dom_name", ps, depth, &out->ptr_dom_name))
1974 if(!smb_io_unihdr("hdr_dom_name", &out->hdr_dom_name, ps, depth))
1976 if(!smb_io_unistr2("uni2_dom_name", &out->uni2_dom_name, out->ptr_dom_name, ps, depth))
1982 if(!prs_ntstatus("status", ps, depth, &out->status))
1988 void init_lsa_q_open_account(LSA_Q_OPENACCOUNT *trn, POLICY_HND *hnd, DOM_SID *sid, uint32 desired_access)
1990 memcpy(&trn->pol, hnd, sizeof(trn->pol));
1992 init_dom_sid2(&trn->sid, sid);
1993 trn->access = desired_access;
1996 /*******************************************************************
1997 Reads or writes an LSA_Q_OPENACCOUNT structure.
1998 ********************************************************************/
2000 bool lsa_io_q_open_account(const char *desc, LSA_Q_OPENACCOUNT *out, prs_struct *ps, int depth)
2002 prs_debug(ps, depth, desc, "lsa_io_q_open_account");
2008 if(!smb_io_pol_hnd("pol", &out->pol, ps, depth))
2011 if(!smb_io_dom_sid2("sid", &out->sid, ps, depth)) /* domain SID */
2014 if(!prs_uint32("access", ps, depth, &out->access))
2020 /*******************************************************************
2021 Reads or writes an LSA_R_OPENACCOUNT structure.
2022 ********************************************************************/
2024 bool lsa_io_r_open_account(const char *desc, LSA_R_OPENACCOUNT *out, prs_struct *ps, int depth)
2026 prs_debug(ps, depth, desc, "lsa_io_r_open_account");
2032 if(!smb_io_pol_hnd("pol", &out->pol, ps, depth))
2035 if(!prs_ntstatus("status", ps, depth, &out->status))
2042 void init_lsa_q_enum_privsaccount(LSA_Q_ENUMPRIVSACCOUNT *trn, POLICY_HND *hnd)
2044 memcpy(&trn->pol, hnd, sizeof(trn->pol));
2048 /*******************************************************************
2049 Reads or writes an LSA_Q_ENUMPRIVSACCOUNT structure.
2050 ********************************************************************/
2052 bool lsa_io_q_enum_privsaccount(const char *desc, LSA_Q_ENUMPRIVSACCOUNT *out, prs_struct *ps, int depth)
2054 prs_debug(ps, depth, desc, "lsa_io_q_enum_privsaccount");
2060 if(!smb_io_pol_hnd("pol", &out->pol, ps, depth))
2066 /*******************************************************************
2067 Reads or writes an LUID structure.
2068 ********************************************************************/
2070 static bool lsa_io_luid(const char *desc, LUID *out, prs_struct *ps, int depth)
2072 prs_debug(ps, depth, desc, "lsa_io_luid");
2078 if(!prs_uint32("low", ps, depth, &out->low))
2081 if(!prs_uint32("high", ps, depth, &out->high))
2087 /*******************************************************************
2088 Reads or writes an LUID_ATTR structure.
2089 ********************************************************************/
2091 static bool lsa_io_luid_attr(const char *desc, LUID_ATTR *out, prs_struct *ps, int depth)
2093 prs_debug(ps, depth, desc, "lsa_io_luid_attr");
2099 if (!lsa_io_luid(desc, &out->luid, ps, depth))
2102 if(!prs_uint32("attr", ps, depth, &out->attr))
2108 /*******************************************************************
2109 Reads or writes an PRIVILEGE_SET structure.
2110 ********************************************************************/
2112 static bool lsa_io_privilege_set(const char *desc, PRIVILEGE_SET *out, prs_struct *ps, int depth)
2116 prs_debug(ps, depth, desc, "lsa_io_privilege_set");
2122 if(!prs_uint32("count", ps, depth, &dummy))
2124 if(!prs_uint32("control", ps, depth, &out->control))
2127 for (i=0; i<out->count; i++) {
2128 if (!lsa_io_luid_attr(desc, &out->set[i], ps, depth))
2135 NTSTATUS init_lsa_r_enum_privsaccount(TALLOC_CTX *mem_ctx, LSA_R_ENUMPRIVSACCOUNT *out, LUID_ATTR *set, uint32 count, uint32 control)
2137 NTSTATUS ret = NT_STATUS_OK;
2142 if ( !NT_STATUS_IS_OK(ret = privilege_set_init_by_ctx(mem_ctx, &(out->set))) )
2145 out->set.count = count;
2147 if (!NT_STATUS_IS_OK(ret = dup_luid_attr(out->set.mem_ctx, &(out->set.set), set, count)))
2150 DEBUG(10,("init_lsa_r_enum_privsaccount: %d privileges\n", out->count));
2155 /*******************************************************************
2156 Reads or writes an LSA_R_ENUMPRIVSACCOUNT structure.
2157 ********************************************************************/
2159 bool lsa_io_r_enum_privsaccount(const char *desc, LSA_R_ENUMPRIVSACCOUNT *out, prs_struct *ps, int depth)
2161 prs_debug(ps, depth, desc, "lsa_io_r_enum_privsaccount");
2167 if(!prs_uint32("ptr", ps, depth, &out->ptr))
2171 if(!prs_uint32("count", ps, depth, &out->count))
2174 /* malloc memory if unmarshalling here */
2176 if (UNMARSHALLING(ps) && out->count != 0) {
2177 if (!NT_STATUS_IS_OK(privilege_set_init_by_ctx(ps->mem_ctx, &(out->set))))
2180 if (!(out->set.set = PRS_ALLOC_MEM(ps,LUID_ATTR,out->count)))
2185 if(!lsa_io_privilege_set(desc, &out->set, ps, depth))
2189 if(!prs_ntstatus("status", ps, depth, &out->status))
2197 /*******************************************************************
2198 Reads or writes an LSA_Q_GETSYSTEMACCOUNTstructure.
2199 ********************************************************************/
2201 bool lsa_io_q_getsystemaccount(const char *desc, LSA_Q_GETSYSTEMACCOUNT *out, prs_struct *ps, int depth)
2203 prs_debug(ps, depth, desc, "lsa_io_q_getsystemaccount");
2209 if(!smb_io_pol_hnd("pol", &out->pol, ps, depth))
2215 /*******************************************************************
2216 Reads or writes an LSA_R_GETSYSTEMACCOUNTstructure.
2217 ********************************************************************/
2219 bool lsa_io_r_getsystemaccount(const char *desc, LSA_R_GETSYSTEMACCOUNT *out, prs_struct *ps, int depth)
2221 prs_debug(ps, depth, desc, "lsa_io_r_getsystemaccount");
2227 if(!prs_uint32("access", ps, depth, &out->access))
2230 if(!prs_ntstatus("status", ps, depth, &out->status))
2237 /*******************************************************************
2238 Reads or writes an LSA_Q_SETSYSTEMACCOUNT structure.
2239 ********************************************************************/
2241 bool lsa_io_q_setsystemaccount(const char *desc, LSA_Q_SETSYSTEMACCOUNT *out, prs_struct *ps, int depth)
2243 prs_debug(ps, depth, desc, "lsa_io_q_setsystemaccount");
2249 if(!smb_io_pol_hnd("pol", &out->pol, ps, depth))
2252 if(!prs_uint32("access", ps, depth, &out->access))
2258 /*******************************************************************
2259 Reads or writes an LSA_R_SETSYSTEMACCOUNT structure.
2260 ********************************************************************/
2262 bool lsa_io_r_setsystemaccount(const char *desc, LSA_R_SETSYSTEMACCOUNT *out, prs_struct *ps, int depth)
2264 prs_debug(ps, depth, desc, "lsa_io_r_setsystemaccount");
2270 if(!prs_ntstatus("status", ps, depth, &out->status))
2277 void init_lsa_string( LSA_STRING *uni, const char *string )
2279 init_unistr2(&uni->unistring, string, UNI_FLAGS_NONE);
2280 init_uni_hdr(&uni->hdr, &uni->unistring);
2283 void init_lsa_q_lookup_priv_value(LSA_Q_LOOKUP_PRIV_VALUE *q_u, POLICY_HND *hnd, const char *name)
2285 memcpy(&q_u->pol, hnd, sizeof(q_u->pol));
2286 init_lsa_string( &q_u->privname, name );
2289 bool smb_io_lsa_string( const char *desc, LSA_STRING *string, prs_struct *ps, int depth )
2291 prs_debug(ps, depth, desc, "smb_io_lsa_string");
2294 if(!smb_io_unihdr ("hdr", &string->hdr, ps, depth))
2296 if(!smb_io_unistr2("unistring", &string->unistring, string->hdr.buffer, ps, depth))
2302 /*******************************************************************
2303 Reads or writes an LSA_Q_LOOKUP_PRIV_VALUE structure.
2304 ********************************************************************/
2306 bool lsa_io_q_lookup_priv_value(const char *desc, LSA_Q_LOOKUP_PRIV_VALUE *out, prs_struct *ps, int depth)
2308 prs_debug(ps, depth, desc, "lsa_io_q_lookup_priv_value");
2314 if(!smb_io_pol_hnd("pol", &out->pol, ps, depth))
2316 if(!smb_io_lsa_string("privname", &out->privname, ps, depth))
2322 /*******************************************************************
2323 Reads or writes an LSA_R_LOOKUP_PRIV_VALUE structure.
2324 ********************************************************************/
2326 bool lsa_io_r_lookup_priv_value(const char *desc, LSA_R_LOOKUP_PRIV_VALUE *out, prs_struct *ps, int depth)
2328 prs_debug(ps, depth, desc, "lsa_io_r_lookup_priv_value");
2334 if(!lsa_io_luid("luid", &out->luid, ps, depth))
2337 if(!prs_ntstatus("status", ps, depth, &out->status))
2344 /*******************************************************************
2345 Reads or writes an LSA_Q_ADDPRIVS structure.
2346 ********************************************************************/
2348 bool lsa_io_q_addprivs(const char *desc, LSA_Q_ADDPRIVS *out, prs_struct *ps, int depth)
2350 prs_debug(ps, depth, desc, "lsa_io_q_addprivs");
2356 if(!smb_io_pol_hnd("pol", &out->pol, ps, depth))
2359 if(!prs_uint32("count", ps, depth, &out->count))
2362 if (UNMARSHALLING(ps) && out->count!=0) {
2363 if (!NT_STATUS_IS_OK(privilege_set_init_by_ctx(ps->mem_ctx, &(out->set))))
2366 if (!(out->set.set = PRS_ALLOC_MEM(ps, LUID_ATTR, out->count)))
2370 if(!lsa_io_privilege_set(desc, &out->set, ps, depth))
2376 /*******************************************************************
2377 Reads or writes an LSA_R_ADDPRIVS structure.
2378 ********************************************************************/
2380 bool lsa_io_r_addprivs(const char *desc, LSA_R_ADDPRIVS *out, prs_struct *ps, int depth)
2382 prs_debug(ps, depth, desc, "lsa_io_r_addprivs");
2388 if(!prs_ntstatus("status", ps, depth, &out->status))
2394 /*******************************************************************
2395 Reads or writes an LSA_Q_REMOVEPRIVS structure.
2396 ********************************************************************/
2398 bool lsa_io_q_removeprivs(const char *desc, LSA_Q_REMOVEPRIVS *out, prs_struct *ps, int depth)
2400 prs_debug(ps, depth, desc, "lsa_io_q_removeprivs");
2406 if(!smb_io_pol_hnd("pol", &out->pol, ps, depth))
2409 if(!prs_uint32("allrights", ps, depth, &out->allrights))
2412 if(!prs_uint32("ptr", ps, depth, &out->ptr))
2416 * JFM: I'm not sure at all if the count is inside the ptr
2417 * never seen one with ptr=0
2421 if(!prs_uint32("count", ps, depth, &out->count))
2424 if (UNMARSHALLING(ps) && out->count!=0) {
2425 if (!NT_STATUS_IS_OK(privilege_set_init_by_ctx(ps->mem_ctx, &(out->set))))
2428 if (!(out->set.set = PRS_ALLOC_MEM(ps, LUID_ATTR, out->count)))
2432 if(!lsa_io_privilege_set(desc, &out->set, ps, depth))
2439 /*******************************************************************
2440 Reads or writes an LSA_R_REMOVEPRIVS structure.
2441 ********************************************************************/
2443 bool lsa_io_r_removeprivs(const char *desc, LSA_R_REMOVEPRIVS *out, prs_struct *ps, int depth)
2445 prs_debug(ps, depth, desc, "lsa_io_r_removeprivs");
2451 if(!prs_ntstatus("status", ps, depth, &out->status))
2457 bool policy_handle_is_valid(const POLICY_HND *hnd)
2459 POLICY_HND zero_pol;
2461 ZERO_STRUCT(zero_pol);
2462 return ((memcmp(&zero_pol, hnd, sizeof(POLICY_HND)) == 0) ? False : True );
2465 /*******************************************************************
2466 Inits an LSA_Q_ENUM_ACCT_RIGHTS structure.
2467 ********************************************************************/
2468 void init_q_enum_acct_rights(LSA_Q_ENUM_ACCT_RIGHTS *in,
2473 DEBUG(5, ("init_q_enum_acct_rights\n"));
2476 init_dom_sid2(&in->sid, sid);
2479 /*******************************************************************
2480 ********************************************************************/
2481 NTSTATUS init_r_enum_acct_rights( LSA_R_ENUM_ACCT_RIGHTS *out, PRIVILEGE_SET *privileges )
2484 const char *privname;
2485 const char **privname_array = NULL;
2488 for ( i=0; i<privileges->count; i++ ) {
2489 privname = luid_to_privilege_name( &privileges->set[i].luid );
2491 if ( !add_string_to_array( talloc_tos(), privname, &privname_array, &num_priv ) )
2492 return NT_STATUS_NO_MEMORY;
2497 out->rights = TALLOC_P( talloc_tos(), UNISTR4_ARRAY );
2499 return NT_STATUS_NO_MEMORY;
2502 if ( !init_unistr4_array( out->rights, num_priv, privname_array ) )
2503 return NT_STATUS_NO_MEMORY;
2505 out->count = num_priv;
2508 return NT_STATUS_OK;
2511 /*******************************************************************
2512 reads or writes a LSA_Q_ENUM_ACCT_RIGHTS structure.
2513 ********************************************************************/
2514 bool lsa_io_q_enum_acct_rights(const char *desc, LSA_Q_ENUM_ACCT_RIGHTS *in, prs_struct *ps, int depth)
2520 prs_debug(ps, depth, desc, "lsa_io_q_enum_acct_rights");
2523 if (!smb_io_pol_hnd("", &in->pol, ps, depth))
2526 if(!smb_io_dom_sid2("sid", &in->sid, ps, depth))
2533 /*******************************************************************
2534 reads or writes a LSA_R_ENUM_ACCT_RIGHTS structure.
2535 ********************************************************************/
2536 bool lsa_io_r_enum_acct_rights(const char *desc, LSA_R_ENUM_ACCT_RIGHTS *out, prs_struct *ps, int depth)
2538 prs_debug(ps, depth, desc, "lsa_io_r_enum_acct_rights");
2541 if(!prs_uint32("count ", ps, depth, &out->count))
2544 if ( !prs_pointer("rights", ps, depth, (void*)&out->rights, sizeof(UNISTR4_ARRAY), (PRS_POINTER_CAST)prs_unistr4_array) )
2550 if(!prs_ntstatus("status", ps, depth, &out->status))
2557 /*******************************************************************
2558 Inits an LSA_Q_ADD_ACCT_RIGHTS structure.
2559 ********************************************************************/
2560 void init_q_add_acct_rights( LSA_Q_ADD_ACCT_RIGHTS *in, POLICY_HND *hnd,
2561 DOM_SID *sid, uint32 count, const char **rights )
2563 DEBUG(5, ("init_q_add_acct_rights\n"));
2566 init_dom_sid2(&in->sid, sid);
2568 in->rights = TALLOC_P( talloc_tos(), UNISTR4_ARRAY );
2570 smb_panic("init_q_add_acct_rights: talloc fail\n");
2573 init_unistr4_array( in->rights, count, rights );
2579 /*******************************************************************
2580 reads or writes a LSA_Q_ADD_ACCT_RIGHTS structure.
2581 ********************************************************************/
2582 bool lsa_io_q_add_acct_rights(const char *desc, LSA_Q_ADD_ACCT_RIGHTS *in, prs_struct *ps, int depth)
2584 prs_debug(ps, depth, desc, "lsa_io_q_add_acct_rights");
2587 if (!smb_io_pol_hnd("", &in->pol, ps, depth))
2590 if(!smb_io_dom_sid2("sid", &in->sid, ps, depth))
2593 if(!prs_uint32("count", ps, depth, &in->count))
2596 if ( !prs_pointer("rights", ps, depth, (void*)&in->rights, sizeof(UNISTR4_ARRAY), (PRS_POINTER_CAST)prs_unistr4_array) )
2602 /*******************************************************************
2603 reads or writes a LSA_R_ENUM_ACCT_RIGHTS structure.
2604 ********************************************************************/
2605 bool lsa_io_r_add_acct_rights(const char *desc, LSA_R_ADD_ACCT_RIGHTS *out, prs_struct *ps, int depth)
2607 prs_debug(ps, depth, desc, "lsa_io_r_add_acct_rights");
2610 if(!prs_ntstatus("status", ps, depth, &out->status))
2616 /*******************************************************************
2617 Inits an LSA_Q_REMOVE_ACCT_RIGHTS structure.
2618 ********************************************************************/
2620 void init_q_remove_acct_rights(LSA_Q_REMOVE_ACCT_RIGHTS *in,
2625 const char **rights)
2627 DEBUG(5, ("init_q_remove_acct_rights\n"));
2631 init_dom_sid2(&in->sid, sid);
2633 in->removeall = removeall;
2636 in->rights = TALLOC_P( talloc_tos(), UNISTR4_ARRAY );
2638 smb_panic("init_q_remove_acct_rights: talloc fail\n");
2641 init_unistr4_array( in->rights, count, rights );
2644 /*******************************************************************
2645 reads or writes a LSA_Q_REMOVE_ACCT_RIGHTS structure.
2646 ********************************************************************/
2648 bool lsa_io_q_remove_acct_rights(const char *desc, LSA_Q_REMOVE_ACCT_RIGHTS *in, prs_struct *ps, int depth)
2650 prs_debug(ps, depth, desc, "lsa_io_q_remove_acct_rights");
2653 if (!smb_io_pol_hnd("", &in->pol, ps, depth))
2656 if(!smb_io_dom_sid2("sid", &in->sid, ps, depth))
2659 if(!prs_uint32("removeall", ps, depth, &in->removeall))
2662 if(!prs_uint32("count", ps, depth, &in->count))
2665 if ( !prs_pointer("rights", ps, depth, (void*)&in->rights, sizeof(UNISTR4_ARRAY), (PRS_POINTER_CAST)prs_unistr4_array) )
2671 /*******************************************************************
2672 reads or writes a LSA_R_ENUM_ACCT_RIGHTS structure.
2673 ********************************************************************/
2674 bool lsa_io_r_remove_acct_rights(const char *desc, LSA_R_REMOVE_ACCT_RIGHTS *out, prs_struct *ps, int depth)
2676 prs_debug(ps, depth, desc, "lsa_io_r_remove_acct_rights");
2679 if(!prs_ntstatus("status", ps, depth, &out->status))