The branch, master has been updated via 0633d8837ce vfs_glusterfs: Fix fdopendir implementation via 767ede0064c vfs_glusterfs: Fix get_real_filename_at implementation from d3c678233c4 s3:smbd: Covscan: remove dead code
https://git.samba.org/?p=samba.git;a=shortlog;h=master - Log ----------------------------------------------------------------- commit 0633d8837ce4ddcf7f46c5f320e8d0b3142177fa Author: Anoop C S <anoo...@samba.org> Date: Fri May 13 16:46:01 2022 +0530 vfs_glusterfs: Fix fdopendir implementation Directory stream returned for fdopendir() within vfs_glusterfs doesn't correctly point to required directory fd. Since GlusterFS still don't support *at() variant syscalls we will have to rely on full path/name constructed out of fsp. Signed-off-by: Anoop C S <anoo...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> Autobuild-User(master): Jeremy Allison <j...@samba.org> Autobuild-Date(master): Tue May 17 20:20:05 UTC 2022 on sn-devel-184 commit 767ede0064ce9a9d0576a337b2059f4ba3a6adeb Author: Anoop C S <anoo...@samba.org> Date: Mon May 2 15:15:53 2022 +0530 vfs_glusterfs: Fix get_real_filename_at implementation glfd(gluster fd) used in glfs_fgetxattr() for get_real_filename_at() implementation doesn't correctly point to required directory fd. Since GlusterFS still don't support *at() variant syscalls we will have to rely on full path/name constructed out of dirfsp. Signed-off-by: Anoop C S <anoo...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> ----------------------------------------------------------------------- Summary of changes: source3/modules/vfs_glusterfs.c | 72 ++++++++++++++++++++++++++++++++++++----- 1 file changed, 64 insertions(+), 8 deletions(-) Changeset truncated at 500 lines: diff --git a/source3/modules/vfs_glusterfs.c b/source3/modules/vfs_glusterfs.c index f526d413373..c06829a1799 100644 --- a/source3/modules/vfs_glusterfs.c +++ b/source3/modules/vfs_glusterfs.c @@ -625,12 +625,39 @@ static DIR *vfs_gluster_fdopendir(struct vfs_handle_struct *handle, files_struct *fsp, const char *mask, uint32_t attributes) { - glfs_fd_t *glfd = vfs_gluster_fetch_glfd(handle, fsp); + glfs_fd_t *glfd = NULL; + struct smb_filename *full_fname = NULL; + struct smb_filename *smb_fname_dot = NULL; + + smb_fname_dot = synthetic_smb_fname(fsp->fsp_name, + ".", + NULL, + NULL, + 0, + 0); + + if (smb_fname_dot == NULL) { + return NULL; + } + + full_fname = full_path_from_dirfsp_atname(talloc_tos(), + fsp, + smb_fname_dot); + if (full_fname == NULL) { + TALLOC_FREE(smb_fname_dot); + return NULL; + } + + glfd = glfs_opendir(handle->data, full_fname->base_name); if (glfd == NULL) { - DBG_ERR("Failed to fetch gluster fd\n"); + TALLOC_FREE(full_fname); + TALLOC_FREE(smb_fname_dot); return NULL; } + TALLOC_FREE(full_fname); + TALLOC_FREE(smb_fname_dot); + return (DIR *)glfd; } @@ -2006,31 +2033,60 @@ static NTSTATUS vfs_gluster_get_real_filename_at( TALLOC_CTX *mem_ctx, char **found_name) { - glfs_fd_t *glfd = vfs_gluster_fetch_glfd(handle, dirfsp); int ret; char key_buf[GLUSTER_NAME_MAX + 64]; char val_buf[GLUSTER_NAME_MAX + 1]; + NTSTATUS status = NT_STATUS_OK; + struct smb_filename *smb_fname_dot = NULL; + struct smb_filename *full_fname = NULL; + + smb_fname_dot = synthetic_smb_fname(mem_ctx, + ".", + NULL, + NULL, + 0, + 0); + if (smb_fname_dot == NULL) { + return NT_STATUS_NO_MEMORY; + } + + full_fname = full_path_from_dirfsp_atname(talloc_tos(), + dirfsp, + smb_fname_dot); + if (full_fname == NULL) { + TALLOC_FREE(smb_fname_dot); + return NT_STATUS_NO_MEMORY; + } if (strlen(name) >= GLUSTER_NAME_MAX) { - return NT_STATUS_OBJECT_NAME_INVALID; + status = NT_STATUS_OBJECT_NAME_INVALID; + goto out; } snprintf(key_buf, GLUSTER_NAME_MAX + 64, "glusterfs.get_real_filename:%s", name); - ret = glfs_fgetxattr(glfd, key_buf, val_buf, GLUSTER_NAME_MAX + 1); + ret = glfs_getxattr(handle->data, full_fname->base_name, + key_buf, val_buf, GLUSTER_NAME_MAX + 1); if (ret == -1) { if (errno == ENOATTR) { errno = ENOENT; } - return map_nt_error_from_unix(errno); + status = map_nt_error_from_unix(errno); + goto out; } *found_name = talloc_strdup(mem_ctx, val_buf); if (found_name[0] == NULL) { - return NT_STATUS_NO_MEMORY; + status = NT_STATUS_NO_MEMORY; + goto out; } - return NT_STATUS_OK; + +out: + TALLOC_FREE(smb_fname_dot); + TALLOC_FREE(full_fname); + + return status; } static const char *vfs_gluster_connectpath(struct vfs_handle_struct *handle, -- Samba Shared Repository