From: Jeremy Allison Date: Wed, 3 Feb 2021 20:36:27 +0000 (-0800) Subject: s3: VFS: media_harmony: Fix mh_linkat() to cope with real directory fsps. X-Git-Tag: tevent-0.11.0~1792 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=035909ec590c1bdbfe3f21c5f1a0d47b74e55f17;p=thirdparty%2Fsamba.git s3: VFS: media_harmony: Fix mh_linkat() to cope with real directory fsps. Signed-off-by: Jeremy Allison Reviewed-by: Ralph Böhme --- diff --git a/source3/modules/vfs_media_harmony.c b/source3/modules/vfs_media_harmony.c index 307d7afa963..fb5a082c98e 100644 --- a/source3/modules/vfs_media_harmony.c +++ b/source3/modules/vfs_media_harmony.c @@ -1721,12 +1721,34 @@ static int mh_linkat(vfs_handle_struct *handle, int flags) { int status; + struct smb_filename *old_full_fname = NULL; struct smb_filename *oldclientFname = NULL; + struct smb_filename *new_full_fname = NULL; struct smb_filename *newclientFname = NULL; DEBUG(MH_INFO_DEBUG, ("Entering mh_linkat\n")); - if (!is_in_media_files(old_smb_fname->base_name) && - !is_in_media_files(new_smb_fname->base_name)) { + + old_full_fname = full_path_from_dirfsp_atname(talloc_tos(), + srcfsp, + old_smb_fname); + if (old_full_fname == NULL) { + status = -1; + goto err; + } + + new_full_fname = full_path_from_dirfsp_atname(talloc_tos(), + dstfsp, + new_smb_fname); + if (new_full_fname == NULL) { + status = -1; + goto err; + } + + if (!is_in_media_files(old_full_fname->base_name) && + !is_in_media_files(new_full_fname->base_name)) { + TALLOC_FREE(old_full_fname); + TALLOC_FREE(new_full_fname); + status = SMB_VFS_NEXT_LINKAT(handle, srcfsp, old_smb_fname, @@ -1737,24 +1759,26 @@ static int mh_linkat(vfs_handle_struct *handle, } if ((status = alloc_get_client_smb_fname(handle, talloc_tos(), - old_smb_fname, + old_full_fname, &oldclientFname))) { goto err; } if ((status = alloc_get_client_smb_fname(handle, talloc_tos(), - new_smb_fname, + new_full_fname, &newclientFname))) { goto err; } status = SMB_VFS_NEXT_LINKAT(handle, - srcfsp, + handle->conn->cwd_fsp, oldclientFname, - dstfsp, + handle->conn->cwd_fsp, newclientFname, flags); err: + TALLOC_FREE(old_full_fname); + TALLOC_FREE(new_full_fname); TALLOC_FREE(newclientFname); TALLOC_FREE(oldclientFname); out: