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