s3: VFS: vfs_time_audit. Implement symlinkat().
authorJeremy Allison <jra@samba.org>
Fri, 30 Aug 2019 21:01:33 +0000 (14:01 -0700)
committerJeremy Allison <jra@samba.org>
Tue, 3 Sep 2019 21:15:43 +0000 (21:15 +0000)
Currently identical to symlink().

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Böhme <slow@samba.org>
source3/modules/vfs_time_audit.c

index b8e19267b5d9a98e30f24e3d26f0f9b1e6bafdd4..e2236f16af04dde8958238a03e19cd0d9bdbd014 100644 (file)
@@ -1398,6 +1398,31 @@ static int smb_time_audit_symlink(vfs_handle_struct *handle,
        return result;
 }
 
+static int smb_time_audit_symlinkat(vfs_handle_struct *handle,
+                               const char *link_contents,
+                               struct files_struct *dirfsp,
+                               const struct smb_filename *new_smb_fname)
+{
+       int result;
+       struct timespec ts1,ts2;
+       double timediff;
+
+       clock_gettime_mono(&ts1);
+       result = SMB_VFS_NEXT_SYMLINKAT(handle,
+                               link_contents,
+                               dirfsp,
+                               new_smb_fname);
+       clock_gettime_mono(&ts2);
+       timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
+
+       if (timediff > audit_timeout) {
+               smb_time_audit_log_fname("symlinkat", timediff,
+                       new_smb_fname->base_name);
+       }
+
+       return result;
+}
+
 static int smb_time_audit_readlinkat(vfs_handle_struct *handle,
                                files_struct *dirfsp,
                                const struct smb_filename *smb_fname,
@@ -2856,6 +2881,7 @@ static struct vfs_fn_pointers vfs_time_audit_fns = {
        .linux_setlease_fn = smb_time_audit_linux_setlease,
        .getlock_fn = smb_time_audit_getlock,
        .symlink_fn = smb_time_audit_symlink,
+       .symlinkat_fn = smb_time_audit_symlinkat,
        .readlinkat_fn = smb_time_audit_readlinkat,
        .linkat_fn = smb_time_audit_linkat,
        .mknodat_fn = smb_time_audit_mknodat,