LCOV - code coverage report
Current view: top level - source3/modules - vfs_full_audit.c (source / functions) Hit Total Coverage
Test: coverage report for master 2b515b7d Lines: 554 965 57.4 %
Date: 2024-02-28 12:06:22 Functions: 86 116 74.1 %

          Line data    Source code
       1             : /*
       2             :  * Auditing VFS module for samba.  Log selected file operations to syslog
       3             :  * facility.
       4             :  *
       5             :  * Copyright (C) Tim Potter, 1999-2000
       6             :  * Copyright (C) Alexander Bokovoy, 2002
       7             :  * Copyright (C) John H Terpstra, 2003
       8             :  * Copyright (C) Stefan (metze) Metzmacher, 2003
       9             :  * Copyright (C) Volker Lendecke, 2004
      10             :  *
      11             :  * This program is free software; you can redistribute it and/or modify
      12             :  * it under the terms of the GNU General Public License as published by
      13             :  * the Free Software Foundation; either version 3 of the License, or
      14             :  * (at your option) any later version.
      15             :  *
      16             :  * This program is distributed in the hope that it will be useful,
      17             :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18             :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19             :  * GNU General Public License for more details.
      20             :  *
      21             :  * You should have received a copy of the GNU General Public License
      22             :  * along with this program; if not, see <http://www.gnu.org/licenses/>.
      23             :  */
      24             : 
      25             : /*
      26             :  * This module implements parseable logging for all Samba VFS operations.
      27             :  *
      28             :  * You use it as follows:
      29             :  *
      30             :  * [tmp]
      31             :  * path = /tmp
      32             :  * vfs objects = full_audit
      33             :  * full_audit:prefix = %u|%I
      34             :  * full_audit:success = open opendir create_file
      35             :  * full_audit:failure = all
      36             :  *
      37             :  * vfs op can be "all" which means log all operations.
      38             :  * vfs op can be "none" which means no logging.
      39             :  *
      40             :  * This leads to syslog entries of the form:
      41             :  * smbd_audit: nobody|192.168.234.1|opendir|ok|/tmp
      42             :  * smbd_audit: nobody|192.168.234.1|create_file|fail (No such file or directory)|0x1|file|open|/ts/doesNotExist
      43             :  * smbd_audit: nobody|192.168.234.1|open|ok|w|/tmp/file.txt
      44             :  * smbd_audit: nobody|192.168.234.1|create_file|ok|0x3|file|open|/tmp/file.txt
      45             :  *
      46             :  * where "nobody" is the connected username and "192.168.234.1" is the
      47             :  * client's IP address.
      48             :  *
      49             :  * Options:
      50             :  *
      51             :  * prefix: A macro expansion template prepended to the syslog entry.
      52             :  *
      53             :  * success: A list of VFS operations for which a successful completion should
      54             :  * be logged. Defaults to no logging at all. The special operation "all" logs
      55             :  * - you guessed it - everything.
      56             :  *
      57             :  * failure: A list of VFS operations for which failure to complete should be
      58             :  * logged. Defaults to logging everything.
      59             :  */
      60             : 
      61             : 
      62             : #include "includes.h"
      63             : #include "system/filesys.h"
      64             : #include "system/syslog.h"
      65             : #include "smbd/smbd.h"
      66             : #include "../librpc/gen_ndr/ndr_netlogon.h"
      67             : #include "auth.h"
      68             : #include "ntioctl.h"
      69             : #include "lib/param/loadparm.h"
      70             : #include "lib/util/bitmap.h"
      71             : #include "lib/util/tevent_unix.h"
      72             : #include "libcli/security/sddl.h"
      73             : #include "passdb/machine_sid.h"
      74             : #include "lib/util/tevent_ntstatus.h"
      75             : #include "lib/util/string_wrappers.h"
      76             : #include "source3/lib/substitute.h"
      77             : 
      78             : static int vfs_full_audit_debug_level = DBGC_VFS;
      79             : 
      80             : struct vfs_full_audit_private_data {
      81             :         struct bitmap *success_ops;
      82             :         struct bitmap *failure_ops;
      83             :         int syslog_facility;
      84             :         int syslog_priority;
      85             :         bool log_secdesc;
      86             :         bool do_syslog;
      87             : };
      88             : 
      89             : #undef DBGC_CLASS
      90             : #define DBGC_CLASS vfs_full_audit_debug_level
      91             : 
      92             : typedef enum _vfs_op_type {
      93             :         SMB_VFS_OP_NOOP = -1,
      94             : 
      95             :         /* Disk operations */
      96             : 
      97             :         SMB_VFS_OP_CONNECT = 0,
      98             :         SMB_VFS_OP_DISCONNECT,
      99             :         SMB_VFS_OP_DISK_FREE,
     100             :         SMB_VFS_OP_GET_QUOTA,
     101             :         SMB_VFS_OP_SET_QUOTA,
     102             :         SMB_VFS_OP_GET_SHADOW_COPY_DATA,
     103             :         SMB_VFS_OP_STATVFS,
     104             :         SMB_VFS_OP_FS_CAPABILITIES,
     105             :         SMB_VFS_OP_GET_DFS_REFERRALS,
     106             :         SMB_VFS_OP_CREATE_DFS_PATHAT,
     107             :         SMB_VFS_OP_READ_DFS_PATHAT,
     108             : 
     109             :         /* Directory operations */
     110             : 
     111             :         SMB_VFS_OP_FDOPENDIR,
     112             :         SMB_VFS_OP_READDIR,
     113             :         SMB_VFS_OP_REWINDDIR,
     114             :         SMB_VFS_OP_MKDIRAT,
     115             :         SMB_VFS_OP_CLOSEDIR,
     116             : 
     117             :         /* File operations */
     118             : 
     119             :         SMB_VFS_OP_OPEN,
     120             :         SMB_VFS_OP_OPENAT,
     121             :         SMB_VFS_OP_CREATE_FILE,
     122             :         SMB_VFS_OP_CLOSE,
     123             :         SMB_VFS_OP_READ,
     124             :         SMB_VFS_OP_PREAD,
     125             :         SMB_VFS_OP_PREAD_SEND,
     126             :         SMB_VFS_OP_PREAD_RECV,
     127             :         SMB_VFS_OP_WRITE,
     128             :         SMB_VFS_OP_PWRITE,
     129             :         SMB_VFS_OP_PWRITE_SEND,
     130             :         SMB_VFS_OP_PWRITE_RECV,
     131             :         SMB_VFS_OP_LSEEK,
     132             :         SMB_VFS_OP_SENDFILE,
     133             :         SMB_VFS_OP_RECVFILE,
     134             :         SMB_VFS_OP_RENAMEAT,
     135             :         SMB_VFS_OP_FSYNC_SEND,
     136             :         SMB_VFS_OP_FSYNC_RECV,
     137             :         SMB_VFS_OP_STAT,
     138             :         SMB_VFS_OP_FSTAT,
     139             :         SMB_VFS_OP_LSTAT,
     140             :         SMB_VFS_OP_FSTATAT,
     141             :         SMB_VFS_OP_GET_ALLOC_SIZE,
     142             :         SMB_VFS_OP_UNLINKAT,
     143             :         SMB_VFS_OP_FCHMOD,
     144             :         SMB_VFS_OP_FCHOWN,
     145             :         SMB_VFS_OP_LCHOWN,
     146             :         SMB_VFS_OP_CHDIR,
     147             :         SMB_VFS_OP_GETWD,
     148             :         SMB_VFS_OP_NTIMES,
     149             :         SMB_VFS_OP_FNTIMES,
     150             :         SMB_VFS_OP_FTRUNCATE,
     151             :         SMB_VFS_OP_FALLOCATE,
     152             :         SMB_VFS_OP_LOCK,
     153             :         SMB_VFS_OP_FILESYSTEM_SHAREMODE,
     154             :         SMB_VFS_OP_FCNTL,
     155             :         SMB_VFS_OP_LINUX_SETLEASE,
     156             :         SMB_VFS_OP_GETLOCK,
     157             :         SMB_VFS_OP_SYMLINKAT,
     158             :         SMB_VFS_OP_READLINKAT,
     159             :         SMB_VFS_OP_LINKAT,
     160             :         SMB_VFS_OP_MKNODAT,
     161             :         SMB_VFS_OP_REALPATH,
     162             :         SMB_VFS_OP_FCHFLAGS,
     163             :         SMB_VFS_OP_FILE_ID_CREATE,
     164             :         SMB_VFS_OP_FS_FILE_ID,
     165             :         SMB_VFS_OP_FSTREAMINFO,
     166             :         SMB_VFS_OP_GET_REAL_FILENAME,
     167             :         SMB_VFS_OP_GET_REAL_FILENAME_AT,
     168             :         SMB_VFS_OP_CONNECTPATH,
     169             :         SMB_VFS_OP_BRL_LOCK_WINDOWS,
     170             :         SMB_VFS_OP_BRL_UNLOCK_WINDOWS,
     171             :         SMB_VFS_OP_STRICT_LOCK_CHECK,
     172             :         SMB_VFS_OP_TRANSLATE_NAME,
     173             :         SMB_VFS_OP_PARENT_PATHNAME,
     174             :         SMB_VFS_OP_FSCTL,
     175             :         SMB_VFS_OP_OFFLOAD_READ_SEND,
     176             :         SMB_VFS_OP_OFFLOAD_READ_RECV,
     177             :         SMB_VFS_OP_OFFLOAD_WRITE_SEND,
     178             :         SMB_VFS_OP_OFFLOAD_WRITE_RECV,
     179             :         SMB_VFS_OP_FGET_COMPRESSION,
     180             :         SMB_VFS_OP_SET_COMPRESSION,
     181             :         SMB_VFS_OP_SNAP_CHECK_PATH,
     182             :         SMB_VFS_OP_SNAP_CREATE,
     183             :         SMB_VFS_OP_SNAP_DELETE,
     184             : 
     185             :         /* DOS attribute operations. */
     186             :         SMB_VFS_OP_GET_DOS_ATTRIBUTES_SEND,
     187             :         SMB_VFS_OP_GET_DOS_ATTRIBUTES_RECV,
     188             :         SMB_VFS_OP_FGET_DOS_ATTRIBUTES,
     189             :         SMB_VFS_OP_FSET_DOS_ATTRIBUTES,
     190             : 
     191             :         /* NT ACL operations. */
     192             : 
     193             :         SMB_VFS_OP_FGET_NT_ACL,
     194             :         SMB_VFS_OP_FSET_NT_ACL,
     195             :         SMB_VFS_OP_AUDIT_FILE,
     196             : 
     197             :         /* POSIX ACL operations. */
     198             : 
     199             :         SMB_VFS_OP_SYS_ACL_GET_FD,
     200             :         SMB_VFS_OP_SYS_ACL_BLOB_GET_FD,
     201             :         SMB_VFS_OP_SYS_ACL_SET_FD,
     202             :         SMB_VFS_OP_SYS_ACL_DELETE_DEF_FD,
     203             : 
     204             :         /* EA operations. */
     205             :         SMB_VFS_OP_GETXATTRAT_SEND,
     206             :         SMB_VFS_OP_GETXATTRAT_RECV,
     207             :         SMB_VFS_OP_FGETXATTR,
     208             :         SMB_VFS_OP_FLISTXATTR,
     209             :         SMB_VFS_OP_REMOVEXATTR,
     210             :         SMB_VFS_OP_FREMOVEXATTR,
     211             :         SMB_VFS_OP_FSETXATTR,
     212             : 
     213             :         /* aio operations */
     214             :         SMB_VFS_OP_AIO_FORCE,
     215             : 
     216             :         /* offline operations */
     217             :         SMB_VFS_OP_IS_OFFLINE,
     218             :         SMB_VFS_OP_SET_OFFLINE,
     219             : 
     220             :         /* Durable handle operations. */
     221             :         SMB_VFS_OP_DURABLE_COOKIE,
     222             :         SMB_VFS_OP_DURABLE_DISCONNECT,
     223             :         SMB_VFS_OP_DURABLE_RECONNECT,
     224             : 
     225             :         SMB_VFS_OP_FREADDIR_ATTR,
     226             : 
     227             :         /* This should always be last enum value */
     228             : 
     229             :         SMB_VFS_OP_LAST
     230             : } vfs_op_type;
     231             : 
     232             : /* The following array *must* be in the same order as defined in vfs_op_type */
     233             : 
     234             : static struct {
     235             :         vfs_op_type type;
     236             :         const char *name;
     237             : } vfs_op_names[] = {
     238             :         { SMB_VFS_OP_CONNECT,   "connect" },
     239             :         { SMB_VFS_OP_DISCONNECT,        "disconnect" },
     240             :         { SMB_VFS_OP_DISK_FREE, "disk_free" },
     241             :         { SMB_VFS_OP_GET_QUOTA, "get_quota" },
     242             :         { SMB_VFS_OP_SET_QUOTA, "set_quota" },
     243             :         { SMB_VFS_OP_GET_SHADOW_COPY_DATA,      "get_shadow_copy_data" },
     244             :         { SMB_VFS_OP_STATVFS,   "statvfs" },
     245             :         { SMB_VFS_OP_FS_CAPABILITIES,   "fs_capabilities" },
     246             :         { SMB_VFS_OP_GET_DFS_REFERRALS, "get_dfs_referrals" },
     247             :         { SMB_VFS_OP_CREATE_DFS_PATHAT, "create_dfs_pathat" },
     248             :         { SMB_VFS_OP_READ_DFS_PATHAT,   "read_dfs_pathat" },
     249             :         { SMB_VFS_OP_FDOPENDIR, "fdopendir" },
     250             :         { SMB_VFS_OP_READDIR,   "readdir" },
     251             :         { SMB_VFS_OP_REWINDDIR, "rewinddir" },
     252             :         { SMB_VFS_OP_MKDIRAT,   "mkdirat" },
     253             :         { SMB_VFS_OP_CLOSEDIR,  "closedir" },
     254             :         { SMB_VFS_OP_OPEN,      "open" },
     255             :         { SMB_VFS_OP_OPENAT,    "openat" },
     256             :         { SMB_VFS_OP_CREATE_FILE, "create_file" },
     257             :         { SMB_VFS_OP_CLOSE,     "close" },
     258             :         { SMB_VFS_OP_READ,      "read" },
     259             :         { SMB_VFS_OP_PREAD,     "pread" },
     260             :         { SMB_VFS_OP_PREAD_SEND,        "pread_send" },
     261             :         { SMB_VFS_OP_PREAD_RECV,        "pread_recv" },
     262             :         { SMB_VFS_OP_WRITE,     "write" },
     263             :         { SMB_VFS_OP_PWRITE,    "pwrite" },
     264             :         { SMB_VFS_OP_PWRITE_SEND,       "pwrite_send" },
     265             :         { SMB_VFS_OP_PWRITE_RECV,       "pwrite_recv" },
     266             :         { SMB_VFS_OP_LSEEK,     "lseek" },
     267             :         { SMB_VFS_OP_SENDFILE,  "sendfile" },
     268             :         { SMB_VFS_OP_RECVFILE,  "recvfile" },
     269             :         { SMB_VFS_OP_RENAMEAT,  "renameat" },
     270             :         { SMB_VFS_OP_FSYNC_SEND,        "fsync_send" },
     271             :         { SMB_VFS_OP_FSYNC_RECV,        "fsync_recv" },
     272             :         { SMB_VFS_OP_STAT,      "stat" },
     273             :         { SMB_VFS_OP_FSTAT,     "fstat" },
     274             :         { SMB_VFS_OP_LSTAT,     "lstat" },
     275             :         { SMB_VFS_OP_FSTATAT,   "fstatat" },
     276             :         { SMB_VFS_OP_GET_ALLOC_SIZE,    "get_alloc_size" },
     277             :         { SMB_VFS_OP_UNLINKAT,  "unlinkat" },
     278             :         { SMB_VFS_OP_FCHMOD,    "fchmod" },
     279             :         { SMB_VFS_OP_FCHOWN,    "fchown" },
     280             :         { SMB_VFS_OP_LCHOWN,    "lchown" },
     281             :         { SMB_VFS_OP_CHDIR,     "chdir" },
     282             :         { SMB_VFS_OP_GETWD,     "getwd" },
     283             :         { SMB_VFS_OP_NTIMES,    "ntimes" },
     284             :         { SMB_VFS_OP_FNTIMES,   "fntimes" },
     285             :         { SMB_VFS_OP_FTRUNCATE, "ftruncate" },
     286             :         { SMB_VFS_OP_FALLOCATE,"fallocate" },
     287             :         { SMB_VFS_OP_LOCK,      "lock" },
     288             :         { SMB_VFS_OP_FILESYSTEM_SHAREMODE,      "filesystem_sharemode" },
     289             :         { SMB_VFS_OP_FCNTL,     "fcntl" },
     290             :         { SMB_VFS_OP_LINUX_SETLEASE, "linux_setlease" },
     291             :         { SMB_VFS_OP_GETLOCK,   "getlock" },
     292             :         { SMB_VFS_OP_SYMLINKAT, "symlinkat" },
     293             :         { SMB_VFS_OP_READLINKAT,"readlinkat" },
     294             :         { SMB_VFS_OP_LINKAT,    "linkat" },
     295             :         { SMB_VFS_OP_MKNODAT,   "mknodat" },
     296             :         { SMB_VFS_OP_REALPATH,  "realpath" },
     297             :         { SMB_VFS_OP_FCHFLAGS,  "fchflags" },
     298             :         { SMB_VFS_OP_FILE_ID_CREATE,    "file_id_create" },
     299             :         { SMB_VFS_OP_FS_FILE_ID,        "fs_file_id" },
     300             :         { SMB_VFS_OP_FSTREAMINFO,       "fstreaminfo" },
     301             :         { SMB_VFS_OP_GET_REAL_FILENAME, "get_real_filename" },
     302             :         { SMB_VFS_OP_GET_REAL_FILENAME_AT, "get_real_filename_at" },
     303             :         { SMB_VFS_OP_CONNECTPATH,       "connectpath" },
     304             :         { SMB_VFS_OP_BRL_LOCK_WINDOWS,  "brl_lock_windows" },
     305             :         { SMB_VFS_OP_BRL_UNLOCK_WINDOWS, "brl_unlock_windows" },
     306             :         { SMB_VFS_OP_STRICT_LOCK_CHECK, "strict_lock_check" },
     307             :         { SMB_VFS_OP_TRANSLATE_NAME,    "translate_name" },
     308             :         { SMB_VFS_OP_PARENT_PATHNAME,   "parent_pathname" },
     309             :         { SMB_VFS_OP_FSCTL,             "fsctl" },
     310             :         { SMB_VFS_OP_OFFLOAD_READ_SEND, "offload_read_send" },
     311             :         { SMB_VFS_OP_OFFLOAD_READ_RECV, "offload_read_recv" },
     312             :         { SMB_VFS_OP_OFFLOAD_WRITE_SEND,        "offload_write_send" },
     313             :         { SMB_VFS_OP_OFFLOAD_WRITE_RECV,        "offload_write_recv" },
     314             :         { SMB_VFS_OP_FGET_COMPRESSION,  "fget_compression" },
     315             :         { SMB_VFS_OP_SET_COMPRESSION,   "set_compression" },
     316             :         { SMB_VFS_OP_SNAP_CHECK_PATH, "snap_check_path" },
     317             :         { SMB_VFS_OP_SNAP_CREATE, "snap_create" },
     318             :         { SMB_VFS_OP_SNAP_DELETE, "snap_delete" },
     319             :         { SMB_VFS_OP_GET_DOS_ATTRIBUTES_SEND, "get_dos_attributes_send" },
     320             :         { SMB_VFS_OP_GET_DOS_ATTRIBUTES_RECV, "get_dos_attributes_recv" },
     321             :         { SMB_VFS_OP_FGET_DOS_ATTRIBUTES, "fget_dos_attributes" },
     322             :         { SMB_VFS_OP_FSET_DOS_ATTRIBUTES, "fset_dos_attributes" },
     323             :         { SMB_VFS_OP_FGET_NT_ACL,       "fget_nt_acl" },
     324             :         { SMB_VFS_OP_FSET_NT_ACL,       "fset_nt_acl" },
     325             :         { SMB_VFS_OP_AUDIT_FILE,        "audit_file" },
     326             :         { SMB_VFS_OP_SYS_ACL_GET_FD,    "sys_acl_get_fd" },
     327             :         { SMB_VFS_OP_SYS_ACL_BLOB_GET_FD,       "sys_acl_blob_get_fd" },
     328             :         { SMB_VFS_OP_SYS_ACL_SET_FD,    "sys_acl_set_fd" },
     329             :         { SMB_VFS_OP_SYS_ACL_DELETE_DEF_FD,     "sys_acl_delete_def_fd" },
     330             :         { SMB_VFS_OP_GETXATTRAT_SEND, "getxattrat_send" },
     331             :         { SMB_VFS_OP_GETXATTRAT_RECV, "getxattrat_recv" },
     332             :         { SMB_VFS_OP_FGETXATTR, "fgetxattr" },
     333             :         { SMB_VFS_OP_FLISTXATTR,        "flistxattr" },
     334             :         { SMB_VFS_OP_REMOVEXATTR,       "removexattr" },
     335             :         { SMB_VFS_OP_FREMOVEXATTR,      "fremovexattr" },
     336             :         { SMB_VFS_OP_FSETXATTR, "fsetxattr" },
     337             :         { SMB_VFS_OP_AIO_FORCE, "aio_force" },
     338             :         { SMB_VFS_OP_IS_OFFLINE, "is_offline" },
     339             :         { SMB_VFS_OP_SET_OFFLINE, "set_offline" },
     340             :         { SMB_VFS_OP_DURABLE_COOKIE, "durable_cookie" },
     341             :         { SMB_VFS_OP_DURABLE_DISCONNECT, "durable_disconnect" },
     342             :         { SMB_VFS_OP_DURABLE_RECONNECT, "durable_reconnect" },
     343             :         { SMB_VFS_OP_FREADDIR_ATTR,      "freaddir_attr" },
     344             :         { SMB_VFS_OP_LAST, NULL }
     345             : };
     346             : 
     347       49766 : static int audit_syslog_facility(vfs_handle_struct *handle)
     348             : {
     349           0 :         static const struct enum_list enum_log_facilities[] = {
     350             : #ifdef LOG_AUTH
     351             :                 { LOG_AUTH,             "AUTH" },
     352             : #endif
     353             : #ifdef LOG_AUTHPRIV
     354             :                 { LOG_AUTHPRIV,         "AUTHPRIV" },
     355             : #endif
     356             : #ifdef LOG_AUDIT
     357             :                 { LOG_AUDIT,            "AUDIT" },
     358             : #endif
     359             : #ifdef LOG_CONSOLE
     360             :                 { LOG_CONSOLE,          "CONSOLE" },
     361             : #endif
     362             : #ifdef LOG_CRON
     363             :                 { LOG_CRON,             "CRON" },
     364             : #endif
     365             : #ifdef LOG_DAEMON
     366             :                 { LOG_DAEMON,           "DAEMON" },
     367             : #endif
     368             : #ifdef LOG_FTP
     369             :                 { LOG_FTP,              "FTP" },
     370             : #endif
     371             : #ifdef LOG_INSTALL
     372             :                 { LOG_INSTALL,          "INSTALL" },
     373             : #endif
     374             : #ifdef LOG_KERN
     375             :                 { LOG_KERN,             "KERN" },
     376             : #endif
     377             : #ifdef LOG_LAUNCHD
     378             :                 { LOG_LAUNCHD,          "LAUNCHD" },
     379             : #endif
     380             : #ifdef LOG_LFMT
     381             :                 { LOG_LFMT,             "LFMT" },
     382             : #endif
     383             : #ifdef LOG_LPR
     384             :                 { LOG_LPR,              "LPR" },
     385             : #endif
     386             : #ifdef LOG_MAIL
     387             :                 { LOG_MAIL,             "MAIL" },
     388             : #endif
     389             : #ifdef LOG_MEGASAFE
     390             :                 { LOG_MEGASAFE,         "MEGASAFE" },
     391             : #endif
     392             : #ifdef LOG_NETINFO
     393             :                 { LOG_NETINFO,          "NETINFO" },
     394             : #endif
     395             : #ifdef LOG_NEWS
     396             :                 { LOG_NEWS,             "NEWS" },
     397             : #endif
     398             : #ifdef LOG_NFACILITIES
     399             :                 { LOG_NFACILITIES,      "NFACILITIES" },
     400             : #endif
     401             : #ifdef LOG_NTP
     402             :                 { LOG_NTP,              "NTP" },
     403             : #endif
     404             : #ifdef LOG_RAS
     405             :                 { LOG_RAS,              "RAS" },
     406             : #endif
     407             : #ifdef LOG_REMOTEAUTH
     408             :                 { LOG_REMOTEAUTH,       "REMOTEAUTH" },
     409             : #endif
     410             : #ifdef LOG_SECURITY
     411             :                 { LOG_SECURITY,         "SECURITY" },
     412             : #endif
     413             : #ifdef LOG_SYSLOG
     414             :                 { LOG_SYSLOG,           "SYSLOG" },
     415             : #endif
     416             : #ifdef LOG_USER
     417             :                 { LOG_USER,             "USER" },
     418             : #endif
     419             : #ifdef LOG_UUCP
     420             :                 { LOG_UUCP,             "UUCP" },
     421             : #endif
     422             :                 { LOG_LOCAL0,           "LOCAL0" },
     423             :                 { LOG_LOCAL1,           "LOCAL1" },
     424             :                 { LOG_LOCAL2,           "LOCAL2" },
     425             :                 { LOG_LOCAL3,           "LOCAL3" },
     426             :                 { LOG_LOCAL4,           "LOCAL4" },
     427             :                 { LOG_LOCAL5,           "LOCAL5" },
     428             :                 { LOG_LOCAL6,           "LOCAL6" },
     429             :                 { LOG_LOCAL7,           "LOCAL7" },
     430             :                 { -1,                   NULL }
     431             :         };
     432             : 
     433           0 :         int facility;
     434             : 
     435       49766 :         facility = lp_parm_enum(SNUM(handle->conn), "full_audit", "facility", enum_log_facilities, LOG_USER);
     436             : 
     437       49766 :         return facility;
     438             : }
     439             : 
     440       49766 : static int audit_syslog_priority(vfs_handle_struct *handle)
     441             : {
     442           0 :         static const struct enum_list enum_log_priorities[] = {
     443             :                 { LOG_EMERG, "EMERG" },
     444             :                 { LOG_ALERT, "ALERT" },
     445             :                 { LOG_CRIT, "CRIT" },
     446             :                 { LOG_ERR, "ERR" },
     447             :                 { LOG_WARNING, "WARNING" },
     448             :                 { LOG_NOTICE, "NOTICE" },
     449             :                 { LOG_INFO, "INFO" },
     450             :                 { LOG_DEBUG, "DEBUG" },
     451             :                 { -1, NULL }
     452             :         };
     453             : 
     454           0 :         int priority;
     455             : 
     456       49766 :         priority = lp_parm_enum(SNUM(handle->conn), "full_audit", "priority",
     457             :                                 enum_log_priorities, LOG_NOTICE);
     458       49766 :         if (priority == -1) {
     459           0 :                 priority = LOG_WARNING;
     460             :         }
     461             : 
     462       49766 :         return priority;
     463             : }
     464             : 
     465           0 : static char *audit_prefix(TALLOC_CTX *ctx, connection_struct *conn)
     466             : {
     467           0 :         const struct loadparm_substitution *lp_sub =
     468           0 :                 loadparm_s3_global_substitution();
     469           0 :         char *prefix = NULL;
     470           0 :         char *result;
     471             : 
     472           0 :         prefix = talloc_strdup(ctx,
     473           0 :                         lp_parm_const_string(SNUM(conn), "full_audit",
     474             :                                              "prefix", "%u|%I"));
     475           0 :         if (!prefix) {
     476           0 :                 return NULL;
     477             :         }
     478           0 :         result = talloc_sub_full(ctx,
     479           0 :                         lp_servicename(talloc_tos(), lp_sub, SNUM(conn)),
     480           0 :                         conn->session_info->unix_info->unix_name,
     481           0 :                         conn->connectpath,
     482           0 :                         conn->session_info->unix_token->gid,
     483           0 :                         conn->session_info->unix_info->sanitized_username,
     484           0 :                         conn->session_info->info->domain_name,
     485             :                         prefix);
     486           0 :         TALLOC_FREE(prefix);
     487           0 :         return result;
     488             : }
     489             : 
     490   163554645 : static bool log_success(struct vfs_full_audit_private_data *pd, vfs_op_type op)
     491             : {
     492   163554645 :         if (pd->success_ops == NULL) {
     493           0 :                 return True;
     494             :         }
     495             : 
     496   163554645 :         return bitmap_query(pd->success_ops, op);
     497             : }
     498             : 
     499   106913046 : static bool log_failure(struct vfs_full_audit_private_data *pd, vfs_op_type op)
     500             : {
     501   106913046 :         if (pd->failure_ops == NULL)
     502           0 :                 return True;
     503             : 
     504   106913046 :         return bitmap_query(pd->failure_ops, op);
     505             : }
     506             : 
     507       99523 : static struct bitmap *init_bitmap(TALLOC_CTX *mem_ctx, const char **ops)
     508             : {
     509           0 :         struct bitmap *bm;
     510             : 
     511       99523 :         if (ops == NULL) {
     512           0 :                 DBG_ERR("init_bitmap, ops list is empty (logic error)\n");
     513           0 :                 return NULL;
     514             :         }
     515             : 
     516       99523 :         bm = bitmap_talloc(mem_ctx, SMB_VFS_OP_LAST);
     517       99523 :         if (bm == NULL) {
     518           0 :                 DBG_ERR("Could not alloc bitmap\n");
     519           0 :                 return NULL;
     520             :         }
     521             : 
     522       99523 :         for (; *ops != NULL; ops += 1) {
     523           0 :                 int i;
     524       99523 :                 bool neg = false;
     525           0 :                 const char *op;
     526             : 
     527       99523 :                 if (strequal(*ops, "all")) {
     528           0 :                         for (i=0; i<SMB_VFS_OP_LAST; i++) {
     529           0 :                                 bitmap_set(bm, i);
     530             :                         }
     531           0 :                         continue;
     532             :                 }
     533             : 
     534       99523 :                 if (strequal(*ops, "none")) {
     535       99505 :                         break;
     536             :                 }
     537             : 
     538          18 :                 op = ops[0];
     539          18 :                 if (op[0] == '!') {
     540           0 :                         neg = true;
     541           0 :                         op += 1;
     542             :                 }
     543             : 
     544        1926 :                 for (i=0; i<SMB_VFS_OP_LAST; i++) {
     545        1908 :                         if ((vfs_op_names[i].name == NULL)
     546        1908 :                          || (vfs_op_names[i].type != i)) {
     547           0 :                                 smb_panic("vfs_full_audit.c: name table not "
     548             :                                           "in sync with vfs_op_type enums\n");
     549             :                         }
     550        1908 :                         if (strequal(op, vfs_op_names[i].name)) {
     551           0 :                                 if (neg) {
     552           0 :                                         bitmap_clear(bm, i);
     553             :                                 } else {
     554           0 :                                         bitmap_set(bm, i);
     555             :                                 }
     556           0 :                                 break;
     557             :                         }
     558             :                 }
     559          18 :                 if (i == SMB_VFS_OP_LAST) {
     560          18 :                         DBG_ERR("Could not find opname %s\n", *ops);
     561          18 :                         TALLOC_FREE(bm);
     562          18 :                         return NULL;
     563             :                 }
     564             :         }
     565       99505 :         return bm;
     566             : }
     567             : 
     568           0 : static const char *audit_opname(vfs_op_type op)
     569             : {
     570           0 :         if (op >= SMB_VFS_OP_LAST)
     571           0 :                 return "INVALID VFS OP";
     572           0 :         return vfs_op_names[op].name;
     573             : }
     574             : 
     575             : static TALLOC_CTX *tmp_do_log_ctx;
     576             : /*
     577             :  * Get us a temporary talloc context usable just for DEBUG arguments
     578             :  */
     579   109852595 : static TALLOC_CTX *do_log_ctx(void)
     580             : {
     581   109852595 :         if (tmp_do_log_ctx == NULL) {
     582    39465677 :                 tmp_do_log_ctx = talloc_named_const(NULL, 0, "do_log_ctx");
     583             :         }
     584   109852595 :         return tmp_do_log_ctx;
     585             : }
     586             : 
     587             : static void do_log(vfs_op_type op, bool success, vfs_handle_struct *handle,
     588             :                    const char *format, ...) PRINTF_ATTRIBUTE(4, 5);
     589             : 
     590   270467691 : static void do_log(vfs_op_type op, bool success, vfs_handle_struct *handle,
     591             :                    const char *format, ...)
     592             : {
     593           0 :         struct vfs_full_audit_private_data *pd;
     594           0 :         fstring err_msg;
     595   270467691 :         char *audit_pre = NULL;
     596           0 :         va_list ap;
     597   270467691 :         char *op_msg = NULL;
     598             : 
     599   270467691 :         SMB_VFS_HANDLE_GET_DATA(handle, pd,
     600             :                                 struct vfs_full_audit_private_data,
     601           0 :                                 return;);
     602             : 
     603   270467691 :         if (success && (!log_success(pd, op)))
     604   163554645 :                 goto out;
     605             : 
     606   106913046 :         if (!success && (!log_failure(pd, op)))
     607   106913046 :                 goto out;
     608             : 
     609           0 :         if (success)
     610           0 :                 fstrcpy(err_msg, "ok");
     611             :         else
     612           0 :                 fstr_sprintf(err_msg, "fail (%s)", strerror(errno));
     613             : 
     614           0 :         va_start(ap, format);
     615           0 :         op_msg = talloc_vasprintf(talloc_tos(), format, ap);
     616           0 :         va_end(ap);
     617             : 
     618           0 :         if (!op_msg) {
     619           0 :                 goto out;
     620             :         }
     621             : 
     622           0 :         audit_pre = audit_prefix(talloc_tos(), handle->conn);
     623             : 
     624           0 :         if (pd->do_syslog) {
     625           0 :                 int priority;
     626             : 
     627             :                 /*
     628             :                  * Specify the facility to interoperate with other syslog
     629             :                  * callers (smbd for example).
     630             :                  */
     631           0 :                 priority = pd->syslog_priority | pd->syslog_facility;
     632             : 
     633           0 :                 syslog(priority, "%s|%s|%s|%s\n",
     634             :                        audit_pre ? audit_pre : "",
     635             :                        audit_opname(op), err_msg, op_msg);
     636             :         } else {
     637           0 :                 DEBUG(1, ("%s|%s|%s|%s\n",
     638             :                           audit_pre ? audit_pre : "",
     639             :                           audit_opname(op), err_msg, op_msg));
     640             :         }
     641   270467691 :  out:
     642   270467691 :         TALLOC_FREE(audit_pre);
     643   270467691 :         TALLOC_FREE(op_msg);
     644   270467691 :         TALLOC_FREE(tmp_do_log_ctx);
     645             : }
     646             : 
     647             : /**
     648             :  * Return a string using the do_log_ctx()
     649             :  */
     650    39503513 : static const char *smb_fname_str_do_log(struct connection_struct *conn,
     651             :                                 const struct smb_filename *smb_fname)
     652             : {
     653    39503513 :         char *fname = NULL;
     654           0 :         NTSTATUS status;
     655             : 
     656    39503513 :         if (smb_fname == NULL) {
     657           0 :                 return "";
     658             :         }
     659             : 
     660    39503513 :         if (smb_fname->base_name[0] != '/') {
     661    35174541 :                 char *abs_name = NULL;
     662    35174541 :                 struct smb_filename *fname_copy = cp_smb_filename(
     663             :                                                         do_log_ctx(),
     664             :                                                         smb_fname);
     665    35174541 :                 if (fname_copy == NULL) {
     666           0 :                         return "";
     667             :                 }
     668             : 
     669    35174541 :                 if (!ISDOT(smb_fname->base_name)) {
     670    21951440 :                         abs_name = talloc_asprintf(do_log_ctx(),
     671             :                                         "%s/%s",
     672    21951440 :                                         conn->cwd_fsp->fsp_name->base_name,
     673    21951440 :                                         smb_fname->base_name);
     674             :                 } else {
     675    13223101 :                         abs_name = talloc_strdup(do_log_ctx(),
     676    13223101 :                                         conn->cwd_fsp->fsp_name->base_name);
     677             :                 }
     678    35174541 :                 if (abs_name == NULL) {
     679           0 :                         return "";
     680             :                 }
     681    35174541 :                 fname_copy->base_name = abs_name;
     682    35174541 :                 smb_fname = fname_copy;
     683             :         }
     684             : 
     685    39503513 :         status = get_full_smb_filename(do_log_ctx(), smb_fname, &fname);
     686    39503513 :         if (!NT_STATUS_IS_OK(status)) {
     687           0 :                 return "";
     688             :         }
     689    39503513 :         return fname;
     690             : }
     691             : 
     692             : /**
     693             :  * Return an fsp debug string using the do_log_ctx()
     694             :  */
     695    26730326 : static const char *fsp_str_do_log(const struct files_struct *fsp)
     696             : {
     697    26730326 :         return smb_fname_str_do_log(fsp->conn, fsp->fsp_name);
     698             : }
     699             : 
     700             : /* Implementation of vfs_ops.  Pass everything on to the default
     701             :    operation but log event first. */
     702             : 
     703       49766 : static int smb_full_audit_connect(vfs_handle_struct *handle,
     704             :                          const char *svc, const char *user)
     705             : {
     706           0 :         int result;
     707       49766 :         const char *none[] = { "none" };
     708       49766 :         struct vfs_full_audit_private_data *pd = NULL;
     709             : 
     710       49766 :         result = SMB_VFS_NEXT_CONNECT(handle, svc, user);
     711       49766 :         if (result < 0) {
     712           0 :                 return result;
     713             :         }
     714             : 
     715       49766 :         pd = talloc_zero(handle, struct vfs_full_audit_private_data);
     716       49766 :         if (!pd) {
     717           0 :                 SMB_VFS_NEXT_DISCONNECT(handle);
     718           0 :                 return -1;
     719             :         }
     720             : 
     721       49766 :         pd->syslog_facility = audit_syslog_facility(handle);
     722       49766 :         if (pd->syslog_facility == -1) {
     723           0 :                 DEBUG(1, ("%s: Unknown facility %s\n", __func__,
     724             :                           lp_parm_const_string(SNUM(handle->conn),
     725             :                                                "full_audit", "facility",
     726             :                                                "USER")));
     727           0 :                 SMB_VFS_NEXT_DISCONNECT(handle);
     728           0 :                 return -1;
     729             :         }
     730             : 
     731       49766 :         pd->syslog_priority = audit_syslog_priority(handle);
     732             : 
     733       49766 :         pd->log_secdesc = lp_parm_bool(SNUM(handle->conn),
     734             :                                        "full_audit", "log_secdesc", false);
     735             : 
     736       49766 :         pd->do_syslog = lp_parm_bool(SNUM(handle->conn),
     737             :                                      "full_audit", "syslog", true);
     738             : 
     739             : #ifdef WITH_SYSLOG
     740       49766 :         if (pd->do_syslog) {
     741           0 :                 openlog("smbd_audit", 0, pd->syslog_facility);
     742             :         }
     743             : #endif
     744             : 
     745       49766 :         pd->success_ops = init_bitmap(
     746       49766 :                 pd, lp_parm_string_list(SNUM(handle->conn), "full_audit",
     747             :                                         "success", none));
     748       49766 :         if (pd->success_ops == NULL) {
     749           9 :                 DBG_ERR("Invalid success operations list. Failing connect\n");
     750           9 :                 SMB_VFS_NEXT_DISCONNECT(handle);
     751           9 :                 return -1;
     752             :         }
     753       49757 :         pd->failure_ops = init_bitmap(
     754       49757 :                 pd, lp_parm_string_list(SNUM(handle->conn), "full_audit",
     755             :                                         "failure", none));
     756       49757 :         if (pd->failure_ops == NULL) {
     757           9 :                 DBG_ERR("Invalid failure operations list. Failing connect\n");
     758           9 :                 SMB_VFS_NEXT_DISCONNECT(handle);
     759           9 :                 return -1;
     760             :         }
     761             : 
     762             :         /* Store the private data. */
     763       49748 :         SMB_VFS_HANDLE_SET_DATA(handle, pd, NULL,
     764           0 :                                 struct vfs_full_audit_private_data, return -1);
     765             : 
     766       49748 :         do_log(SMB_VFS_OP_CONNECT, True, handle,
     767             :                "%s", svc);
     768             : 
     769       49748 :         return 0;
     770             : }
     771             : 
     772       49716 : static void smb_full_audit_disconnect(vfs_handle_struct *handle)
     773             : {
     774           0 :         const struct loadparm_substitution *lp_sub =
     775       49716 :                 loadparm_s3_global_substitution();
     776             : 
     777       49716 :         SMB_VFS_NEXT_DISCONNECT(handle);
     778             : 
     779       49716 :         do_log(SMB_VFS_OP_DISCONNECT, True, handle,
     780       49716 :                "%s", lp_servicename(talloc_tos(), lp_sub, SNUM(handle->conn)));
     781             : 
     782             :         /* The bitmaps will be disconnected when the private
     783             :            data is deleted. */
     784       49716 : }
     785             : 
     786        1043 : static uint64_t smb_full_audit_disk_free(vfs_handle_struct *handle,
     787             :                                 const struct smb_filename *smb_fname,
     788             :                                 uint64_t *bsize,
     789             :                                 uint64_t *dfree,
     790             :                                 uint64_t *dsize)
     791             : {
     792           0 :         uint64_t result;
     793             : 
     794        1043 :         result = SMB_VFS_NEXT_DISK_FREE(handle, smb_fname, bsize, dfree, dsize);
     795             : 
     796             :         /* Don't have a reasonable notion of failure here */
     797             : 
     798        1043 :         do_log(SMB_VFS_OP_DISK_FREE,
     799             :                True,
     800             :                handle,
     801             :                "%s",
     802             :                smb_fname_str_do_log(handle->conn, smb_fname));
     803             : 
     804        1043 :         return result;
     805             : }
     806             : 
     807        2206 : static int smb_full_audit_get_quota(struct vfs_handle_struct *handle,
     808             :                                 const struct smb_filename *smb_fname,
     809             :                                 enum SMB_QUOTA_TYPE qtype,
     810             :                                 unid_t id,
     811             :                                 SMB_DISK_QUOTA *qt)
     812             : {
     813           0 :         int result;
     814             : 
     815        2206 :         result = SMB_VFS_NEXT_GET_QUOTA(handle, smb_fname, qtype, id, qt);
     816             : 
     817        2206 :         do_log(SMB_VFS_OP_GET_QUOTA,
     818             :                (result >= 0),
     819             :                handle,
     820             :                "%s",
     821             :                smb_fname_str_do_log(handle->conn, smb_fname));
     822             : 
     823        2206 :         return result;
     824             : }
     825             : 
     826           6 : static int smb_full_audit_set_quota(struct vfs_handle_struct *handle,
     827             :                            enum SMB_QUOTA_TYPE qtype, unid_t id,
     828             :                            SMB_DISK_QUOTA *qt)
     829             : {
     830           0 :         int result;
     831             : 
     832           6 :         result = SMB_VFS_NEXT_SET_QUOTA(handle, qtype, id, qt);
     833             : 
     834           6 :         do_log(SMB_VFS_OP_SET_QUOTA, (result >= 0), handle, "");
     835             : 
     836           6 :         return result;
     837             : }
     838             : 
     839         262 : static int smb_full_audit_get_shadow_copy_data(struct vfs_handle_struct *handle,
     840             :                                 struct files_struct *fsp,
     841             :                                 struct shadow_copy_data *shadow_copy_data,
     842             :                                 bool labels)
     843             : {
     844           0 :         int result;
     845             : 
     846         262 :         result = SMB_VFS_NEXT_GET_SHADOW_COPY_DATA(handle, fsp, shadow_copy_data, labels);
     847             : 
     848         262 :         do_log(SMB_VFS_OP_GET_SHADOW_COPY_DATA, (result >= 0), handle, "");
     849             : 
     850         262 :         return result;
     851             : }
     852             : 
     853       22369 : static int smb_full_audit_statvfs(struct vfs_handle_struct *handle,
     854             :                                 const struct smb_filename *smb_fname,
     855             :                                 struct vfs_statvfs_struct *statbuf)
     856             : {
     857           0 :         int result;
     858             : 
     859       22369 :         result = SMB_VFS_NEXT_STATVFS(handle, smb_fname, statbuf);
     860             : 
     861       22369 :         do_log(SMB_VFS_OP_STATVFS, (result >= 0), handle, "");
     862             : 
     863       22369 :         return result;
     864             : }
     865             : 
     866       22369 : static uint32_t smb_full_audit_fs_capabilities(struct vfs_handle_struct *handle, enum timestamp_set_resolution *p_ts_res)
     867             : {
     868           0 :         int result;
     869             : 
     870       22369 :         result = SMB_VFS_NEXT_FS_CAPABILITIES(handle, p_ts_res);
     871             : 
     872       22369 :         do_log(SMB_VFS_OP_FS_CAPABILITIES, true, handle, "");
     873             : 
     874       22369 :         return result;
     875             : }
     876             : 
     877       17805 : static NTSTATUS smb_full_audit_get_dfs_referrals(
     878             :                                 struct vfs_handle_struct *handle,
     879             :                                 struct dfs_GetDFSReferral *r)
     880             : {
     881           0 :         NTSTATUS status;
     882             : 
     883       17805 :         status = SMB_VFS_NEXT_GET_DFS_REFERRALS(handle, r);
     884             : 
     885       17805 :         do_log(SMB_VFS_OP_GET_DFS_REFERRALS, NT_STATUS_IS_OK(status),
     886             :                handle, "");
     887             : 
     888       17805 :         return status;
     889             : }
     890             : 
     891           0 : static NTSTATUS smb_full_audit_create_dfs_pathat(struct vfs_handle_struct *handle,
     892             :                                 struct files_struct *dirfsp,
     893             :                                 const struct smb_filename *smb_fname,
     894             :                                 const struct referral *reflist,
     895             :                                 size_t referral_count)
     896             : {
     897           0 :         NTSTATUS status;
     898           0 :         struct smb_filename *full_fname = NULL;
     899             : 
     900           0 :         full_fname = full_path_from_dirfsp_atname(talloc_tos(),
     901             :                                                   dirfsp,
     902             :                                                   smb_fname);
     903           0 :         if (full_fname == NULL) {
     904           0 :                 return NT_STATUS_NO_MEMORY;
     905             :         }
     906             : 
     907           0 :         status = SMB_VFS_NEXT_CREATE_DFS_PATHAT(handle,
     908             :                         dirfsp,
     909             :                         smb_fname,
     910             :                         reflist,
     911             :                         referral_count);
     912             : 
     913           0 :         do_log(SMB_VFS_OP_CREATE_DFS_PATHAT,
     914           0 :                 NT_STATUS_IS_OK(status),
     915             :                 handle,
     916             :                 "%s",
     917             :                 smb_fname_str_do_log(handle->conn, full_fname));
     918             : 
     919           0 :         TALLOC_FREE(full_fname);
     920           0 :         return status;
     921             : }
     922             : 
     923        5196 : static NTSTATUS smb_full_audit_read_dfs_pathat(struct vfs_handle_struct *handle,
     924             :                         TALLOC_CTX *mem_ctx,
     925             :                         struct files_struct *dirfsp,
     926             :                         struct smb_filename *smb_fname,
     927             :                         struct referral **ppreflist,
     928             :                         size_t *preferral_count)
     929             : {
     930        5196 :         struct smb_filename *full_fname = NULL;
     931           0 :         NTSTATUS status;
     932             : 
     933        5196 :         full_fname = full_path_from_dirfsp_atname(talloc_tos(),
     934             :                                                   dirfsp,
     935             :                                                   smb_fname);
     936        5196 :         if (full_fname == NULL) {
     937           0 :                 return NT_STATUS_NO_MEMORY;
     938             :         }
     939             : 
     940        5196 :         status = SMB_VFS_NEXT_READ_DFS_PATHAT(handle,
     941             :                         mem_ctx,
     942             :                         dirfsp,
     943             :                         smb_fname,
     944             :                         ppreflist,
     945             :                         preferral_count);
     946             : 
     947        5196 :         do_log(SMB_VFS_OP_READ_DFS_PATHAT,
     948        5196 :                 NT_STATUS_IS_OK(status),
     949             :                 handle,
     950             :                 "%s",
     951             :                 smb_fname_str_do_log(handle->conn, full_fname));
     952             : 
     953        5196 :         TALLOC_FREE(full_fname);
     954        5196 :         return status;
     955             : }
     956             : 
     957           0 : static NTSTATUS smb_full_audit_snap_check_path(struct vfs_handle_struct *handle,
     958             :                                                TALLOC_CTX *mem_ctx,
     959             :                                                const char *service_path,
     960             :                                                char **base_volume)
     961             : {
     962           0 :         NTSTATUS status;
     963             : 
     964           0 :         status = SMB_VFS_NEXT_SNAP_CHECK_PATH(handle, mem_ctx, service_path,
     965             :                                               base_volume);
     966           0 :         do_log(SMB_VFS_OP_SNAP_CHECK_PATH, NT_STATUS_IS_OK(status),
     967             :                handle, "");
     968             : 
     969           0 :         return status;
     970             : }
     971             : 
     972           0 : static NTSTATUS smb_full_audit_snap_create(struct vfs_handle_struct *handle,
     973             :                                            TALLOC_CTX *mem_ctx,
     974             :                                            const char *base_volume,
     975             :                                            time_t *tstamp,
     976             :                                            bool rw,
     977             :                                            char **base_path,
     978             :                                            char **snap_path)
     979             : {
     980           0 :         NTSTATUS status;
     981             : 
     982           0 :         status = SMB_VFS_NEXT_SNAP_CREATE(handle, mem_ctx, base_volume, tstamp,
     983             :                                           rw, base_path, snap_path);
     984           0 :         do_log(SMB_VFS_OP_SNAP_CREATE, NT_STATUS_IS_OK(status), handle, "");
     985             : 
     986           0 :         return status;
     987             : }
     988             : 
     989           0 : static NTSTATUS smb_full_audit_snap_delete(struct vfs_handle_struct *handle,
     990             :                                            TALLOC_CTX *mem_ctx,
     991             :                                            char *base_path,
     992             :                                            char *snap_path)
     993             : {
     994           0 :         NTSTATUS status;
     995             : 
     996           0 :         status = SMB_VFS_NEXT_SNAP_DELETE(handle, mem_ctx, base_path,
     997             :                                           snap_path);
     998           0 :         do_log(SMB_VFS_OP_SNAP_DELETE, NT_STATUS_IS_OK(status), handle, "");
     999             : 
    1000           0 :         return status;
    1001             : }
    1002             : 
    1003      169540 : static DIR *smb_full_audit_fdopendir(vfs_handle_struct *handle,
    1004             :                           files_struct *fsp, const char *mask, uint32_t attr)
    1005             : {
    1006           0 :         DIR *result;
    1007             : 
    1008      169540 :         result = SMB_VFS_NEXT_FDOPENDIR(handle, fsp, mask, attr);
    1009             : 
    1010      169540 :         do_log(SMB_VFS_OP_FDOPENDIR, (result != NULL), handle, "%s",
    1011             :                         fsp_str_do_log(fsp));
    1012             : 
    1013      169540 :         return result;
    1014             : }
    1015             : 
    1016   104918607 : static struct dirent *smb_full_audit_readdir(vfs_handle_struct *handle,
    1017             :                                              struct files_struct *dirfsp,
    1018             :                                              DIR *dirp)
    1019             : {
    1020           0 :         struct dirent *result;
    1021             : 
    1022   104918607 :         result = SMB_VFS_NEXT_READDIR(handle, dirfsp, dirp);
    1023             : 
    1024             :         /* This operation has no reasonable error condition
    1025             :          * (End of dir is also failure), so always succeed.
    1026             :          */
    1027   104918607 :         do_log(SMB_VFS_OP_READDIR, True, handle, "");
    1028             : 
    1029   104918607 :         return result;
    1030             : }
    1031             : 
    1032        1007 : static void smb_full_audit_rewinddir(vfs_handle_struct *handle,
    1033             :                         DIR *dirp)
    1034             : {
    1035        1007 :         SMB_VFS_NEXT_REWINDDIR(handle, dirp);
    1036             : 
    1037        1007 :         do_log(SMB_VFS_OP_REWINDDIR, True, handle, "");
    1038        1007 : }
    1039             : 
    1040        6503 : static int smb_full_audit_mkdirat(vfs_handle_struct *handle,
    1041             :                         struct files_struct *dirfsp,
    1042             :                         const struct smb_filename *smb_fname,
    1043             :                         mode_t mode)
    1044             : {
    1045        6503 :         struct smb_filename *full_fname = NULL;
    1046           0 :         int result;
    1047             : 
    1048        6503 :         full_fname = full_path_from_dirfsp_atname(talloc_tos(),
    1049             :                                                   dirfsp,
    1050             :                                                   smb_fname);
    1051        6503 :         if (full_fname == NULL) {
    1052           0 :                 errno = ENOMEM;
    1053           0 :                 return -1;
    1054             :         }
    1055             : 
    1056        6503 :         result = SMB_VFS_NEXT_MKDIRAT(handle,
    1057             :                         dirfsp,
    1058             :                         smb_fname,
    1059             :                         mode);
    1060             : 
    1061        6503 :         do_log(SMB_VFS_OP_MKDIRAT,
    1062             :                (result >= 0),
    1063             :                handle,
    1064             :                "%s",
    1065             :                smb_fname_str_do_log(handle->conn, full_fname));
    1066             : 
    1067        6503 :         TALLOC_FREE(full_fname);
    1068             : 
    1069        6503 :         return result;
    1070             : }
    1071             : 
    1072      169540 : static int smb_full_audit_closedir(vfs_handle_struct *handle,
    1073             :                           DIR *dirp)
    1074             : {
    1075           0 :         int result;
    1076             : 
    1077      169540 :         result = SMB_VFS_NEXT_CLOSEDIR(handle, dirp);
    1078             : 
    1079      169540 :         do_log(SMB_VFS_OP_CLOSEDIR, (result >= 0), handle, "");
    1080             : 
    1081      169540 :         return result;
    1082             : }
    1083             : 
    1084     3689345 : static int smb_full_audit_openat(vfs_handle_struct *handle,
    1085             :                                  const struct files_struct *dirfsp,
    1086             :                                  const struct smb_filename *smb_fname,
    1087             :                                  struct files_struct *fsp,
    1088             :                                  const struct vfs_open_how *how)
    1089             : {
    1090           0 :         int result;
    1091             : 
    1092     3689345 :         result = SMB_VFS_NEXT_OPENAT(handle, dirfsp, smb_fname, fsp, how);
    1093             : 
    1094     7378690 :         do_log(SMB_VFS_OP_OPENAT, (result >= 0), handle, "%s|%s",
    1095     3689345 :                ((how->flags & O_WRONLY) || (how->flags & O_RDWR))?"w":"r",
    1096             :                fsp_str_do_log(fsp));
    1097             : 
    1098     3689345 :         return result;
    1099             : }
    1100             : 
    1101      313762 : static NTSTATUS smb_full_audit_create_file(vfs_handle_struct *handle,
    1102             :                                       struct smb_request *req,
    1103             :                                       struct files_struct *dirfsp,
    1104             :                                       struct smb_filename *smb_fname,
    1105             :                                       uint32_t access_mask,
    1106             :                                       uint32_t share_access,
    1107             :                                       uint32_t create_disposition,
    1108             :                                       uint32_t create_options,
    1109             :                                       uint32_t file_attributes,
    1110             :                                       uint32_t oplock_request,
    1111             :                                       const struct smb2_lease *lease,
    1112             :                                       uint64_t allocation_size,
    1113             :                                       uint32_t private_flags,
    1114             :                                       struct security_descriptor *sd,
    1115             :                                       struct ea_list *ea_list,
    1116             :                                       files_struct **result_fsp,
    1117             :                                       int *pinfo,
    1118             :                                       const struct smb2_create_blobs *in_context_blobs,
    1119             :                                       struct smb2_create_blobs *out_context_blobs)
    1120             : {
    1121           0 :         NTSTATUS result;
    1122           0 :         const char* str_create_disposition;
    1123             : 
    1124      313762 :         switch (create_disposition) {
    1125          80 :         case FILE_SUPERSEDE:
    1126          80 :                 str_create_disposition = "supersede";
    1127          80 :                 break;
    1128        5770 :         case FILE_OVERWRITE_IF:
    1129        5770 :                 str_create_disposition = "overwrite_if";
    1130        5770 :                 break;
    1131      210976 :         case FILE_OPEN:
    1132      210976 :                 str_create_disposition = "open";
    1133      210976 :                 break;
    1134        1134 :         case FILE_OVERWRITE:
    1135        1134 :                 str_create_disposition = "overwrite";
    1136        1134 :                 break;
    1137       82172 :         case FILE_CREATE:
    1138       82172 :                 str_create_disposition = "create";
    1139       82172 :                 break;
    1140       13612 :         case FILE_OPEN_IF:
    1141       13612 :                 str_create_disposition = "open_if";
    1142       13612 :                 break;
    1143          18 :         default:
    1144          18 :                 str_create_disposition = "unknown";
    1145             :         }
    1146             : 
    1147      313762 :         result = SMB_VFS_NEXT_CREATE_FILE(
    1148             :                 handle,                                 /* handle */
    1149             :                 req,                                    /* req */
    1150             :                 dirfsp,                                 /* dirfsp */
    1151             :                 smb_fname,                              /* fname */
    1152             :                 access_mask,                            /* access_mask */
    1153             :                 share_access,                           /* share_access */
    1154             :                 create_disposition,                     /* create_disposition*/
    1155             :                 create_options,                         /* create_options */
    1156             :                 file_attributes,                        /* file_attributes */
    1157             :                 oplock_request,                         /* oplock_request */
    1158             :                 lease,                                  /* lease */
    1159             :                 allocation_size,                        /* allocation_size */
    1160             :                 private_flags,
    1161             :                 sd,                                     /* sd */
    1162             :                 ea_list,                                /* ea_list */
    1163             :                 result_fsp,                             /* result */
    1164             :                 pinfo,                                  /* pinfo */
    1165             :                 in_context_blobs, out_context_blobs);   /* create context */
    1166             : 
    1167      627524 :         do_log(SMB_VFS_OP_CREATE_FILE, (NT_STATUS_IS_OK(result)), handle,
    1168             :                "0x%x|%s|%s|%s", access_mask,
    1169      313762 :                create_options & FILE_DIRECTORY_FILE ? "dir" : "file",
    1170             :                str_create_disposition,
    1171             :                 smb_fname_str_do_log(handle->conn, smb_fname));
    1172             : 
    1173      313762 :         return result;
    1174             : }
    1175             : 
    1176     2417458 : static int smb_full_audit_close(vfs_handle_struct *handle, files_struct *fsp)
    1177             : {
    1178           0 :         int result;
    1179             : 
    1180     2417458 :         result = SMB_VFS_NEXT_CLOSE(handle, fsp);
    1181             : 
    1182     2417458 :         do_log(SMB_VFS_OP_CLOSE, (result >= 0), handle, "%s",
    1183             :                fsp_str_do_log(fsp));
    1184             : 
    1185     2417458 :         return result;
    1186             : }
    1187             : 
    1188        1843 : static ssize_t smb_full_audit_pread(vfs_handle_struct *handle, files_struct *fsp,
    1189             :                            void *data, size_t n, off_t offset)
    1190             : {
    1191           0 :         ssize_t result;
    1192             : 
    1193        1843 :         result = SMB_VFS_NEXT_PREAD(handle, fsp, data, n, offset);
    1194             : 
    1195        1843 :         do_log(SMB_VFS_OP_PREAD, (result >= 0), handle, "%s",
    1196             :                fsp_str_do_log(fsp));
    1197             : 
    1198        1843 :         return result;
    1199             : }
    1200             : 
    1201             : struct smb_full_audit_pread_state {
    1202             :         vfs_handle_struct *handle;
    1203             :         files_struct *fsp;
    1204             :         ssize_t ret;
    1205             :         struct vfs_aio_state vfs_aio_state;
    1206             : };
    1207             : 
    1208             : static void smb_full_audit_pread_done(struct tevent_req *subreq);
    1209             : 
    1210       10026 : static struct tevent_req *smb_full_audit_pread_send(
    1211             :         struct vfs_handle_struct *handle, TALLOC_CTX *mem_ctx,
    1212             :         struct tevent_context *ev, struct files_struct *fsp,
    1213             :         void *data, size_t n, off_t offset)
    1214             : {
    1215           0 :         struct tevent_req *req, *subreq;
    1216           0 :         struct smb_full_audit_pread_state *state;
    1217             : 
    1218       10026 :         req = tevent_req_create(mem_ctx, &state,
    1219             :                                 struct smb_full_audit_pread_state);
    1220       10026 :         if (req == NULL) {
    1221           0 :                 do_log(SMB_VFS_OP_PREAD_SEND, false, handle, "%s",
    1222             :                        fsp_str_do_log(fsp));
    1223           0 :                 return NULL;
    1224             :         }
    1225       10026 :         state->handle = handle;
    1226       10026 :         state->fsp = fsp;
    1227             : 
    1228       10026 :         subreq = SMB_VFS_NEXT_PREAD_SEND(state, ev, handle, fsp, data,
    1229             :                                          n, offset);
    1230       10026 :         if (tevent_req_nomem(subreq, req)) {
    1231           0 :                 do_log(SMB_VFS_OP_PREAD_SEND, false, handle, "%s",
    1232             :                        fsp_str_do_log(fsp));
    1233           0 :                 return tevent_req_post(req, ev);
    1234             :         }
    1235       10026 :         tevent_req_set_callback(subreq, smb_full_audit_pread_done, req);
    1236             : 
    1237       10026 :         do_log(SMB_VFS_OP_PREAD_SEND, true, handle, "%s", fsp_str_do_log(fsp));
    1238       10026 :         return req;
    1239             : }
    1240             : 
    1241       10026 : static void smb_full_audit_pread_done(struct tevent_req *subreq)
    1242             : {
    1243       10026 :         struct tevent_req *req = tevent_req_callback_data(
    1244             :                 subreq, struct tevent_req);
    1245       10026 :         struct smb_full_audit_pread_state *state = tevent_req_data(
    1246             :                 req, struct smb_full_audit_pread_state);
    1247             : 
    1248       10026 :         state->ret = SMB_VFS_PREAD_RECV(subreq, &state->vfs_aio_state);
    1249       10026 :         TALLOC_FREE(subreq);
    1250       10026 :         tevent_req_done(req);
    1251       10026 : }
    1252             : 
    1253       10026 : static ssize_t smb_full_audit_pread_recv(struct tevent_req *req,
    1254             :                                          struct vfs_aio_state *vfs_aio_state)
    1255             : {
    1256       10026 :         struct smb_full_audit_pread_state *state = tevent_req_data(
    1257             :                 req, struct smb_full_audit_pread_state);
    1258             : 
    1259       10026 :         if (tevent_req_is_unix_error(req, &vfs_aio_state->error)) {
    1260           0 :                 do_log(SMB_VFS_OP_PREAD_RECV, false, state->handle, "%s",
    1261           0 :                        fsp_str_do_log(state->fsp));
    1262           0 :                 return -1;
    1263             :         }
    1264             : 
    1265       10026 :         do_log(SMB_VFS_OP_PREAD_RECV, (state->ret >= 0), state->handle, "%s",
    1266       10026 :                fsp_str_do_log(state->fsp));
    1267             : 
    1268       10026 :         *vfs_aio_state = state->vfs_aio_state;
    1269       10026 :         return state->ret;
    1270             : }
    1271             : 
    1272         231 : static ssize_t smb_full_audit_pwrite(vfs_handle_struct *handle, files_struct *fsp,
    1273             :                             const void *data, size_t n,
    1274             :                             off_t offset)
    1275             : {
    1276           0 :         ssize_t result;
    1277             : 
    1278         231 :         result = SMB_VFS_NEXT_PWRITE(handle, fsp, data, n, offset);
    1279             : 
    1280         231 :         do_log(SMB_VFS_OP_PWRITE, (result >= 0), handle, "%s",
    1281             :                fsp_str_do_log(fsp));
    1282             : 
    1283         231 :         return result;
    1284             : }
    1285             : 
    1286             : struct smb_full_audit_pwrite_state {
    1287             :         vfs_handle_struct *handle;
    1288             :         files_struct *fsp;
    1289             :         ssize_t ret;
    1290             :         struct vfs_aio_state vfs_aio_state;
    1291             : };
    1292             : 
    1293             : static void smb_full_audit_pwrite_done(struct tevent_req *subreq);
    1294             : 
    1295      124734 : static struct tevent_req *smb_full_audit_pwrite_send(
    1296             :         struct vfs_handle_struct *handle, TALLOC_CTX *mem_ctx,
    1297             :         struct tevent_context *ev, struct files_struct *fsp,
    1298             :         const void *data, size_t n, off_t offset)
    1299             : {
    1300           0 :         struct tevent_req *req, *subreq;
    1301           0 :         struct smb_full_audit_pwrite_state *state;
    1302             : 
    1303      124734 :         req = tevent_req_create(mem_ctx, &state,
    1304             :                                 struct smb_full_audit_pwrite_state);
    1305      124734 :         if (req == NULL) {
    1306           0 :                 do_log(SMB_VFS_OP_PWRITE_SEND, false, handle, "%s",
    1307             :                        fsp_str_do_log(fsp));
    1308           0 :                 return NULL;
    1309             :         }
    1310      124734 :         state->handle = handle;
    1311      124734 :         state->fsp = fsp;
    1312             : 
    1313      124734 :         subreq = SMB_VFS_NEXT_PWRITE_SEND(state, ev, handle, fsp, data,
    1314             :                                          n, offset);
    1315      124734 :         if (tevent_req_nomem(subreq, req)) {
    1316           0 :                 do_log(SMB_VFS_OP_PWRITE_SEND, false, handle, "%s",
    1317             :                        fsp_str_do_log(fsp));
    1318           0 :                 return tevent_req_post(req, ev);
    1319             :         }
    1320      124734 :         tevent_req_set_callback(subreq, smb_full_audit_pwrite_done, req);
    1321             : 
    1322      124734 :         do_log(SMB_VFS_OP_PWRITE_SEND, true, handle, "%s",
    1323             :                fsp_str_do_log(fsp));
    1324      124734 :         return req;
    1325             : }
    1326             : 
    1327      124734 : static void smb_full_audit_pwrite_done(struct tevent_req *subreq)
    1328             : {
    1329      124734 :         struct tevent_req *req = tevent_req_callback_data(
    1330             :                 subreq, struct tevent_req);
    1331      124734 :         struct smb_full_audit_pwrite_state *state = tevent_req_data(
    1332             :                 req, struct smb_full_audit_pwrite_state);
    1333             : 
    1334      124734 :         state->ret = SMB_VFS_PWRITE_RECV(subreq, &state->vfs_aio_state);
    1335      124734 :         TALLOC_FREE(subreq);
    1336      124734 :         tevent_req_done(req);
    1337      124734 : }
    1338             : 
    1339      124734 : static ssize_t smb_full_audit_pwrite_recv(struct tevent_req *req,
    1340             :                                           struct vfs_aio_state *vfs_aio_state)
    1341             : {
    1342      124734 :         struct smb_full_audit_pwrite_state *state = tevent_req_data(
    1343             :                 req, struct smb_full_audit_pwrite_state);
    1344             : 
    1345      124734 :         if (tevent_req_is_unix_error(req, &vfs_aio_state->error)) {
    1346           0 :                 do_log(SMB_VFS_OP_PWRITE_RECV, false, state->handle, "%s",
    1347           0 :                        fsp_str_do_log(state->fsp));
    1348           0 :                 return -1;
    1349             :         }
    1350             : 
    1351      124734 :         do_log(SMB_VFS_OP_PWRITE_RECV, (state->ret >= 0), state->handle, "%s",
    1352      124734 :                fsp_str_do_log(state->fsp));
    1353             : 
    1354      124734 :         *vfs_aio_state = state->vfs_aio_state;
    1355      124734 :         return state->ret;
    1356             : }
    1357             : 
    1358         387 : static off_t smb_full_audit_lseek(vfs_handle_struct *handle, files_struct *fsp,
    1359             :                              off_t offset, int whence)
    1360             : {
    1361           0 :         ssize_t result;
    1362             : 
    1363         387 :         result = SMB_VFS_NEXT_LSEEK(handle, fsp, offset, whence);
    1364             : 
    1365         387 :         do_log(SMB_VFS_OP_LSEEK, (result != (ssize_t)-1), handle,
    1366             :                "%s", fsp_str_do_log(fsp));
    1367             : 
    1368         387 :         return result;
    1369             : }
    1370             : 
    1371           0 : static ssize_t smb_full_audit_sendfile(vfs_handle_struct *handle, int tofd,
    1372             :                               files_struct *fromfsp,
    1373             :                               const DATA_BLOB *hdr, off_t offset,
    1374             :                               size_t n)
    1375             : {
    1376           0 :         ssize_t result;
    1377             : 
    1378           0 :         result = SMB_VFS_NEXT_SENDFILE(handle, tofd, fromfsp, hdr, offset, n);
    1379             : 
    1380           0 :         do_log(SMB_VFS_OP_SENDFILE, (result >= 0), handle,
    1381             :                "%s", fsp_str_do_log(fromfsp));
    1382             : 
    1383           0 :         return result;
    1384             : }
    1385             : 
    1386           0 : static ssize_t smb_full_audit_recvfile(vfs_handle_struct *handle, int fromfd,
    1387             :                       files_struct *tofsp,
    1388             :                               off_t offset,
    1389             :                               size_t n)
    1390             : {
    1391           0 :         ssize_t result;
    1392             : 
    1393           0 :         result = SMB_VFS_NEXT_RECVFILE(handle, fromfd, tofsp, offset, n);
    1394             : 
    1395           0 :         do_log(SMB_VFS_OP_RECVFILE, (result >= 0), handle,
    1396             :                "%s", fsp_str_do_log(tofsp));
    1397             : 
    1398           0 :         return result;
    1399             : }
    1400             : 
    1401         701 : static int smb_full_audit_renameat(vfs_handle_struct *handle,
    1402             :                                 files_struct *srcfsp,
    1403             :                                 const struct smb_filename *smb_fname_src,
    1404             :                                 files_struct *dstfsp,
    1405             :                                 const struct smb_filename *smb_fname_dst)
    1406             : {
    1407           0 :         int result;
    1408           0 :         int saved_errno;
    1409         701 :         struct smb_filename *full_fname_src = NULL;
    1410         701 :         struct smb_filename *full_fname_dst = NULL;
    1411             : 
    1412         701 :         full_fname_src = full_path_from_dirfsp_atname(talloc_tos(),
    1413             :                                                       srcfsp,
    1414             :                                                       smb_fname_src);
    1415         701 :         if (full_fname_src == NULL) {
    1416           0 :                 errno = ENOMEM;
    1417           0 :                 return -1;
    1418             :         }
    1419         701 :         full_fname_dst = full_path_from_dirfsp_atname(talloc_tos(),
    1420             :                                                       dstfsp,
    1421             :                                                       smb_fname_dst);
    1422         701 :         if (full_fname_dst == NULL) {
    1423           0 :                 TALLOC_FREE(full_fname_src);
    1424           0 :                 errno = ENOMEM;
    1425           0 :                 return -1;
    1426             :         }
    1427             : 
    1428         701 :         result = SMB_VFS_NEXT_RENAMEAT(handle,
    1429             :                                 srcfsp,
    1430             :                                 smb_fname_src,
    1431             :                                 dstfsp,
    1432             :                                 smb_fname_dst);
    1433             : 
    1434         701 :         if (result == -1) {
    1435           0 :                 saved_errno = errno;
    1436             :         }
    1437         701 :         do_log(SMB_VFS_OP_RENAMEAT, (result >= 0), handle, "%s|%s",
    1438             :                smb_fname_str_do_log(handle->conn, full_fname_src),
    1439             :                smb_fname_str_do_log(handle->conn, full_fname_dst));
    1440             : 
    1441         701 :         TALLOC_FREE(full_fname_src);
    1442         701 :         TALLOC_FREE(full_fname_dst);
    1443             : 
    1444         701 :         if (result == -1) {
    1445           0 :                 errno = saved_errno;
    1446             :         }
    1447         701 :         return result;
    1448             : }
    1449             : 
    1450             : struct smb_full_audit_fsync_state {
    1451             :         vfs_handle_struct *handle;
    1452             :         files_struct *fsp;
    1453             :         int ret;
    1454             :         struct vfs_aio_state vfs_aio_state;
    1455             : };
    1456             : 
    1457             : static void smb_full_audit_fsync_done(struct tevent_req *subreq);
    1458             : 
    1459         126 : static struct tevent_req *smb_full_audit_fsync_send(
    1460             :         struct vfs_handle_struct *handle, TALLOC_CTX *mem_ctx,
    1461             :         struct tevent_context *ev, struct files_struct *fsp)
    1462             : {
    1463           0 :         struct tevent_req *req, *subreq;
    1464           0 :         struct smb_full_audit_fsync_state *state;
    1465             : 
    1466         126 :         req = tevent_req_create(mem_ctx, &state,
    1467             :                                 struct smb_full_audit_fsync_state);
    1468         126 :         if (req == NULL) {
    1469           0 :                 do_log(SMB_VFS_OP_FSYNC_SEND, false, handle, "%s",
    1470             :                        fsp_str_do_log(fsp));
    1471           0 :                 return NULL;
    1472             :         }
    1473         126 :         state->handle = handle;
    1474         126 :         state->fsp = fsp;
    1475             : 
    1476         126 :         subreq = SMB_VFS_NEXT_FSYNC_SEND(state, ev, handle, fsp);
    1477         126 :         if (tevent_req_nomem(subreq, req)) {
    1478           0 :                 do_log(SMB_VFS_OP_FSYNC_SEND, false, handle, "%s",
    1479             :                        fsp_str_do_log(fsp));
    1480           0 :                 return tevent_req_post(req, ev);
    1481             :         }
    1482         126 :         tevent_req_set_callback(subreq, smb_full_audit_fsync_done, req);
    1483             : 
    1484         126 :         do_log(SMB_VFS_OP_FSYNC_SEND, true, handle, "%s", fsp_str_do_log(fsp));
    1485         126 :         return req;
    1486             : }
    1487             : 
    1488         126 : static void smb_full_audit_fsync_done(struct tevent_req *subreq)
    1489             : {
    1490         126 :         struct tevent_req *req = tevent_req_callback_data(
    1491             :                 subreq, struct tevent_req);
    1492         126 :         struct smb_full_audit_fsync_state *state = tevent_req_data(
    1493             :                 req, struct smb_full_audit_fsync_state);
    1494             : 
    1495         126 :         state->ret = SMB_VFS_FSYNC_RECV(subreq, &state->vfs_aio_state);
    1496         126 :         TALLOC_FREE(subreq);
    1497         126 :         tevent_req_done(req);
    1498         126 : }
    1499             : 
    1500         126 : static int smb_full_audit_fsync_recv(struct tevent_req *req,
    1501             :                                      struct vfs_aio_state *vfs_aio_state)
    1502             : {
    1503         126 :         struct smb_full_audit_fsync_state *state = tevent_req_data(
    1504             :                 req, struct smb_full_audit_fsync_state);
    1505             : 
    1506         126 :         if (tevent_req_is_unix_error(req, &vfs_aio_state->error)) {
    1507           0 :                 do_log(SMB_VFS_OP_FSYNC_RECV, false, state->handle, "%s",
    1508           0 :                        fsp_str_do_log(state->fsp));
    1509           0 :                 return -1;
    1510             :         }
    1511             : 
    1512         126 :         do_log(SMB_VFS_OP_FSYNC_RECV, (state->ret >= 0), state->handle, "%s",
    1513         126 :                fsp_str_do_log(state->fsp));
    1514             : 
    1515         126 :         *vfs_aio_state = state->vfs_aio_state;
    1516         126 :         return state->ret;
    1517             : }
    1518             : 
    1519     3471030 : static int smb_full_audit_stat(vfs_handle_struct *handle,
    1520             :                                struct smb_filename *smb_fname)
    1521             : {
    1522           0 :         int result;
    1523             : 
    1524     3471030 :         result = SMB_VFS_NEXT_STAT(handle, smb_fname);
    1525             : 
    1526     3471030 :         do_log(SMB_VFS_OP_STAT, (result >= 0), handle, "%s",
    1527             :                smb_fname_str_do_log(handle->conn, smb_fname));
    1528             : 
    1529     3471030 :         return result;
    1530             : }
    1531             : 
    1532    18002663 : static int smb_full_audit_fstat(vfs_handle_struct *handle, files_struct *fsp,
    1533             :                        SMB_STRUCT_STAT *sbuf)
    1534             : {
    1535           0 :         int result;
    1536             : 
    1537    18002663 :         result = SMB_VFS_NEXT_FSTAT(handle, fsp, sbuf);
    1538             : 
    1539    18002663 :         do_log(SMB_VFS_OP_FSTAT, (result >= 0), handle, "%s",
    1540             :                fsp_str_do_log(fsp));
    1541             : 
    1542    18002663 :         return result;
    1543             : }
    1544             : 
    1545        8290 : static int smb_full_audit_lstat(vfs_handle_struct *handle,
    1546             :                                 struct smb_filename *smb_fname)
    1547             : {
    1548           0 :         int result;
    1549             : 
    1550        8290 :         result = SMB_VFS_NEXT_LSTAT(handle, smb_fname);
    1551             : 
    1552        8290 :         do_log(SMB_VFS_OP_LSTAT, (result >= 0), handle, "%s",
    1553             :                smb_fname_str_do_log(handle->conn, smb_fname));
    1554             : 
    1555        8290 :         return result;
    1556             : }
    1557             : 
    1558       37102 : static int smb_full_audit_fstatat(
    1559             :         struct vfs_handle_struct *handle,
    1560             :         const struct files_struct *dirfsp,
    1561             :         const struct smb_filename *smb_fname,
    1562             :         SMB_STRUCT_STAT *sbuf,
    1563             :         int flags)
    1564             : {
    1565           0 :         int result;
    1566             : 
    1567       37102 :         result = SMB_VFS_NEXT_FSTATAT(handle, dirfsp, smb_fname, sbuf, flags);
    1568             : 
    1569       37102 :         do_log(SMB_VFS_OP_FSTATAT,
    1570             :                (result >= 0),
    1571             :                handle,
    1572             :                "%s/%s",
    1573             :                fsp_str_do_log(dirfsp),
    1574             :                smb_fname_str_do_log(handle->conn, smb_fname));
    1575             : 
    1576       37102 :         return result;
    1577             : }
    1578      923598 : static uint64_t smb_full_audit_get_alloc_size(vfs_handle_struct *handle,
    1579             :                        files_struct *fsp, const SMB_STRUCT_STAT *sbuf)
    1580             : {
    1581           0 :         uint64_t result;
    1582             : 
    1583      923598 :         result = SMB_VFS_NEXT_GET_ALLOC_SIZE(handle, fsp, sbuf);
    1584             : 
    1585      923598 :         do_log(SMB_VFS_OP_GET_ALLOC_SIZE, (result != (uint64_t)-1), handle,
    1586             :                         "%llu", (unsigned long long)result);
    1587             : 
    1588      923598 :         return result;
    1589             : }
    1590             : 
    1591       95586 : static int smb_full_audit_unlinkat(vfs_handle_struct *handle,
    1592             :                         struct files_struct *dirfsp,
    1593             :                         const struct smb_filename *smb_fname,
    1594             :                         int flags)
    1595             : {
    1596       95586 :         struct smb_filename *full_fname = NULL;
    1597           0 :         int result;
    1598             : 
    1599       95586 :         full_fname = full_path_from_dirfsp_atname(talloc_tos(),
    1600             :                                                   dirfsp,
    1601             :                                                   smb_fname);
    1602       95586 :         if (full_fname == NULL) {
    1603           0 :                 return -1;
    1604             :         }
    1605             : 
    1606       95586 :         result = SMB_VFS_NEXT_UNLINKAT(handle,
    1607             :                         dirfsp,
    1608             :                         smb_fname,
    1609             :                         flags);
    1610             : 
    1611       95586 :         do_log(SMB_VFS_OP_UNLINKAT, (result >= 0), handle, "%s",
    1612             :                smb_fname_str_do_log(handle->conn, full_fname));
    1613             : 
    1614       95586 :         TALLOC_FREE(full_fname);
    1615       95586 :         return result;
    1616             : }
    1617             : 
    1618          12 : static int smb_full_audit_fchmod(vfs_handle_struct *handle, files_struct *fsp,
    1619             :                         mode_t mode)
    1620             : {
    1621           0 :         int result;
    1622             : 
    1623          12 :         result = SMB_VFS_NEXT_FCHMOD(handle, fsp, mode);
    1624             : 
    1625          12 :         do_log(SMB_VFS_OP_FCHMOD, (result >= 0), handle,
    1626             :                "%s|%o", fsp_str_do_log(fsp), mode);
    1627             : 
    1628          12 :         return result;
    1629             : }
    1630             : 
    1631           0 : static int smb_full_audit_fchown(vfs_handle_struct *handle, files_struct *fsp,
    1632             :                         uid_t uid, gid_t gid)
    1633             : {
    1634           0 :         int result;
    1635             : 
    1636           0 :         result = SMB_VFS_NEXT_FCHOWN(handle, fsp, uid, gid);
    1637             : 
    1638           0 :         do_log(SMB_VFS_OP_FCHOWN, (result >= 0), handle, "%s|%ld|%ld",
    1639             :                fsp_str_do_log(fsp), (long int)uid, (long int)gid);
    1640             : 
    1641           0 :         return result;
    1642             : }
    1643             : 
    1644           0 : static int smb_full_audit_lchown(vfs_handle_struct *handle,
    1645             :                         const struct smb_filename *smb_fname,
    1646             :                         uid_t uid,
    1647             :                         gid_t gid)
    1648             : {
    1649           0 :         int result;
    1650             : 
    1651           0 :         result = SMB_VFS_NEXT_LCHOWN(handle, smb_fname, uid, gid);
    1652             : 
    1653           0 :         do_log(SMB_VFS_OP_LCHOWN, (result >= 0), handle, "%s|%ld|%ld",
    1654           0 :                smb_fname->base_name, (long int)uid, (long int)gid);
    1655             : 
    1656           0 :         return result;
    1657             : }
    1658             : 
    1659     1130625 : static int smb_full_audit_chdir(vfs_handle_struct *handle,
    1660             :                         const struct smb_filename *smb_fname)
    1661             : {
    1662           0 :         int result;
    1663             : 
    1664     1130625 :         result = SMB_VFS_NEXT_CHDIR(handle, smb_fname);
    1665             : 
    1666     1130625 :         do_log(SMB_VFS_OP_CHDIR,
    1667             :                (result >= 0),
    1668             :                handle,
    1669             :                "chdir|%s",
    1670             :                smb_fname_str_do_log(handle->conn, smb_fname));
    1671             : 
    1672     1130625 :         return result;
    1673             : }
    1674             : 
    1675       62884 : static struct smb_filename *smb_full_audit_getwd(vfs_handle_struct *handle,
    1676             :                                 TALLOC_CTX *ctx)
    1677             : {
    1678           0 :         struct smb_filename *result;
    1679             : 
    1680       62884 :         result = SMB_VFS_NEXT_GETWD(handle, ctx);
    1681             : 
    1682       62884 :         do_log(SMB_VFS_OP_GETWD, (result != NULL), handle, "%s",
    1683             :                 result == NULL? "" : result->base_name);
    1684             : 
    1685       62884 :         return result;
    1686             : }
    1687             : 
    1688        7568 : static int smb_full_audit_fntimes(vfs_handle_struct *handle,
    1689             :                                   files_struct *fsp,
    1690             :                                   struct smb_file_time *ft)
    1691             : {
    1692           0 :         int result;
    1693        7568 :         time_t create_time = convert_timespec_to_time_t(ft->create_time);
    1694        7568 :         time_t atime = convert_timespec_to_time_t(ft->atime);
    1695        7568 :         time_t mtime = convert_timespec_to_time_t(ft->mtime);
    1696        7568 :         time_t ctime = convert_timespec_to_time_t(ft->ctime);
    1697        7568 :         const char *create_time_str = "";
    1698        7568 :         const char *atime_str = "";
    1699        7568 :         const char *mtime_str = "";
    1700        7568 :         const char *ctime_str = "";
    1701        7568 :         TALLOC_CTX *frame = talloc_stackframe();
    1702             : 
    1703        7568 :         if (frame == NULL) {
    1704           0 :                 errno = ENOMEM;
    1705           0 :                 return -1;
    1706             :         }
    1707             : 
    1708        7568 :         result = SMB_VFS_NEXT_FNTIMES(handle, fsp, ft);
    1709             : 
    1710        7568 :         if (create_time > 0) {
    1711        7560 :                 create_time_str = timestring(frame, create_time);
    1712             :         }
    1713        7568 :         if (atime > 0) {
    1714        7568 :                 atime_str = timestring(frame, atime);
    1715             :         }
    1716        7568 :         if (mtime > 0) {
    1717        7552 :                 mtime_str = timestring(frame, mtime);
    1718             :         }
    1719        7568 :         if (ctime > 0) {
    1720        7560 :                 ctime_str = timestring(frame, ctime);
    1721             :         }
    1722             : 
    1723        7568 :         do_log(SMB_VFS_OP_FNTIMES,
    1724             :                (result >= 0),
    1725             :                handle,
    1726             :                "%s|%s|%s|%s|%s",
    1727             :                fsp_str_do_log(fsp),
    1728             :                create_time_str,
    1729             :                atime_str,
    1730             :                mtime_str,
    1731             :                ctime_str);
    1732             : 
    1733        7568 :         TALLOC_FREE(frame);
    1734             : 
    1735        7568 :         return result;
    1736             : }
    1737             : 
    1738         488 : static int smb_full_audit_ftruncate(vfs_handle_struct *handle, files_struct *fsp,
    1739             :                            off_t len)
    1740             : {
    1741           0 :         int result;
    1742             : 
    1743         488 :         result = SMB_VFS_NEXT_FTRUNCATE(handle, fsp, len);
    1744             : 
    1745         488 :         do_log(SMB_VFS_OP_FTRUNCATE, (result >= 0), handle,
    1746             :                "%s", fsp_str_do_log(fsp));
    1747             : 
    1748         488 :         return result;
    1749             : }
    1750             : 
    1751         164 : static int smb_full_audit_fallocate(vfs_handle_struct *handle, files_struct *fsp,
    1752             :                            uint32_t mode,
    1753             :                            off_t offset,
    1754             :                            off_t len)
    1755             : {
    1756           0 :         int result;
    1757             : 
    1758         164 :         result = SMB_VFS_NEXT_FALLOCATE(handle, fsp, mode, offset, len);
    1759             : 
    1760         164 :         do_log(SMB_VFS_OP_FALLOCATE, (result >= 0), handle,
    1761             :                "%s", fsp_str_do_log(fsp));
    1762             : 
    1763         164 :         return result;
    1764             : }
    1765             : 
    1766        4084 : static bool smb_full_audit_lock(vfs_handle_struct *handle, files_struct *fsp,
    1767             :                        int op, off_t offset, off_t count, int type)
    1768             : {
    1769           0 :         bool result;
    1770             : 
    1771        4084 :         result = SMB_VFS_NEXT_LOCK(handle, fsp, op, offset, count, type);
    1772             : 
    1773        4084 :         do_log(SMB_VFS_OP_LOCK, result, handle, "%s", fsp_str_do_log(fsp));
    1774             : 
    1775        4084 :         return result;
    1776             : }
    1777             : 
    1778           0 : static int smb_full_audit_filesystem_sharemode(struct vfs_handle_struct *handle,
    1779             :                                                struct files_struct *fsp,
    1780             :                                                uint32_t share_access,
    1781             :                                                uint32_t access_mask)
    1782             : {
    1783           0 :         int result;
    1784             : 
    1785           0 :         result = SMB_VFS_NEXT_FILESYSTEM_SHAREMODE(handle,
    1786             :                                                    fsp,
    1787             :                                                    share_access,
    1788             :                                                    access_mask);
    1789             : 
    1790           0 :         do_log(SMB_VFS_OP_FILESYSTEM_SHAREMODE, (result >= 0), handle, "%s",
    1791             :                fsp_str_do_log(fsp));
    1792             : 
    1793           0 :         return result;
    1794             : }
    1795             : 
    1796      212134 : static int smb_full_audit_fcntl(struct vfs_handle_struct *handle,
    1797             :                                 struct files_struct *fsp,
    1798             :                                 int cmd, va_list cmd_arg)
    1799             : {
    1800           0 :         void *arg;
    1801           0 :         va_list dup_cmd_arg;
    1802           0 :         int result;
    1803             : 
    1804      212134 :         va_copy(dup_cmd_arg, cmd_arg);
    1805      212134 :         arg = va_arg(dup_cmd_arg, void *);
    1806      212134 :         result = SMB_VFS_NEXT_FCNTL(handle, fsp, cmd, arg);
    1807      212134 :         va_end(dup_cmd_arg);
    1808             : 
    1809      212134 :         do_log(SMB_VFS_OP_FCNTL, (result >= 0), handle, "%s",
    1810             :                fsp_str_do_log(fsp));
    1811             : 
    1812      212134 :         return result;
    1813             : }
    1814             : 
    1815           0 : static int smb_full_audit_linux_setlease(vfs_handle_struct *handle, files_struct *fsp,
    1816             :                                  int leasetype)
    1817             : {
    1818           0 :         int result;
    1819             : 
    1820           0 :         result = SMB_VFS_NEXT_LINUX_SETLEASE(handle, fsp, leasetype);
    1821             : 
    1822           0 :         do_log(SMB_VFS_OP_LINUX_SETLEASE, (result >= 0), handle, "%s",
    1823             :                fsp_str_do_log(fsp));
    1824             : 
    1825           0 :         return result;
    1826             : }
    1827             : 
    1828      134784 : static bool smb_full_audit_getlock(vfs_handle_struct *handle, files_struct *fsp,
    1829             :                        off_t *poffset, off_t *pcount, int *ptype, pid_t *ppid)
    1830             : {
    1831           0 :         bool result;
    1832             : 
    1833      134784 :         result = SMB_VFS_NEXT_GETLOCK(handle, fsp, poffset, pcount, ptype, ppid);
    1834             : 
    1835      134784 :         do_log(SMB_VFS_OP_GETLOCK, result, handle, "%s", fsp_str_do_log(fsp));
    1836             : 
    1837      134784 :         return result;
    1838             : }
    1839             : 
    1840          16 : static int smb_full_audit_symlinkat(vfs_handle_struct *handle,
    1841             :                         const struct smb_filename *link_contents,
    1842             :                         struct files_struct *dirfsp,
    1843             :                         const struct smb_filename *new_smb_fname)
    1844             : {
    1845          16 :         struct smb_filename *full_fname = NULL;
    1846           0 :         int result;
    1847             : 
    1848          16 :         full_fname = full_path_from_dirfsp_atname(talloc_tos(),
    1849             :                                                 dirfsp,
    1850             :                                                 new_smb_fname);
    1851          16 :         if (full_fname == NULL) {
    1852           0 :                 return -1;
    1853             :         }
    1854             : 
    1855          16 :         result = SMB_VFS_NEXT_SYMLINKAT(handle,
    1856             :                                 link_contents,
    1857             :                                 dirfsp,
    1858             :                                 new_smb_fname);
    1859             : 
    1860          16 :         do_log(SMB_VFS_OP_SYMLINKAT,
    1861             :                (result >= 0),
    1862             :                handle,
    1863             :                "%s|%s",
    1864          16 :                link_contents->base_name,
    1865             :                smb_fname_str_do_log(handle->conn, full_fname));
    1866             : 
    1867          16 :         TALLOC_FREE(full_fname);
    1868             : 
    1869          16 :         return result;
    1870             : }
    1871             : 
    1872       71410 : static int smb_full_audit_readlinkat(vfs_handle_struct *handle,
    1873             :                         const struct files_struct *dirfsp,
    1874             :                         const struct smb_filename *smb_fname,
    1875             :                         char *buf,
    1876             :                         size_t bufsiz)
    1877             : {
    1878       71410 :         struct smb_filename *full_fname = NULL;
    1879           0 :         int result;
    1880             : 
    1881       71410 :         full_fname = full_path_from_dirfsp_atname(talloc_tos(),
    1882             :                                                 dirfsp,
    1883             :                                                 smb_fname);
    1884       71410 :         if (full_fname == NULL) {
    1885           0 :                 return -1;
    1886             :         }
    1887             : 
    1888       71410 :         result = SMB_VFS_NEXT_READLINKAT(handle,
    1889             :                         dirfsp,
    1890             :                         smb_fname,
    1891             :                         buf,
    1892             :                         bufsiz);
    1893             : 
    1894       71410 :         do_log(SMB_VFS_OP_READLINKAT,
    1895             :                (result >= 0),
    1896             :                handle,
    1897             :                "%s",
    1898             :                smb_fname_str_do_log(handle->conn, full_fname));
    1899             : 
    1900       71410 :         TALLOC_FREE(full_fname);
    1901             : 
    1902       71410 :         return result;
    1903             : }
    1904             : 
    1905          33 : static int smb_full_audit_linkat(vfs_handle_struct *handle,
    1906             :                         files_struct *srcfsp,
    1907             :                         const struct smb_filename *old_smb_fname,
    1908             :                         files_struct *dstfsp,
    1909             :                         const struct smb_filename *new_smb_fname,
    1910             :                         int flags)
    1911             : {
    1912          33 :         struct smb_filename *old_full_fname = NULL;
    1913          33 :         struct smb_filename *new_full_fname = NULL;
    1914           0 :         int result;
    1915             : 
    1916          33 :         old_full_fname = full_path_from_dirfsp_atname(talloc_tos(),
    1917             :                                                 srcfsp,
    1918             :                                                 old_smb_fname);
    1919          33 :         if (old_full_fname == NULL) {
    1920           0 :                 return -1;
    1921             :         }
    1922          33 :         new_full_fname = full_path_from_dirfsp_atname(talloc_tos(),
    1923             :                                                 dstfsp,
    1924             :                                                 new_smb_fname);
    1925          33 :         if (new_full_fname == NULL) {
    1926           0 :                 TALLOC_FREE(old_full_fname);
    1927           0 :                 return -1;
    1928             :         }
    1929          33 :         result = SMB_VFS_NEXT_LINKAT(handle,
    1930             :                         srcfsp,
    1931             :                         old_smb_fname,
    1932             :                         dstfsp,
    1933             :                         new_smb_fname,
    1934             :                         flags);
    1935             : 
    1936          33 :         do_log(SMB_VFS_OP_LINKAT,
    1937             :                (result >= 0),
    1938             :                handle,
    1939             :                "%s|%s",
    1940             :                smb_fname_str_do_log(handle->conn, old_full_fname),
    1941             :                smb_fname_str_do_log(handle->conn, new_full_fname));
    1942             : 
    1943          33 :         TALLOC_FREE(old_full_fname);
    1944          33 :         TALLOC_FREE(new_full_fname);
    1945             : 
    1946          33 :         return result;
    1947             : }
    1948             : 
    1949           0 : static int smb_full_audit_mknodat(vfs_handle_struct *handle,
    1950             :                         files_struct *dirfsp,
    1951             :                         const struct smb_filename *smb_fname,
    1952             :                         mode_t mode,
    1953             :                         SMB_DEV_T dev)
    1954             : {
    1955           0 :         struct smb_filename *full_fname = NULL;
    1956           0 :         int result;
    1957             : 
    1958           0 :         full_fname = full_path_from_dirfsp_atname(talloc_tos(),
    1959             :                                                 dirfsp,
    1960             :                                                 smb_fname);
    1961           0 :         if (full_fname == NULL) {
    1962           0 :                 return -1;
    1963             :         }
    1964             : 
    1965           0 :         result = SMB_VFS_NEXT_MKNODAT(handle,
    1966             :                                 dirfsp,
    1967             :                                 smb_fname,
    1968             :                                 mode,
    1969             :                                 dev);
    1970             : 
    1971           0 :         do_log(SMB_VFS_OP_MKNODAT,
    1972             :                (result >= 0),
    1973             :                handle,
    1974             :                "%s",
    1975             :                smb_fname_str_do_log(handle->conn, full_fname));
    1976             : 
    1977           0 :         TALLOC_FREE(full_fname);
    1978             : 
    1979           0 :         return result;
    1980             : }
    1981             : 
    1982     2300869 : static struct smb_filename *smb_full_audit_realpath(vfs_handle_struct *handle,
    1983             :                                 TALLOC_CTX *ctx,
    1984             :                                 const struct smb_filename *smb_fname)
    1985             : {
    1986     2300869 :         struct smb_filename *result_fname = NULL;
    1987             : 
    1988     2300869 :         result_fname = SMB_VFS_NEXT_REALPATH(handle, ctx, smb_fname);
    1989             : 
    1990     2300869 :         do_log(SMB_VFS_OP_REALPATH,
    1991             :                (result_fname != NULL),
    1992             :                handle,
    1993             :                "%s",
    1994             :                smb_fname_str_do_log(handle->conn, smb_fname));
    1995             : 
    1996     2300869 :         return result_fname;
    1997             : }
    1998             : 
    1999           0 : static int smb_full_audit_fchflags(vfs_handle_struct *handle,
    2000             :                         struct files_struct *fsp,
    2001             :                         unsigned int flags)
    2002             : {
    2003           0 :         int result;
    2004             : 
    2005           0 :         result = SMB_VFS_NEXT_FCHFLAGS(handle, fsp, flags);
    2006             : 
    2007           0 :         do_log(SMB_VFS_OP_FCHFLAGS,
    2008             :                (result != 0),
    2009             :                handle,
    2010             :                "%s",
    2011           0 :                smb_fname_str_do_log(handle->conn, fsp->fsp_name));
    2012             : 
    2013           0 :         return result;
    2014             : }
    2015             : 
    2016    19404876 : static struct file_id smb_full_audit_file_id_create(struct vfs_handle_struct *handle,
    2017             :                                                     const SMB_STRUCT_STAT *sbuf)
    2018             : {
    2019    19404876 :         struct file_id id_zero = { 0 };
    2020           0 :         struct file_id result;
    2021           0 :         struct file_id_buf idbuf;
    2022             : 
    2023    19404876 :         result = SMB_VFS_NEXT_FILE_ID_CREATE(handle, sbuf);
    2024             : 
    2025    19404876 :         do_log(SMB_VFS_OP_FILE_ID_CREATE,
    2026    19404876 :                !file_id_equal(&id_zero, &result),
    2027             :                handle,
    2028             :                "%s",
    2029    19404876 :                file_id_str_buf(result, &idbuf));
    2030             : 
    2031    19404876 :         return result;
    2032             : }
    2033             : 
    2034      455721 : static uint64_t smb_full_audit_fs_file_id(struct vfs_handle_struct *handle,
    2035             :                                           const SMB_STRUCT_STAT *sbuf)
    2036             : {
    2037           0 :         uint64_t result;
    2038             : 
    2039      455721 :         result = SMB_VFS_NEXT_FS_FILE_ID(handle, sbuf);
    2040             : 
    2041      455721 :         do_log(SMB_VFS_OP_FS_FILE_ID,
    2042             :                result != 0,
    2043             :                handle, "%" PRIu64, result);
    2044             : 
    2045      455721 :         return result;
    2046             : }
    2047             : 
    2048      198672 : static NTSTATUS smb_full_audit_fstreaminfo(vfs_handle_struct *handle,
    2049             :                                           struct files_struct *fsp,
    2050             :                                           TALLOC_CTX *mem_ctx,
    2051             :                                           unsigned int *pnum_streams,
    2052             :                                           struct stream_struct **pstreams)
    2053             : {
    2054           0 :         NTSTATUS result;
    2055             : 
    2056      198672 :         result = SMB_VFS_NEXT_FSTREAMINFO(handle, fsp, mem_ctx,
    2057             :                                          pnum_streams, pstreams);
    2058             : 
    2059      397344 :         do_log(SMB_VFS_OP_FSTREAMINFO,
    2060      198672 :                NT_STATUS_IS_OK(result),
    2061             :                handle,
    2062             :                "%s",
    2063      198672 :                smb_fname_str_do_log(handle->conn, fsp->fsp_name));
    2064             : 
    2065      198672 :         return result;
    2066             : }
    2067             : 
    2068      151547 : static NTSTATUS smb_full_audit_get_real_filename_at(
    2069             :         struct vfs_handle_struct *handle,
    2070             :         struct files_struct *dirfsp,
    2071             :         const char *name,
    2072             :         TALLOC_CTX *mem_ctx,
    2073             :         char **found_name)
    2074             : {
    2075           0 :         NTSTATUS result;
    2076             : 
    2077      151547 :         result = SMB_VFS_NEXT_GET_REAL_FILENAME_AT(
    2078             :                 handle, dirfsp, name, mem_ctx, found_name);
    2079             : 
    2080      151547 :         do_log(SMB_VFS_OP_GET_REAL_FILENAME_AT,
    2081      151547 :                NT_STATUS_IS_OK(result),
    2082             :                handle,
    2083             :                "%s/%s->%s",
    2084             :                fsp_str_dbg(dirfsp),
    2085             :                name,
    2086      151547 :                NT_STATUS_IS_OK(result) ? *found_name : "");
    2087             : 
    2088      151547 :         return result;
    2089             : }
    2090             : 
    2091     2489003 : static const char *smb_full_audit_connectpath(
    2092             :         vfs_handle_struct *handle,
    2093             :         const struct files_struct *dirfsp,
    2094             :         const struct smb_filename *smb_fname)
    2095             : {
    2096           0 :         const char *result;
    2097             : 
    2098     2489003 :         result = SMB_VFS_NEXT_CONNECTPATH(handle, dirfsp, smb_fname);
    2099             : 
    2100     2489003 :         do_log(SMB_VFS_OP_CONNECTPATH,
    2101             :                result != NULL,
    2102             :                handle,
    2103             :                "%s",
    2104             :                smb_fname_str_do_log(handle->conn, smb_fname));
    2105             : 
    2106     2489003 :         return result;
    2107             : }
    2108             : 
    2109        5630 : static NTSTATUS smb_full_audit_brl_lock_windows(struct vfs_handle_struct *handle,
    2110             :                                                 struct byte_range_lock *br_lck,
    2111             :                                                 struct lock_struct *plock)
    2112             : {
    2113           0 :         NTSTATUS result;
    2114             : 
    2115        5630 :         result = SMB_VFS_NEXT_BRL_LOCK_WINDOWS(handle, br_lck, plock);
    2116             : 
    2117        5630 :         do_log(SMB_VFS_OP_BRL_LOCK_WINDOWS, NT_STATUS_IS_OK(result), handle,
    2118             :             "%s:%llu-%llu. type=%d.",
    2119        5630 :                fsp_str_do_log(brl_fsp(br_lck)),
    2120        5630 :                (unsigned long long)plock->start,
    2121        5630 :                (unsigned long long)plock->size,
    2122        5630 :                plock->lock_type);
    2123             : 
    2124        5630 :         return result;
    2125             : }
    2126             : 
    2127        2778 : static bool smb_full_audit_brl_unlock_windows(struct vfs_handle_struct *handle,
    2128             :                                               struct byte_range_lock *br_lck,
    2129             :                                               const struct lock_struct *plock)
    2130             : {
    2131           0 :         bool result;
    2132             : 
    2133        2778 :         result = SMB_VFS_NEXT_BRL_UNLOCK_WINDOWS(handle, br_lck, plock);
    2134             : 
    2135        2778 :         do_log(SMB_VFS_OP_BRL_UNLOCK_WINDOWS, (result == 0), handle,
    2136        2778 :                "%s:%llu-%llu:%d", fsp_str_do_log(brl_fsp(br_lck)),
    2137        2778 :                (unsigned long long)plock->start,
    2138        2778 :                (unsigned long long)plock->size,
    2139        5556 :                plock->lock_type);
    2140             : 
    2141        2778 :         return result;
    2142             : }
    2143             : 
    2144      135883 : static bool smb_full_audit_strict_lock_check(struct vfs_handle_struct *handle,
    2145             :                                              struct files_struct *fsp,
    2146             :                                              struct lock_struct *plock)
    2147             : {
    2148           0 :         bool result;
    2149             : 
    2150      135883 :         result = SMB_VFS_NEXT_STRICT_LOCK_CHECK(handle, fsp, plock);
    2151             : 
    2152      135883 :         do_log(SMB_VFS_OP_STRICT_LOCK_CHECK, result, handle,
    2153             :                "%s:%llu-%llu:%d", fsp_str_do_log(fsp),
    2154      135883 :                (unsigned long long)plock->start,
    2155      135883 :                (unsigned long long)plock->size,
    2156      135883 :                plock->lock_type);
    2157             : 
    2158      135883 :         return result;
    2159             : }
    2160             : 
    2161   104750408 : static NTSTATUS smb_full_audit_translate_name(struct vfs_handle_struct *handle,
    2162             :                                               const char *name,
    2163             :                                               enum vfs_translate_direction direction,
    2164             :                                               TALLOC_CTX *mem_ctx,
    2165             :                                               char **mapped_name)
    2166             : {
    2167           0 :         NTSTATUS result;
    2168             : 
    2169   104750408 :         result = SMB_VFS_NEXT_TRANSLATE_NAME(handle, name, direction, mem_ctx,
    2170             :                                              mapped_name);
    2171             : 
    2172   104750408 :         do_log(SMB_VFS_OP_TRANSLATE_NAME, NT_STATUS_IS_OK(result), handle, "");
    2173             : 
    2174   104750408 :         return result;
    2175             : }
    2176             : 
    2177     2640406 : static NTSTATUS smb_full_audit_parent_pathname(struct vfs_handle_struct *handle,
    2178             :                                                TALLOC_CTX *mem_ctx,
    2179             :                                                const struct smb_filename *smb_fname_in,
    2180             :                                                struct smb_filename **parent_dir_out,
    2181             :                                                struct smb_filename **atname_out)
    2182             : {
    2183           0 :         NTSTATUS result;
    2184             : 
    2185     2640406 :         result = SMB_VFS_NEXT_PARENT_PATHNAME(handle,
    2186             :                                               mem_ctx,
    2187             :                                               smb_fname_in,
    2188             :                                               parent_dir_out,
    2189             :                                               atname_out);
    2190     2640406 :         do_log(SMB_VFS_OP_CONNECTPATH,
    2191     2640406 :                NT_STATUS_IS_OK(result),
    2192             :                handle,
    2193             :                "%s",
    2194             :                smb_fname_str_do_log(handle->conn, smb_fname_in));
    2195             : 
    2196     2640406 :         return result;
    2197             : }
    2198             : 
    2199         545 : static NTSTATUS smb_full_audit_fsctl(struct vfs_handle_struct *handle,
    2200             :                                 struct files_struct *fsp,
    2201             :                                 TALLOC_CTX *ctx,
    2202             :                                 uint32_t function,
    2203             :                                 uint16_t req_flags,
    2204             :                                 const uint8_t *_in_data,
    2205             :                                 uint32_t in_len,
    2206             :                                 uint8_t **_out_data,
    2207             :                                 uint32_t max_out_len,
    2208             :                                 uint32_t *out_len)
    2209             : {
    2210           0 :         NTSTATUS result;
    2211             : 
    2212         545 :         result = SMB_VFS_NEXT_FSCTL(handle,
    2213             :                                 fsp,
    2214             :                                 ctx,
    2215             :                                 function,
    2216             :                                 req_flags,
    2217             :                                 _in_data,
    2218             :                                 in_len,
    2219             :                                 _out_data,
    2220             :                                 max_out_len,
    2221             :                                 out_len);
    2222             : 
    2223         545 :         do_log(SMB_VFS_OP_FSCTL, NT_STATUS_IS_OK(result), handle, "");
    2224             : 
    2225         545 :         return result;
    2226             : }
    2227             : 
    2228         210 : static struct tevent_req *smb_full_audit_offload_read_send(
    2229             :         TALLOC_CTX *mem_ctx,
    2230             :         struct tevent_context *ev,
    2231             :         struct vfs_handle_struct *handle,
    2232             :         struct files_struct *fsp,
    2233             :         uint32_t fsctl,
    2234             :         uint32_t ttl,
    2235             :         off_t offset,
    2236             :         size_t to_copy)
    2237             : {
    2238         210 :         struct tevent_req *req = NULL;
    2239             : 
    2240         210 :         req = SMB_VFS_NEXT_OFFLOAD_READ_SEND(mem_ctx, ev, handle, fsp,
    2241             :                                              fsctl, ttl, offset, to_copy);
    2242             : 
    2243         210 :         do_log(SMB_VFS_OP_OFFLOAD_READ_SEND, req, handle, "");
    2244             : 
    2245         210 :         return req;
    2246             : }
    2247             : 
    2248         210 : static NTSTATUS smb_full_audit_offload_read_recv(
    2249             :         struct tevent_req *req,
    2250             :         struct vfs_handle_struct *handle,
    2251             :         TALLOC_CTX *mem_ctx,
    2252             :         uint32_t *flags,
    2253             :         uint64_t *xferlen,
    2254             :         DATA_BLOB *_token_blob)
    2255             : {
    2256           0 :         NTSTATUS status;
    2257             : 
    2258         210 :         status = SMB_VFS_NEXT_OFFLOAD_READ_RECV(req, handle, mem_ctx,
    2259             :                                                 flags, xferlen, _token_blob);
    2260             : 
    2261         210 :         do_log(SMB_VFS_OP_OFFLOAD_READ_RECV, NT_STATUS_IS_OK(status), handle, "");
    2262             : 
    2263         210 :         return status;
    2264             : }
    2265             : 
    2266         238 : static struct tevent_req *smb_full_audit_offload_write_send(struct vfs_handle_struct *handle,
    2267             :                                                          TALLOC_CTX *mem_ctx,
    2268             :                                                          struct tevent_context *ev,
    2269             :                                                          uint32_t fsctl,
    2270             :                                                          DATA_BLOB *token,
    2271             :                                                          off_t transfer_offset,
    2272             :                                                          struct files_struct *dest_fsp,
    2273             :                                                          off_t dest_off,
    2274             :                                                             off_t num)
    2275             : {
    2276           0 :         struct tevent_req *req;
    2277             : 
    2278         238 :         req = SMB_VFS_NEXT_OFFLOAD_WRITE_SEND(handle, mem_ctx, ev,
    2279             :                                            fsctl, token, transfer_offset,
    2280             :                                            dest_fsp, dest_off, num);
    2281             : 
    2282         238 :         do_log(SMB_VFS_OP_OFFLOAD_WRITE_SEND, req, handle, "");
    2283             : 
    2284         238 :         return req;
    2285             : }
    2286             : 
    2287         238 : static NTSTATUS smb_full_audit_offload_write_recv(struct vfs_handle_struct *handle,
    2288             :                                                struct tevent_req *req,
    2289             :                                                off_t *copied)
    2290             : {
    2291           0 :         NTSTATUS result;
    2292             : 
    2293         238 :         result = SMB_VFS_NEXT_OFFLOAD_WRITE_RECV(handle, req, copied);
    2294             : 
    2295         238 :         do_log(SMB_VFS_OP_OFFLOAD_WRITE_RECV, NT_STATUS_IS_OK(result), handle, "");
    2296             : 
    2297         238 :         return result;
    2298             : }
    2299             : 
    2300           0 : static NTSTATUS smb_full_audit_fget_compression(vfs_handle_struct *handle,
    2301             :                                                TALLOC_CTX *mem_ctx,
    2302             :                                                struct files_struct *fsp,
    2303             :                                                uint16_t *_compression_fmt)
    2304             : {
    2305           0 :         NTSTATUS result;
    2306             : 
    2307           0 :         result = SMB_VFS_NEXT_FGET_COMPRESSION(handle, mem_ctx, fsp,
    2308             :                                               _compression_fmt);
    2309             : 
    2310           0 :         do_log(SMB_VFS_OP_FGET_COMPRESSION, NT_STATUS_IS_OK(result), handle,
    2311             :                "%s",
    2312             :                fsp_str_do_log(fsp));
    2313             : 
    2314           0 :         return result;
    2315             : }
    2316             : 
    2317           0 : static NTSTATUS smb_full_audit_set_compression(vfs_handle_struct *handle,
    2318             :                                                TALLOC_CTX *mem_ctx,
    2319             :                                                struct files_struct *fsp,
    2320             :                                                uint16_t compression_fmt)
    2321             : {
    2322           0 :         NTSTATUS result;
    2323             : 
    2324           0 :         result = SMB_VFS_NEXT_SET_COMPRESSION(handle, mem_ctx, fsp,
    2325             :                                               compression_fmt);
    2326             : 
    2327           0 :         do_log(SMB_VFS_OP_SET_COMPRESSION, NT_STATUS_IS_OK(result), handle,
    2328             :                "%s", fsp_str_do_log(fsp));
    2329             : 
    2330           0 :         return result;
    2331             : }
    2332             : 
    2333      446965 : static NTSTATUS smb_full_audit_freaddir_attr(struct vfs_handle_struct *handle,
    2334             :                                         struct files_struct *fsp,
    2335             :                                         TALLOC_CTX *mem_ctx,
    2336             :                                         struct readdir_attr_data **pattr_data)
    2337             : {
    2338           0 :         NTSTATUS status;
    2339             : 
    2340      446965 :         status = SMB_VFS_NEXT_FREADDIR_ATTR(handle, fsp, mem_ctx, pattr_data);
    2341             : 
    2342      446965 :         do_log(SMB_VFS_OP_FREADDIR_ATTR,
    2343      446965 :                NT_STATUS_IS_OK(status),
    2344             :                handle,
    2345             :                "%s",
    2346             :                fsp_str_do_log(fsp));
    2347             : 
    2348      446965 :         return status;
    2349             : }
    2350             : 
    2351             : struct smb_full_audit_get_dos_attributes_state {
    2352             :         struct vfs_aio_state aio_state;
    2353             :         vfs_handle_struct *handle;
    2354             :         files_struct *dir_fsp;
    2355             :         const struct smb_filename *smb_fname;
    2356             :         uint32_t dosmode;
    2357             : };
    2358             : 
    2359             : static void smb_full_audit_get_dos_attributes_done(struct tevent_req *subreq);
    2360             : 
    2361           0 : static struct tevent_req *smb_full_audit_get_dos_attributes_send(
    2362             :                 TALLOC_CTX *mem_ctx,
    2363             :                 struct tevent_context *ev,
    2364             :                 struct vfs_handle_struct *handle,
    2365             :                 files_struct *dir_fsp,
    2366             :                 struct smb_filename *smb_fname)
    2367             : {
    2368           0 :         struct tevent_req *req = NULL;
    2369           0 :         struct smb_full_audit_get_dos_attributes_state *state = NULL;
    2370           0 :         struct tevent_req *subreq = NULL;
    2371             : 
    2372           0 :         req = tevent_req_create(mem_ctx, &state,
    2373             :                                 struct smb_full_audit_get_dos_attributes_state);
    2374           0 :         if (req == NULL) {
    2375           0 :                 do_log(SMB_VFS_OP_GET_DOS_ATTRIBUTES_SEND,
    2376             :                        false,
    2377             :                        handle,
    2378             :                        "%s/%s",
    2379             :                        fsp_str_do_log(dir_fsp),
    2380             :                        smb_fname->base_name);
    2381           0 :                 return NULL;
    2382             :         }
    2383           0 :         *state = (struct smb_full_audit_get_dos_attributes_state) {
    2384             :                 .handle = handle,
    2385             :                 .dir_fsp = dir_fsp,
    2386             :                 .smb_fname = smb_fname,
    2387             :         };
    2388             : 
    2389           0 :         subreq = SMB_VFS_NEXT_GET_DOS_ATTRIBUTES_SEND(mem_ctx,
    2390             :                                                       ev,
    2391             :                                                       handle,
    2392             :                                                       dir_fsp,
    2393             :                                                       smb_fname);
    2394           0 :         if (tevent_req_nomem(subreq, req)) {
    2395           0 :                 do_log(SMB_VFS_OP_GET_DOS_ATTRIBUTES_SEND,
    2396             :                        false,
    2397             :                        handle,
    2398             :                        "%s/%s",
    2399             :                        fsp_str_do_log(dir_fsp),
    2400             :                        smb_fname->base_name);
    2401           0 :                 return tevent_req_post(req, ev);
    2402             :         }
    2403           0 :         tevent_req_set_callback(subreq,
    2404             :                                 smb_full_audit_get_dos_attributes_done,
    2405             :                                 req);
    2406             : 
    2407           0 :         do_log(SMB_VFS_OP_GET_DOS_ATTRIBUTES_SEND,
    2408             :                true,
    2409             :                handle,
    2410             :                "%s/%s",
    2411             :                fsp_str_do_log(dir_fsp),
    2412             :                smb_fname->base_name);
    2413             : 
    2414           0 :         return req;
    2415             : }
    2416             : 
    2417           0 : static void smb_full_audit_get_dos_attributes_done(struct tevent_req *subreq)
    2418             : {
    2419           0 :         struct tevent_req *req =
    2420           0 :                 tevent_req_callback_data(subreq,
    2421             :                 struct tevent_req);
    2422           0 :         struct smb_full_audit_get_dos_attributes_state *state =
    2423           0 :                 tevent_req_data(req,
    2424             :                 struct smb_full_audit_get_dos_attributes_state);
    2425           0 :         NTSTATUS status;
    2426             : 
    2427           0 :         status = SMB_VFS_NEXT_GET_DOS_ATTRIBUTES_RECV(subreq,
    2428             :                                                       &state->aio_state,
    2429             :                                                       &state->dosmode);
    2430           0 :         TALLOC_FREE(subreq);
    2431           0 :         if (tevent_req_nterror(req, status)) {
    2432           0 :                 return;
    2433             :         }
    2434             : 
    2435           0 :         tevent_req_done(req);
    2436           0 :         return;
    2437             : }
    2438             : 
    2439           0 : static NTSTATUS smb_full_audit_get_dos_attributes_recv(struct tevent_req *req,
    2440             :                                                 struct vfs_aio_state *aio_state,
    2441             :                                                 uint32_t *dosmode)
    2442             : {
    2443           0 :         struct smb_full_audit_get_dos_attributes_state *state =
    2444           0 :                 tevent_req_data(req,
    2445             :                 struct smb_full_audit_get_dos_attributes_state);
    2446           0 :         NTSTATUS status;
    2447             : 
    2448           0 :         if (tevent_req_is_nterror(req, &status)) {
    2449           0 :                 do_log(SMB_VFS_OP_GET_DOS_ATTRIBUTES_RECV,
    2450             :                        false,
    2451             :                        state->handle,
    2452             :                        "%s/%s",
    2453           0 :                        fsp_str_do_log(state->dir_fsp),
    2454           0 :                        state->smb_fname->base_name);
    2455           0 :                 tevent_req_received(req);
    2456           0 :                 return status;
    2457             :         }
    2458             : 
    2459           0 :         do_log(SMB_VFS_OP_GET_DOS_ATTRIBUTES_RECV,
    2460             :                true,
    2461             :                state->handle,
    2462             :                "%s/%s",
    2463           0 :                fsp_str_do_log(state->dir_fsp),
    2464           0 :                state->smb_fname->base_name);
    2465             : 
    2466           0 :         *aio_state = state->aio_state;
    2467           0 :         *dosmode = state->dosmode;
    2468           0 :         tevent_req_received(req);
    2469           0 :         return NT_STATUS_OK;
    2470             : }
    2471             : 
    2472      766594 : static NTSTATUS smb_full_audit_fget_dos_attributes(
    2473             :                                 struct vfs_handle_struct *handle,
    2474             :                                 struct files_struct *fsp,
    2475             :                                 uint32_t *dosmode)
    2476             : {
    2477           0 :         NTSTATUS status;
    2478             : 
    2479      766594 :         status = SMB_VFS_NEXT_FGET_DOS_ATTRIBUTES(handle,
    2480             :                                 fsp,
    2481             :                                 dosmode);
    2482             : 
    2483      766594 :         do_log(SMB_VFS_OP_FGET_DOS_ATTRIBUTES,
    2484      766594 :                 NT_STATUS_IS_OK(status),
    2485             :                 handle,
    2486             :                 "%s",
    2487             :                 fsp_str_do_log(fsp));
    2488             : 
    2489      766594 :         return status;
    2490             : }
    2491             : 
    2492       97827 : static NTSTATUS smb_full_audit_fset_dos_attributes(
    2493             :                                 struct vfs_handle_struct *handle,
    2494             :                                 struct files_struct *fsp,
    2495             :                                 uint32_t dosmode)
    2496             : {
    2497           0 :         NTSTATUS status;
    2498             : 
    2499       97827 :         status = SMB_VFS_NEXT_FSET_DOS_ATTRIBUTES(handle,
    2500             :                                 fsp,
    2501             :                                 dosmode);
    2502             : 
    2503       97827 :         do_log(SMB_VFS_OP_FSET_DOS_ATTRIBUTES,
    2504       97827 :                 NT_STATUS_IS_OK(status),
    2505             :                 handle,
    2506             :                 "%s",
    2507             :                 fsp_str_do_log(fsp));
    2508             : 
    2509       97827 :         return status;
    2510             : }
    2511             : 
    2512      226386 : static NTSTATUS smb_full_audit_fget_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
    2513             :                                            uint32_t security_info,
    2514             :                                            TALLOC_CTX *mem_ctx,
    2515             :                                            struct security_descriptor **ppdesc)
    2516             : {
    2517           0 :         NTSTATUS result;
    2518             : 
    2519      226386 :         result = SMB_VFS_NEXT_FGET_NT_ACL(handle, fsp, security_info,
    2520             :                                           mem_ctx, ppdesc);
    2521             : 
    2522      226386 :         do_log(SMB_VFS_OP_FGET_NT_ACL, NT_STATUS_IS_OK(result), handle,
    2523             :                "%s", fsp_str_do_log(fsp));
    2524             : 
    2525      226386 :         return result;
    2526             : }
    2527             : 
    2528      100126 : static NTSTATUS smb_full_audit_fset_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
    2529             :                               uint32_t security_info_sent,
    2530             :                               const struct security_descriptor *psd)
    2531             : {
    2532           0 :         struct vfs_full_audit_private_data *pd;
    2533           0 :         NTSTATUS result;
    2534      100126 :         char *sd = NULL;
    2535             : 
    2536      100126 :         SMB_VFS_HANDLE_GET_DATA(handle, pd,
    2537             :                                 struct vfs_full_audit_private_data,
    2538           0 :                                 return NT_STATUS_INTERNAL_ERROR);
    2539             : 
    2540      100126 :         if (pd->log_secdesc) {
    2541           0 :                 sd = sddl_encode(talloc_tos(), psd, get_global_sam_sid());
    2542             :         }
    2543             : 
    2544      100126 :         result = SMB_VFS_NEXT_FSET_NT_ACL(handle, fsp, security_info_sent, psd);
    2545             : 
    2546      100126 :         do_log(SMB_VFS_OP_FSET_NT_ACL, NT_STATUS_IS_OK(result), handle,
    2547             :                "%s [%s]", fsp_str_do_log(fsp), sd ? sd : "");
    2548             : 
    2549      100126 :         TALLOC_FREE(sd);
    2550             : 
    2551      100126 :         return result;
    2552             : }
    2553             : 
    2554           0 : static NTSTATUS smb_full_audit_audit_file(struct vfs_handle_struct *handle,
    2555             :                                 struct smb_filename *file,
    2556             :                                 struct security_acl *sacl,
    2557             :                                 uint32_t access_requested,
    2558             :                                 uint32_t access_denied)
    2559             : {
    2560           0 :         NTSTATUS result;
    2561             : 
    2562           0 :         result = SMB_VFS_NEXT_AUDIT_FILE(handle,
    2563             :                                         file,
    2564             :                                         sacl,
    2565             :                                         access_requested,
    2566             :                                         access_denied);
    2567             : 
    2568           0 :         do_log(SMB_VFS_OP_AUDIT_FILE, NT_STATUS_IS_OK(result), handle,
    2569             :                         "%s",
    2570             :                         smb_fname_str_do_log(handle->conn, file));
    2571             : 
    2572           0 :         return result;
    2573             : }
    2574             : 
    2575           0 : static SMB_ACL_T smb_full_audit_sys_acl_get_fd(vfs_handle_struct *handle,
    2576             :                                                files_struct *fsp,
    2577             :                                                SMB_ACL_TYPE_T type,
    2578             :                                                TALLOC_CTX *mem_ctx)
    2579             : {
    2580           0 :         SMB_ACL_T result;
    2581             : 
    2582           0 :         result = SMB_VFS_NEXT_SYS_ACL_GET_FD(handle,
    2583             :                                              fsp,
    2584             :                                              type,
    2585             :                                              mem_ctx);
    2586             : 
    2587           0 :         do_log(SMB_VFS_OP_SYS_ACL_GET_FD, (result != NULL), handle,
    2588             :                "%s", fsp_str_do_log(fsp));
    2589             : 
    2590           0 :         return result;
    2591             : }
    2592             : 
    2593           0 : static int smb_full_audit_sys_acl_blob_get_fd(vfs_handle_struct *handle,
    2594             :                                               files_struct *fsp,
    2595             :                                               TALLOC_CTX *mem_ctx,
    2596             :                                               char **blob_description,
    2597             :                                               DATA_BLOB *blob)
    2598             : {
    2599           0 :         int result;
    2600             : 
    2601           0 :         result = SMB_VFS_NEXT_SYS_ACL_BLOB_GET_FD(handle, fsp, mem_ctx, blob_description, blob);
    2602             : 
    2603           0 :         do_log(SMB_VFS_OP_SYS_ACL_BLOB_GET_FD, (result >= 0), handle,
    2604             :                "%s", fsp_str_do_log(fsp));
    2605             : 
    2606           0 :         return result;
    2607             : }
    2608             : 
    2609           0 : static int smb_full_audit_sys_acl_set_fd(vfs_handle_struct *handle,
    2610             :                                          struct files_struct *fsp,
    2611             :                                          SMB_ACL_TYPE_T type,
    2612             :                                          SMB_ACL_T theacl)
    2613             : {
    2614           0 :         int result;
    2615             : 
    2616           0 :         result = SMB_VFS_NEXT_SYS_ACL_SET_FD(handle, fsp, type, theacl);
    2617             : 
    2618           0 :         do_log(SMB_VFS_OP_SYS_ACL_SET_FD, (result >= 0), handle,
    2619             :                "%s", fsp_str_do_log(fsp));
    2620             : 
    2621           0 :         return result;
    2622             : }
    2623             : 
    2624           0 : static int smb_full_audit_sys_acl_delete_def_fd(vfs_handle_struct *handle,
    2625             :                                 struct files_struct *fsp)
    2626             : {
    2627           0 :         int result;
    2628             : 
    2629           0 :         result = SMB_VFS_NEXT_SYS_ACL_DELETE_DEF_FD(handle, fsp);
    2630             : 
    2631           0 :         do_log(SMB_VFS_OP_SYS_ACL_DELETE_DEF_FD,
    2632             :                (result >= 0),
    2633             :                handle,
    2634             :                "%s",
    2635             :                fsp_str_do_log(fsp));
    2636             : 
    2637           0 :         return result;
    2638             : }
    2639             : 
    2640             : struct smb_full_audit_getxattrat_state {
    2641             :         struct vfs_aio_state aio_state;
    2642             :         vfs_handle_struct *handle;
    2643             :         files_struct *dir_fsp;
    2644             :         const struct smb_filename *smb_fname;
    2645             :         const char *xattr_name;
    2646             :         ssize_t xattr_size;
    2647             :         uint8_t *xattr_value;
    2648             : };
    2649             : 
    2650             : static void smb_full_audit_getxattrat_done(struct tevent_req *subreq);
    2651             : 
    2652           0 : static struct tevent_req *smb_full_audit_getxattrat_send(
    2653             :                         TALLOC_CTX *mem_ctx,
    2654             :                         struct tevent_context *ev,
    2655             :                         struct vfs_handle_struct *handle,
    2656             :                         files_struct *dir_fsp,
    2657             :                         const struct smb_filename *smb_fname,
    2658             :                         const char *xattr_name,
    2659             :                         size_t alloc_hint)
    2660             : {
    2661           0 :         struct tevent_req *req = NULL;
    2662           0 :         struct tevent_req *subreq = NULL;
    2663           0 :         struct smb_full_audit_getxattrat_state *state = NULL;
    2664             : 
    2665           0 :         req = tevent_req_create(mem_ctx, &state,
    2666             :                                 struct smb_full_audit_getxattrat_state);
    2667           0 :         if (req == NULL) {
    2668           0 :                 do_log(SMB_VFS_OP_GETXATTRAT_SEND,
    2669             :                        false,
    2670             :                        handle,
    2671             :                        "%s/%s|%s",
    2672             :                        fsp_str_do_log(dir_fsp),
    2673           0 :                        smb_fname->base_name,
    2674             :                        xattr_name);
    2675           0 :                 return NULL;
    2676             :         }
    2677           0 :         *state = (struct smb_full_audit_getxattrat_state) {
    2678             :                 .handle = handle,
    2679             :                 .dir_fsp = dir_fsp,
    2680             :                 .smb_fname = smb_fname,
    2681             :                 .xattr_name = xattr_name,
    2682             :         };
    2683             : 
    2684           0 :         subreq = SMB_VFS_NEXT_GETXATTRAT_SEND(state,
    2685             :                                               ev,
    2686             :                                               handle,
    2687             :                                               dir_fsp,
    2688             :                                               smb_fname,
    2689             :                                               xattr_name,
    2690             :                                               alloc_hint);
    2691           0 :         if (tevent_req_nomem(subreq, req)) {
    2692           0 :                 do_log(SMB_VFS_OP_GETXATTRAT_SEND,
    2693             :                        false,
    2694             :                        handle,
    2695             :                        "%s/%s|%s",
    2696             :                        fsp_str_do_log(dir_fsp),
    2697           0 :                        smb_fname->base_name,
    2698             :                        xattr_name);
    2699           0 :                 return tevent_req_post(req, ev);
    2700             :         }
    2701           0 :         tevent_req_set_callback(subreq, smb_full_audit_getxattrat_done, req);
    2702             : 
    2703           0 :         do_log(SMB_VFS_OP_GETXATTRAT_SEND,
    2704             :                true,
    2705             :                handle,
    2706             :                "%s/%s|%s",
    2707             :                fsp_str_do_log(dir_fsp),
    2708           0 :                smb_fname->base_name,
    2709             :                xattr_name);
    2710             : 
    2711           0 :         return req;
    2712             : }
    2713             : 
    2714           0 : static void smb_full_audit_getxattrat_done(struct tevent_req *subreq)
    2715             : {
    2716           0 :         struct tevent_req *req = tevent_req_callback_data(
    2717             :                 subreq, struct tevent_req);
    2718           0 :         struct smb_full_audit_getxattrat_state *state = tevent_req_data(
    2719             :                 req, struct smb_full_audit_getxattrat_state);
    2720             : 
    2721           0 :         state->xattr_size = SMB_VFS_NEXT_GETXATTRAT_RECV(subreq,
    2722             :                                                          &state->aio_state,
    2723             :                                                          state,
    2724             :                                                          &state->xattr_value);
    2725           0 :         TALLOC_FREE(subreq);
    2726           0 :         if (state->xattr_size == -1) {
    2727           0 :                 tevent_req_error(req, state->aio_state.error);
    2728           0 :                 return;
    2729             :         }
    2730             : 
    2731           0 :         tevent_req_done(req);
    2732             : }
    2733             : 
    2734           0 : static ssize_t smb_full_audit_getxattrat_recv(struct tevent_req *req,
    2735             :                                               struct vfs_aio_state *aio_state,
    2736             :                                               TALLOC_CTX *mem_ctx,
    2737             :                                               uint8_t **xattr_value)
    2738             : {
    2739           0 :         struct smb_full_audit_getxattrat_state *state = tevent_req_data(
    2740             :                 req, struct smb_full_audit_getxattrat_state);
    2741           0 :         ssize_t xattr_size;
    2742             : 
    2743           0 :         if (tevent_req_is_unix_error(req, &aio_state->error)) {
    2744           0 :                 do_log(SMB_VFS_OP_GETXATTRAT_RECV,
    2745             :                        false,
    2746             :                        state->handle,
    2747             :                        "%s/%s|%s",
    2748           0 :                        fsp_str_do_log(state->dir_fsp),
    2749           0 :                        state->smb_fname->base_name,
    2750             :                        state->xattr_name);
    2751           0 :                 tevent_req_received(req);
    2752           0 :                 return -1;
    2753             :         }
    2754             : 
    2755           0 :         do_log(SMB_VFS_OP_GETXATTRAT_RECV,
    2756             :                true,
    2757             :                state->handle,
    2758             :                "%s/%s|%s",
    2759           0 :                fsp_str_do_log(state->dir_fsp),
    2760           0 :                state->smb_fname->base_name,
    2761             :                state->xattr_name);
    2762             : 
    2763           0 :         *aio_state = state->aio_state;
    2764           0 :         xattr_size = state->xattr_size;
    2765           0 :         if (xattr_value != NULL) {
    2766           0 :                 *xattr_value = talloc_move(mem_ctx, &state->xattr_value);
    2767             :         }
    2768             : 
    2769           0 :         tevent_req_received(req);
    2770           0 :         return xattr_size;
    2771             : }
    2772             : 
    2773           2 : static ssize_t smb_full_audit_fgetxattr(struct vfs_handle_struct *handle,
    2774             :                                struct files_struct *fsp,
    2775             :                                const char *name, void *value, size_t size)
    2776             : {
    2777           0 :         ssize_t result;
    2778             : 
    2779           2 :         result = SMB_VFS_NEXT_FGETXATTR(handle, fsp, name, value, size);
    2780             : 
    2781           2 :         do_log(SMB_VFS_OP_FGETXATTR, (result >= 0), handle,
    2782             :                "%s|%s", fsp_str_do_log(fsp), name);
    2783             : 
    2784           2 :         return result;
    2785             : }
    2786             : 
    2787           0 : static ssize_t smb_full_audit_flistxattr(struct vfs_handle_struct *handle,
    2788             :                                 struct files_struct *fsp, char *list,
    2789             :                                 size_t size)
    2790             : {
    2791           0 :         ssize_t result;
    2792             : 
    2793           0 :         result = SMB_VFS_NEXT_FLISTXATTR(handle, fsp, list, size);
    2794             : 
    2795           0 :         do_log(SMB_VFS_OP_FLISTXATTR, (result >= 0), handle,
    2796             :                "%s", fsp_str_do_log(fsp));
    2797             : 
    2798           0 :         return result;
    2799             : }
    2800             : 
    2801           0 : static int smb_full_audit_fremovexattr(struct vfs_handle_struct *handle,
    2802             :                               struct files_struct *fsp,
    2803             :                               const char *name)
    2804             : {
    2805           0 :         int result;
    2806             : 
    2807           0 :         result = SMB_VFS_NEXT_FREMOVEXATTR(handle, fsp, name);
    2808             : 
    2809           0 :         do_log(SMB_VFS_OP_FREMOVEXATTR, (result >= 0), handle,
    2810             :                "%s|%s", fsp_str_do_log(fsp), name);
    2811             : 
    2812           0 :         return result;
    2813             : }
    2814             : 
    2815           0 : static int smb_full_audit_fsetxattr(struct vfs_handle_struct *handle,
    2816             :                            struct files_struct *fsp, const char *name,
    2817             :                            const void *value, size_t size, int flags)
    2818             : {
    2819           0 :         int result;
    2820             : 
    2821           0 :         result = SMB_VFS_NEXT_FSETXATTR(handle, fsp, name, value, size, flags);
    2822             : 
    2823           0 :         do_log(SMB_VFS_OP_FSETXATTR, (result >= 0), handle,
    2824             :                "%s|%s", fsp_str_do_log(fsp), name);
    2825             : 
    2826           0 :         return result;
    2827             : }
    2828             : 
    2829          64 : static bool smb_full_audit_aio_force(struct vfs_handle_struct *handle,
    2830             :                                      struct files_struct *fsp)
    2831             : {
    2832           0 :         bool result;
    2833             : 
    2834          64 :         result = SMB_VFS_NEXT_AIO_FORCE(handle, fsp);
    2835          64 :         do_log(SMB_VFS_OP_AIO_FORCE, result, handle,
    2836             :                 "%s", fsp_str_do_log(fsp));
    2837             : 
    2838          64 :         return result;
    2839             : }
    2840             : 
    2841         384 : static NTSTATUS smb_full_audit_durable_cookie(struct vfs_handle_struct *handle,
    2842             :                                 struct files_struct *fsp,
    2843             :                                 TALLOC_CTX *mem_ctx,
    2844             :                                 DATA_BLOB *cookie)
    2845             : {
    2846           0 :         NTSTATUS result;
    2847             : 
    2848         384 :         result = SMB_VFS_NEXT_DURABLE_COOKIE(handle,
    2849             :                                         fsp,
    2850             :                                         mem_ctx,
    2851             :                                         cookie);
    2852             : 
    2853         384 :         do_log(SMB_VFS_OP_DURABLE_COOKIE, NT_STATUS_IS_OK(result), handle,
    2854             :                         "%s", fsp_str_do_log(fsp));
    2855             : 
    2856         384 :         return result;
    2857             : }
    2858             : 
    2859         112 : static NTSTATUS smb_full_audit_durable_disconnect(
    2860             :                                 struct vfs_handle_struct *handle,
    2861             :                                 struct files_struct *fsp,
    2862             :                                 const DATA_BLOB old_cookie,
    2863             :                                 TALLOC_CTX *mem_ctx,
    2864             :                                 DATA_BLOB *new_cookie)
    2865             : {
    2866           0 :         NTSTATUS result;
    2867             : 
    2868         112 :         result = SMB_VFS_NEXT_DURABLE_DISCONNECT(handle,
    2869             :                                         fsp,
    2870             :                                         old_cookie,
    2871             :                                         mem_ctx,
    2872             :                                         new_cookie);
    2873             : 
    2874         112 :         do_log(SMB_VFS_OP_DURABLE_DISCONNECT, NT_STATUS_IS_OK(result), handle,
    2875             :                         "%s", fsp_str_do_log(fsp));
    2876             : 
    2877         112 :         return result;
    2878             : }
    2879             : 
    2880         110 : static NTSTATUS smb_full_audit_durable_reconnect(
    2881             :                                 struct vfs_handle_struct *handle,
    2882             :                                 struct smb_request *smb1req,
    2883             :                                 struct smbXsrv_open *op,
    2884             :                                 const DATA_BLOB old_cookie,
    2885             :                                 TALLOC_CTX *mem_ctx,
    2886             :                                 struct files_struct **fsp,
    2887             :                                 DATA_BLOB *new_cookie)
    2888             : {
    2889           0 :         NTSTATUS result;
    2890             : 
    2891         110 :         result = SMB_VFS_NEXT_DURABLE_RECONNECT(handle,
    2892             :                                         smb1req,
    2893             :                                         op,
    2894             :                                         old_cookie,
    2895             :                                         mem_ctx,
    2896             :                                         fsp,
    2897             :                                         new_cookie);
    2898             : 
    2899         110 :         do_log(SMB_VFS_OP_DURABLE_RECONNECT,
    2900         110 :                         NT_STATUS_IS_OK(result),
    2901             :                         handle,
    2902             :                         "");
    2903             : 
    2904         110 :         return result;
    2905             : }
    2906             : 
    2907             : static struct vfs_fn_pointers vfs_full_audit_fns = {
    2908             : 
    2909             :         /* Disk operations */
    2910             : 
    2911             :         .connect_fn = smb_full_audit_connect,
    2912             :         .disconnect_fn = smb_full_audit_disconnect,
    2913             :         .disk_free_fn = smb_full_audit_disk_free,
    2914             :         .get_quota_fn = smb_full_audit_get_quota,
    2915             :         .set_quota_fn = smb_full_audit_set_quota,
    2916             :         .get_shadow_copy_data_fn = smb_full_audit_get_shadow_copy_data,
    2917             :         .statvfs_fn = smb_full_audit_statvfs,
    2918             :         .fs_capabilities_fn = smb_full_audit_fs_capabilities,
    2919             :         .get_dfs_referrals_fn = smb_full_audit_get_dfs_referrals,
    2920             :         .create_dfs_pathat_fn = smb_full_audit_create_dfs_pathat,
    2921             :         .read_dfs_pathat_fn = smb_full_audit_read_dfs_pathat,
    2922             :         .fdopendir_fn = smb_full_audit_fdopendir,
    2923             :         .readdir_fn = smb_full_audit_readdir,
    2924             :         .rewind_dir_fn = smb_full_audit_rewinddir,
    2925             :         .mkdirat_fn = smb_full_audit_mkdirat,
    2926             :         .closedir_fn = smb_full_audit_closedir,
    2927             :         .openat_fn = smb_full_audit_openat,
    2928             :         .create_file_fn = smb_full_audit_create_file,
    2929             :         .close_fn = smb_full_audit_close,
    2930             :         .pread_fn = smb_full_audit_pread,
    2931             :         .pread_send_fn = smb_full_audit_pread_send,
    2932             :         .pread_recv_fn = smb_full_audit_pread_recv,
    2933             :         .pwrite_fn = smb_full_audit_pwrite,
    2934             :         .pwrite_send_fn = smb_full_audit_pwrite_send,
    2935             :         .pwrite_recv_fn = smb_full_audit_pwrite_recv,
    2936             :         .lseek_fn = smb_full_audit_lseek,
    2937             :         .sendfile_fn = smb_full_audit_sendfile,
    2938             :         .recvfile_fn = smb_full_audit_recvfile,
    2939             :         .renameat_fn = smb_full_audit_renameat,
    2940             :         .fsync_send_fn = smb_full_audit_fsync_send,
    2941             :         .fsync_recv_fn = smb_full_audit_fsync_recv,
    2942             :         .stat_fn = smb_full_audit_stat,
    2943             :         .fstat_fn = smb_full_audit_fstat,
    2944             :         .lstat_fn = smb_full_audit_lstat,
    2945             :         .fstatat_fn = smb_full_audit_fstatat,
    2946             :         .get_alloc_size_fn = smb_full_audit_get_alloc_size,
    2947             :         .unlinkat_fn = smb_full_audit_unlinkat,
    2948             :         .fchmod_fn = smb_full_audit_fchmod,
    2949             :         .fchown_fn = smb_full_audit_fchown,
    2950             :         .lchown_fn = smb_full_audit_lchown,
    2951             :         .chdir_fn = smb_full_audit_chdir,
    2952             :         .getwd_fn = smb_full_audit_getwd,
    2953             :         .fntimes_fn = smb_full_audit_fntimes,
    2954             :         .ftruncate_fn = smb_full_audit_ftruncate,
    2955             :         .fallocate_fn = smb_full_audit_fallocate,
    2956             :         .lock_fn = smb_full_audit_lock,
    2957             :         .filesystem_sharemode_fn = smb_full_audit_filesystem_sharemode,
    2958             :         .fcntl_fn = smb_full_audit_fcntl,
    2959             :         .linux_setlease_fn = smb_full_audit_linux_setlease,
    2960             :         .getlock_fn = smb_full_audit_getlock,
    2961             :         .symlinkat_fn = smb_full_audit_symlinkat,
    2962             :         .readlinkat_fn = smb_full_audit_readlinkat,
    2963             :         .linkat_fn = smb_full_audit_linkat,
    2964             :         .mknodat_fn = smb_full_audit_mknodat,
    2965             :         .realpath_fn = smb_full_audit_realpath,
    2966             :         .fchflags_fn = smb_full_audit_fchflags,
    2967             :         .file_id_create_fn = smb_full_audit_file_id_create,
    2968             :         .fs_file_id_fn = smb_full_audit_fs_file_id,
    2969             :         .offload_read_send_fn = smb_full_audit_offload_read_send,
    2970             :         .offload_read_recv_fn = smb_full_audit_offload_read_recv,
    2971             :         .offload_write_send_fn = smb_full_audit_offload_write_send,
    2972             :         .offload_write_recv_fn = smb_full_audit_offload_write_recv,
    2973             :         .fget_compression_fn = smb_full_audit_fget_compression,
    2974             :         .set_compression_fn = smb_full_audit_set_compression,
    2975             :         .snap_check_path_fn =  smb_full_audit_snap_check_path,
    2976             :         .snap_create_fn = smb_full_audit_snap_create,
    2977             :         .snap_delete_fn = smb_full_audit_snap_delete,
    2978             :         .fstreaminfo_fn = smb_full_audit_fstreaminfo,
    2979             :         .get_real_filename_at_fn = smb_full_audit_get_real_filename_at,
    2980             :         .connectpath_fn = smb_full_audit_connectpath,
    2981             :         .brl_lock_windows_fn = smb_full_audit_brl_lock_windows,
    2982             :         .brl_unlock_windows_fn = smb_full_audit_brl_unlock_windows,
    2983             :         .strict_lock_check_fn = smb_full_audit_strict_lock_check,
    2984             :         .translate_name_fn = smb_full_audit_translate_name,
    2985             :         .parent_pathname_fn = smb_full_audit_parent_pathname,
    2986             :         .fsctl_fn = smb_full_audit_fsctl,
    2987             :         .get_dos_attributes_send_fn = smb_full_audit_get_dos_attributes_send,
    2988             :         .get_dos_attributes_recv_fn = smb_full_audit_get_dos_attributes_recv,
    2989             :         .fget_dos_attributes_fn = smb_full_audit_fget_dos_attributes,
    2990             :         .fset_dos_attributes_fn = smb_full_audit_fset_dos_attributes,
    2991             :         .fget_nt_acl_fn = smb_full_audit_fget_nt_acl,
    2992             :         .fset_nt_acl_fn = smb_full_audit_fset_nt_acl,
    2993             :         .audit_file_fn = smb_full_audit_audit_file,
    2994             :         .sys_acl_get_fd_fn = smb_full_audit_sys_acl_get_fd,
    2995             :         .sys_acl_blob_get_fd_fn = smb_full_audit_sys_acl_blob_get_fd,
    2996             :         .sys_acl_set_fd_fn = smb_full_audit_sys_acl_set_fd,
    2997             :         .sys_acl_delete_def_fd_fn = smb_full_audit_sys_acl_delete_def_fd,
    2998             :         .getxattrat_send_fn = smb_full_audit_getxattrat_send,
    2999             :         .getxattrat_recv_fn = smb_full_audit_getxattrat_recv,
    3000             :         .fgetxattr_fn = smb_full_audit_fgetxattr,
    3001             :         .flistxattr_fn = smb_full_audit_flistxattr,
    3002             :         .fremovexattr_fn = smb_full_audit_fremovexattr,
    3003             :         .fsetxattr_fn = smb_full_audit_fsetxattr,
    3004             :         .aio_force_fn = smb_full_audit_aio_force,
    3005             :         .durable_cookie_fn = smb_full_audit_durable_cookie,
    3006             :         .durable_disconnect_fn = smb_full_audit_durable_disconnect,
    3007             :         .durable_reconnect_fn = smb_full_audit_durable_reconnect,
    3008             :         .freaddir_attr_fn = smb_full_audit_freaddir_attr,
    3009             : };
    3010             : 
    3011             : static_decl_vfs;
    3012       23286 : NTSTATUS vfs_full_audit_init(TALLOC_CTX *ctx)
    3013             : {
    3014           0 :         NTSTATUS ret;
    3015             : 
    3016       23286 :         smb_vfs_assert_all_fns(&vfs_full_audit_fns, "full_audit");
    3017             : 
    3018       23286 :         ret = smb_register_vfs(SMB_VFS_INTERFACE_VERSION, "full_audit",
    3019             :                                &vfs_full_audit_fns);
    3020             : 
    3021       23286 :         if (!NT_STATUS_IS_OK(ret))
    3022           0 :                 return ret;
    3023             : 
    3024       23286 :         vfs_full_audit_debug_level = debug_add_class("full_audit");
    3025       23286 :         if (vfs_full_audit_debug_level == -1) {
    3026           0 :                 vfs_full_audit_debug_level = DBGC_VFS;
    3027           0 :                 DEBUG(0, ("vfs_full_audit: Couldn't register custom debugging "
    3028             :                           "class!\n"));
    3029             :         } else {
    3030       23286 :                 DEBUG(10, ("vfs_full_audit: Debug class number of "
    3031             :                            "'full_audit': %d\n", vfs_full_audit_debug_level));
    3032             :         }
    3033             : 
    3034       23286 :         return ret;
    3035             : }

Generated by: LCOV version 1.14