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