LCOV - code coverage report
Current view: top level - source3/modules - vfs_full_audit.c (source / functions) Hit Total Coverage
Test: coverage report for v4-17-test 1498b464 Lines: 444 857 51.8 %
Date: 2024-06-13 04:01:37 Functions: 67 118 56.8 %

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

Generated by: LCOV version 1.13