Changeset 740 for vendor/current/source3/groupdb/mapping.c
- Timestamp:
- Nov 14, 2012, 12:59:34 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
vendor/current/source3/groupdb/mapping.c
r414 r740 22 22 23 23 #include "includes.h" 24 #include "system/passwd.h" 25 #include "passdb.h" 24 26 #include "groupdb/mapping.h" 27 #include "../libcli/security/security.h" 28 #include "lib/winbind_util.h" 29 #include <tdb.h> 25 30 26 31 static const struct mapping_backend *backend; … … 31 36 static bool init_group_mapping(void) 32 37 { 33 const char *backend_string;34 35 38 if (backend != NULL) { 36 39 /* already initialised */ … … 38 41 } 39 42 40 /* 41 * default to using the ldb backend. This parameter should 42 * disappear in future versions of Samba3. 43 * 44 * But it's needed for cluster setups, because it's 45 * not yet possible to distribute a ldb inside a cluster. 46 */ 47 backend_string = lp_parm_const_string(-1, "groupdb", "backend", "ldb"); 48 49 if (strcmp(backend_string, "ldb") == 0) { 50 backend = groupdb_ldb_init(); 51 } else if (strcmp(backend_string, "tdb") == 0) { 52 backend = groupdb_tdb_init(); 53 } else { 54 DEBUG(0,("Unknown groupdb backend '%s'\n", backend_string)); 55 smb_panic("Unknown groupdb backend"); 56 } 43 backend = groupdb_tdb_init(); 57 44 58 45 return backend != NULL; … … 70 57 return NT_STATUS_UNSUCCESSFUL; 71 58 } 72 59 73 60 map.gid=gid; 74 61 if (!string_to_sid(&map.sid, sid)) { … … 76 63 return NT_STATUS_UNSUCCESSFUL; 77 64 } 78 65 79 66 map.sid_name_use=sid_name_use; 80 67 fstrcpy(map.nt_name, nt_name); … … 84 71 } 85 72 86 static NTSTATUS alias_memberships(const DOM_SID*members, size_t num_members,87 DOM_SID**sids, size_t *num)73 static NTSTATUS alias_memberships(const struct dom_sid *members, size_t num_members, 74 struct dom_sid **sids, size_t *num) 88 75 { 89 76 size_t i; … … 101 88 102 89 struct aliasmem_closure { 103 const DOM_SID*alias;104 DOM_SID**sids;90 const struct dom_sid *alias; 91 struct dom_sid **sids; 105 92 size_t *num; 106 93 }; … … 120 107 /* get a domain group from it's SID */ 121 108 122 bool get_domain_group_from_sid( DOM_SIDsid, GROUP_MAP *map)109 bool get_domain_group_from_sid(struct dom_sid sid, GROUP_MAP *map) 123 110 { 124 111 struct group *grp; 125 112 bool ret; 126 113 127 114 if(!init_group_mapping()) { 128 115 DEBUG(0,("failed to initialize group mapping\n")); … … 133 120 134 121 /* if the group is NOT in the database, it CAN NOT be a domain group */ 135 122 136 123 become_root(); 137 124 ret = pdb_getgrsid(map, sid); 138 125 unbecome_root(); 139 126 140 127 /* special case check for rid 513 */ 141 128 142 129 if ( !ret ) { 143 130 uint32 rid; 144 131 145 132 sid_peek_rid( &sid, &rid ); 146 147 if ( rid == DOMAIN_ GROUP_RID_USERS ) {133 134 if ( rid == DOMAIN_RID_USERS ) { 148 135 fstrcpy( map->nt_name, "None" ); 149 136 fstrcpy( map->comment, "Ordinary Users" ); … … 151 138 map->sid_name_use = SID_NAME_DOM_GRP; 152 139 map->gid = (gid_t)-1; 153 154 140 return True; 155 141 } 156 157 142 return False; 158 143 } 159 144 160 DEBUG(10, ("get_domain_group_from_sid: SID found in the TDB\n"));145 DEBUG(10, ("get_domain_group_from_sid: SID found in passdb\n")); 161 146 162 147 /* if it's not a domain group, continue */ … … 166 151 167 152 DEBUG(10, ("get_domain_group_from_sid: SID is a domain group\n")); 168 153 169 154 if (map->gid==-1) { 170 155 return False; … … 172 157 173 158 DEBUG(10, ("get_domain_group_from_sid: SID is mapped to gid:%lu\n",(unsigned long)map->gid)); 174 159 175 160 grp = getgrgid(map->gid); 176 161 if ( !grp ) { … … 344 329 return -1; 345 330 } 346 add_script = talloc_string_sub (ctx,347 add_script, "%u", unix_user );331 add_script = talloc_string_sub2(ctx, 332 add_script, "%u", unix_user, true, false, true); 348 333 if (!add_script) { 349 334 return -1; … … 384 369 return -1; 385 370 } 386 del_script = talloc_string_sub (ctx,387 del_script, "%u", unix_user );371 del_script = talloc_string_sub2(ctx, 372 del_script, "%u", unix_user, true, false, true); 388 373 if (!del_script) { 389 374 return -1; … … 402 387 403 388 NTSTATUS pdb_default_getgrsid(struct pdb_methods *methods, GROUP_MAP *map, 404 DOM_SIDsid)389 struct dom_sid sid) 405 390 { 406 391 if (!init_group_mapping()) { … … 457 442 458 443 NTSTATUS pdb_default_delete_group_mapping_entry(struct pdb_methods *methods, 459 DOM_SIDsid)444 struct dom_sid sid) 460 445 { 461 446 if (!init_group_mapping()) { … … 468 453 469 454 NTSTATUS pdb_default_enum_group_mapping(struct pdb_methods *methods, 470 const DOM_SID*sid, enum lsa_SidType sid_name_use,455 const struct dom_sid *sid, enum lsa_SidType sid_name_use, 471 456 GROUP_MAP **pp_rmap, size_t *p_num_entries, 472 457 bool unix_only) … … 483 468 const char *name, uint32 *rid) 484 469 { 485 DOM_SIDsid;470 struct dom_sid sid; 486 471 enum lsa_SidType type; 487 472 uint32 new_rid; … … 507 492 } 508 493 494 if (!pdb_new_rid(&new_rid)) { 495 DEBUG(0, ("Could not allocate a RID.\n")); 496 return NT_STATUS_ACCESS_DENIED; 497 } 498 499 sid_compose(&sid, get_global_sam_sid(), new_rid); 500 509 501 if (!winbind_allocate_gid(&gid)) { 510 DEBUG(3, ("Could not get a gid out of winbind\n")); 511 return NT_STATUS_ACCESS_DENIED; 512 } 513 514 if (!pdb_new_rid(&new_rid)) { 515 DEBUG(0, ("Could not allocate a RID -- wasted a gid :-(\n")); 502 DEBUG(3, ("Could not get a gid out of winbind - " 503 "wasted a rid :-(\n")); 516 504 return NT_STATUS_ACCESS_DENIED; 517 505 } … … 519 507 DEBUG(10, ("Creating alias %s with gid %u and rid %u\n", 520 508 name, (unsigned int)gid, (unsigned int)new_rid)); 521 522 sid_copy(&sid, get_global_sam_sid());523 sid_append_rid(&sid, new_rid);524 509 525 510 map.gid = gid; … … 543 528 544 529 NTSTATUS pdb_default_delete_alias(struct pdb_methods *methods, 545 const DOM_SID*sid)530 const struct dom_sid *sid) 546 531 { 547 532 return pdb_delete_group_mapping_entry(*sid); … … 549 534 550 535 NTSTATUS pdb_default_get_aliasinfo(struct pdb_methods *methods, 551 const DOM_SID*sid,536 const struct dom_sid *sid, 552 537 struct acct_info *info) 553 538 { … … 572 557 573 558 NTSTATUS pdb_default_set_aliasinfo(struct pdb_methods *methods, 574 const DOM_SID*sid,559 const struct dom_sid *sid, 575 560 struct acct_info *info) 576 561 { … … 587 572 588 573 NTSTATUS pdb_default_add_aliasmem(struct pdb_methods *methods, 589 const DOM_SID *alias, const DOM_SID*member)574 const struct dom_sid *alias, const struct dom_sid *member) 590 575 { 591 576 if (!init_group_mapping()) { … … 597 582 598 583 NTSTATUS pdb_default_del_aliasmem(struct pdb_methods *methods, 599 const DOM_SID *alias, const DOM_SID*member)584 const struct dom_sid *alias, const struct dom_sid *member) 600 585 { 601 586 if (!init_group_mapping()) { … … 607 592 608 593 NTSTATUS pdb_default_enum_aliasmem(struct pdb_methods *methods, 609 const DOM_SID*alias, TALLOC_CTX *mem_ctx,610 DOM_SID**pp_members, size_t *p_num_members)594 const struct dom_sid *alias, TALLOC_CTX *mem_ctx, 595 struct dom_sid **pp_members, size_t *p_num_members) 611 596 { 612 597 if (!init_group_mapping()) { … … 620 605 NTSTATUS pdb_default_alias_memberships(struct pdb_methods *methods, 621 606 TALLOC_CTX *mem_ctx, 622 const DOM_SID*domain_sid,623 const DOM_SID*members,607 const struct dom_sid *domain_sid, 608 const struct dom_sid *members, 624 609 size_t num_members, 625 610 uint32 **pp_alias_rids, 626 611 size_t *p_num_alias_rids) 627 612 { 628 DOM_SID*alias_sids;613 struct dom_sid *alias_sids; 629 614 size_t i, num_alias_sids; 630 615 NTSTATUS result; … … 672 657 673 658 NTSTATUS pdb_nop_getgrsid(struct pdb_methods *methods, GROUP_MAP *map, 674 DOM_SIDsid)659 struct dom_sid sid) 675 660 { 676 661 return NT_STATUS_UNSUCCESSFUL; … … 702 687 703 688 NTSTATUS pdb_nop_delete_group_mapping_entry(struct pdb_methods *methods, 704 DOM_SIDsid)689 struct dom_sid sid) 705 690 { 706 691 return NT_STATUS_UNSUCCESSFUL; … … 718 703 These need to be redirected through pdb_interface.c 719 704 ****************************************************************************/ 720 bool pdb_get_dom_grp_info(const DOM_SID*sid, struct acct_info *info)705 bool pdb_get_dom_grp_info(const struct dom_sid *sid, struct acct_info *info) 721 706 { 722 707 GROUP_MAP map; … … 736 721 } 737 722 738 bool pdb_set_dom_grp_info(const DOM_SID*sid, const struct acct_info *info)723 bool pdb_set_dom_grp_info(const struct dom_sid *sid, const struct acct_info *info) 739 724 { 740 725 GROUP_MAP map; … … 755 740 NTSTATUS pdb_create_builtin_alias(uint32 rid) 756 741 { 757 DOM_SIDsid;742 struct dom_sid sid; 758 743 enum lsa_SidType type; 759 744 gid_t gid; … … 765 750 766 751 DEBUG(10, ("Trying to create builtin alias %d\n", rid)); 767 752 768 753 if ( !sid_compose( &sid, &global_sid_Builtin, rid ) ) { 769 754 return NT_STATUS_NO_SUCH_ALIAS; 770 755 } 771 756 772 757 if ( (mem_ctx = talloc_new(NULL)) == NULL ) { 773 758 return NT_STATUS_NO_MEMORY; 774 759 } 775 760 776 761 if ( !lookup_sid(mem_ctx, &sid, NULL, &name, &type) ) { 777 762 TALLOC_FREE( mem_ctx ); 778 763 return NT_STATUS_NO_SUCH_ALIAS; 779 764 } 780 765 781 766 /* validate RID so copy the name and move on */ 782 767 783 768 fstrcpy( groupname, name ); 784 769 TALLOC_FREE( mem_ctx );
Note:
See TracChangeset
for help on using the changeset viewer.