From: Jeremy Allison Date: Thu, 17 Jun 2021 02:54:46 +0000 (-0700) Subject: s3: VFS: audit: Use real dirfsp for SMB_VFS_RENAMEAT() X-Git-Tag: tevent-0.11.0~229 X-Git-Url: http://git.samba.org/?a=commitdiff_plain;h=7785da8dde5c103cf548810fe6781e341f38de68;p=samba.git s3: VFS: audit: Use real dirfsp for SMB_VFS_RENAMEAT() Signed-off-by: Jeremy Allison Reviewed-by: Noel Power --- diff --git a/source3/modules/vfs_audit.c b/source3/modules/vfs_audit.c index 2b0171b9c09..91fbd8c19ba 100644 --- a/source3/modules/vfs_audit.c +++ b/source3/modules/vfs_audit.c @@ -248,20 +248,48 @@ static int audit_renameat(vfs_handle_struct *handle, files_struct *dstfsp, const struct smb_filename *smb_fname_dst) { + struct smb_filename *full_fname_src = NULL; + struct smb_filename *full_fname_dst = NULL; int result; + int saved_errno = 0; + full_fname_src = full_path_from_dirfsp_atname(talloc_tos(), + srcfsp, + smb_fname_src); + if (full_fname_src == NULL) { + errno = ENOMEM; + return -1; + } + full_fname_dst = full_path_from_dirfsp_atname(talloc_tos(), + dstfsp, + smb_fname_dst); + if (full_fname_dst == NULL) { + TALLOC_FREE(full_fname_src); + errno = ENOMEM; + return -1; + } result = SMB_VFS_NEXT_RENAMEAT(handle, srcfsp, smb_fname_src, dstfsp, smb_fname_dst); + if (result == -1) { + saved_errno = errno; + } syslog(audit_syslog_priority(handle), "renameat %s -> %s %s%s\n", - smb_fname_src->base_name, - smb_fname_dst->base_name, + full_fname_src->base_name, + full_fname_dst->base_name, (result < 0) ? "failed: " : "", (result < 0) ? strerror(errno) : ""); + TALLOC_FREE(full_fname_src); + TALLOC_FREE(full_fname_dst); + + if (saved_errno != 0) { + errno = saved_errno; + } + return result; }