s3: VFS: audit: Use real dirfsp for SMB_VFS_RENAMEAT()
authorJeremy Allison <jra@samba.org>
Thu, 17 Jun 2021 02:54:46 +0000 (19:54 -0700)
committerNoel Power <npower@samba.org>
Tue, 22 Jun 2021 13:44:34 +0000 (13:44 +0000)
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Noel Power <npower@samba.org>
source3/modules/vfs_audit.c

index 2b0171b9c094de2808aa13d5c92886f7441747bf..91fbd8c19ba2a765613ee40d7e77dba1943bb845 100644 (file)
@@ -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;
 }