From: Jeremy Allison Date: Mon, 12 Jul 2021 23:58:05 +0000 (-0700) Subject: s3: VFS: ceph: In cephwrap_read_dfs_pathat(), cope with relative pathnames. X-Git-Tag: talloc-2.3.3~64 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=43970634cff9d60ae670710951f32f27c697efc7;p=thirdparty%2Fsamba.git s3: VFS: ceph: In cephwrap_read_dfs_pathat(), cope with relative pathnames. Signed-off-by: Jeremy Allison Reviewed-by: Ralph Boehme --- diff --git a/source3/modules/vfs_ceph.c b/source3/modules/vfs_ceph.c index f3efd28107c..594ebce4b9a 100644 --- a/source3/modules/vfs_ceph.c +++ b/source3/modules/vfs_ceph.c @@ -1466,10 +1466,9 @@ static NTSTATUS cephwrap_read_dfs_pathat(struct vfs_handle_struct *handle, char link_target_buf[7]; #endif struct ceph_statx stx; + struct smb_filename *full_fname = NULL; int ret; - SMB_ASSERT(dirfsp == dirfsp->conn->cwd_fsp); - if (is_named_stream(smb_fname)) { status = NT_STATUS_OBJECT_NAME_NOT_FOUND; goto err; @@ -1490,8 +1489,16 @@ static NTSTATUS cephwrap_read_dfs_pathat(struct vfs_handle_struct *handle, } } + full_fname = full_path_from_dirfsp_atname(talloc_tos(), + dirfsp, + smb_fname); + if (full_fname == NULL) { + status = NT_STATUS_NO_MEMORY; + goto err; + } + ret = ceph_statx(handle->data, - smb_fname->base_name, + full_fname->base_name, &stx, SAMBA_STATX_ATTR_MASK, AT_SYMLINK_NOFOLLOW); @@ -1501,20 +1508,20 @@ static NTSTATUS cephwrap_read_dfs_pathat(struct vfs_handle_struct *handle, } referral_len = ceph_readlink(handle->data, - smb_fname->base_name, + full_fname->base_name, link_target, bufsize - 1); if (referral_len < 0) { /* ceph errors are -errno. */ if (-referral_len == EINVAL) { DBG_INFO("%s is not a link.\n", - smb_fname->base_name); + full_fname->base_name); status = NT_STATUS_OBJECT_TYPE_MISMATCH; } else { status = map_nt_error_from_unix(-referral_len); DBG_ERR("Error reading " "msdfs link %s: %s\n", - smb_fname->base_name, + full_fname->base_name, strerror(errno)); } goto err; @@ -1522,7 +1529,7 @@ static NTSTATUS cephwrap_read_dfs_pathat(struct vfs_handle_struct *handle, link_target[referral_len] = '\0'; DBG_INFO("%s -> %s\n", - smb_fname->base_name, + full_fname->base_name, link_target); if (!strnequal(link_target, "msdfs:", 6)) { @@ -1532,6 +1539,7 @@ static NTSTATUS cephwrap_read_dfs_pathat(struct vfs_handle_struct *handle, if (ppreflist == NULL && preferral_count == NULL) { /* Early return for checking if this is a DFS link. */ + TALLOC_FREE(full_fname); init_stat_ex_from_ceph_statx(&smb_fname->st, &stx); return NT_STATUS_OK; } @@ -1554,6 +1562,7 @@ static NTSTATUS cephwrap_read_dfs_pathat(struct vfs_handle_struct *handle, if (link_target != link_target_buf) { TALLOC_FREE(link_target); } + TALLOC_FREE(full_fname); return status; }