[SCM] Samba Shared Repository - branch master updated

Jeremy Allison jra at samba.org
Fri Apr 1 21:19:01 UTC 2022


The branch, master has been updated
       via  edc4c910f27 vfs: Simplify streams_depot_openat()
       via  57bcbbcacde smbd: Don't loose base_fsp statinfo in non_widelink_open
       via  b15c2497577 vfs: streams_xattr uses fsetxattr by now, remove an assert
       via  702af7f85f1 vfs: Ensure we have a base fsp openat() for named streams
       via  fbce308dd4b torture: Create a base_fsp for a named stream in vfstest
       via  b3ab69a4350 torture: Introduce error labels for vfstest's cmd_open()
      from  ac7d0b45fc7 Move LSP stuff to buildtools/devel_env.sh

https://git.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit edc4c910f27ea4920734dc2a62e4f57862024ed7
Author: Volker Lendecke <vl at samba.org>
Date:   Thu Mar 31 18:12:32 2022 +0200

    vfs: Simplify streams_depot_openat()
    
    We don't need an explicit stat(), VALID_STAT on the existing base_fsp
    is sufficient.
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    
    Autobuild-User(master): Jeremy Allison <jra at samba.org>
    Autobuild-Date(master): Fri Apr  1 21:18:37 UTC 2022 on sn-devel-184

commit 57bcbbcacde6d35e056b3a6fc4b7035b17919fe2
Author: Volker Lendecke <vl at samba.org>
Date:   Thu Mar 31 21:21:30 2022 +0200

    smbd: Don't loose base_fsp statinfo in non_widelink_open
    
    smb_fname_rel came from SMB_VFS_PARENT_PATHNAME() without a reference
    to the underlying base_fsp. We want to pass the existing stat-info to
    the VFS objects, so when creating the relative base fsp_name we should
    copy the stat-info from the base fsp we were handed, not the fake one
    that we just made up in SMB_VFS_PARENT_PATHNAME()
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit b15c24975770298479cb3782f2618cdb361fdf12
Author: Volker Lendecke <vl at samba.org>
Date:   Thu Mar 31 17:49:06 2022 +0200

    vfs: streams_xattr uses fsetxattr by now, remove an assert
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 702af7f85f1c37117064e57135528ee56711844a
Author: Volker Lendecke <vl at samba.org>
Date:   Thu Mar 31 17:40:35 2022 +0200

    vfs: Ensure we have a base fsp openat() for named streams
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit fbce308dd4b59c2669fd85352b6584e5bea9b771
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Feb 22 13:15:02 2022 +0100

    torture: Create a base_fsp for a named stream in vfstest
    
    This will enable a simplification in the stream-handling openat vfs
    routines.
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit b3ab69a435020c15f6f6bbfdb7f2887eafe201bf
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Feb 22 12:38:27 2022 +0100

    torture: Introduce error labels for vfstest's cmd_open()
    
    Next patch will have another error exit
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

-----------------------------------------------------------------------

Summary of changes:
 source3/modules/vfs_fruit.c         |  2 ++
 source3/modules/vfs_streams_depot.c | 26 ++---------------------
 source3/modules/vfs_streams_xattr.c |  5 +----
 source3/smbd/open.c                 |  2 +-
 source3/torture/cmd_vfs.c           | 42 ++++++++++++++++++++++++++-----------
 5 files changed, 36 insertions(+), 41 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/modules/vfs_fruit.c b/source3/modules/vfs_fruit.c
index 3c19aad8b0a..995c869d10f 100644
--- a/source3/modules/vfs_fruit.c
+++ b/source3/modules/vfs_fruit.c
@@ -1754,6 +1754,8 @@ static int fruit_openat(vfs_handle_struct *handle,
 					   mode);
 	}
 
+	SMB_ASSERT(fsp_is_alternate_stream(fsp));
+
 	if (is_afpinfo_stream(smb_fname->stream_name)) {
 		fd = fruit_open_meta(handle,
 				     dirfsp,
diff --git a/source3/modules/vfs_streams_depot.c b/source3/modules/vfs_streams_depot.c
index 3016cfcf19c..cc2d25a36f6 100644
--- a/source3/modules/vfs_streams_depot.c
+++ b/source3/modules/vfs_streams_depot.c
@@ -710,7 +710,6 @@ static int streams_depot_openat(struct vfs_handle_struct *handle,
 				mode_t mode)
 {
 	struct smb_filename *smb_fname_stream = NULL;
-	struct smb_filename *smb_fname_base = NULL;
 	struct files_struct *fspcwd = NULL;
 	NTSTATUS status;
 	int ret = -1;
@@ -724,28 +723,8 @@ static int streams_depot_openat(struct vfs_handle_struct *handle,
 					   mode);
 	}
 
-	/*
-	 * For now assert this so the below SMB_VFS_STAT() is ok.
-	 */
-	SMB_ASSERT(fsp_get_pathref_fd(dirfsp) == AT_FDCWD);
-
-	/* Ensure the base file still exists. */
-	smb_fname_base = synthetic_smb_fname(talloc_tos(),
-					smb_fname->base_name,
-					NULL,
-					NULL,
-					smb_fname->twrp,
-					smb_fname->flags);
-	if (smb_fname_base == NULL) {
-		ret = -1;
-		errno = ENOMEM;
-		goto done;
-	}
-
-	ret = SMB_VFS_NEXT_STAT(handle, smb_fname_base);
-	if (ret == -1) {
-		goto done;
-	}
+	SMB_ASSERT(fsp_is_alternate_stream(fsp));
+	SMB_ASSERT(VALID_STAT(fsp->base_fsp->fsp_name->st));
 
 	/* Determine the stream name, and then open it. */
 	status = stream_smb_fname(handle, smb_fname, &smb_fname_stream, true);
@@ -771,7 +750,6 @@ static int streams_depot_openat(struct vfs_handle_struct *handle,
 
  done:
 	TALLOC_FREE(smb_fname_stream);
-	TALLOC_FREE(smb_fname_base);
 	TALLOC_FREE(fspcwd);
 	return ret;
 }
diff --git a/source3/modules/vfs_streams_xattr.c b/source3/modules/vfs_streams_xattr.c
index 48fc1cd134b..324490354b0 100644
--- a/source3/modules/vfs_streams_xattr.c
+++ b/source3/modules/vfs_streams_xattr.c
@@ -343,10 +343,7 @@ static int streams_xattr_openat(struct vfs_handle_struct *handle,
 					   mode);
 	}
 
-	/*
-	 * For now assert this, so the below SMB_VFS_SETXATTR() works.
-	 */
-	SMB_ASSERT(fsp_get_pathref_fd(dirfsp) == AT_FDCWD);
+	SMB_ASSERT(fsp_is_alternate_stream(fsp));
 
 	status = streams_xattr_get_name(handle, talloc_tos(),
 					smb_fname->stream_name, &xattr_name);
diff --git a/source3/smbd/open.c b/source3/smbd/open.c
index 35f57221171..1644d867566 100644
--- a/source3/smbd/open.c
+++ b/source3/smbd/open.c
@@ -745,7 +745,7 @@ static NTSTATUS non_widelink_open(const struct files_struct *dirfsp,
 						talloc_tos(),
 						smb_fname_rel->base_name,
 						NULL,
-						&smb_fname_rel->st,
+						&fsp->base_fsp->fsp_name->st,
 						smb_fname_rel->twrp,
 						smb_fname_rel->flags);
 			if (base_smb_fname_rel == NULL) {
diff --git a/source3/torture/cmd_vfs.c b/source3/torture/cmd_vfs.c
index 470f039c4a3..7a23f7bf5a2 100644
--- a/source3/torture/cmd_vfs.c
+++ b/source3/torture/cmd_vfs.c
@@ -383,12 +383,11 @@ static NTSTATUS cmd_open(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc, c
 
 	fsp = talloc_zero(vfs, struct files_struct);
 	if (fsp == NULL) {
-		return NT_STATUS_NO_MEMORY;
+		goto nomem;
 	}
 	fsp->fh = fd_handle_create(fsp);
 	if (fsp->fh == NULL) {
-		TALLOC_FREE(fsp);
-		return NT_STATUS_NO_MEMORY;
+		goto nomem;
 	}
 	fsp->conn = vfs->conn;
 
@@ -396,15 +395,30 @@ static NTSTATUS cmd_open(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc, c
 					argv[1],
 					lp_posix_pathnames());
 	if (smb_fname == NULL) {
-		TALLOC_FREE(fsp);
-		return NT_STATUS_NO_MEMORY;
+		goto nomem;
 	}
 
 	fsp->fsp_name = smb_fname;
 
 	status = vfs_at_fspcwd(fsp, vfs->conn, &fspcwd);
 	if (!NT_STATUS_IS_OK(status)) {
-		return status;
+		goto fail;
+	}
+
+	if (is_named_stream(smb_fname)) {
+		struct smb_filename *base_name = NULL;
+
+		base_name = cp_smb_filename_nostream(NULL, smb_fname);
+		if (base_name == NULL) {
+			goto nomem;
+		}
+
+		status = openat_pathref_fsp(fspcwd, base_name);
+		if (!NT_STATUS_IS_OK(status)) {
+			goto fail;
+		}
+
+		fsp->base_fsp = base_name->fsp;
 	}
 
 	fd = SMB_VFS_OPENAT(vfs->conn,
@@ -415,9 +429,8 @@ static NTSTATUS cmd_open(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc, c
 			    mode);
 	if (fd == -1) {
 		printf("open: error=%d (%s)\n", errno, strerror(errno));
-		TALLOC_FREE(fsp);
-		TALLOC_FREE(smb_fname);
-		return NT_STATUS_UNSUCCESSFUL;
+		status = map_nt_error_from_unix(errno);
+		goto fail;
 	}
 	fsp_set_fd(fsp, fd);
 
@@ -435,9 +448,7 @@ static NTSTATUS cmd_open(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc, c
 
 	if (!NT_STATUS_IS_OK(status)) {
 		fd_close(fsp);
-		TALLOC_FREE(fsp);
-		TALLOC_FREE(smb_fname);
-		return status;
+		goto fail;
 	}
 
 	fsp->file_id = vfs_file_id_from_sbuf(vfs->conn, &smb_fname->st);
@@ -454,6 +465,13 @@ static NTSTATUS cmd_open(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc, c
 	vfs->files[fsp_get_pathref_fd(fsp)] = fsp;
 	printf("open: fd=%d\n", fsp_get_pathref_fd(fsp));
 	return NT_STATUS_OK;
+
+nomem:
+	status = NT_STATUS_NO_MEMORY;
+fail:
+	TALLOC_FREE(smb_fname);
+	TALLOC_FREE(fsp);
+	return status;
 }
 
 


-- 
Samba Shared Repository



More information about the samba-cvs mailing list