s3: Plumb smb_filename through SMB_VFS_CREATE_FILE
[samba.git] / source3 / modules / vfs_full_audit.c
1 /* 
2  * Auditing VFS module for samba.  Log selected file operations to syslog
3  * facility.
4  *
5  * Copyright (C) Tim Potter, 1999-2000
6  * Copyright (C) Alexander Bokovoy, 2002
7  * Copyright (C) John H Terpstra, 2003
8  * Copyright (C) Stefan (metze) Metzmacher, 2003
9  * Copyright (C) Volker Lendecke, 2004
10  *
11  * This program is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation; either version 3 of the License, or
14  * (at your option) any later version.
15  *  
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  * GNU General Public License for more details.
20  *  
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, see <http://www.gnu.org/licenses/>.
23  */
24
25 /*
26  * This module implements parseable logging for all Samba VFS operations.
27  *
28  * You use it as follows:
29  *
30  * [tmp]
31  * path = /tmp
32  * vfs objects = full_audit
33  * full_audit:prefix = %u|%I
34  * full_audit:success = open opendir
35  * full_audit:failure = all
36  *
37  * vfs op can be "all" which means log all operations.
38  * vfs op can be "none" which means no logging.
39  *
40  * This leads to syslog entries of the form:
41  * smbd_audit: nobody|192.168.234.1|opendir|ok|.
42  * smbd_audit: nobody|192.168.234.1|open|fail (File not found)|r|x.txt
43  *
44  * where "nobody" is the connected username and "192.168.234.1" is the
45  * client's IP address. 
46  *
47  * Options:
48  *
49  * prefix: A macro expansion template prepended to the syslog entry.
50  *
51  * success: A list of VFS operations for which a successful completion should
52  * be logged. Defaults to no logging at all. The special operation "all" logs
53  * - you guessed it - everything.
54  *
55  * failure: A list of VFS operations for which failure to complete should be
56  * logged. Defaults to logging everything.
57  */
58
59
60 #include "includes.h"
61
62 static int vfs_full_audit_debug_level = DBGC_VFS;
63
64 struct vfs_full_audit_private_data {
65         struct bitmap *success_ops;
66         struct bitmap *failure_ops;
67 };
68
69 #undef DBGC_CLASS
70 #define DBGC_CLASS vfs_full_audit_debug_level
71
72 /* Function prototypes */
73
74 static int smb_full_audit_connect(vfs_handle_struct *handle,
75                          const char *svc, const char *user);
76 static void smb_full_audit_disconnect(vfs_handle_struct *handle);
77 static uint64_t smb_full_audit_disk_free(vfs_handle_struct *handle,
78                                     const char *path,
79                                     bool small_query, uint64_t *bsize, 
80                                     uint64_t *dfree, uint64_t *dsize);
81 static int smb_full_audit_get_quota(struct vfs_handle_struct *handle,
82                            enum SMB_QUOTA_TYPE qtype, unid_t id,
83                            SMB_DISK_QUOTA *qt);
84 static int smb_full_audit_set_quota(struct vfs_handle_struct *handle,
85                            enum SMB_QUOTA_TYPE qtype, unid_t id,
86                            SMB_DISK_QUOTA *qt);
87 static int smb_full_audit_get_shadow_copy_data(struct vfs_handle_struct *handle,
88                                 struct files_struct *fsp,
89                                 SHADOW_COPY_DATA *shadow_copy_data, bool labels);
90 static int smb_full_audit_statvfs(struct vfs_handle_struct *handle,
91                                 const char *path,
92                                 struct vfs_statvfs_struct *statbuf);
93 static int smb_full_audit_fs_capabilities(struct vfs_handle_struct *handle);
94 static SMB_STRUCT_DIR *smb_full_audit_opendir(vfs_handle_struct *handle,
95                           const char *fname, const char *mask, uint32 attr);
96 static SMB_STRUCT_DIRENT *smb_full_audit_readdir(vfs_handle_struct *handle,
97                                     SMB_STRUCT_DIR *dirp,
98                                     SMB_STRUCT_STAT *sbuf);
99 static void smb_full_audit_seekdir(vfs_handle_struct *handle,
100                         SMB_STRUCT_DIR *dirp, long offset);
101 static long smb_full_audit_telldir(vfs_handle_struct *handle,
102                         SMB_STRUCT_DIR *dirp);
103 static void smb_full_audit_rewinddir(vfs_handle_struct *handle,
104                         SMB_STRUCT_DIR *dirp);
105 static int smb_full_audit_mkdir(vfs_handle_struct *handle,
106                        const char *path, mode_t mode);
107 static int smb_full_audit_rmdir(vfs_handle_struct *handle,
108                        const char *path);
109 static int smb_full_audit_closedir(vfs_handle_struct *handle,
110                           SMB_STRUCT_DIR *dirp);
111 static void smb_full_audit_init_search_op(vfs_handle_struct *handle,
112                         SMB_STRUCT_DIR *dirp);
113 static int smb_full_audit_open(vfs_handle_struct *handle,
114                       const char *fname, files_struct *fsp, int flags, mode_t mode);
115 static NTSTATUS smb_full_audit_create_file(vfs_handle_struct *handle,
116                                       struct smb_request *req,
117                                       uint16_t root_dir_fid,
118                                       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                       const char *fname, SMB_STRUCT_STAT *sbuf);
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                        const char *path, SMB_STRUCT_STAT *sbuf);
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                       const char *fname, files_struct *fsp, int flags, mode_t mode)
1183 {
1184         int result;
1185         
1186         result = SMB_VFS_NEXT_OPEN(handle, fname, fsp, flags, mode);
1187
1188         do_log(SMB_VFS_OP_OPEN, (result >= 0), handle, "%s|%s",
1189                ((flags & O_WRONLY) || (flags & O_RDWR))?"w":"r",
1190                fname);
1191
1192         return result;
1193 }
1194
1195 static NTSTATUS smb_full_audit_create_file(vfs_handle_struct *handle,
1196                                       struct smb_request *req,
1197                                       uint16_t root_dir_fid,
1198                                       struct smb_filename *smb_fname,
1199                                       uint32_t access_mask,
1200                                       uint32_t share_access,
1201                                       uint32_t create_disposition,
1202                                       uint32_t create_options,
1203                                       uint32_t file_attributes,
1204                                       uint32_t oplock_request,
1205                                       uint64_t allocation_size,
1206                                       struct security_descriptor *sd,
1207                                       struct ea_list *ea_list,
1208                                       files_struct **result_fsp,
1209                                       int *pinfo)
1210 {
1211         NTSTATUS result;
1212
1213         result = SMB_VFS_NEXT_CREATE_FILE(
1214                 handle,                                 /* handle */
1215                 req,                                    /* req */
1216                 root_dir_fid,                           /* root_dir_fid */
1217                 smb_fname,                              /* fname */
1218                 access_mask,                            /* access_mask */
1219                 share_access,                           /* share_access */
1220                 create_disposition,                     /* create_disposition*/
1221                 create_options,                         /* create_options */
1222                 file_attributes,                        /* file_attributes */
1223                 oplock_request,                         /* oplock_request */
1224                 allocation_size,                        /* allocation_size */
1225                 sd,                                     /* sd */
1226                 ea_list,                                /* ea_list */
1227                 result_fsp,                             /* result */
1228                 pinfo);                                 /* pinfo */
1229
1230         do_log(SMB_VFS_OP_CREATE_FILE, (NT_STATUS_IS_OK(result)), handle, "0x%x|%s",
1231                access_mask, smb_fname_str_dbg(smb_fname));
1232
1233         return result;
1234 }
1235
1236 static int smb_full_audit_close(vfs_handle_struct *handle, files_struct *fsp)
1237 {
1238         int result;
1239         
1240         result = SMB_VFS_NEXT_CLOSE(handle, fsp);
1241
1242         do_log(SMB_VFS_OP_CLOSE, (result >= 0), handle, "%s", fsp->fsp_name);
1243
1244         return result;
1245 }
1246
1247 static ssize_t smb_full_audit_read(vfs_handle_struct *handle, files_struct *fsp,
1248                           void *data, size_t n)
1249 {
1250         ssize_t result;
1251
1252         result = SMB_VFS_NEXT_READ(handle, fsp, data, n);
1253
1254         do_log(SMB_VFS_OP_READ, (result >= 0), handle, "%s", fsp->fsp_name);
1255
1256         return result;
1257 }
1258
1259 static ssize_t smb_full_audit_pread(vfs_handle_struct *handle, files_struct *fsp,
1260                            void *data, size_t n, SMB_OFF_T offset)
1261 {
1262         ssize_t result;
1263
1264         result = SMB_VFS_NEXT_PREAD(handle, fsp, data, n, offset);
1265
1266         do_log(SMB_VFS_OP_PREAD, (result >= 0), handle, "%s", fsp->fsp_name);
1267
1268         return result;
1269 }
1270
1271 static ssize_t smb_full_audit_write(vfs_handle_struct *handle, files_struct *fsp,
1272                            const void *data, size_t n)
1273 {
1274         ssize_t result;
1275
1276         result = SMB_VFS_NEXT_WRITE(handle, fsp, data, n);
1277
1278         do_log(SMB_VFS_OP_WRITE, (result >= 0), handle, "%s", fsp->fsp_name);
1279
1280         return result;
1281 }
1282
1283 static ssize_t smb_full_audit_pwrite(vfs_handle_struct *handle, files_struct *fsp,
1284                             const void *data, size_t n,
1285                             SMB_OFF_T offset)
1286 {
1287         ssize_t result;
1288
1289         result = SMB_VFS_NEXT_PWRITE(handle, fsp, data, n, offset);
1290
1291         do_log(SMB_VFS_OP_PWRITE, (result >= 0), handle, "%s", fsp->fsp_name);
1292
1293         return result;
1294 }
1295
1296 static SMB_OFF_T smb_full_audit_lseek(vfs_handle_struct *handle, files_struct *fsp,
1297                              SMB_OFF_T offset, int whence)
1298 {
1299         ssize_t result;
1300
1301         result = SMB_VFS_NEXT_LSEEK(handle, fsp, offset, whence);
1302
1303         do_log(SMB_VFS_OP_LSEEK, (result != (ssize_t)-1), handle,
1304                "%s", fsp->fsp_name);
1305
1306         return result;
1307 }
1308
1309 static ssize_t smb_full_audit_sendfile(vfs_handle_struct *handle, int tofd,
1310                               files_struct *fromfsp,
1311                               const DATA_BLOB *hdr, SMB_OFF_T offset,
1312                               size_t n)
1313 {
1314         ssize_t result;
1315
1316         result = SMB_VFS_NEXT_SENDFILE(handle, tofd, fromfsp, hdr, offset, n);
1317
1318         do_log(SMB_VFS_OP_SENDFILE, (result >= 0), handle,
1319                "%s", fromfsp->fsp_name);
1320
1321         return result;
1322 }
1323
1324 static ssize_t smb_full_audit_recvfile(vfs_handle_struct *handle, int fromfd,
1325                       files_struct *tofsp,
1326                               SMB_OFF_T offset,
1327                               size_t n)
1328 {
1329         ssize_t result;
1330
1331         result = SMB_VFS_NEXT_RECVFILE(handle, fromfd, tofsp, offset, n);
1332
1333         do_log(SMB_VFS_OP_RECVFILE, (result >= 0), handle,
1334                "%s", tofsp->fsp_name);
1335
1336         return result;
1337 }
1338
1339 static int smb_full_audit_rename(vfs_handle_struct *handle,
1340                         const char *oldname, const char *newname)
1341 {
1342         int result;
1343         
1344         result = SMB_VFS_NEXT_RENAME(handle, oldname, newname);
1345
1346         do_log(SMB_VFS_OP_RENAME, (result >= 0), handle, "%s|%s", oldname, newname);
1347
1348         return result;    
1349 }
1350
1351 static int smb_full_audit_fsync(vfs_handle_struct *handle, files_struct *fsp)
1352 {
1353         int result;
1354         
1355         result = SMB_VFS_NEXT_FSYNC(handle, fsp);
1356
1357         do_log(SMB_VFS_OP_FSYNC, (result >= 0), handle, "%s", fsp->fsp_name);
1358
1359         return result;    
1360 }
1361
1362 static int smb_full_audit_stat(vfs_handle_struct *handle,
1363                       const char *fname, SMB_STRUCT_STAT *sbuf)
1364 {
1365         int result;
1366         
1367         result = SMB_VFS_NEXT_STAT(handle, fname, sbuf);
1368
1369         do_log(SMB_VFS_OP_STAT, (result >= 0), handle, "%s", fname);
1370
1371         return result;    
1372 }
1373
1374 static int smb_full_audit_fstat(vfs_handle_struct *handle, files_struct *fsp,
1375                        SMB_STRUCT_STAT *sbuf)
1376 {
1377         int result;
1378         
1379         result = SMB_VFS_NEXT_FSTAT(handle, fsp, sbuf);
1380
1381         do_log(SMB_VFS_OP_FSTAT, (result >= 0), handle, "%s", fsp->fsp_name);
1382
1383         return result;
1384 }
1385
1386 static int smb_full_audit_lstat(vfs_handle_struct *handle,
1387                        const char *path, SMB_STRUCT_STAT *sbuf)
1388 {
1389         int result;
1390         
1391         result = SMB_VFS_NEXT_LSTAT(handle, path, sbuf);
1392
1393         do_log(SMB_VFS_OP_LSTAT, (result >= 0), handle, "%s", path);
1394
1395         return result;    
1396 }
1397
1398 static int smb_full_audit_get_alloc_size(vfs_handle_struct *handle,
1399                        files_struct *fsp, const SMB_STRUCT_STAT *sbuf)
1400 {
1401         int result;
1402
1403         result = SMB_VFS_NEXT_GET_ALLOC_SIZE(handle, fsp, sbuf);
1404
1405         do_log(SMB_VFS_OP_GET_ALLOC_SIZE, (result >= 0), handle, "%d", result);
1406
1407         return result;
1408 }
1409
1410 static int smb_full_audit_unlink(vfs_handle_struct *handle,
1411                         const char *path)
1412 {
1413         int result;
1414         
1415         result = SMB_VFS_NEXT_UNLINK(handle, path);
1416
1417         do_log(SMB_VFS_OP_UNLINK, (result >= 0), handle, "%s", path);
1418
1419         return result;
1420 }
1421
1422 static int smb_full_audit_chmod(vfs_handle_struct *handle,
1423                        const char *path, mode_t mode)
1424 {
1425         int result;
1426
1427         result = SMB_VFS_NEXT_CHMOD(handle, path, mode);
1428
1429         do_log(SMB_VFS_OP_CHMOD, (result >= 0), handle, "%s|%o", path, mode);
1430
1431         return result;
1432 }
1433
1434 static int smb_full_audit_fchmod(vfs_handle_struct *handle, files_struct *fsp,
1435                         mode_t mode)
1436 {
1437         int result;
1438         
1439         result = SMB_VFS_NEXT_FCHMOD(handle, fsp, mode);
1440
1441         do_log(SMB_VFS_OP_FCHMOD, (result >= 0), handle,
1442                "%s|%o", fsp->fsp_name, mode);
1443
1444         return result;
1445 }
1446
1447 static int smb_full_audit_chown(vfs_handle_struct *handle,
1448                        const char *path, uid_t uid, gid_t gid)
1449 {
1450         int result;
1451
1452         result = SMB_VFS_NEXT_CHOWN(handle, path, uid, gid);
1453
1454         do_log(SMB_VFS_OP_CHOWN, (result >= 0), handle, "%s|%ld|%ld",
1455                path, (long int)uid, (long int)gid);
1456
1457         return result;
1458 }
1459
1460 static int smb_full_audit_fchown(vfs_handle_struct *handle, files_struct *fsp,
1461                         uid_t uid, gid_t gid)
1462 {
1463         int result;
1464
1465         result = SMB_VFS_NEXT_FCHOWN(handle, fsp, uid, gid);
1466
1467         do_log(SMB_VFS_OP_FCHOWN, (result >= 0), handle, "%s|%ld|%ld",
1468                fsp->fsp_name, (long int)uid, (long int)gid);
1469
1470         return result;
1471 }
1472
1473 static int smb_full_audit_lchown(vfs_handle_struct *handle,
1474                        const char *path, uid_t uid, gid_t gid)
1475 {
1476         int result;
1477
1478         result = SMB_VFS_NEXT_LCHOWN(handle, path, uid, gid);
1479
1480         do_log(SMB_VFS_OP_LCHOWN, (result >= 0), handle, "%s|%ld|%ld",
1481                path, (long int)uid, (long int)gid);
1482
1483         return result;
1484 }
1485
1486 static int smb_full_audit_chdir(vfs_handle_struct *handle,
1487                        const char *path)
1488 {
1489         int result;
1490
1491         result = SMB_VFS_NEXT_CHDIR(handle, path);
1492
1493         do_log(SMB_VFS_OP_CHDIR, (result >= 0), handle, "chdir|%s", path);
1494
1495         return result;
1496 }
1497
1498 static char *smb_full_audit_getwd(vfs_handle_struct *handle,
1499                          char *path)
1500 {
1501         char *result;
1502
1503         result = SMB_VFS_NEXT_GETWD(handle, path);
1504         
1505         do_log(SMB_VFS_OP_GETWD, (result != NULL), handle, "%s", path);
1506
1507         return result;
1508 }
1509
1510 static int smb_full_audit_ntimes(vfs_handle_struct *handle,
1511                        const char *path, struct smb_file_time *ft)
1512 {
1513         int result;
1514
1515         result = SMB_VFS_NEXT_NTIMES(handle, path, ft);
1516
1517         do_log(SMB_VFS_OP_NTIMES, (result >= 0), handle, "%s", path);
1518
1519         return result;
1520 }
1521
1522 static int smb_full_audit_ftruncate(vfs_handle_struct *handle, files_struct *fsp,
1523                            SMB_OFF_T len)
1524 {
1525         int result;
1526
1527         result = SMB_VFS_NEXT_FTRUNCATE(handle, fsp, len);
1528
1529         do_log(SMB_VFS_OP_FTRUNCATE, (result >= 0), handle,
1530                "%s", fsp->fsp_name);
1531
1532         return result;
1533 }
1534
1535 static bool smb_full_audit_lock(vfs_handle_struct *handle, files_struct *fsp,
1536                        int op, SMB_OFF_T offset, SMB_OFF_T count, int type)
1537 {
1538         bool result;
1539
1540         result = SMB_VFS_NEXT_LOCK(handle, fsp, op, offset, count, type);
1541
1542         do_log(SMB_VFS_OP_LOCK, result, handle, "%s", fsp->fsp_name);
1543
1544         return result;
1545 }
1546
1547 static int smb_full_audit_kernel_flock(struct vfs_handle_struct *handle,
1548                                        struct files_struct *fsp,
1549                                        uint32 share_mode)
1550 {
1551         int result;
1552
1553         result = SMB_VFS_NEXT_KERNEL_FLOCK(handle, fsp, share_mode);
1554
1555         do_log(SMB_VFS_OP_KERNEL_FLOCK, (result >= 0), handle, "%s",
1556                fsp->fsp_name);
1557
1558         return result;
1559 }
1560
1561 static int smb_full_audit_linux_setlease(vfs_handle_struct *handle, files_struct *fsp,
1562                                  int leasetype)
1563 {
1564         int result;
1565
1566         result = SMB_VFS_NEXT_LINUX_SETLEASE(handle, fsp, leasetype);
1567
1568         do_log(SMB_VFS_OP_LINUX_SETLEASE, (result >= 0), handle, "%s",
1569                fsp->fsp_name);
1570
1571         return result;
1572 }
1573
1574 static bool smb_full_audit_getlock(vfs_handle_struct *handle, files_struct *fsp,
1575                        SMB_OFF_T *poffset, SMB_OFF_T *pcount, int *ptype, pid_t *ppid)
1576 {
1577         bool result;
1578
1579         result = SMB_VFS_NEXT_GETLOCK(handle, fsp, poffset, pcount, ptype, ppid);
1580
1581         do_log(SMB_VFS_OP_GETLOCK, result, handle, "%s", fsp->fsp_name);
1582
1583         return result;
1584 }
1585
1586 static int smb_full_audit_symlink(vfs_handle_struct *handle,
1587                          const char *oldpath, const char *newpath)
1588 {
1589         int result;
1590
1591         result = SMB_VFS_NEXT_SYMLINK(handle, oldpath, newpath);
1592
1593         do_log(SMB_VFS_OP_SYMLINK, (result >= 0), handle,
1594                "%s|%s", oldpath, newpath);
1595
1596         return result;
1597 }
1598
1599 static int smb_full_audit_readlink(vfs_handle_struct *handle,
1600                           const char *path, char *buf, size_t bufsiz)
1601 {
1602         int result;
1603
1604         result = SMB_VFS_NEXT_READLINK(handle, path, buf, bufsiz);
1605
1606         do_log(SMB_VFS_OP_READLINK, (result >= 0), handle, "%s", path);
1607
1608         return result;
1609 }
1610
1611 static int smb_full_audit_link(vfs_handle_struct *handle,
1612                       const char *oldpath, const char *newpath)
1613 {
1614         int result;
1615
1616         result = SMB_VFS_NEXT_LINK(handle, oldpath, newpath);
1617
1618         do_log(SMB_VFS_OP_LINK, (result >= 0), handle,
1619                "%s|%s", oldpath, newpath);
1620
1621         return result;
1622 }
1623
1624 static int smb_full_audit_mknod(vfs_handle_struct *handle,
1625                        const char *pathname, mode_t mode, SMB_DEV_T dev)
1626 {
1627         int result;
1628
1629         result = SMB_VFS_NEXT_MKNOD(handle, pathname, mode, dev);
1630
1631         do_log(SMB_VFS_OP_MKNOD, (result >= 0), handle, "%s", pathname);
1632
1633         return result;
1634 }
1635
1636 static char *smb_full_audit_realpath(vfs_handle_struct *handle,
1637                             const char *path, char *resolved_path)
1638 {
1639         char *result;
1640
1641         result = SMB_VFS_NEXT_REALPATH(handle, path, resolved_path);
1642
1643         do_log(SMB_VFS_OP_REALPATH, (result != NULL), handle, "%s", path);
1644
1645         return result;
1646 }
1647
1648 static NTSTATUS smb_full_audit_notify_watch(struct vfs_handle_struct *handle,
1649                         struct sys_notify_context *ctx,
1650                         struct notify_entry *e,
1651                         void (*callback)(struct sys_notify_context *ctx,
1652                                         void *private_data,
1653                                         struct notify_event *ev),
1654                         void *private_data, void *handle_p)
1655 {
1656         NTSTATUS result;
1657
1658         result = SMB_VFS_NEXT_NOTIFY_WATCH(handle, ctx, e, callback, private_data, handle_p);
1659
1660         do_log(SMB_VFS_OP_NOTIFY_WATCH, NT_STATUS_IS_OK(result), handle, "");
1661
1662         return result;
1663 }
1664
1665 static int smb_full_audit_chflags(vfs_handle_struct *handle,
1666                             const char *path, unsigned int flags)
1667 {
1668         int result;
1669
1670         result = SMB_VFS_NEXT_CHFLAGS(handle, path, flags);
1671
1672         do_log(SMB_VFS_OP_CHFLAGS, (result != 0), handle, "%s", path);
1673
1674         return result;
1675 }
1676
1677 static struct file_id smb_full_audit_file_id_create(struct vfs_handle_struct *handle,
1678                                                     const SMB_STRUCT_STAT *sbuf)
1679 {
1680         struct file_id id_zero;
1681         struct file_id result;
1682
1683         ZERO_STRUCT(id_zero);
1684
1685         result = SMB_VFS_NEXT_FILE_ID_CREATE(handle, sbuf);
1686
1687         do_log(SMB_VFS_OP_FILE_ID_CREATE,
1688                !file_id_equal(&id_zero, &result),
1689                handle, "%s", file_id_string_tos(&result));
1690
1691         return result;
1692 }
1693
1694 static NTSTATUS smb_full_audit_streaminfo(vfs_handle_struct *handle,
1695                                           struct files_struct *fsp,
1696                                           const char *fname,
1697                                           TALLOC_CTX *mem_ctx,
1698                                           unsigned int *pnum_streams,
1699                                           struct stream_struct **pstreams)
1700 {
1701         NTSTATUS result;
1702
1703         result = SMB_VFS_NEXT_STREAMINFO(handle, fsp, fname, mem_ctx,
1704                                          pnum_streams, pstreams);
1705
1706         do_log(SMB_VFS_OP_STREAMINFO, NT_STATUS_IS_OK(result), handle,
1707                "%s", fname);
1708
1709         return result;
1710 }
1711
1712 static int smb_full_audit_get_real_filename(struct vfs_handle_struct *handle,
1713                                             const char *path,
1714                                             const char *name,
1715                                             TALLOC_CTX *mem_ctx,
1716                                             char **found_name)
1717 {
1718         int result;
1719
1720         result = SMB_VFS_NEXT_GET_REAL_FILENAME(handle, path, name, mem_ctx,
1721                                                 found_name);
1722
1723         do_log(SMB_VFS_OP_GET_REAL_FILENAME, (result == 0), handle,
1724                "%s/%s->%s", path, name, (result == 0) ? "" : *found_name);
1725
1726         return result;
1727 }
1728
1729 static const char *smb_full_audit_connectpath(vfs_handle_struct *handle,
1730                                               const char *fname)
1731 {
1732         const char *result;
1733
1734         result = SMB_VFS_NEXT_CONNECTPATH(handle, fname);
1735
1736         do_log(SMB_VFS_OP_CONNECTPATH, result != NULL, handle,
1737                "%s", fname);
1738
1739         return result;
1740 }
1741
1742 static NTSTATUS smb_full_audit_brl_lock_windows(struct vfs_handle_struct *handle,
1743                                                 struct byte_range_lock *br_lck,
1744                                                 struct lock_struct *plock,
1745                                                 bool blocking_lock,
1746                                                 struct blocking_lock_record *blr)
1747 {
1748         NTSTATUS result;
1749
1750         result = SMB_VFS_NEXT_BRL_LOCK_WINDOWS(handle, br_lck, plock,
1751             blocking_lock, blr);
1752
1753         do_log(SMB_VFS_OP_BRL_LOCK_WINDOWS, NT_STATUS_IS_OK(result), handle,
1754             "%s:%llu-%llu. type=%d. blocking=%d", br_lck->fsp->fsp_name,
1755             plock->start, plock->size, plock->lock_type, blocking_lock );
1756
1757         return result;
1758 }
1759
1760 static bool smb_full_audit_brl_unlock_windows(struct vfs_handle_struct *handle,
1761                                               struct messaging_context *msg_ctx,
1762                                               struct byte_range_lock *br_lck,
1763                                               const struct lock_struct *plock)
1764 {
1765         bool result;
1766
1767         result = SMB_VFS_NEXT_BRL_UNLOCK_WINDOWS(handle, msg_ctx, br_lck,
1768             plock);
1769
1770         do_log(SMB_VFS_OP_BRL_UNLOCK_WINDOWS, (result == 0), handle,
1771             "%s:%llu-%llu:%d", br_lck->fsp->fsp_name, plock->start,
1772             plock->size, plock->lock_type);
1773
1774         return result;
1775 }
1776
1777 static bool smb_full_audit_brl_cancel_windows(struct vfs_handle_struct *handle,
1778                                               struct byte_range_lock *br_lck,
1779                                               struct lock_struct *plock,
1780                                               struct blocking_lock_record *blr)
1781 {
1782         bool result;
1783
1784         result = SMB_VFS_NEXT_BRL_CANCEL_WINDOWS(handle, br_lck, plock, blr);
1785
1786         do_log(SMB_VFS_OP_BRL_CANCEL_WINDOWS, (result == 0), handle,
1787             "%s:%llu-%llu:%d", br_lck->fsp->fsp_name, plock->start,
1788             plock->size);
1789
1790         return result;
1791 }
1792
1793 static bool smb_full_audit_strict_lock(struct vfs_handle_struct *handle,
1794                                        struct files_struct *fsp,
1795                                        struct lock_struct *plock)
1796 {
1797         bool result;
1798
1799         result = SMB_VFS_NEXT_STRICT_LOCK(handle, fsp, plock);
1800
1801         do_log(SMB_VFS_OP_STRICT_LOCK, result, handle,
1802             "%s:%llu-%llu:%d", fsp->fsp_name, plock->start,
1803             plock->size);
1804
1805         return result;
1806 }
1807
1808 static void smb_full_audit_strict_unlock(struct vfs_handle_struct *handle,
1809                                          struct files_struct *fsp,
1810                                          struct lock_struct *plock)
1811 {
1812         SMB_VFS_NEXT_STRICT_UNLOCK(handle, fsp, plock);
1813
1814         do_log(SMB_VFS_OP_STRICT_UNLOCK, true, handle,
1815             "%s:%llu-%llu:%d", fsp->fsp_name, plock->start,
1816             plock->size);
1817
1818         return;
1819 }
1820
1821 static NTSTATUS smb_full_audit_fget_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
1822                                 uint32 security_info,
1823                                 SEC_DESC **ppdesc)
1824 {
1825         NTSTATUS result;
1826
1827         result = SMB_VFS_NEXT_FGET_NT_ACL(handle, fsp, security_info, ppdesc);
1828
1829         do_log(SMB_VFS_OP_FGET_NT_ACL, NT_STATUS_IS_OK(result), handle,
1830                "%s", fsp->fsp_name);
1831
1832         return result;
1833 }
1834
1835 static NTSTATUS smb_full_audit_get_nt_acl(vfs_handle_struct *handle,
1836                                           const char *name,
1837                                           uint32 security_info,
1838                                           SEC_DESC **ppdesc)
1839 {
1840         NTSTATUS result;
1841
1842         result = SMB_VFS_NEXT_GET_NT_ACL(handle, name, security_info, ppdesc);
1843
1844         do_log(SMB_VFS_OP_GET_NT_ACL, NT_STATUS_IS_OK(result), handle,
1845                "%s", name);
1846
1847         return result;
1848 }
1849
1850 static NTSTATUS smb_full_audit_fset_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
1851                               uint32 security_info_sent,
1852                               const SEC_DESC *psd)
1853 {
1854         NTSTATUS result;
1855
1856         result = SMB_VFS_NEXT_FSET_NT_ACL(handle, fsp, security_info_sent, psd);
1857
1858         do_log(SMB_VFS_OP_FSET_NT_ACL, NT_STATUS_IS_OK(result), handle, "%s", fsp->fsp_name);
1859
1860         return result;
1861 }
1862
1863 static int smb_full_audit_chmod_acl(vfs_handle_struct *handle,
1864                            const char *path, mode_t mode)
1865 {
1866         int result;
1867         
1868         result = SMB_VFS_NEXT_CHMOD_ACL(handle, path, mode);
1869
1870         do_log(SMB_VFS_OP_CHMOD_ACL, (result >= 0), handle,
1871                "%s|%o", path, mode);
1872
1873         return result;
1874 }
1875
1876 static int smb_full_audit_fchmod_acl(vfs_handle_struct *handle, files_struct *fsp,
1877                                      mode_t mode)
1878 {
1879         int result;
1880         
1881         result = SMB_VFS_NEXT_FCHMOD_ACL(handle, fsp, mode);
1882
1883         do_log(SMB_VFS_OP_FCHMOD_ACL, (result >= 0), handle,
1884                "%s|%o", fsp->fsp_name, mode);
1885
1886         return result;
1887 }
1888
1889 static int smb_full_audit_sys_acl_get_entry(vfs_handle_struct *handle,
1890
1891                                    SMB_ACL_T theacl, int entry_id,
1892                                    SMB_ACL_ENTRY_T *entry_p)
1893 {
1894         int result;
1895
1896         result = SMB_VFS_NEXT_SYS_ACL_GET_ENTRY(handle, theacl, entry_id,
1897                                                 entry_p);
1898
1899         do_log(SMB_VFS_OP_SYS_ACL_GET_ENTRY, (result >= 0), handle,
1900                "");
1901
1902         return result;
1903 }
1904
1905 static int smb_full_audit_sys_acl_get_tag_type(vfs_handle_struct *handle,
1906
1907                                       SMB_ACL_ENTRY_T entry_d,
1908                                       SMB_ACL_TAG_T *tag_type_p)
1909 {
1910         int result;
1911
1912         result = SMB_VFS_NEXT_SYS_ACL_GET_TAG_TYPE(handle, entry_d,
1913                                                    tag_type_p);
1914
1915         do_log(SMB_VFS_OP_SYS_ACL_GET_TAG_TYPE, (result >= 0), handle,
1916                "");
1917
1918         return result;
1919 }
1920
1921 static int smb_full_audit_sys_acl_get_permset(vfs_handle_struct *handle,
1922
1923                                      SMB_ACL_ENTRY_T entry_d,
1924                                      SMB_ACL_PERMSET_T *permset_p)
1925 {
1926         int result;
1927
1928         result = SMB_VFS_NEXT_SYS_ACL_GET_PERMSET(handle, entry_d,
1929                                                   permset_p);
1930
1931         do_log(SMB_VFS_OP_SYS_ACL_GET_PERMSET, (result >= 0), handle,
1932                "");
1933
1934         return result;
1935 }
1936
1937 static void * smb_full_audit_sys_acl_get_qualifier(vfs_handle_struct *handle,
1938
1939                                           SMB_ACL_ENTRY_T entry_d)
1940 {
1941         void *result;
1942
1943         result = SMB_VFS_NEXT_SYS_ACL_GET_QUALIFIER(handle, entry_d);
1944
1945         do_log(SMB_VFS_OP_SYS_ACL_GET_QUALIFIER, (result != NULL), handle,
1946                "");
1947
1948         return result;
1949 }
1950
1951 static SMB_ACL_T smb_full_audit_sys_acl_get_file(vfs_handle_struct *handle,
1952                                         const char *path_p,
1953                                         SMB_ACL_TYPE_T type)
1954 {
1955         SMB_ACL_T result;
1956
1957         result = SMB_VFS_NEXT_SYS_ACL_GET_FILE(handle, path_p, type);
1958
1959         do_log(SMB_VFS_OP_SYS_ACL_GET_FILE, (result != NULL), handle,
1960                "%s", path_p);
1961
1962         return result;
1963 }
1964
1965 static SMB_ACL_T smb_full_audit_sys_acl_get_fd(vfs_handle_struct *handle,
1966                                       files_struct *fsp)
1967 {
1968         SMB_ACL_T result;
1969
1970         result = SMB_VFS_NEXT_SYS_ACL_GET_FD(handle, fsp);
1971
1972         do_log(SMB_VFS_OP_SYS_ACL_GET_FD, (result != NULL), handle,
1973                "%s", fsp->fsp_name);
1974
1975         return result;
1976 }
1977
1978 static int smb_full_audit_sys_acl_clear_perms(vfs_handle_struct *handle,
1979
1980                                      SMB_ACL_PERMSET_T permset)
1981 {
1982         int result;
1983
1984         result = SMB_VFS_NEXT_SYS_ACL_CLEAR_PERMS(handle, permset);
1985
1986         do_log(SMB_VFS_OP_SYS_ACL_CLEAR_PERMS, (result >= 0), handle,
1987                "");
1988
1989         return result;
1990 }
1991
1992 static int smb_full_audit_sys_acl_add_perm(vfs_handle_struct *handle,
1993
1994                                   SMB_ACL_PERMSET_T permset,
1995                                   SMB_ACL_PERM_T perm)
1996 {
1997         int result;
1998
1999         result = SMB_VFS_NEXT_SYS_ACL_ADD_PERM(handle, permset, perm);
2000
2001         do_log(SMB_VFS_OP_SYS_ACL_ADD_PERM, (result >= 0), handle,
2002                "");
2003
2004         return result;
2005 }
2006
2007 static char * smb_full_audit_sys_acl_to_text(vfs_handle_struct *handle,
2008                                     SMB_ACL_T theacl,
2009                                     ssize_t *plen)
2010 {
2011         char * result;
2012
2013         result = SMB_VFS_NEXT_SYS_ACL_TO_TEXT(handle, theacl, plen);
2014
2015         do_log(SMB_VFS_OP_SYS_ACL_TO_TEXT, (result != NULL), handle,
2016                "");
2017
2018         return result;
2019 }
2020
2021 static SMB_ACL_T smb_full_audit_sys_acl_init(vfs_handle_struct *handle,
2022
2023                                     int count)
2024 {
2025         SMB_ACL_T result;
2026
2027         result = SMB_VFS_NEXT_SYS_ACL_INIT(handle, count);
2028
2029         do_log(SMB_VFS_OP_SYS_ACL_INIT, (result != NULL), handle,
2030                "");
2031
2032         return result;
2033 }
2034
2035 static int smb_full_audit_sys_acl_create_entry(vfs_handle_struct *handle,
2036                                       SMB_ACL_T *pacl,
2037                                       SMB_ACL_ENTRY_T *pentry)
2038 {
2039         int result;
2040
2041         result = SMB_VFS_NEXT_SYS_ACL_CREATE_ENTRY(handle, pacl, pentry);
2042
2043         do_log(SMB_VFS_OP_SYS_ACL_CREATE_ENTRY, (result >= 0), handle,
2044                "");
2045
2046         return result;
2047 }
2048
2049 static int smb_full_audit_sys_acl_set_tag_type(vfs_handle_struct *handle,
2050
2051                                       SMB_ACL_ENTRY_T entry,
2052                                       SMB_ACL_TAG_T tagtype)
2053 {
2054         int result;
2055
2056         result = SMB_VFS_NEXT_SYS_ACL_SET_TAG_TYPE(handle, entry,
2057                                                    tagtype);
2058
2059         do_log(SMB_VFS_OP_SYS_ACL_SET_TAG_TYPE, (result >= 0), handle,
2060                "");
2061
2062         return result;
2063 }
2064
2065 static int smb_full_audit_sys_acl_set_qualifier(vfs_handle_struct *handle,
2066
2067                                        SMB_ACL_ENTRY_T entry,
2068                                        void *qual)
2069 {
2070         int result;
2071
2072         result = SMB_VFS_NEXT_SYS_ACL_SET_QUALIFIER(handle, entry, qual);
2073
2074         do_log(SMB_VFS_OP_SYS_ACL_SET_QUALIFIER, (result >= 0), handle,
2075                "");
2076
2077         return result;
2078 }
2079
2080 static int smb_full_audit_sys_acl_set_permset(vfs_handle_struct *handle,
2081
2082                                      SMB_ACL_ENTRY_T entry,
2083                                      SMB_ACL_PERMSET_T permset)
2084 {
2085         int result;
2086
2087         result = SMB_VFS_NEXT_SYS_ACL_SET_PERMSET(handle, entry, permset);
2088
2089         do_log(SMB_VFS_OP_SYS_ACL_SET_PERMSET, (result >= 0), handle,
2090                "");
2091
2092         return result;
2093 }
2094
2095 static int smb_full_audit_sys_acl_valid(vfs_handle_struct *handle,
2096
2097                                SMB_ACL_T theacl )
2098 {
2099         int result;
2100
2101         result = SMB_VFS_NEXT_SYS_ACL_VALID(handle, theacl);
2102
2103         do_log(SMB_VFS_OP_SYS_ACL_VALID, (result >= 0), handle,
2104                "");
2105
2106         return result;
2107 }
2108
2109 static int smb_full_audit_sys_acl_set_file(vfs_handle_struct *handle,
2110
2111                                   const char *name, SMB_ACL_TYPE_T acltype,
2112                                   SMB_ACL_T theacl)
2113 {
2114         int result;
2115
2116         result = SMB_VFS_NEXT_SYS_ACL_SET_FILE(handle, name, acltype,
2117                                                theacl);
2118
2119         do_log(SMB_VFS_OP_SYS_ACL_SET_FILE, (result >= 0), handle,
2120                "%s", name);
2121
2122         return result;
2123 }
2124
2125 static int smb_full_audit_sys_acl_set_fd(vfs_handle_struct *handle, files_struct *fsp,
2126                                 SMB_ACL_T theacl)
2127 {
2128         int result;
2129
2130         result = SMB_VFS_NEXT_SYS_ACL_SET_FD(handle, fsp, theacl);
2131
2132         do_log(SMB_VFS_OP_SYS_ACL_SET_FD, (result >= 0), handle,
2133                "%s", fsp->fsp_name);
2134
2135         return result;
2136 }
2137
2138 static int smb_full_audit_sys_acl_delete_def_file(vfs_handle_struct *handle,
2139
2140                                          const char *path)
2141 {
2142         int result;
2143
2144         result = SMB_VFS_NEXT_SYS_ACL_DELETE_DEF_FILE(handle, path);
2145
2146         do_log(SMB_VFS_OP_SYS_ACL_DELETE_DEF_FILE, (result >= 0), handle,
2147                "%s", path);
2148
2149         return result;
2150 }
2151
2152 static int smb_full_audit_sys_acl_get_perm(vfs_handle_struct *handle,
2153
2154                                   SMB_ACL_PERMSET_T permset,
2155                                   SMB_ACL_PERM_T perm)
2156 {
2157         int result;
2158
2159         result = SMB_VFS_NEXT_SYS_ACL_GET_PERM(handle, permset, perm);
2160
2161         do_log(SMB_VFS_OP_SYS_ACL_GET_PERM, (result >= 0), handle,
2162                "");
2163
2164         return result;
2165 }
2166
2167 static int smb_full_audit_sys_acl_free_text(vfs_handle_struct *handle,
2168
2169                                    char *text)
2170 {
2171         int result;
2172
2173         result = SMB_VFS_NEXT_SYS_ACL_FREE_TEXT(handle, text);
2174
2175         do_log(SMB_VFS_OP_SYS_ACL_FREE_TEXT, (result >= 0), handle,
2176                "");
2177
2178         return result;
2179 }
2180
2181 static int smb_full_audit_sys_acl_free_acl(vfs_handle_struct *handle,
2182
2183                                   SMB_ACL_T posix_acl)
2184 {
2185         int result;
2186
2187         result = SMB_VFS_NEXT_SYS_ACL_FREE_ACL(handle, posix_acl);
2188
2189         do_log(SMB_VFS_OP_SYS_ACL_FREE_ACL, (result >= 0), handle,
2190                "");
2191
2192         return result;
2193 }
2194
2195 static int smb_full_audit_sys_acl_free_qualifier(vfs_handle_struct *handle,
2196                                         void *qualifier,
2197                                         SMB_ACL_TAG_T tagtype)
2198 {
2199         int result;
2200
2201         result = SMB_VFS_NEXT_SYS_ACL_FREE_QUALIFIER(handle, qualifier,
2202                                                      tagtype);
2203
2204         do_log(SMB_VFS_OP_SYS_ACL_FREE_QUALIFIER, (result >= 0), handle,
2205                "");
2206
2207         return result;
2208 }
2209
2210 static ssize_t smb_full_audit_getxattr(struct vfs_handle_struct *handle,
2211                               const char *path,
2212                               const char *name, void *value, size_t size)
2213 {
2214         ssize_t result;
2215
2216         result = SMB_VFS_NEXT_GETXATTR(handle, path, name, value, size);
2217
2218         do_log(SMB_VFS_OP_GETXATTR, (result >= 0), handle,
2219                "%s|%s", path, name);
2220
2221         return result;
2222 }
2223
2224 static ssize_t smb_full_audit_lgetxattr(struct vfs_handle_struct *handle,
2225                                const char *path, const char *name,
2226                                void *value, size_t size)
2227 {
2228         ssize_t result;
2229
2230         result = SMB_VFS_NEXT_LGETXATTR(handle, path, name, value, size);
2231
2232         do_log(SMB_VFS_OP_LGETXATTR, (result >= 0), handle,
2233                "%s|%s", path, name);
2234
2235         return result;
2236 }
2237
2238 static ssize_t smb_full_audit_fgetxattr(struct vfs_handle_struct *handle,
2239                                struct files_struct *fsp,
2240                                const char *name, void *value, size_t size)
2241 {
2242         ssize_t result;
2243
2244         result = SMB_VFS_NEXT_FGETXATTR(handle, fsp, name, value, size);
2245
2246         do_log(SMB_VFS_OP_FGETXATTR, (result >= 0), handle,
2247                "%s|%s", fsp->fsp_name, name);
2248
2249         return result;
2250 }
2251
2252 static ssize_t smb_full_audit_listxattr(struct vfs_handle_struct *handle,
2253                                const char *path, char *list, size_t size)
2254 {
2255         ssize_t result;
2256
2257         result = SMB_VFS_NEXT_LISTXATTR(handle, path, list, size);
2258
2259         do_log(SMB_VFS_OP_LISTXATTR, (result >= 0), handle, "%s", path);
2260
2261         return result;
2262 }
2263
2264 static ssize_t smb_full_audit_llistxattr(struct vfs_handle_struct *handle,
2265                                 const char *path, char *list, size_t size)
2266 {
2267         ssize_t result;
2268
2269         result = SMB_VFS_NEXT_LLISTXATTR(handle, path, list, size);
2270
2271         do_log(SMB_VFS_OP_LLISTXATTR, (result >= 0), handle, "%s", path);
2272
2273         return result;
2274 }
2275
2276 static ssize_t smb_full_audit_flistxattr(struct vfs_handle_struct *handle,
2277                                 struct files_struct *fsp, char *list,
2278                                 size_t size)
2279 {
2280         ssize_t result;
2281
2282         result = SMB_VFS_NEXT_FLISTXATTR(handle, fsp, list, size);
2283
2284         do_log(SMB_VFS_OP_FLISTXATTR, (result >= 0), handle,
2285                "%s", fsp->fsp_name);
2286
2287         return result;
2288 }
2289
2290 static int smb_full_audit_removexattr(struct vfs_handle_struct *handle,
2291                              const char *path,
2292                              const char *name)
2293 {
2294         int result;
2295
2296         result = SMB_VFS_NEXT_REMOVEXATTR(handle, path, name);
2297
2298         do_log(SMB_VFS_OP_REMOVEXATTR, (result >= 0), handle,
2299                "%s|%s", path, name);
2300
2301         return result;
2302 }
2303
2304 static int smb_full_audit_lremovexattr(struct vfs_handle_struct *handle,
2305                               const char *path,
2306                               const char *name)
2307 {
2308         int result;
2309
2310         result = SMB_VFS_NEXT_LREMOVEXATTR(handle, path, name);
2311
2312         do_log(SMB_VFS_OP_LREMOVEXATTR, (result >= 0), handle,
2313                "%s|%s", path, name);
2314
2315         return result;
2316 }
2317
2318 static int smb_full_audit_fremovexattr(struct vfs_handle_struct *handle,
2319                               struct files_struct *fsp,
2320                               const char *name)
2321 {
2322         int result;
2323
2324         result = SMB_VFS_NEXT_FREMOVEXATTR(handle, fsp, name);
2325
2326         do_log(SMB_VFS_OP_FREMOVEXATTR, (result >= 0), handle,
2327                "%s|%s", fsp->fsp_name, name);
2328
2329         return result;
2330 }
2331
2332 static int smb_full_audit_setxattr(struct vfs_handle_struct *handle,
2333                           const char *path,
2334                           const char *name, const void *value, size_t size,
2335                           int flags)
2336 {
2337         int result;
2338
2339         result = SMB_VFS_NEXT_SETXATTR(handle, path, name, value, size,
2340                                        flags);
2341
2342         do_log(SMB_VFS_OP_SETXATTR, (result >= 0), handle,
2343                "%s|%s", path, name);
2344
2345         return result;
2346 }
2347
2348 static int smb_full_audit_lsetxattr(struct vfs_handle_struct *handle,
2349                            const char *path,
2350                            const char *name, const void *value, size_t size,
2351                            int flags)
2352 {
2353         int result;
2354
2355         result = SMB_VFS_NEXT_LSETXATTR(handle, path, name, value, size,
2356                                         flags);
2357
2358         do_log(SMB_VFS_OP_LSETXATTR, (result >= 0), handle,
2359                "%s|%s", path, name);
2360
2361         return result;
2362 }
2363
2364 static int smb_full_audit_fsetxattr(struct vfs_handle_struct *handle,
2365                            struct files_struct *fsp, const char *name,
2366                            const void *value, size_t size, int flags)
2367 {
2368         int result;
2369
2370         result = SMB_VFS_NEXT_FSETXATTR(handle, fsp, name, value, size, flags);
2371
2372         do_log(SMB_VFS_OP_FSETXATTR, (result >= 0), handle,
2373                "%s|%s", fsp->fsp_name, name);
2374
2375         return result;
2376 }
2377
2378 static int smb_full_audit_aio_read(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb)
2379 {
2380         int result;
2381
2382         result = SMB_VFS_NEXT_AIO_READ(handle, fsp, aiocb);
2383         do_log(SMB_VFS_OP_AIO_READ, (result >= 0), handle,
2384                 "%s", fsp->fsp_name);
2385
2386         return result;
2387 }
2388
2389 static int smb_full_audit_aio_write(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb)
2390 {
2391         int result;
2392
2393         result = SMB_VFS_NEXT_AIO_WRITE(handle, fsp, aiocb);
2394         do_log(SMB_VFS_OP_AIO_WRITE, (result >= 0), handle,
2395                 "%s", fsp->fsp_name);
2396
2397         return result;
2398 }
2399
2400 static ssize_t smb_full_audit_aio_return(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb)
2401 {
2402         int result;
2403
2404         result = SMB_VFS_NEXT_AIO_RETURN(handle, fsp, aiocb);
2405         do_log(SMB_VFS_OP_AIO_RETURN, (result >= 0), handle,
2406                 "%s", fsp->fsp_name);
2407
2408         return result;
2409 }
2410
2411 static int smb_full_audit_aio_cancel(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb)
2412 {
2413         int result;
2414
2415         result = SMB_VFS_NEXT_AIO_CANCEL(handle, fsp, aiocb);
2416         do_log(SMB_VFS_OP_AIO_CANCEL, (result >= 0), handle,
2417                 "%s", fsp->fsp_name);
2418
2419         return result;
2420 }
2421
2422 static int smb_full_audit_aio_error(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb)
2423 {
2424         int result;
2425
2426         result = SMB_VFS_NEXT_AIO_ERROR(handle, fsp, aiocb);
2427         do_log(SMB_VFS_OP_AIO_ERROR, (result >= 0), handle,
2428                 "%s", fsp->fsp_name);
2429
2430         return result;
2431 }
2432
2433 static int smb_full_audit_aio_fsync(struct vfs_handle_struct *handle, struct files_struct *fsp, int op, SMB_STRUCT_AIOCB *aiocb)
2434 {
2435         int result;
2436
2437         result = SMB_VFS_NEXT_AIO_FSYNC(handle, fsp, op, aiocb);
2438         do_log(SMB_VFS_OP_AIO_FSYNC, (result >= 0), handle,
2439                 "%s", fsp->fsp_name);
2440
2441         return result;
2442 }
2443
2444 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)
2445 {
2446         int result;
2447
2448         result = SMB_VFS_NEXT_AIO_SUSPEND(handle, fsp, aiocb, n, ts);
2449         do_log(SMB_VFS_OP_AIO_SUSPEND, (result >= 0), handle,
2450                 "%s", fsp->fsp_name);
2451
2452         return result;
2453 }
2454
2455 static bool smb_full_audit_aio_force(struct vfs_handle_struct *handle,
2456                                      struct files_struct *fsp)
2457 {
2458         bool result;
2459
2460         result = SMB_VFS_NEXT_AIO_FORCE(handle, fsp);
2461         do_log(SMB_VFS_OP_AIO_FORCE, result, handle,
2462                 "%s", fsp->fsp_name);
2463
2464         return result;
2465 }
2466
2467 NTSTATUS vfs_full_audit_init(void);
2468 NTSTATUS vfs_full_audit_init(void)
2469 {
2470         NTSTATUS ret = smb_register_vfs(SMB_VFS_INTERFACE_VERSION,
2471                                         "full_audit", audit_op_tuples);
2472         
2473         if (!NT_STATUS_IS_OK(ret))
2474                 return ret;
2475
2476         vfs_full_audit_debug_level = debug_add_class("full_audit");
2477         if (vfs_full_audit_debug_level == -1) {
2478                 vfs_full_audit_debug_level = DBGC_VFS;
2479                 DEBUG(0, ("vfs_full_audit: Couldn't register custom debugging "
2480                           "class!\n"));
2481         } else {
2482                 DEBUG(10, ("vfs_full_audit: Debug class number of "
2483                            "'full_audit': %d\n", vfs_full_audit_debug_level));
2484         }
2485         
2486         return ret;
2487 }