]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3: cmd_vfs: cmd_open(). All calls to SMB_VFS_FSTAT(fsp, &fsp->fsp_name->st) clobber...
authorJeremy Allison <jra@samba.org>
Fri, 18 Mar 2022 22:01:52 +0000 (15:01 -0700)
committerJeremy Allison <jra@samba.org>
Thu, 24 Mar 2022 16:28:37 +0000 (16:28 +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>
source3/torture/cmd_vfs.c

index 303d80fc766cef8f0e29e4a0c47236cc4e0bf796..b1c8b128e0b778bc203e390e25f4596b5aa168de 100644 (file)
@@ -305,7 +305,6 @@ static NTSTATUS cmd_open(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc, c
        struct files_struct *fspcwd = NULL;
        struct smb_filename *smb_fname = NULL;
        NTSTATUS status;
-       int ret;
        int fd;
 
        mode = 00400;
@@ -422,15 +421,13 @@ static NTSTATUS cmd_open(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc, c
        }
        fsp_set_fd(fsp, fd);
 
-       status = NT_STATUS_OK;
-       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) ));
-               status = map_nt_error_from_unix(errno);
+                        nt_errstr(status) ));
        } else if (S_ISDIR(smb_fname->st.st_ex_mode)) {
                errno = EISDIR;
                status = NT_STATUS_FILE_IS_A_DIRECTORY;