1/* 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 * 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. 14 * 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. 19 * 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. 23 */ 24 25#include "includes.h" 26 27#undef DBGC_CLASS 28#define DBGC_CLASS DBGC_RPC_PARSE 29 30static BOOL lsa_io_trans_names(const char *desc, LSA_TRANS_NAME_ENUM *trn, prs_struct *ps, int depth); 31 32/******************************************************************* 33 Inits a LSA_TRANS_NAME structure. 34********************************************************************/ 35 36void init_lsa_trans_name(LSA_TRANS_NAME *trn, UNISTR2 *uni_name, 37 uint16 sid_name_use, const char *name, uint32 idx) 38{ 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; 43} 44 45/******************************************************************* 46 Reads or writes a LSA_TRANS_NAME structure. 47********************************************************************/ 48 49static BOOL lsa_io_trans_name(const char *desc, LSA_TRANS_NAME *trn, prs_struct *ps, 50 int depth) 51{ 52 prs_debug(ps, depth, desc, "lsa_io_trans_name"); 53 depth++; 54 55 if(!prs_align(ps)) 56 return False; 57 58 if(!prs_uint16("sid_name_use", ps, depth, &trn->sid_name_use)) 59 return False; 60 if(!prs_align(ps)) 61 return False; 62 63 if(!smb_io_unihdr ("hdr_name", &trn->hdr_name, ps, depth)) 64 return False; 65 if(!prs_uint32("domain_idx ", ps, depth, &trn->domain_idx)) 66 return False; 67 68 return True; 69} 70 71/******************************************************************* 72 Reads or writes a DOM_R_REF structure. 73********************************************************************/ 74 75static BOOL lsa_io_dom_r_ref(const char *desc, DOM_R_REF *r_r, prs_struct *ps, 76 int depth) 77{ 78 unsigned int i; 79 80 prs_debug(ps, depth, desc, "lsa_io_dom_r_ref"); 81 depth++; 82 83 if(!prs_align(ps)) 84 return False; 85 86 if(!prs_uint32("num_ref_doms_1", ps, depth, &r_r->num_ref_doms_1)) /* num referenced domains? */ 87 return False; 88 if(!prs_uint32("ptr_ref_dom ", ps, depth, &r_r->ptr_ref_dom)) /* undocumented buffer pointer. */ 89 return False; 90 if(!prs_uint32("max_entries ", ps, depth, &r_r->max_entries)) /* 32 - max number of entries */ 91 return False; 92 93 SMB_ASSERT_ARRAY(r_r->hdr_ref_dom, r_r->num_ref_doms_1); 94 95 if (r_r->ptr_ref_dom != 0) { 96 97 if(!prs_uint32("num_ref_doms_2", ps, depth, &r_r->num_ref_doms_2)) /* 4 - num referenced domains? */ 98 return False; 99 100 SMB_ASSERT_ARRAY(r_r->ref_dom, r_r->num_ref_doms_2); 101 102 for (i = 0; i < r_r->num_ref_doms_1; i++) { 103 fstring t; 104 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)) 107 return False; 108 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)) 111 return False; 112 } 113 114 for (i = 0; i < r_r->num_ref_doms_2; i++) { 115 fstring t; 116 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 */ 120 return False; 121 if(!prs_align(ps)) 122 return False; 123 } 124 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 */ 128 return False; 129 } 130 } 131 } 132 133 return True; 134} 135 136/******************************************************************* 137 Inits an LSA_SEC_QOS structure. 138********************************************************************/ 139 140void init_lsa_sec_qos(LSA_SEC_QOS *qos, uint16 imp_lev, uint8 ctxt, uint8 eff) 141{ 142 DEBUG(5, ("init_lsa_sec_qos\n")); 143 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; 148} 149 150/******************************************************************* 151 Reads or writes an LSA_SEC_QOS structure. 152********************************************************************/ 153 154static BOOL lsa_io_sec_qos(const char *desc, LSA_SEC_QOS *qos, prs_struct *ps, 155 int depth) 156{ 157 uint32 start; 158 159 prs_debug(ps, depth, desc, "lsa_io_obj_qos"); 160 depth++; 161 162 if(!prs_align(ps)) 163 return False; 164 165 start = prs_offset(ps); 166 167 /* these pointers had _better_ be zero, because we don't know 168 what they point to! 169 */ 170 if(!prs_uint32("len ", ps, depth, &qos->len)) /* 0x18 - length (in bytes) inc. the length field. */ 171 return False; 172 if(!prs_uint16("sec_imp_level ", ps, depth, &qos->sec_imp_level )) 173 return False; 174 if(!prs_uint8 ("sec_ctxt_mode ", ps, depth, &qos->sec_ctxt_mode )) 175 return False; 176 if(!prs_uint8 ("effective_only", ps, depth, &qos->effective_only)) 177 return False; 178 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)); 182 } 183 184 return True; 185} 186 187/******************************************************************* 188 Inits an LSA_OBJ_ATTR structure. 189********************************************************************/ 190 191static void init_lsa_obj_attr(LSA_OBJ_ATTR *attr, uint32 attributes, LSA_SEC_QOS *qos) 192{ 193 DEBUG(5, ("init_lsa_obj_attr\n")); 194 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; 200 201 if (qos != NULL) { 202 attr->ptr_sec_qos = 1; 203 attr->sec_qos = qos; 204 } else { 205 attr->ptr_sec_qos = 0; 206 attr->sec_qos = NULL; 207 } 208} 209 210/******************************************************************* 211 Reads or writes an LSA_OBJ_ATTR structure. 212********************************************************************/ 213 214static BOOL lsa_io_obj_attr(const char *desc, LSA_OBJ_ATTR *attr, prs_struct *ps, 215 int depth) 216{ 217 prs_debug(ps, depth, desc, "lsa_io_obj_attr"); 218 depth++; 219 220 if(!prs_align(ps)) 221 return False; 222 223 /* these pointers had _better_ be zero, because we don't know 224 what they point to! 225 */ 226 if(!prs_uint32("len ", ps, depth, &attr->len)) /* 0x18 - length (in bytes) inc. the length field. */ 227 return False; 228 if(!prs_uint32("ptr_root_dir", ps, depth, &attr->ptr_root_dir)) /* 0 - root directory (pointer) */ 229 return False; 230 if(!prs_uint32("ptr_obj_name", ps, depth, &attr->ptr_obj_name)) /* 0 - object name (pointer) */ 231 return False; 232 if(!prs_uint32("attributes ", ps, depth, &attr->attributes)) /* 0 - attributes (undocumented) */ 233 return False; 234 if(!prs_uint32("ptr_sec_desc", ps, depth, &attr->ptr_sec_desc)) /* 0 - security descriptior (pointer) */ 235 return False; 236 if(!prs_uint32("ptr_sec_qos ", ps, depth, &attr->ptr_sec_qos )) /* security quality of service (pointer) */ 237 return False; 238 239 if (attr->ptr_sec_qos != 0) { 240 if (UNMARSHALLING(ps)) 241 if (!(attr->sec_qos = PRS_ALLOC_MEM(ps,LSA_SEC_QOS,1))) 242 return False; 243 244 if(!lsa_io_sec_qos("sec_qos", attr->sec_qos, ps, depth)) 245 return False; 246 } 247 248 return True; 249} 250 251 252/******************************************************************* 253 Inits an LSA_Q_OPEN_POL structure. 254********************************************************************/ 255 256void init_q_open_pol(LSA_Q_OPEN_POL *r_q, uint16 system_name, 257 uint32 attributes, uint32 desired_access, 258 LSA_SEC_QOS *qos) 259{ 260 DEBUG(5, ("init_open_pol: attr:%d da:%d\n", attributes, 261 desired_access)); 262 263 r_q->ptr = 1; /* undocumented pointer */ 264 265 r_q->des_access = desired_access; 266 267 r_q->system_name = system_name; 268 init_lsa_obj_attr(&r_q->attr, attributes, qos); 269} 270 271/******************************************************************* 272 Reads or writes an LSA_Q_OPEN_POL structure. 273********************************************************************/ 274 275BOOL lsa_io_q_open_pol(const char *desc, LSA_Q_OPEN_POL *r_q, prs_struct *ps, 276 int depth) 277{ 278 prs_debug(ps, depth, desc, "lsa_io_q_open_pol"); 279 depth++; 280 281 if(!prs_uint32("ptr ", ps, depth, &r_q->ptr)) 282 return False; 283 if(!prs_uint16("system_name", ps, depth, &r_q->system_name)) 284 return False; 285 if(!prs_align( ps )) 286 return False; 287 288 if(!lsa_io_obj_attr("", &r_q->attr, ps, depth)) 289 return False; 290 291 if(!prs_uint32("des_access", ps, depth, &r_q->des_access)) 292 return False; 293 294 return True; 295} 296 297/******************************************************************* 298 Reads or writes an LSA_R_OPEN_POL structure. 299********************************************************************/ 300 301BOOL lsa_io_r_open_pol(const char *desc, LSA_R_OPEN_POL *r_p, prs_struct *ps, 302 int depth) 303{ 304 prs_debug(ps, depth, desc, "lsa_io_r_open_pol"); 305 depth++; 306 307 if(!smb_io_pol_hnd("", &r_p->pol, ps, depth)) 308 return False; 309 310 if(!prs_ntstatus("status", ps, depth, &r_p->status)) 311 return False; 312 313 return True; 314} 315 316/******************************************************************* 317 Inits an LSA_Q_OPEN_POL2 structure. 318********************************************************************/ 319 320void init_q_open_pol2(LSA_Q_OPEN_POL2 *r_q, const char *server_name, 321 uint32 attributes, uint32 desired_access, 322 LSA_SEC_QOS *qos) 323{ 324 DEBUG(5, ("init_q_open_pol2: attr:%d da:%d\n", attributes, 325 desired_access)); 326 327 r_q->ptr = 1; /* undocumented pointer */ 328 329 r_q->des_access = desired_access; 330 331 init_unistr2(&r_q->uni_server_name, server_name, UNI_STR_TERMINATE); 332 333 init_lsa_obj_attr(&r_q->attr, attributes, qos); 334} 335 336/******************************************************************* 337 Reads or writes an LSA_Q_OPEN_POL2 structure. 338********************************************************************/ 339 340BOOL lsa_io_q_open_pol2(const char *desc, LSA_Q_OPEN_POL2 *r_q, prs_struct *ps, 341 int depth) 342{ 343 prs_debug(ps, depth, desc, "lsa_io_q_open_pol2"); 344 depth++; 345 346 if(!prs_uint32("ptr ", ps, depth, &r_q->ptr)) 347 return False; 348 349 if(!smb_io_unistr2 ("", &r_q->uni_server_name, r_q->ptr, ps, depth)) 350 return False; 351 if(!lsa_io_obj_attr("", &r_q->attr, ps, depth)) 352 return False; 353 354 if(!prs_uint32("des_access", ps, depth, &r_q->des_access)) 355 return False; 356 357 return True; 358} 359 360/******************************************************************* 361 Reads or writes an LSA_R_OPEN_POL2 structure. 362********************************************************************/ 363 364BOOL lsa_io_r_open_pol2(const char *desc, LSA_R_OPEN_POL2 *r_p, prs_struct *ps, 365 int depth) 366{ 367 prs_debug(ps, depth, desc, "lsa_io_r_open_pol2"); 368 depth++; 369 370 if(!smb_io_pol_hnd("", &r_p->pol, ps, depth)) 371 return False; 372 373 if(!prs_ntstatus("status", ps, depth, &r_p->status)) 374 return False; 375 376 return True; 377} 378 379/******************************************************************* 380makes an LSA_Q_QUERY_SEC_OBJ structure. 381********************************************************************/ 382 383void init_q_query_sec_obj(LSA_Q_QUERY_SEC_OBJ *q_q, const POLICY_HND *hnd, 384 uint32 sec_info) 385{ 386 DEBUG(5, ("init_q_query_sec_obj\n")); 387 388 q_q->pol = *hnd; 389 q_q->sec_info = sec_info; 390 391 return; 392} 393 394/******************************************************************* 395 Reads or writes an LSA_Q_QUERY_SEC_OBJ structure. 396********************************************************************/ 397 398BOOL lsa_io_q_query_sec_obj(const char *desc, LSA_Q_QUERY_SEC_OBJ *q_q, 399 prs_struct *ps, int depth) 400{ 401 prs_debug(ps, depth, desc, "lsa_io_q_query_sec_obj"); 402 depth++; 403 404 if (!smb_io_pol_hnd("", &q_q->pol, ps, depth)) 405 return False; 406 407 if (!prs_uint32("sec_info", ps, depth, &q_q->sec_info)) 408 return False; 409 410 return True; 411} 412 413/******************************************************************* 414 Reads or writes a LSA_R_QUERY_SEC_OBJ structure. 415********************************************************************/ 416 417BOOL lsa_io_r_query_sec_obj(const char *desc, LSA_R_QUERY_SEC_OBJ *r_u, 418 prs_struct *ps, int depth) 419{ 420 prs_debug(ps, depth, desc, "lsa_io_r_query_sec_obj"); 421 depth++; 422 423 if (!prs_align(ps)) 424 return False; 425 426 if (!prs_uint32("ptr", ps, depth, &r_u->ptr)) 427 return False; 428 429 if (r_u->ptr != 0) { 430 if (!sec_io_desc_buf("sec", &r_u->buf, ps, depth)) 431 return False; 432 } 433 434 if (!prs_ntstatus("status", ps, depth, &r_u->status)) 435 return False; 436 437 return True; 438} 439 440/******************************************************************* 441 Inits an LSA_Q_QUERY_INFO structure. 442********************************************************************/ 443 444void init_q_query(LSA_Q_QUERY_INFO *q_q, POLICY_HND *hnd, uint16 info_class) 445{ 446 DEBUG(5, ("init_q_query\n")); 447 448 memcpy(&q_q->pol, hnd, sizeof(q_q->pol)); 449 450 q_q->info_class = info_class; 451} 452 453/******************************************************************* 454 Reads or writes an LSA_Q_QUERY_INFO structure. 455********************************************************************/ 456 457BOOL lsa_io_q_query(const char *desc, LSA_Q_QUERY_INFO *q_q, prs_struct *ps, 458 int depth) 459{ 460 prs_debug(ps, depth, desc, "lsa_io_q_query"); 461 depth++; 462 463 if(!smb_io_pol_hnd("", &q_q->pol, ps, depth)) 464 return False; 465 466 if(!prs_uint16("info_class", ps, depth, &q_q->info_class)) 467 return False; 468 469 return True; 470} 471 472/******************************************************************* 473makes an LSA_Q_ENUM_TRUST_DOM structure. 474********************************************************************/ 475BOOL init_q_enum_trust_dom(LSA_Q_ENUM_TRUST_DOM * q_e, POLICY_HND *pol, 476 uint32 enum_context, uint32 preferred_len) 477{ 478 DEBUG(5, ("init_q_enum_trust_dom\n")); 479 480 q_e->pol = *pol; 481 q_e->enum_context = enum_context; 482 q_e->preferred_len = preferred_len; 483 484 return True; 485} 486 487/******************************************************************* 488 Reads or writes an LSA_Q_ENUM_TRUST_DOM structure. 489********************************************************************/ 490 491BOOL lsa_io_q_enum_trust_dom(const char *desc, LSA_Q_ENUM_TRUST_DOM *q_e, 492 prs_struct *ps, int depth) 493{ 494 prs_debug(ps, depth, desc, "lsa_io_q_enum_trust_dom"); 495 depth++; 496 497 if(!smb_io_pol_hnd("", &q_e->pol, ps, depth)) 498 return False; 499 500 if(!prs_uint32("enum_context ", ps, depth, &q_e->enum_context)) 501 return False; 502 if(!prs_uint32("preferred_len", ps, depth, &q_e->preferred_len)) 503 return False; 504 505 return True; 506} 507 508/******************************************************************* 509 Inits an LSA_R_ENUM_TRUST_DOM structure. 510********************************************************************/ 511 512void 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) 514{ 515 unsigned int i; 516 517 DEBUG(5, ("init_r_enum_trust_dom\n")); 518 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; 523 524 if (num_domains != 0) { 525 526 /* 527 * allocating empty arrays of unicode headers, strings 528 * and sids of enumerated trusted domains 529 */ 530 if (!(r_e->hdr_domain_name = TALLOC_ARRAY(ctx,UNIHDR2,num_domains))) { 531 r_e->status = NT_STATUS_NO_MEMORY; 532 return; 533 } 534 535 if (!(r_e->uni_domain_name = TALLOC_ARRAY(ctx,UNISTR2,num_domains))) { 536 r_e->status = NT_STATUS_NO_MEMORY; 537 return; 538 } 539 540 if (!(r_e->domain_sid = TALLOC_ARRAY(ctx,DOM_SID2,num_domains))) { 541 r_e->status = NT_STATUS_NO_MEMORY; 542 return; 543 } 544 545 for (i = 0; i < num_domains; i++) { 546 547 /* don't know what actually is this for */ 548 r_e->ptr_enum_domains = 1; 549 550 init_dom_sid2(&r_e->domain_sid[i], &(td[i])->sid); 551 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]); 554 555 }; 556 } 557 558} 559 560/******************************************************************* 561 Reads or writes an LSA_R_ENUM_TRUST_DOM structure. 562********************************************************************/ 563 564BOOL lsa_io_r_enum_trust_dom(const char *desc, LSA_R_ENUM_TRUST_DOM *r_e, 565 prs_struct *ps, int depth) 566{ 567 prs_debug(ps, depth, desc, "lsa_io_r_enum_trust_dom"); 568 depth++; 569 570 if(!prs_uint32("enum_context ", ps, depth, &r_e->enum_context)) 571 return False; 572 if(!prs_uint32("num_domains ", ps, depth, &r_e->num_domains)) 573 return False; 574 if(!prs_uint32("ptr_enum_domains", ps, depth, &r_e->ptr_enum_domains)) 575 return False; 576 577 if (r_e->ptr_enum_domains) { 578 int i, num_domains; 579 580 if(!prs_uint32("num_domains2", ps, depth, &r_e->num_domains2)) 581 return False; 582 583 num_domains = r_e->num_domains2; 584 585 if (UNMARSHALLING(ps)) { 586 if (!(r_e->hdr_domain_name = PRS_ALLOC_MEM(ps,UNIHDR2,num_domains))) 587 return False; 588 589 if (!(r_e->uni_domain_name = PRS_ALLOC_MEM(ps,UNISTR2,num_domains))) 590 return False; 591 592 if (!(r_e->domain_sid = PRS_ALLOC_MEM(ps,DOM_SID2,num_domains))) 593 return False; 594 } 595 596 for (i = 0; i < num_domains; i++) { 597 if(!smb_io_unihdr2 ("", &r_e->hdr_domain_name[i], ps, 598 depth)) 599 return False; 600 } 601 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, 605 ps, depth)) 606 return False; 607 if(!smb_io_dom_sid2("", &r_e->domain_sid[i], ps, 608 depth)) 609 return False; 610 } 611 } 612 613 if(!prs_ntstatus("status", ps, depth, &r_e->status)) 614 return False; 615 616 return True; 617} 618 619/******************************************************************* 620reads or writes a dom query structure. 621********************************************************************/ 622 623static BOOL lsa_io_dom_query(const char *desc, DOM_QUERY *d_q, prs_struct *ps, int depth) 624{ 625 if (d_q == NULL) 626 return False; 627 628 prs_debug(ps, depth, desc, "lsa_io_dom_query"); 629 depth++; 630 631 if(!prs_align(ps)) 632 return False; 633 634 if(!prs_uint16("uni_dom_max_len", ps, depth, &d_q->uni_dom_max_len)) /* domain name string length * 2 */ 635 return False; 636 if(!prs_uint16("uni_dom_str_len", ps, depth, &d_q->uni_dom_str_len)) /* domain name string length * 2 */ 637 return False; 638 639 if(!prs_uint32("buffer_dom_name", ps, depth, &d_q->buffer_dom_name)) /* undocumented domain name string buffer pointer */ 640 return False; 641 if(!prs_uint32("buffer_dom_sid ", ps, depth, &d_q->buffer_dom_sid)) /* undocumented domain SID string buffer pointer */ 642 return False; 643 644 if(!smb_io_unistr2("unistr2", &d_q->uni_domain_name, d_q->buffer_dom_name, ps, depth)) /* domain name (unicode string) */ 645 return False; 646 647 if(!prs_align(ps)) 648 return False; 649 650 if (d_q->buffer_dom_sid != 0) { 651 if(!smb_io_dom_sid2("", &d_q->dom_sid, ps, depth)) /* domain SID */ 652 return False; 653 } else { 654 memset((char *)&d_q->dom_sid, '\0', sizeof(d_q->dom_sid)); 655 } 656 657 return True; 658} 659 660/******************************************************************* 661reads or writes a structure. 662********************************************************************/ 663 664static BOOL lsa_io_dom_query_2(const char *desc, DOM_QUERY_2 *d_q, prs_struct *ps, int depth) 665{ 666 uint32 ptr = 1; 667 668 if (d_q == NULL) 669 return False; 670 671 prs_debug(ps, depth, desc, "lsa_io_dom_query_2"); 672 depth++; 673 674 if (!prs_align(ps)) 675 return False; 676 677 if (!prs_uint32("auditing_enabled", ps, depth, &d_q->auditing_enabled)) 678 return False; 679 if (!prs_uint32("ptr ", ps, depth, &ptr)) 680 return False; 681 if (!prs_uint32("count1", ps, depth, &d_q->count1)) 682 return False; 683 if (!prs_uint32("count2", ps, depth, &d_q->count2)) 684 return False; 685 686 if (UNMARSHALLING(ps)) { 687 d_q->auditsettings = TALLOC_ZERO_ARRAY(ps->mem_ctx, uint32, d_q->count2); 688 } 689 690 if (d_q->auditsettings == NULL) { 691 DEBUG(1, ("lsa_io_dom_query_2: NULL auditsettings!\n")); 692 return False; 693 } 694 695 if (!prs_uint32s(False, "auditsettings", ps, depth, d_q->auditsettings, d_q->count2)) 696 return False; 697 698 return True; 699} 700 701/******************************************************************* 702 Reads or writes a dom query structure. 703********************************************************************/ 704 705static BOOL lsa_io_dom_query_3(const char *desc, DOM_QUERY_3 *d_q, prs_struct *ps, int depth) 706{ 707 return lsa_io_dom_query("", d_q, ps, depth); 708} 709 710/******************************************************************* 711 Reads or writes a dom query structure. 712********************************************************************/ 713 714static BOOL lsa_io_dom_query_5(const char *desc, DOM_QUERY_5 *d_q, prs_struct *ps, int depth) 715{ 716 return lsa_io_dom_query("", d_q, ps, depth); 717} 718 719/******************************************************************* 720 Reads or writes a dom query structure. 721********************************************************************/ 722 723static BOOL lsa_io_dom_query_6(const char *desc, DOM_QUERY_6 *d_q, prs_struct *ps, int depth) 724{ 725 if (d_q == NULL) 726 return False; 727 728 prs_debug(ps, depth, desc, "lsa_io_dom_query_6"); 729 depth++; 730 731 if (!prs_uint16("server_role", ps, depth, &d_q->server_role)) 732 return False; 733 734 return True; 735} 736 737/******************************************************************* 738 Reads or writes an LSA_R_QUERY_INFO structure. 739********************************************************************/ 740 741BOOL lsa_io_r_query(const char *desc, LSA_R_QUERY_INFO *r_q, prs_struct *ps, 742 int depth) 743{ 744 prs_debug(ps, depth, desc, "lsa_io_r_query"); 745 depth++; 746 747 if(!prs_uint32("undoc_buffer", ps, depth, &r_q->undoc_buffer)) 748 return False; 749 750 if (r_q->undoc_buffer != 0) { 751 if(!prs_uint16("info_class", ps, depth, &r_q->info_class)) 752 return False; 753 754 if(!prs_align(ps)) 755 return False; 756 757 switch (r_q->info_class) { 758 case 2: 759 if(!lsa_io_dom_query_2("", &r_q->dom.id2, ps, depth)) 760 return False; 761 break; 762 case 3: 763 if(!lsa_io_dom_query_3("", &r_q->dom.id3, ps, depth)) 764 return False; 765 break; 766 case 5: 767 if(!lsa_io_dom_query_5("", &r_q->dom.id5, ps, depth)) 768 return False; 769 break; 770 case 6: 771 if(!lsa_io_dom_query_6("", &r_q->dom.id6, ps, depth)) 772 return False; 773 break; 774 default: 775 /* PANIC! */ 776 break; 777 } 778 } 779 780 if(!prs_align(ps)) 781 return False; 782 783 if(!prs_ntstatus("status", ps, depth, &r_q->status)) 784 return False; 785 786 return True; 787} 788 789/******************************************************************* 790 Inits a LSA_SID_ENUM structure. 791********************************************************************/ 792 793static void init_lsa_sid_enum(TALLOC_CTX *mem_ctx, LSA_SID_ENUM *sen, 794 int num_entries, const DOM_SID *sids) 795{ 796 int i; 797 798 DEBUG(5, ("init_lsa_sid_enum\n")); 799 800 sen->num_entries = num_entries; 801 sen->ptr_sid_enum = (num_entries != 0); 802 sen->num_entries2 = num_entries; 803 804 /* Allocate memory for sids and sid pointers */ 805 806 if (num_entries == 0) return; 807 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")); 810 return; 811 } 812 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")); 815 return; 816 } 817 818 /* Copy across SIDs and SID pointers */ 819 820 for (i = 0; i < num_entries; i++) { 821 sen->ptr_sid[i] = 1; 822 init_dom_sid2(&sen->sid[i], &sids[i]); 823 } 824} 825 826/******************************************************************* 827 Reads or writes a LSA_SID_ENUM structure. 828********************************************************************/ 829 830static BOOL lsa_io_sid_enum(const char *desc, LSA_SID_ENUM *sen, prs_struct *ps, 831 int depth) 832{ 833 unsigned int i; 834 835 prs_debug(ps, depth, desc, "lsa_io_sid_enum"); 836 depth++; 837 838 if(!prs_align(ps)) 839 return False; 840 841 if(!prs_uint32("num_entries ", ps, depth, &sen->num_entries)) 842 return False; 843 if(!prs_uint32("ptr_sid_enum", ps, depth, &sen->ptr_sid_enum)) 844 return False; 845 846 /* 847 if the ptr is NULL, leave here. checked from a real w2k trace. 848 JFM, 11/23/2001 849 */ 850 851 if (sen->ptr_sid_enum==0) 852 return True; 853 854 if(!prs_uint32("num_entries2", ps, depth, &sen->num_entries2)) 855 return False; 856 857 /* Mallocate memory if we're unpacking from the wire */ 858 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 " 862 "ptr_sid\n")); 863 return False; 864 } 865 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 " 868 "sids\n")); 869 return False; 870 } 871 } 872 873 for (i = 0; i < sen->num_entries; i++) { 874 fstring temp; 875 876 slprintf(temp, sizeof(temp) - 1, "ptr_sid[%d]", i); 877 if(!prs_uint32(temp, ps, depth, &sen->ptr_sid[i])) { 878 return False; 879 } 880 } 881 882 for (i = 0; i < sen->num_entries; i++) { 883 fstring temp; 884 885 slprintf(temp, sizeof(temp) - 1, "sid[%d]", i); 886 if(!smb_io_dom_sid2(temp, &sen->sid[i], ps, depth)) { 887 return False; 888 } 889 } 890 891 return True; 892} 893 894/******************************************************************* 895 Inits an LSA_R_ENUM_TRUST_DOM structure. 896********************************************************************/ 897 898void 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, 900 uint16 level) 901{ 902 DEBUG(5, ("init_q_lookup_sids\n")); 903 904 ZERO_STRUCTP(q_l); 905 906 memcpy(&q_l->pol, hnd, sizeof(q_l->pol)); 907 init_lsa_sid_enum(mem_ctx, &q_l->sids, num_sids, sids); 908 909 q_l->level.value = level; 910} 911 912/******************************************************************* 913 Reads or writes a LSA_Q_LOOKUP_SIDS structure. 914********************************************************************/ 915 916BOOL lsa_io_q_lookup_sids(const char *desc, LSA_Q_LOOKUP_SIDS *q_s, prs_struct *ps, 917 int depth) 918{ 919 prs_debug(ps, depth, desc, "lsa_io_q_lookup_sids"); 920 depth++; 921 922 if(!prs_align(ps)) 923 return False; 924 925 if(!smb_io_pol_hnd("pol_hnd", &q_s->pol, ps, depth)) /* policy handle */ 926 return False; 927 if(!lsa_io_sid_enum("sids ", &q_s->sids, ps, depth)) /* sids to be looked up */ 928 return False; 929 if(!lsa_io_trans_names("names ", &q_s->names, ps, depth)) /* translated names */ 930 return False; 931 if(!smb_io_lookup_level("switch ", &q_s->level, ps, depth)) /* lookup level */ 932 return False; 933 934 if(!prs_uint32("mapped_count", ps, depth, &q_s->mapped_count)) 935 return False; 936 937 return True; 938} 939 940/******************************************************************* 941 Reads or writes a structure. 942********************************************************************/ 943 944static BOOL lsa_io_trans_names(const char *desc, LSA_TRANS_NAME_ENUM *trn, 945 prs_struct *ps, int depth) 946{ 947 unsigned int i; 948 949 prs_debug(ps, depth, desc, "lsa_io_trans_names"); 950 depth++; 951 952 if(!prs_align(ps)) 953 return False; 954 955 if(!prs_uint32("num_entries ", ps, depth, &trn->num_entries)) 956 return False; 957 if(!prs_uint32("ptr_trans_names", ps, depth, &trn->ptr_trans_names)) 958 return False; 959 960 if (trn->ptr_trans_names != 0) { 961 if(!prs_uint32("num_entries2 ", ps, depth, 962 &trn->num_entries2)) 963 return False; 964 965 if (UNMARSHALLING(ps)) { 966 if ((trn->name = PRS_ALLOC_MEM(ps, LSA_TRANS_NAME, trn->num_entries)) == NULL) { 967 return False; 968 } 969 970 if ((trn->uni_name = PRS_ALLOC_MEM(ps, UNISTR2, trn->num_entries)) == NULL) { 971 return False; 972 } 973 } 974 975 for (i = 0; i < trn->num_entries2; i++) { 976 fstring t; 977 slprintf(t, sizeof(t) - 1, "name[%d] ", i); 978 979 if(!lsa_io_trans_name(t, &trn->name[i], ps, depth)) /* translated name */ 980 return False; 981 } 982 983 for (i = 0; i < trn->num_entries2; i++) { 984 fstring t; 985 slprintf(t, sizeof(t) - 1, "name[%d] ", i); 986 987 if(!smb_io_unistr2(t, &trn->uni_name[i], trn->name[i].hdr_name.buffer, ps, depth)) 988 return False; 989 if(!prs_align(ps)) 990 return False; 991 } 992 } 993 994 return True; 995} 996 997/******************************************************************* 998 Reads or writes a structure. 999********************************************************************/ 1000 1001BOOL lsa_io_r_lookup_sids(const char *desc, LSA_R_LOOKUP_SIDS *r_s, 1002 prs_struct *ps, int depth) 1003{ 1004 prs_debug(ps, depth, desc, "lsa_io_r_lookup_sids"); 1005 depth++; 1006 1007 if(!prs_align(ps)) 1008 return False; 1009 1010 if(!prs_uint32("ptr_dom_ref", ps, depth, &r_s->ptr_dom_ref)) 1011 return False; 1012 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 */ 1015 return False; 1016 1017 if(!lsa_io_trans_names("names ", r_s->names, ps, depth)) /* translated names */ 1018 return False; 1019 1020 if(!prs_align(ps)) 1021 return False; 1022 1023 if(!prs_uint32("mapped_count", ps, depth, &r_s->mapped_count)) 1024 return False; 1025 1026 if(!prs_ntstatus("status ", ps, depth, &r_s->status)) 1027 return False; 1028 1029 return True; 1030} 1031 1032/******************************************************************* 1033makes a structure. 1034********************************************************************/ 1035 1036void init_q_lookup_names(TALLOC_CTX *mem_ctx, LSA_Q_LOOKUP_NAMES *q_l, 1037 POLICY_HND *hnd, int num_names, const char **names) 1038{ 1039 unsigned int i; 1040 1041 DEBUG(5, ("init_q_lookup_names\n")); 1042 1043 ZERO_STRUCTP(q_l); 1044 1045 q_l->pol = *hnd; 1046 q_l->num_entries = num_names; 1047 q_l->num_entries2 = num_names; 1048 q_l->lookup_level = 1; 1049 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")); 1052 return; 1053 } 1054 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")); 1057 return; 1058 } 1059 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]); 1063 } 1064} 1065 1066/******************************************************************* 1067reads or writes a structure. 1068********************************************************************/ 1069 1070BOOL lsa_io_q_lookup_names(const char *desc, LSA_Q_LOOKUP_NAMES *q_r, 1071 prs_struct *ps, int depth) 1072{ 1073 unsigned int i; 1074 1075 prs_debug(ps, depth, desc, "lsa_io_q_lookup_names"); 1076 depth++; 1077 1078 if(!prs_align(ps)) 1079 return False; 1080 1081 if(!smb_io_pol_hnd("", &q_r->pol, ps, depth)) /* policy handle */ 1082 return False; 1083 1084 if(!prs_align(ps)) 1085 return False; 1086 if(!prs_uint32("num_entries ", ps, depth, &q_r->num_entries)) 1087 return False; 1088 if(!prs_uint32("num_entries2 ", ps, depth, &q_r->num_entries2)) 1089 return False; 1090 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) 1094 return False; 1095 if ((q_r->uni_name = PRS_ALLOC_MEM(ps, UNISTR2, q_r->num_entries)) == NULL) 1096 return False; 1097 } 1098 } 1099 1100 for (i = 0; i < q_r->num_entries; i++) { 1101 if(!prs_align(ps)) 1102 return False; 1103 if(!smb_io_unihdr("hdr_name", &q_r->hdr_name[i], ps, depth)) /* pointer names */ 1104 return False; 1105 } 1106 1107 for (i = 0; i < q_r->num_entries; i++) { 1108 if(!prs_align(ps)) 1109 return False; 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 */ 1111 return False; 1112 } 1113 1114 if(!prs_align(ps)) 1115 return False; 1116 if(!prs_uint32("num_trans_entries ", ps, depth, &q_r->num_trans_entries)) 1117 return False; 1118 if(!prs_uint32("ptr_trans_sids ", ps, depth, &q_r->ptr_trans_sids)) 1119 return False; 1120 if(!prs_uint32("lookup_level ", ps, depth, &q_r->lookup_level)) 1121 return False; 1122 if(!prs_uint32("mapped_count ", ps, depth, &q_r->mapped_count)) 1123 return False; 1124 1125 return True; 1126} 1127 1128/******************************************************************* 1129reads or writes a structure. 1130********************************************************************/ 1131 1132BOOL lsa_io_r_lookup_names(const char *desc, LSA_R_LOOKUP_NAMES *r_r, 1133 prs_struct *ps, int depth) 1134{ 1135 unsigned int i; 1136 1137 prs_debug(ps, depth, desc, "lsa_io_r_lookup_names"); 1138 depth++; 1139 1140 if(!prs_align(ps)) 1141 return False; 1142 1143 if(!prs_uint32("ptr_dom_ref", ps, depth, &r_r->ptr_dom_ref)) 1144 return False; 1145 1146 if (r_r->ptr_dom_ref != 0) 1147 if(!lsa_io_dom_r_ref("", r_r->dom_ref, ps, depth)) 1148 return False; 1149 1150 if(!prs_uint32("num_entries", ps, depth, &r_r->num_entries)) 1151 return False; 1152 if(!prs_uint32("ptr_entries", ps, depth, &r_r->ptr_entries)) 1153 return False; 1154 1155 if (r_r->ptr_entries != 0) { 1156 if(!prs_uint32("num_entries2", ps, depth, &r_r->num_entries2)) 1157 return False; 1158 1159 if (r_r->num_entries2 != r_r->num_entries) { 1160 /* RPC fault */ 1161 return False; 1162 } 1163 1164 if (UNMARSHALLING(ps)) { 1165 if ((r_r->dom_rid = PRS_ALLOC_MEM(ps, DOM_RID2, r_r->num_entries2)) 1166 == NULL) { 1167 DEBUG(3, ("lsa_io_r_lookup_names(): out of memory\n")); 1168 return False; 1169 } 1170 } 1171 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 */ 1174 return False; 1175 } 1176 1177 if(!prs_uint32("mapped_count", ps, depth, &r_r->mapped_count)) 1178 return False; 1179 1180 if(!prs_ntstatus("status ", ps, depth, &r_r->status)) 1181 return False; 1182 1183 return True; 1184} 1185 1186 1187/******************************************************************* 1188 Inits an LSA_Q_CLOSE structure. 1189********************************************************************/ 1190 1191void init_lsa_q_close(LSA_Q_CLOSE *q_c, POLICY_HND *hnd) 1192{ 1193 DEBUG(5, ("init_lsa_q_close\n")); 1194 1195 memcpy(&q_c->pol, hnd, sizeof(q_c->pol)); 1196} 1197 1198/******************************************************************* 1199 Reads or writes an LSA_Q_CLOSE structure. 1200********************************************************************/ 1201 1202BOOL lsa_io_q_close(const char *desc, LSA_Q_CLOSE *q_c, prs_struct *ps, int depth) 1203{ 1204 prs_debug(ps, depth, desc, "lsa_io_q_close"); 1205 depth++; 1206 1207 if(!smb_io_pol_hnd("", &q_c->pol, ps, depth)) 1208 return False; 1209 1210 return True; 1211} 1212 1213/******************************************************************* 1214 Reads or writes an LSA_R_CLOSE structure. 1215********************************************************************/ 1216 1217BOOL lsa_io_r_close(const char *desc, LSA_R_CLOSE *r_c, prs_struct *ps, int depth) 1218{ 1219 prs_debug(ps, depth, desc, "lsa_io_r_close"); 1220 depth++; 1221 1222 if(!smb_io_pol_hnd("", &r_c->pol, ps, depth)) 1223 return False; 1224 1225 if(!prs_ntstatus("status", ps, depth, &r_c->status)) 1226 return False; 1227 1228 return True; 1229} 1230 1231/******************************************************************* 1232 Reads or writes an LSA_Q_OPEN_SECRET structure. 1233********************************************************************/ 1234 1235BOOL lsa_io_q_open_secret(const char *desc, LSA_Q_OPEN_SECRET *q_c, prs_struct *ps, int depth) 1236{ 1237 prs_debug(ps, depth, desc, "lsa_io_q_open_secret"); 1238 depth++; 1239 1240 /* Don't bother to read or write at present... */ 1241 return True; 1242} 1243 1244/******************************************************************* 1245 Reads or writes an LSA_R_OPEN_SECRET structure. 1246********************************************************************/ 1247 1248BOOL lsa_io_r_open_secret(const char *desc, LSA_R_OPEN_SECRET *r_c, prs_struct *ps, int depth) 1249{ 1250 prs_debug(ps, depth, desc, "lsa_io_r_open_secret"); 1251 depth++; 1252 1253 if(!prs_align(ps)) 1254 return False; 1255 1256 if(!prs_uint32("dummy1", ps, depth, &r_c->dummy1)) 1257 return False; 1258 if(!prs_uint32("dummy2", ps, depth, &r_c->dummy2)) 1259 return False; 1260 if(!prs_uint32("dummy3", ps, depth, &r_c->dummy3)) 1261 return False; 1262 if(!prs_uint32("dummy4", ps, depth, &r_c->dummy4)) 1263 return False; 1264 if(!prs_ntstatus("status", ps, depth, &r_c->status)) 1265 return False; 1266 1267 return True; 1268} 1269 1270/******************************************************************* 1271 Inits an LSA_Q_ENUM_PRIVS structure. 1272********************************************************************/ 1273 1274void init_q_enum_privs(LSA_Q_ENUM_PRIVS *q_q, POLICY_HND *hnd, uint32 enum_context, uint32 pref_max_length) 1275{ 1276 DEBUG(5, ("init_q_enum_privs\n")); 1277 1278 memcpy(&q_q->pol, hnd, sizeof(q_q->pol)); 1279 1280 q_q->enum_context = enum_context; 1281 q_q->pref_max_length = pref_max_length; 1282} 1283 1284/******************************************************************* 1285reads or writes a structure. 1286********************************************************************/ 1287BOOL lsa_io_q_enum_privs(const char *desc, LSA_Q_ENUM_PRIVS *q_q, prs_struct *ps, int depth) 1288{ 1289 if (q_q == NULL) 1290 return False; 1291 1292 prs_debug(ps, depth, desc, "lsa_io_q_enum_privs"); 1293 depth++; 1294 1295 if (!smb_io_pol_hnd("", &q_q->pol, ps, depth)) 1296 return False; 1297 1298 if(!prs_uint32("enum_context ", ps, depth, &q_q->enum_context)) 1299 return False; 1300 if(!prs_uint32("pref_max_length", ps, depth, &q_q->pref_max_length)) 1301 return False; 1302 1303 return True; 1304} 1305 1306/******************************************************************* 1307reads or writes a structure. 1308********************************************************************/ 1309static BOOL lsa_io_priv_entries(const char *desc, LSA_PRIV_ENTRY *entries, uint32 count, prs_struct *ps, int depth) 1310{ 1311 uint32 i; 1312 1313 if (entries == NULL) 1314 return False; 1315 1316 prs_debug(ps, depth, desc, "lsa_io_priv_entries"); 1317 depth++; 1318 1319 if(!prs_align(ps)) 1320 return False; 1321 1322 for (i = 0; i < count; i++) { 1323 if (!smb_io_unihdr("", &entries[i].hdr_name, ps, depth)) 1324 return False; 1325 if(!prs_uint32("luid_low ", ps, depth, &entries[i].luid_low)) 1326 return False; 1327 if(!prs_uint32("luid_high", ps, depth, &entries[i].luid_high)) 1328 return False; 1329 } 1330 1331 for (i = 0; i < count; i++) 1332 if (!smb_io_unistr2("", &entries[i].name, entries[i].hdr_name.buffer, ps, depth)) 1333 return False; 1334 1335 return True; 1336} 1337 1338/******************************************************************* 1339 Inits an LSA_R_ENUM_PRIVS structure. 1340********************************************************************/ 1341 1342void init_lsa_r_enum_privs(LSA_R_ENUM_PRIVS *r_u, uint32 enum_context, 1343 uint32 count, LSA_PRIV_ENTRY *entries) 1344{ 1345 DEBUG(5, ("init_lsa_r_enum_privs\n")); 1346 1347 r_u->enum_context=enum_context; 1348 r_u->count=count; 1349 1350 if (entries!=NULL) { 1351 r_u->ptr=1; 1352 r_u->count1=count; 1353 r_u->privs=entries; 1354 } else { 1355 r_u->ptr=0; 1356 r_u->count1=0; 1357 r_u->privs=NULL; 1358 } 1359} 1360 1361/******************************************************************* 1362reads or writes a structure. 1363********************************************************************/ 1364BOOL lsa_io_r_enum_privs(const char *desc, LSA_R_ENUM_PRIVS *r_q, prs_struct *ps, int depth) 1365{ 1366 if (r_q == NULL) 1367 return False; 1368 1369 prs_debug(ps, depth, desc, "lsa_io_r_enum_privs"); 1370 depth++; 1371 1372 if(!prs_align(ps)) 1373 return False; 1374 1375 if(!prs_uint32("enum_context", ps, depth, &r_q->enum_context)) 1376 return False; 1377 if(!prs_uint32("count", ps, depth, &r_q->count)) 1378 return False; 1379 if(!prs_uint32("ptr", ps, depth, &r_q->ptr)) 1380 return False; 1381 1382 if (r_q->ptr) { 1383 if(!prs_uint32("count1", ps, depth, &r_q->count1)) 1384 return False; 1385 1386 if (UNMARSHALLING(ps)) 1387 if (!(r_q->privs = PRS_ALLOC_MEM(ps, LSA_PRIV_ENTRY, r_q->count1))) 1388 return False; 1389 1390 if (!lsa_io_priv_entries("", r_q->privs, r_q->count1, ps, depth)) 1391 return False; 1392 } 1393 1394 if(!prs_align(ps)) 1395 return False; 1396 1397 if(!prs_ntstatus("status", ps, depth, &r_q->status)) 1398 return False; 1399 1400 return True; 1401} 1402 1403void init_lsa_priv_get_dispname(LSA_Q_PRIV_GET_DISPNAME *trn, POLICY_HND *hnd, const char *name, uint16 lang_id, uint16 lang_id_sys) 1404{ 1405 memcpy(&trn->pol, hnd, sizeof(trn->pol)); 1406 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; 1411} 1412 1413/******************************************************************* 1414reads or writes a structure. 1415********************************************************************/ 1416BOOL lsa_io_q_priv_get_dispname(const char *desc, LSA_Q_PRIV_GET_DISPNAME *q_q, prs_struct *ps, int depth) 1417{ 1418 if (q_q == NULL) 1419 return False; 1420 1421 prs_debug(ps, depth, desc, "lsa_io_q_priv_get_dispname"); 1422 depth++; 1423 1424 if(!prs_align(ps)) 1425 return False; 1426 1427 if (!smb_io_pol_hnd("", &q_q->pol, ps, depth)) 1428 return False; 1429 1430 if (!smb_io_unihdr("hdr_name", &q_q->hdr_name, ps, depth)) 1431 return False; 1432 1433 if (!smb_io_unistr2("name", &q_q->name, q_q->hdr_name.buffer, ps, depth)) 1434 return False; 1435 1436 if(!prs_uint16("lang_id ", ps, depth, &q_q->lang_id)) 1437 return False; 1438 if(!prs_uint16("lang_id_sys", ps, depth, &q_q->lang_id_sys)) 1439 return False; 1440 1441 return True; 1442} 1443 1444/******************************************************************* 1445reads or writes a structure. 1446********************************************************************/ 1447BOOL lsa_io_r_priv_get_dispname(const char *desc, LSA_R_PRIV_GET_DISPNAME *r_q, prs_struct *ps, int depth) 1448{ 1449 if (r_q == NULL) 1450 return False; 1451 1452 prs_debug(ps, depth, desc, "lsa_io_r_priv_get_dispname"); 1453 depth++; 1454 1455 if (!prs_align(ps)) 1456 return False; 1457 1458 if (!prs_uint32("ptr_info", ps, depth, &r_q->ptr_info)) 1459 return False; 1460 1461 if (r_q->ptr_info){ 1462 if (!smb_io_unihdr("hdr_name", &r_q->hdr_desc, ps, depth)) 1463 return False; 1464 1465 if (!smb_io_unistr2("desc", &r_q->desc, r_q->hdr_desc.buffer, ps, depth)) 1466 return False; 1467 } 1468/* 1469 if(!prs_align(ps)) 1470 return False; 1471*/ 1472 if(!prs_uint16("lang_id", ps, depth, &r_q->lang_id)) 1473 return False; 1474 1475 if(!prs_align(ps)) 1476 return False; 1477 if(!prs_ntstatus("status", ps, depth, &r_q->status)) 1478 return False; 1479 1480 return True; 1481} 1482 1483/* 1484 initialise a LSA_Q_ENUM_ACCOUNTS structure 1485*/ 1486void init_lsa_q_enum_accounts(LSA_Q_ENUM_ACCOUNTS *trn, POLICY_HND *hnd, uint32 enum_context, uint32 pref_max_length) 1487{ 1488 memcpy(&trn->pol, hnd, sizeof(trn->pol)); 1489 1490 trn->enum_context = enum_context; 1491 trn->pref_max_length = pref_max_length; 1492} 1493 1494/******************************************************************* 1495reads or writes a structure. 1496********************************************************************/ 1497BOOL lsa_io_q_enum_accounts(const char *desc, LSA_Q_ENUM_ACCOUNTS *q_q, prs_struct *ps, int depth) 1498{ 1499 if (q_q == NULL) 1500 return False; 1501 1502 prs_debug(ps, depth, desc, "lsa_io_q_enum_accounts"); 1503 depth++; 1504 1505 if (!smb_io_pol_hnd("", &q_q->pol, ps, depth)) 1506 return False; 1507 1508 if(!prs_uint32("enum_context ", ps, depth, &q_q->enum_context)) 1509 return False; 1510 if(!prs_uint32("pref_max_length", ps, depth, &q_q->pref_max_length)) 1511 return False; 1512 1513 return True; 1514} 1515 1516 1517/******************************************************************* 1518 Inits an LSA_R_ENUM_PRIVS structure. 1519********************************************************************/ 1520 1521void init_lsa_r_enum_accounts(LSA_R_ENUM_ACCOUNTS *r_u, uint32 enum_context) 1522{ 1523 DEBUG(5, ("init_lsa_r_enum_accounts\n")); 1524 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; 1530 } else { 1531 r_u->sids.num_entries=0; 1532 r_u->sids.ptr_sid_enum=0; 1533 r_u->sids.num_entries2=0; 1534 } 1535} 1536 1537/******************************************************************* 1538reads or writes a structure. 1539********************************************************************/ 1540BOOL lsa_io_r_enum_accounts(const char *desc, LSA_R_ENUM_ACCOUNTS *r_q, prs_struct *ps, int depth) 1541{ 1542 if (r_q == NULL) 1543 return False; 1544 1545 prs_debug(ps, depth, desc, "lsa_io_r_enum_accounts"); 1546 depth++; 1547 1548 if (!prs_align(ps)) 1549 return False; 1550 1551 if(!prs_uint32("enum_context", ps, depth, &r_q->enum_context)) 1552 return False; 1553 1554 if (!lsa_io_sid_enum("sids", &r_q->sids, ps, depth)) 1555 return False; 1556 1557 if (!prs_align(ps)) 1558 return False; 1559 1560 if(!prs_ntstatus("status", ps, depth, &r_q->status)) 1561 return False; 1562 1563 return True; 1564} 1565 1566 1567/******************************************************************* 1568 Reads or writes an LSA_Q_UNK_GET_CONNUSER structure. 1569********************************************************************/ 1570 1571BOOL lsa_io_q_unk_get_connuser(const char *desc, LSA_Q_UNK_GET_CONNUSER *q_c, prs_struct *ps, int depth) 1572{ 1573 prs_debug(ps, depth, desc, "lsa_io_q_unk_get_connuser"); 1574 depth++; 1575 1576 if(!prs_align(ps)) 1577 return False; 1578 1579 if(!prs_uint32("ptr_srvname", ps, depth, &q_c->ptr_srvname)) 1580 return False; 1581 1582 if(!smb_io_unistr2("uni2_srvname", &q_c->uni2_srvname, q_c->ptr_srvname, ps, depth)) /* server name to be looked up */ 1583 return False; 1584 1585 if (!prs_align(ps)) 1586 return False; 1587 1588 if(!prs_uint32("unk1", ps, depth, &q_c->unk1)) 1589 return False; 1590 if(!prs_uint32("unk2", ps, depth, &q_c->unk2)) 1591 return False; 1592 if(!prs_uint32("unk3", ps, depth, &q_c->unk3)) 1593 return False; 1594 1595 /* Don't bother to read or write at present... */ 1596 return True; 1597} 1598 1599/******************************************************************* 1600 Reads or writes an LSA_R_UNK_GET_CONNUSER structure. 1601********************************************************************/ 1602 1603BOOL lsa_io_r_unk_get_connuser(const char *desc, LSA_R_UNK_GET_CONNUSER *r_c, prs_struct *ps, int depth) 1604{ 1605 prs_debug(ps, depth, desc, "lsa_io_r_unk_get_connuser"); 1606 depth++; 1607 1608 if(!prs_align(ps)) 1609 return False; 1610 1611 if(!prs_uint32("ptr_user_name", ps, depth, &r_c->ptr_user_name)) 1612 return False; 1613 if(!smb_io_unihdr("hdr_user_name", &r_c->hdr_user_name, ps, depth)) 1614 return False; 1615 if(!smb_io_unistr2("uni2_user_name", &r_c->uni2_user_name, r_c->ptr_user_name, ps, depth)) 1616 return False; 1617 1618 if (!prs_align(ps)) 1619 return False; 1620 1621 if(!prs_uint32("unk1", ps, depth, &r_c->unk1)) 1622 return False; 1623 1624 if(!prs_uint32("ptr_dom_name", ps, depth, &r_c->ptr_dom_name)) 1625 return False; 1626 if(!smb_io_unihdr("hdr_dom_name", &r_c->hdr_dom_name, ps, depth)) 1627 return False; 1628 if(!smb_io_unistr2("uni2_dom_name", &r_c->uni2_dom_name, r_c->ptr_dom_name, ps, depth)) 1629 return False; 1630 1631 if (!prs_align(ps)) 1632 return False; 1633 1634 if(!prs_ntstatus("status", ps, depth, &r_c->status)) 1635 return False; 1636 1637 return True; 1638} 1639 1640void init_lsa_q_create_account(LSA_Q_CREATEACCOUNT *trn, POLICY_HND *hnd, DOM_SID *sid, uint32 desired_access) 1641{ 1642 memcpy(&trn->pol, hnd, sizeof(trn->pol)); 1643 1644 init_dom_sid2(&trn->sid, sid); 1645 trn->access = desired_access; 1646} 1647 1648 1649/******************************************************************* 1650 Reads or writes an LSA_Q_CREATEACCOUNT structure. 1651********************************************************************/ 1652 1653BOOL lsa_io_q_create_account(const char *desc, LSA_Q_CREATEACCOUNT *r_c, prs_struct *ps, int depth) 1654{ 1655 prs_debug(ps, depth, desc, "lsa_io_q_create_account"); 1656 depth++; 1657 1658 if(!prs_align(ps)) 1659 return False; 1660 1661 if(!smb_io_pol_hnd("pol", &r_c->pol, ps, depth)) 1662 return False; 1663 1664 if(!smb_io_dom_sid2("sid", &r_c->sid, ps, depth)) /* domain SID */ 1665 return False; 1666 1667 if(!prs_uint32("access", ps, depth, &r_c->access)) 1668 return False; 1669 1670 return True; 1671} 1672 1673/******************************************************************* 1674 Reads or writes an LSA_R_CREATEACCOUNT structure. 1675********************************************************************/ 1676 1677BOOL lsa_io_r_create_account(const char *desc, LSA_R_CREATEACCOUNT *r_c, prs_struct *ps, int depth) 1678{ 1679 prs_debug(ps, depth, desc, "lsa_io_r_open_account"); 1680 depth++; 1681 1682 if(!prs_align(ps)) 1683 return False; 1684 1685 if(!smb_io_pol_hnd("pol", &r_c->pol, ps, depth)) 1686 return False; 1687 1688 if(!prs_ntstatus("status", ps, depth, &r_c->status)) 1689 return False; 1690 1691 return True; 1692} 1693 1694 1695void init_lsa_q_open_account(LSA_Q_OPENACCOUNT *trn, POLICY_HND *hnd, DOM_SID *sid, uint32 desired_access) 1696{ 1697 memcpy(&trn->pol, hnd, sizeof(trn->pol)); 1698 1699 init_dom_sid2(&trn->sid, sid); 1700 trn->access = desired_access; 1701} 1702 1703/******************************************************************* 1704 Reads or writes an LSA_Q_OPENACCOUNT structure. 1705********************************************************************/ 1706 1707BOOL lsa_io_q_open_account(const char *desc, LSA_Q_OPENACCOUNT *r_c, prs_struct *ps, int depth) 1708{ 1709 prs_debug(ps, depth, desc, "lsa_io_q_open_account"); 1710 depth++; 1711 1712 if(!prs_align(ps)) 1713 return False; 1714 1715 if(!smb_io_pol_hnd("pol", &r_c->pol, ps, depth)) 1716 return False; 1717 1718 if(!smb_io_dom_sid2("sid", &r_c->sid, ps, depth)) /* domain SID */ 1719 return False; 1720 1721 if(!prs_uint32("access", ps, depth, &r_c->access)) 1722 return False; 1723 1724 return True; 1725} 1726 1727/******************************************************************* 1728 Reads or writes an LSA_R_OPENACCOUNT structure. 1729********************************************************************/ 1730 1731BOOL lsa_io_r_open_account(const char *desc, LSA_R_OPENACCOUNT *r_c, prs_struct *ps, int depth) 1732{ 1733 prs_debug(ps, depth, desc, "lsa_io_r_open_account"); 1734 depth++; 1735 1736 if(!prs_align(ps)) 1737 return False; 1738 1739 if(!smb_io_pol_hnd("pol", &r_c->pol, ps, depth)) 1740 return False; 1741 1742 if(!prs_ntstatus("status", ps, depth, &r_c->status)) 1743 return False; 1744 1745 return True; 1746} 1747 1748 1749void init_lsa_q_enum_privsaccount(LSA_Q_ENUMPRIVSACCOUNT *trn, POLICY_HND *hnd) 1750{ 1751 memcpy(&trn->pol, hnd, sizeof(trn->pol)); 1752 1753} 1754 1755/******************************************************************* 1756 Reads or writes an LSA_Q_ENUMPRIVSACCOUNT structure. 1757********************************************************************/ 1758 1759BOOL lsa_io_q_enum_privsaccount(const char *desc, LSA_Q_ENUMPRIVSACCOUNT *r_c, prs_struct *ps, int depth) 1760{ 1761 prs_debug(ps, depth, desc, "lsa_io_q_enum_privsaccount"); 1762 depth++; 1763 1764 if(!prs_align(ps)) 1765 return False; 1766 1767 if(!smb_io_pol_hnd("pol", &r_c->pol, ps, depth)) 1768 return False; 1769 1770 return True; 1771} 1772 1773/******************************************************************* 1774 Reads or writes an LUID structure. 1775********************************************************************/ 1776 1777static BOOL lsa_io_luid(const char *desc, LUID *r_c, prs_struct *ps, int depth) 1778{ 1779 prs_debug(ps, depth, desc, "lsa_io_luid"); 1780 depth++; 1781 1782 if(!prs_align(ps)) 1783 return False; 1784 1785 if(!prs_uint32("low", ps, depth, &r_c->low)) 1786 return False; 1787 1788 if(!prs_uint32("high", ps, depth, &r_c->high)) 1789 return False; 1790 1791 return True; 1792} 1793 1794/******************************************************************* 1795 Reads or writes an LUID_ATTR structure. 1796********************************************************************/ 1797 1798static BOOL lsa_io_luid_attr(const char *desc, LUID_ATTR *r_c, prs_struct *ps, int depth) 1799{ 1800 prs_debug(ps, depth, desc, "lsa_io_luid_attr"); 1801 depth++; 1802 1803 if(!prs_align(ps)) 1804 return False; 1805 1806 if (!lsa_io_luid(desc, &r_c->luid, ps, depth)) 1807 return False; 1808 1809 if(!prs_uint32("attr", ps, depth, &r_c->attr)) 1810 return False; 1811 1812 return True; 1813} 1814 1815/******************************************************************* 1816 Reads or writes an PRIVILEGE_SET structure. 1817********************************************************************/ 1818 1819static BOOL lsa_io_privilege_set(const char *desc, PRIVILEGE_SET *r_c, prs_struct *ps, int depth) 1820{ 1821 uint32 i; 1822 1823 prs_debug(ps, depth, desc, "lsa_io_privilege_set"); 1824 depth++; 1825 1826 if(!prs_align(ps)) 1827 return False; 1828 1829 if(!prs_uint32("count", ps, depth, &r_c->count)) 1830 return False; 1831 if(!prs_uint32("control", ps, depth, &r_c->control)) 1832 return False; 1833 1834 for (i=0; i<r_c->count; i++) { 1835 if (!lsa_io_luid_attr(desc, &r_c->set[i], ps, depth)) 1836 return False; 1837 } 1838 1839 return True; 1840} 1841 1842NTSTATUS init_lsa_r_enum_privsaccount(TALLOC_CTX *mem_ctx, LSA_R_ENUMPRIVSACCOUNT *r_u, LUID_ATTR *set, uint32 count, uint32 control) 1843{ 1844 NTSTATUS ret = NT_STATUS_OK; 1845 1846 r_u->ptr = 1; 1847 r_u->count = count; 1848 1849 if ( !NT_STATUS_IS_OK(ret = privilege_set_init_by_ctx(mem_ctx, &(r_u->set))) ) 1850 return ret; 1851 1852 r_u->set.count = count; 1853 1854 if (!NT_STATUS_IS_OK(ret = dup_luid_attr(r_u->set.mem_ctx, &(r_u->set.set), set, count))) 1855 return ret; 1856 1857 DEBUG(10,("init_lsa_r_enum_privsaccount: %d privileges\n", r_u->count)); 1858 1859 return ret; 1860} 1861 1862/******************************************************************* 1863 Reads or writes an LSA_R_ENUMPRIVSACCOUNT structure. 1864********************************************************************/ 1865 1866BOOL lsa_io_r_enum_privsaccount(const char *desc, LSA_R_ENUMPRIVSACCOUNT *r_c, prs_struct *ps, int depth) 1867{ 1868 prs_debug(ps, depth, desc, "lsa_io_r_enum_privsaccount"); 1869 depth++; 1870 1871 if(!prs_align(ps)) 1872 return False; 1873 1874 if(!prs_uint32("ptr", ps, depth, &r_c->ptr)) 1875 return False; 1876 1877 if (r_c->ptr!=0) { 1878 if(!prs_uint32("count", ps, depth, &r_c->count)) 1879 return False; 1880 1881 /* malloc memory if unmarshalling here */ 1882 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)))) 1885 return False; 1886 1887 if (!(r_c->set.set = PRS_ALLOC_MEM(ps,LUID_ATTR,r_c->count))) 1888 return False; 1889 1890 } 1891 1892 if(!lsa_io_privilege_set(desc, &r_c->set, ps, depth)) 1893 return False; 1894 } 1895 1896 if(!prs_ntstatus("status", ps, depth, &r_c->status)) 1897 return False; 1898 1899 return True; 1900} 1901 1902 1903 1904/******************************************************************* 1905 Reads or writes an LSA_Q_GETSYSTEMACCOUNTstructure. 1906********************************************************************/ 1907 1908BOOL lsa_io_q_getsystemaccount(const char *desc, LSA_Q_GETSYSTEMACCOUNT *r_c, prs_struct *ps, int depth) 1909{ 1910 prs_debug(ps, depth, desc, "lsa_io_q_getsystemaccount"); 1911 depth++; 1912 1913 if(!prs_align(ps)) 1914 return False; 1915 1916 if(!smb_io_pol_hnd("pol", &r_c->pol, ps, depth)) 1917 return False; 1918 1919 return True; 1920} 1921 1922/******************************************************************* 1923 Reads or writes an LSA_R_GETSYSTEMACCOUNTstructure. 1924********************************************************************/ 1925 1926BOOL lsa_io_r_getsystemaccount(const char *desc, LSA_R_GETSYSTEMACCOUNT *r_c, prs_struct *ps, int depth) 1927{ 1928 prs_debug(ps, depth, desc, "lsa_io_r_getsystemaccount"); 1929 depth++; 1930 1931 if(!prs_align(ps)) 1932 return False; 1933 1934 if(!prs_uint32("access", ps, depth, &r_c->access)) 1935 return False; 1936 1937 if(!prs_ntstatus("status", ps, depth, &r_c->status)) 1938 return False; 1939 1940 return True; 1941} 1942 1943 1944/******************************************************************* 1945 Reads or writes an LSA_Q_SETSYSTEMACCOUNT structure. 1946********************************************************************/ 1947 1948BOOL lsa_io_q_setsystemaccount(const char *desc, LSA_Q_SETSYSTEMACCOUNT *r_c, prs_struct *ps, int depth) 1949{ 1950 prs_debug(ps, depth, desc, "lsa_io_q_setsystemaccount"); 1951 depth++; 1952 1953 if(!prs_align(ps)) 1954 return False; 1955 1956 if(!smb_io_pol_hnd("pol", &r_c->pol, ps, depth)) 1957 return False; 1958 1959 if(!prs_uint32("access", ps, depth, &r_c->access)) 1960 return False; 1961 1962 return True; 1963} 1964 1965/******************************************************************* 1966 Reads or writes an LSA_R_SETSYSTEMACCOUNT structure. 1967********************************************************************/ 1968 1969BOOL lsa_io_r_setsystemaccount(const char *desc, LSA_R_SETSYSTEMACCOUNT *r_c, prs_struct *ps, int depth) 1970{ 1971 prs_debug(ps, depth, desc, "lsa_io_r_setsystemaccount"); 1972 depth++; 1973 1974 if(!prs_align(ps)) 1975 return False; 1976 1977 if(!prs_ntstatus("status", ps, depth, &r_c->status)) 1978 return False; 1979 1980 return True; 1981} 1982 1983 1984static void init_lsa_string( LSA_STRING *uni, const char *string ) 1985{ 1986 init_unistr2(&uni->unistring, string, UNI_FLAGS_NONE); 1987 init_uni_hdr(&uni->hdr, &uni->unistring); 1988} 1989 1990void init_lsa_q_lookup_priv_value(LSA_Q_LOOKUP_PRIV_VALUE *q_u, POLICY_HND *hnd, const char *name) 1991{ 1992 memcpy(&q_u->pol, hnd, sizeof(q_u->pol)); 1993 init_lsa_string( &q_u->privname, name ); 1994} 1995 1996BOOL smb_io_lsa_string( const char *desc, LSA_STRING *string, prs_struct *ps, int depth ) 1997{ 1998 prs_debug(ps, depth, desc, "smb_io_lsa_string"); 1999 depth++; 2000 2001 if(!smb_io_unihdr ("hdr", &string->hdr, ps, depth)) 2002 return False; 2003 if(!smb_io_unistr2("unistring", &string->unistring, string->hdr.buffer, ps, depth)) 2004 return False; 2005 2006 return True; 2007} 2008 2009/******************************************************************* 2010 Reads or writes an LSA_Q_LOOKUP_PRIV_VALUE structure. 2011********************************************************************/ 2012 2013BOOL lsa_io_q_lookup_priv_value(const char *desc, LSA_Q_LOOKUP_PRIV_VALUE *r_c, prs_struct *ps, int depth) 2014{ 2015 prs_debug(ps, depth, desc, "lsa_io_q_lookup_priv_value"); 2016 depth++; 2017 2018 if(!prs_align(ps)) 2019 return False; 2020 2021 if(!smb_io_pol_hnd("pol", &r_c->pol, ps, depth)) 2022 return False; 2023 if(!smb_io_lsa_string("privname", &r_c->privname, ps, depth)) 2024 return False; 2025 2026 return True; 2027} 2028 2029/******************************************************************* 2030 Reads or writes an LSA_R_LOOKUP_PRIV_VALUE structure. 2031********************************************************************/ 2032 2033BOOL lsa_io_r_lookup_priv_value(const char *desc, LSA_R_LOOKUP_PRIV_VALUE *r_c, prs_struct *ps, int depth) 2034{ 2035 prs_debug(ps, depth, desc, "lsa_io_r_lookup_priv_value"); 2036 depth++; 2037 2038 if(!prs_align(ps)) 2039 return False; 2040 2041 if(!lsa_io_luid("luid", &r_c->luid, ps, depth)) 2042 return False; 2043 2044 if(!prs_ntstatus("status", ps, depth, &r_c->status)) 2045 return False; 2046 2047 return True; 2048} 2049 2050 2051/******************************************************************* 2052 Reads or writes an LSA_Q_ADDPRIVS structure. 2053********************************************************************/ 2054 2055BOOL lsa_io_q_addprivs(const char *desc, LSA_Q_ADDPRIVS *r_c, prs_struct *ps, int depth) 2056{ 2057 prs_debug(ps, depth, desc, "lsa_io_q_addprivs"); 2058 depth++; 2059 2060 if(!prs_align(ps)) 2061 return False; 2062 2063 if(!smb_io_pol_hnd("pol", &r_c->pol, ps, depth)) 2064 return False; 2065 2066 if(!prs_uint32("count", ps, depth, &r_c->count)) 2067 return False; 2068 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)))) 2071 return False; 2072 2073 if (!(r_c->set.set = PRS_ALLOC_MEM(ps, LUID_ATTR, r_c->count))) 2074 return False; 2075 } 2076 2077 if(!lsa_io_privilege_set(desc, &r_c->set, ps, depth)) 2078 return False; 2079 2080 return True; 2081} 2082 2083/******************************************************************* 2084 Reads or writes an LSA_R_ADDPRIVS structure. 2085********************************************************************/ 2086 2087BOOL lsa_io_r_addprivs(const char *desc, LSA_R_ADDPRIVS *r_c, prs_struct *ps, int depth) 2088{ 2089 prs_debug(ps, depth, desc, "lsa_io_r_addprivs"); 2090 depth++; 2091 2092 if(!prs_align(ps)) 2093 return False; 2094 2095 if(!prs_ntstatus("status", ps, depth, &r_c->status)) 2096 return False; 2097 2098 return True; 2099} 2100 2101/******************************************************************* 2102 Reads or writes an LSA_Q_REMOVEPRIVS structure. 2103********************************************************************/ 2104 2105BOOL lsa_io_q_removeprivs(const char *desc, LSA_Q_REMOVEPRIVS *r_c, prs_struct *ps, int depth) 2106{ 2107 prs_debug(ps, depth, desc, "lsa_io_q_removeprivs"); 2108 depth++; 2109 2110 if(!prs_align(ps)) 2111 return False; 2112 2113 if(!smb_io_pol_hnd("pol", &r_c->pol, ps, depth)) 2114 return False; 2115 2116 if(!prs_uint32("allrights", ps, depth, &r_c->allrights)) 2117 return False; 2118 2119 if(!prs_uint32("ptr", ps, depth, &r_c->ptr)) 2120 return False; 2121 2122 /* 2123 * JFM: I'm not sure at all if the count is inside the ptr 2124 * never seen one with ptr=0 2125 */ 2126 2127 if (r_c->ptr!=0) { 2128 if(!prs_uint32("count", ps, depth, &r_c->count)) 2129 return False; 2130 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)))) 2133 return False; 2134 2135 if (!(r_c->set.set = PRS_ALLOC_MEM(ps, LUID_ATTR, r_c->count))) 2136 return False; 2137 } 2138 2139 if(!lsa_io_privilege_set(desc, &r_c->set, ps, depth)) 2140 return False; 2141 } 2142 2143 return True; 2144} 2145 2146/******************************************************************* 2147 Reads or writes an LSA_R_REMOVEPRIVS structure. 2148********************************************************************/ 2149 2150BOOL lsa_io_r_removeprivs(const char *desc, LSA_R_REMOVEPRIVS *r_c, prs_struct *ps, int depth) 2151{ 2152 prs_debug(ps, depth, desc, "lsa_io_r_removeprivs"); 2153 depth++; 2154 2155 if(!prs_align(ps)) 2156 return False; 2157 2158 if(!prs_ntstatus("status", ps, depth, &r_c->status)) 2159 return False; 2160 2161 return True; 2162} 2163 2164BOOL policy_handle_is_valid(const POLICY_HND *hnd) 2165{ 2166 POLICY_HND zero_pol; 2167 2168 ZERO_STRUCT(zero_pol); 2169 return ((memcmp(&zero_pol, hnd, sizeof(POLICY_HND)) == 0) ? False : True ); 2170} 2171 2172/******************************************************************* 2173 Reads or writes an LSA_DNS_DOM_INFO structure. 2174********************************************************************/ 2175 2176BOOL lsa_io_dns_dom_info(const char *desc, LSA_DNS_DOM_INFO *info, 2177 prs_struct *ps, int depth) 2178{ 2179 prs_debug(ps, depth, desc, "lsa_io_dns_dom_info"); 2180 depth++; 2181 2182 if(!prs_align(ps)) 2183 return False; 2184 if(!smb_io_unihdr("nb_name", &info->hdr_nb_dom_name, ps, depth)) 2185 return False; 2186 if(!smb_io_unihdr("dns_name", &info->hdr_dns_dom_name, ps, depth)) 2187 return False; 2188 if(!smb_io_unihdr("forest", &info->hdr_forest_name, ps, depth)) 2189 return False; 2190 2191 if(!prs_align(ps)) 2192 return False; 2193 if ( !smb_io_uuid("dom_guid", &info->dom_guid, ps, depth) ) 2194 return False; 2195 2196 if(!prs_align(ps)) 2197 return False; 2198 if(!prs_uint32("dom_sid", ps, depth, &info->ptr_dom_sid)) 2199 return False; 2200 2201 if(!smb_io_unistr2("nb_name", &info->uni_nb_dom_name, 2202 info->hdr_nb_dom_name.buffer, ps, depth)) 2203 return False; 2204 if(!smb_io_unistr2("dns_name", &info->uni_dns_dom_name, 2205 info->hdr_dns_dom_name.buffer, ps, depth)) 2206 return False; 2207 if(!smb_io_unistr2("forest", &info->uni_forest_name, 2208 info->hdr_forest_name.buffer, ps, depth)) 2209 return False; 2210 2211 if(!smb_io_dom_sid2("dom_sid", &info->dom_sid, ps, depth)) 2212 return False; 2213 2214 return True; 2215 2216} 2217 2218/******************************************************************* 2219 Inits an LSA_Q_QUERY_INFO2 structure. 2220********************************************************************/ 2221 2222void init_q_query2(LSA_Q_QUERY_INFO2 *q_q, POLICY_HND *hnd, uint16 info_class) 2223{ 2224 DEBUG(5, ("init_q_query2\n")); 2225 2226 memcpy(&q_q->pol, hnd, sizeof(q_q->pol)); 2227 2228 q_q->info_class = info_class; 2229} 2230 2231/******************************************************************* 2232 Reads or writes an LSA_Q_QUERY_DNSDOMINFO structure. 2233********************************************************************/ 2234 2235BOOL lsa_io_q_query_info2(const char *desc, LSA_Q_QUERY_INFO2 *q_c, 2236 prs_struct *ps, int depth) 2237{ 2238 prs_debug(ps, depth, desc, "lsa_io_q_query_info2"); 2239 depth++; 2240 2241 if(!prs_align(ps)) 2242 return False; 2243 2244 if(!smb_io_pol_hnd("pol", &q_c->pol, ps, depth)) 2245 return False; 2246 2247 if(!prs_uint16("info_class", ps, depth, &q_c->info_class)) 2248 return False; 2249 2250 return True; 2251} 2252 2253/******************************************************************* 2254 Reads or writes an LSA_R_QUERY_DNSDOMINFO structure. 2255********************************************************************/ 2256 2257BOOL lsa_io_r_query_info2(const char *desc, LSA_R_QUERY_INFO2 *r_c, 2258 prs_struct *ps, int depth) 2259{ 2260 prs_debug(ps, depth, desc, "lsa_io_r_query_info2"); 2261 depth++; 2262 2263 if(!prs_align(ps)) 2264 return False; 2265 2266 if(!prs_uint32("ptr", ps, depth, &r_c->ptr)) 2267 return False; 2268 if(!prs_uint16("info_class", ps, depth, &r_c->info_class)) 2269 return False; 2270 switch(r_c->info_class) { 2271 case 0x000c: 2272 if (!lsa_io_dns_dom_info("info12", &r_c->info.dns_dom_info, 2273 ps, depth)) 2274 return False; 2275 break; 2276 default: 2277 DEBUG(0,("lsa_io_r_query_info2: unknown info class %d\n", 2278 r_c->info_class)); 2279 return False; 2280 } 2281 2282 if(!prs_align(ps)) 2283 return False; 2284 if(!prs_ntstatus("status", ps, depth, &r_c->status)) 2285 return False; 2286 2287 return True; 2288} 2289 2290/******************************************************************* 2291 Inits an LSA_Q_ENUM_ACCT_RIGHTS structure. 2292********************************************************************/ 2293void init_q_enum_acct_rights(LSA_Q_ENUM_ACCT_RIGHTS *q_q, 2294 POLICY_HND *hnd, 2295 uint32 count, 2296 DOM_SID *sid) 2297{ 2298 DEBUG(5, ("init_q_enum_acct_rights\n")); 2299 2300 q_q->pol = *hnd; 2301 init_dom_sid2(&q_q->sid, sid); 2302} 2303 2304/******************************************************************* 2305********************************************************************/ 2306NTSTATUS init_r_enum_acct_rights( LSA_R_ENUM_ACCT_RIGHTS *r_u, PRIVILEGE_SET *privileges ) 2307{ 2308 uint32 i; 2309 char *privname; 2310 const char **privname_array = NULL; 2311 int num_priv = 0; 2312 2313 for ( i=0; i<privileges->count; i++ ) { 2314 privname = luid_to_privilege_name( &privileges->set[i].luid ); 2315 if ( privname ) { 2316 if ( !add_string_to_array( get_talloc_ctx(), privname, &privname_array, &num_priv ) ) 2317 return NT_STATUS_NO_MEMORY; 2318 } 2319 } 2320 2321 if ( num_priv ) { 2322 if ( !init_unistr2_array( &r_u->rights, num_priv, privname_array ) ) 2323 return NT_STATUS_NO_MEMORY; 2324 2325 r_u->count = num_priv; 2326 } 2327 2328 return NT_STATUS_OK; 2329} 2330 2331/******************************************************************* 2332reads or writes a LSA_Q_ENUM_ACCT_RIGHTS structure. 2333********************************************************************/ 2334BOOL lsa_io_q_enum_acct_rights(const char *desc, LSA_Q_ENUM_ACCT_RIGHTS *q_q, prs_struct *ps, int depth) 2335{ 2336 2337 if (q_q == NULL) 2338 return False; 2339 2340 prs_debug(ps, depth, desc, "lsa_io_q_enum_acct_rights"); 2341 depth++; 2342 2343 if (!smb_io_pol_hnd("", &q_q->pol, ps, depth)) 2344 return False; 2345 2346 if(!smb_io_dom_sid2("sid", &q_q->sid, ps, depth)) 2347 return False; 2348 2349 return True; 2350} 2351 2352 2353/******************************************************************* 2354reads or writes a LSA_R_ENUM_ACCT_RIGHTS structure. 2355********************************************************************/ 2356BOOL lsa_io_r_enum_acct_rights(const char *desc, LSA_R_ENUM_ACCT_RIGHTS *r_c, prs_struct *ps, int depth) 2357{ 2358 prs_debug(ps, depth, desc, "lsa_io_r_enum_acct_rights"); 2359 depth++; 2360 2361 if(!prs_uint32("count ", ps, depth, &r_c->count)) 2362 return False; 2363 2364 if(!smb_io_unistr2_array("rights", &r_c->rights, ps, depth)) 2365 return False; 2366 2367 if(!prs_align(ps)) 2368 return False; 2369 2370 if(!prs_ntstatus("status", ps, depth, &r_c->status)) 2371 return False; 2372 2373 return True; 2374} 2375 2376 2377/******************************************************************* 2378 Inits an LSA_Q_ADD_ACCT_RIGHTS structure. 2379********************************************************************/ 2380void init_q_add_acct_rights(LSA_Q_ADD_ACCT_RIGHTS *q_q, 2381 POLICY_HND *hnd, 2382 DOM_SID *sid, 2383 uint32 count, 2384 const char **rights) 2385{ 2386 DEBUG(5, ("init_q_add_acct_rights\n")); 2387 2388 q_q->pol = *hnd; 2389 init_dom_sid2(&q_q->sid, sid); 2390 init_unistr2_array(&q_q->rights, count, rights); 2391 q_q->count = count; 2392} 2393 2394 2395/******************************************************************* 2396reads or writes a LSA_Q_ADD_ACCT_RIGHTS structure. 2397********************************************************************/ 2398BOOL lsa_io_q_add_acct_rights(const char *desc, LSA_Q_ADD_ACCT_RIGHTS *q_q, prs_struct *ps, int depth) 2399{ 2400 prs_debug(ps, depth, desc, "lsa_io_q_add_acct_rights"); 2401 depth++; 2402 2403 if (!smb_io_pol_hnd("", &q_q->pol, ps, depth)) 2404 return False; 2405 2406 if(!smb_io_dom_sid2("sid", &q_q->sid, ps, depth)) 2407 return False; 2408 2409 if(!prs_uint32("count", ps, depth, &q_q->count)) 2410 return False; 2411 2412 if(!smb_io_unistr2_array("rights", &q_q->rights, ps, depth)) 2413 return False; 2414 2415 return True; 2416} 2417 2418/******************************************************************* 2419reads or writes a LSA_R_ENUM_ACCT_RIGHTS structure. 2420********************************************************************/ 2421BOOL lsa_io_r_add_acct_rights(const char *desc, LSA_R_ADD_ACCT_RIGHTS *r_c, prs_struct *ps, int depth) 2422{ 2423 prs_debug(ps, depth, desc, "lsa_io_r_add_acct_rights"); 2424 depth++; 2425 2426 if(!prs_ntstatus("status", ps, depth, &r_c->status)) 2427 return False; 2428 2429 return True; 2430} 2431 2432 2433/******************************************************************* 2434 Inits an LSA_Q_REMOVE_ACCT_RIGHTS structure. 2435********************************************************************/ 2436void init_q_remove_acct_rights(LSA_Q_REMOVE_ACCT_RIGHTS *q_q, 2437 POLICY_HND *hnd, 2438 DOM_SID *sid, 2439 uint32 removeall, 2440 uint32 count, 2441 const char **rights) 2442{ 2443 DEBUG(5, ("init_q_remove_acct_rights\n")); 2444 2445 q_q->pol = *hnd; 2446 init_dom_sid2(&q_q->sid, sid); 2447 q_q->removeall = removeall; 2448 init_unistr2_array(&q_q->rights, count, rights); 2449 q_q->count = count; 2450} 2451 2452 2453/******************************************************************* 2454reads or writes a LSA_Q_REMOVE_ACCT_RIGHTS structure. 2455********************************************************************/ 2456BOOL lsa_io_q_remove_acct_rights(const char *desc, LSA_Q_REMOVE_ACCT_RIGHTS *q_q, prs_struct *ps, int depth) 2457{ 2458 prs_debug(ps, depth, desc, "lsa_io_q_remove_acct_rights"); 2459 depth++; 2460 2461 if (!smb_io_pol_hnd("", &q_q->pol, ps, depth)) 2462 return False; 2463 2464 if(!smb_io_dom_sid2("sid", &q_q->sid, ps, depth)) 2465 return False; 2466 2467 if(!prs_uint32("removeall", ps, depth, &q_q->removeall)) 2468 return False; 2469 2470 if(!prs_uint32("count", ps, depth, &q_q->count)) 2471 return False; 2472 2473 if(!smb_io_unistr2_array("rights", &q_q->rights, ps, depth)) 2474 return False; 2475 2476 return True; 2477} 2478 2479/******************************************************************* 2480reads or writes a LSA_R_ENUM_ACCT_RIGHTS structure. 2481********************************************************************/ 2482BOOL lsa_io_r_remove_acct_rights(const char *desc, LSA_R_REMOVE_ACCT_RIGHTS *r_c, prs_struct *ps, int depth) 2483{ 2484 prs_debug(ps, depth, desc, "lsa_io_r_remove_acct_rights"); 2485 depth++; 2486 2487 if(!prs_ntstatus("status", ps, depth, &r_c->status)) 2488 return False; 2489 2490 return True; 2491} 2492