s3: VFS: vfs_audit. Implement unlinkat().
authorJeremy Allison <jra@samba.org>
Tue, 17 Sep 2019 00:57:25 +0000 (17:57 -0700)
committerRalph Boehme <slow@samba.org>
Thu, 26 Sep 2019 17:20:47 +0000 (17:20 +0000)
This is identical to unlink(), as there
are no special cases needed for rmdir().

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
source3/modules/vfs_audit.c

index 718d13d7c9c8bcece76904d8e3d792a56f1e3b24..c75339351b64d02faf9c8254a4003bf40943703c 100644 (file)
@@ -283,7 +283,6 @@ static int audit_renameat(vfs_handle_struct *handle,
        return result;
 }
 
-
 static int audit_unlink(vfs_handle_struct *handle,
                        const struct smb_filename *smb_fname)
 {
@@ -299,6 +298,26 @@ static int audit_unlink(vfs_handle_struct *handle,
        return result;
 }
 
+static int audit_unlinkat(vfs_handle_struct *handle,
+                       struct files_struct *dirfsp,
+                       const struct smb_filename *smb_fname,
+                       int flags)
+{
+       int result;
+
+       result = SMB_VFS_NEXT_UNLINKAT(handle,
+                       dirfsp,
+                       smb_fname,
+                       flags);
+
+       syslog(audit_syslog_priority(handle), "unlinkat %s %s%s\n",
+              smb_fname->base_name,
+              (result < 0) ? "failed: " : "",
+              (result < 0) ? strerror(errno) : "");
+
+       return result;
+}
+
 static int audit_chmod(vfs_handle_struct *handle,
                        const struct smb_filename *smb_fname,
                        mode_t mode)
@@ -339,6 +358,7 @@ static struct vfs_fn_pointers vfs_audit_fns = {
        .close_fn = audit_close,
        .renameat_fn = audit_renameat,
        .unlink_fn = audit_unlink,
+       .unlinkat_fn = audit_unlinkat,
        .chmod_fn = audit_chmod,
        .fchmod_fn = audit_fchmod,
 };