s3: VFS: time_audit: Fix smb_time_audit_linkat() to cope with real directory fsps.
authorJeremy Allison <jra@samba.org>
Wed, 3 Feb 2021 21:59:00 +0000 (13:59 -0800)
committerJeremy Allison <jra@samba.org>
Tue, 9 Feb 2021 00:10:29 +0000 (00:10 +0000)
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Böhme <slow@samba.org>
source3/modules/vfs_time_audit.c

index a56839c77ad2423728d0e00d11dfefd10a4ab7d1..db9e9d3cf1208ebe38862fd3b95abc320cb2f277 100644 (file)
@@ -1497,10 +1497,19 @@ static int smb_time_audit_linkat(vfs_handle_struct *handle,
                                const struct smb_filename *new_smb_fname,
                                int flags)
 {
+       struct smb_filename *new_full_fname = NULL;
        int result;
        struct timespec ts1,ts2;
        double timediff;
 
+       new_full_fname = full_path_from_dirfsp_atname(talloc_tos(),
+                                                 dstfsp,
+                                                 new_smb_fname);
+       if (new_full_fname == NULL) {
+               errno = ENOMEM;
+               return -1;
+       }
+
        clock_gettime_mono(&ts1);
        result = SMB_VFS_NEXT_LINKAT(handle,
                        srcfsp,
@@ -1513,9 +1522,10 @@ static int smb_time_audit_linkat(vfs_handle_struct *handle,
 
        if (timediff > audit_timeout) {
                smb_time_audit_log_fname("linkat", timediff,
-                       new_smb_fname->base_name);
+                       new_full_fname->base_name);
        }
 
+       TALLOC_FREE(new_full_fname);
        return result;
 }