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