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