Changeset 221 for branches/samba-3.3.x/source/smbd/open.c
- Timestamp:
- May 24, 2009, 7:17:10 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/samba-3.3.x/source/smbd/open.c
r206 r221 51 51 static NTSTATUS check_open_rights(struct connection_struct *conn, 52 52 const char *fname, 53 uint32_t access_mask) 53 uint32_t access_mask, 54 uint32_t *access_granted) 54 55 { 55 56 /* Check if we have rights to open. */ 56 57 NTSTATUS status; 57 uint32_t access_granted = 0;58 58 struct security_descriptor *sd; 59 60 *access_granted = 0; 59 61 60 62 status = SMB_VFS_GET_NT_ACL(conn, fname, … … 74 76 conn->server_info->ptok, 75 77 access_mask, 76 &access_granted);78 access_granted); 77 79 78 80 TALLOC_FREE(sd); 81 82 DEBUG(10,("check_open_rights: file %s requesting " 83 "0x%x returning 0x%x (%s)\n", 84 fname, 85 (unsigned int)access_mask, 86 (unsigned int)*access_granted, 87 nt_errstr(status) )); 88 79 89 return status; 80 90 } … … 399 409 fsp->fh->fd = -1; /* What we used to call a stat open. */ 400 410 if (file_existed) { 411 uint32_t access_granted = 0; 412 401 413 status = check_open_rights(conn, 402 414 path, 403 access_mask); 415 access_mask, 416 &access_granted); 404 417 if (!NT_STATUS_IS_OK(status)) { 405 DEBUG(10, ("open_file: Access denied on " 406 "file %s\n", 407 path)); 408 return status; 418 if (NT_STATUS_EQUAL(status, NT_STATUS_ACCESS_DENIED)) { 419 if ((access_mask & DELETE_ACCESS) && 420 (access_granted == DELETE_ACCESS) && 421 can_delete_file_in_directory(conn, path)) { 422 /* Were we trying to do a stat open 423 * for delete and didn't get DELETE 424 * access (only) ? Check if the 425 * directory allows DELETE_CHILD. 426 * See here: 427 * http://blogs.msdn.com/oldnewthing/archive/2004/06/04/148426.aspx 428 * for details. */ 429 430 DEBUG(10,("open_file: overrode ACCESS_DENIED " 431 "on file %s\n", 432 path )); 433 } else { 434 DEBUG(10, ("open_file: Access denied on " 435 "file %s\n", 436 path)); 437 return status; 438 } 439 } else if (NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_NOT_FOUND) && 440 fsp->posix_open && 441 S_ISLNK(psbuf->st_mode)) { 442 /* This is a POSIX stat open for delete 443 * or rename on a symlink that points 444 * nowhere. Allow. */ 445 DEBUG(10, ("open_file: allowing POSIX open " 446 "on bad symlink %s\n", 447 path )); 448 } else { 449 DEBUG(10, ("open_file: check_open_rights " 450 "on file %s returned %s\n", 451 path, nt_errstr(status) )); 452 return status; 453 } 409 454 } 410 455 } … … 1314 1359 bool posix_open = False; 1315 1360 bool new_file_created = False; 1361 bool clear_ads = false; 1316 1362 struct file_id id; 1317 1363 NTSTATUS fsp_open = NT_STATUS_ACCESS_DENIED; … … 1367 1413 "unix mode=0%o oplock_request=%d\n", 1368 1414 fname, new_dos_attributes, access_mask, share_access, 1369 create_disposition, create_options, unx_mode,1415 create_disposition, create_options, (unsigned int)unx_mode, 1370 1416 oplock_request)); 1371 1417 … … 1446 1492 * exist create. */ 1447 1493 flags2 |= (O_CREAT | O_TRUNC); 1494 clear_ads = true; 1448 1495 break; 1449 1496 … … 1452 1499 * exist create. */ 1453 1500 flags2 |= (O_CREAT | O_TRUNC); 1501 clear_ads = true; 1454 1502 break; 1455 1503 … … 1476 1524 } 1477 1525 flags2 |= O_TRUNC; 1526 clear_ads = true; 1478 1527 break; 1479 1528 … … 1908 1957 1909 1958 SMB_ASSERT(lck != NULL); 1959 1960 /* Delete streams if create_disposition requires it */ 1961 if (file_existed && clear_ads && !is_ntfs_stream_name(fname)) { 1962 status = delete_all_streams(conn, fname); 1963 if (!NT_STATUS_IS_OK(status)) { 1964 TALLOC_FREE(lck); 1965 fd_close(fsp); 1966 return status; 1967 } 1968 } 1910 1969 1911 1970 /* note that we ignore failure for the following. It is … … 2399 2458 2400 2459 if (info == FILE_WAS_OPENED) { 2460 uint32_t access_granted = 0; 2401 2461 status = check_open_rights(conn, 2402 2462 fname, 2403 access_mask); 2463 access_mask, 2464 &access_granted); 2404 2465 if (!NT_STATUS_IS_OK(status)) { 2405 2466 DEBUG(10, ("open_directory: check_open_rights on " … … 2820 2881 && (share_access & FILE_SHARE_DELETE) 2821 2882 && (access_mask & DELETE_ACCESS) 2822 && (!can_delete_file_in_directory(conn, fname))) { 2883 && (!(can_delete_file_in_directory(conn, fname) || 2884 can_access_file_acl(conn, fname, DELETE_ACCESS)))) { 2823 2885 status = NT_STATUS_ACCESS_DENIED; 2886 DEBUG(10,("create_file_unixpath: open file %s " 2887 "for delete ACCESS_DENIED\n", fname )); 2824 2888 goto fail; 2825 2889 }
Note:
See TracChangeset
for help on using the changeset viewer.