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,
217 prs_debug(ps, depth, desc, "lsa_io_obj_attr");
223 /* these pointers had _better_ be zero, because we don't know
226 if(!prs_uint32("len ", ps, depth, &attr->len)) /* 0x18 - length (in bytes) inc. the length field. */
228 if(!prs_uint32("ptr_root_dir", ps, depth, &attr->ptr_root_dir)) /* 0 - root directory (pointer) */
230 if(!prs_uint32("ptr_obj_name", ps, depth, &attr->ptr_obj_name)) /* 0 - object name (pointer) */
232 if(!prs_uint32("attributes ", ps, depth, &attr->attributes)) /* 0 - attributes (undocumented) */
234 if(!prs_uint32("ptr_sec_desc", ps, depth, &attr->ptr_sec_desc)) /* 0 - security descriptior (pointer) */
236 if(!prs_uint32("ptr_sec_qos ", ps, depth, &attr->ptr_sec_qos )) /* security quality of service (pointer) */
239 if (attr->ptr_sec_qos != 0) {
240 if (UNMARSHALLING(ps))
241 if (!(attr->sec_qos = PRS_ALLOC_MEM(ps,LSA_SEC_QOS,1)))
244 if(!lsa_io_sec_qos("sec_qos", attr->sec_qos, ps, depth))
252 /*******************************************************************
253 Inits an LSA_Q_OPEN_POL structure.
254 ********************************************************************/
256 void init_q_open_pol(LSA_Q_OPEN_POL *r_q, uint16 system_name,
257 uint32 attributes, uint32 desired_access,
260 DEBUG(5, ("init_open_pol: attr:%d da:%d\n", attributes,
263 r_q->ptr = 1; /* undocumented pointer */
265 r_q->des_access = desired_access;
267 r_q->system_name = system_name;
268 init_lsa_obj_attr(&r_q->attr, attributes, qos);
271 /*******************************************************************
272 Reads or writes an LSA_Q_OPEN_POL structure.
273 ********************************************************************/
275 BOOL lsa_io_q_open_pol(const char *desc, LSA_Q_OPEN_POL *r_q, prs_struct *ps,
278 prs_debug(ps, depth, desc, "lsa_io_q_open_pol");
281 if(!prs_uint32("ptr ", ps, depth, &r_q->ptr))
283 if(!prs_uint16("system_name", ps, depth, &r_q->system_name))
288 if(!lsa_io_obj_attr("", &r_q->attr, ps, depth))
291 if(!prs_uint32("des_access", ps, depth, &r_q->des_access))
297 /*******************************************************************
298 Reads or writes an LSA_R_OPEN_POL structure.
299 ********************************************************************/
301 BOOL lsa_io_r_open_pol(const char *desc, LSA_R_OPEN_POL *r_p, prs_struct *ps,
304 prs_debug(ps, depth, desc, "lsa_io_r_open_pol");
307 if(!smb_io_pol_hnd("", &r_p->pol, ps, depth))
310 if(!prs_ntstatus("status", ps, depth, &r_p->status))
316 /*******************************************************************
317 Inits an LSA_Q_OPEN_POL2 structure.
318 ********************************************************************/
320 void init_q_open_pol2(LSA_Q_OPEN_POL2 *r_q, const char *server_name,
321 uint32 attributes, uint32 desired_access,
324 DEBUG(5, ("init_q_open_pol2: attr:%d da:%d\n", attributes,
327 r_q->ptr = 1; /* undocumented pointer */
329 r_q->des_access = desired_access;
331 init_unistr2(&r_q->uni_server_name, server_name, UNI_STR_TERMINATE);
333 init_lsa_obj_attr(&r_q->attr, attributes, qos);
336 /*******************************************************************
337 Reads or writes an LSA_Q_OPEN_POL2 structure.
338 ********************************************************************/
340 BOOL lsa_io_q_open_pol2(const char *desc, LSA_Q_OPEN_POL2 *r_q, prs_struct *ps,
343 prs_debug(ps, depth, desc, "lsa_io_q_open_pol2");
346 if(!prs_uint32("ptr ", ps, depth, &r_q->ptr))
349 if(!smb_io_unistr2 ("", &r_q->uni_server_name, r_q->ptr, ps, depth))
351 if(!lsa_io_obj_attr("", &r_q->attr, ps, depth))
354 if(!prs_uint32("des_access", ps, depth, &r_q->des_access))
360 /*******************************************************************
361 Reads or writes an LSA_R_OPEN_POL2 structure.
362 ********************************************************************/
364 BOOL lsa_io_r_open_pol2(const char *desc, LSA_R_OPEN_POL2 *r_p, prs_struct *ps,
367 prs_debug(ps, depth, desc, "lsa_io_r_open_pol2");
370 if(!smb_io_pol_hnd("", &r_p->pol, ps, depth))
373 if(!prs_ntstatus("status", ps, depth, &r_p->status))
379 /*******************************************************************
380 makes an LSA_Q_QUERY_SEC_OBJ structure.
381 ********************************************************************/
383 void init_q_query_sec_obj(LSA_Q_QUERY_SEC_OBJ *q_q, const POLICY_HND *hnd,
386 DEBUG(5, ("init_q_query_sec_obj\n"));
389 q_q->sec_info = sec_info;
394 /*******************************************************************
395 Reads or writes an LSA_Q_QUERY_SEC_OBJ structure.
396 ********************************************************************/
398 BOOL lsa_io_q_query_sec_obj(const char *desc, LSA_Q_QUERY_SEC_OBJ *q_q,
399 prs_struct *ps, int depth)
401 prs_debug(ps, depth, desc, "lsa_io_q_query_sec_obj");
404 if (!smb_io_pol_hnd("", &q_q->pol, ps, depth))
407 if (!prs_uint32("sec_info", ps, depth, &q_q->sec_info))
413 /*******************************************************************
414 Reads or writes a LSA_R_QUERY_SEC_OBJ structure.
415 ********************************************************************/
417 BOOL lsa_io_r_query_sec_obj(const char *desc, LSA_R_QUERY_SEC_OBJ *r_u,
418 prs_struct *ps, int depth)
420 prs_debug(ps, depth, desc, "lsa_io_r_query_sec_obj");
426 if (!prs_uint32("ptr", ps, depth, &r_u->ptr))
430 if (!sec_io_desc_buf("sec", &r_u->buf, ps, depth))
434 if (!prs_ntstatus("status", ps, depth, &r_u->status))
440 /*******************************************************************
441 Inits an LSA_Q_QUERY_INFO structure.
442 ********************************************************************/
444 void init_q_query(LSA_Q_QUERY_INFO *q_q, POLICY_HND *hnd, uint16 info_class)
446 DEBUG(5, ("init_q_query\n"));
448 memcpy(&q_q->pol, hnd, sizeof(q_q->pol));
450 q_q->info_class = info_class;
453 /*******************************************************************
454 Reads or writes an LSA_Q_QUERY_INFO structure.
455 ********************************************************************/
457 BOOL lsa_io_q_query(const char *desc, LSA_Q_QUERY_INFO *q_q, prs_struct *ps,
460 prs_debug(ps, depth, desc, "lsa_io_q_query");
463 if(!smb_io_pol_hnd("", &q_q->pol, ps, depth))
466 if(!prs_uint16("info_class", ps, depth, &q_q->info_class))
472 /*******************************************************************
473 makes an LSA_Q_ENUM_TRUST_DOM structure.
474 ********************************************************************/
475 BOOL init_q_enum_trust_dom(LSA_Q_ENUM_TRUST_DOM * q_e, POLICY_HND *pol,
476 uint32 enum_context, uint32 preferred_len)
478 DEBUG(5, ("init_q_enum_trust_dom\n"));
481 q_e->enum_context = enum_context;
482 q_e->preferred_len = preferred_len;
487 /*******************************************************************
488 Reads or writes an LSA_Q_ENUM_TRUST_DOM structure.
489 ********************************************************************/
491 BOOL lsa_io_q_enum_trust_dom(const char *desc, LSA_Q_ENUM_TRUST_DOM *q_e,
492 prs_struct *ps, int depth)
494 prs_debug(ps, depth, desc, "lsa_io_q_enum_trust_dom");
497 if(!smb_io_pol_hnd("", &q_e->pol, ps, depth))
500 if(!prs_uint32("enum_context ", ps, depth, &q_e->enum_context))
502 if(!prs_uint32("preferred_len", ps, depth, &q_e->preferred_len))
508 /*******************************************************************
509 Inits an LSA_R_ENUM_TRUST_DOM structure.
510 ********************************************************************/
512 void init_r_enum_trust_dom(TALLOC_CTX *ctx, LSA_R_ENUM_TRUST_DOM *r_e, uint32 enum_context,
513 uint32 req_num_domains, uint32 num_domains, TRUSTDOM **td)
517 DEBUG(5, ("init_r_enum_trust_dom\n"));
519 r_e->enum_context = enum_context;
520 r_e->num_domains = num_domains;
521 r_e->ptr_enum_domains = 0;
522 r_e->num_domains2 = num_domains;
524 if (num_domains != 0) {
527 * allocating empty arrays of unicode headers, strings
528 * and sids of enumerated trusted domains
530 if (!(r_e->hdr_domain_name = TALLOC_ARRAY(ctx,UNIHDR2,num_domains))) {
531 r_e->status = NT_STATUS_NO_MEMORY;
535 if (!(r_e->uni_domain_name = TALLOC_ARRAY(ctx,UNISTR2,num_domains))) {
536 r_e->status = NT_STATUS_NO_MEMORY;
540 if (!(r_e->domain_sid = TALLOC_ARRAY(ctx,DOM_SID2,num_domains))) {
541 r_e->status = NT_STATUS_NO_MEMORY;
545 for (i = 0; i < num_domains; i++) {
547 /* don't know what actually is this for */
548 r_e->ptr_enum_domains = 1;
550 init_dom_sid2(&r_e->domain_sid[i], &(td[i])->sid);
552 init_unistr2_w(ctx, &r_e->uni_domain_name[i], (td[i])->name);
553 init_uni_hdr2(&r_e->hdr_domain_name[i], &r_e->uni_domain_name[i]);
560 /*******************************************************************
561 Reads or writes an LSA_R_ENUM_TRUST_DOM structure.
562 ********************************************************************/
564 BOOL lsa_io_r_enum_trust_dom(const char *desc, LSA_R_ENUM_TRUST_DOM *r_e,
565 prs_struct *ps, int depth)
567 prs_debug(ps, depth, desc, "lsa_io_r_enum_trust_dom");
570 if(!prs_uint32("enum_context ", ps, depth, &r_e->enum_context))
572 if(!prs_uint32("num_domains ", ps, depth, &r_e->num_domains))
574 if(!prs_uint32("ptr_enum_domains", ps, depth, &r_e->ptr_enum_domains))
577 if (r_e->ptr_enum_domains) {
580 if(!prs_uint32("num_domains2", ps, depth, &r_e->num_domains2))
583 num_domains = r_e->num_domains2;
585 if (UNMARSHALLING(ps)) {
586 if (!(r_e->hdr_domain_name = PRS_ALLOC_MEM(ps,UNIHDR2,num_domains)))
589 if (!(r_e->uni_domain_name = PRS_ALLOC_MEM(ps,UNISTR2,num_domains)))
592 if (!(r_e->domain_sid = PRS_ALLOC_MEM(ps,DOM_SID2,num_domains)))
596 for (i = 0; i < num_domains; i++) {
597 if(!smb_io_unihdr2 ("", &r_e->hdr_domain_name[i], ps,
602 for (i = 0; i < num_domains; i++) {
603 if(!smb_io_unistr2 ("", &r_e->uni_domain_name[i],
604 r_e->hdr_domain_name[i].buffer,
607 if(!smb_io_dom_sid2("", &r_e->domain_sid[i], ps,
613 if(!prs_ntstatus("status", ps, depth, &r_e->status))
619 /*******************************************************************
620 reads or writes a dom query structure.
621 ********************************************************************/
623 static BOOL lsa_io_dom_query(const char *desc, DOM_QUERY *d_q, prs_struct *ps, int depth)
628 prs_debug(ps, depth, desc, "lsa_io_dom_query");
634 if(!prs_uint16("uni_dom_max_len", ps, depth, &d_q->uni_dom_max_len)) /* domain name string length * 2 */
636 if(!prs_uint16("uni_dom_str_len", ps, depth, &d_q->uni_dom_str_len)) /* domain name string length * 2 */
639 if(!prs_uint32("buffer_dom_name", ps, depth, &d_q->buffer_dom_name)) /* undocumented domain name string buffer pointer */
641 if(!prs_uint32("buffer_dom_sid ", ps, depth, &d_q->buffer_dom_sid)) /* undocumented domain SID string buffer pointer */
644 if(!smb_io_unistr2("unistr2", &d_q->uni_domain_name, d_q->buffer_dom_name, ps, depth)) /* domain name (unicode string) */
650 if (d_q->buffer_dom_sid != 0) {
651 if(!smb_io_dom_sid2("", &d_q->dom_sid, ps, depth)) /* domain SID */
654 memset((char *)&d_q->dom_sid, '\0', sizeof(d_q->dom_sid));
660 /*******************************************************************
661 reads or writes a structure.
662 ********************************************************************/
664 static BOOL lsa_io_dom_query_2(const char *desc, DOM_QUERY_2 *d_q, prs_struct *ps, int depth)
671 prs_debug(ps, depth, desc, "lsa_io_dom_query_2");
677 if (!prs_uint32("auditing_enabled", ps, depth, &d_q->auditing_enabled))
679 if (!prs_uint32("ptr ", ps, depth, &ptr))
681 if (!prs_uint32("count1", ps, depth, &d_q->count1))
683 if (!prs_uint32("count2", ps, depth, &d_q->count2))
686 if (UNMARSHALLING(ps)) {
687 d_q->auditsettings = TALLOC_ZERO_ARRAY(ps->mem_ctx, uint32, d_q->count2);
690 if (d_q->auditsettings == NULL) {
691 DEBUG(1, ("lsa_io_dom_query_2: NULL auditsettings!\n"));
695 if (!prs_uint32s(False, "auditsettings", ps, depth, d_q->auditsettings, d_q->count2))
701 /*******************************************************************
702 Reads or writes a dom query structure.
703 ********************************************************************/
705 static BOOL lsa_io_dom_query_3(const char *desc, DOM_QUERY_3 *d_q, prs_struct *ps, int depth)
707 return lsa_io_dom_query("", d_q, ps, depth);
710 /*******************************************************************
711 Reads or writes a dom query structure.
712 ********************************************************************/
714 static BOOL lsa_io_dom_query_5(const char *desc, DOM_QUERY_5 *d_q, prs_struct *ps, int depth)
716 return lsa_io_dom_query("", d_q, ps, depth);
719 /*******************************************************************
720 Reads or writes a dom query structure.
721 ********************************************************************/
723 static BOOL lsa_io_dom_query_6(const char *desc, DOM_QUERY_6 *d_q, prs_struct *ps, int depth)
728 prs_debug(ps, depth, desc, "lsa_io_dom_query_6");
731 if (!prs_uint16("server_role", ps, depth, &d_q->server_role))
737 /*******************************************************************
738 Reads or writes an LSA_R_QUERY_INFO structure.
739 ********************************************************************/
741 BOOL lsa_io_r_query(const char *desc, LSA_R_QUERY_INFO *r_q, prs_struct *ps,
744 prs_debug(ps, depth, desc, "lsa_io_r_query");
747 if(!prs_uint32("undoc_buffer", ps, depth, &r_q->undoc_buffer))
750 if (r_q->undoc_buffer != 0) {
751 if(!prs_uint16("info_class", ps, depth, &r_q->info_class))
757 switch (r_q->info_class) {
759 if(!lsa_io_dom_query_2("", &r_q->dom.id2, ps, depth))
763 if(!lsa_io_dom_query_3("", &r_q->dom.id3, ps, depth))
767 if(!lsa_io_dom_query_5("", &r_q->dom.id5, ps, depth))
771 if(!lsa_io_dom_query_6("", &r_q->dom.id6, ps, depth))
783 if(!prs_ntstatus("status", ps, depth, &r_q->status))
789 /*******************************************************************
790 Inits a LSA_SID_ENUM structure.
791 ********************************************************************/
793 static void init_lsa_sid_enum(TALLOC_CTX *mem_ctx, LSA_SID_ENUM *sen,
794 int num_entries, const DOM_SID *sids)
798 DEBUG(5, ("init_lsa_sid_enum\n"));
800 sen->num_entries = num_entries;
801 sen->ptr_sid_enum = (num_entries != 0);
802 sen->num_entries2 = num_entries;
804 /* Allocate memory for sids and sid pointers */
806 if (num_entries == 0) return;
808 if ((sen->ptr_sid = TALLOC_ZERO_ARRAY(mem_ctx, uint32, num_entries )) == NULL) {
809 DEBUG(3, ("init_lsa_sid_enum(): out of memory for ptr_sid\n"));
813 if ((sen->sid = TALLOC_ZERO_ARRAY(mem_ctx, DOM_SID2, num_entries)) == NULL) {
814 DEBUG(3, ("init_lsa_sid_enum(): out of memory for sids\n"));
818 /* Copy across SIDs and SID pointers */
820 for (i = 0; i < num_entries; i++) {
822 init_dom_sid2(&sen->sid[i], &sids[i]);
826 /*******************************************************************
827 Reads or writes a LSA_SID_ENUM structure.
828 ********************************************************************/
830 static BOOL lsa_io_sid_enum(const char *desc, LSA_SID_ENUM *sen, prs_struct *ps,
835 prs_debug(ps, depth, desc, "lsa_io_sid_enum");
841 if(!prs_uint32("num_entries ", ps, depth, &sen->num_entries))
843 if(!prs_uint32("ptr_sid_enum", ps, depth, &sen->ptr_sid_enum))
847 if the ptr is NULL, leave here. checked from a real w2k trace.
851 if (sen->ptr_sid_enum==0)
854 if(!prs_uint32("num_entries2", ps, depth, &sen->num_entries2))
857 /* Mallocate memory if we're unpacking from the wire */
859 if (UNMARSHALLING(ps)) {
860 if ((sen->ptr_sid = PRS_ALLOC_MEM( ps, uint32, sen->num_entries)) == NULL) {
861 DEBUG(3, ("init_lsa_sid_enum(): out of memory for "
866 if ((sen->sid = PRS_ALLOC_MEM( ps, DOM_SID2, sen->num_entries)) == NULL) {
867 DEBUG(3, ("init_lsa_sid_enum(): out of memory for "
873 for (i = 0; i < sen->num_entries; i++) {
876 slprintf(temp, sizeof(temp) - 1, "ptr_sid[%d]", i);
877 if(!prs_uint32(temp, ps, depth, &sen->ptr_sid[i])) {
882 for (i = 0; i < sen->num_entries; i++) {
885 slprintf(temp, sizeof(temp) - 1, "sid[%d]", i);
886 if(!smb_io_dom_sid2(temp, &sen->sid[i], ps, depth)) {
894 /*******************************************************************
895 Inits an LSA_R_ENUM_TRUST_DOM structure.
896 ********************************************************************/
898 void init_q_lookup_sids(TALLOC_CTX *mem_ctx, LSA_Q_LOOKUP_SIDS *q_l,
899 POLICY_HND *hnd, int num_sids, const DOM_SID *sids,
902 DEBUG(5, ("init_q_lookup_sids\n"));
906 memcpy(&q_l->pol, hnd, sizeof(q_l->pol));
907 init_lsa_sid_enum(mem_ctx, &q_l->sids, num_sids, sids);
909 q_l->level.value = level;
912 /*******************************************************************
913 Reads or writes a LSA_Q_LOOKUP_SIDS structure.
914 ********************************************************************/
916 BOOL lsa_io_q_lookup_sids(const char *desc, LSA_Q_LOOKUP_SIDS *q_s, prs_struct *ps,
919 prs_debug(ps, depth, desc, "lsa_io_q_lookup_sids");
925 if(!smb_io_pol_hnd("pol_hnd", &q_s->pol, ps, depth)) /* policy handle */
927 if(!lsa_io_sid_enum("sids ", &q_s->sids, ps, depth)) /* sids to be looked up */
929 if(!lsa_io_trans_names("names ", &q_s->names, ps, depth)) /* translated names */
931 if(!smb_io_lookup_level("switch ", &q_s->level, ps, depth)) /* lookup level */
934 if(!prs_uint32("mapped_count", ps, depth, &q_s->mapped_count))
940 /*******************************************************************
941 Reads or writes a structure.
942 ********************************************************************/
944 static BOOL lsa_io_trans_names(const char *desc, LSA_TRANS_NAME_ENUM *trn,
945 prs_struct *ps, int depth)
949 prs_debug(ps, depth, desc, "lsa_io_trans_names");
955 if(!prs_uint32("num_entries ", ps, depth, &trn->num_entries))
957 if(!prs_uint32("ptr_trans_names", ps, depth, &trn->ptr_trans_names))
960 if (trn->ptr_trans_names != 0) {
961 if(!prs_uint32("num_entries2 ", ps, depth,
965 if (UNMARSHALLING(ps)) {
966 if ((trn->name = PRS_ALLOC_MEM(ps, LSA_TRANS_NAME, trn->num_entries)) == NULL) {
970 if ((trn->uni_name = PRS_ALLOC_MEM(ps, UNISTR2, trn->num_entries)) == NULL) {
975 for (i = 0; i < trn->num_entries2; i++) {
977 slprintf(t, sizeof(t) - 1, "name[%d] ", i);
979 if(!lsa_io_trans_name(t, &trn->name[i], ps, depth)) /* translated name */
983 for (i = 0; i < trn->num_entries2; i++) {
985 slprintf(t, sizeof(t) - 1, "name[%d] ", i);
987 if(!smb_io_unistr2(t, &trn->uni_name[i], trn->name[i].hdr_name.buffer, ps, depth))
997 /*******************************************************************
998 Reads or writes a structure.
999 ********************************************************************/
1001 BOOL lsa_io_r_lookup_sids(const char *desc, LSA_R_LOOKUP_SIDS *r_s,
1002 prs_struct *ps, int depth)
1004 prs_debug(ps, depth, desc, "lsa_io_r_lookup_sids");
1010 if(!prs_uint32("ptr_dom_ref", ps, depth, &r_s->ptr_dom_ref))
1013 if (r_s->ptr_dom_ref != 0)
1014 if(!lsa_io_dom_r_ref ("dom_ref", r_s->dom_ref, ps, depth)) /* domain reference info */
1017 if(!lsa_io_trans_names("names ", r_s->names, ps, depth)) /* translated names */
1023 if(!prs_uint32("mapped_count", ps, depth, &r_s->mapped_count))
1026 if(!prs_ntstatus("status ", ps, depth, &r_s->status))
1032 /*******************************************************************
1034 ********************************************************************/
1036 void init_q_lookup_names(TALLOC_CTX *mem_ctx, LSA_Q_LOOKUP_NAMES *q_l,
1037 POLICY_HND *hnd, int num_names, const char **names)
1041 DEBUG(5, ("init_q_lookup_names\n"));
1046 q_l->num_entries = num_names;
1047 q_l->num_entries2 = num_names;
1048 q_l->lookup_level = 1;
1050 if ((q_l->uni_name = TALLOC_ZERO_ARRAY(mem_ctx, UNISTR2, num_names)) == NULL) {
1051 DEBUG(3, ("init_q_lookup_names(): out of memory\n"));
1055 if ((q_l->hdr_name = TALLOC_ZERO_ARRAY(mem_ctx, UNIHDR, num_names)) == NULL) {
1056 DEBUG(3, ("init_q_lookup_names(): out of memory\n"));
1060 for (i = 0; i < num_names; i++) {
1061 init_unistr2(&q_l->uni_name[i], names[i], UNI_FLAGS_NONE);
1062 init_uni_hdr(&q_l->hdr_name[i], &q_l->uni_name[i]);
1066 /*******************************************************************
1067 reads or writes a structure.
1068 ********************************************************************/
1070 BOOL lsa_io_q_lookup_names(const char *desc, LSA_Q_LOOKUP_NAMES *q_r,
1071 prs_struct *ps, int depth)
1075 prs_debug(ps, depth, desc, "lsa_io_q_lookup_names");
1081 if(!smb_io_pol_hnd("", &q_r->pol, ps, depth)) /* policy handle */
1086 if(!prs_uint32("num_entries ", ps, depth, &q_r->num_entries))
1088 if(!prs_uint32("num_entries2 ", ps, depth, &q_r->num_entries2))
1091 if (UNMARSHALLING(ps)) {
1092 if (q_r->num_entries) {
1093 if ((q_r->hdr_name = PRS_ALLOC_MEM(ps, UNIHDR, q_r->num_entries)) == NULL)
1095 if ((q_r->uni_name = PRS_ALLOC_MEM(ps, UNISTR2, q_r->num_entries)) == NULL)
1100 for (i = 0; i < q_r->num_entries; i++) {
1103 if(!smb_io_unihdr("hdr_name", &q_r->hdr_name[i], ps, depth)) /* pointer names */
1107 for (i = 0; i < q_r->num_entries; i++) {
1110 if(!smb_io_unistr2("dom_name", &q_r->uni_name[i], q_r->hdr_name[i].buffer, ps, depth)) /* names to be looked up */
1116 if(!prs_uint32("num_trans_entries ", ps, depth, &q_r->num_trans_entries))
1118 if(!prs_uint32("ptr_trans_sids ", ps, depth, &q_r->ptr_trans_sids))
1120 if(!prs_uint32("lookup_level ", ps, depth, &q_r->lookup_level))
1122 if(!prs_uint32("mapped_count ", ps, depth, &q_r->mapped_count))
1128 /*******************************************************************
1129 reads or writes a structure.
1130 ********************************************************************/
1132 BOOL lsa_io_r_lookup_names(const char *desc, LSA_R_LOOKUP_NAMES *r_r,
1133 prs_struct *ps, int depth)
1137 prs_debug(ps, depth, desc, "lsa_io_r_lookup_names");
1143 if(!prs_uint32("ptr_dom_ref", ps, depth, &r_r->ptr_dom_ref))
1146 if (r_r->ptr_dom_ref != 0)
1147 if(!lsa_io_dom_r_ref("", r_r->dom_ref, ps, depth))
1150 if(!prs_uint32("num_entries", ps, depth, &r_r->num_entries))
1152 if(!prs_uint32("ptr_entries", ps, depth, &r_r->ptr_entries))
1155 if (r_r->ptr_entries != 0) {
1156 if(!prs_uint32("num_entries2", ps, depth, &r_r->num_entries2))
1159 if (r_r->num_entries2 != r_r->num_entries) {
1164 if (UNMARSHALLING(ps)) {
1165 if ((r_r->dom_rid = PRS_ALLOC_MEM(ps, DOM_RID2, r_r->num_entries2))
1167 DEBUG(3, ("lsa_io_r_lookup_names(): out of memory\n"));
1172 for (i = 0; i < r_r->num_entries2; i++)
1173 if(!smb_io_dom_rid2("", &r_r->dom_rid[i], ps, depth)) /* domain RIDs being looked up */
1177 if(!prs_uint32("mapped_count", ps, depth, &r_r->mapped_count))
1180 if(!prs_ntstatus("status ", ps, depth, &r_r->status))
1187 /*******************************************************************
1188 Inits an LSA_Q_CLOSE structure.
1189 ********************************************************************/
1191 void init_lsa_q_close(LSA_Q_CLOSE *q_c, POLICY_HND *hnd)
1193 DEBUG(5, ("init_lsa_q_close\n"));
1195 memcpy(&q_c->pol, hnd, sizeof(q_c->pol));
1198 /*******************************************************************
1199 Reads or writes an LSA_Q_CLOSE structure.
1200 ********************************************************************/
1202 BOOL lsa_io_q_close(const char *desc, LSA_Q_CLOSE *q_c, prs_struct *ps, int depth)
1204 prs_debug(ps, depth, desc, "lsa_io_q_close");
1207 if(!smb_io_pol_hnd("", &q_c->pol, ps, depth))
1213 /*******************************************************************
1214 Reads or writes an LSA_R_CLOSE structure.
1215 ********************************************************************/
1217 BOOL lsa_io_r_close(const char *desc, LSA_R_CLOSE *r_c, prs_struct *ps, int depth)
1219 prs_debug(ps, depth, desc, "lsa_io_r_close");
1222 if(!smb_io_pol_hnd("", &r_c->pol, ps, depth))
1225 if(!prs_ntstatus("status", ps, depth, &r_c->status))
1231 /*******************************************************************
1232 Reads or writes an LSA_Q_OPEN_SECRET structure.
1233 ********************************************************************/
1235 BOOL lsa_io_q_open_secret(const char *desc, LSA_Q_OPEN_SECRET *q_c, prs_struct *ps, int depth)
1237 prs_debug(ps, depth, desc, "lsa_io_q_open_secret");
1240 /* Don't bother to read or write at present... */
1244 /*******************************************************************
1245 Reads or writes an LSA_R_OPEN_SECRET structure.
1246 ********************************************************************/
1248 BOOL lsa_io_r_open_secret(const char *desc, LSA_R_OPEN_SECRET *r_c, prs_struct *ps, int depth)
1250 prs_debug(ps, depth, desc, "lsa_io_r_open_secret");
1256 if(!prs_uint32("dummy1", ps, depth, &r_c->dummy1))
1258 if(!prs_uint32("dummy2", ps, depth, &r_c->dummy2))
1260 if(!prs_uint32("dummy3", ps, depth, &r_c->dummy3))
1262 if(!prs_uint32("dummy4", ps, depth, &r_c->dummy4))
1264 if(!prs_ntstatus("status", ps, depth, &r_c->status))
1270 /*******************************************************************
1271 Inits an LSA_Q_ENUM_PRIVS structure.
1272 ********************************************************************/
1274 void init_q_enum_privs(LSA_Q_ENUM_PRIVS *q_q, POLICY_HND *hnd, uint32 enum_context, uint32 pref_max_length)
1276 DEBUG(5, ("init_q_enum_privs\n"));
1278 memcpy(&q_q->pol, hnd, sizeof(q_q->pol));
1280 q_q->enum_context = enum_context;
1281 q_q->pref_max_length = pref_max_length;
1284 /*******************************************************************
1285 reads or writes a structure.
1286 ********************************************************************/
1287 BOOL lsa_io_q_enum_privs(const char *desc, LSA_Q_ENUM_PRIVS *q_q, prs_struct *ps, int depth)
1292 prs_debug(ps, depth, desc, "lsa_io_q_enum_privs");
1295 if (!smb_io_pol_hnd("", &q_q->pol, ps, depth))
1298 if(!prs_uint32("enum_context ", ps, depth, &q_q->enum_context))
1300 if(!prs_uint32("pref_max_length", ps, depth, &q_q->pref_max_length))
1306 /*******************************************************************
1307 reads or writes a structure.
1308 ********************************************************************/
1309 static BOOL lsa_io_priv_entries(const char *desc, LSA_PRIV_ENTRY *entries, uint32 count, prs_struct *ps, int depth)
1313 if (entries == NULL)
1316 prs_debug(ps, depth, desc, "lsa_io_priv_entries");
1322 for (i = 0; i < count; i++) {
1323 if (!smb_io_unihdr("", &entries[i].hdr_name, ps, depth))
1325 if(!prs_uint32("luid_low ", ps, depth, &entries[i].luid_low))
1327 if(!prs_uint32("luid_high", ps, depth, &entries[i].luid_high))
1331 for (i = 0; i < count; i++)
1332 if (!smb_io_unistr2("", &entries[i].name, entries[i].hdr_name.buffer, ps, depth))
1338 /*******************************************************************
1339 Inits an LSA_R_ENUM_PRIVS structure.
1340 ********************************************************************/
1342 void init_lsa_r_enum_privs(LSA_R_ENUM_PRIVS *r_u, uint32 enum_context,
1343 uint32 count, LSA_PRIV_ENTRY *entries)
1345 DEBUG(5, ("init_lsa_r_enum_privs\n"));
1347 r_u->enum_context=enum_context;
1350 if (entries!=NULL) {
1361 /*******************************************************************
1362 reads or writes a structure.
1363 ********************************************************************/
1364 BOOL lsa_io_r_enum_privs(const char *desc, LSA_R_ENUM_PRIVS *r_q, prs_struct *ps, int depth)
1369 prs_debug(ps, depth, desc, "lsa_io_r_enum_privs");
1375 if(!prs_uint32("enum_context", ps, depth, &r_q->enum_context))
1377 if(!prs_uint32("count", ps, depth, &r_q->count))
1379 if(!prs_uint32("ptr", ps, depth, &r_q->ptr))
1383 if(!prs_uint32("count1", ps, depth, &r_q->count1))
1386 if (UNMARSHALLING(ps))
1387 if (!(r_q->privs = PRS_ALLOC_MEM(ps, LSA_PRIV_ENTRY, r_q->count1)))
1390 if (!lsa_io_priv_entries("", r_q->privs, r_q->count1, ps, depth))
1397 if(!prs_ntstatus("status", ps, depth, &r_q->status))
1403 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)
1405 memcpy(&trn->pol, hnd, sizeof(trn->pol));
1407 init_unistr2(&trn->name, name, UNI_FLAGS_NONE);
1408 init_uni_hdr(&trn->hdr_name, &trn->name);
1409 trn->lang_id = lang_id;
1410 trn->lang_id_sys = lang_id_sys;
1413 /*******************************************************************
1414 reads or writes a structure.
1415 ********************************************************************/
1416 BOOL lsa_io_q_priv_get_dispname(const char *desc, LSA_Q_PRIV_GET_DISPNAME *q_q, prs_struct *ps, int depth)
1421 prs_debug(ps, depth, desc, "lsa_io_q_priv_get_dispname");
1427 if (!smb_io_pol_hnd("", &q_q->pol, ps, depth))
1430 if (!smb_io_unihdr("hdr_name", &q_q->hdr_name, ps, depth))
1433 if (!smb_io_unistr2("name", &q_q->name, q_q->hdr_name.buffer, ps, depth))
1436 if(!prs_uint16("lang_id ", ps, depth, &q_q->lang_id))
1438 if(!prs_uint16("lang_id_sys", ps, depth, &q_q->lang_id_sys))
1444 /*******************************************************************
1445 reads or writes a structure.
1446 ********************************************************************/
1447 BOOL lsa_io_r_priv_get_dispname(const char *desc, LSA_R_PRIV_GET_DISPNAME *r_q, prs_struct *ps, int depth)
1452 prs_debug(ps, depth, desc, "lsa_io_r_priv_get_dispname");
1458 if (!prs_uint32("ptr_info", ps, depth, &r_q->ptr_info))
1462 if (!smb_io_unihdr("hdr_name", &r_q->hdr_desc, ps, depth))
1465 if (!smb_io_unistr2("desc", &r_q->desc, r_q->hdr_desc.buffer, ps, depth))
1472 if(!prs_uint16("lang_id", ps, depth, &r_q->lang_id))
1477 if(!prs_ntstatus("status", ps, depth, &r_q->status))
1484 initialise a LSA_Q_ENUM_ACCOUNTS structure
1486 void init_lsa_q_enum_accounts(LSA_Q_ENUM_ACCOUNTS *trn, POLICY_HND *hnd, uint32 enum_context, uint32 pref_max_length)
1488 memcpy(&trn->pol, hnd, sizeof(trn->pol));
1490 trn->enum_context = enum_context;
1491 trn->pref_max_length = pref_max_length;
1494 /*******************************************************************
1495 reads or writes a structure.
1496 ********************************************************************/
1497 BOOL lsa_io_q_enum_accounts(const char *desc, LSA_Q_ENUM_ACCOUNTS *q_q, prs_struct *ps, int depth)
1502 prs_debug(ps, depth, desc, "lsa_io_q_enum_accounts");
1505 if (!smb_io_pol_hnd("", &q_q->pol, ps, depth))
1508 if(!prs_uint32("enum_context ", ps, depth, &q_q->enum_context))
1510 if(!prs_uint32("pref_max_length", ps, depth, &q_q->pref_max_length))
1517 /*******************************************************************
1518 Inits an LSA_R_ENUM_PRIVS structure.
1519 ********************************************************************/
1521 void init_lsa_r_enum_accounts(LSA_R_ENUM_ACCOUNTS *r_u, uint32 enum_context)
1523 DEBUG(5, ("init_lsa_r_enum_accounts\n"));
1525 r_u->enum_context=enum_context;
1526 if (r_u->enum_context!=0) {
1527 r_u->sids.num_entries=enum_context;
1528 r_u->sids.ptr_sid_enum=1;
1529 r_u->sids.num_entries2=enum_context;
1531 r_u->sids.num_entries=0;
1532 r_u->sids.ptr_sid_enum=0;
1533 r_u->sids.num_entries2=0;
1537 /*******************************************************************
1538 reads or writes a structure.
1539 ********************************************************************/
1540 BOOL lsa_io_r_enum_accounts(const char *desc, LSA_R_ENUM_ACCOUNTS *r_q, prs_struct *ps, int depth)
1545 prs_debug(ps, depth, desc, "lsa_io_r_enum_accounts");
1551 if(!prs_uint32("enum_context", ps, depth, &r_q->enum_context))
1554 if (!lsa_io_sid_enum("sids", &r_q->sids, ps, depth))
1560 if(!prs_ntstatus("status", ps, depth, &r_q->status))
1567 /*******************************************************************
1568 Reads or writes an LSA_Q_UNK_GET_CONNUSER structure.
1569 ********************************************************************/
1571 BOOL lsa_io_q_unk_get_connuser(const char *desc, LSA_Q_UNK_GET_CONNUSER *q_c, prs_struct *ps, int depth)
1573 prs_debug(ps, depth, desc, "lsa_io_q_unk_get_connuser");
1579 if(!prs_uint32("ptr_srvname", ps, depth, &q_c->ptr_srvname))
1582 if(!smb_io_unistr2("uni2_srvname", &q_c->uni2_srvname, q_c->ptr_srvname, ps, depth)) /* server name to be looked up */
1588 if(!prs_uint32("unk1", ps, depth, &q_c->unk1))
1590 if(!prs_uint32("unk2", ps, depth, &q_c->unk2))
1592 if(!prs_uint32("unk3", ps, depth, &q_c->unk3))
1595 /* Don't bother to read or write at present... */
1599 /*******************************************************************
1600 Reads or writes an LSA_R_UNK_GET_CONNUSER structure.
1601 ********************************************************************/
1603 BOOL lsa_io_r_unk_get_connuser(const char *desc, LSA_R_UNK_GET_CONNUSER *r_c, prs_struct *ps, int depth)
1605 prs_debug(ps, depth, desc, "lsa_io_r_unk_get_connuser");
1611 if(!prs_uint32("ptr_user_name", ps, depth, &r_c->ptr_user_name))
1613 if(!smb_io_unihdr("hdr_user_name", &r_c->hdr_user_name, ps, depth))
1615 if(!smb_io_unistr2("uni2_user_name", &r_c->uni2_user_name, r_c->ptr_user_name, ps, depth))
1621 if(!prs_uint32("unk1", ps, depth, &r_c->unk1))
1624 if(!prs_uint32("ptr_dom_name", ps, depth, &r_c->ptr_dom_name))
1626 if(!smb_io_unihdr("hdr_dom_name", &r_c->hdr_dom_name, ps, depth))
1628 if(!smb_io_unistr2("uni2_dom_name", &r_c->uni2_dom_name, r_c->ptr_dom_name, ps, depth))
1634 if(!prs_ntstatus("status", ps, depth, &r_c->status))
1640 void init_lsa_q_create_account(LSA_Q_CREATEACCOUNT *trn, POLICY_HND *hnd, DOM_SID *sid, uint32 desired_access)
1642 memcpy(&trn->pol, hnd, sizeof(trn->pol));
1644 init_dom_sid2(&trn->sid, sid);
1645 trn->access = desired_access;
1649 /*******************************************************************
1650 Reads or writes an LSA_Q_CREATEACCOUNT structure.
1651 ********************************************************************/
1653 BOOL lsa_io_q_create_account(const char *desc, LSA_Q_CREATEACCOUNT *r_c, prs_struct *ps, int depth)
1655 prs_debug(ps, depth, desc, "lsa_io_q_create_account");
1661 if(!smb_io_pol_hnd("pol", &r_c->pol, ps, depth))
1664 if(!smb_io_dom_sid2("sid", &r_c->sid, ps, depth)) /* domain SID */
1667 if(!prs_uint32("access", ps, depth, &r_c->access))
1673 /*******************************************************************
1674 Reads or writes an LSA_R_CREATEACCOUNT structure.
1675 ********************************************************************/
1677 BOOL lsa_io_r_create_account(const char *desc, LSA_R_CREATEACCOUNT *r_c, prs_struct *ps, int depth)
1679 prs_debug(ps, depth, desc, "lsa_io_r_open_account");
1685 if(!smb_io_pol_hnd("pol", &r_c->pol, ps, depth))
1688 if(!prs_ntstatus("status", ps, depth, &r_c->status))
1695 void init_lsa_q_open_account(LSA_Q_OPENACCOUNT *trn, POLICY_HND *hnd, DOM_SID *sid, uint32 desired_access)
1697 memcpy(&trn->pol, hnd, sizeof(trn->pol));
1699 init_dom_sid2(&trn->sid, sid);
1700 trn->access = desired_access;
1703 /*******************************************************************
1704 Reads or writes an LSA_Q_OPENACCOUNT structure.
1705 ********************************************************************/
1707 BOOL lsa_io_q_open_account(const char *desc, LSA_Q_OPENACCOUNT *r_c, prs_struct *ps, int depth)
1709 prs_debug(ps, depth, desc, "lsa_io_q_open_account");
1715 if(!smb_io_pol_hnd("pol", &r_c->pol, ps, depth))
1718 if(!smb_io_dom_sid2("sid", &r_c->sid, ps, depth)) /* domain SID */
1721 if(!prs_uint32("access", ps, depth, &r_c->access))
1727 /*******************************************************************
1728 Reads or writes an LSA_R_OPENACCOUNT structure.
1729 ********************************************************************/
1731 BOOL lsa_io_r_open_account(const char *desc, LSA_R_OPENACCOUNT *r_c, prs_struct *ps, int depth)
1733 prs_debug(ps, depth, desc, "lsa_io_r_open_account");
1739 if(!smb_io_pol_hnd("pol", &r_c->pol, ps, depth))
1742 if(!prs_ntstatus("status", ps, depth, &r_c->status))
1749 void init_lsa_q_enum_privsaccount(LSA_Q_ENUMPRIVSACCOUNT *trn, POLICY_HND *hnd)
1751 memcpy(&trn->pol, hnd, sizeof(trn->pol));
1755 /*******************************************************************
1756 Reads or writes an LSA_Q_ENUMPRIVSACCOUNT structure.
1757 ********************************************************************/
1759 BOOL lsa_io_q_enum_privsaccount(const char *desc, LSA_Q_ENUMPRIVSACCOUNT *r_c, prs_struct *ps, int depth)
1761 prs_debug(ps, depth, desc, "lsa_io_q_enum_privsaccount");
1767 if(!smb_io_pol_hnd("pol", &r_c->pol, ps, depth))
1773 /*******************************************************************
1774 Reads or writes an LUID structure.
1775 ********************************************************************/
1777 static BOOL lsa_io_luid(const char *desc, LUID *r_c, prs_struct *ps, int depth)
1779 prs_debug(ps, depth, desc, "lsa_io_luid");
1785 if(!prs_uint32("low", ps, depth, &r_c->low))
1788 if(!prs_uint32("high", ps, depth, &r_c->high))
1794 /*******************************************************************
1795 Reads or writes an LUID_ATTR structure.
1796 ********************************************************************/
1798 static BOOL lsa_io_luid_attr(const char *desc, LUID_ATTR *r_c, prs_struct *ps, int depth)
1800 prs_debug(ps, depth, desc, "lsa_io_luid_attr");
1806 if (!lsa_io_luid(desc, &r_c->luid, ps, depth))
1809 if(!prs_uint32("attr", ps, depth, &r_c->attr))
1815 /*******************************************************************
1816 Reads or writes an PRIVILEGE_SET structure.
1817 ********************************************************************/
1819 static BOOL lsa_io_privilege_set(const char *desc, PRIVILEGE_SET *r_c, prs_struct *ps, int depth)
1823 prs_debug(ps, depth, desc, "lsa_io_privilege_set");
1829 if(!prs_uint32("count", ps, depth, &r_c->count))
1831 if(!prs_uint32("control", ps, depth, &r_c->control))
1834 for (i=0; i<r_c->count; i++) {
1835 if (!lsa_io_luid_attr(desc, &r_c->set[i], ps, depth))
1842 NTSTATUS init_lsa_r_enum_privsaccount(TALLOC_CTX *mem_ctx, LSA_R_ENUMPRIVSACCOUNT *r_u, LUID_ATTR *set, uint32 count, uint32 control)
1844 NTSTATUS ret = NT_STATUS_OK;
1849 if ( !NT_STATUS_IS_OK(ret = privilege_set_init_by_ctx(mem_ctx, &(r_u->set))) )
1852 r_u->set.count = count;
1854 if (!NT_STATUS_IS_OK(ret = dup_luid_attr(r_u->set.mem_ctx, &(r_u->set.set), set, count)))
1857 DEBUG(10,("init_lsa_r_enum_privsaccount: %d privileges\n", r_u->count));
1862 /*******************************************************************
1863 Reads or writes an LSA_R_ENUMPRIVSACCOUNT structure.
1864 ********************************************************************/
1866 BOOL lsa_io_r_enum_privsaccount(const char *desc, LSA_R_ENUMPRIVSACCOUNT *r_c, prs_struct *ps, int depth)
1868 prs_debug(ps, depth, desc, "lsa_io_r_enum_privsaccount");
1874 if(!prs_uint32("ptr", ps, depth, &r_c->ptr))
1878 if(!prs_uint32("count", ps, depth, &r_c->count))
1881 /* malloc memory if unmarshalling here */
1883 if (UNMARSHALLING(ps) && r_c->count != 0) {
1884 if (!NT_STATUS_IS_OK(privilege_set_init_by_ctx(ps->mem_ctx, &(r_c->set))))
1887 if (!(r_c->set.set = PRS_ALLOC_MEM(ps,LUID_ATTR,r_c->count)))
1892 if(!lsa_io_privilege_set(desc, &r_c->set, ps, depth))
1896 if(!prs_ntstatus("status", ps, depth, &r_c->status))
1904 /*******************************************************************
1905 Reads or writes an LSA_Q_GETSYSTEMACCOUNTstructure.
1906 ********************************************************************/
1908 BOOL lsa_io_q_getsystemaccount(const char *desc, LSA_Q_GETSYSTEMACCOUNT *r_c, prs_struct *ps, int depth)
1910 prs_debug(ps, depth, desc, "lsa_io_q_getsystemaccount");
1916 if(!smb_io_pol_hnd("pol", &r_c->pol, ps, depth))
1922 /*******************************************************************
1923 Reads or writes an LSA_R_GETSYSTEMACCOUNTstructure.
1924 ********************************************************************/
1926 BOOL lsa_io_r_getsystemaccount(const char *desc, LSA_R_GETSYSTEMACCOUNT *r_c, prs_struct *ps, int depth)
1928 prs_debug(ps, depth, desc, "lsa_io_r_getsystemaccount");
1934 if(!prs_uint32("access", ps, depth, &r_c->access))
1937 if(!prs_ntstatus("status", ps, depth, &r_c->status))
1944 /*******************************************************************
1945 Reads or writes an LSA_Q_SETSYSTEMACCOUNT structure.
1946 ********************************************************************/
1948 BOOL lsa_io_q_setsystemaccount(const char *desc, LSA_Q_SETSYSTEMACCOUNT *r_c, prs_struct *ps, int depth)
1950 prs_debug(ps, depth, desc, "lsa_io_q_setsystemaccount");
1956 if(!smb_io_pol_hnd("pol", &r_c->pol, ps, depth))
1959 if(!prs_uint32("access", ps, depth, &r_c->access))
1965 /*******************************************************************
1966 Reads or writes an LSA_R_SETSYSTEMACCOUNT structure.
1967 ********************************************************************/
1969 BOOL lsa_io_r_setsystemaccount(const char *desc, LSA_R_SETSYSTEMACCOUNT *r_c, prs_struct *ps, int depth)
1971 prs_debug(ps, depth, desc, "lsa_io_r_setsystemaccount");
1977 if(!prs_ntstatus("status", ps, depth, &r_c->status))
1984 static void init_lsa_string( LSA_STRING *uni, const char *string )
1986 init_unistr2(&uni->unistring, string, UNI_FLAGS_NONE);
1987 init_uni_hdr(&uni->hdr, &uni->unistring);
1990 void init_lsa_q_lookup_priv_value(LSA_Q_LOOKUP_PRIV_VALUE *q_u, POLICY_HND *hnd, const char *name)
1992 memcpy(&q_u->pol, hnd, sizeof(q_u->pol));
1993 init_lsa_string( &q_u->privname, name );
1996 BOOL smb_io_lsa_string( const char *desc, LSA_STRING *string, prs_struct *ps, int depth )
1998 prs_debug(ps, depth, desc, "smb_io_lsa_string");
2001 if(!smb_io_unihdr ("hdr", &string->hdr, ps, depth))
2003 if(!smb_io_unistr2("unistring", &string->unistring, string->hdr.buffer, ps, depth))
2009 /*******************************************************************
2010 Reads or writes an LSA_Q_LOOKUP_PRIV_VALUE structure.
2011 ********************************************************************/
2013 BOOL lsa_io_q_lookup_priv_value(const char *desc, LSA_Q_LOOKUP_PRIV_VALUE *r_c, prs_struct *ps, int depth)
2015 prs_debug(ps, depth, desc, "lsa_io_q_lookup_priv_value");
2021 if(!smb_io_pol_hnd("pol", &r_c->pol, ps, depth))
2023 if(!smb_io_lsa_string("privname", &r_c->privname, ps, depth))
2029 /*******************************************************************
2030 Reads or writes an LSA_R_LOOKUP_PRIV_VALUE structure.
2031 ********************************************************************/
2033 BOOL lsa_io_r_lookup_priv_value(const char *desc, LSA_R_LOOKUP_PRIV_VALUE *r_c, prs_struct *ps, int depth)
2035 prs_debug(ps, depth, desc, "lsa_io_r_lookup_priv_value");
2041 if(!lsa_io_luid("luid", &r_c->luid, ps, depth))
2044 if(!prs_ntstatus("status", ps, depth, &r_c->status))
2051 /*******************************************************************
2052 Reads or writes an LSA_Q_ADDPRIVS structure.
2053 ********************************************************************/
2055 BOOL lsa_io_q_addprivs(const char *desc, LSA_Q_ADDPRIVS *r_c, prs_struct *ps, int depth)
2057 prs_debug(ps, depth, desc, "lsa_io_q_addprivs");
2063 if(!smb_io_pol_hnd("pol", &r_c->pol, ps, depth))
2066 if(!prs_uint32("count", ps, depth, &r_c->count))
2069 if (UNMARSHALLING(ps) && r_c->count!=0) {
2070 if (!NT_STATUS_IS_OK(privilege_set_init_by_ctx(ps->mem_ctx, &(r_c->set))))
2073 if (!(r_c->set.set = PRS_ALLOC_MEM(ps, LUID_ATTR, r_c->count)))
2077 if(!lsa_io_privilege_set(desc, &r_c->set, ps, depth))
2083 /*******************************************************************
2084 Reads or writes an LSA_R_ADDPRIVS structure.
2085 ********************************************************************/
2087 BOOL lsa_io_r_addprivs(const char *desc, LSA_R_ADDPRIVS *r_c, prs_struct *ps, int depth)
2089 prs_debug(ps, depth, desc, "lsa_io_r_addprivs");
2095 if(!prs_ntstatus("status", ps, depth, &r_c->status))
2101 /*******************************************************************
2102 Reads or writes an LSA_Q_REMOVEPRIVS structure.
2103 ********************************************************************/
2105 BOOL lsa_io_q_removeprivs(const char *desc, LSA_Q_REMOVEPRIVS *r_c, prs_struct *ps, int depth)
2107 prs_debug(ps, depth, desc, "lsa_io_q_removeprivs");
2113 if(!smb_io_pol_hnd("pol", &r_c->pol, ps, depth))
2116 if(!prs_uint32("allrights", ps, depth, &r_c->allrights))
2119 if(!prs_uint32("ptr", ps, depth, &r_c->ptr))
2123 * JFM: I'm not sure at all if the count is inside the ptr
2124 * never seen one with ptr=0
2128 if(!prs_uint32("count", ps, depth, &r_c->count))
2131 if (UNMARSHALLING(ps) && r_c->count!=0) {
2132 if (!NT_STATUS_IS_OK(privilege_set_init_by_ctx(ps->mem_ctx, &(r_c->set))))
2135 if (!(r_c->set.set = PRS_ALLOC_MEM(ps, LUID_ATTR, r_c->count)))
2139 if(!lsa_io_privilege_set(desc, &r_c->set, ps, depth))
2146 /*******************************************************************
2147 Reads or writes an LSA_R_REMOVEPRIVS structure.
2148 ********************************************************************/
2150 BOOL lsa_io_r_removeprivs(const char *desc, LSA_R_REMOVEPRIVS *r_c, prs_struct *ps, int depth)
2152 prs_debug(ps, depth, desc, "lsa_io_r_removeprivs");
2158 if(!prs_ntstatus("status", ps, depth, &r_c->status))
2164 BOOL policy_handle_is_valid(const POLICY_HND *hnd)
2166 POLICY_HND zero_pol;
2168 ZERO_STRUCT(zero_pol);
2169 return ((memcmp(&zero_pol, hnd, sizeof(POLICY_HND)) == 0) ? False : True );
2172 /*******************************************************************
2173 Reads or writes an LSA_DNS_DOM_INFO structure.
2174 ********************************************************************/
2176 BOOL lsa_io_dns_dom_info(const char *desc, LSA_DNS_DOM_INFO *info,
2177 prs_struct *ps, int depth)
2179 prs_debug(ps, depth, desc, "lsa_io_dns_dom_info");
2184 if(!smb_io_unihdr("nb_name", &info->hdr_nb_dom_name, ps, depth))
2186 if(!smb_io_unihdr("dns_name", &info->hdr_dns_dom_name, ps, depth))
2188 if(!smb_io_unihdr("forest", &info->hdr_forest_name, ps, depth))
2193 if ( !smb_io_uuid("dom_guid", &info->dom_guid, ps, depth) )
2198 if(!prs_uint32("dom_sid", ps, depth, &info->ptr_dom_sid))
2201 if(!smb_io_unistr2("nb_name", &info->uni_nb_dom_name,
2202 info->hdr_nb_dom_name.buffer, ps, depth))
2204 if(!smb_io_unistr2("dns_name", &info->uni_dns_dom_name,
2205 info->hdr_dns_dom_name.buffer, ps, depth))
2207 if(!smb_io_unistr2("forest", &info->uni_forest_name,
2208 info->hdr_forest_name.buffer, ps, depth))
2211 if(!smb_io_dom_sid2("dom_sid", &info->dom_sid, ps, depth))
2218 /*******************************************************************
2219 Inits an LSA_Q_QUERY_INFO2 structure.
2220 ********************************************************************/
2222 void init_q_query2(LSA_Q_QUERY_INFO2 *q_q, POLICY_HND *hnd, uint16 info_class)
2224 DEBUG(5, ("init_q_query2\n"));
2226 memcpy(&q_q->pol, hnd, sizeof(q_q->pol));
2228 q_q->info_class = info_class;
2231 /*******************************************************************
2232 Reads or writes an LSA_Q_QUERY_DNSDOMINFO structure.
2233 ********************************************************************/
2235 BOOL lsa_io_q_query_info2(const char *desc, LSA_Q_QUERY_INFO2 *q_c,
2236 prs_struct *ps, int depth)
2238 prs_debug(ps, depth, desc, "lsa_io_q_query_info2");
2244 if(!smb_io_pol_hnd("pol", &q_c->pol, ps, depth))
2247 if(!prs_uint16("info_class", ps, depth, &q_c->info_class))
2253 /*******************************************************************
2254 Reads or writes an LSA_R_QUERY_DNSDOMINFO structure.
2255 ********************************************************************/
2257 BOOL lsa_io_r_query_info2(const char *desc, LSA_R_QUERY_INFO2 *r_c,
2258 prs_struct *ps, int depth)
2260 prs_debug(ps, depth, desc, "lsa_io_r_query_info2");
2266 if(!prs_uint32("ptr", ps, depth, &r_c->ptr))
2268 if(!prs_uint16("info_class", ps, depth, &r_c->info_class))
2270 switch(r_c->info_class) {
2272 if (!lsa_io_dns_dom_info("info12", &r_c->info.dns_dom_info,
2277 DEBUG(0,("lsa_io_r_query_info2: unknown info class %d\n",
2284 if(!prs_ntstatus("status", ps, depth, &r_c->status))
2290 /*******************************************************************
2291 Inits an LSA_Q_ENUM_ACCT_RIGHTS structure.
2292 ********************************************************************/
2293 void init_q_enum_acct_rights(LSA_Q_ENUM_ACCT_RIGHTS *q_q,
2298 DEBUG(5, ("init_q_enum_acct_rights\n"));
2301 init_dom_sid2(&q_q->sid, sid);
2304 /*******************************************************************
2305 ********************************************************************/
2306 NTSTATUS init_r_enum_acct_rights( LSA_R_ENUM_ACCT_RIGHTS *r_u, PRIVILEGE_SET *privileges )
2310 const char **privname_array = NULL;
2313 for ( i=0; i<privileges->count; i++ ) {
2314 privname = luid_to_privilege_name( &privileges->set[i].luid );
2316 if ( !add_string_to_array( get_talloc_ctx(), privname, &privname_array, &num_priv ) )
2317 return NT_STATUS_NO_MEMORY;
2322 if ( !init_unistr2_array( &r_u->rights, num_priv, privname_array ) )
2323 return NT_STATUS_NO_MEMORY;
2325 r_u->count = num_priv;
2328 return NT_STATUS_OK;
2331 /*******************************************************************
2332 reads or writes a LSA_Q_ENUM_ACCT_RIGHTS structure.
2333 ********************************************************************/
2334 BOOL lsa_io_q_enum_acct_rights(const char *desc, LSA_Q_ENUM_ACCT_RIGHTS *q_q, prs_struct *ps, int depth)
2340 prs_debug(ps, depth, desc, "lsa_io_q_enum_acct_rights");
2343 if (!smb_io_pol_hnd("", &q_q->pol, ps, depth))
2346 if(!smb_io_dom_sid2("sid", &q_q->sid, ps, depth))
2353 /*******************************************************************
2354 reads or writes a LSA_R_ENUM_ACCT_RIGHTS structure.
2355 ********************************************************************/
2356 BOOL lsa_io_r_enum_acct_rights(const char *desc, LSA_R_ENUM_ACCT_RIGHTS *r_c, prs_struct *ps, int depth)
2358 prs_debug(ps, depth, desc, "lsa_io_r_enum_acct_rights");
2361 if(!prs_uint32("count ", ps, depth, &r_c->count))
2364 if(!smb_io_unistr2_array("rights", &r_c->rights, ps, depth))
2370 if(!prs_ntstatus("status", ps, depth, &r_c->status))
2377 /*******************************************************************
2378 Inits an LSA_Q_ADD_ACCT_RIGHTS structure.
2379 ********************************************************************/
2380 void init_q_add_acct_rights(LSA_Q_ADD_ACCT_RIGHTS *q_q,
2384 const char **rights)
2386 DEBUG(5, ("init_q_add_acct_rights\n"));
2389 init_dom_sid2(&q_q->sid, sid);
2390 init_unistr2_array(&q_q->rights, count, rights);
2395 /*******************************************************************
2396 reads or writes a LSA_Q_ADD_ACCT_RIGHTS structure.
2397 ********************************************************************/
2398 BOOL lsa_io_q_add_acct_rights(const char *desc, LSA_Q_ADD_ACCT_RIGHTS *q_q, prs_struct *ps, int depth)
2400 prs_debug(ps, depth, desc, "lsa_io_q_add_acct_rights");
2403 if (!smb_io_pol_hnd("", &q_q->pol, ps, depth))
2406 if(!smb_io_dom_sid2("sid", &q_q->sid, ps, depth))
2409 if(!prs_uint32("count", ps, depth, &q_q->count))
2412 if(!smb_io_unistr2_array("rights", &q_q->rights, ps, depth))
2418 /*******************************************************************
2419 reads or writes a LSA_R_ENUM_ACCT_RIGHTS structure.
2420 ********************************************************************/
2421 BOOL lsa_io_r_add_acct_rights(const char *desc, LSA_R_ADD_ACCT_RIGHTS *r_c, prs_struct *ps, int depth)
2423 prs_debug(ps, depth, desc, "lsa_io_r_add_acct_rights");
2426 if(!prs_ntstatus("status", ps, depth, &r_c->status))
2433 /*******************************************************************
2434 Inits an LSA_Q_REMOVE_ACCT_RIGHTS structure.
2435 ********************************************************************/
2436 void init_q_remove_acct_rights(LSA_Q_REMOVE_ACCT_RIGHTS *q_q,
2441 const char **rights)
2443 DEBUG(5, ("init_q_remove_acct_rights\n"));
2446 init_dom_sid2(&q_q->sid, sid);
2447 q_q->removeall = removeall;
2448 init_unistr2_array(&q_q->rights, count, rights);
2453 /*******************************************************************
2454 reads or writes a LSA_Q_REMOVE_ACCT_RIGHTS structure.
2455 ********************************************************************/
2456 BOOL lsa_io_q_remove_acct_rights(const char *desc, LSA_Q_REMOVE_ACCT_RIGHTS *q_q, prs_struct *ps, int depth)
2458 prs_debug(ps, depth, desc, "lsa_io_q_remove_acct_rights");
2461 if (!smb_io_pol_hnd("", &q_q->pol, ps, depth))
2464 if(!smb_io_dom_sid2("sid", &q_q->sid, ps, depth))
2467 if(!prs_uint32("removeall", ps, depth, &q_q->removeall))
2470 if(!prs_uint32("count", ps, depth, &q_q->count))
2473 if(!smb_io_unistr2_array("rights", &q_q->rights, ps, depth))
2479 /*******************************************************************
2480 reads or writes a LSA_R_ENUM_ACCT_RIGHTS structure.
2481 ********************************************************************/
2482 BOOL lsa_io_r_remove_acct_rights(const char *desc, LSA_R_REMOVE_ACCT_RIGHTS *r_c, prs_struct *ps, int depth)
2484 prs_debug(ps, depth, desc, "lsa_io_r_remove_acct_rights");
2487 if(!prs_ntstatus("status", ps, depth, &r_c->status))