Make the smbd VFS typesafe
[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
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  * Return an fsp debug string using the do_log_ctx()
424  */
425 static const char *fsp_str_do_log(const struct files_struct *fsp)
426 {
427         return smb_fname_str_do_log(fsp->fsp_name);
428 }
429
430 /* Free function for the private data. */
431
432 static void free_private_data(void **p_data)
433 {
434         struct vfs_full_audit_private_data *pd = *(struct vfs_full_audit_private_data **)p_data;
435
436         if (pd->success_ops) {
437                 bitmap_free(pd->success_ops);
438         }
439         if (pd->failure_ops) {
440                 bitmap_free(pd->failure_ops);
441         }
442         SAFE_FREE(pd);
443         *p_data = NULL;
444 }
445
446 /* Implementation of vfs_ops.  Pass everything on to the default
447    operation but log event first. */
448
449 static int smb_full_audit_connect(vfs_handle_struct *handle,
450                          const char *svc, const char *user)
451 {
452         int result;
453         struct vfs_full_audit_private_data *pd = NULL;
454         const char *none[] = { NULL };
455         const char *all [] = { "all" };
456
457         if (!handle) {
458                 return -1;
459         }
460
461         pd = SMB_MALLOC_P(struct vfs_full_audit_private_data);
462         if (!pd) {
463                 return -1;
464         }
465         ZERO_STRUCTP(pd);
466
467         openlog("smbd_audit", 0, audit_syslog_facility(handle));
468
469         init_bitmap(&pd->success_ops,
470                     lp_parm_string_list(SNUM(handle->conn), "full_audit", "success",
471                                         none));
472         init_bitmap(&pd->failure_ops,
473                     lp_parm_string_list(SNUM(handle->conn), "full_audit", "failure",
474                                         all));
475
476         /* Store the private data. */
477         SMB_VFS_HANDLE_SET_DATA(handle, pd, free_private_data,
478                                 struct vfs_full_audit_private_data, return -1);
479
480         result = SMB_VFS_NEXT_CONNECT(handle, svc, user);
481
482         do_log(SMB_VFS_OP_CONNECT, True, handle,
483                "%s", svc);
484
485         return result;
486 }
487
488 static void smb_full_audit_disconnect(vfs_handle_struct *handle)
489 {
490         SMB_VFS_NEXT_DISCONNECT(handle);
491
492         do_log(SMB_VFS_OP_DISCONNECT, True, handle,
493                "%s", lp_servicename(SNUM(handle->conn)));
494
495         /* The bitmaps will be disconnected when the private
496            data is deleted. */
497
498         return;
499 }
500
501 static uint64_t smb_full_audit_disk_free(vfs_handle_struct *handle,
502                                     const char *path,
503                                     bool small_query, uint64_t *bsize, 
504                                     uint64_t *dfree, uint64_t *dsize)
505 {
506         uint64_t result;
507
508         result = SMB_VFS_NEXT_DISK_FREE(handle, path, small_query, bsize,
509                                         dfree, dsize);
510
511         /* Don't have a reasonable notion of failure here */
512
513         do_log(SMB_VFS_OP_DISK_FREE, True, handle, "%s", path);
514
515         return result;
516 }
517
518 static int smb_full_audit_get_quota(struct vfs_handle_struct *handle,
519                            enum SMB_QUOTA_TYPE qtype, unid_t id,
520                            SMB_DISK_QUOTA *qt)
521 {
522         int result;
523
524         result = SMB_VFS_NEXT_GET_QUOTA(handle, qtype, id, qt);
525
526         do_log(SMB_VFS_OP_GET_QUOTA, (result >= 0), handle, "");
527
528         return result;
529 }
530
531         
532 static int smb_full_audit_set_quota(struct vfs_handle_struct *handle,
533                            enum SMB_QUOTA_TYPE qtype, unid_t id,
534                            SMB_DISK_QUOTA *qt)
535 {
536         int result;
537
538         result = SMB_VFS_NEXT_SET_QUOTA(handle, qtype, id, qt);
539
540         do_log(SMB_VFS_OP_SET_QUOTA, (result >= 0), handle, "");
541
542         return result;
543 }
544
545 static int smb_full_audit_get_shadow_copy_data(struct vfs_handle_struct *handle,
546                                 struct files_struct *fsp,
547                                 SHADOW_COPY_DATA *shadow_copy_data, bool labels)
548 {
549         int result;
550
551         result = SMB_VFS_NEXT_GET_SHADOW_COPY_DATA(handle, fsp, shadow_copy_data, labels);
552
553         do_log(SMB_VFS_OP_GET_SHADOW_COPY_DATA, (result >= 0), handle, "");
554
555         return result;
556 }
557
558 static int smb_full_audit_statvfs(struct vfs_handle_struct *handle,
559                                 const char *path,
560                                 struct vfs_statvfs_struct *statbuf)
561 {
562         int result;
563
564         result = SMB_VFS_NEXT_STATVFS(handle, path, statbuf);
565
566         do_log(SMB_VFS_OP_STATVFS, (result >= 0), handle, "");
567
568         return result;
569 }
570
571 static uint32_t smb_full_audit_fs_capabilities(struct vfs_handle_struct *handle)
572 {
573         int result;
574
575         result = SMB_VFS_NEXT_FS_CAPABILITIES(handle);
576
577         do_log(SMB_VFS_OP_FS_CAPABILITIES, true, handle, "");
578
579         return result;
580 }
581
582 static SMB_STRUCT_DIR *smb_full_audit_opendir(vfs_handle_struct *handle,
583                           const char *fname, const char *mask, uint32 attr)
584 {
585         SMB_STRUCT_DIR *result;
586
587         result = SMB_VFS_NEXT_OPENDIR(handle, fname, mask, attr);
588
589         do_log(SMB_VFS_OP_OPENDIR, (result != NULL), handle, "%s", fname);
590
591         return result;
592 }
593
594 static SMB_STRUCT_DIRENT *smb_full_audit_readdir(vfs_handle_struct *handle,
595                                     SMB_STRUCT_DIR *dirp, SMB_STRUCT_STAT *sbuf)
596 {
597         SMB_STRUCT_DIRENT *result;
598
599         result = SMB_VFS_NEXT_READDIR(handle, dirp, sbuf);
600
601         /* This operation has no reasonable error condition
602          * (End of dir is also failure), so always succeed.
603          */
604         do_log(SMB_VFS_OP_READDIR, True, handle, "");
605
606         return result;
607 }
608
609 static void smb_full_audit_seekdir(vfs_handle_struct *handle,
610                         SMB_STRUCT_DIR *dirp, long offset)
611 {
612         SMB_VFS_NEXT_SEEKDIR(handle, dirp, offset);
613
614         do_log(SMB_VFS_OP_SEEKDIR, True, handle, "");
615         return;
616 }
617
618 static long smb_full_audit_telldir(vfs_handle_struct *handle,
619                         SMB_STRUCT_DIR *dirp)
620 {
621         long result;
622
623         result = SMB_VFS_NEXT_TELLDIR(handle, dirp);
624
625         do_log(SMB_VFS_OP_TELLDIR, True, handle, "");
626
627         return result;
628 }
629
630 static void smb_full_audit_rewinddir(vfs_handle_struct *handle,
631                         SMB_STRUCT_DIR *dirp)
632 {
633         SMB_VFS_NEXT_REWINDDIR(handle, dirp);
634
635         do_log(SMB_VFS_OP_REWINDDIR, True, handle, "");
636         return;
637 }
638
639 static int smb_full_audit_mkdir(vfs_handle_struct *handle,
640                        const char *path, mode_t mode)
641 {
642         int result;
643         
644         result = SMB_VFS_NEXT_MKDIR(handle, path, mode);
645         
646         do_log(SMB_VFS_OP_MKDIR, (result >= 0), handle, "%s", path);
647
648         return result;
649 }
650
651 static int smb_full_audit_rmdir(vfs_handle_struct *handle,
652                        const char *path)
653 {
654         int result;
655         
656         result = SMB_VFS_NEXT_RMDIR(handle, path);
657
658         do_log(SMB_VFS_OP_RMDIR, (result >= 0), handle, "%s", path);
659
660         return result;
661 }
662
663 static int smb_full_audit_closedir(vfs_handle_struct *handle,
664                           SMB_STRUCT_DIR *dirp)
665 {
666         int result;
667
668         result = SMB_VFS_NEXT_CLOSEDIR(handle, dirp);
669         
670         do_log(SMB_VFS_OP_CLOSEDIR, (result >= 0), handle, "");
671
672         return result;
673 }
674
675 static void smb_full_audit_init_search_op(vfs_handle_struct *handle,
676                         SMB_STRUCT_DIR *dirp)
677 {
678         SMB_VFS_NEXT_INIT_SEARCH_OP(handle, dirp);
679
680         do_log(SMB_VFS_OP_INIT_SEARCH_OP, True, handle, "");
681         return;
682 }
683
684 static int smb_full_audit_open(vfs_handle_struct *handle,
685                                struct smb_filename *smb_fname,
686                                files_struct *fsp, int flags, mode_t mode)
687 {
688         int result;
689         
690         result = SMB_VFS_NEXT_OPEN(handle, smb_fname, fsp, flags, mode);
691
692         do_log(SMB_VFS_OP_OPEN, (result >= 0), handle, "%s|%s",
693                ((flags & O_WRONLY) || (flags & O_RDWR))?"w":"r",
694                smb_fname_str_do_log(smb_fname));
695
696         return result;
697 }
698
699 static NTSTATUS smb_full_audit_create_file(vfs_handle_struct *handle,
700                                       struct smb_request *req,
701                                       uint16_t root_dir_fid,
702                                       struct smb_filename *smb_fname,
703                                       uint32_t access_mask,
704                                       uint32_t share_access,
705                                       uint32_t create_disposition,
706                                       uint32_t create_options,
707                                       uint32_t file_attributes,
708                                       uint32_t oplock_request,
709                                       uint64_t allocation_size,
710                                       struct security_descriptor *sd,
711                                       struct ea_list *ea_list,
712                                       files_struct **result_fsp,
713                                       int *pinfo)
714 {
715         NTSTATUS result;
716
717         result = SMB_VFS_NEXT_CREATE_FILE(
718                 handle,                                 /* handle */
719                 req,                                    /* req */
720                 root_dir_fid,                           /* root_dir_fid */
721                 smb_fname,                              /* fname */
722                 access_mask,                            /* access_mask */
723                 share_access,                           /* share_access */
724                 create_disposition,                     /* create_disposition*/
725                 create_options,                         /* create_options */
726                 file_attributes,                        /* file_attributes */
727                 oplock_request,                         /* oplock_request */
728                 allocation_size,                        /* allocation_size */
729                 sd,                                     /* sd */
730                 ea_list,                                /* ea_list */
731                 result_fsp,                             /* result */
732                 pinfo);                                 /* pinfo */
733
734         do_log(SMB_VFS_OP_CREATE_FILE, (NT_STATUS_IS_OK(result)), handle, "0x%x|%s",
735                access_mask, smb_fname_str_do_log(smb_fname));
736
737         return result;
738 }
739
740 static int smb_full_audit_close(vfs_handle_struct *handle, files_struct *fsp)
741 {
742         int result;
743         
744         result = SMB_VFS_NEXT_CLOSE(handle, fsp);
745
746         do_log(SMB_VFS_OP_CLOSE, (result >= 0), handle, "%s",
747                fsp_str_do_log(fsp));
748
749         return result;
750 }
751
752 static ssize_t smb_full_audit_read(vfs_handle_struct *handle, files_struct *fsp,
753                           void *data, size_t n)
754 {
755         ssize_t result;
756
757         result = SMB_VFS_NEXT_READ(handle, fsp, data, n);
758
759         do_log(SMB_VFS_OP_READ, (result >= 0), handle, "%s",
760                fsp_str_do_log(fsp));
761
762         return result;
763 }
764
765 static ssize_t smb_full_audit_pread(vfs_handle_struct *handle, files_struct *fsp,
766                            void *data, size_t n, SMB_OFF_T offset)
767 {
768         ssize_t result;
769
770         result = SMB_VFS_NEXT_PREAD(handle, fsp, data, n, offset);
771
772         do_log(SMB_VFS_OP_PREAD, (result >= 0), handle, "%s",
773                fsp_str_do_log(fsp));
774
775         return result;
776 }
777
778 static ssize_t smb_full_audit_write(vfs_handle_struct *handle, files_struct *fsp,
779                            const void *data, size_t n)
780 {
781         ssize_t result;
782
783         result = SMB_VFS_NEXT_WRITE(handle, fsp, data, n);
784
785         do_log(SMB_VFS_OP_WRITE, (result >= 0), handle, "%s",
786                fsp_str_do_log(fsp));
787
788         return result;
789 }
790
791 static ssize_t smb_full_audit_pwrite(vfs_handle_struct *handle, files_struct *fsp,
792                             const void *data, size_t n,
793                             SMB_OFF_T offset)
794 {
795         ssize_t result;
796
797         result = SMB_VFS_NEXT_PWRITE(handle, fsp, data, n, offset);
798
799         do_log(SMB_VFS_OP_PWRITE, (result >= 0), handle, "%s",
800                fsp_str_do_log(fsp));
801
802         return result;
803 }
804
805 static SMB_OFF_T smb_full_audit_lseek(vfs_handle_struct *handle, files_struct *fsp,
806                              SMB_OFF_T offset, int whence)
807 {
808         ssize_t result;
809
810         result = SMB_VFS_NEXT_LSEEK(handle, fsp, offset, whence);
811
812         do_log(SMB_VFS_OP_LSEEK, (result != (ssize_t)-1), handle,
813                "%s", fsp_str_do_log(fsp));
814
815         return result;
816 }
817
818 static ssize_t smb_full_audit_sendfile(vfs_handle_struct *handle, int tofd,
819                               files_struct *fromfsp,
820                               const DATA_BLOB *hdr, SMB_OFF_T offset,
821                               size_t n)
822 {
823         ssize_t result;
824
825         result = SMB_VFS_NEXT_SENDFILE(handle, tofd, fromfsp, hdr, offset, n);
826
827         do_log(SMB_VFS_OP_SENDFILE, (result >= 0), handle,
828                "%s", fsp_str_do_log(fromfsp));
829
830         return result;
831 }
832
833 static ssize_t smb_full_audit_recvfile(vfs_handle_struct *handle, int fromfd,
834                       files_struct *tofsp,
835                               SMB_OFF_T offset,
836                               size_t n)
837 {
838         ssize_t result;
839
840         result = SMB_VFS_NEXT_RECVFILE(handle, fromfd, tofsp, offset, n);
841
842         do_log(SMB_VFS_OP_RECVFILE, (result >= 0), handle,
843                "%s", fsp_str_do_log(tofsp));
844
845         return result;
846 }
847
848 static int smb_full_audit_rename(vfs_handle_struct *handle,
849                                  const struct smb_filename *smb_fname_src,
850                                  const struct smb_filename *smb_fname_dst)
851 {
852         int result;
853         
854         result = SMB_VFS_NEXT_RENAME(handle, smb_fname_src, smb_fname_dst);
855
856         do_log(SMB_VFS_OP_RENAME, (result >= 0), handle, "%s|%s",
857                smb_fname_str_do_log(smb_fname_src),
858                smb_fname_str_do_log(smb_fname_dst));
859
860         return result;    
861 }
862
863 static int smb_full_audit_fsync(vfs_handle_struct *handle, files_struct *fsp)
864 {
865         int result;
866         
867         result = SMB_VFS_NEXT_FSYNC(handle, fsp);
868
869         do_log(SMB_VFS_OP_FSYNC, (result >= 0), handle, "%s",
870                fsp_str_do_log(fsp));
871
872         return result;    
873 }
874
875 static int smb_full_audit_stat(vfs_handle_struct *handle,
876                                struct smb_filename *smb_fname)
877 {
878         int result;
879         
880         result = SMB_VFS_NEXT_STAT(handle, smb_fname);
881
882         do_log(SMB_VFS_OP_STAT, (result >= 0), handle, "%s",
883                smb_fname_str_do_log(smb_fname));
884
885         return result;    
886 }
887
888 static int smb_full_audit_fstat(vfs_handle_struct *handle, files_struct *fsp,
889                        SMB_STRUCT_STAT *sbuf)
890 {
891         int result;
892         
893         result = SMB_VFS_NEXT_FSTAT(handle, fsp, sbuf);
894
895         do_log(SMB_VFS_OP_FSTAT, (result >= 0), handle, "%s",
896                fsp_str_do_log(fsp));
897
898         return result;
899 }
900
901 static int smb_full_audit_lstat(vfs_handle_struct *handle,
902                                 struct smb_filename *smb_fname)
903 {
904         int result;
905         
906         result = SMB_VFS_NEXT_LSTAT(handle, smb_fname);
907
908         do_log(SMB_VFS_OP_LSTAT, (result >= 0), handle, "%s",
909                smb_fname_str_do_log(smb_fname));
910
911         return result;    
912 }
913
914 static uint64_t smb_full_audit_get_alloc_size(vfs_handle_struct *handle,
915                        files_struct *fsp, const SMB_STRUCT_STAT *sbuf)
916 {
917         int result;
918
919         result = SMB_VFS_NEXT_GET_ALLOC_SIZE(handle, fsp, sbuf);
920
921         do_log(SMB_VFS_OP_GET_ALLOC_SIZE, (result >= 0), handle, "%d", result);
922
923         return result;
924 }
925
926 static int smb_full_audit_unlink(vfs_handle_struct *handle,
927                                  const struct smb_filename *smb_fname)
928 {
929         int result;
930         
931         result = SMB_VFS_NEXT_UNLINK(handle, smb_fname);
932
933         do_log(SMB_VFS_OP_UNLINK, (result >= 0), handle, "%s",
934                smb_fname_str_do_log(smb_fname));
935
936         return result;
937 }
938
939 static int smb_full_audit_chmod(vfs_handle_struct *handle,
940                        const char *path, mode_t mode)
941 {
942         int result;
943
944         result = SMB_VFS_NEXT_CHMOD(handle, path, mode);
945
946         do_log(SMB_VFS_OP_CHMOD, (result >= 0), handle, "%s|%o", path, mode);
947
948         return result;
949 }
950
951 static int smb_full_audit_fchmod(vfs_handle_struct *handle, files_struct *fsp,
952                         mode_t mode)
953 {
954         int result;
955         
956         result = SMB_VFS_NEXT_FCHMOD(handle, fsp, mode);
957
958         do_log(SMB_VFS_OP_FCHMOD, (result >= 0), handle,
959                "%s|%o", fsp_str_do_log(fsp), mode);
960
961         return result;
962 }
963
964 static int smb_full_audit_chown(vfs_handle_struct *handle,
965                        const char *path, uid_t uid, gid_t gid)
966 {
967         int result;
968
969         result = SMB_VFS_NEXT_CHOWN(handle, path, uid, gid);
970
971         do_log(SMB_VFS_OP_CHOWN, (result >= 0), handle, "%s|%ld|%ld",
972                path, (long int)uid, (long int)gid);
973
974         return result;
975 }
976
977 static int smb_full_audit_fchown(vfs_handle_struct *handle, files_struct *fsp,
978                         uid_t uid, gid_t gid)
979 {
980         int result;
981
982         result = SMB_VFS_NEXT_FCHOWN(handle, fsp, uid, gid);
983
984         do_log(SMB_VFS_OP_FCHOWN, (result >= 0), handle, "%s|%ld|%ld",
985                fsp_str_do_log(fsp), (long int)uid, (long int)gid);
986
987         return result;
988 }
989
990 static int smb_full_audit_lchown(vfs_handle_struct *handle,
991                        const char *path, uid_t uid, gid_t gid)
992 {
993         int result;
994
995         result = SMB_VFS_NEXT_LCHOWN(handle, path, uid, gid);
996
997         do_log(SMB_VFS_OP_LCHOWN, (result >= 0), handle, "%s|%ld|%ld",
998                path, (long int)uid, (long int)gid);
999
1000         return result;
1001 }
1002
1003 static int smb_full_audit_chdir(vfs_handle_struct *handle,
1004                        const char *path)
1005 {
1006         int result;
1007
1008         result = SMB_VFS_NEXT_CHDIR(handle, path);
1009
1010         do_log(SMB_VFS_OP_CHDIR, (result >= 0), handle, "chdir|%s", path);
1011
1012         return result;
1013 }
1014
1015 static char *smb_full_audit_getwd(vfs_handle_struct *handle,
1016                          char *path)
1017 {
1018         char *result;
1019
1020         result = SMB_VFS_NEXT_GETWD(handle, path);
1021         
1022         do_log(SMB_VFS_OP_GETWD, (result != NULL), handle, "%s", path);
1023
1024         return result;
1025 }
1026
1027 static int smb_full_audit_ntimes(vfs_handle_struct *handle,
1028                                  const struct smb_filename *smb_fname,
1029                                  struct smb_file_time *ft)
1030 {
1031         int result;
1032
1033         result = SMB_VFS_NEXT_NTIMES(handle, smb_fname, ft);
1034
1035         do_log(SMB_VFS_OP_NTIMES, (result >= 0), handle, "%s",
1036                smb_fname_str_do_log(smb_fname));
1037
1038         return result;
1039 }
1040
1041 static int smb_full_audit_ftruncate(vfs_handle_struct *handle, files_struct *fsp,
1042                            SMB_OFF_T len)
1043 {
1044         int result;
1045
1046         result = SMB_VFS_NEXT_FTRUNCATE(handle, fsp, len);
1047
1048         do_log(SMB_VFS_OP_FTRUNCATE, (result >= 0), handle,
1049                "%s", fsp_str_do_log(fsp));
1050
1051         return result;
1052 }
1053
1054 static bool smb_full_audit_lock(vfs_handle_struct *handle, files_struct *fsp,
1055                        int op, SMB_OFF_T offset, SMB_OFF_T count, int type)
1056 {
1057         bool result;
1058
1059         result = SMB_VFS_NEXT_LOCK(handle, fsp, op, offset, count, type);
1060
1061         do_log(SMB_VFS_OP_LOCK, result, handle, "%s", fsp_str_do_log(fsp));
1062
1063         return result;
1064 }
1065
1066 static int smb_full_audit_kernel_flock(struct vfs_handle_struct *handle,
1067                                        struct files_struct *fsp,
1068                                        uint32 share_mode)
1069 {
1070         int result;
1071
1072         result = SMB_VFS_NEXT_KERNEL_FLOCK(handle, fsp, share_mode);
1073
1074         do_log(SMB_VFS_OP_KERNEL_FLOCK, (result >= 0), handle, "%s",
1075                fsp_str_do_log(fsp));
1076
1077         return result;
1078 }
1079
1080 static int smb_full_audit_linux_setlease(vfs_handle_struct *handle, files_struct *fsp,
1081                                  int leasetype)
1082 {
1083         int result;
1084
1085         result = SMB_VFS_NEXT_LINUX_SETLEASE(handle, fsp, leasetype);
1086
1087         do_log(SMB_VFS_OP_LINUX_SETLEASE, (result >= 0), handle, "%s",
1088                fsp_str_do_log(fsp));
1089
1090         return result;
1091 }
1092
1093 static bool smb_full_audit_getlock(vfs_handle_struct *handle, files_struct *fsp,
1094                        SMB_OFF_T *poffset, SMB_OFF_T *pcount, int *ptype, pid_t *ppid)
1095 {
1096         bool result;
1097
1098         result = SMB_VFS_NEXT_GETLOCK(handle, fsp, poffset, pcount, ptype, ppid);
1099
1100         do_log(SMB_VFS_OP_GETLOCK, result, handle, "%s", fsp_str_do_log(fsp));
1101
1102         return result;
1103 }
1104
1105 static int smb_full_audit_symlink(vfs_handle_struct *handle,
1106                          const char *oldpath, const char *newpath)
1107 {
1108         int result;
1109
1110         result = SMB_VFS_NEXT_SYMLINK(handle, oldpath, newpath);
1111
1112         do_log(SMB_VFS_OP_SYMLINK, (result >= 0), handle,
1113                "%s|%s", oldpath, newpath);
1114
1115         return result;
1116 }
1117
1118 static int smb_full_audit_readlink(vfs_handle_struct *handle,
1119                           const char *path, char *buf, size_t bufsiz)
1120 {
1121         int result;
1122
1123         result = SMB_VFS_NEXT_READLINK(handle, path, buf, bufsiz);
1124
1125         do_log(SMB_VFS_OP_READLINK, (result >= 0), handle, "%s", path);
1126
1127         return result;
1128 }
1129
1130 static int smb_full_audit_link(vfs_handle_struct *handle,
1131                       const char *oldpath, const char *newpath)
1132 {
1133         int result;
1134
1135         result = SMB_VFS_NEXT_LINK(handle, oldpath, newpath);
1136
1137         do_log(SMB_VFS_OP_LINK, (result >= 0), handle,
1138                "%s|%s", oldpath, newpath);
1139
1140         return result;
1141 }
1142
1143 static int smb_full_audit_mknod(vfs_handle_struct *handle,
1144                        const char *pathname, mode_t mode, SMB_DEV_T dev)
1145 {
1146         int result;
1147
1148         result = SMB_VFS_NEXT_MKNOD(handle, pathname, mode, dev);
1149
1150         do_log(SMB_VFS_OP_MKNOD, (result >= 0), handle, "%s", pathname);
1151
1152         return result;
1153 }
1154
1155 static char *smb_full_audit_realpath(vfs_handle_struct *handle,
1156                             const char *path, char *resolved_path)
1157 {
1158         char *result;
1159
1160         result = SMB_VFS_NEXT_REALPATH(handle, path, resolved_path);
1161
1162         do_log(SMB_VFS_OP_REALPATH, (result != NULL), handle, "%s", path);
1163
1164         return result;
1165 }
1166
1167 static NTSTATUS smb_full_audit_notify_watch(struct vfs_handle_struct *handle,
1168                         struct sys_notify_context *ctx,
1169                         struct notify_entry *e,
1170                         void (*callback)(struct sys_notify_context *ctx,
1171                                         void *private_data,
1172                                         struct notify_event *ev),
1173                         void *private_data, void *handle_p)
1174 {
1175         NTSTATUS result;
1176
1177         result = SMB_VFS_NEXT_NOTIFY_WATCH(handle, ctx, e, callback, private_data, handle_p);
1178
1179         do_log(SMB_VFS_OP_NOTIFY_WATCH, NT_STATUS_IS_OK(result), handle, "");
1180
1181         return result;
1182 }
1183
1184 static int smb_full_audit_chflags(vfs_handle_struct *handle,
1185                             const char *path, unsigned int flags)
1186 {
1187         int result;
1188
1189         result = SMB_VFS_NEXT_CHFLAGS(handle, path, flags);
1190
1191         do_log(SMB_VFS_OP_CHFLAGS, (result != 0), handle, "%s", path);
1192
1193         return result;
1194 }
1195
1196 static struct file_id smb_full_audit_file_id_create(struct vfs_handle_struct *handle,
1197                                                     const SMB_STRUCT_STAT *sbuf)
1198 {
1199         struct file_id id_zero;
1200         struct file_id result;
1201
1202         ZERO_STRUCT(id_zero);
1203
1204         result = SMB_VFS_NEXT_FILE_ID_CREATE(handle, sbuf);
1205
1206         do_log(SMB_VFS_OP_FILE_ID_CREATE,
1207                !file_id_equal(&id_zero, &result),
1208                handle, "%s", file_id_string_tos(&result));
1209
1210         return result;
1211 }
1212
1213 static NTSTATUS smb_full_audit_streaminfo(vfs_handle_struct *handle,
1214                                           struct files_struct *fsp,
1215                                           const char *fname,
1216                                           TALLOC_CTX *mem_ctx,
1217                                           unsigned int *pnum_streams,
1218                                           struct stream_struct **pstreams)
1219 {
1220         NTSTATUS result;
1221
1222         result = SMB_VFS_NEXT_STREAMINFO(handle, fsp, fname, mem_ctx,
1223                                          pnum_streams, pstreams);
1224
1225         do_log(SMB_VFS_OP_STREAMINFO, NT_STATUS_IS_OK(result), handle,
1226                "%s", fname);
1227
1228         return result;
1229 }
1230
1231 static int smb_full_audit_get_real_filename(struct vfs_handle_struct *handle,
1232                                             const char *path,
1233                                             const char *name,
1234                                             TALLOC_CTX *mem_ctx,
1235                                             char **found_name)
1236 {
1237         int result;
1238
1239         result = SMB_VFS_NEXT_GET_REAL_FILENAME(handle, path, name, mem_ctx,
1240                                                 found_name);
1241
1242         do_log(SMB_VFS_OP_GET_REAL_FILENAME, (result == 0), handle,
1243                "%s/%s->%s", path, name, (result == 0) ? "" : *found_name);
1244
1245         return result;
1246 }
1247
1248 static const char *smb_full_audit_connectpath(vfs_handle_struct *handle,
1249                                               const char *fname)
1250 {
1251         const char *result;
1252
1253         result = SMB_VFS_NEXT_CONNECTPATH(handle, fname);
1254
1255         do_log(SMB_VFS_OP_CONNECTPATH, result != NULL, handle,
1256                "%s", fname);
1257
1258         return result;
1259 }
1260
1261 static NTSTATUS smb_full_audit_brl_lock_windows(struct vfs_handle_struct *handle,
1262                                                 struct byte_range_lock *br_lck,
1263                                                 struct lock_struct *plock,
1264                                                 bool blocking_lock,
1265                                                 struct blocking_lock_record *blr)
1266 {
1267         NTSTATUS result;
1268
1269         result = SMB_VFS_NEXT_BRL_LOCK_WINDOWS(handle, br_lck, plock,
1270             blocking_lock, blr);
1271
1272         do_log(SMB_VFS_OP_BRL_LOCK_WINDOWS, NT_STATUS_IS_OK(result), handle,
1273             "%s:%llu-%llu. type=%d. blocking=%d", fsp_str_do_log(br_lck->fsp),
1274             plock->start, plock->size, plock->lock_type, blocking_lock );
1275
1276         return result;
1277 }
1278
1279 static bool smb_full_audit_brl_unlock_windows(struct vfs_handle_struct *handle,
1280                                               struct messaging_context *msg_ctx,
1281                                               struct byte_range_lock *br_lck,
1282                                               const struct lock_struct *plock)
1283 {
1284         bool result;
1285
1286         result = SMB_VFS_NEXT_BRL_UNLOCK_WINDOWS(handle, msg_ctx, br_lck,
1287             plock);
1288
1289         do_log(SMB_VFS_OP_BRL_UNLOCK_WINDOWS, (result == 0), handle,
1290             "%s:%llu-%llu:%d", fsp_str_do_log(br_lck->fsp), plock->start,
1291             plock->size, plock->lock_type);
1292
1293         return result;
1294 }
1295
1296 static bool smb_full_audit_brl_cancel_windows(struct vfs_handle_struct *handle,
1297                                               struct byte_range_lock *br_lck,
1298                                               struct lock_struct *plock,
1299                                               struct blocking_lock_record *blr)
1300 {
1301         bool result;
1302
1303         result = SMB_VFS_NEXT_BRL_CANCEL_WINDOWS(handle, br_lck, plock, blr);
1304
1305         do_log(SMB_VFS_OP_BRL_CANCEL_WINDOWS, (result == 0), handle,
1306             "%s:%llu-%llu:%d", fsp_str_do_log(br_lck->fsp), plock->start,
1307             plock->size);
1308
1309         return result;
1310 }
1311
1312 static bool smb_full_audit_strict_lock(struct vfs_handle_struct *handle,
1313                                        struct files_struct *fsp,
1314                                        struct lock_struct *plock)
1315 {
1316         bool result;
1317
1318         result = SMB_VFS_NEXT_STRICT_LOCK(handle, fsp, plock);
1319
1320         do_log(SMB_VFS_OP_STRICT_LOCK, result, handle,
1321             "%s:%llu-%llu:%d", fsp_str_do_log(fsp), plock->start,
1322             plock->size);
1323
1324         return result;
1325 }
1326
1327 static void smb_full_audit_strict_unlock(struct vfs_handle_struct *handle,
1328                                          struct files_struct *fsp,
1329                                          struct lock_struct *plock)
1330 {
1331         SMB_VFS_NEXT_STRICT_UNLOCK(handle, fsp, plock);
1332
1333         do_log(SMB_VFS_OP_STRICT_UNLOCK, true, handle,
1334             "%s:%llu-%llu:%d", fsp_str_do_log(fsp), plock->start,
1335             plock->size);
1336
1337         return;
1338 }
1339
1340 static NTSTATUS smb_full_audit_fget_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
1341                                 uint32 security_info,
1342                                 SEC_DESC **ppdesc)
1343 {
1344         NTSTATUS result;
1345
1346         result = SMB_VFS_NEXT_FGET_NT_ACL(handle, fsp, security_info, ppdesc);
1347
1348         do_log(SMB_VFS_OP_FGET_NT_ACL, NT_STATUS_IS_OK(result), handle,
1349                "%s", fsp_str_do_log(fsp));
1350
1351         return result;
1352 }
1353
1354 static NTSTATUS smb_full_audit_get_nt_acl(vfs_handle_struct *handle,
1355                                           const char *name,
1356                                           uint32 security_info,
1357                                           SEC_DESC **ppdesc)
1358 {
1359         NTSTATUS result;
1360
1361         result = SMB_VFS_NEXT_GET_NT_ACL(handle, name, security_info, ppdesc);
1362
1363         do_log(SMB_VFS_OP_GET_NT_ACL, NT_STATUS_IS_OK(result), handle,
1364                "%s", name);
1365
1366         return result;
1367 }
1368
1369 static NTSTATUS smb_full_audit_fset_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
1370                               uint32 security_info_sent,
1371                               const SEC_DESC *psd)
1372 {
1373         NTSTATUS result;
1374
1375         result = SMB_VFS_NEXT_FSET_NT_ACL(handle, fsp, security_info_sent, psd);
1376
1377         do_log(SMB_VFS_OP_FSET_NT_ACL, NT_STATUS_IS_OK(result), handle, "%s",
1378                fsp_str_do_log(fsp));
1379
1380         return result;
1381 }
1382
1383 static int smb_full_audit_chmod_acl(vfs_handle_struct *handle,
1384                            const char *path, mode_t mode)
1385 {
1386         int result;
1387         
1388         result = SMB_VFS_NEXT_CHMOD_ACL(handle, path, mode);
1389
1390         do_log(SMB_VFS_OP_CHMOD_ACL, (result >= 0), handle,
1391                "%s|%o", path, mode);
1392
1393         return result;
1394 }
1395
1396 static int smb_full_audit_fchmod_acl(vfs_handle_struct *handle, files_struct *fsp,
1397                                      mode_t mode)
1398 {
1399         int result;
1400         
1401         result = SMB_VFS_NEXT_FCHMOD_ACL(handle, fsp, mode);
1402
1403         do_log(SMB_VFS_OP_FCHMOD_ACL, (result >= 0), handle,
1404                "%s|%o", fsp_str_do_log(fsp), mode);
1405
1406         return result;
1407 }
1408
1409 static int smb_full_audit_sys_acl_get_entry(vfs_handle_struct *handle,
1410
1411                                    SMB_ACL_T theacl, int entry_id,
1412                                    SMB_ACL_ENTRY_T *entry_p)
1413 {
1414         int result;
1415
1416         result = SMB_VFS_NEXT_SYS_ACL_GET_ENTRY(handle, theacl, entry_id,
1417                                                 entry_p);
1418
1419         do_log(SMB_VFS_OP_SYS_ACL_GET_ENTRY, (result >= 0), handle,
1420                "");
1421
1422         return result;
1423 }
1424
1425 static int smb_full_audit_sys_acl_get_tag_type(vfs_handle_struct *handle,
1426
1427                                       SMB_ACL_ENTRY_T entry_d,
1428                                       SMB_ACL_TAG_T *tag_type_p)
1429 {
1430         int result;
1431
1432         result = SMB_VFS_NEXT_SYS_ACL_GET_TAG_TYPE(handle, entry_d,
1433                                                    tag_type_p);
1434
1435         do_log(SMB_VFS_OP_SYS_ACL_GET_TAG_TYPE, (result >= 0), handle,
1436                "");
1437
1438         return result;
1439 }
1440
1441 static int smb_full_audit_sys_acl_get_permset(vfs_handle_struct *handle,
1442
1443                                      SMB_ACL_ENTRY_T entry_d,
1444                                      SMB_ACL_PERMSET_T *permset_p)
1445 {
1446         int result;
1447
1448         result = SMB_VFS_NEXT_SYS_ACL_GET_PERMSET(handle, entry_d,
1449                                                   permset_p);
1450
1451         do_log(SMB_VFS_OP_SYS_ACL_GET_PERMSET, (result >= 0), handle,
1452                "");
1453
1454         return result;
1455 }
1456
1457 static void * smb_full_audit_sys_acl_get_qualifier(vfs_handle_struct *handle,
1458
1459                                           SMB_ACL_ENTRY_T entry_d)
1460 {
1461         void *result;
1462
1463         result = SMB_VFS_NEXT_SYS_ACL_GET_QUALIFIER(handle, entry_d);
1464
1465         do_log(SMB_VFS_OP_SYS_ACL_GET_QUALIFIER, (result != NULL), handle,
1466                "");
1467
1468         return result;
1469 }
1470
1471 static SMB_ACL_T smb_full_audit_sys_acl_get_file(vfs_handle_struct *handle,
1472                                         const char *path_p,
1473                                         SMB_ACL_TYPE_T type)
1474 {
1475         SMB_ACL_T result;
1476
1477         result = SMB_VFS_NEXT_SYS_ACL_GET_FILE(handle, path_p, type);
1478
1479         do_log(SMB_VFS_OP_SYS_ACL_GET_FILE, (result != NULL), handle,
1480                "%s", path_p);
1481
1482         return result;
1483 }
1484
1485 static SMB_ACL_T smb_full_audit_sys_acl_get_fd(vfs_handle_struct *handle,
1486                                       files_struct *fsp)
1487 {
1488         SMB_ACL_T result;
1489
1490         result = SMB_VFS_NEXT_SYS_ACL_GET_FD(handle, fsp);
1491
1492         do_log(SMB_VFS_OP_SYS_ACL_GET_FD, (result != NULL), handle,
1493                "%s", fsp_str_do_log(fsp));
1494
1495         return result;
1496 }
1497
1498 static int smb_full_audit_sys_acl_clear_perms(vfs_handle_struct *handle,
1499
1500                                      SMB_ACL_PERMSET_T permset)
1501 {
1502         int result;
1503
1504         result = SMB_VFS_NEXT_SYS_ACL_CLEAR_PERMS(handle, permset);
1505
1506         do_log(SMB_VFS_OP_SYS_ACL_CLEAR_PERMS, (result >= 0), handle,
1507                "");
1508
1509         return result;
1510 }
1511
1512 static int smb_full_audit_sys_acl_add_perm(vfs_handle_struct *handle,
1513
1514                                   SMB_ACL_PERMSET_T permset,
1515                                   SMB_ACL_PERM_T perm)
1516 {
1517         int result;
1518
1519         result = SMB_VFS_NEXT_SYS_ACL_ADD_PERM(handle, permset, perm);
1520
1521         do_log(SMB_VFS_OP_SYS_ACL_ADD_PERM, (result >= 0), handle,
1522                "");
1523
1524         return result;
1525 }
1526
1527 static char * smb_full_audit_sys_acl_to_text(vfs_handle_struct *handle,
1528                                     SMB_ACL_T theacl,
1529                                     ssize_t *plen)
1530 {
1531         char * result;
1532
1533         result = SMB_VFS_NEXT_SYS_ACL_TO_TEXT(handle, theacl, plen);
1534
1535         do_log(SMB_VFS_OP_SYS_ACL_TO_TEXT, (result != NULL), handle,
1536                "");
1537
1538         return result;
1539 }
1540
1541 static SMB_ACL_T smb_full_audit_sys_acl_init(vfs_handle_struct *handle,
1542
1543                                     int count)
1544 {
1545         SMB_ACL_T result;
1546
1547         result = SMB_VFS_NEXT_SYS_ACL_INIT(handle, count);
1548
1549         do_log(SMB_VFS_OP_SYS_ACL_INIT, (result != NULL), handle,
1550                "");
1551
1552         return result;
1553 }
1554
1555 static int smb_full_audit_sys_acl_create_entry(vfs_handle_struct *handle,
1556                                       SMB_ACL_T *pacl,
1557                                       SMB_ACL_ENTRY_T *pentry)
1558 {
1559         int result;
1560
1561         result = SMB_VFS_NEXT_SYS_ACL_CREATE_ENTRY(handle, pacl, pentry);
1562
1563         do_log(SMB_VFS_OP_SYS_ACL_CREATE_ENTRY, (result >= 0), handle,
1564                "");
1565
1566         return result;
1567 }
1568
1569 static int smb_full_audit_sys_acl_set_tag_type(vfs_handle_struct *handle,
1570
1571                                       SMB_ACL_ENTRY_T entry,
1572                                       SMB_ACL_TAG_T tagtype)
1573 {
1574         int result;
1575
1576         result = SMB_VFS_NEXT_SYS_ACL_SET_TAG_TYPE(handle, entry,
1577                                                    tagtype);
1578
1579         do_log(SMB_VFS_OP_SYS_ACL_SET_TAG_TYPE, (result >= 0), handle,
1580                "");
1581
1582         return result;
1583 }
1584
1585 static int smb_full_audit_sys_acl_set_qualifier(vfs_handle_struct *handle,
1586
1587                                        SMB_ACL_ENTRY_T entry,
1588                                        void *qual)
1589 {
1590         int result;
1591
1592         result = SMB_VFS_NEXT_SYS_ACL_SET_QUALIFIER(handle, entry, qual);
1593
1594         do_log(SMB_VFS_OP_SYS_ACL_SET_QUALIFIER, (result >= 0), handle,
1595                "");
1596
1597         return result;
1598 }
1599
1600 static int smb_full_audit_sys_acl_set_permset(vfs_handle_struct *handle,
1601
1602                                      SMB_ACL_ENTRY_T entry,
1603                                      SMB_ACL_PERMSET_T permset)
1604 {
1605         int result;
1606
1607         result = SMB_VFS_NEXT_SYS_ACL_SET_PERMSET(handle, entry, permset);
1608
1609         do_log(SMB_VFS_OP_SYS_ACL_SET_PERMSET, (result >= 0), handle,
1610                "");
1611
1612         return result;
1613 }
1614
1615 static int smb_full_audit_sys_acl_valid(vfs_handle_struct *handle,
1616
1617                                SMB_ACL_T theacl )
1618 {
1619         int result;
1620
1621         result = SMB_VFS_NEXT_SYS_ACL_VALID(handle, theacl);
1622
1623         do_log(SMB_VFS_OP_SYS_ACL_VALID, (result >= 0), handle,
1624                "");
1625
1626         return result;
1627 }
1628
1629 static int smb_full_audit_sys_acl_set_file(vfs_handle_struct *handle,
1630
1631                                   const char *name, SMB_ACL_TYPE_T acltype,
1632                                   SMB_ACL_T theacl)
1633 {
1634         int result;
1635
1636         result = SMB_VFS_NEXT_SYS_ACL_SET_FILE(handle, name, acltype,
1637                                                theacl);
1638
1639         do_log(SMB_VFS_OP_SYS_ACL_SET_FILE, (result >= 0), handle,
1640                "%s", name);
1641
1642         return result;
1643 }
1644
1645 static int smb_full_audit_sys_acl_set_fd(vfs_handle_struct *handle, files_struct *fsp,
1646                                 SMB_ACL_T theacl)
1647 {
1648         int result;
1649
1650         result = SMB_VFS_NEXT_SYS_ACL_SET_FD(handle, fsp, theacl);
1651
1652         do_log(SMB_VFS_OP_SYS_ACL_SET_FD, (result >= 0), handle,
1653                "%s", fsp_str_do_log(fsp));
1654
1655         return result;
1656 }
1657
1658 static int smb_full_audit_sys_acl_delete_def_file(vfs_handle_struct *handle,
1659
1660                                          const char *path)
1661 {
1662         int result;
1663
1664         result = SMB_VFS_NEXT_SYS_ACL_DELETE_DEF_FILE(handle, path);
1665
1666         do_log(SMB_VFS_OP_SYS_ACL_DELETE_DEF_FILE, (result >= 0), handle,
1667                "%s", path);
1668
1669         return result;
1670 }
1671
1672 static int smb_full_audit_sys_acl_get_perm(vfs_handle_struct *handle,
1673
1674                                   SMB_ACL_PERMSET_T permset,
1675                                   SMB_ACL_PERM_T perm)
1676 {
1677         int result;
1678
1679         result = SMB_VFS_NEXT_SYS_ACL_GET_PERM(handle, permset, perm);
1680
1681         do_log(SMB_VFS_OP_SYS_ACL_GET_PERM, (result >= 0), handle,
1682                "");
1683
1684         return result;
1685 }
1686
1687 static int smb_full_audit_sys_acl_free_text(vfs_handle_struct *handle,
1688
1689                                    char *text)
1690 {
1691         int result;
1692
1693         result = SMB_VFS_NEXT_SYS_ACL_FREE_TEXT(handle, text);
1694
1695         do_log(SMB_VFS_OP_SYS_ACL_FREE_TEXT, (result >= 0), handle,
1696                "");
1697
1698         return result;
1699 }
1700
1701 static int smb_full_audit_sys_acl_free_acl(vfs_handle_struct *handle,
1702
1703                                   SMB_ACL_T posix_acl)
1704 {
1705         int result;
1706
1707         result = SMB_VFS_NEXT_SYS_ACL_FREE_ACL(handle, posix_acl);
1708
1709         do_log(SMB_VFS_OP_SYS_ACL_FREE_ACL, (result >= 0), handle,
1710                "");
1711
1712         return result;
1713 }
1714
1715 static int smb_full_audit_sys_acl_free_qualifier(vfs_handle_struct *handle,
1716                                         void *qualifier,
1717                                         SMB_ACL_TAG_T tagtype)
1718 {
1719         int result;
1720
1721         result = SMB_VFS_NEXT_SYS_ACL_FREE_QUALIFIER(handle, qualifier,
1722                                                      tagtype);
1723
1724         do_log(SMB_VFS_OP_SYS_ACL_FREE_QUALIFIER, (result >= 0), handle,
1725                "");
1726
1727         return result;
1728 }
1729
1730 static ssize_t smb_full_audit_getxattr(struct vfs_handle_struct *handle,
1731                               const char *path,
1732                               const char *name, void *value, size_t size)
1733 {
1734         ssize_t result;
1735
1736         result = SMB_VFS_NEXT_GETXATTR(handle, path, name, value, size);
1737
1738         do_log(SMB_VFS_OP_GETXATTR, (result >= 0), handle,
1739                "%s|%s", path, name);
1740
1741         return result;
1742 }
1743
1744 static ssize_t smb_full_audit_lgetxattr(struct vfs_handle_struct *handle,
1745                                const char *path, const char *name,
1746                                void *value, size_t size)
1747 {
1748         ssize_t result;
1749
1750         result = SMB_VFS_NEXT_LGETXATTR(handle, path, name, value, size);
1751
1752         do_log(SMB_VFS_OP_LGETXATTR, (result >= 0), handle,
1753                "%s|%s", path, name);
1754
1755         return result;
1756 }
1757
1758 static ssize_t smb_full_audit_fgetxattr(struct vfs_handle_struct *handle,
1759                                struct files_struct *fsp,
1760                                const char *name, void *value, size_t size)
1761 {
1762         ssize_t result;
1763
1764         result = SMB_VFS_NEXT_FGETXATTR(handle, fsp, name, value, size);
1765
1766         do_log(SMB_VFS_OP_FGETXATTR, (result >= 0), handle,
1767                "%s|%s", fsp_str_do_log(fsp), name);
1768
1769         return result;
1770 }
1771
1772 static ssize_t smb_full_audit_listxattr(struct vfs_handle_struct *handle,
1773                                const char *path, char *list, size_t size)
1774 {
1775         ssize_t result;
1776
1777         result = SMB_VFS_NEXT_LISTXATTR(handle, path, list, size);
1778
1779         do_log(SMB_VFS_OP_LISTXATTR, (result >= 0), handle, "%s", path);
1780
1781         return result;
1782 }
1783
1784 static ssize_t smb_full_audit_llistxattr(struct vfs_handle_struct *handle,
1785                                 const char *path, char *list, size_t size)
1786 {
1787         ssize_t result;
1788
1789         result = SMB_VFS_NEXT_LLISTXATTR(handle, path, list, size);
1790
1791         do_log(SMB_VFS_OP_LLISTXATTR, (result >= 0), handle, "%s", path);
1792
1793         return result;
1794 }
1795
1796 static ssize_t smb_full_audit_flistxattr(struct vfs_handle_struct *handle,
1797                                 struct files_struct *fsp, char *list,
1798                                 size_t size)
1799 {
1800         ssize_t result;
1801
1802         result = SMB_VFS_NEXT_FLISTXATTR(handle, fsp, list, size);
1803
1804         do_log(SMB_VFS_OP_FLISTXATTR, (result >= 0), handle,
1805                "%s", fsp_str_do_log(fsp));
1806
1807         return result;
1808 }
1809
1810 static int smb_full_audit_removexattr(struct vfs_handle_struct *handle,
1811                              const char *path,
1812                              const char *name)
1813 {
1814         int result;
1815
1816         result = SMB_VFS_NEXT_REMOVEXATTR(handle, path, name);
1817
1818         do_log(SMB_VFS_OP_REMOVEXATTR, (result >= 0), handle,
1819                "%s|%s", path, name);
1820
1821         return result;
1822 }
1823
1824 static int smb_full_audit_lremovexattr(struct vfs_handle_struct *handle,
1825                               const char *path,
1826                               const char *name)
1827 {
1828         int result;
1829
1830         result = SMB_VFS_NEXT_LREMOVEXATTR(handle, path, name);
1831
1832         do_log(SMB_VFS_OP_LREMOVEXATTR, (result >= 0), handle,
1833                "%s|%s", path, name);
1834
1835         return result;
1836 }
1837
1838 static int smb_full_audit_fremovexattr(struct vfs_handle_struct *handle,
1839                               struct files_struct *fsp,
1840                               const char *name)
1841 {
1842         int result;
1843
1844         result = SMB_VFS_NEXT_FREMOVEXATTR(handle, fsp, name);
1845
1846         do_log(SMB_VFS_OP_FREMOVEXATTR, (result >= 0), handle,
1847                "%s|%s", fsp_str_do_log(fsp), name);
1848
1849         return result;
1850 }
1851
1852 static int smb_full_audit_setxattr(struct vfs_handle_struct *handle,
1853                           const char *path,
1854                           const char *name, const void *value, size_t size,
1855                           int flags)
1856 {
1857         int result;
1858
1859         result = SMB_VFS_NEXT_SETXATTR(handle, path, name, value, size,
1860                                        flags);
1861
1862         do_log(SMB_VFS_OP_SETXATTR, (result >= 0), handle,
1863                "%s|%s", path, name);
1864
1865         return result;
1866 }
1867
1868 static int smb_full_audit_lsetxattr(struct vfs_handle_struct *handle,
1869                            const char *path,
1870                            const char *name, const void *value, size_t size,
1871                            int flags)
1872 {
1873         int result;
1874
1875         result = SMB_VFS_NEXT_LSETXATTR(handle, path, name, value, size,
1876                                         flags);
1877
1878         do_log(SMB_VFS_OP_LSETXATTR, (result >= 0), handle,
1879                "%s|%s", path, name);
1880
1881         return result;
1882 }
1883
1884 static int smb_full_audit_fsetxattr(struct vfs_handle_struct *handle,
1885                            struct files_struct *fsp, const char *name,
1886                            const void *value, size_t size, int flags)
1887 {
1888         int result;
1889
1890         result = SMB_VFS_NEXT_FSETXATTR(handle, fsp, name, value, size, flags);
1891
1892         do_log(SMB_VFS_OP_FSETXATTR, (result >= 0), handle,
1893                "%s|%s", fsp_str_do_log(fsp), name);
1894
1895         return result;
1896 }
1897
1898 static int smb_full_audit_aio_read(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb)
1899 {
1900         int result;
1901
1902         result = SMB_VFS_NEXT_AIO_READ(handle, fsp, aiocb);
1903         do_log(SMB_VFS_OP_AIO_READ, (result >= 0), handle,
1904                "%s", fsp_str_do_log(fsp));
1905
1906         return result;
1907 }
1908
1909 static int smb_full_audit_aio_write(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb)
1910 {
1911         int result;
1912
1913         result = SMB_VFS_NEXT_AIO_WRITE(handle, fsp, aiocb);
1914         do_log(SMB_VFS_OP_AIO_WRITE, (result >= 0), handle,
1915                "%s", fsp_str_do_log(fsp));
1916
1917         return result;
1918 }
1919
1920 static ssize_t smb_full_audit_aio_return(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb)
1921 {
1922         int result;
1923
1924         result = SMB_VFS_NEXT_AIO_RETURN(handle, fsp, aiocb);
1925         do_log(SMB_VFS_OP_AIO_RETURN, (result >= 0), handle,
1926                "%s", fsp_str_do_log(fsp));
1927
1928         return result;
1929 }
1930
1931 static int smb_full_audit_aio_cancel(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb)
1932 {
1933         int result;
1934
1935         result = SMB_VFS_NEXT_AIO_CANCEL(handle, fsp, aiocb);
1936         do_log(SMB_VFS_OP_AIO_CANCEL, (result >= 0), handle,
1937                "%s", fsp_str_do_log(fsp));
1938
1939         return result;
1940 }
1941
1942 static int smb_full_audit_aio_error(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb)
1943 {
1944         int result;
1945
1946         result = SMB_VFS_NEXT_AIO_ERROR(handle, fsp, aiocb);
1947         do_log(SMB_VFS_OP_AIO_ERROR, (result >= 0), handle,
1948                "%s", fsp_str_do_log(fsp));
1949
1950         return result;
1951 }
1952
1953 static int smb_full_audit_aio_fsync(struct vfs_handle_struct *handle, struct files_struct *fsp, int op, SMB_STRUCT_AIOCB *aiocb)
1954 {
1955         int result;
1956
1957         result = SMB_VFS_NEXT_AIO_FSYNC(handle, fsp, op, aiocb);
1958         do_log(SMB_VFS_OP_AIO_FSYNC, (result >= 0), handle,
1959                 "%s", fsp_str_do_log(fsp));
1960
1961         return result;
1962 }
1963
1964 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)
1965 {
1966         int result;
1967
1968         result = SMB_VFS_NEXT_AIO_SUSPEND(handle, fsp, aiocb, n, ts);
1969         do_log(SMB_VFS_OP_AIO_SUSPEND, (result >= 0), handle,
1970                 "%s", fsp_str_do_log(fsp));
1971
1972         return result;
1973 }
1974
1975 static bool smb_full_audit_aio_force(struct vfs_handle_struct *handle,
1976                                      struct files_struct *fsp)
1977 {
1978         bool result;
1979
1980         result = SMB_VFS_NEXT_AIO_FORCE(handle, fsp);
1981         do_log(SMB_VFS_OP_AIO_FORCE, result, handle,
1982                 "%s", fsp_str_do_log(fsp));
1983
1984         return result;
1985 }
1986
1987 static struct vfs_fn_pointers vfs_full_audit_fns = {
1988
1989         /* Disk operations */
1990
1991         .connect_fn = smb_full_audit_connect,
1992         .disconnect = smb_full_audit_disconnect,
1993         .disk_free = smb_full_audit_disk_free,
1994         .get_quota = smb_full_audit_get_quota,
1995         .set_quota = smb_full_audit_set_quota,
1996         .get_shadow_copy_data = smb_full_audit_get_shadow_copy_data,
1997         .statvfs = smb_full_audit_statvfs,
1998         .fs_capabilities = smb_full_audit_fs_capabilities,
1999         .opendir = smb_full_audit_opendir,
2000         .readdir = smb_full_audit_readdir,
2001         .seekdir = smb_full_audit_seekdir,
2002         .telldir = smb_full_audit_telldir,
2003         .rewind_dir = smb_full_audit_rewinddir,
2004         .mkdir = smb_full_audit_mkdir,
2005         .rmdir = smb_full_audit_rmdir,
2006         .closedir = smb_full_audit_closedir,
2007         .init_search_op = smb_full_audit_init_search_op,
2008         .open = smb_full_audit_open,
2009         .create_file = smb_full_audit_create_file,
2010         .close_fn = smb_full_audit_close,
2011         .vfs_read = smb_full_audit_read,
2012         .pread = smb_full_audit_pread,
2013         .write = smb_full_audit_write,
2014         .pwrite = smb_full_audit_pwrite,
2015         .lseek = smb_full_audit_lseek,
2016         .sendfile = smb_full_audit_sendfile,
2017         .recvfile = smb_full_audit_recvfile,
2018         .rename = smb_full_audit_rename,
2019         .fsync = smb_full_audit_fsync,
2020         .stat = smb_full_audit_stat,
2021         .fstat = smb_full_audit_fstat,
2022         .lstat = smb_full_audit_lstat,
2023         .get_alloc_size = smb_full_audit_get_alloc_size,
2024         .unlink = smb_full_audit_unlink,
2025         .chmod = smb_full_audit_chmod,
2026         .fchmod = smb_full_audit_fchmod,
2027         .chown = smb_full_audit_chown,
2028         .fchown = smb_full_audit_fchown,
2029         .lchown = smb_full_audit_lchown,
2030         .chdir = smb_full_audit_chdir,
2031         .getwd = smb_full_audit_getwd,
2032         .ntimes = smb_full_audit_ntimes,
2033         .ftruncate = smb_full_audit_ftruncate,
2034         .lock = smb_full_audit_lock,
2035         .kernel_flock = smb_full_audit_kernel_flock,
2036         .linux_setlease = smb_full_audit_linux_setlease,
2037         .getlock = smb_full_audit_getlock,
2038         .symlink = smb_full_audit_symlink,
2039         .vfs_readlink = smb_full_audit_readlink,
2040         .link = smb_full_audit_link,
2041         .mknod = smb_full_audit_mknod,
2042         .realpath = smb_full_audit_realpath,
2043         .notify_watch = smb_full_audit_notify_watch,
2044         .chflags = smb_full_audit_chflags,
2045         .file_id_create = smb_full_audit_file_id_create,
2046         .streaminfo = smb_full_audit_streaminfo,
2047         .get_real_filename = smb_full_audit_get_real_filename,
2048         .connectpath = smb_full_audit_connectpath,
2049         .brl_lock_windows = smb_full_audit_brl_lock_windows,
2050         .brl_unlock_windows = smb_full_audit_brl_unlock_windows,
2051         .brl_cancel_windows = smb_full_audit_brl_cancel_windows,
2052         .strict_lock = smb_full_audit_strict_lock,
2053         .strict_unlock = smb_full_audit_strict_unlock,
2054         .fget_nt_acl = smb_full_audit_fget_nt_acl,
2055         .get_nt_acl = smb_full_audit_get_nt_acl,
2056         .fset_nt_acl = smb_full_audit_fset_nt_acl,
2057         .chmod_acl = smb_full_audit_chmod_acl,
2058         .fchmod_acl = smb_full_audit_fchmod_acl,
2059         .sys_acl_get_entry = smb_full_audit_sys_acl_get_entry,
2060         .sys_acl_get_tag_type = smb_full_audit_sys_acl_get_tag_type,
2061         .sys_acl_get_permset = smb_full_audit_sys_acl_get_permset,
2062         .sys_acl_get_qualifier = smb_full_audit_sys_acl_get_qualifier,
2063         .sys_acl_get_file = smb_full_audit_sys_acl_get_file,
2064         .sys_acl_get_fd = smb_full_audit_sys_acl_get_fd,
2065         .sys_acl_clear_perms = smb_full_audit_sys_acl_clear_perms,
2066         .sys_acl_add_perm = smb_full_audit_sys_acl_add_perm,
2067         .sys_acl_to_text = smb_full_audit_sys_acl_to_text,
2068         .sys_acl_init = smb_full_audit_sys_acl_init,
2069         .sys_acl_create_entry = smb_full_audit_sys_acl_create_entry,
2070         .sys_acl_set_tag_type = smb_full_audit_sys_acl_set_tag_type,
2071         .sys_acl_set_qualifier = smb_full_audit_sys_acl_set_qualifier,
2072         .sys_acl_set_permset = smb_full_audit_sys_acl_set_permset,
2073         .sys_acl_valid = smb_full_audit_sys_acl_valid,
2074         .sys_acl_set_file = smb_full_audit_sys_acl_set_file,
2075         .sys_acl_set_fd = smb_full_audit_sys_acl_set_fd,
2076         .sys_acl_delete_def_file = smb_full_audit_sys_acl_delete_def_file,
2077         .sys_acl_get_perm = smb_full_audit_sys_acl_get_perm,
2078         .sys_acl_free_text = smb_full_audit_sys_acl_free_text,
2079         .sys_acl_free_acl = smb_full_audit_sys_acl_free_acl,
2080         .sys_acl_free_qualifier = smb_full_audit_sys_acl_free_qualifier,
2081         .getxattr = smb_full_audit_getxattr,
2082         .lgetxattr = smb_full_audit_lgetxattr,
2083         .fgetxattr = smb_full_audit_fgetxattr,
2084         .listxattr = smb_full_audit_listxattr,
2085         .llistxattr = smb_full_audit_llistxattr,
2086         .flistxattr = smb_full_audit_flistxattr,
2087         .removexattr = smb_full_audit_removexattr,
2088         .lremovexattr = smb_full_audit_lremovexattr,
2089         .fremovexattr = smb_full_audit_fremovexattr,
2090         .setxattr = smb_full_audit_setxattr,
2091         .lsetxattr = smb_full_audit_lsetxattr,
2092         .fsetxattr = smb_full_audit_fsetxattr,
2093         .aio_read = smb_full_audit_aio_read,
2094         .aio_write = smb_full_audit_aio_write,
2095         .aio_return_fn = smb_full_audit_aio_return,
2096         .aio_cancel = smb_full_audit_aio_cancel,
2097         .aio_error_fn = smb_full_audit_aio_error,
2098         .aio_fsync = smb_full_audit_aio_fsync,
2099         .aio_suspend = smb_full_audit_aio_suspend,
2100         .aio_force = smb_full_audit_aio_force,
2101 };
2102
2103 NTSTATUS vfs_full_audit_init(void)
2104 {
2105         NTSTATUS ret = smb_register_vfs(SMB_VFS_INTERFACE_VERSION,
2106                                         "full_audit", &vfs_full_audit_fns);
2107         
2108         if (!NT_STATUS_IS_OK(ret))
2109                 return ret;
2110
2111         vfs_full_audit_debug_level = debug_add_class("full_audit");
2112         if (vfs_full_audit_debug_level == -1) {
2113                 vfs_full_audit_debug_level = DBGC_VFS;
2114                 DEBUG(0, ("vfs_full_audit: Couldn't register custom debugging "
2115                           "class!\n"));
2116         } else {
2117                 DEBUG(10, ("vfs_full_audit: Debug class number of "
2118                            "'full_audit': %d\n", vfs_full_audit_debug_level));
2119         }
2120         
2121         return ret;
2122 }