]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3: smbd: Change change_file_owner_to_parent() -> change_file_owner_to_parent_fsp().
authorJeremy Allison <jra@samba.org>
Wed, 9 Jun 2021 19:28:42 +0000 (12:28 -0700)
committerRalph Boehme <slow@samba.org>
Fri, 18 Jun 2021 16:32:28 +0000 (16:32 +0000)
Same changes as for change_dir_owner_to_parent_fsp().

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
source3/smbd/open.c

index 32672373646348479a269349139eda0e3218db6c..22bd6050eb8963940ea9a1b319e9337f4b98f09c 100644 (file)
@@ -939,45 +939,48 @@ NTSTATUS fd_close(files_struct *fsp)
  Do this by fd if possible.
 ****************************************************************************/
 
-static void change_file_owner_to_parent(connection_struct *conn,
-                                struct smb_filename *smb_fname_parent,
-                                files_struct *fsp)
+static void change_file_owner_to_parent_fsp(struct files_struct *parent_fsp,
+                                           struct files_struct *fsp)
 {
        int ret;
 
-       ret = SMB_VFS_STAT(conn, smb_fname_parent);
+       ret = SMB_VFS_FSTAT(parent_fsp, &parent_fsp->fsp_name->st);
        if (ret == -1) {
-               DEBUG(0,("change_file_owner_to_parent: failed to stat parent "
-                        "directory %s. Error was %s\n",
-                        smb_fname_str_dbg(smb_fname_parent),
-                        strerror(errno)));
-               return;
+               DBG_ERR("failed to stat parent "
+                       "directory %s. Error was %s\n",
+                       fsp_str_dbg(parent_fsp),
+                       strerror(errno));
+                return;
        }
 
-       if (smb_fname_parent->st.st_ex_uid == fsp->fsp_name->st.st_ex_uid) {
+       if (parent_fsp->fsp_name->st.st_ex_uid == fsp->fsp_name->st.st_ex_uid) {
                /* Already this uid - no need to change. */
-               DEBUG(10,("change_file_owner_to_parent: file %s "
-                       "is already owned by uid %d\n",
+               DBG_DEBUG("file %s is already owned by uid %u\n",
                        fsp_str_dbg(fsp),
-                       (int)fsp->fsp_name->st.st_ex_uid ));
-               return;
+                       (unsigned int)fsp->fsp_name->st.st_ex_uid);
+                return;
        }
 
        become_root();
-       ret = SMB_VFS_FCHOWN(fsp, smb_fname_parent->st.st_ex_uid, (gid_t)-1);
+       ret = SMB_VFS_FCHOWN(fsp,
+                            parent_fsp->fsp_name->st.st_ex_uid,
+                            (gid_t)-1);
        unbecome_root();
        if (ret == -1) {
-               DEBUG(0,("change_file_owner_to_parent: failed to fchown "
-                        "file %s to parent directory uid %u. Error "
-                        "was %s\n", fsp_str_dbg(fsp),
-                        (unsigned int)smb_fname_parent->st.st_ex_uid,
-                        strerror(errno) ));
+               DBG_ERR("failed to fchown "
+                       "file %s to parent directory uid %u. Error "
+                       "was %s\n",
+                       fsp_str_dbg(fsp),
+                       (unsigned int)parent_fsp->fsp_name->st.st_ex_uid,
+                       strerror(errno));
        } else {
-               DEBUG(10,("change_file_owner_to_parent: changed new file %s to "
-                       "parent directory uid %u.\n", fsp_str_dbg(fsp),
-                       (unsigned int)smb_fname_parent->st.st_ex_uid));
+               DBG_DEBUG("changed new file %s to "
+                         "parent directory uid %u.\n",
+                         fsp_str_dbg(fsp),
+                         (unsigned int)parent_fsp->fsp_name->st.st_ex_uid);
                /* Ensure the uid entry is updated. */
-               fsp->fsp_name->st.st_ex_uid = smb_fname_parent->st.st_ex_uid;
+               fsp->fsp_name->st.st_ex_uid =
+                       parent_fsp->fsp_name->st.st_ex_uid;
        }
 }
 
@@ -1470,8 +1473,7 @@ static NTSTATUS open_file(files_struct *fsp,
 
                        /* Change the owner if required. */
                        if (lp_inherit_owner(SNUM(conn)) != INHERIT_OWNER_NO) {
-                               change_file_owner_to_parent(conn,
-                                                           parent_dir,
+                               change_file_owner_to_parent_fsp(parent_dir->fsp,
                                                            fsp);
                                need_re_stat = true;
                        }