vfs_audit: implement SMB_VFS_OPENAT()
authorRalph Boehme <slow@samba.org>
Wed, 20 May 2020 20:58:47 +0000 (22:58 +0200)
committerJeremy Allison <jra@samba.org>
Thu, 21 May 2020 20:38:32 +0000 (20:38 +0000)
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/modules/vfs_audit.c

index 916d8a04206d7bdf5654ee61c8e4f35ef595af40..464dbde26406e32d05ac5d78487c60a6f723cc84 100644 (file)
@@ -214,6 +214,27 @@ static int audit_open(vfs_handle_struct *handle,
        return result;
 }
 
+static int 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;
+
+       result = SMB_VFS_NEXT_OPENAT(handle, dirfsp, smb_fname, fsp, flags, mode);
+
+       syslog(audit_syslog_priority(handle),
+              "openat %s (fd %d) %s%s%s\n",
+              fsp_str_dbg(fsp), result,
+              ((flags & O_WRONLY) || (flags & O_RDWR)) ? "for writing " : "",
+              (result < 0) ? "failed: " : "",
+              (result < 0) ? strerror(errno) : "");
+
+       return result;
+}
+
 static int audit_close(vfs_handle_struct *handle, files_struct *fsp)
 {
        int result;
@@ -306,6 +327,7 @@ static struct vfs_fn_pointers vfs_audit_fns = {
        .disconnect_fn = audit_disconnect,
        .mkdirat_fn = audit_mkdirat,
        .open_fn = audit_open,
+       .openat_fn = audit_openat,
        .close_fn = audit_close,
        .renameat_fn = audit_renameat,
        .unlinkat_fn = audit_unlinkat,