Changeset 746 for vendor/current/source3/smbd/open.c
- Timestamp:
- Nov 27, 2012, 4:56:06 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
vendor/current/source3/smbd/open.c
r740 r746 93 93 smb_fname_str_dbg(smb_fname), 94 94 (unsigned int)*access_granted )); 95 return NT_STATUS_OK; 96 } 97 98 if (access_mask == DELETE_ACCESS && 99 VALID_STAT(smb_fname->st) && 100 S_ISLNK(smb_fname->st.st_ex_mode)) { 101 /* We can always delete a symlink. */ 102 DEBUG(10,("smbd_check_open_rights: not checking ACL " 103 "on DELETE_ACCESS on symlink %s.\n", 104 smb_fname_str_dbg(smb_fname) )); 95 105 return NT_STATUS_OK; 96 106 } … … 698 708 } 699 709 700 /*******************************************************************701 Return True if the filename is one of the special executable types.702 ********************************************************************/703 704 bool is_executable(const char *fname)705 {706 if ((fname = strrchr_m(fname,'.'))) {707 if (strequal(fname,".com") ||708 strequal(fname,".dll") ||709 strequal(fname,".exe") ||710 strequal(fname,".sym")) {711 return True;712 }713 }714 return False;715 }716 717 710 /**************************************************************************** 718 711 Check if we can open a file with a share mode. … … 942 935 } 943 936 944 static bool is_delete_request(files_struct *fsp) {945 return ((fsp->access_mask == DELETE_ACCESS) &&946 (fsp->oplock_type == NO_OPLOCK));947 }948 949 937 /* 950 938 * Send a break message to the oplock holder and delay the open for … … 1091 1079 1092 1080 if (ex_entry != NULL) { 1093 /* Found an exclusive or batch oplock */ 1094 bool delay_it = is_delete_request(fsp) ? 1095 BATCH_OPLOCK_TYPE(ex_entry->op_type) : true; 1096 if (delay_it) { 1097 send_break_message(fsp, ex_entry, mid, oplock_request); 1098 return true; 1099 } 1081 send_break_message(fsp, ex_entry, mid, oplock_request); 1082 return true; 1100 1083 } 1101 1084 return false; … … 1335 1318 } 1336 1319 1337 /****************************************************************************1338 Open a file with a share mode - old openX method - map into NTCreate.1339 ****************************************************************************/1340 1341 bool map_open_params_to_ntcreate(const struct smb_filename *smb_fname,1342 int deny_mode, int open_func,1343 uint32 *paccess_mask,1344 uint32 *pshare_mode,1345 uint32 *pcreate_disposition,1346 uint32 *pcreate_options,1347 uint32_t *pprivate_flags)1348 {1349 uint32 access_mask;1350 uint32 share_mode;1351 uint32 create_disposition;1352 uint32 create_options = FILE_NON_DIRECTORY_FILE;1353 uint32_t private_flags = 0;1354 1355 DEBUG(10,("map_open_params_to_ntcreate: fname = %s, deny_mode = 0x%x, "1356 "open_func = 0x%x\n",1357 smb_fname_str_dbg(smb_fname), (unsigned int)deny_mode,1358 (unsigned int)open_func ));1359 1360 /* Create the NT compatible access_mask. */1361 switch (GET_OPENX_MODE(deny_mode)) {1362 case DOS_OPEN_EXEC: /* Implies read-only - used to be FILE_READ_DATA */1363 case DOS_OPEN_RDONLY:1364 access_mask = FILE_GENERIC_READ;1365 break;1366 case DOS_OPEN_WRONLY:1367 access_mask = FILE_GENERIC_WRITE;1368 break;1369 case DOS_OPEN_RDWR:1370 case DOS_OPEN_FCB:1371 access_mask = FILE_GENERIC_READ|FILE_GENERIC_WRITE;1372 break;1373 default:1374 DEBUG(10,("map_open_params_to_ntcreate: bad open mode = 0x%x\n",1375 (unsigned int)GET_OPENX_MODE(deny_mode)));1376 return False;1377 }1378 1379 /* Create the NT compatible create_disposition. */1380 switch (open_func) {1381 case OPENX_FILE_EXISTS_FAIL|OPENX_FILE_CREATE_IF_NOT_EXIST:1382 create_disposition = FILE_CREATE;1383 break;1384 1385 case OPENX_FILE_EXISTS_OPEN:1386 create_disposition = FILE_OPEN;1387 break;1388 1389 case OPENX_FILE_EXISTS_OPEN|OPENX_FILE_CREATE_IF_NOT_EXIST:1390 create_disposition = FILE_OPEN_IF;1391 break;1392 1393 case OPENX_FILE_EXISTS_TRUNCATE:1394 create_disposition = FILE_OVERWRITE;1395 break;1396 1397 case OPENX_FILE_EXISTS_TRUNCATE|OPENX_FILE_CREATE_IF_NOT_EXIST:1398 create_disposition = FILE_OVERWRITE_IF;1399 break;1400 1401 default:1402 /* From samba4 - to be confirmed. */1403 if (GET_OPENX_MODE(deny_mode) == DOS_OPEN_EXEC) {1404 create_disposition = FILE_CREATE;1405 break;1406 }1407 DEBUG(10,("map_open_params_to_ntcreate: bad "1408 "open_func 0x%x\n", (unsigned int)open_func));1409 return False;1410 }1411 1412 /* Create the NT compatible share modes. */1413 switch (GET_DENY_MODE(deny_mode)) {1414 case DENY_ALL:1415 share_mode = FILE_SHARE_NONE;1416 break;1417 1418 case DENY_WRITE:1419 share_mode = FILE_SHARE_READ;1420 break;1421 1422 case DENY_READ:1423 share_mode = FILE_SHARE_WRITE;1424 break;1425 1426 case DENY_NONE:1427 share_mode = FILE_SHARE_READ|FILE_SHARE_WRITE;1428 break;1429 1430 case DENY_DOS:1431 private_flags |= NTCREATEX_OPTIONS_PRIVATE_DENY_DOS;1432 if (is_executable(smb_fname->base_name)) {1433 share_mode = FILE_SHARE_READ|FILE_SHARE_WRITE;1434 } else {1435 if (GET_OPENX_MODE(deny_mode) == DOS_OPEN_RDONLY) {1436 share_mode = FILE_SHARE_READ;1437 } else {1438 share_mode = FILE_SHARE_NONE;1439 }1440 }1441 break;1442 1443 case DENY_FCB:1444 private_flags |= NTCREATEX_OPTIONS_PRIVATE_DENY_FCB;1445 share_mode = FILE_SHARE_NONE;1446 break;1447 1448 default:1449 DEBUG(10,("map_open_params_to_ntcreate: bad deny_mode 0x%x\n",1450 (unsigned int)GET_DENY_MODE(deny_mode) ));1451 return False;1452 }1453 1454 DEBUG(10,("map_open_params_to_ntcreate: file %s, access_mask = 0x%x, "1455 "share_mode = 0x%x, create_disposition = 0x%x, "1456 "create_options = 0x%x private_flags = 0x%x\n",1457 smb_fname_str_dbg(smb_fname),1458 (unsigned int)access_mask,1459 (unsigned int)share_mode,1460 (unsigned int)create_disposition,1461 (unsigned int)create_options,1462 (unsigned int)private_flags));1463 1464 if (paccess_mask) {1465 *paccess_mask = access_mask;1466 }1467 if (pshare_mode) {1468 *pshare_mode = share_mode;1469 }1470 if (pcreate_disposition) {1471 *pcreate_disposition = create_disposition;1472 }1473 if (pcreate_options) {1474 *pcreate_options = create_options;1475 }1476 if (pprivate_flags) {1477 *pprivate_flags = private_flags;1478 }1479 1480 return True;1481 1482 }1483 1484 1320 static void schedule_defer_open(struct share_mode_lock *lck, 1485 1321 struct timeval request_time, … … 1573 1409 smb_fname_str_dbg(smb_fname))); 1574 1410 return NT_STATUS_ACCESS_DENIED; 1411 } 1412 1413 if (!(access_granted & DELETE_ACCESS)) { 1414 if (can_delete_file_in_directory(conn, smb_fname)) { 1415 access_granted |= DELETE_ACCESS; 1416 } 1575 1417 } 1576 1418 … … 1705 1547 ZERO_STRUCT(id); 1706 1548 1707 /* Windows allows a new file to be created and1708 silently removes a FILE_ATTRIBUTE_DIRECTORY1709 sent by the client. Do the same. */1710 1711 new_dos_attributes &= ~FILE_ATTRIBUTE_DIRECTORY;1712 1713 1549 if (conn->printer) { 1714 1550 /* … … 1744 1580 new_dos_attributes = 0; 1745 1581 } else { 1582 /* Windows allows a new file to be created and 1583 silently removes a FILE_ATTRIBUTE_DIRECTORY 1584 sent by the client. Do the same. */ 1585 1586 new_dos_attributes &= ~FILE_ATTRIBUTE_DIRECTORY; 1587 1746 1588 /* We add FILE_ATTRIBUTE_ARCHIVE to this as this mode is only used if the file is 1747 1589 * created new. */ … … 1787 1629 remove_deferred_open_message_smb(req->mid); 1788 1630 } 1789 }1790 1791 status = check_name(conn, smb_fname->base_name);1792 if (!NT_STATUS_IS_OK(status)) {1793 return status;1794 1631 } 1795 1632 … … 2743 2580 SMB_ASSERT(!is_ntfs_stream_smb_fname(smb_dname)); 2744 2581 2745 /* Ensure we have a directory attribute. */ 2746 file_attributes |= FILE_ATTRIBUTE_DIRECTORY; 2582 if (!(file_attributes & FILE_FLAG_POSIX_SEMANTICS)) { 2583 /* Ensure we have a directory attribute. */ 2584 file_attributes |= FILE_ATTRIBUTE_DIRECTORY; 2585 } 2747 2586 2748 2587 DEBUG(5,("open_directory: opening directory %s, access_mask = 0x%x, " … … 2900 2739 fsp->share_access = share_access; 2901 2740 fsp->fh->private_options = 0; 2902 /*2903 * According to Samba4, SEC_FILE_READ_ATTRIBUTE is always granted,2904 */2905 fsp->access_mask = access_mask | FILE_READ_ATTRIBUTES;2906 2741 fsp->print_file = NULL; 2907 2742 fsp->modified = False; … … 2918 2753 mtimespec = smb_dname->st.st_ex_mtime; 2919 2754 2755 /* Temporary access mask used to open the directory fd. */ 2756 fsp->access_mask = FILE_READ_DATA | FILE_READ_ATTRIBUTES; 2920 2757 #ifdef O_DIRECTORY 2921 2758 status = fd_open(conn, fsp, O_RDONLY|O_DIRECTORY, 0); … … 2932 2769 return status; 2933 2770 } 2771 2772 /* 2773 * According to Samba4, SEC_FILE_READ_ATTRIBUTE is always granted, 2774 * Set the real access mask for later access (possibly delete). 2775 */ 2776 fsp->access_mask = access_mask | FILE_READ_ATTRIBUTES; 2934 2777 2935 2778 status = vfs_stat_fsp(fsp); … … 3132 2975 const char *fname) 3133 2976 { 3134 struct stream_struct *stream_info ;3135 files_struct **streams ;2977 struct stream_struct *stream_info = NULL; 2978 files_struct **streams = NULL; 3136 2979 int i; 3137 unsigned int num_streams ;2980 unsigned int num_streams = 0; 3138 2981 TALLOC_CTX *frame = talloc_stackframe(); 3139 2982 NTSTATUS status; 3140 2983 3141 status = SMB_VFS_STREAMINFO(conn, NULL, fname, talloc_tos(),3142 2984 status = vfs_streaminfo(conn, NULL, fname, talloc_tos(), 2985 &num_streams, &stream_info); 3143 2986 3144 2987 if (NT_STATUS_EQUAL(status, NT_STATUS_NOT_IMPLEMENTED) … … 3150 2993 3151 2994 if (!NT_STATUS_IS_OK(status)) { 3152 DEBUG(10, (" SMB_VFS_STREAMINFOfailed: %s\n",2995 DEBUG(10, ("vfs_streaminfo failed: %s\n", 3153 2996 nt_errstr(status))); 3154 2997 goto fail; … … 3517 3360 fsp->access_mask = FILE_GENERIC_ALL; 3518 3361 3519 /* Convert all the generic bits. */3520 security_acl_map_generic(sd->dacl, &file_generic_mapping);3521 security_acl_map_generic(sd->sacl, &file_generic_mapping);3522 3523 3362 if (sec_info_sent & (SECINFO_OWNER| 3524 3363 SECINFO_GROUP| 3525 3364 SECINFO_DACL| 3526 3365 SECINFO_SACL)) { 3527 status = SMB_VFS_FSET_NT_ACL(fsp, sec_info_sent, sd);3366 status = set_sd(fsp, sd, sec_info_sent); 3528 3367 } 3529 3368 … … 3814 3653 } 3815 3654 3816 /* All file access must go through check_name() */3817 3818 status = check_name(conn, smb_fname->base_name);3819 if (!NT_STATUS_IS_OK(status)) {3820 goto fail;3821 }3822 3823 3655 if (stream_name && is_ntfs_default_stream_smb_fname(smb_fname)) { 3824 3656 int ret;
Note:
See TracChangeset
for help on using the changeset viewer.