s3: Plumb smb_filename through SMB_VFS_NTIMES
[sfrench/samba-autobuild/.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
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|.
42  * smbd_audit: nobody|192.168.234.1|open|fail (File not found)|r|x.txt
43  *
44  * where "nobody" is the connected username and "192.168.234.1" is the
45  * client's IP address. 
46  *
47  * Options:
48  *
49  * prefix: A macro expansion template prepended to the syslog entry.
50  *
51  * success: A list of VFS operations for which a successful completion should
52  * be logged. Defaults to no logging at all. The special operation "all" logs
53  * - you guessed it - everything.
54  *
55  * failure: A list of VFS operations for which failure to complete should be
56  * logged. Defaults to logging everything.
57  */
58
59
60 #include "includes.h"
61
62 static int vfs_full_audit_debug_level = DBGC_VFS;
63
64 struct vfs_full_audit_private_data {
65         struct bitmap *success_ops;
66         struct bitmap *failure_ops;
67 };
68
69 #undef DBGC_CLASS
70 #define DBGC_CLASS vfs_full_audit_debug_level
71
72 /* The following array *must* be in the same order as defined in vfs.h */
73
74 static struct {
75         vfs_op_type type;
76         const char *name;
77 } vfs_op_names[] = {
78         { SMB_VFS_OP_CONNECT,   "connect" },
79         { SMB_VFS_OP_DISCONNECT,        "disconnect" },
80         { SMB_VFS_OP_DISK_FREE, "disk_free" },
81         { SMB_VFS_OP_GET_QUOTA, "get_quota" },
82         { SMB_VFS_OP_SET_QUOTA, "set_quota" },
83         { SMB_VFS_OP_GET_SHADOW_COPY_DATA,      "get_shadow_copy_data" },
84         { SMB_VFS_OP_STATVFS,   "statvfs" },
85         { SMB_VFS_OP_FS_CAPABILITIES,   "fs_capabilities" },
86         { SMB_VFS_OP_OPENDIR,   "opendir" },
87         { SMB_VFS_OP_READDIR,   "readdir" },
88         { SMB_VFS_OP_SEEKDIR,   "seekdir" },
89         { SMB_VFS_OP_TELLDIR,   "telldir" },
90         { SMB_VFS_OP_REWINDDIR, "rewinddir" },
91         { SMB_VFS_OP_MKDIR,     "mkdir" },
92         { SMB_VFS_OP_RMDIR,     "rmdir" },
93         { SMB_VFS_OP_CLOSEDIR,  "closedir" },
94         { SMB_VFS_OP_INIT_SEARCH_OP, "init_search_op" },
95         { SMB_VFS_OP_OPEN,      "open" },
96         { SMB_VFS_OP_CREATE_FILE, "create_file" },
97         { SMB_VFS_OP_CLOSE,     "close" },
98         { SMB_VFS_OP_READ,      "read" },
99         { SMB_VFS_OP_PREAD,     "pread" },
100         { SMB_VFS_OP_WRITE,     "write" },
101         { SMB_VFS_OP_PWRITE,    "pwrite" },
102         { SMB_VFS_OP_LSEEK,     "lseek" },
103         { SMB_VFS_OP_SENDFILE,  "sendfile" },
104         { SMB_VFS_OP_RECVFILE,  "recvfile" },
105         { SMB_VFS_OP_RENAME,    "rename" },
106         { SMB_VFS_OP_FSYNC,     "fsync" },
107         { SMB_VFS_OP_STAT,      "stat" },
108         { SMB_VFS_OP_FSTAT,     "fstat" },
109         { SMB_VFS_OP_LSTAT,     "lstat" },
110         { SMB_VFS_OP_GET_ALLOC_SIZE,    "get_alloc_size" },
111         { SMB_VFS_OP_UNLINK,    "unlink" },
112         { SMB_VFS_OP_CHMOD,     "chmod" },
113         { SMB_VFS_OP_FCHMOD,    "fchmod" },
114         { SMB_VFS_OP_CHOWN,     "chown" },
115         { SMB_VFS_OP_FCHOWN,    "fchown" },
116         { SMB_VFS_OP_LCHOWN,    "lchown" },
117         { SMB_VFS_OP_CHDIR,     "chdir" },
118         { SMB_VFS_OP_GETWD,     "getwd" },
119         { SMB_VFS_OP_NTIMES,    "ntimes" },
120         { SMB_VFS_OP_FTRUNCATE, "ftruncate" },
121         { SMB_VFS_OP_LOCK,      "lock" },
122         { SMB_VFS_OP_KERNEL_FLOCK,      "kernel_flock" },
123         { SMB_VFS_OP_LINUX_SETLEASE, "linux_setlease" },
124         { SMB_VFS_OP_GETLOCK,   "getlock" },
125         { SMB_VFS_OP_SYMLINK,   "symlink" },
126         { SMB_VFS_OP_READLINK,  "readlink" },
127         { SMB_VFS_OP_LINK,      "link" },
128         { SMB_VFS_OP_MKNOD,     "mknod" },
129         { SMB_VFS_OP_REALPATH,  "realpath" },
130         { SMB_VFS_OP_NOTIFY_WATCH, "notify_watch" },
131         { SMB_VFS_OP_CHFLAGS,   "chflags" },
132         { SMB_VFS_OP_FILE_ID_CREATE,    "file_id_create" },
133         { SMB_VFS_OP_STREAMINFO,        "streaminfo" },
134         { SMB_VFS_OP_GET_REAL_FILENAME, "get_real_filename" },
135         { SMB_VFS_OP_CONNECTPATH,       "connectpath" },
136         { SMB_VFS_OP_BRL_LOCK_WINDOWS,  "brl_lock_windows" },
137         { SMB_VFS_OP_BRL_UNLOCK_WINDOWS, "brl_unlock_windows" },
138         { SMB_VFS_OP_BRL_CANCEL_WINDOWS, "brl_cancel_windows" },
139         { SMB_VFS_OP_STRICT_LOCK, "strict_lock" },
140         { SMB_VFS_OP_STRICT_UNLOCK, "strict_unlock" },
141         { SMB_VFS_OP_FGET_NT_ACL,       "fget_nt_acl" },
142         { SMB_VFS_OP_GET_NT_ACL,        "get_nt_acl" },
143         { SMB_VFS_OP_FSET_NT_ACL,       "fset_nt_acl" },
144         { SMB_VFS_OP_CHMOD_ACL, "chmod_acl" },
145         { SMB_VFS_OP_FCHMOD_ACL,        "fchmod_acl" },
146         { SMB_VFS_OP_SYS_ACL_GET_ENTRY, "sys_acl_get_entry" },
147         { SMB_VFS_OP_SYS_ACL_GET_TAG_TYPE,      "sys_acl_get_tag_type" },
148         { SMB_VFS_OP_SYS_ACL_GET_PERMSET,       "sys_acl_get_permset" },
149         { SMB_VFS_OP_SYS_ACL_GET_QUALIFIER,     "sys_acl_get_qualifier" },
150         { SMB_VFS_OP_SYS_ACL_GET_FILE,  "sys_acl_get_file" },
151         { SMB_VFS_OP_SYS_ACL_GET_FD,    "sys_acl_get_fd" },
152         { SMB_VFS_OP_SYS_ACL_CLEAR_PERMS,       "sys_acl_clear_perms" },
153         { SMB_VFS_OP_SYS_ACL_ADD_PERM,  "sys_acl_add_perm" },
154         { SMB_VFS_OP_SYS_ACL_TO_TEXT,   "sys_acl_to_text" },
155         { SMB_VFS_OP_SYS_ACL_INIT,      "sys_acl_init" },
156         { SMB_VFS_OP_SYS_ACL_CREATE_ENTRY,      "sys_acl_create_entry" },
157         { SMB_VFS_OP_SYS_ACL_SET_TAG_TYPE,      "sys_acl_set_tag_type" },
158         { SMB_VFS_OP_SYS_ACL_SET_QUALIFIER,     "sys_acl_set_qualifier" },
159         { SMB_VFS_OP_SYS_ACL_SET_PERMSET,       "sys_acl_set_permset" },
160         { SMB_VFS_OP_SYS_ACL_VALID,     "sys_acl_valid" },
161         { SMB_VFS_OP_SYS_ACL_SET_FILE,  "sys_acl_set_file" },
162         { SMB_VFS_OP_SYS_ACL_SET_FD,    "sys_acl_set_fd" },
163         { SMB_VFS_OP_SYS_ACL_DELETE_DEF_FILE,   "sys_acl_delete_def_file" },
164         { SMB_VFS_OP_SYS_ACL_GET_PERM,  "sys_acl_get_perm" },
165         { SMB_VFS_OP_SYS_ACL_FREE_TEXT, "sys_acl_free_text" },
166         { SMB_VFS_OP_SYS_ACL_FREE_ACL,  "sys_acl_free_acl" },
167         { SMB_VFS_OP_SYS_ACL_FREE_QUALIFIER,    "sys_acl_free_qualifier" },
168         { SMB_VFS_OP_GETXATTR,  "getxattr" },
169         { SMB_VFS_OP_LGETXATTR, "lgetxattr" },
170         { SMB_VFS_OP_FGETXATTR, "fgetxattr" },
171         { SMB_VFS_OP_LISTXATTR, "listxattr" },
172         { SMB_VFS_OP_LLISTXATTR,        "llistxattr" },
173         { SMB_VFS_OP_FLISTXATTR,        "flistxattr" },
174         { SMB_VFS_OP_REMOVEXATTR,       "removexattr" },
175         { SMB_VFS_OP_LREMOVEXATTR,      "lremovexattr" },
176         { SMB_VFS_OP_FREMOVEXATTR,      "fremovexattr" },
177         { SMB_VFS_OP_SETXATTR,  "setxattr" },
178         { SMB_VFS_OP_LSETXATTR, "lsetxattr" },
179         { SMB_VFS_OP_FSETXATTR, "fsetxattr" },
180         { SMB_VFS_OP_AIO_READ,  "aio_read" },
181         { SMB_VFS_OP_AIO_WRITE, "aio_write" },
182         { SMB_VFS_OP_AIO_RETURN,"aio_return" },
183         { SMB_VFS_OP_AIO_CANCEL,"aio_cancel" },
184         { SMB_VFS_OP_AIO_ERROR, "aio_error" },
185         { SMB_VFS_OP_AIO_FSYNC, "aio_fsync" },
186         { SMB_VFS_OP_AIO_SUSPEND,"aio_suspend" },
187         { SMB_VFS_OP_AIO_FORCE, "aio_force" },
188         { SMB_VFS_OP_IS_OFFLINE, "aio_is_offline" },
189         { SMB_VFS_OP_SET_OFFLINE, "aio_set_offline" },
190         { SMB_VFS_OP_LAST, NULL }
191 };
192
193 static int audit_syslog_facility(vfs_handle_struct *handle)
194 {
195         static const struct enum_list enum_log_facilities[] = {
196                 { LOG_USER, "USER" },
197                 { LOG_LOCAL0, "LOCAL0" },
198                 { LOG_LOCAL1, "LOCAL1" },
199                 { LOG_LOCAL2, "LOCAL2" },
200                 { LOG_LOCAL3, "LOCAL3" },
201                 { LOG_LOCAL4, "LOCAL4" },
202                 { LOG_LOCAL5, "LOCAL5" },
203                 { LOG_LOCAL6, "LOCAL6" },
204                 { LOG_LOCAL7, "LOCAL7" }
205         };
206
207         int facility;
208
209         facility = lp_parm_enum(SNUM(handle->conn), "full_audit", "facility", enum_log_facilities, LOG_USER);
210
211         return facility;
212 }
213
214 static int audit_syslog_priority(vfs_handle_struct *handle)
215 {
216         static const struct enum_list enum_log_priorities[] = {
217                 { LOG_EMERG, "EMERG" },
218                 { LOG_ALERT, "ALERT" },
219                 { LOG_CRIT, "CRIT" },
220                 { LOG_ERR, "ERR" },
221                 { LOG_WARNING, "WARNING" },
222                 { LOG_NOTICE, "NOTICE" },
223                 { LOG_INFO, "INFO" },
224                 { LOG_DEBUG, "DEBUG" }
225         };
226
227         int priority;
228
229         priority = lp_parm_enum(SNUM(handle->conn), "full_audit", "priority",
230                                 enum_log_priorities, LOG_NOTICE);
231         if (priority == -1) {
232                 priority = LOG_WARNING;
233         }
234
235         return priority;
236 }
237
238 static char *audit_prefix(TALLOC_CTX *ctx, connection_struct *conn)
239 {
240         char *prefix = NULL;
241         char *result;
242
243         prefix = talloc_strdup(ctx,
244                         lp_parm_const_string(SNUM(conn), "full_audit",
245                                              "prefix", "%u|%I"));
246         if (!prefix) {
247                 return NULL;
248         }
249         result = talloc_sub_advanced(ctx,
250                         lp_servicename(SNUM(conn)),
251                         conn->server_info->unix_name,
252                         conn->connectpath,
253                         conn->server_info->utok.gid,
254                         conn->server_info->sanitized_username,
255                         pdb_get_domain(conn->server_info->sam_account),
256                         prefix);
257         TALLOC_FREE(prefix);
258         return result;
259 }
260
261 static bool log_success(vfs_handle_struct *handle, vfs_op_type op)
262 {
263         struct vfs_full_audit_private_data *pd = NULL;
264
265         SMB_VFS_HANDLE_GET_DATA(handle, pd,
266                 struct vfs_full_audit_private_data,
267                 return True);
268
269         if (pd->success_ops == NULL) {
270                 return True;
271         }
272
273         return bitmap_query(pd->success_ops, op);
274 }
275
276 static bool log_failure(vfs_handle_struct *handle, vfs_op_type op)
277 {
278         struct vfs_full_audit_private_data *pd = NULL;
279
280         SMB_VFS_HANDLE_GET_DATA(handle, pd,
281                 struct vfs_full_audit_private_data,
282                 return True);
283
284         if (pd->failure_ops == NULL)
285                 return True;
286
287         return bitmap_query(pd->failure_ops, op);
288 }
289
290 static void init_bitmap(struct bitmap **bm, const char **ops)
291 {
292         bool log_all = False;
293
294         if (*bm != NULL)
295                 return;
296
297         *bm = bitmap_allocate(SMB_VFS_OP_LAST);
298
299         if (*bm == NULL) {
300                 DEBUG(0, ("Could not alloc bitmap -- "
301                           "defaulting to logging everything\n"));
302                 return;
303         }
304
305         while (*ops != NULL) {
306                 int i;
307                 bool found = False;
308
309                 if (strequal(*ops, "all")) {
310                         log_all = True;
311                         break;
312                 }
313
314                 if (strequal(*ops, "none")) {
315                         break;
316                 }
317
318                 for (i=0; i<SMB_VFS_OP_LAST; i++) {
319                         if (vfs_op_names[i].name == NULL) {
320                                 smb_panic("vfs_full_audit.c: name table not "
321                                           "in sync with vfs.h\n");
322                         }
323
324                         if (strequal(*ops, vfs_op_names[i].name)) {
325                                 bitmap_set(*bm, i);
326                                 found = True;
327                         }
328                 }
329                 if (!found) {
330                         DEBUG(0, ("Could not find opname %s, logging all\n",
331                                   *ops));
332                         log_all = True;
333                         break;
334                 }
335                 ops += 1;
336         }
337
338         if (log_all) {
339                 /* The query functions default to True */
340                 bitmap_free(*bm);
341                 *bm = NULL;
342         }
343 }
344
345 static const char *audit_opname(vfs_op_type op)
346 {
347         if (op >= SMB_VFS_OP_LAST)
348                 return "INVALID VFS OP";
349         return vfs_op_names[op].name;
350 }
351
352 static TALLOC_CTX *tmp_do_log_ctx;
353 /*
354  * Get us a temporary talloc context usable just for DEBUG arguments
355  */
356 static TALLOC_CTX *do_log_ctx(void)
357 {
358         if (tmp_do_log_ctx == NULL) {
359                 tmp_do_log_ctx = talloc_named_const(NULL, 0, "do_log_ctx");
360         }
361         return tmp_do_log_ctx;
362 }
363
364 static void do_log(vfs_op_type op, bool success, vfs_handle_struct *handle,
365                    const char *format, ...)
366 {
367         fstring err_msg;
368         char *audit_pre = NULL;
369         va_list ap;
370         char *op_msg = NULL;
371
372         if (success && (!log_success(handle, op)))
373                 goto out;
374
375         if (!success && (!log_failure(handle, op)))
376                 goto out;
377
378         if (success)
379                 fstrcpy(err_msg, "ok");
380         else
381                 fstr_sprintf(err_msg, "fail (%s)", strerror(errno));
382
383         va_start(ap, format);
384         op_msg = talloc_vasprintf(talloc_tos(), format, ap);
385         va_end(ap);
386
387         if (!op_msg) {
388                 goto out;
389         }
390
391         audit_pre = audit_prefix(talloc_tos(), handle->conn);
392         syslog(audit_syslog_priority(handle), "%s|%s|%s|%s\n",
393                 audit_pre ? audit_pre : "",
394                 audit_opname(op), err_msg, op_msg);
395
396  out:
397         TALLOC_FREE(audit_pre);
398         TALLOC_FREE(op_msg);
399         TALLOC_FREE(tmp_do_log_ctx);
400
401         return;
402 }
403
404 /**
405  * Return a string using the do_log_ctx()
406  */
407 static const char *smb_fname_str_do_log(const struct smb_filename *smb_fname)
408 {
409         char *fname = NULL;
410         NTSTATUS status;
411
412         if (smb_fname == NULL) {
413                 return "";
414         }
415         status = get_full_smb_filename(do_log_ctx(), smb_fname, &fname);
416         if (!NT_STATUS_IS_OK(status)) {
417                 return "";
418         }
419         return fname;
420 }
421
422
423 /* Free function for the private data. */
424
425 static void free_private_data(void **p_data)
426 {
427         struct vfs_full_audit_private_data *pd = *(struct vfs_full_audit_private_data **)p_data;
428
429         if (pd->success_ops) {
430                 bitmap_free(pd->success_ops);
431         }
432         if (pd->failure_ops) {
433                 bitmap_free(pd->failure_ops);
434         }
435         SAFE_FREE(pd);
436         *p_data = NULL;
437 }
438
439 /* Implementation of vfs_ops.  Pass everything on to the default
440    operation but log event first. */
441
442 static int smb_full_audit_connect(vfs_handle_struct *handle,
443                          const char *svc, const char *user)
444 {
445         int result;
446         struct vfs_full_audit_private_data *pd = NULL;
447         const char *none[] = { NULL };
448         const char *all [] = { "all" };
449
450         if (!handle) {
451                 return -1;
452         }
453
454         pd = SMB_MALLOC_P(struct vfs_full_audit_private_data);
455         if (!pd) {
456                 return -1;
457         }
458         ZERO_STRUCTP(pd);
459
460         openlog("smbd_audit", 0, audit_syslog_facility(handle));
461
462         init_bitmap(&pd->success_ops,
463                     lp_parm_string_list(SNUM(handle->conn), "full_audit", "success",
464                                         none));
465         init_bitmap(&pd->failure_ops,
466                     lp_parm_string_list(SNUM(handle->conn), "full_audit", "failure",
467                                         all));
468
469         /* Store the private data. */
470         SMB_VFS_HANDLE_SET_DATA(handle, pd, free_private_data,
471                                 struct vfs_full_audit_private_data, return -1);
472
473         result = SMB_VFS_NEXT_CONNECT(handle, svc, user);
474
475         do_log(SMB_VFS_OP_CONNECT, True, handle,
476                "%s", svc);
477
478         return result;
479 }
480
481 static void smb_full_audit_disconnect(vfs_handle_struct *handle)
482 {
483         SMB_VFS_NEXT_DISCONNECT(handle);
484
485         do_log(SMB_VFS_OP_DISCONNECT, True, handle,
486                "%s", lp_servicename(SNUM(handle->conn)));
487
488         /* The bitmaps will be disconnected when the private
489            data is deleted. */
490
491         return;
492 }
493
494 static uint64_t smb_full_audit_disk_free(vfs_handle_struct *handle,
495                                     const char *path,
496                                     bool small_query, uint64_t *bsize, 
497                                     uint64_t *dfree, uint64_t *dsize)
498 {
499         uint64_t result;
500
501         result = SMB_VFS_NEXT_DISK_FREE(handle, path, small_query, bsize,
502                                         dfree, dsize);
503
504         /* Don't have a reasonable notion of failure here */
505
506         do_log(SMB_VFS_OP_DISK_FREE, True, handle, "%s", path);
507
508         return result;
509 }
510
511 static int smb_full_audit_get_quota(struct vfs_handle_struct *handle,
512                            enum SMB_QUOTA_TYPE qtype, unid_t id,
513                            SMB_DISK_QUOTA *qt)
514 {
515         int result;
516
517         result = SMB_VFS_NEXT_GET_QUOTA(handle, qtype, id, qt);
518
519         do_log(SMB_VFS_OP_GET_QUOTA, (result >= 0), handle, "");
520
521         return result;
522 }
523
524         
525 static int smb_full_audit_set_quota(struct vfs_handle_struct *handle,
526                            enum SMB_QUOTA_TYPE qtype, unid_t id,
527                            SMB_DISK_QUOTA *qt)
528 {
529         int result;
530
531         result = SMB_VFS_NEXT_SET_QUOTA(handle, qtype, id, qt);
532
533         do_log(SMB_VFS_OP_SET_QUOTA, (result >= 0), handle, "");
534
535         return result;
536 }
537
538 static int smb_full_audit_get_shadow_copy_data(struct vfs_handle_struct *handle,
539                                 struct files_struct *fsp,
540                                 SHADOW_COPY_DATA *shadow_copy_data, bool labels)
541 {
542         int result;
543
544         result = SMB_VFS_NEXT_GET_SHADOW_COPY_DATA(handle, fsp, shadow_copy_data, labels);
545
546         do_log(SMB_VFS_OP_GET_SHADOW_COPY_DATA, (result >= 0), handle, "");
547
548         return result;
549 }
550
551 static int smb_full_audit_statvfs(struct vfs_handle_struct *handle,
552                                 const char *path,
553                                 struct vfs_statvfs_struct *statbuf)
554 {
555         int result;
556
557         result = SMB_VFS_NEXT_STATVFS(handle, path, statbuf);
558
559         do_log(SMB_VFS_OP_STATVFS, (result >= 0), handle, "");
560
561         return result;
562 }
563
564 static int smb_full_audit_fs_capabilities(struct vfs_handle_struct *handle)
565 {
566         int result;
567
568         result = SMB_VFS_NEXT_FS_CAPABILITIES(handle);
569
570         do_log(SMB_VFS_OP_FS_CAPABILITIES, true, handle, "");
571
572         return result;
573 }
574
575 static SMB_STRUCT_DIR *smb_full_audit_opendir(vfs_handle_struct *handle,
576                           const char *fname, const char *mask, uint32 attr)
577 {
578         SMB_STRUCT_DIR *result;
579
580         result = SMB_VFS_NEXT_OPENDIR(handle, fname, mask, attr);
581
582         do_log(SMB_VFS_OP_OPENDIR, (result != NULL), handle, "%s", fname);
583
584         return result;
585 }
586
587 static SMB_STRUCT_DIRENT *smb_full_audit_readdir(vfs_handle_struct *handle,
588                                     SMB_STRUCT_DIR *dirp, SMB_STRUCT_STAT *sbuf)
589 {
590         SMB_STRUCT_DIRENT *result;
591
592         result = SMB_VFS_NEXT_READDIR(handle, dirp, sbuf);
593
594         /* This operation has no reasonable error condition
595          * (End of dir is also failure), so always succeed.
596          */
597         do_log(SMB_VFS_OP_READDIR, True, handle, "");
598
599         return result;
600 }
601
602 static void smb_full_audit_seekdir(vfs_handle_struct *handle,
603                         SMB_STRUCT_DIR *dirp, long offset)
604 {
605         SMB_VFS_NEXT_SEEKDIR(handle, dirp, offset);
606
607         do_log(SMB_VFS_OP_SEEKDIR, True, handle, "");
608         return;
609 }
610
611 static long smb_full_audit_telldir(vfs_handle_struct *handle,
612                         SMB_STRUCT_DIR *dirp)
613 {
614         long result;
615
616         result = SMB_VFS_NEXT_TELLDIR(handle, dirp);
617
618         do_log(SMB_VFS_OP_TELLDIR, True, handle, "");
619
620         return result;
621 }
622
623 static void smb_full_audit_rewinddir(vfs_handle_struct *handle,
624                         SMB_STRUCT_DIR *dirp)
625 {
626         SMB_VFS_NEXT_REWINDDIR(handle, dirp);
627
628         do_log(SMB_VFS_OP_REWINDDIR, True, handle, "");
629         return;
630 }
631
632 static int smb_full_audit_mkdir(vfs_handle_struct *handle,
633                        const char *path, mode_t mode)
634 {
635         int result;
636         
637         result = SMB_VFS_NEXT_MKDIR(handle, path, mode);
638         
639         do_log(SMB_VFS_OP_MKDIR, (result >= 0), handle, "%s", path);
640
641         return result;
642 }
643
644 static int smb_full_audit_rmdir(vfs_handle_struct *handle,
645                        const char *path)
646 {
647         int result;
648         
649         result = SMB_VFS_NEXT_RMDIR(handle, path);
650
651         do_log(SMB_VFS_OP_RMDIR, (result >= 0), handle, "%s", path);
652
653         return result;
654 }
655
656 static int smb_full_audit_closedir(vfs_handle_struct *handle,
657                           SMB_STRUCT_DIR *dirp)
658 {
659         int result;
660
661         result = SMB_VFS_NEXT_CLOSEDIR(handle, dirp);
662         
663         do_log(SMB_VFS_OP_CLOSEDIR, (result >= 0), handle, "");
664
665         return result;
666 }
667
668 static void smb_full_audit_init_search_op(vfs_handle_struct *handle,
669                         SMB_STRUCT_DIR *dirp)
670 {
671         SMB_VFS_NEXT_INIT_SEARCH_OP(handle, dirp);
672
673         do_log(SMB_VFS_OP_INIT_SEARCH_OP, True, handle, "");
674         return;
675 }
676
677 static int smb_full_audit_open(vfs_handle_struct *handle,
678                                struct smb_filename *smb_fname,
679                                files_struct *fsp, int flags, mode_t mode)
680 {
681         int result;
682         
683         result = SMB_VFS_NEXT_OPEN(handle, smb_fname, fsp, flags, mode);
684
685         do_log(SMB_VFS_OP_OPEN, (result >= 0), handle, "%s|%s",
686                ((flags & O_WRONLY) || (flags & O_RDWR))?"w":"r",
687                smb_fname_str_do_log(smb_fname));
688
689         return result;
690 }
691
692 static NTSTATUS smb_full_audit_create_file(vfs_handle_struct *handle,
693                                       struct smb_request *req,
694                                       uint16_t root_dir_fid,
695                                       struct smb_filename *smb_fname,
696                                       uint32_t access_mask,
697                                       uint32_t share_access,
698                                       uint32_t create_disposition,
699                                       uint32_t create_options,
700                                       uint32_t file_attributes,
701                                       uint32_t oplock_request,
702                                       uint64_t allocation_size,
703                                       struct security_descriptor *sd,
704                                       struct ea_list *ea_list,
705                                       files_struct **result_fsp,
706                                       int *pinfo)
707 {
708         NTSTATUS result;
709
710         result = SMB_VFS_NEXT_CREATE_FILE(
711                 handle,                                 /* handle */
712                 req,                                    /* req */
713                 root_dir_fid,                           /* root_dir_fid */
714                 smb_fname,                              /* fname */
715                 access_mask,                            /* access_mask */
716                 share_access,                           /* share_access */
717                 create_disposition,                     /* create_disposition*/
718                 create_options,                         /* create_options */
719                 file_attributes,                        /* file_attributes */
720                 oplock_request,                         /* oplock_request */
721                 allocation_size,                        /* allocation_size */
722                 sd,                                     /* sd */
723                 ea_list,                                /* ea_list */
724                 result_fsp,                             /* result */
725                 pinfo);                                 /* pinfo */
726
727         do_log(SMB_VFS_OP_CREATE_FILE, (NT_STATUS_IS_OK(result)), handle, "0x%x|%s",
728                access_mask, smb_fname_str_do_log(smb_fname));
729
730         return result;
731 }
732
733 static int smb_full_audit_close(vfs_handle_struct *handle, files_struct *fsp)
734 {
735         int result;
736         
737         result = SMB_VFS_NEXT_CLOSE(handle, fsp);
738
739         do_log(SMB_VFS_OP_CLOSE, (result >= 0), handle, "%s", fsp->fsp_name);
740
741         return result;
742 }
743
744 static ssize_t smb_full_audit_read(vfs_handle_struct *handle, files_struct *fsp,
745                           void *data, size_t n)
746 {
747         ssize_t result;
748
749         result = SMB_VFS_NEXT_READ(handle, fsp, data, n);
750
751         do_log(SMB_VFS_OP_READ, (result >= 0), handle, "%s", fsp->fsp_name);
752
753         return result;
754 }
755
756 static ssize_t smb_full_audit_pread(vfs_handle_struct *handle, files_struct *fsp,
757                            void *data, size_t n, SMB_OFF_T offset)
758 {
759         ssize_t result;
760
761         result = SMB_VFS_NEXT_PREAD(handle, fsp, data, n, offset);
762
763         do_log(SMB_VFS_OP_PREAD, (result >= 0), handle, "%s", fsp->fsp_name);
764
765         return result;
766 }
767
768 static ssize_t smb_full_audit_write(vfs_handle_struct *handle, files_struct *fsp,
769                            const void *data, size_t n)
770 {
771         ssize_t result;
772
773         result = SMB_VFS_NEXT_WRITE(handle, fsp, data, n);
774
775         do_log(SMB_VFS_OP_WRITE, (result >= 0), handle, "%s", fsp->fsp_name);
776
777         return result;
778 }
779
780 static ssize_t smb_full_audit_pwrite(vfs_handle_struct *handle, files_struct *fsp,
781                             const void *data, size_t n,
782                             SMB_OFF_T offset)
783 {
784         ssize_t result;
785
786         result = SMB_VFS_NEXT_PWRITE(handle, fsp, data, n, offset);
787
788         do_log(SMB_VFS_OP_PWRITE, (result >= 0), handle, "%s", fsp->fsp_name);
789
790         return result;
791 }
792
793 static SMB_OFF_T smb_full_audit_lseek(vfs_handle_struct *handle, files_struct *fsp,
794                              SMB_OFF_T offset, int whence)
795 {
796         ssize_t result;
797
798         result = SMB_VFS_NEXT_LSEEK(handle, fsp, offset, whence);
799
800         do_log(SMB_VFS_OP_LSEEK, (result != (ssize_t)-1), handle,
801                "%s", fsp->fsp_name);
802
803         return result;
804 }
805
806 static ssize_t smb_full_audit_sendfile(vfs_handle_struct *handle, int tofd,
807                               files_struct *fromfsp,
808                               const DATA_BLOB *hdr, SMB_OFF_T offset,
809                               size_t n)
810 {
811         ssize_t result;
812
813         result = SMB_VFS_NEXT_SENDFILE(handle, tofd, fromfsp, hdr, offset, n);
814
815         do_log(SMB_VFS_OP_SENDFILE, (result >= 0), handle,
816                "%s", fromfsp->fsp_name);
817
818         return result;
819 }
820
821 static ssize_t smb_full_audit_recvfile(vfs_handle_struct *handle, int fromfd,
822                       files_struct *tofsp,
823                               SMB_OFF_T offset,
824                               size_t n)
825 {
826         ssize_t result;
827
828         result = SMB_VFS_NEXT_RECVFILE(handle, fromfd, tofsp, offset, n);
829
830         do_log(SMB_VFS_OP_RECVFILE, (result >= 0), handle,
831                "%s", tofsp->fsp_name);
832
833         return result;
834 }
835
836 static int smb_full_audit_rename(vfs_handle_struct *handle,
837                                  const struct smb_filename *smb_fname_src,
838                                  const struct smb_filename *smb_fname_dst)
839 {
840         int result;
841         
842         result = SMB_VFS_NEXT_RENAME(handle, smb_fname_src, smb_fname_dst);
843
844         do_log(SMB_VFS_OP_RENAME, (result >= 0), handle, "%s|%s",
845                smb_fname_str_do_log(smb_fname_src),
846                smb_fname_str_do_log(smb_fname_dst));
847
848         return result;    
849 }
850
851 static int smb_full_audit_fsync(vfs_handle_struct *handle, files_struct *fsp)
852 {
853         int result;
854         
855         result = SMB_VFS_NEXT_FSYNC(handle, fsp);
856
857         do_log(SMB_VFS_OP_FSYNC, (result >= 0), handle, "%s", fsp->fsp_name);
858
859         return result;    
860 }
861
862 static int smb_full_audit_stat(vfs_handle_struct *handle,
863                                struct smb_filename *smb_fname)
864 {
865         int result;
866         
867         result = SMB_VFS_NEXT_STAT(handle, smb_fname);
868
869         do_log(SMB_VFS_OP_STAT, (result >= 0), handle, "%s",
870                smb_fname_str_do_log(smb_fname));
871
872         return result;    
873 }
874
875 static int smb_full_audit_fstat(vfs_handle_struct *handle, files_struct *fsp,
876                        SMB_STRUCT_STAT *sbuf)
877 {
878         int result;
879         
880         result = SMB_VFS_NEXT_FSTAT(handle, fsp, sbuf);
881
882         do_log(SMB_VFS_OP_FSTAT, (result >= 0), handle, "%s", fsp->fsp_name);
883
884         return result;
885 }
886
887 static int smb_full_audit_lstat(vfs_handle_struct *handle,
888                                 struct smb_filename *smb_fname)
889 {
890         int result;
891         
892         result = SMB_VFS_NEXT_LSTAT(handle, smb_fname);
893
894         do_log(SMB_VFS_OP_LSTAT, (result >= 0), handle, "%s",
895                smb_fname_str_do_log(smb_fname));
896
897         return result;    
898 }
899
900 static int smb_full_audit_get_alloc_size(vfs_handle_struct *handle,
901                        files_struct *fsp, const SMB_STRUCT_STAT *sbuf)
902 {
903         int result;
904
905         result = SMB_VFS_NEXT_GET_ALLOC_SIZE(handle, fsp, sbuf);
906
907         do_log(SMB_VFS_OP_GET_ALLOC_SIZE, (result >= 0), handle, "%d", result);
908
909         return result;
910 }
911
912 static int smb_full_audit_unlink(vfs_handle_struct *handle,
913                                  const struct smb_filename *smb_fname)
914 {
915         int result;
916         
917         result = SMB_VFS_NEXT_UNLINK(handle, smb_fname);
918
919         do_log(SMB_VFS_OP_UNLINK, (result >= 0), handle, "%s",
920                smb_fname_str_do_log(smb_fname));
921
922         return result;
923 }
924
925 static int smb_full_audit_chmod(vfs_handle_struct *handle,
926                        const char *path, mode_t mode)
927 {
928         int result;
929
930         result = SMB_VFS_NEXT_CHMOD(handle, path, mode);
931
932         do_log(SMB_VFS_OP_CHMOD, (result >= 0), handle, "%s|%o", path, mode);
933
934         return result;
935 }
936
937 static int smb_full_audit_fchmod(vfs_handle_struct *handle, files_struct *fsp,
938                         mode_t mode)
939 {
940         int result;
941         
942         result = SMB_VFS_NEXT_FCHMOD(handle, fsp, mode);
943
944         do_log(SMB_VFS_OP_FCHMOD, (result >= 0), handle,
945                "%s|%o", fsp->fsp_name, mode);
946
947         return result;
948 }
949
950 static int smb_full_audit_chown(vfs_handle_struct *handle,
951                        const char *path, uid_t uid, gid_t gid)
952 {
953         int result;
954
955         result = SMB_VFS_NEXT_CHOWN(handle, path, uid, gid);
956
957         do_log(SMB_VFS_OP_CHOWN, (result >= 0), handle, "%s|%ld|%ld",
958                path, (long int)uid, (long int)gid);
959
960         return result;
961 }
962
963 static int smb_full_audit_fchown(vfs_handle_struct *handle, files_struct *fsp,
964                         uid_t uid, gid_t gid)
965 {
966         int result;
967
968         result = SMB_VFS_NEXT_FCHOWN(handle, fsp, uid, gid);
969
970         do_log(SMB_VFS_OP_FCHOWN, (result >= 0), handle, "%s|%ld|%ld",
971                fsp->fsp_name, (long int)uid, (long int)gid);
972
973         return result;
974 }
975
976 static int smb_full_audit_lchown(vfs_handle_struct *handle,
977                        const char *path, uid_t uid, gid_t gid)
978 {
979         int result;
980
981         result = SMB_VFS_NEXT_LCHOWN(handle, path, uid, gid);
982
983         do_log(SMB_VFS_OP_LCHOWN, (result >= 0), handle, "%s|%ld|%ld",
984                path, (long int)uid, (long int)gid);
985
986         return result;
987 }
988
989 static int smb_full_audit_chdir(vfs_handle_struct *handle,
990                        const char *path)
991 {
992         int result;
993
994         result = SMB_VFS_NEXT_CHDIR(handle, path);
995
996         do_log(SMB_VFS_OP_CHDIR, (result >= 0), handle, "chdir|%s", path);
997
998         return result;
999 }
1000
1001 static char *smb_full_audit_getwd(vfs_handle_struct *handle,
1002                          char *path)
1003 {
1004         char *result;
1005
1006         result = SMB_VFS_NEXT_GETWD(handle, path);
1007         
1008         do_log(SMB_VFS_OP_GETWD, (result != NULL), handle, "%s", path);
1009
1010         return result;
1011 }
1012
1013 static int smb_full_audit_ntimes(vfs_handle_struct *handle,
1014                                  const struct smb_filename *smb_fname,
1015                                  struct smb_file_time *ft)
1016 {
1017         int result;
1018
1019         result = SMB_VFS_NEXT_NTIMES(handle, smb_fname, ft);
1020
1021         do_log(SMB_VFS_OP_NTIMES, (result >= 0), handle, "%s",
1022                smb_fname_str_do_log(smb_fname));
1023
1024         return result;
1025 }
1026
1027 static int smb_full_audit_ftruncate(vfs_handle_struct *handle, files_struct *fsp,
1028                            SMB_OFF_T len)
1029 {
1030         int result;
1031
1032         result = SMB_VFS_NEXT_FTRUNCATE(handle, fsp, len);
1033
1034         do_log(SMB_VFS_OP_FTRUNCATE, (result >= 0), handle,
1035                "%s", fsp->fsp_name);
1036
1037         return result;
1038 }
1039
1040 static bool smb_full_audit_lock(vfs_handle_struct *handle, files_struct *fsp,
1041                        int op, SMB_OFF_T offset, SMB_OFF_T count, int type)
1042 {
1043         bool result;
1044
1045         result = SMB_VFS_NEXT_LOCK(handle, fsp, op, offset, count, type);
1046
1047         do_log(SMB_VFS_OP_LOCK, result, handle, "%s", fsp->fsp_name);
1048
1049         return result;
1050 }
1051
1052 static int smb_full_audit_kernel_flock(struct vfs_handle_struct *handle,
1053                                        struct files_struct *fsp,
1054                                        uint32 share_mode)
1055 {
1056         int result;
1057
1058         result = SMB_VFS_NEXT_KERNEL_FLOCK(handle, fsp, share_mode);
1059
1060         do_log(SMB_VFS_OP_KERNEL_FLOCK, (result >= 0), handle, "%s",
1061                fsp->fsp_name);
1062
1063         return result;
1064 }
1065
1066 static int smb_full_audit_linux_setlease(vfs_handle_struct *handle, files_struct *fsp,
1067                                  int leasetype)
1068 {
1069         int result;
1070
1071         result = SMB_VFS_NEXT_LINUX_SETLEASE(handle, fsp, leasetype);
1072
1073         do_log(SMB_VFS_OP_LINUX_SETLEASE, (result >= 0), handle, "%s",
1074                fsp->fsp_name);
1075
1076         return result;
1077 }
1078
1079 static bool smb_full_audit_getlock(vfs_handle_struct *handle, files_struct *fsp,
1080                        SMB_OFF_T *poffset, SMB_OFF_T *pcount, int *ptype, pid_t *ppid)
1081 {
1082         bool result;
1083
1084         result = SMB_VFS_NEXT_GETLOCK(handle, fsp, poffset, pcount, ptype, ppid);
1085
1086         do_log(SMB_VFS_OP_GETLOCK, result, handle, "%s", fsp->fsp_name);
1087
1088         return result;
1089 }
1090
1091 static int smb_full_audit_symlink(vfs_handle_struct *handle,
1092                          const char *oldpath, const char *newpath)
1093 {
1094         int result;
1095
1096         result = SMB_VFS_NEXT_SYMLINK(handle, oldpath, newpath);
1097
1098         do_log(SMB_VFS_OP_SYMLINK, (result >= 0), handle,
1099                "%s|%s", oldpath, newpath);
1100
1101         return result;
1102 }
1103
1104 static int smb_full_audit_readlink(vfs_handle_struct *handle,
1105                           const char *path, char *buf, size_t bufsiz)
1106 {
1107         int result;
1108
1109         result = SMB_VFS_NEXT_READLINK(handle, path, buf, bufsiz);
1110
1111         do_log(SMB_VFS_OP_READLINK, (result >= 0), handle, "%s", path);
1112
1113         return result;
1114 }
1115
1116 static int smb_full_audit_link(vfs_handle_struct *handle,
1117                       const char *oldpath, const char *newpath)
1118 {
1119         int result;
1120
1121         result = SMB_VFS_NEXT_LINK(handle, oldpath, newpath);
1122
1123         do_log(SMB_VFS_OP_LINK, (result >= 0), handle,
1124                "%s|%s", oldpath, newpath);
1125
1126         return result;
1127 }
1128
1129 static int smb_full_audit_mknod(vfs_handle_struct *handle,
1130                        const char *pathname, mode_t mode, SMB_DEV_T dev)
1131 {
1132         int result;
1133
1134         result = SMB_VFS_NEXT_MKNOD(handle, pathname, mode, dev);
1135
1136         do_log(SMB_VFS_OP_MKNOD, (result >= 0), handle, "%s", pathname);
1137
1138         return result;
1139 }
1140
1141 static char *smb_full_audit_realpath(vfs_handle_struct *handle,
1142                             const char *path, char *resolved_path)
1143 {
1144         char *result;
1145
1146         result = SMB_VFS_NEXT_REALPATH(handle, path, resolved_path);
1147
1148         do_log(SMB_VFS_OP_REALPATH, (result != NULL), handle, "%s", path);
1149
1150         return result;
1151 }
1152
1153 static NTSTATUS smb_full_audit_notify_watch(struct vfs_handle_struct *handle,
1154                         struct sys_notify_context *ctx,
1155                         struct notify_entry *e,
1156                         void (*callback)(struct sys_notify_context *ctx,
1157                                         void *private_data,
1158                                         struct notify_event *ev),
1159                         void *private_data, void *handle_p)
1160 {
1161         NTSTATUS result;
1162
1163         result = SMB_VFS_NEXT_NOTIFY_WATCH(handle, ctx, e, callback, private_data, handle_p);
1164
1165         do_log(SMB_VFS_OP_NOTIFY_WATCH, NT_STATUS_IS_OK(result), handle, "");
1166
1167         return result;
1168 }
1169
1170 static int smb_full_audit_chflags(vfs_handle_struct *handle,
1171                             const char *path, unsigned int flags)
1172 {
1173         int result;
1174
1175         result = SMB_VFS_NEXT_CHFLAGS(handle, path, flags);
1176
1177         do_log(SMB_VFS_OP_CHFLAGS, (result != 0), handle, "%s", path);
1178
1179         return result;
1180 }
1181
1182 static struct file_id smb_full_audit_file_id_create(struct vfs_handle_struct *handle,
1183                                                     const SMB_STRUCT_STAT *sbuf)
1184 {
1185         struct file_id id_zero;
1186         struct file_id result;
1187
1188         ZERO_STRUCT(id_zero);
1189
1190         result = SMB_VFS_NEXT_FILE_ID_CREATE(handle, sbuf);
1191
1192         do_log(SMB_VFS_OP_FILE_ID_CREATE,
1193                !file_id_equal(&id_zero, &result),
1194                handle, "%s", file_id_string_tos(&result));
1195
1196         return result;
1197 }
1198
1199 static NTSTATUS smb_full_audit_streaminfo(vfs_handle_struct *handle,
1200                                           struct files_struct *fsp,
1201                                           const char *fname,
1202                                           TALLOC_CTX *mem_ctx,
1203                                           unsigned int *pnum_streams,
1204                                           struct stream_struct **pstreams)
1205 {
1206         NTSTATUS result;
1207
1208         result = SMB_VFS_NEXT_STREAMINFO(handle, fsp, fname, mem_ctx,
1209                                          pnum_streams, pstreams);
1210
1211         do_log(SMB_VFS_OP_STREAMINFO, NT_STATUS_IS_OK(result), handle,
1212                "%s", fname);
1213
1214         return result;
1215 }
1216
1217 static int smb_full_audit_get_real_filename(struct vfs_handle_struct *handle,
1218                                             const char *path,
1219                                             const char *name,
1220                                             TALLOC_CTX *mem_ctx,
1221                                             char **found_name)
1222 {
1223         int result;
1224
1225         result = SMB_VFS_NEXT_GET_REAL_FILENAME(handle, path, name, mem_ctx,
1226                                                 found_name);
1227
1228         do_log(SMB_VFS_OP_GET_REAL_FILENAME, (result == 0), handle,
1229                "%s/%s->%s", path, name, (result == 0) ? "" : *found_name);
1230
1231         return result;
1232 }
1233
1234 static const char *smb_full_audit_connectpath(vfs_handle_struct *handle,
1235                                               const char *fname)
1236 {
1237         const char *result;
1238
1239         result = SMB_VFS_NEXT_CONNECTPATH(handle, fname);
1240
1241         do_log(SMB_VFS_OP_CONNECTPATH, result != NULL, handle,
1242                "%s", fname);
1243
1244         return result;
1245 }
1246
1247 static NTSTATUS smb_full_audit_brl_lock_windows(struct vfs_handle_struct *handle,
1248                                                 struct byte_range_lock *br_lck,
1249                                                 struct lock_struct *plock,
1250                                                 bool blocking_lock,
1251                                                 struct blocking_lock_record *blr)
1252 {
1253         NTSTATUS result;
1254
1255         result = SMB_VFS_NEXT_BRL_LOCK_WINDOWS(handle, br_lck, plock,
1256             blocking_lock, blr);
1257
1258         do_log(SMB_VFS_OP_BRL_LOCK_WINDOWS, NT_STATUS_IS_OK(result), handle,
1259             "%s:%llu-%llu. type=%d. blocking=%d", br_lck->fsp->fsp_name,
1260             plock->start, plock->size, plock->lock_type, blocking_lock );
1261
1262         return result;
1263 }
1264
1265 static bool smb_full_audit_brl_unlock_windows(struct vfs_handle_struct *handle,
1266                                               struct messaging_context *msg_ctx,
1267                                               struct byte_range_lock *br_lck,
1268                                               const struct lock_struct *plock)
1269 {
1270         bool result;
1271
1272         result = SMB_VFS_NEXT_BRL_UNLOCK_WINDOWS(handle, msg_ctx, br_lck,
1273             plock);
1274
1275         do_log(SMB_VFS_OP_BRL_UNLOCK_WINDOWS, (result == 0), handle,
1276             "%s:%llu-%llu:%d", br_lck->fsp->fsp_name, plock->start,
1277             plock->size, plock->lock_type);
1278
1279         return result;
1280 }
1281
1282 static bool smb_full_audit_brl_cancel_windows(struct vfs_handle_struct *handle,
1283                                               struct byte_range_lock *br_lck,
1284                                               struct lock_struct *plock,
1285                                               struct blocking_lock_record *blr)
1286 {
1287         bool result;
1288
1289         result = SMB_VFS_NEXT_BRL_CANCEL_WINDOWS(handle, br_lck, plock, blr);
1290
1291         do_log(SMB_VFS_OP_BRL_CANCEL_WINDOWS, (result == 0), handle,
1292             "%s:%llu-%llu:%d", br_lck->fsp->fsp_name, plock->start,
1293             plock->size);
1294
1295         return result;
1296 }
1297
1298 static bool smb_full_audit_strict_lock(struct vfs_handle_struct *handle,
1299                                        struct files_struct *fsp,
1300                                        struct lock_struct *plock)
1301 {
1302         bool result;
1303
1304         result = SMB_VFS_NEXT_STRICT_LOCK(handle, fsp, plock);
1305
1306         do_log(SMB_VFS_OP_STRICT_LOCK, result, handle,
1307             "%s:%llu-%llu:%d", fsp->fsp_name, plock->start,
1308             plock->size);
1309
1310         return result;
1311 }
1312
1313 static void smb_full_audit_strict_unlock(struct vfs_handle_struct *handle,
1314                                          struct files_struct *fsp,
1315                                          struct lock_struct *plock)
1316 {
1317         SMB_VFS_NEXT_STRICT_UNLOCK(handle, fsp, plock);
1318
1319         do_log(SMB_VFS_OP_STRICT_UNLOCK, true, handle,
1320             "%s:%llu-%llu:%d", fsp->fsp_name, plock->start,
1321             plock->size);
1322
1323         return;
1324 }
1325
1326 static NTSTATUS smb_full_audit_fget_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
1327                                 uint32 security_info,
1328                                 SEC_DESC **ppdesc)
1329 {
1330         NTSTATUS result;
1331
1332         result = SMB_VFS_NEXT_FGET_NT_ACL(handle, fsp, security_info, ppdesc);
1333
1334         do_log(SMB_VFS_OP_FGET_NT_ACL, NT_STATUS_IS_OK(result), handle,
1335                "%s", fsp->fsp_name);
1336
1337         return result;
1338 }
1339
1340 static NTSTATUS smb_full_audit_get_nt_acl(vfs_handle_struct *handle,
1341                                           const char *name,
1342                                           uint32 security_info,
1343                                           SEC_DESC **ppdesc)
1344 {
1345         NTSTATUS result;
1346
1347         result = SMB_VFS_NEXT_GET_NT_ACL(handle, name, security_info, ppdesc);
1348
1349         do_log(SMB_VFS_OP_GET_NT_ACL, NT_STATUS_IS_OK(result), handle,
1350                "%s", name);
1351
1352         return result;
1353 }
1354
1355 static NTSTATUS smb_full_audit_fset_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
1356                               uint32 security_info_sent,
1357                               const SEC_DESC *psd)
1358 {
1359         NTSTATUS result;
1360
1361         result = SMB_VFS_NEXT_FSET_NT_ACL(handle, fsp, security_info_sent, psd);
1362
1363         do_log(SMB_VFS_OP_FSET_NT_ACL, NT_STATUS_IS_OK(result), handle, "%s", fsp->fsp_name);
1364
1365         return result;
1366 }
1367
1368 static int smb_full_audit_chmod_acl(vfs_handle_struct *handle,
1369                            const char *path, mode_t mode)
1370 {
1371         int result;
1372         
1373         result = SMB_VFS_NEXT_CHMOD_ACL(handle, path, mode);
1374
1375         do_log(SMB_VFS_OP_CHMOD_ACL, (result >= 0), handle,
1376                "%s|%o", path, mode);
1377
1378         return result;
1379 }
1380
1381 static int smb_full_audit_fchmod_acl(vfs_handle_struct *handle, files_struct *fsp,
1382                                      mode_t mode)
1383 {
1384         int result;
1385         
1386         result = SMB_VFS_NEXT_FCHMOD_ACL(handle, fsp, mode);
1387
1388         do_log(SMB_VFS_OP_FCHMOD_ACL, (result >= 0), handle,
1389                "%s|%o", fsp->fsp_name, mode);
1390
1391         return result;
1392 }
1393
1394 static int smb_full_audit_sys_acl_get_entry(vfs_handle_struct *handle,
1395
1396                                    SMB_ACL_T theacl, int entry_id,
1397                                    SMB_ACL_ENTRY_T *entry_p)
1398 {
1399         int result;
1400
1401         result = SMB_VFS_NEXT_SYS_ACL_GET_ENTRY(handle, theacl, entry_id,
1402                                                 entry_p);
1403
1404         do_log(SMB_VFS_OP_SYS_ACL_GET_ENTRY, (result >= 0), handle,
1405                "");
1406
1407         return result;
1408 }
1409
1410 static int smb_full_audit_sys_acl_get_tag_type(vfs_handle_struct *handle,
1411
1412                                       SMB_ACL_ENTRY_T entry_d,
1413                                       SMB_ACL_TAG_T *tag_type_p)
1414 {
1415         int result;
1416
1417         result = SMB_VFS_NEXT_SYS_ACL_GET_TAG_TYPE(handle, entry_d,
1418                                                    tag_type_p);
1419
1420         do_log(SMB_VFS_OP_SYS_ACL_GET_TAG_TYPE, (result >= 0), handle,
1421                "");
1422
1423         return result;
1424 }
1425
1426 static int smb_full_audit_sys_acl_get_permset(vfs_handle_struct *handle,
1427
1428                                      SMB_ACL_ENTRY_T entry_d,
1429                                      SMB_ACL_PERMSET_T *permset_p)
1430 {
1431         int result;
1432
1433         result = SMB_VFS_NEXT_SYS_ACL_GET_PERMSET(handle, entry_d,
1434                                                   permset_p);
1435
1436         do_log(SMB_VFS_OP_SYS_ACL_GET_PERMSET, (result >= 0), handle,
1437                "");
1438
1439         return result;
1440 }
1441
1442 static void * smb_full_audit_sys_acl_get_qualifier(vfs_handle_struct *handle,
1443
1444                                           SMB_ACL_ENTRY_T entry_d)
1445 {
1446         void *result;
1447
1448         result = SMB_VFS_NEXT_SYS_ACL_GET_QUALIFIER(handle, entry_d);
1449
1450         do_log(SMB_VFS_OP_SYS_ACL_GET_QUALIFIER, (result != NULL), handle,
1451                "");
1452
1453         return result;
1454 }
1455
1456 static SMB_ACL_T smb_full_audit_sys_acl_get_file(vfs_handle_struct *handle,
1457                                         const char *path_p,
1458                                         SMB_ACL_TYPE_T type)
1459 {
1460         SMB_ACL_T result;
1461
1462         result = SMB_VFS_NEXT_SYS_ACL_GET_FILE(handle, path_p, type);
1463
1464         do_log(SMB_VFS_OP_SYS_ACL_GET_FILE, (result != NULL), handle,
1465                "%s", path_p);
1466
1467         return result;
1468 }
1469
1470 static SMB_ACL_T smb_full_audit_sys_acl_get_fd(vfs_handle_struct *handle,
1471                                       files_struct *fsp)
1472 {
1473         SMB_ACL_T result;
1474
1475         result = SMB_VFS_NEXT_SYS_ACL_GET_FD(handle, fsp);
1476
1477         do_log(SMB_VFS_OP_SYS_ACL_GET_FD, (result != NULL), handle,
1478                "%s", fsp->fsp_name);
1479
1480         return result;
1481 }
1482
1483 static int smb_full_audit_sys_acl_clear_perms(vfs_handle_struct *handle,
1484
1485                                      SMB_ACL_PERMSET_T permset)
1486 {
1487         int result;
1488
1489         result = SMB_VFS_NEXT_SYS_ACL_CLEAR_PERMS(handle, permset);
1490
1491         do_log(SMB_VFS_OP_SYS_ACL_CLEAR_PERMS, (result >= 0), handle,
1492                "");
1493
1494         return result;
1495 }
1496
1497 static int smb_full_audit_sys_acl_add_perm(vfs_handle_struct *handle,
1498
1499                                   SMB_ACL_PERMSET_T permset,
1500                                   SMB_ACL_PERM_T perm)
1501 {
1502         int result;
1503
1504         result = SMB_VFS_NEXT_SYS_ACL_ADD_PERM(handle, permset, perm);
1505
1506         do_log(SMB_VFS_OP_SYS_ACL_ADD_PERM, (result >= 0), handle,
1507                "");
1508
1509         return result;
1510 }
1511
1512 static char * smb_full_audit_sys_acl_to_text(vfs_handle_struct *handle,
1513                                     SMB_ACL_T theacl,
1514                                     ssize_t *plen)
1515 {
1516         char * result;
1517
1518         result = SMB_VFS_NEXT_SYS_ACL_TO_TEXT(handle, theacl, plen);
1519
1520         do_log(SMB_VFS_OP_SYS_ACL_TO_TEXT, (result != NULL), handle,
1521                "");
1522
1523         return result;
1524 }
1525
1526 static SMB_ACL_T smb_full_audit_sys_acl_init(vfs_handle_struct *handle,
1527
1528                                     int count)
1529 {
1530         SMB_ACL_T result;
1531
1532         result = SMB_VFS_NEXT_SYS_ACL_INIT(handle, count);
1533
1534         do_log(SMB_VFS_OP_SYS_ACL_INIT, (result != NULL), handle,
1535                "");
1536
1537         return result;
1538 }
1539
1540 static int smb_full_audit_sys_acl_create_entry(vfs_handle_struct *handle,
1541                                       SMB_ACL_T *pacl,
1542                                       SMB_ACL_ENTRY_T *pentry)
1543 {
1544         int result;
1545
1546         result = SMB_VFS_NEXT_SYS_ACL_CREATE_ENTRY(handle, pacl, pentry);
1547
1548         do_log(SMB_VFS_OP_SYS_ACL_CREATE_ENTRY, (result >= 0), handle,
1549                "");
1550
1551         return result;
1552 }
1553
1554 static int smb_full_audit_sys_acl_set_tag_type(vfs_handle_struct *handle,
1555
1556                                       SMB_ACL_ENTRY_T entry,
1557                                       SMB_ACL_TAG_T tagtype)
1558 {
1559         int result;
1560
1561         result = SMB_VFS_NEXT_SYS_ACL_SET_TAG_TYPE(handle, entry,
1562                                                    tagtype);
1563
1564         do_log(SMB_VFS_OP_SYS_ACL_SET_TAG_TYPE, (result >= 0), handle,
1565                "");
1566
1567         return result;
1568 }
1569
1570 static int smb_full_audit_sys_acl_set_qualifier(vfs_handle_struct *handle,
1571
1572                                        SMB_ACL_ENTRY_T entry,
1573                                        void *qual)
1574 {
1575         int result;
1576
1577         result = SMB_VFS_NEXT_SYS_ACL_SET_QUALIFIER(handle, entry, qual);
1578
1579         do_log(SMB_VFS_OP_SYS_ACL_SET_QUALIFIER, (result >= 0), handle,
1580                "");
1581
1582         return result;
1583 }
1584
1585 static int smb_full_audit_sys_acl_set_permset(vfs_handle_struct *handle,
1586
1587                                      SMB_ACL_ENTRY_T entry,
1588                                      SMB_ACL_PERMSET_T permset)
1589 {
1590         int result;
1591
1592         result = SMB_VFS_NEXT_SYS_ACL_SET_PERMSET(handle, entry, permset);
1593
1594         do_log(SMB_VFS_OP_SYS_ACL_SET_PERMSET, (result >= 0), handle,
1595                "");
1596
1597         return result;
1598 }
1599
1600 static int smb_full_audit_sys_acl_valid(vfs_handle_struct *handle,
1601
1602                                SMB_ACL_T theacl )
1603 {
1604         int result;
1605
1606         result = SMB_VFS_NEXT_SYS_ACL_VALID(handle, theacl);
1607
1608         do_log(SMB_VFS_OP_SYS_ACL_VALID, (result >= 0), handle,
1609                "");
1610
1611         return result;
1612 }
1613
1614 static int smb_full_audit_sys_acl_set_file(vfs_handle_struct *handle,
1615
1616                                   const char *name, SMB_ACL_TYPE_T acltype,
1617                                   SMB_ACL_T theacl)
1618 {
1619         int result;
1620
1621         result = SMB_VFS_NEXT_SYS_ACL_SET_FILE(handle, name, acltype,
1622                                                theacl);
1623
1624         do_log(SMB_VFS_OP_SYS_ACL_SET_FILE, (result >= 0), handle,
1625                "%s", name);
1626
1627         return result;
1628 }
1629
1630 static int smb_full_audit_sys_acl_set_fd(vfs_handle_struct *handle, files_struct *fsp,
1631                                 SMB_ACL_T theacl)
1632 {
1633         int result;
1634
1635         result = SMB_VFS_NEXT_SYS_ACL_SET_FD(handle, fsp, theacl);
1636
1637         do_log(SMB_VFS_OP_SYS_ACL_SET_FD, (result >= 0), handle,
1638                "%s", fsp->fsp_name);
1639
1640         return result;
1641 }
1642
1643 static int smb_full_audit_sys_acl_delete_def_file(vfs_handle_struct *handle,
1644
1645                                          const char *path)
1646 {
1647         int result;
1648
1649         result = SMB_VFS_NEXT_SYS_ACL_DELETE_DEF_FILE(handle, path);
1650
1651         do_log(SMB_VFS_OP_SYS_ACL_DELETE_DEF_FILE, (result >= 0), handle,
1652                "%s", path);
1653
1654         return result;
1655 }
1656
1657 static int smb_full_audit_sys_acl_get_perm(vfs_handle_struct *handle,
1658
1659                                   SMB_ACL_PERMSET_T permset,
1660                                   SMB_ACL_PERM_T perm)
1661 {
1662         int result;
1663
1664         result = SMB_VFS_NEXT_SYS_ACL_GET_PERM(handle, permset, perm);
1665
1666         do_log(SMB_VFS_OP_SYS_ACL_GET_PERM, (result >= 0), handle,
1667                "");
1668
1669         return result;
1670 }
1671
1672 static int smb_full_audit_sys_acl_free_text(vfs_handle_struct *handle,
1673
1674                                    char *text)
1675 {
1676         int result;
1677
1678         result = SMB_VFS_NEXT_SYS_ACL_FREE_TEXT(handle, text);
1679
1680         do_log(SMB_VFS_OP_SYS_ACL_FREE_TEXT, (result >= 0), handle,
1681                "");
1682
1683         return result;
1684 }
1685
1686 static int smb_full_audit_sys_acl_free_acl(vfs_handle_struct *handle,
1687
1688                                   SMB_ACL_T posix_acl)
1689 {
1690         int result;
1691
1692         result = SMB_VFS_NEXT_SYS_ACL_FREE_ACL(handle, posix_acl);
1693
1694         do_log(SMB_VFS_OP_SYS_ACL_FREE_ACL, (result >= 0), handle,
1695                "");
1696
1697         return result;
1698 }
1699
1700 static int smb_full_audit_sys_acl_free_qualifier(vfs_handle_struct *handle,
1701                                         void *qualifier,
1702                                         SMB_ACL_TAG_T tagtype)
1703 {
1704         int result;
1705
1706         result = SMB_VFS_NEXT_SYS_ACL_FREE_QUALIFIER(handle, qualifier,
1707                                                      tagtype);
1708
1709         do_log(SMB_VFS_OP_SYS_ACL_FREE_QUALIFIER, (result >= 0), handle,
1710                "");
1711
1712         return result;
1713 }
1714
1715 static ssize_t smb_full_audit_getxattr(struct vfs_handle_struct *handle,
1716                               const char *path,
1717                               const char *name, void *value, size_t size)
1718 {
1719         ssize_t result;
1720
1721         result = SMB_VFS_NEXT_GETXATTR(handle, path, name, value, size);
1722
1723         do_log(SMB_VFS_OP_GETXATTR, (result >= 0), handle,
1724                "%s|%s", path, name);
1725
1726         return result;
1727 }
1728
1729 static ssize_t smb_full_audit_lgetxattr(struct vfs_handle_struct *handle,
1730                                const char *path, const char *name,
1731                                void *value, size_t size)
1732 {
1733         ssize_t result;
1734
1735         result = SMB_VFS_NEXT_LGETXATTR(handle, path, name, value, size);
1736
1737         do_log(SMB_VFS_OP_LGETXATTR, (result >= 0), handle,
1738                "%s|%s", path, name);
1739
1740         return result;
1741 }
1742
1743 static ssize_t smb_full_audit_fgetxattr(struct vfs_handle_struct *handle,
1744                                struct files_struct *fsp,
1745                                const char *name, void *value, size_t size)
1746 {
1747         ssize_t result;
1748
1749         result = SMB_VFS_NEXT_FGETXATTR(handle, fsp, name, value, size);
1750
1751         do_log(SMB_VFS_OP_FGETXATTR, (result >= 0), handle,
1752                "%s|%s", fsp->fsp_name, name);
1753
1754         return result;
1755 }
1756
1757 static ssize_t smb_full_audit_listxattr(struct vfs_handle_struct *handle,
1758                                const char *path, char *list, size_t size)
1759 {
1760         ssize_t result;
1761
1762         result = SMB_VFS_NEXT_LISTXATTR(handle, path, list, size);
1763
1764         do_log(SMB_VFS_OP_LISTXATTR, (result >= 0), handle, "%s", path);
1765
1766         return result;
1767 }
1768
1769 static ssize_t smb_full_audit_llistxattr(struct vfs_handle_struct *handle,
1770                                 const char *path, char *list, size_t size)
1771 {
1772         ssize_t result;
1773
1774         result = SMB_VFS_NEXT_LLISTXATTR(handle, path, list, size);
1775
1776         do_log(SMB_VFS_OP_LLISTXATTR, (result >= 0), handle, "%s", path);
1777
1778         return result;
1779 }
1780
1781 static ssize_t smb_full_audit_flistxattr(struct vfs_handle_struct *handle,
1782                                 struct files_struct *fsp, char *list,
1783                                 size_t size)
1784 {
1785         ssize_t result;
1786
1787         result = SMB_VFS_NEXT_FLISTXATTR(handle, fsp, list, size);
1788
1789         do_log(SMB_VFS_OP_FLISTXATTR, (result >= 0), handle,
1790                "%s", fsp->fsp_name);
1791
1792         return result;
1793 }
1794
1795 static int smb_full_audit_removexattr(struct vfs_handle_struct *handle,
1796                              const char *path,
1797                              const char *name)
1798 {
1799         int result;
1800
1801         result = SMB_VFS_NEXT_REMOVEXATTR(handle, path, name);
1802
1803         do_log(SMB_VFS_OP_REMOVEXATTR, (result >= 0), handle,
1804                "%s|%s", path, name);
1805
1806         return result;
1807 }
1808
1809 static int smb_full_audit_lremovexattr(struct vfs_handle_struct *handle,
1810                               const char *path,
1811                               const char *name)
1812 {
1813         int result;
1814
1815         result = SMB_VFS_NEXT_LREMOVEXATTR(handle, path, name);
1816
1817         do_log(SMB_VFS_OP_LREMOVEXATTR, (result >= 0), handle,
1818                "%s|%s", path, name);
1819
1820         return result;
1821 }
1822
1823 static int smb_full_audit_fremovexattr(struct vfs_handle_struct *handle,
1824                               struct files_struct *fsp,
1825                               const char *name)
1826 {
1827         int result;
1828
1829         result = SMB_VFS_NEXT_FREMOVEXATTR(handle, fsp, name);
1830
1831         do_log(SMB_VFS_OP_FREMOVEXATTR, (result >= 0), handle,
1832                "%s|%s", fsp->fsp_name, name);
1833
1834         return result;
1835 }
1836
1837 static int smb_full_audit_setxattr(struct vfs_handle_struct *handle,
1838                           const char *path,
1839                           const char *name, const void *value, size_t size,
1840                           int flags)
1841 {
1842         int result;
1843
1844         result = SMB_VFS_NEXT_SETXATTR(handle, path, name, value, size,
1845                                        flags);
1846
1847         do_log(SMB_VFS_OP_SETXATTR, (result >= 0), handle,
1848                "%s|%s", path, name);
1849
1850         return result;
1851 }
1852
1853 static int smb_full_audit_lsetxattr(struct vfs_handle_struct *handle,
1854                            const char *path,
1855                            const char *name, const void *value, size_t size,
1856                            int flags)
1857 {
1858         int result;
1859
1860         result = SMB_VFS_NEXT_LSETXATTR(handle, path, name, value, size,
1861                                         flags);
1862
1863         do_log(SMB_VFS_OP_LSETXATTR, (result >= 0), handle,
1864                "%s|%s", path, name);
1865
1866         return result;
1867 }
1868
1869 static int smb_full_audit_fsetxattr(struct vfs_handle_struct *handle,
1870                            struct files_struct *fsp, const char *name,
1871                            const void *value, size_t size, int flags)
1872 {
1873         int result;
1874
1875         result = SMB_VFS_NEXT_FSETXATTR(handle, fsp, name, value, size, flags);
1876
1877         do_log(SMB_VFS_OP_FSETXATTR, (result >= 0), handle,
1878                "%s|%s", fsp->fsp_name, name);
1879
1880         return result;
1881 }
1882
1883 static int smb_full_audit_aio_read(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb)
1884 {
1885         int result;
1886
1887         result = SMB_VFS_NEXT_AIO_READ(handle, fsp, aiocb);
1888         do_log(SMB_VFS_OP_AIO_READ, (result >= 0), handle,
1889                 "%s", fsp->fsp_name);
1890
1891         return result;
1892 }
1893
1894 static int smb_full_audit_aio_write(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb)
1895 {
1896         int result;
1897
1898         result = SMB_VFS_NEXT_AIO_WRITE(handle, fsp, aiocb);
1899         do_log(SMB_VFS_OP_AIO_WRITE, (result >= 0), handle,
1900                 "%s", fsp->fsp_name);
1901
1902         return result;
1903 }
1904
1905 static ssize_t smb_full_audit_aio_return(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb)
1906 {
1907         int result;
1908
1909         result = SMB_VFS_NEXT_AIO_RETURN(handle, fsp, aiocb);
1910         do_log(SMB_VFS_OP_AIO_RETURN, (result >= 0), handle,
1911                 "%s", fsp->fsp_name);
1912
1913         return result;
1914 }
1915
1916 static int smb_full_audit_aio_cancel(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb)
1917 {
1918         int result;
1919
1920         result = SMB_VFS_NEXT_AIO_CANCEL(handle, fsp, aiocb);
1921         do_log(SMB_VFS_OP_AIO_CANCEL, (result >= 0), handle,
1922                 "%s", fsp->fsp_name);
1923
1924         return result;
1925 }
1926
1927 static int smb_full_audit_aio_error(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb)
1928 {
1929         int result;
1930
1931         result = SMB_VFS_NEXT_AIO_ERROR(handle, fsp, aiocb);
1932         do_log(SMB_VFS_OP_AIO_ERROR, (result >= 0), handle,
1933                 "%s", fsp->fsp_name);
1934
1935         return result;
1936 }
1937
1938 static int smb_full_audit_aio_fsync(struct vfs_handle_struct *handle, struct files_struct *fsp, int op, SMB_STRUCT_AIOCB *aiocb)
1939 {
1940         int result;
1941
1942         result = SMB_VFS_NEXT_AIO_FSYNC(handle, fsp, op, aiocb);
1943         do_log(SMB_VFS_OP_AIO_FSYNC, (result >= 0), handle,
1944                 "%s", fsp->fsp_name);
1945
1946         return result;
1947 }
1948
1949 static int smb_full_audit_aio_suspend(struct vfs_handle_struct *handle, struct files_struct *fsp, const SMB_STRUCT_AIOCB * const aiocb[], int n, const struct timespec *ts)
1950 {
1951         int result;
1952
1953         result = SMB_VFS_NEXT_AIO_SUSPEND(handle, fsp, aiocb, n, ts);
1954         do_log(SMB_VFS_OP_AIO_SUSPEND, (result >= 0), handle,
1955                 "%s", fsp->fsp_name);
1956
1957         return result;
1958 }
1959
1960 static bool smb_full_audit_aio_force(struct vfs_handle_struct *handle,
1961                                      struct files_struct *fsp)
1962 {
1963         bool result;
1964
1965         result = SMB_VFS_NEXT_AIO_FORCE(handle, fsp);
1966         do_log(SMB_VFS_OP_AIO_FORCE, result, handle,
1967                 "%s", fsp->fsp_name);
1968
1969         return result;
1970 }
1971
1972 /* VFS operations */
1973 static vfs_op_tuple audit_op_tuples[] = {
1974
1975         /* Disk operations */
1976
1977         {SMB_VFS_OP(smb_full_audit_connect),    SMB_VFS_OP_CONNECT,
1978          SMB_VFS_LAYER_LOGGER},
1979         {SMB_VFS_OP(smb_full_audit_disconnect), SMB_VFS_OP_DISCONNECT,
1980          SMB_VFS_LAYER_LOGGER},
1981         {SMB_VFS_OP(smb_full_audit_disk_free),  SMB_VFS_OP_DISK_FREE,
1982          SMB_VFS_LAYER_LOGGER},
1983         {SMB_VFS_OP(smb_full_audit_get_quota),  SMB_VFS_OP_GET_QUOTA,
1984          SMB_VFS_LAYER_LOGGER},
1985         {SMB_VFS_OP(smb_full_audit_set_quota),  SMB_VFS_OP_SET_QUOTA,
1986          SMB_VFS_LAYER_LOGGER},
1987         {SMB_VFS_OP(smb_full_audit_get_shadow_copy_data), SMB_VFS_OP_GET_SHADOW_COPY_DATA,
1988          SMB_VFS_LAYER_LOGGER},
1989         {SMB_VFS_OP(smb_full_audit_statvfs),    SMB_VFS_OP_STATVFS,
1990          SMB_VFS_LAYER_LOGGER},
1991         {SMB_VFS_OP(smb_full_audit_fs_capabilities), SMB_VFS_OP_FS_CAPABILITIES,
1992          SMB_VFS_LAYER_LOGGER},
1993
1994         /* Directory operations */
1995
1996         {SMB_VFS_OP(smb_full_audit_opendir),    SMB_VFS_OP_OPENDIR,
1997          SMB_VFS_LAYER_LOGGER},
1998         {SMB_VFS_OP(smb_full_audit_readdir),    SMB_VFS_OP_READDIR,
1999          SMB_VFS_LAYER_LOGGER},
2000         {SMB_VFS_OP(smb_full_audit_seekdir),    SMB_VFS_OP_SEEKDIR,
2001          SMB_VFS_LAYER_LOGGER},
2002         {SMB_VFS_OP(smb_full_audit_telldir),    SMB_VFS_OP_TELLDIR,
2003          SMB_VFS_LAYER_LOGGER},
2004         {SMB_VFS_OP(smb_full_audit_rewinddir),  SMB_VFS_OP_REWINDDIR,
2005          SMB_VFS_LAYER_LOGGER},
2006         {SMB_VFS_OP(smb_full_audit_mkdir),      SMB_VFS_OP_MKDIR,
2007          SMB_VFS_LAYER_LOGGER},
2008         {SMB_VFS_OP(smb_full_audit_rmdir),      SMB_VFS_OP_RMDIR,
2009          SMB_VFS_LAYER_LOGGER},
2010         {SMB_VFS_OP(smb_full_audit_closedir),   SMB_VFS_OP_CLOSEDIR,
2011          SMB_VFS_LAYER_LOGGER},
2012         {SMB_VFS_OP(smb_full_audit_init_search_op), SMB_VFS_OP_INIT_SEARCH_OP,
2013          SMB_VFS_LAYER_LOGGER},
2014
2015         /* File operations */
2016
2017         {SMB_VFS_OP(smb_full_audit_open),       SMB_VFS_OP_OPEN,
2018          SMB_VFS_LAYER_LOGGER},
2019         {SMB_VFS_OP(smb_full_audit_create_file),SMB_VFS_OP_CREATE_FILE,
2020          SMB_VFS_LAYER_LOGGER},
2021         {SMB_VFS_OP(smb_full_audit_close),      SMB_VFS_OP_CLOSE,
2022          SMB_VFS_LAYER_LOGGER},
2023         {SMB_VFS_OP(smb_full_audit_read),       SMB_VFS_OP_READ,
2024          SMB_VFS_LAYER_LOGGER},
2025         {SMB_VFS_OP(smb_full_audit_pread),      SMB_VFS_OP_PREAD,
2026          SMB_VFS_LAYER_LOGGER},
2027         {SMB_VFS_OP(smb_full_audit_write),      SMB_VFS_OP_WRITE,
2028          SMB_VFS_LAYER_LOGGER},
2029         {SMB_VFS_OP(smb_full_audit_pwrite),     SMB_VFS_OP_PWRITE,
2030          SMB_VFS_LAYER_LOGGER},
2031         {SMB_VFS_OP(smb_full_audit_lseek),      SMB_VFS_OP_LSEEK,
2032          SMB_VFS_LAYER_LOGGER},
2033         {SMB_VFS_OP(smb_full_audit_sendfile),   SMB_VFS_OP_SENDFILE,
2034          SMB_VFS_LAYER_LOGGER},
2035         {SMB_VFS_OP(smb_full_audit_recvfile),   SMB_VFS_OP_RECVFILE,
2036          SMB_VFS_LAYER_LOGGER},
2037         {SMB_VFS_OP(smb_full_audit_rename),     SMB_VFS_OP_RENAME,
2038          SMB_VFS_LAYER_LOGGER},
2039         {SMB_VFS_OP(smb_full_audit_fsync),      SMB_VFS_OP_FSYNC,
2040          SMB_VFS_LAYER_LOGGER},
2041         {SMB_VFS_OP(smb_full_audit_stat),       SMB_VFS_OP_STAT,
2042          SMB_VFS_LAYER_LOGGER},
2043         {SMB_VFS_OP(smb_full_audit_fstat),      SMB_VFS_OP_FSTAT,
2044          SMB_VFS_LAYER_LOGGER},
2045         {SMB_VFS_OP(smb_full_audit_lstat),      SMB_VFS_OP_LSTAT,
2046          SMB_VFS_LAYER_LOGGER},
2047         {SMB_VFS_OP(smb_full_audit_get_alloc_size),     SMB_VFS_OP_GET_ALLOC_SIZE,
2048          SMB_VFS_LAYER_LOGGER},
2049         {SMB_VFS_OP(smb_full_audit_unlink),     SMB_VFS_OP_UNLINK,
2050          SMB_VFS_LAYER_LOGGER},
2051         {SMB_VFS_OP(smb_full_audit_chmod),      SMB_VFS_OP_CHMOD,
2052          SMB_VFS_LAYER_LOGGER},
2053         {SMB_VFS_OP(smb_full_audit_fchmod),     SMB_VFS_OP_FCHMOD,
2054          SMB_VFS_LAYER_LOGGER},
2055         {SMB_VFS_OP(smb_full_audit_chown),      SMB_VFS_OP_CHOWN,
2056          SMB_VFS_LAYER_LOGGER},
2057         {SMB_VFS_OP(smb_full_audit_fchown),     SMB_VFS_OP_FCHOWN,
2058          SMB_VFS_LAYER_LOGGER},
2059         {SMB_VFS_OP(smb_full_audit_lchown),     SMB_VFS_OP_LCHOWN,
2060          SMB_VFS_LAYER_LOGGER},
2061         {SMB_VFS_OP(smb_full_audit_chdir),      SMB_VFS_OP_CHDIR,
2062          SMB_VFS_LAYER_LOGGER},
2063         {SMB_VFS_OP(smb_full_audit_getwd),      SMB_VFS_OP_GETWD,
2064          SMB_VFS_LAYER_LOGGER},
2065         {SMB_VFS_OP(smb_full_audit_ntimes),     SMB_VFS_OP_NTIMES,
2066          SMB_VFS_LAYER_LOGGER},
2067         {SMB_VFS_OP(smb_full_audit_ftruncate),  SMB_VFS_OP_FTRUNCATE,
2068          SMB_VFS_LAYER_LOGGER},
2069         {SMB_VFS_OP(smb_full_audit_lock),       SMB_VFS_OP_LOCK,
2070          SMB_VFS_LAYER_LOGGER},
2071         {SMB_VFS_OP(smb_full_audit_kernel_flock),       SMB_VFS_OP_KERNEL_FLOCK,
2072          SMB_VFS_LAYER_LOGGER},
2073         {SMB_VFS_OP(smb_full_audit_linux_setlease),       SMB_VFS_OP_LINUX_SETLEASE,
2074          SMB_VFS_LAYER_LOGGER},
2075         {SMB_VFS_OP(smb_full_audit_getlock),    SMB_VFS_OP_GETLOCK,
2076          SMB_VFS_LAYER_LOGGER},
2077         {SMB_VFS_OP(smb_full_audit_symlink),    SMB_VFS_OP_SYMLINK,
2078          SMB_VFS_LAYER_LOGGER},
2079         {SMB_VFS_OP(smb_full_audit_readlink),   SMB_VFS_OP_READLINK,
2080          SMB_VFS_LAYER_LOGGER},
2081         {SMB_VFS_OP(smb_full_audit_link),       SMB_VFS_OP_LINK,
2082          SMB_VFS_LAYER_LOGGER},
2083         {SMB_VFS_OP(smb_full_audit_mknod),      SMB_VFS_OP_MKNOD,
2084          SMB_VFS_LAYER_LOGGER},
2085         {SMB_VFS_OP(smb_full_audit_realpath),   SMB_VFS_OP_REALPATH,
2086          SMB_VFS_LAYER_LOGGER},
2087         {SMB_VFS_OP(smb_full_audit_notify_watch),SMB_VFS_OP_NOTIFY_WATCH,
2088          SMB_VFS_LAYER_LOGGER},
2089         {SMB_VFS_OP(smb_full_audit_chflags),    SMB_VFS_OP_CHFLAGS,
2090          SMB_VFS_LAYER_LOGGER},
2091         {SMB_VFS_OP(smb_full_audit_file_id_create),     SMB_VFS_OP_FILE_ID_CREATE,
2092          SMB_VFS_LAYER_LOGGER},
2093         {SMB_VFS_OP(smb_full_audit_streaminfo), SMB_VFS_OP_STREAMINFO,
2094          SMB_VFS_LAYER_LOGGER},
2095         {SMB_VFS_OP(smb_full_audit_get_real_filename), SMB_VFS_OP_GET_REAL_FILENAME,
2096          SMB_VFS_LAYER_LOGGER},
2097         {SMB_VFS_OP(smb_full_audit_connectpath), SMB_VFS_OP_CONNECTPATH,
2098          SMB_VFS_LAYER_LOGGER},
2099         {SMB_VFS_OP(smb_full_audit_brl_lock_windows), SMB_VFS_OP_BRL_LOCK_WINDOWS,
2100          SMB_VFS_LAYER_LOGGER},
2101         {SMB_VFS_OP(smb_full_audit_brl_unlock_windows), SMB_VFS_OP_BRL_UNLOCK_WINDOWS,
2102          SMB_VFS_LAYER_LOGGER},
2103         {SMB_VFS_OP(smb_full_audit_brl_cancel_windows), SMB_VFS_OP_BRL_CANCEL_WINDOWS,
2104          SMB_VFS_LAYER_LOGGER},
2105         {SMB_VFS_OP(smb_full_audit_strict_lock), SMB_VFS_OP_STRICT_LOCK,
2106          SMB_VFS_LAYER_LOGGER},
2107         {SMB_VFS_OP(smb_full_audit_strict_unlock), SMB_VFS_OP_STRICT_UNLOCK,
2108          SMB_VFS_LAYER_LOGGER},
2109
2110         /* NT ACL operations. */
2111
2112         {SMB_VFS_OP(smb_full_audit_fget_nt_acl),        SMB_VFS_OP_FGET_NT_ACL,
2113          SMB_VFS_LAYER_LOGGER},
2114         {SMB_VFS_OP(smb_full_audit_get_nt_acl), SMB_VFS_OP_GET_NT_ACL,
2115          SMB_VFS_LAYER_LOGGER},
2116         {SMB_VFS_OP(smb_full_audit_fset_nt_acl),        SMB_VFS_OP_FSET_NT_ACL,
2117          SMB_VFS_LAYER_LOGGER},
2118
2119         /* POSIX ACL operations. */
2120
2121         {SMB_VFS_OP(smb_full_audit_chmod_acl),  SMB_VFS_OP_CHMOD_ACL,
2122          SMB_VFS_LAYER_LOGGER},
2123         {SMB_VFS_OP(smb_full_audit_fchmod_acl), SMB_VFS_OP_FCHMOD_ACL,
2124          SMB_VFS_LAYER_LOGGER},
2125         {SMB_VFS_OP(smb_full_audit_sys_acl_get_entry),  SMB_VFS_OP_SYS_ACL_GET_ENTRY,
2126          SMB_VFS_LAYER_LOGGER},
2127         {SMB_VFS_OP(smb_full_audit_sys_acl_get_tag_type),       SMB_VFS_OP_SYS_ACL_GET_TAG_TYPE,
2128          SMB_VFS_LAYER_LOGGER},
2129         {SMB_VFS_OP(smb_full_audit_sys_acl_get_permset),        SMB_VFS_OP_SYS_ACL_GET_PERMSET,
2130          SMB_VFS_LAYER_LOGGER},
2131         {SMB_VFS_OP(smb_full_audit_sys_acl_get_qualifier),      SMB_VFS_OP_SYS_ACL_GET_QUALIFIER,
2132          SMB_VFS_LAYER_LOGGER},
2133         {SMB_VFS_OP(smb_full_audit_sys_acl_get_file),   SMB_VFS_OP_SYS_ACL_GET_FILE,
2134          SMB_VFS_LAYER_LOGGER},
2135         {SMB_VFS_OP(smb_full_audit_sys_acl_get_fd),     SMB_VFS_OP_SYS_ACL_GET_FD,
2136          SMB_VFS_LAYER_LOGGER},
2137         {SMB_VFS_OP(smb_full_audit_sys_acl_clear_perms),        SMB_VFS_OP_SYS_ACL_CLEAR_PERMS,
2138          SMB_VFS_LAYER_LOGGER},
2139         {SMB_VFS_OP(smb_full_audit_sys_acl_add_perm),   SMB_VFS_OP_SYS_ACL_ADD_PERM,
2140          SMB_VFS_LAYER_LOGGER},
2141         {SMB_VFS_OP(smb_full_audit_sys_acl_to_text),    SMB_VFS_OP_SYS_ACL_TO_TEXT,
2142          SMB_VFS_LAYER_LOGGER},
2143         {SMB_VFS_OP(smb_full_audit_sys_acl_init),       SMB_VFS_OP_SYS_ACL_INIT,
2144          SMB_VFS_LAYER_LOGGER},
2145         {SMB_VFS_OP(smb_full_audit_sys_acl_create_entry),       SMB_VFS_OP_SYS_ACL_CREATE_ENTRY,
2146          SMB_VFS_LAYER_LOGGER},
2147         {SMB_VFS_OP(smb_full_audit_sys_acl_set_tag_type),       SMB_VFS_OP_SYS_ACL_SET_TAG_TYPE,
2148          SMB_VFS_LAYER_LOGGER},
2149         {SMB_VFS_OP(smb_full_audit_sys_acl_set_qualifier),      SMB_VFS_OP_SYS_ACL_SET_QUALIFIER,
2150          SMB_VFS_LAYER_LOGGER},
2151         {SMB_VFS_OP(smb_full_audit_sys_acl_set_permset),        SMB_VFS_OP_SYS_ACL_SET_PERMSET,
2152          SMB_VFS_LAYER_LOGGER},
2153         {SMB_VFS_OP(smb_full_audit_sys_acl_valid),      SMB_VFS_OP_SYS_ACL_VALID,
2154          SMB_VFS_LAYER_LOGGER},
2155         {SMB_VFS_OP(smb_full_audit_sys_acl_set_file),   SMB_VFS_OP_SYS_ACL_SET_FILE,
2156          SMB_VFS_LAYER_LOGGER},
2157         {SMB_VFS_OP(smb_full_audit_sys_acl_set_fd),     SMB_VFS_OP_SYS_ACL_SET_FD,
2158          SMB_VFS_LAYER_LOGGER},
2159         {SMB_VFS_OP(smb_full_audit_sys_acl_delete_def_file),    SMB_VFS_OP_SYS_ACL_DELETE_DEF_FILE,
2160          SMB_VFS_LAYER_LOGGER},
2161         {SMB_VFS_OP(smb_full_audit_sys_acl_get_perm),   SMB_VFS_OP_SYS_ACL_GET_PERM,
2162          SMB_VFS_LAYER_LOGGER},
2163         {SMB_VFS_OP(smb_full_audit_sys_acl_free_text),  SMB_VFS_OP_SYS_ACL_FREE_TEXT,
2164          SMB_VFS_LAYER_LOGGER},
2165         {SMB_VFS_OP(smb_full_audit_sys_acl_free_acl),   SMB_VFS_OP_SYS_ACL_FREE_ACL,
2166          SMB_VFS_LAYER_LOGGER},
2167         {SMB_VFS_OP(smb_full_audit_sys_acl_free_qualifier),     SMB_VFS_OP_SYS_ACL_FREE_QUALIFIER,
2168          SMB_VFS_LAYER_LOGGER},
2169
2170         /* EA operations. */
2171
2172         {SMB_VFS_OP(smb_full_audit_getxattr),   SMB_VFS_OP_GETXATTR,
2173          SMB_VFS_LAYER_LOGGER},
2174         {SMB_VFS_OP(smb_full_audit_lgetxattr),  SMB_VFS_OP_LGETXATTR,
2175          SMB_VFS_LAYER_LOGGER},
2176         {SMB_VFS_OP(smb_full_audit_fgetxattr),  SMB_VFS_OP_FGETXATTR,
2177          SMB_VFS_LAYER_LOGGER},
2178         {SMB_VFS_OP(smb_full_audit_listxattr),  SMB_VFS_OP_LISTXATTR,
2179          SMB_VFS_LAYER_LOGGER},
2180         {SMB_VFS_OP(smb_full_audit_llistxattr), SMB_VFS_OP_LLISTXATTR,
2181          SMB_VFS_LAYER_LOGGER},
2182         {SMB_VFS_OP(smb_full_audit_flistxattr), SMB_VFS_OP_FLISTXATTR,
2183          SMB_VFS_LAYER_LOGGER},
2184         {SMB_VFS_OP(smb_full_audit_removexattr),        SMB_VFS_OP_REMOVEXATTR,
2185          SMB_VFS_LAYER_LOGGER},
2186         {SMB_VFS_OP(smb_full_audit_lremovexattr),       SMB_VFS_OP_LREMOVEXATTR,
2187          SMB_VFS_LAYER_LOGGER},
2188         {SMB_VFS_OP(smb_full_audit_fremovexattr),       SMB_VFS_OP_FREMOVEXATTR,
2189          SMB_VFS_LAYER_LOGGER},
2190         {SMB_VFS_OP(smb_full_audit_setxattr),   SMB_VFS_OP_SETXATTR,
2191          SMB_VFS_LAYER_LOGGER},
2192         {SMB_VFS_OP(smb_full_audit_lsetxattr),  SMB_VFS_OP_LSETXATTR,
2193          SMB_VFS_LAYER_LOGGER},
2194         {SMB_VFS_OP(smb_full_audit_fsetxattr),  SMB_VFS_OP_FSETXATTR,
2195          SMB_VFS_LAYER_LOGGER},
2196
2197         {SMB_VFS_OP(smb_full_audit_aio_read),   SMB_VFS_OP_AIO_READ,
2198          SMB_VFS_LAYER_LOGGER},
2199         {SMB_VFS_OP(smb_full_audit_aio_write),  SMB_VFS_OP_AIO_WRITE,
2200          SMB_VFS_LAYER_LOGGER},
2201         {SMB_VFS_OP(smb_full_audit_aio_return), SMB_VFS_OP_AIO_RETURN,
2202          SMB_VFS_LAYER_LOGGER},
2203         {SMB_VFS_OP(smb_full_audit_aio_cancel), SMB_VFS_OP_AIO_CANCEL,
2204          SMB_VFS_LAYER_LOGGER},
2205         {SMB_VFS_OP(smb_full_audit_aio_error),  SMB_VFS_OP_AIO_ERROR,
2206          SMB_VFS_LAYER_LOGGER},
2207         {SMB_VFS_OP(smb_full_audit_aio_fsync),  SMB_VFS_OP_AIO_FSYNC,
2208          SMB_VFS_LAYER_LOGGER},
2209         {SMB_VFS_OP(smb_full_audit_aio_suspend),SMB_VFS_OP_AIO_SUSPEND,
2210          SMB_VFS_LAYER_LOGGER},
2211         {SMB_VFS_OP(smb_full_audit_aio_force),SMB_VFS_OP_AIO_FORCE,
2212          SMB_VFS_LAYER_LOGGER},
2213
2214         /* Finish VFS operations definition */
2215
2216         {SMB_VFS_OP(NULL),              SMB_VFS_OP_NOOP,
2217          SMB_VFS_LAYER_NOOP}
2218 };
2219
2220 NTSTATUS vfs_full_audit_init(void)
2221 {
2222         NTSTATUS ret = smb_register_vfs(SMB_VFS_INTERFACE_VERSION,
2223                                         "full_audit", audit_op_tuples);
2224         
2225         if (!NT_STATUS_IS_OK(ret))
2226                 return ret;
2227
2228         vfs_full_audit_debug_level = debug_add_class("full_audit");
2229         if (vfs_full_audit_debug_level == -1) {
2230                 vfs_full_audit_debug_level = DBGC_VFS;
2231                 DEBUG(0, ("vfs_full_audit: Couldn't register custom debugging "
2232                           "class!\n"));
2233         } else {
2234                 DEBUG(10, ("vfs_full_audit: Debug class number of "
2235                            "'full_audit': %d\n", vfs_full_audit_debug_level));
2236         }
2237         
2238         return ret;
2239 }