Changeset 751 for trunk/server/source3/modules/vfs_acl_common.c
- Timestamp:
- Nov 29, 2012, 1:59:04 PM (13 years ago)
- File:
-
- 1 edited
-
trunk/server/source3/modules/vfs_acl_common.c (modified) (20 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/server/source3/modules/vfs_acl_common.c
r745 r751 167 167 *******************************************************************/ 168 168 169 static voidadd_directory_inheritable_components(vfs_handle_struct *handle,169 static add_directory_inheritable_components(vfs_handle_struct *handle, 170 170 const char *name, 171 171 SMB_STRUCT_STAT *psbuf, … … 185 185 186 186 if (new_ace_list == NULL) { 187 return ;187 return; 188 188 } 189 189 … … 237 237 SEC_ACE_FLAG_OBJECT_INHERIT| 238 238 SEC_ACE_FLAG_INHERIT_ONLY); 239 psd->dacl->aces = new_ace_list; 240 psd->dacl->num_aces += 3; 239 if (psd->dacl) { 240 psd->dacl->aces = new_ace_list; 241 psd->dacl->num_aces += 3; 242 } else { 243 psd->dacl = make_sec_acl(talloc_tos(), 244 NT4_ACL_REVISION, 245 3, 246 new_ace_list); 247 if (psd->dacl == NULL) { 248 return NT_STATUS_NO_MEMORY; 249 } 250 } 251 return NT_STATUS_OK; 241 252 } 242 253 … … 253 264 struct security_descriptor **ppdesc) 254 265 { 255 DATA_BLOB blob ;266 DATA_BLOB blob; 256 267 NTSTATUS status; 257 268 uint16_t hash_type = XATTR_SD_HASH_TYPE_NONE; … … 379 390 } 380 391 } 381 is_directory = S_ISDIR( sbuf.st_ex_mode);392 is_directory = S_ISDIR(st_ex_mode); 382 393 383 394 if (ignore_file_system_acl) { … … 394 405 !sd_has_inheritable_components(psd, 395 406 true)) { 396 add_directory_inheritable_components(handle, 407 status = add_directory_inheritable_components( 408 handle, 397 409 name, 398 410 psbuf, 399 411 psd); 412 413 414 400 415 } 401 416 /* The underlying POSIX module always sets … … 414 429 } 415 430 if (!(security_info & SECINFO_DACL)) { 431 416 432 psd->dacl = NULL; 417 433 } 418 434 if (!(security_info & SECINFO_SACL)) { 435 419 436 psd->sacl = NULL; 420 437 } … … 538 555 (SECINFO_OWNER | 539 556 SECINFO_GROUP | 540 SECINFO_DACL), 557 SECINFO_DACL | 558 SECINFO_SACL), 541 559 pp_parent_desc); 542 560 … … 557 575 struct security_descriptor **pp_parent_desc) 558 576 { 559 char *parent_name = NULL;560 577 struct security_descriptor *parent_desc = NULL; 561 578 uint32_t access_granted = 0; … … 576 593 if(!NT_STATUS_IS_OK(status)) { 577 594 DEBUG(10,("check_parent_acl_common: access check " 578 "on directory %s for"595 "on " 579 596 "path %s for mask 0x%x returned %s\n", 580 parent_name,581 597 path, 582 598 access_mask, … … 621 637 (SECINFO_OWNER | 622 638 SECINFO_GROUP | 623 SECINFO_DACL), 639 SECINFO_DACL | 640 SECINFO_SACL), 624 641 &pdesc); 625 642 if (NT_STATUS_IS_OK(status)) { … … 632 649 if (!NT_STATUS_IS_OK(status)) { 633 650 DEBUG(10,("open_acl_xattr: %s open " 651 634 652 "refused with error %s\n", 635 653 fsp_str_dbg(fsp), 654 655 636 656 nt_errstr(status) )); 637 657 goto err; … … 800 820 CONST_DISCARD(struct security_descriptor *,psd)); 801 821 } 802 create_acl_blob(psd, &blob, XATTR_SD_HASH_TYPE_SHA256, hash); 803 store_acl_blob_fsp(handle, fsp, &blob); 804 805 return NT_STATUS_OK; 822 status = create_acl_blob(psd, &blob, XATTR_SD_HASH_TYPE_SHA256, hash); 823 if (!NT_STATUS_IS_OK(status)) { 824 DEBUG(10, ("fset_nt_acl_xattr: create_acl_blob failed\n")); 825 return status; 826 } 827 828 status = store_acl_blob_fsp(handle, fsp, &blob); 829 830 return status; 806 831 } 807 832 … … 809 834 const char *fname, const char *mask, uint32 attr) 810 835 { 811 NTSTATUS status = check_parent_acl_common(handle, fname, 812 SEC_DIR_LIST, NULL); 813 814 if (!NT_STATUS_IS_OK(status)) { 836 NTSTATUS status; 837 uint32_t access_granted = 0; 838 struct security_descriptor *sd = NULL; 839 840 status = get_nt_acl_internal(handle, 841 NULL, 842 fname, 843 (SECINFO_OWNER | 844 SECINFO_GROUP | 845 SECINFO_DACL | 846 SECINFO_SACL), 847 &sd); 848 if (!NT_STATUS_IS_OK(status)) { 849 DEBUG(10,("opendir_acl_common: " 850 "get_nt_acl_internal for dir %s " 851 "failed with error %s\n", 852 fname, 853 nt_errstr(status) )); 815 854 errno = map_errno_from_nt_status(status); 816 855 return NULL; 817 856 } 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 818 874 return SMB_VFS_NEXT_OPENDIR(handle, fname, mask, attr); 819 875 } … … 831 887 struct smb_filename local_fname; 832 888 int saved_errno = 0; 889 890 891 892 893 894 895 833 896 834 897 if (!parent_dirname(talloc_tos(), path, … … 843 906 844 907 /* cd into the parent dir to pin it. */ 845 ret = SMB_VFS_CHDIR(conn, parent_dir);908 ret = (conn, parent_dir); 846 909 if (ret == -1) { 847 910 saved_errno = errno; … … 862 925 id = vfs_file_id_from_sbuf(conn, &local_fname.st); 863 926 for (fsp = file_find_di_first(conn->sconn, id); fsp; 864 file_find_di_next(fsp)) {927 file_find_di_next(fsp)) { 865 928 if (fsp->access_mask & DELETE_ACCESS && 866 929 fsp->delete_on_close) { … … 897 960 TALLOC_FREE(parent_dir); 898 961 899 vfs_ChDir(conn, conn->connectpath); 962 if (saved_dir) { 963 vfs_ChDir(conn, saved_dir); 964 } 900 965 if (saved_errno) { 901 966 errno = saved_errno; … … 909 974 int ret; 910 975 976 911 977 ret = SMB_VFS_NEXT_RMDIR(handle, path); 912 if (!(ret == -1 && (errno == EACCES || errno == EPERM))) { 913 DEBUG(10,("rmdir_acl_common: unlink of %s failed %s\n", 914 path, 915 strerror(errno) )); 916 return ret; 917 } 918 919 return acl_common_remove_object(handle, 920 path, 921 true); 978 if (ret == 0) { 979 return 0; 980 } 981 if (errno == EACCES || errno == EPERM) { 982 /* Failed due to access denied, 983 see if we need to root override. */ 984 return acl_common_remove_object(handle, 985 path, 986 true); 987 } 988 989 DEBUG(10,("rmdir_acl_common: unlink of %s failed %s\n", 990 path, 991 strerror(errno) )); 992 return -1; 922 993 } 923 994 … … 1039 1110 int ret; 1040 1111 1112 1041 1113 ret = SMB_VFS_NEXT_UNLINK(handle, smb_fname); 1042 if ( !(ret == -1 && (errno == EACCES || errno == EPERM))) {1043 DEBUG(10,("unlink_acl_common: unlink of %s failed %s\n",1044 smb_fname->base_name,1045 strerror(errno) ));1046 return ret;1047 }1048 /* Don't do anything fancy for streams. */ 1049 if (smb_fname->stream_name) {1050 return ret;1051 }1052 1053 return acl_common_remove_object(handle,1114 if () { 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 } 1125 return acl_common_remove_object(handle, 1054 1126 smb_fname->base_name, 1055 1127 false); 1128 1129 1130 1131 1132 1133 1056 1134 } 1057 1135
Note:
See TracChangeset
for help on using the changeset viewer.
