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