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