From 11ea133e73e3157ec6fac4629e0438fa3118dbca Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 5 Feb 2021 14:19:21 -0800 Subject: [PATCH] s3: VFS: syncops: Fix syncops_linkat() to cope with real directory fsps. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jeremy Allison Reviewed-by: Ralph Böhme --- source3/modules/vfs_syncops.c | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/source3/modules/vfs_syncops.c b/source3/modules/vfs_syncops.c index 9c633456ad1..e36cb79e64d 100644 --- a/source3/modules/vfs_syncops.c +++ b/source3/modules/vfs_syncops.c @@ -196,14 +196,26 @@ static int syncops_linkat(vfs_handle_struct *handle, { int ret; struct syncops_config_data *config; + struct smb_filename *old_full_fname = NULL; + struct smb_filename *new_full_fname = NULL; SMB_VFS_HANDLE_GET_DATA(handle, config, struct syncops_config_data, return -1); - SMB_ASSERT(srcfsp == srcfsp->conn->cwd_fsp); - SMB_ASSERT(dstfsp == dstfsp->conn->cwd_fsp); - + old_full_fname = full_path_from_dirfsp_atname(talloc_tos(), + srcfsp, + old_smb_fname); + if (old_full_fname == NULL) { + return -1; + } + new_full_fname = full_path_from_dirfsp_atname(talloc_tos(), + dstfsp, + new_smb_fname); + if (new_full_fname == NULL) { + TALLOC_FREE(old_full_fname); + return -1; + } ret = SMB_VFS_NEXT_LINKAT(handle, srcfsp, old_smb_fname, @@ -212,9 +224,11 @@ static int syncops_linkat(vfs_handle_struct *handle, flags); if (ret == 0 && config->onmeta && !config->disable) { - syncops_two_names(old_smb_fname->base_name, - new_smb_fname->base_name); + syncops_two_names(old_full_fname->base_name, + new_full_fname->base_name); } + TALLOC_FREE(old_full_fname); + TALLOC_FREE(new_full_fname); return ret; } -- 2.47.3