]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3/smb3: ensure file_set_dosmode is passed valid smb_fname->fsp
authorNoel Power <noel.power@suse.com>
Thu, 18 Feb 2021 11:05:34 +0000 (11:05 +0000)
committerJeremy Allison <jra@samba.org>
Thu, 11 Mar 2021 17:50:30 +0000 (17:50 +0000)
Signed-off-by: Noel Power <noel.power@suse.com>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/smbd/nttrans.c

index ab933bcc520183eb4896f2b854b987b83201dbd0..86426c360424c7cc3b333d9a818379050ce35bd6 100644 (file)
@@ -1555,6 +1555,7 @@ static NTSTATUS copy_internals(TALLOC_CTX *ctx,
        off_t ret=-1;
        NTSTATUS status = NT_STATUS_OK;
        struct smb_filename *parent = NULL;
+       struct smb_filename *pathref = NULL;
        bool ok;
 
        if (!CAN_WRITE(conn)) {
@@ -1671,7 +1672,26 @@ static NTSTATUS copy_internals(TALLOC_CTX *ctx,
                status = NT_STATUS_NO_MEMORY;
                goto out;
        }
-       file_set_dosmode(conn, smb_fname_dst, fattr, parent, false);
+       if (smb_fname_dst->fsp == NULL) {
+               status = synthetic_pathref(parent,
+                                       conn->cwd_fsp,
+                                       smb_fname_dst->base_name,
+                                       smb_fname_dst->stream_name,
+                                       NULL,
+                                       smb_fname_dst->twrp,
+                                       smb_fname_dst->flags,
+                                       &pathref);
+
+               /* should we handle NT_STATUS_OBJECT_NAME_NOT_FOUND specially here ???? */
+               if (!NT_STATUS_IS_OK(status)) {
+                       TALLOC_FREE(parent);
+                       goto out;
+               }
+               file_set_dosmode(conn, pathref, fattr, parent, false);
+               smb_fname_dst->st.st_ex_mode = pathref->st.st_ex_mode;
+       } else {
+               file_set_dosmode(conn, smb_fname_dst, fattr, parent, false);
+       }
        TALLOC_FREE(parent);
 
        if (ret < (off_t)smb_fname_src->st.st_ex_size) {