]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
smbd: add and use vfs_fget_dos_attributes()
authorRalph Boehme <slow@samba.org>
Thu, 11 Aug 2022 15:18:13 +0000 (17:18 +0200)
committerStefan Metzmacher <metze@samba.org>
Mon, 22 Aug 2022 08:02:35 +0000 (08:02 +0000)
Commit d71ef1365cdde47aeb3465699181656b0655fa04 caused a regression where the
creation date on streams wasn't updated anymore on the stream fsp.

By adding a simple wrapper vfs_fget_dos_attributes() that takes care of

- passing only the base_fsp to the VFS, so the VFS can be completely agnostic of
  all the streams related complexity like fake fds,

- propagating any updated btime from the base_fsp->fsp_name to the
  stream_fsp->fsp_name

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15126
MR: https://gitlab.com/samba-team/samba/-/merge_requests/2643

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
selftest/knownfail.d/smb2.streams [deleted file]
source3/include/proto.h
source3/smbd/dosmode.c
source3/smbd/open.c
source3/smbd/vfs.c

diff --git a/selftest/knownfail.d/smb2.streams b/selftest/knownfail.d/smb2.streams
deleted file mode 100644 (file)
index 9dcebb0..0000000
+++ /dev/null
@@ -1 +0,0 @@
-^samba3.smb2.streams streams_xattr.attributes2
index 6a6edc36dfb0607fcc01b6c6df0f5cedabdf6a43..f632cf37c087e2e6dc5ba07bdbf67d695e8c0e41 100644 (file)
@@ -82,6 +82,9 @@ NTSTATUS vfs_at_fspcwd(TALLOC_CTX *mem_ctx,
                       struct connection_struct *conn,
                       struct files_struct **_fsp);
 
+NTSTATUS vfs_fget_dos_attributes(struct files_struct *fsp,
+                                uint32_t *dosmode);
+
 #include "source3/lib/interface.h"
 
 /* The following definitions come from lib/ldap_debug_handler.c  */
index 3d69a35b3660c0aa8d9bbaacdc0bf9d61ab6945a..3fe84824a9470db4acefc221b0bd92e53afb0526 100644 (file)
@@ -727,8 +727,7 @@ uint32_t fdos_mode(struct files_struct *fsp)
        }
 
        /* Get the DOS attributes via the VFS if we can */
-       status = SMB_VFS_FGET_DOS_ATTRIBUTES(
-               fsp->conn, metadata_fsp(fsp), &result);
+       status = vfs_fget_dos_attributes(fsp, &result);
        if (!NT_STATUS_IS_OK(status)) {
                /*
                 * Only fall back to using UNIX modes if we get NOT_IMPLEMENTED.
index d5c2f4c830f1459a7a327162bb729eaae458d4dd..3dd9f69b8ccdbacce94e15d7539559952dc1fbfa 100644 (file)
@@ -3651,8 +3651,7 @@ static NTSTATUS open_file_ntcreate(connection_struct *conn,
                         */
                        uint32_t attr = 0;
 
-                       status = SMB_VFS_FGET_DOS_ATTRIBUTES(
-                               conn, metadata_fsp(smb_fname->fsp), &attr);
+                       status = vfs_fget_dos_attributes(smb_fname->fsp, &attr);
                        if (NT_STATUS_IS_OK(status)) {
                                existing_dos_attributes = attr;
                        }
index 09be625ab5f3141e8e6c34719c6000db03a03e62..5833d1b2ab284d948e9e06be3fe43faff0fbbf5d 100644 (file)
@@ -1509,6 +1509,45 @@ NTSTATUS vfs_at_fspcwd(TALLOC_CTX *mem_ctx,
        return NT_STATUS_OK;
 }
 
+NTSTATUS vfs_fget_dos_attributes(struct files_struct *fsp,
+                                uint32_t *dosmode)
+{
+       NTSTATUS status;
+
+       /*
+        * First make sure to pass the base_fsp to the VFS
+        */
+       status = SMB_VFS_FGET_DOS_ATTRIBUTES(
+               fsp->conn, metadata_fsp(fsp), dosmode);
+       if (!NT_STATUS_IS_OK(status)) {
+               return status;
+       }
+
+       /*
+        * If this isn't a stream fsp we're done, ...
+        */
+       if (!fsp_is_alternate_stream(fsp)) {
+               return NT_STATUS_OK;
+       }
+
+       /*
+        * ...otherwise the VFS might have updated the btime, propagate the
+        * btime from the base_fsp to the stream fsp.
+        */
+
+       if (fsp->base_fsp->fsp_name->st.st_ex_iflags & ST_EX_IFLAG_CALCULATED_BTIME) {
+               /*
+                * Not a value from backend storage, ignore it
+                */
+               return NT_STATUS_OK;
+       }
+
+       update_stat_ex_create_time(&fsp->fsp_name->st,
+                                  fsp->base_fsp->fsp_name->st.st_ex_btime);
+
+       return NT_STATUS_OK;
+}
+
 int smb_vfs_call_connect(struct vfs_handle_struct *handle,
                         const char *service, const char *user)
 {