Changeset 233 for branches/samba-3.2.x/source/auth/auth_util.c
- Timestamp:
- May 27, 2009, 11:39:15 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/samba-3.2.x/source/auth/auth_util.c
r149 r233 548 548 gid_t *gids; 549 549 auth_serversupplied_info *result; 550 int i;551 size_t num_gids;552 DOM_SID unix_group_sid;553 550 const char *username = pdb_get_username(sampass); 554 551 NTSTATUS status; … … 566 563 567 564 result->sam_account = sampass; 568 /* Ensure thaat the sampass will be freed with the result */569 talloc_steal(result, sampass);570 565 result->unix_name = pwd->pw_name; 571 566 /* Ensure that we keep pwd->pw_name, because we will free pwd below */ … … 617 612 } 618 613 619 /* Add the "Unix Group" SID for each gid to catch mapped groups620 and their Unix equivalent. This is to solve the backwards621 compatibility problem of 'valid users = +ntadmin' where622 ntadmin has been paired with "Domain Admins" in the group623 mapping table. Otherwise smb.conf would need to be changed624 to 'valid user = "Domain Admins"'. --jerry */625 626 num_gids = result->num_sids;627 for ( i=0; i<num_gids; i++ ) {628 if ( !gid_to_unix_groups_sid( gids[i], &unix_group_sid ) ) {629 DEBUG(1,("make_server_info_sam: Failed to create SID "630 "for gid %d!\n", gids[i]));631 continue;632 }633 status = add_sid_to_array_unique(result, &unix_group_sid,634 &result->sids,635 &result->num_sids);636 if (!NT_STATUS_IS_OK(status)) {637 result->sam_account = NULL; /* Don't free on error exit. */638 TALLOC_FREE(result);639 return status;640 }641 }642 643 614 /* For now we throw away the gids and convert via sid_to_gid 644 615 * later. This needs fixing, but I'd like to get the code straight and … … 651 622 652 623 *server_info = result; 624 /* Ensure thaat the sampass will be freed with the result */ 625 talloc_steal(result, sampass); 653 626 654 627 return NT_STATUS_OK; … … 701 674 NTSTATUS status; 702 675 size_t i; 703 704 705 mem_ctx = talloc_new(NULL); 706 if (mem_ctx == NULL) { 707 DEBUG(0, ("talloc_new failed\n")); 708 return NT_STATUS_NO_MEMORY; 709 } 676 struct dom_sid tmp_sid; 710 677 711 678 /* … … 736 703 737 704 if (!NT_STATUS_IS_OK(status)) { 738 TALLOC_FREE(mem_ctx);739 705 return status; 740 706 } … … 759 725 &server_info->n_groups); 760 726 } 761 727 728 if (!uid_to_unix_users_sid(server_info->uid, &tmp_sid)) { 729 DEBUG(1,("create_local_token: Failed to create SID " 730 "for uid %d!\n", server_info->uid)); 731 } 732 add_sid_to_array_unique(server_info->ptok, &tmp_sid, 733 &server_info->ptok->user_sids, 734 &server_info->ptok->num_sids); 735 736 if (!gid_to_unix_groups_sid( server_info->gid, &tmp_sid)) { 737 DEBUG(1,("create_local_token: Failed to create SID " 738 "for gid %d!\n", server_info->gid)); 739 } 740 add_sid_to_array_unique(server_info->ptok, &tmp_sid, 741 &server_info->ptok->user_sids, 742 &server_info->ptok->num_sids); 743 744 for ( i=0; i<server_info->n_groups; i++ ) { 745 if (!gid_to_unix_groups_sid( server_info->groups[i], &tmp_sid ) ) { 746 DEBUG(1,("create_local_token: Failed to create SID " 747 "for gid %d!\n", server_info->groups[i])); 748 continue; 749 } 750 add_sid_to_array_unique(server_info->ptok, &tmp_sid, 751 &server_info->ptok->user_sids, 752 &server_info->ptok->num_sids); 753 } 754 762 755 debug_nt_user_token(DBGC_AUTH, 10, server_info->ptok); 756 debug_unix_user_token(DBGC_AUTH, 10, 757 server_info->uid, 758 server_info->gid, 759 server_info->n_groups, 760 server_info->groups); 761 762 mem_ctx = talloc_new(NULL); 763 if (mem_ctx == NULL) { 764 DEBUG(0, ("talloc_new failed\n")); 765 return NT_STATUS_NO_MEMORY; 766 } 763 767 764 768 status = log_nt_token(mem_ctx, server_info->ptok); … … 769 773 770 774 /* 771 * Create an artificial NT token given just a username. (Initially in dended775 * Create an artificial NT token given just a username. (Initially intended 772 776 * for force user) 773 777 * … … 822 826 } 823 827 824 if (!sid_to_uid(&user_sid, uid)) {825 DEBUG(1, ("sid_to_uid for %s (%s) failed\n",826 username, sid_string_dbg(&user_sid)));827 goto done;828 }829 830 828 if (sid_check_is_in_our_domain(&user_sid)) { 831 829 bool ret; … … 884 882 885 883 unix_user: 884 885 if (!sid_to_uid(&user_sid, uid)) { 886 DEBUG(1, ("sid_to_uid for %s (%s) failed\n", 887 username, sid_string_dbg(&user_sid))); 888 goto done; 889 } 886 890 887 891 uid_to_unix_users_sid(*uid, &user_sid);
Note:
See TracChangeset
for help on using the changeset viewer.