s3: pysmbd.c: init_files_struct(). All calls to SMB_VFS_FSTAT(fsp, &fsp->fsp_name...
authorJeremy Allison <jra@samba.org>
Fri, 18 Mar 2022 21:57:13 +0000 (14:57 -0700)
committerJule Anger <janger@samba.org>
Mon, 11 Apr 2022 07:49:13 +0000 (07:49 +0000)
If doing an SMB_VFS_FSTAT() returning onto the stat struct stored in the fsp,
we must call vfs_stat_fsp() as this preserves the iflags.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15022

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
(cherry picked from commit c4193f11d1871051d4cce4521b1f444a083c9189)

source3/smbd/pysmbd.c

index 17a27e8cb35959361f20e08950b7bef432a67b0b..92c4037b49316301fd7e06e91693dcfc21d94570 100644 (file)
@@ -176,7 +176,6 @@ static NTSTATUS init_files_struct(TALLOC_CTX *mem_ctx,
 {
        struct smb_filename *smb_fname = NULL;
        int fd;
-       int ret;
        mode_t saved_umask;
        struct files_struct *fsp;
        struct files_struct *fspcwd = NULL;
@@ -230,13 +229,13 @@ static NTSTATUS init_files_struct(TALLOC_CTX *mem_ctx,
        }
        fsp_set_fd(fsp, fd);
 
-       ret = SMB_VFS_FSTAT(fsp, &smb_fname->st);
-       if (ret == -1) {
+       status = vfs_stat_fsp(fsp);
+       if (!NT_STATUS_IS_OK(status)) {
                /* If we have an fd, this stat should succeed. */
                DEBUG(0,("Error doing fstat on open file %s (%s)\n",
                         smb_fname_str_dbg(smb_fname),
-                        strerror(errno) ));
-               return map_nt_error_from_unix(errno);
+                        nt_errstr(status) ));
+               return status;
        }
 
        fsp->file_id = vfs_file_id_from_sbuf(conn, &smb_fname->st);