[SCM] Samba Shared Repository - branch master updated

Ralph Böhme slow at samba.org
Mon Jan 11 21:35:01 UTC 2021


The branch, master has been updated
       via  b31405e31bc vfs_glusterfs: support read dirfsps in vfs_gluster_openat()
       via  9a3cdb68fc7 smbd: pass O_DIRECTORY to fd_openat() for directories
       via  847465b3900 smbd: move S_ISDIR check up a bit in openat_pathref_fsp()
      from  08da3439edd librpc: Use GUID_buf_string in dcerpc_binding_string()

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


- Log -----------------------------------------------------------------
commit b31405e31bc29c3ff3f4232c20363ad5a52c80dc
Author: Ralph Boehme <slow at samba.org>
Date:   Mon Jan 11 10:53:31 2021 +0100

    vfs_glusterfs: support read dirfsps in vfs_gluster_openat()
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Anoop C S <anoopcs at samba.org>
    
    Autobuild-User(master): Ralph Böhme <slow at samba.org>
    Autobuild-Date(master): Mon Jan 11 21:34:52 UTC 2021 on sn-devel-184

commit 9a3cdb68fc7376634940bdaf3e3ab80c60700979
Author: Ralph Boehme <slow at samba.org>
Date:   Mon Jan 11 09:58:58 2021 +0100

    smbd: pass O_DIRECTORY to fd_openat() for directories
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Anoop C S <anoopcs at samba.org>

commit 847465b3900ca78046ceaf08d89fdd4535e7193a
Author: Ralph Boehme <slow at samba.org>
Date:   Mon Jan 11 09:57:26 2021 +0100

    smbd: move S_ISDIR check up a bit in openat_pathref_fsp()
    
    This relies on the caller having stat()ed smb_fname instead of relying on
    fd_openat() fstat()ing fsp->fsp_name. Otherwise no change in behaviour.
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Anoop C S <anoopcs at samba.org>

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

Summary of changes:
 source3/modules/vfs_glusterfs.c | 14 +++++++++++++-
 source3/smbd/files.c            | 10 ++++++----
 2 files changed, 19 insertions(+), 5 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/modules/vfs_glusterfs.c b/source3/modules/vfs_glusterfs.c
index 45516441ba8..ddead1f269c 100644
--- a/source3/modules/vfs_glusterfs.c
+++ b/source3/modules/vfs_glusterfs.c
@@ -742,6 +742,7 @@ static int vfs_gluster_openat(struct vfs_handle_struct *handle,
 			      int flags,
 			      mode_t mode)
 {
+	struct smb_filename *name = NULL;
 	bool became_root = false;
 	glfs_fd_t *glfd;
 	glfs_fd_t **p_tmp;
@@ -751,10 +752,19 @@ static int vfs_gluster_openat(struct vfs_handle_struct *handle,
 	/*
 	 * Looks like glfs API doesn't have openat().
 	 */
-	SMB_ASSERT(fsp_get_pathref_fd(dirfsp) == AT_FDCWD);
+	if (fsp_get_pathref_fd(dirfsp) != AT_FDCWD) {
+		name = full_path_from_dirfsp_atname(talloc_tos(),
+						    dirfsp,
+						    smb_fname);
+		if (name == NULL) {
+			return -1;
+		}
+		smb_fname = name;
+	}
 
 	p_tmp = VFS_ADD_FSP_EXTENSION(handle, fsp, glfs_fd_t *, NULL);
 	if (p_tmp == NULL) {
+		TALLOC_FREE(name);
 		END_PROFILE(syscall_openat);
 		errno = ENOMEM;
 		return -1;
@@ -785,6 +795,7 @@ static int vfs_gluster_openat(struct vfs_handle_struct *handle,
 	fsp->fsp_flags.have_proc_fds = false;
 
 	if (glfd == NULL) {
+		TALLOC_FREE(name);
 		END_PROFILE(syscall_openat);
 		/* no extension destroy_fn, so no need to save errno */
 		VFS_REMOVE_FSP_EXTENSION(handle, fsp);
@@ -793,6 +804,7 @@ static int vfs_gluster_openat(struct vfs_handle_struct *handle,
 
 	*p_tmp = glfd;
 
+	TALLOC_FREE(name);
 	END_PROFILE(syscall_openat);
 	/* An arbitrary value for error reporting, so you know its us. */
 	return 13371337;
diff --git a/source3/smbd/files.c b/source3/smbd/files.c
index 57fd67ab426..e19c11883eb 100644
--- a/source3/smbd/files.c
+++ b/source3/smbd/files.c
@@ -410,6 +410,7 @@ NTSTATUS openat_pathref_fsp(const struct files_struct *dirfsp,
 	struct smb_filename *full_fname = NULL;
 	bool file_existed = VALID_STAT(smb_fname->st);
 	struct files_struct *fsp = NULL;
+	int open_flags = O_RDONLY;
 	NTSTATUS status;
 
 	DBG_DEBUG("smb_fname [%s]\n", smb_fname_str_dbg(smb_fname));
@@ -435,6 +436,10 @@ NTSTATUS openat_pathref_fsp(const struct files_struct *dirfsp,
 	ZERO_STRUCT(conn->sconn->fsp_fi_cache);
 
 	fsp->fsp_flags.is_pathref = true;
+	if (S_ISDIR(smb_fname->st.st_ex_mode)) {
+		fsp->fsp_flags.is_directory = true;
+		open_flags |= O_DIRECTORY;
+	}
 
 	full_fname = full_path_from_dirfsp_atname(talloc_tos(),
 						  dirfsp,
@@ -466,7 +471,7 @@ NTSTATUS openat_pathref_fsp(const struct files_struct *dirfsp,
 		}
 	}
 
-	status = fd_openat(dirfsp, smb_fname, fsp, O_RDONLY, 0);
+	status = fd_openat(dirfsp, smb_fname, fsp, open_flags, 0);
 	if (!NT_STATUS_IS_OK(status)) {
 		DBG_DEBUG("Could not open fd for [%s]: %s\n",
 			  fsp_str_dbg(fsp),
@@ -519,9 +524,6 @@ NTSTATUS openat_pathref_fsp(const struct files_struct *dirfsp,
 	}
 
 	fsp->file_id = vfs_file_id_from_sbuf(conn, &fsp->fsp_name->st);
-	if (S_ISDIR(fsp->fsp_name->st.st_ex_mode)) {
-		fsp->fsp_flags.is_directory = true;
-	}
 
 	fsp->fsp_name->fsp = fsp;
 	smb_fname->fsp = fsp;


-- 
Samba Shared Repository



More information about the samba-cvs mailing list