Ignore:
Timestamp:
Jul 6, 2011, 8:21:13 PM (14 years ago)
Author:
Herwig Bauernfeind
Message:

Samba 3.5: Update trunk to 3.5.9

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/server/source3/smbd/open.c

    r596 r599  
    233233                         (unsigned int)smb_fname_parent->st.st_ex_uid,
    234234                         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 "
    238237                  "parent directory uid %u.\n", fsp_str_dbg(fsp),
    239238                  (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        }
    240243
    241244        TALLOC_FREE(smb_fname_parent);
     
    312315        /* Ensure we're pointing at the same place. */
    313316        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) {
    316318                DEBUG(0,("change_dir_owner_to_parent: "
    317                          "device/inode/mode on directory %s changed. "
     319                         "device/inode on directory %s changed. "
    318320                         "Refusing to chown !\n", fname ));
    319321                status = NT_STATUS_ACCESS_DENIED;
     
    338340                  "directory %s to parent directory uid %u.\n",
    339341                  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;
    340345
    341346 chdir:
     
    365370        int local_flags = flags;
    366371        bool file_existed = VALID_STAT(fsp->fsp_name->st);
     372        bool file_created = false;
    367373
    368374        fsp->fh->fd = -1;
     
    464470
    465471                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;
    483473                }
    484474
     
    589579                        fd_close(fsp);
    590580                        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);
    591604                }
    592605        }
     
    23072320        NTSTATUS status;
    23082321        bool posix_open = false;
     2322        bool need_re_stat = false;
    23092323
    23102324        if(!CAN_WRITE(conn)) {
     
    23612375                inherit_access_posix_acl(conn, parent_dir,
    23622376                                         smb_dname->base_name, mode);
     2377                need_re_stat = true;
    23632378        }
    23642379
     
    23752390                                      (smb_dname->st.st_ex_mode |
    23762391                                          (mode & ~smb_dname->st.st_ex_mode)));
     2392                        need_re_stat = true;
    23772393                }
    23782394        }
     
    23832399                                           smb_dname->base_name,
    23842400                                           &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                }
    23852410        }
    23862411
     
    29452970        if (lp_acl_check_permissions(SNUM(conn))
    29462971            && (create_disposition != FILE_CREATE)
    2947             && (share_access & FILE_SHARE_DELETE)
    29482972            && (access_mask & DELETE_ACCESS)
    29492973            && (!(can_delete_file_in_directory(conn, smb_fname) ||
Note: See TracChangeset for help on using the changeset viewer.