]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3/modules: stream_dir make sure mark_file_valid is called with fsp
authorNoel Power <noel.power@suse.com>
Thu, 18 Feb 2021 21:13:07 +0000 (21:13 +0000)
committerJeremy Allison <jra@samba.org>
Thu, 11 Mar 2021 17:50:30 +0000 (17:50 +0000)
can we get this further up the call path ???

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

index bfaab2bf9d4b1e4bb431a5544d05d37c911c40a7..410b6c9e0db090d4ef5dca9fb5ff582e078fd99c 100644 (file)
@@ -96,7 +96,7 @@ static bool mark_file_valid(vfs_handle_struct *handle,
 
        DEBUG(10, ("marking file %s as valid\n", smb_fname->base_name));
 
-       ret = SMB_VFS_SETXATTR(handle->conn, smb_fname, SAMBA_XATTR_MARKER,
+       ret = SMB_VFS_FSETXATTR(smb_fname->fsp, SAMBA_XATTR_MARKER,
                                    &buf, sizeof(buf), 0);
 
        if (ret == -1) {
@@ -130,6 +130,8 @@ static char *stream_dir(vfs_handle_struct *handle,
        char *rootdir = NULL;
        struct smb_filename *rootdir_fname = NULL;
        struct smb_filename *tmp_fname = NULL;
+       struct smb_filename *tmpref = NULL;
+       const struct smb_filename *pathref = NULL;
        int ret;
 
        check_valid = lp_parm_bool(SNUM(handle->conn),
@@ -378,11 +380,27 @@ static char *stream_dir(vfs_handle_struct *handle,
        if ((ret != 0) && (errno != EEXIST)) {
                goto fail;
        }
-
-       if (check_valid && !mark_file_valid(handle, smb_fname)) {
+       pathref = smb_fname;
+       if (smb_fname->fsp == NULL) {
+               NTSTATUS status;
+               status = synthetic_pathref(talloc_tos(),
+                                       handle->conn->cwd_fsp,
+                                       smb_fname->base_name,
+                                       NULL,
+                                       NULL,
+                                       smb_fname->twrp,
+                                       smb_fname->flags,
+                                       &tmpref);
+               if (!NT_STATUS_IS_OK(status)) {
+                       goto fail;
+               }
+               pathref = tmpref;
+       }
+       if (check_valid && !mark_file_valid(handle, pathref)) {
                goto fail;
        }
 
+       TALLOC_FREE(tmpref);
        TALLOC_FREE(rootdir_fname);
        TALLOC_FREE(rootdir);
        TALLOC_FREE(tmp_fname);
@@ -390,6 +408,7 @@ static char *stream_dir(vfs_handle_struct *handle,
        return result;
 
  fail:
+       TALLOC_FREE(tmpref);
        TALLOC_FREE(rootdir_fname);
        TALLOC_FREE(rootdir);
        TALLOC_FREE(tmp_fname);