Changeset 599 for trunk/server/source3/smbd/open.c
- Timestamp:
- Jul 6, 2011, 8:21:13 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/server/source3/smbd/open.c
r596 r599 233 233 (unsigned int)smb_fname_parent->st.st_ex_uid, 234 234 strerror(errno) )); 235 } 236 237 DEBUG(10,("change_file_owner_to_parent: changed new file %s to " 235 } else { 236 DEBUG(10,("change_file_owner_to_parent: changed new file %s to " 238 237 "parent directory uid %u.\n", fsp_str_dbg(fsp), 239 238 (unsigned int)smb_fname_parent->st.st_ex_uid)); 239 240 /* Ensure the uid entry is updated. */ 241 fsp->fsp_name->st.st_ex_uid = smb_fname_parent->st.st_ex_uid; 242 } 240 243 241 244 TALLOC_FREE(smb_fname_parent); … … 312 315 /* Ensure we're pointing at the same place. */ 313 316 if (smb_fname_cwd->st.st_ex_dev != psbuf->st_ex_dev || 314 smb_fname_cwd->st.st_ex_ino != psbuf->st_ex_ino || 315 smb_fname_cwd->st.st_ex_mode != psbuf->st_ex_mode ) { 317 smb_fname_cwd->st.st_ex_ino != psbuf->st_ex_ino) { 316 318 DEBUG(0,("change_dir_owner_to_parent: " 317 "device/inode /modeon directory %s changed. "319 "device/inode on directory %s changed. " 318 320 "Refusing to chown !\n", fname )); 319 321 status = NT_STATUS_ACCESS_DENIED; … … 338 340 "directory %s to parent directory uid %u.\n", 339 341 fname, (unsigned int)smb_fname_parent->st.st_ex_uid )); 342 343 /* Ensure the uid entry is updated. */ 344 psbuf->st_ex_uid = smb_fname_parent->st.st_ex_uid; 340 345 341 346 chdir: … … 365 370 int local_flags = flags; 366 371 bool file_existed = VALID_STAT(fsp->fsp_name->st); 372 bool file_created = false; 367 373 368 374 fsp->fh->fd = -1; … … 464 470 465 471 if ((local_flags & O_CREAT) && !file_existed) { 466 467 /* Inherit the ACL if required */ 468 if (lp_inherit_perms(SNUM(conn))) { 469 inherit_access_posix_acl(conn, parent_dir, 470 smb_fname->base_name, 471 unx_mode); 472 } 473 474 /* Change the owner if required. */ 475 if (lp_inherit_owner(SNUM(conn))) { 476 change_file_owner_to_parent(conn, parent_dir, 477 fsp); 478 } 479 480 notify_fname(conn, NOTIFY_ACTION_ADDED, 481 FILE_NOTIFY_CHANGE_FILE_NAME, 482 smb_fname->base_name); 472 file_created = true; 483 473 } 484 474 … … 589 579 fd_close(fsp); 590 580 return status; 581 } 582 583 if (file_created) { 584 /* Do all inheritance work after we've 585 done a successful stat call and filled 586 in the stat struct in fsp->fsp_name. */ 587 588 /* Inherit the ACL if required */ 589 if (lp_inherit_perms(SNUM(conn))) { 590 inherit_access_posix_acl(conn, parent_dir, 591 smb_fname->base_name, 592 unx_mode); 593 } 594 595 /* Change the owner if required. */ 596 if (lp_inherit_owner(SNUM(conn))) { 597 change_file_owner_to_parent(conn, parent_dir, 598 fsp); 599 } 600 601 notify_fname(conn, NOTIFY_ACTION_ADDED, 602 FILE_NOTIFY_CHANGE_FILE_NAME, 603 smb_fname->base_name); 591 604 } 592 605 } … … 2307 2320 NTSTATUS status; 2308 2321 bool posix_open = false; 2322 bool need_re_stat = false; 2309 2323 2310 2324 if(!CAN_WRITE(conn)) { … … 2361 2375 inherit_access_posix_acl(conn, parent_dir, 2362 2376 smb_dname->base_name, mode); 2377 need_re_stat = true; 2363 2378 } 2364 2379 … … 2375 2390 (smb_dname->st.st_ex_mode | 2376 2391 (mode & ~smb_dname->st.st_ex_mode))); 2392 need_re_stat = true; 2377 2393 } 2378 2394 } … … 2383 2399 smb_dname->base_name, 2384 2400 &smb_dname->st); 2401 need_re_stat = true; 2402 } 2403 2404 if (need_re_stat) { 2405 if (SMB_VFS_LSTAT(conn, smb_dname) == -1) { 2406 DEBUG(2, ("Could not stat directory '%s' just created: %s\n", 2407 smb_fname_str_dbg(smb_dname), strerror(errno))); 2408 return map_nt_error_from_unix(errno); 2409 } 2385 2410 } 2386 2411 … … 2945 2970 if (lp_acl_check_permissions(SNUM(conn)) 2946 2971 && (create_disposition != FILE_CREATE) 2947 && (share_access & FILE_SHARE_DELETE)2948 2972 && (access_mask & DELETE_ACCESS) 2949 2973 && (!(can_delete_file_in_directory(conn, smb_fname) ||
Note:
See TracChangeset
for help on using the changeset viewer.