From: Jeremy Allison Date: Wed, 20 Jan 2021 19:33:03 +0000 (-0800) Subject: VFS: cap: Fixup cap_mknodat() to cope with translating dirfsp path. X-Git-Tag: tevent-0.11.0~2036 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e6af33960c842f2a6a8abaf7d4b0ad7234ed0cd7;p=thirdparty%2Fsamba.git VFS: cap: Fixup cap_mknodat() to cope with translating dirfsp path. Missed in my original fixes. Signed-off-by: Jeremy Allison Reviewed-by: Ralph Böhme --- diff --git a/source3/modules/vfs_cap.c b/source3/modules/vfs_cap.c index b7cdd0d8131..3593ef589d8 100644 --- a/source3/modules/vfs_cap.c +++ b/source3/modules/vfs_cap.c @@ -629,12 +629,22 @@ static int cap_mknodat(vfs_handle_struct *handle, mode_t mode, SMB_DEV_T dev) { + struct smb_filename *full_fname = NULL; struct smb_filename *cap_smb_fname = NULL; - char *cappath = capencode(talloc_tos(), smb_fname->base_name); + char *cappath = NULL; int ret; int saved_errno = 0; + full_fname = full_path_from_dirfsp_atname(talloc_tos(), + dirfsp, + smb_fname); + if (full_fname == NULL) { + return -1; + } + + cappath = capencode(talloc_tos(), full_fname->base_name); if (!cappath) { + TALLOC_FREE(full_fname); errno = ENOMEM; return -1; } @@ -645,18 +655,20 @@ static int cap_mknodat(vfs_handle_struct *handle, smb_fname->twrp, smb_fname->flags); if (cap_smb_fname == NULL) { + TALLOC_FREE(full_fname); TALLOC_FREE(cappath); errno = ENOMEM; return -1; } ret = SMB_VFS_NEXT_MKNODAT(handle, - dirfsp, + handle->conn->cwd_fsp, cap_smb_fname, mode, dev); if (ret == -1) { saved_errno = errno; } + TALLOC_FREE(full_fname); TALLOC_FREE(cappath); TALLOC_FREE(cap_smb_fname); if (saved_errno != 0) {