1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-25 23:21:54 +03:00

s3: VFS: extd_audit: Use real dirfsp for SMB_VFS_RENAMEAT()

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Noel Power <npower@samba.org>
This commit is contained in:
Jeremy Allison 2021-06-16 21:05:31 -07:00 committed by Noel Power
parent 5235ffea59
commit 770357f666

View File

@ -280,27 +280,55 @@ static int audit_renameat(vfs_handle_struct *handle,
files_struct *dstfsp, files_struct *dstfsp,
const struct smb_filename *smb_fname_dst) const struct smb_filename *smb_fname_dst)
{ {
struct smb_filename *full_fname_src = NULL;
struct smb_filename *full_fname_dst = NULL;
int result; 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, result = SMB_VFS_NEXT_RENAMEAT(handle,
srcfsp, srcfsp,
smb_fname_src, smb_fname_src,
dstfsp, dstfsp,
smb_fname_dst); smb_fname_dst);
if (result == -1) {
saved_errno = errno;
}
if (lp_syslog() > 0) { if (lp_syslog() > 0) {
syslog(audit_syslog_priority(handle), "renameat %s -> %s %s%s\n", syslog(audit_syslog_priority(handle), "renameat %s -> %s %s%s\n",
smb_fname_src->base_name, full_fname_src->base_name,
smb_fname_dst->base_name, full_fname_dst->base_name,
(result < 0) ? "failed: " : "", (result < 0) ? "failed: " : "",
(result < 0) ? strerror(errno) : ""); (result < 0) ? strerror(saved_errno) : "");
} }
DEBUG(1, ("vfs_extd_audit: renameat old: %s newname: %s %s %s\n", DEBUG(1, ("vfs_extd_audit: renameat old: %s newname: %s %s %s\n",
smb_fname_str_dbg(smb_fname_src), smb_fname_str_dbg(full_fname_src),
smb_fname_str_dbg(smb_fname_dst), smb_fname_str_dbg(full_fname_dst),
(result < 0) ? "failed: " : "", (result < 0) ? "failed: " : "",
(result < 0) ? strerror(errno) : "")); (result < 0) ? strerror(saved_errno) : ""));
TALLOC_FREE(full_fname_src);
TALLOC_FREE(full_fname_dst);
if (result == -1) {
errno = saved_errno;
}
return result; return result;
} }