s3/smbd: set_create_timespec_ea should create smb_fname with valid fsp
authorNoel Power <noel.power@suse.com>
Thu, 18 Feb 2021 10:54:23 +0000 (10:54 +0000)
committerJeremy Allison <jra@samba.org>
Thu, 11 Mar 2021 17:50:30 +0000 (17:50 +0000)
we need to call file_set_dosmode (which ends up calling
SMB_VFS_FSETXATTR via set_ea_dos_attribute) has smb_fname set up
with a valid smb_fname->fsp

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

index ea225a9b1ef6b8a8f4e754ad12bb7b5930a62553..d994b59038161c21828f6d50ac2acc3e27b39727 100644 (file)
@@ -1284,20 +1284,23 @@ NTSTATUS set_create_timespec_ea(connection_struct *conn,
        struct smb_filename *smb_fname;
        uint32_t dosmode;
        int ret;
+       NTSTATUS status;
 
        if (!lp_store_dos_attributes(SNUM(conn))) {
                return NT_STATUS_OK;
        }
 
-       smb_fname = synthetic_smb_fname(talloc_tos(),
+       status = synthetic_pathref(talloc_tos(),
+                                       conn->cwd_fsp,
                                        psmb_fname->base_name,
                                        NULL,
-                                       &psmb_fname->st,
+                                       NULL,
                                        psmb_fname->twrp,
-                                       psmb_fname->flags);
+                                       psmb_fname->flags,
+                                       &smb_fname);
 
-       if (smb_fname == NULL) {
-               return NT_STATUS_NO_MEMORY;
+       if (!NT_STATUS_IS_OK(status)) {
+               return status;
        }
 
        dosmode = fdos_mode(psmb_fname->fsp);
@@ -1306,12 +1309,14 @@ NTSTATUS set_create_timespec_ea(connection_struct *conn,
 
        ret = file_set_dosmode(conn, smb_fname, dosmode, NULL, false);
        if (ret == -1) {
+               TALLOC_FREE(smb_fname);
                return map_nt_error_from_unix(errno);
        }
 
        DEBUG(10,("set_create_timespec_ea: wrote create time EA for file %s\n",
                smb_fname_str_dbg(smb_fname)));
 
+       TALLOC_FREE(smb_fname);
        return NT_STATUS_OK;
 }