]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3: smbd: Remove use of synthetic_pathref() in rename_internals_fsp().
authorJeremy Allison <jra@samba.org>
Fri, 21 May 2021 17:27:09 +0000 (10:27 -0700)
committerNoel Power <npower@samba.org>
Mon, 24 May 2021 16:57:37 +0000 (16:57 +0000)
As we're renaming an open file we don't need to do another
open, we already have an fsp here.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Noel Power <noel.power@suse.com>
source3/smbd/reply.c

index 4ba3b0ee624b632a495552c71e7f61fa98985872..27e9b5f904f77a07656742b4d42de5700d9e5914 100644 (file)
@@ -7829,33 +7829,25 @@ NTSTATUS rename_internals_fsp(connection_struct *conn,
                    (lp_map_archive(SNUM(conn)) ||
                    lp_store_dos_attributes(SNUM(conn))))
                {
-                       struct smb_filename *pathref = NULL;
-                       status = synthetic_pathref(ctx,
-                                               conn->cwd_fsp,
-                                               smb_fname_dst->base_name,
-                                               smb_fname_dst->stream_name,
-                                               NULL,
-                                               smb_fname_dst->twrp,
-                                               smb_fname_dst->flags,
-                                               &pathref);
-                       if (NT_STATUS_IS_OK(status)) {
+                       /*
+                        * We must set the archive bit on the newly renamed
+                        * file.
+                        */
+                       ret = SMB_VFS_FSTAT(fsp, &fsp->fsp_name->st);
+                       if (ret == 0) {
+                               uint32_t old_dosmode;
+                               old_dosmode = fdos_mode(fsp);
                                /*
-                                * We must set the archive bit on the newly renamed
-                                * file.
+                                * We can use fsp->fsp_name here as it has
+                                * already been changed to the new name.
                                 */
-                               ret = SMB_VFS_FSTAT(fsp, &pathref->st);
-                               if (ret == 0) {
-                                       uint32_t old_dosmode;
-                                       fsp->fsp_name->st = pathref->st;
-                                       old_dosmode = fdos_mode(fsp);
-                                       file_set_dosmode(conn,
-                                                       pathref,
-                                                       old_dosmode | FILE_ATTRIBUTE_ARCHIVE,
-                                                       NULL,
-                                                       true);
-                               }
+                               SMB_ASSERT(fsp->fsp_name->fsp == fsp);
+                               file_set_dosmode(conn,
+                                               fsp->fsp_name,
+                                               old_dosmode | FILE_ATTRIBUTE_ARCHIVE,
+                                               NULL,
+                                               true);
                        }
-                       TALLOC_FREE(pathref);
                }
 
                /*