Changeset 232 for branches/samba-3.2.x/source/modules/nfs4_acls.c
- Timestamp:
- May 27, 2009, 9:09:42 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/samba-3.2.x/source/modules/nfs4_acls.c
r204 r232 704 704 705 705 SMB_STRUCT_STAT sbuf; 706 bool need_chown = False;706 bool set_acl_as_root = false; 707 707 uid_t newUID = (uid_t)-1; 708 708 gid_t newGID = (gid_t)-1; 709 int saved_errno; 709 710 710 711 DEBUG(10, ("smb_set_nt_acl_nfs4 invoked for %s\n", fsp->fsp_name)); … … 734 735 if (((newUID != (uid_t)-1) && (sbuf.st_uid != newUID)) || 735 736 ((newGID != (gid_t)-1) && (sbuf.st_gid != newGID))) { 736 need_chown = True; 737 } 738 if (need_chown) { 739 if ((newUID == (uid_t)-1 || newUID == current_user.ut.uid)) { 740 if(try_chown(fsp->conn, fsp->fsp_name, newUID, newGID)) { 741 DEBUG(3,("chown %s, %u, %u failed. Error = %s.\n", 742 fsp->fsp_name, (unsigned int)newUID, (unsigned int)newGID, 743 strerror(errno))); 744 return map_nt_error_from_unix(errno); 745 } 746 747 DEBUG(10,("chown %s, %u, %u succeeded.\n", 748 fsp->fsp_name, (unsigned int)newUID, (unsigned int)newGID)); 749 if (smbacl4_GetFileOwner(fsp->conn, fsp->fsp_name, &sbuf)) 750 return map_nt_error_from_unix(errno); 751 need_chown = False; 752 } else { /* chown is needed, but _after_ changing acl */ 753 sbuf.st_uid = newUID; /* OWNER@ in case of e_special */ 754 sbuf.st_gid = newGID; /* GROUP@ in case of e_special */ 755 } 756 } 757 } 758 759 if ((security_info_sent & DACL_SECURITY_INFORMATION)!=0 && psd->dacl!=NULL) 760 { 761 acl = smbacl4_win2nfs4(fsp->fsp_name, psd->dacl, ¶ms, sbuf.st_uid, sbuf.st_gid); 762 if (!acl) 763 return map_nt_error_from_unix(errno); 764 765 smbacl4_dump_nfs4acl(10, acl); 766 767 result = set_nfs4_native(fsp, acl); 768 if (result!=True) 769 { 770 DEBUG(10, ("set_nfs4_native failed with %s\n", strerror(errno))); 771 return map_nt_error_from_unix(errno); 772 } 773 } else 737 if(try_chown(fsp->conn, fsp->fsp_name, newUID, newGID)) { 738 DEBUG(3,("chown %s, %u, %u failed. Error = %s.\n", 739 fsp->fsp_name, (unsigned int)newUID, (unsigned int)newGID, 740 strerror(errno))); 741 return map_nt_error_from_unix(errno); 742 } 743 744 DEBUG(10,("chown %s, %u, %u succeeded.\n", 745 fsp->fsp_name, (unsigned int)newUID, (unsigned int)newGID)); 746 if (smbacl4_GetFileOwner(fsp->conn, fsp->fsp_name, &sbuf)) 747 return map_nt_error_from_unix(errno); 748 /* If we successfully chowned, we know we must 749 * be able to set the acl, so do it as root. 750 */ 751 set_acl_as_root = true; 752 } 753 } 754 755 if (!(security_info_sent & DACL_SECURITY_INFORMATION) || psd->dacl ==NULL) { 774 756 DEBUG(10, ("no dacl found; security_info_sent = 0x%x\n", security_info_sent)); 775 776 /* Any chown pending? */ 777 if (need_chown) { 778 DEBUG(3,("chown#2 %s. uid = %u, gid = %u.\n", 779 fsp->fsp_name, (unsigned int)newUID, (unsigned int)newGID)); 780 if (try_chown(fsp->conn, fsp->fsp_name, newUID, newGID)) { 781 DEBUG(2,("chown#2 %s, %u, %u failed. Error = %s.\n", 782 fsp->fsp_name, (unsigned int)newUID, (unsigned int)newGID, 783 strerror(errno))); 784 return map_nt_error_from_unix(errno); 785 } 786 DEBUG(10,("chown#2 %s, %u, %u succeeded.\n", 787 fsp->fsp_name, (unsigned int)newUID, (unsigned int)newGID)); 757 return NT_STATUS_OK; 758 } 759 760 acl = smbacl4_win2nfs4(fsp->fsp_name, psd->dacl, ¶ms, sbuf.st_uid, sbuf.st_gid); 761 if (!acl) 762 return map_nt_error_from_unix(errno); 763 764 smbacl4_dump_nfs4acl(10, acl); 765 766 if (set_acl_as_root) { 767 become_root(); 768 } 769 result = set_nfs4_native(fsp, acl); 770 saved_errno = errno; 771 if (set_acl_as_root) { 772 unbecome_root(); 773 } 774 if (result!=True) { 775 errno = saved_errno; 776 DEBUG(10, ("set_nfs4_native failed with %s\n", strerror(errno))); 777 return map_nt_error_from_unix(errno); 788 778 } 789 779
Note:
See TracChangeset
for help on using the changeset viewer.