vfs_time_audit: implement SMB_VFS_OPENAT()
authorRalph Boehme <slow@samba.org>
Wed, 20 May 2020 21:03:18 +0000 (23:03 +0200)
committerJeremy Allison <jra@samba.org>
Thu, 21 May 2020 20:38:33 +0000 (20:38 +0000)
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/modules/vfs_time_audit.c

index 01b9e98706531ccd4e42e24ab4f4b6733c08a1a8..d357eb2e43cf518ec6c4eb70fe2ed136590f5548 100644 (file)
@@ -605,6 +605,34 @@ static int smb_time_audit_open(vfs_handle_struct *handle,
        return result;
 }
 
+static int smb_time_audit_openat(vfs_handle_struct *handle,
+                                const struct files_struct *dirfsp,
+                                const struct smb_filename *smb_fname,
+                                struct files_struct *fsp,
+                                int flags,
+                                mode_t mode)
+{
+       int result;
+       struct timespec ts1,ts2;
+       double timediff;
+
+       clock_gettime_mono(&ts1);
+       result = SMB_VFS_NEXT_OPENAT(handle,
+                                    dirfsp,
+                                    smb_fname,
+                                    fsp,
+                                    flags,
+                                    mode);
+       clock_gettime_mono(&ts2);
+       timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
+
+       if (timediff > audit_timeout) {
+               smb_time_audit_log_fsp("openat", timediff, fsp);
+       }
+
+       return result;
+}
+
 static NTSTATUS smb_time_audit_create_file(vfs_handle_struct *handle,
                                           struct smb_request *req,
                                           struct files_struct **dirfsp,
@@ -2857,6 +2885,7 @@ static struct vfs_fn_pointers vfs_time_audit_fns = {
        .mkdirat_fn = smb_time_audit_mkdirat,
        .closedir_fn = smb_time_audit_closedir,
        .open_fn = smb_time_audit_open,
+       .openat_fn = smb_time_audit_openat,
        .create_file_fn = smb_time_audit_create_file,
        .close_fn = smb_time_audit_close,
        .pread_fn = smb_time_audit_pread,