Fix headers, ldb_includes.h is a private header,
[Samba/bjacke.git] / source3 / modules / vfs_full_audit.c
blob3c159f10eb1ec1369873fe493134ad155e8a382d
1 /*
2 * Auditing VFS module for samba. Log selected file operations to syslog
3 * facility.
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
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.
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.
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/>.
26 * This module implements parseable logging for all Samba VFS operations.
28 * You use it as follows:
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
37 * vfs op can be "all" which means log all operations.
38 * vfs op can be "none" which means no logging.
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
44 * where "nobody" is the connected username and "192.168.234.1" is the
45 * client's IP address.
47 * Options:
49 * prefix: A macro expansion template prepended to the syslog entry.
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.
55 * failure: A list of VFS operations for which failure to complete should be
56 * logged. Defaults to logging everything.
60 #include "includes.h"
62 static int vfs_full_audit_debug_level = DBGC_VFS;
64 struct vfs_full_audit_private_data {
65 struct bitmap *success_ops;
66 struct bitmap *failure_ops;
69 #undef DBGC_CLASS
70 #define DBGC_CLASS vfs_full_audit_debug_level
72 /* Function prototypes */
74 static int smb_full_audit_connect(vfs_handle_struct *handle,
75 const char *svc, const char *user);
76 static void smb_full_audit_disconnect(vfs_handle_struct *handle);
77 static uint64_t smb_full_audit_disk_free(vfs_handle_struct *handle,
78 const char *path,
79 bool small_query, uint64_t *bsize,
80 uint64_t *dfree, uint64_t *dsize);
81 static int smb_full_audit_get_quota(struct vfs_handle_struct *handle,
82 enum SMB_QUOTA_TYPE qtype, unid_t id,
83 SMB_DISK_QUOTA *qt);
84 static int smb_full_audit_set_quota(struct vfs_handle_struct *handle,
85 enum SMB_QUOTA_TYPE qtype, unid_t id,
86 SMB_DISK_QUOTA *qt);
87 static int smb_full_audit_get_shadow_copy_data(struct vfs_handle_struct *handle,
88 struct files_struct *fsp,
89 SHADOW_COPY_DATA *shadow_copy_data, bool labels);
90 static int smb_full_audit_statvfs(struct vfs_handle_struct *handle,
91 const char *path,
92 struct vfs_statvfs_struct *statbuf);
93 static int smb_full_audit_fs_capabilities(struct vfs_handle_struct *handle);
94 static SMB_STRUCT_DIR *smb_full_audit_opendir(vfs_handle_struct *handle,
95 const char *fname, const char *mask, uint32 attr);
96 static SMB_STRUCT_DIRENT *smb_full_audit_readdir(vfs_handle_struct *handle,
97 SMB_STRUCT_DIR *dirp,
98 SMB_STRUCT_STAT *sbuf);
99 static void smb_full_audit_seekdir(vfs_handle_struct *handle,
100 SMB_STRUCT_DIR *dirp, long offset);
101 static long smb_full_audit_telldir(vfs_handle_struct *handle,
102 SMB_STRUCT_DIR *dirp);
103 static void smb_full_audit_rewinddir(vfs_handle_struct *handle,
104 SMB_STRUCT_DIR *dirp);
105 static int smb_full_audit_mkdir(vfs_handle_struct *handle,
106 const char *path, mode_t mode);
107 static int smb_full_audit_rmdir(vfs_handle_struct *handle,
108 const char *path);
109 static int smb_full_audit_closedir(vfs_handle_struct *handle,
110 SMB_STRUCT_DIR *dirp);
111 static void smb_full_audit_init_search_op(vfs_handle_struct *handle,
112 SMB_STRUCT_DIR *dirp);
113 static int smb_full_audit_open(vfs_handle_struct *handle,
114 const char *fname, files_struct *fsp, int flags, mode_t mode);
115 static NTSTATUS smb_full_audit_create_file(vfs_handle_struct *handle,
116 struct smb_request *req,
117 uint16_t root_dir_fid,
118 const char *fname,
119 uint32_t create_file_flags,
120 uint32_t access_mask,
121 uint32_t share_access,
122 uint32_t create_disposition,
123 uint32_t create_options,
124 uint32_t file_attributes,
125 uint32_t oplock_request,
126 uint64_t allocation_size,
127 struct security_descriptor *sd,
128 struct ea_list *ea_list,
129 files_struct **result,
130 int *pinfo,
131 SMB_STRUCT_STAT *psbuf);
132 static int smb_full_audit_close(vfs_handle_struct *handle, files_struct *fsp);
133 static ssize_t smb_full_audit_read(vfs_handle_struct *handle, files_struct *fsp,
134 void *data, size_t n);
135 static ssize_t smb_full_audit_pread(vfs_handle_struct *handle, files_struct *fsp,
136 void *data, size_t n, SMB_OFF_T offset);
137 static ssize_t smb_full_audit_write(vfs_handle_struct *handle, files_struct *fsp,
138 const void *data, size_t n);
139 static ssize_t smb_full_audit_pwrite(vfs_handle_struct *handle, files_struct *fsp,
140 const void *data, size_t n,
141 SMB_OFF_T offset);
142 static SMB_OFF_T smb_full_audit_lseek(vfs_handle_struct *handle, files_struct *fsp,
143 SMB_OFF_T offset, int whence);
144 static ssize_t smb_full_audit_sendfile(vfs_handle_struct *handle, int tofd,
145 files_struct *fromfsp,
146 const DATA_BLOB *hdr, SMB_OFF_T offset,
147 size_t n);
148 static ssize_t smb_full_audit_recvfile(vfs_handle_struct *handle, int fromfd,
149 files_struct *tofsp,
150 SMB_OFF_T offset,
151 size_t n);
152 static int smb_full_audit_rename(vfs_handle_struct *handle,
153 const char *oldname, const char *newname);
154 static int smb_full_audit_fsync(vfs_handle_struct *handle, files_struct *fsp);
155 static int smb_full_audit_stat(vfs_handle_struct *handle,
156 const char *fname, SMB_STRUCT_STAT *sbuf);
157 static int smb_full_audit_fstat(vfs_handle_struct *handle, files_struct *fsp,
158 SMB_STRUCT_STAT *sbuf);
159 static int smb_full_audit_lstat(vfs_handle_struct *handle,
160 const char *path, SMB_STRUCT_STAT *sbuf);
161 static int smb_full_audit_get_alloc_size(vfs_handle_struct *handle,
162 files_struct *fsp, const SMB_STRUCT_STAT *sbuf);
163 static int smb_full_audit_unlink(vfs_handle_struct *handle,
164 const char *path);
165 static int smb_full_audit_chmod(vfs_handle_struct *handle,
166 const char *path, mode_t mode);
167 static int smb_full_audit_fchmod(vfs_handle_struct *handle, files_struct *fsp,
168 mode_t mode);
169 static int smb_full_audit_chown(vfs_handle_struct *handle,
170 const char *path, uid_t uid, gid_t gid);
171 static int smb_full_audit_fchown(vfs_handle_struct *handle, files_struct *fsp,
172 uid_t uid, gid_t gid);
173 static int smb_full_audit_lchown(vfs_handle_struct *handle,
174 const char *path, uid_t uid, gid_t gid);
175 static int smb_full_audit_chdir(vfs_handle_struct *handle,
176 const char *path);
177 static char *smb_full_audit_getwd(vfs_handle_struct *handle,
178 char *path);
179 static int smb_full_audit_ntimes(vfs_handle_struct *handle,
180 const char *path, struct smb_file_time *ft);
181 static int smb_full_audit_ftruncate(vfs_handle_struct *handle, files_struct *fsp,
182 SMB_OFF_T len);
183 static bool smb_full_audit_lock(vfs_handle_struct *handle, files_struct *fsp,
184 int op, SMB_OFF_T offset, SMB_OFF_T count, int type);
185 static int smb_full_audit_kernel_flock(struct vfs_handle_struct *handle,
186 struct files_struct *fsp,
187 uint32 share_mode);
188 static int smb_full_audit_linux_setlease(vfs_handle_struct *handle, files_struct *fsp,
189 int leasetype);
190 static bool smb_full_audit_getlock(vfs_handle_struct *handle, files_struct *fsp,
191 SMB_OFF_T *poffset, SMB_OFF_T *pcount, int *ptype, pid_t *ppid);
192 static int smb_full_audit_symlink(vfs_handle_struct *handle,
193 const char *oldpath, const char *newpath);
194 static int smb_full_audit_readlink(vfs_handle_struct *handle,
195 const char *path, char *buf, size_t bufsiz);
196 static int smb_full_audit_link(vfs_handle_struct *handle,
197 const char *oldpath, const char *newpath);
198 static int smb_full_audit_mknod(vfs_handle_struct *handle,
199 const char *pathname, mode_t mode, SMB_DEV_T dev);
200 static char *smb_full_audit_realpath(vfs_handle_struct *handle,
201 const char *path, char *resolved_path);
202 static NTSTATUS smb_full_audit_notify_watch(struct vfs_handle_struct *handle,
203 struct sys_notify_context *ctx,
204 struct notify_entry *e,
205 void (*callback)(struct sys_notify_context *ctx,
206 void *private_data,
207 struct notify_event *ev),
208 void *private_data, void *handle_p);
209 static int smb_full_audit_chflags(vfs_handle_struct *handle,
210 const char *path, unsigned int flags);
211 static struct file_id smb_full_audit_file_id_create(struct vfs_handle_struct *handle,
212 const SMB_STRUCT_STAT *sbuf);
213 static NTSTATUS smb_full_audit_streaminfo(vfs_handle_struct *handle,
214 struct files_struct *fsp,
215 const char *fname,
216 TALLOC_CTX *mem_ctx,
217 unsigned int *pnum_streams,
218 struct stream_struct **pstreams);
219 static int smb_full_audit_get_real_filename(struct vfs_handle_struct *handle,
220 const char *path,
221 const char *name,
222 TALLOC_CTX *mem_ctx,
223 char **found_name);
224 static NTSTATUS smb_full_audit_brl_lock_windows(struct vfs_handle_struct *handle,
225 struct byte_range_lock *br_lck,
226 struct lock_struct *plock,
227 bool blocking_lock,
228 struct blocking_lock_record *blr);
229 static bool smb_full_audit_brl_unlock_windows(struct vfs_handle_struct *handle,
230 struct messaging_context *msg_ctx,
231 struct byte_range_lock *br_lck,
232 const struct lock_struct *plock);
233 static bool smb_full_audit_brl_cancel_windows(struct vfs_handle_struct *handle,
234 struct byte_range_lock *br_lck,
235 struct lock_struct *plock,
236 struct blocking_lock_record *blr);
237 static NTSTATUS smb_full_audit_fget_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
238 uint32 security_info,
239 SEC_DESC **ppdesc);
240 static NTSTATUS smb_full_audit_get_nt_acl(vfs_handle_struct *handle,
241 const char *name, uint32 security_info,
242 SEC_DESC **ppdesc);
243 static NTSTATUS smb_full_audit_fset_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
244 uint32 security_info_sent,
245 const SEC_DESC *psd);
246 static int smb_full_audit_chmod_acl(vfs_handle_struct *handle,
247 const char *path, mode_t mode);
248 static int smb_full_audit_fchmod_acl(vfs_handle_struct *handle, files_struct *fsp,
249 mode_t mode);
250 static int smb_full_audit_sys_acl_get_entry(vfs_handle_struct *handle,
251 SMB_ACL_T theacl, int entry_id,
252 SMB_ACL_ENTRY_T *entry_p);
253 static int smb_full_audit_sys_acl_get_tag_type(vfs_handle_struct *handle,
254 SMB_ACL_ENTRY_T entry_d,
255 SMB_ACL_TAG_T *tag_type_p);
256 static int smb_full_audit_sys_acl_get_permset(vfs_handle_struct *handle,
257 SMB_ACL_ENTRY_T entry_d,
258 SMB_ACL_PERMSET_T *permset_p);
259 static void * smb_full_audit_sys_acl_get_qualifier(vfs_handle_struct *handle,
260 SMB_ACL_ENTRY_T entry_d);
261 static SMB_ACL_T smb_full_audit_sys_acl_get_file(vfs_handle_struct *handle,
262 const char *path_p,
263 SMB_ACL_TYPE_T type);
264 static SMB_ACL_T smb_full_audit_sys_acl_get_fd(vfs_handle_struct *handle,
265 files_struct *fsp);
266 static int smb_full_audit_sys_acl_clear_perms(vfs_handle_struct *handle,
267 SMB_ACL_PERMSET_T permset);
268 static int smb_full_audit_sys_acl_add_perm(vfs_handle_struct *handle,
269 SMB_ACL_PERMSET_T permset,
270 SMB_ACL_PERM_T perm);
271 static char * smb_full_audit_sys_acl_to_text(vfs_handle_struct *handle,
272 SMB_ACL_T theacl,
273 ssize_t *plen);
274 static SMB_ACL_T smb_full_audit_sys_acl_init(vfs_handle_struct *handle,
275 int count);
276 static int smb_full_audit_sys_acl_create_entry(vfs_handle_struct *handle,
277 SMB_ACL_T *pacl,
278 SMB_ACL_ENTRY_T *pentry);
279 static int smb_full_audit_sys_acl_set_tag_type(vfs_handle_struct *handle,
280 SMB_ACL_ENTRY_T entry,
281 SMB_ACL_TAG_T tagtype);
282 static int smb_full_audit_sys_acl_set_qualifier(vfs_handle_struct *handle,
283 SMB_ACL_ENTRY_T entry,
284 void *qual);
285 static int smb_full_audit_sys_acl_set_permset(vfs_handle_struct *handle,
286 SMB_ACL_ENTRY_T entry,
287 SMB_ACL_PERMSET_T permset);
288 static int smb_full_audit_sys_acl_valid(vfs_handle_struct *handle,
289 SMB_ACL_T theacl );
290 static int smb_full_audit_sys_acl_set_file(vfs_handle_struct *handle,
291 const char *name, SMB_ACL_TYPE_T acltype,
292 SMB_ACL_T theacl);
293 static int smb_full_audit_sys_acl_set_fd(vfs_handle_struct *handle, files_struct *fsp,
294 SMB_ACL_T theacl);
295 static int smb_full_audit_sys_acl_delete_def_file(vfs_handle_struct *handle,
296 const char *path);
297 static int smb_full_audit_sys_acl_get_perm(vfs_handle_struct *handle,
298 SMB_ACL_PERMSET_T permset,
299 SMB_ACL_PERM_T perm);
300 static int smb_full_audit_sys_acl_free_text(vfs_handle_struct *handle,
301 char *text);
302 static int smb_full_audit_sys_acl_free_acl(vfs_handle_struct *handle,
303 SMB_ACL_T posix_acl);
304 static int smb_full_audit_sys_acl_free_qualifier(vfs_handle_struct *handle,
305 void *qualifier,
306 SMB_ACL_TAG_T tagtype);
307 static ssize_t smb_full_audit_getxattr(struct vfs_handle_struct *handle,
308 const char *path,
309 const char *name, void *value, size_t size);
310 static ssize_t smb_full_audit_lgetxattr(struct vfs_handle_struct *handle,
311 const char *path, const char *name,
312 void *value, size_t size);
313 static ssize_t smb_full_audit_fgetxattr(struct vfs_handle_struct *handle,
314 struct files_struct *fsp,
315 const char *name, void *value, size_t size);
316 static ssize_t smb_full_audit_listxattr(struct vfs_handle_struct *handle,
317 const char *path, char *list, size_t size);
318 static ssize_t smb_full_audit_llistxattr(struct vfs_handle_struct *handle,
319 const char *path, char *list, size_t size);
320 static ssize_t smb_full_audit_flistxattr(struct vfs_handle_struct *handle,
321 struct files_struct *fsp, char *list,
322 size_t size);
323 static int smb_full_audit_removexattr(struct vfs_handle_struct *handle,
324 const char *path,
325 const char *name);
326 static int smb_full_audit_lremovexattr(struct vfs_handle_struct *handle,
327 const char *path,
328 const char *name);
329 static int smb_full_audit_fremovexattr(struct vfs_handle_struct *handle,
330 struct files_struct *fsp,
331 const char *name);
332 static int smb_full_audit_setxattr(struct vfs_handle_struct *handle,
333 const char *path,
334 const char *name, const void *value, size_t size,
335 int flags);
336 static int smb_full_audit_lsetxattr(struct vfs_handle_struct *handle,
337 const char *path,
338 const char *name, const void *value, size_t size,
339 int flags);
340 static int smb_full_audit_fsetxattr(struct vfs_handle_struct *handle,
341 struct files_struct *fsp, const char *name,
342 const void *value, size_t size, int flags);
344 static int smb_full_audit_aio_read(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb);
345 static int smb_full_audit_aio_write(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb);
346 static ssize_t smb_full_audit_aio_return(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb);
347 static int smb_full_audit_aio_cancel(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb);
348 static int smb_full_audit_aio_error(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb);
349 static int smb_full_audit_aio_fsync(struct vfs_handle_struct *handle, struct files_struct *fsp, int op, SMB_STRUCT_AIOCB *aiocb);
350 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);
351 static bool smb_full_audit_aio_force(struct vfs_handle_struct *handle,
352 struct files_struct *fsp);
354 /* VFS operations */
356 static vfs_op_tuple audit_op_tuples[] = {
358 /* Disk operations */
360 {SMB_VFS_OP(smb_full_audit_connect), SMB_VFS_OP_CONNECT,
361 SMB_VFS_LAYER_LOGGER},
362 {SMB_VFS_OP(smb_full_audit_disconnect), SMB_VFS_OP_DISCONNECT,
363 SMB_VFS_LAYER_LOGGER},
364 {SMB_VFS_OP(smb_full_audit_disk_free), SMB_VFS_OP_DISK_FREE,
365 SMB_VFS_LAYER_LOGGER},
366 {SMB_VFS_OP(smb_full_audit_get_quota), SMB_VFS_OP_GET_QUOTA,
367 SMB_VFS_LAYER_LOGGER},
368 {SMB_VFS_OP(smb_full_audit_set_quota), SMB_VFS_OP_SET_QUOTA,
369 SMB_VFS_LAYER_LOGGER},
370 {SMB_VFS_OP(smb_full_audit_get_shadow_copy_data), SMB_VFS_OP_GET_SHADOW_COPY_DATA,
371 SMB_VFS_LAYER_LOGGER},
372 {SMB_VFS_OP(smb_full_audit_statvfs), SMB_VFS_OP_STATVFS,
373 SMB_VFS_LAYER_LOGGER},
374 {SMB_VFS_OP(smb_full_audit_fs_capabilities), SMB_VFS_OP_FS_CAPABILITIES,
375 SMB_VFS_LAYER_LOGGER},
377 /* Directory operations */
379 {SMB_VFS_OP(smb_full_audit_opendir), SMB_VFS_OP_OPENDIR,
380 SMB_VFS_LAYER_LOGGER},
381 {SMB_VFS_OP(smb_full_audit_readdir), SMB_VFS_OP_READDIR,
382 SMB_VFS_LAYER_LOGGER},
383 {SMB_VFS_OP(smb_full_audit_seekdir), SMB_VFS_OP_SEEKDIR,
384 SMB_VFS_LAYER_LOGGER},
385 {SMB_VFS_OP(smb_full_audit_telldir), SMB_VFS_OP_TELLDIR,
386 SMB_VFS_LAYER_LOGGER},
387 {SMB_VFS_OP(smb_full_audit_rewinddir), SMB_VFS_OP_REWINDDIR,
388 SMB_VFS_LAYER_LOGGER},
389 {SMB_VFS_OP(smb_full_audit_mkdir), SMB_VFS_OP_MKDIR,
390 SMB_VFS_LAYER_LOGGER},
391 {SMB_VFS_OP(smb_full_audit_rmdir), SMB_VFS_OP_RMDIR,
392 SMB_VFS_LAYER_LOGGER},
393 {SMB_VFS_OP(smb_full_audit_closedir), SMB_VFS_OP_CLOSEDIR,
394 SMB_VFS_LAYER_LOGGER},
395 {SMB_VFS_OP(smb_full_audit_init_search_op), SMB_VFS_OP_INIT_SEARCH_OP,
396 SMB_VFS_LAYER_LOGGER},
398 /* File operations */
400 {SMB_VFS_OP(smb_full_audit_open), SMB_VFS_OP_OPEN,
401 SMB_VFS_LAYER_LOGGER},
402 {SMB_VFS_OP(smb_full_audit_create_file),SMB_VFS_OP_CREATE_FILE,
403 SMB_VFS_LAYER_LOGGER},
404 {SMB_VFS_OP(smb_full_audit_close), SMB_VFS_OP_CLOSE,
405 SMB_VFS_LAYER_LOGGER},
406 {SMB_VFS_OP(smb_full_audit_read), SMB_VFS_OP_READ,
407 SMB_VFS_LAYER_LOGGER},
408 {SMB_VFS_OP(smb_full_audit_pread), SMB_VFS_OP_PREAD,
409 SMB_VFS_LAYER_LOGGER},
410 {SMB_VFS_OP(smb_full_audit_write), SMB_VFS_OP_WRITE,
411 SMB_VFS_LAYER_LOGGER},
412 {SMB_VFS_OP(smb_full_audit_pwrite), SMB_VFS_OP_PWRITE,
413 SMB_VFS_LAYER_LOGGER},
414 {SMB_VFS_OP(smb_full_audit_lseek), SMB_VFS_OP_LSEEK,
415 SMB_VFS_LAYER_LOGGER},
416 {SMB_VFS_OP(smb_full_audit_sendfile), SMB_VFS_OP_SENDFILE,
417 SMB_VFS_LAYER_LOGGER},
418 {SMB_VFS_OP(smb_full_audit_recvfile), SMB_VFS_OP_RECVFILE,
419 SMB_VFS_LAYER_LOGGER},
420 {SMB_VFS_OP(smb_full_audit_rename), SMB_VFS_OP_RENAME,
421 SMB_VFS_LAYER_LOGGER},
422 {SMB_VFS_OP(smb_full_audit_fsync), SMB_VFS_OP_FSYNC,
423 SMB_VFS_LAYER_LOGGER},
424 {SMB_VFS_OP(smb_full_audit_stat), SMB_VFS_OP_STAT,
425 SMB_VFS_LAYER_LOGGER},
426 {SMB_VFS_OP(smb_full_audit_fstat), SMB_VFS_OP_FSTAT,
427 SMB_VFS_LAYER_LOGGER},
428 {SMB_VFS_OP(smb_full_audit_lstat), SMB_VFS_OP_LSTAT,
429 SMB_VFS_LAYER_LOGGER},
430 {SMB_VFS_OP(smb_full_audit_get_alloc_size), SMB_VFS_OP_GET_ALLOC_SIZE,
431 SMB_VFS_LAYER_LOGGER},
432 {SMB_VFS_OP(smb_full_audit_unlink), SMB_VFS_OP_UNLINK,
433 SMB_VFS_LAYER_LOGGER},
434 {SMB_VFS_OP(smb_full_audit_chmod), SMB_VFS_OP_CHMOD,
435 SMB_VFS_LAYER_LOGGER},
436 {SMB_VFS_OP(smb_full_audit_fchmod), SMB_VFS_OP_FCHMOD,
437 SMB_VFS_LAYER_LOGGER},
438 {SMB_VFS_OP(smb_full_audit_chown), SMB_VFS_OP_CHOWN,
439 SMB_VFS_LAYER_LOGGER},
440 {SMB_VFS_OP(smb_full_audit_fchown), SMB_VFS_OP_FCHOWN,
441 SMB_VFS_LAYER_LOGGER},
442 {SMB_VFS_OP(smb_full_audit_lchown), SMB_VFS_OP_LCHOWN,
443 SMB_VFS_LAYER_LOGGER},
444 {SMB_VFS_OP(smb_full_audit_chdir), SMB_VFS_OP_CHDIR,
445 SMB_VFS_LAYER_LOGGER},
446 {SMB_VFS_OP(smb_full_audit_getwd), SMB_VFS_OP_GETWD,
447 SMB_VFS_LAYER_LOGGER},
448 {SMB_VFS_OP(smb_full_audit_ntimes), SMB_VFS_OP_NTIMES,
449 SMB_VFS_LAYER_LOGGER},
450 {SMB_VFS_OP(smb_full_audit_ftruncate), SMB_VFS_OP_FTRUNCATE,
451 SMB_VFS_LAYER_LOGGER},
452 {SMB_VFS_OP(smb_full_audit_lock), SMB_VFS_OP_LOCK,
453 SMB_VFS_LAYER_LOGGER},
454 {SMB_VFS_OP(smb_full_audit_kernel_flock), SMB_VFS_OP_KERNEL_FLOCK,
455 SMB_VFS_LAYER_LOGGER},
456 {SMB_VFS_OP(smb_full_audit_linux_setlease), SMB_VFS_OP_LINUX_SETLEASE,
457 SMB_VFS_LAYER_LOGGER},
458 {SMB_VFS_OP(smb_full_audit_getlock), SMB_VFS_OP_GETLOCK,
459 SMB_VFS_LAYER_LOGGER},
460 {SMB_VFS_OP(smb_full_audit_symlink), SMB_VFS_OP_SYMLINK,
461 SMB_VFS_LAYER_LOGGER},
462 {SMB_VFS_OP(smb_full_audit_readlink), SMB_VFS_OP_READLINK,
463 SMB_VFS_LAYER_LOGGER},
464 {SMB_VFS_OP(smb_full_audit_link), SMB_VFS_OP_LINK,
465 SMB_VFS_LAYER_LOGGER},
466 {SMB_VFS_OP(smb_full_audit_mknod), SMB_VFS_OP_MKNOD,
467 SMB_VFS_LAYER_LOGGER},
468 {SMB_VFS_OP(smb_full_audit_realpath), SMB_VFS_OP_REALPATH,
469 SMB_VFS_LAYER_LOGGER},
470 {SMB_VFS_OP(smb_full_audit_notify_watch),SMB_VFS_OP_NOTIFY_WATCH,
471 SMB_VFS_LAYER_LOGGER},
472 {SMB_VFS_OP(smb_full_audit_chflags), SMB_VFS_OP_CHFLAGS,
473 SMB_VFS_LAYER_LOGGER},
474 {SMB_VFS_OP(smb_full_audit_file_id_create), SMB_VFS_OP_FILE_ID_CREATE,
475 SMB_VFS_LAYER_LOGGER},
476 {SMB_VFS_OP(smb_full_audit_streaminfo), SMB_VFS_OP_STREAMINFO,
477 SMB_VFS_LAYER_LOGGER},
478 {SMB_VFS_OP(smb_full_audit_get_real_filename), SMB_VFS_OP_GET_REAL_FILENAME,
479 SMB_VFS_LAYER_LOGGER},
480 {SMB_VFS_OP(smb_full_audit_brl_lock_windows), SMB_VFS_OP_BRL_LOCK_WINDOWS,
481 SMB_VFS_LAYER_LOGGER},
482 {SMB_VFS_OP(smb_full_audit_brl_unlock_windows), SMB_VFS_OP_BRL_UNLOCK_WINDOWS,
483 SMB_VFS_LAYER_LOGGER},
484 {SMB_VFS_OP(smb_full_audit_brl_cancel_windows), SMB_VFS_OP_BRL_CANCEL_WINDOWS,
485 SMB_VFS_LAYER_LOGGER},
487 /* NT ACL operations. */
489 {SMB_VFS_OP(smb_full_audit_fget_nt_acl), SMB_VFS_OP_FGET_NT_ACL,
490 SMB_VFS_LAYER_LOGGER},
491 {SMB_VFS_OP(smb_full_audit_get_nt_acl), SMB_VFS_OP_GET_NT_ACL,
492 SMB_VFS_LAYER_LOGGER},
493 {SMB_VFS_OP(smb_full_audit_fset_nt_acl), SMB_VFS_OP_FSET_NT_ACL,
494 SMB_VFS_LAYER_LOGGER},
496 /* POSIX ACL operations. */
498 {SMB_VFS_OP(smb_full_audit_chmod_acl), SMB_VFS_OP_CHMOD_ACL,
499 SMB_VFS_LAYER_LOGGER},
500 {SMB_VFS_OP(smb_full_audit_fchmod_acl), SMB_VFS_OP_FCHMOD_ACL,
501 SMB_VFS_LAYER_LOGGER},
502 {SMB_VFS_OP(smb_full_audit_sys_acl_get_entry), SMB_VFS_OP_SYS_ACL_GET_ENTRY,
503 SMB_VFS_LAYER_LOGGER},
504 {SMB_VFS_OP(smb_full_audit_sys_acl_get_tag_type), SMB_VFS_OP_SYS_ACL_GET_TAG_TYPE,
505 SMB_VFS_LAYER_LOGGER},
506 {SMB_VFS_OP(smb_full_audit_sys_acl_get_permset), SMB_VFS_OP_SYS_ACL_GET_PERMSET,
507 SMB_VFS_LAYER_LOGGER},
508 {SMB_VFS_OP(smb_full_audit_sys_acl_get_qualifier), SMB_VFS_OP_SYS_ACL_GET_QUALIFIER,
509 SMB_VFS_LAYER_LOGGER},
510 {SMB_VFS_OP(smb_full_audit_sys_acl_get_file), SMB_VFS_OP_SYS_ACL_GET_FILE,
511 SMB_VFS_LAYER_LOGGER},
512 {SMB_VFS_OP(smb_full_audit_sys_acl_get_fd), SMB_VFS_OP_SYS_ACL_GET_FD,
513 SMB_VFS_LAYER_LOGGER},
514 {SMB_VFS_OP(smb_full_audit_sys_acl_clear_perms), SMB_VFS_OP_SYS_ACL_CLEAR_PERMS,
515 SMB_VFS_LAYER_LOGGER},
516 {SMB_VFS_OP(smb_full_audit_sys_acl_add_perm), SMB_VFS_OP_SYS_ACL_ADD_PERM,
517 SMB_VFS_LAYER_LOGGER},
518 {SMB_VFS_OP(smb_full_audit_sys_acl_to_text), SMB_VFS_OP_SYS_ACL_TO_TEXT,
519 SMB_VFS_LAYER_LOGGER},
520 {SMB_VFS_OP(smb_full_audit_sys_acl_init), SMB_VFS_OP_SYS_ACL_INIT,
521 SMB_VFS_LAYER_LOGGER},
522 {SMB_VFS_OP(smb_full_audit_sys_acl_create_entry), SMB_VFS_OP_SYS_ACL_CREATE_ENTRY,
523 SMB_VFS_LAYER_LOGGER},
524 {SMB_VFS_OP(smb_full_audit_sys_acl_set_tag_type), SMB_VFS_OP_SYS_ACL_SET_TAG_TYPE,
525 SMB_VFS_LAYER_LOGGER},
526 {SMB_VFS_OP(smb_full_audit_sys_acl_set_qualifier), SMB_VFS_OP_SYS_ACL_SET_QUALIFIER,
527 SMB_VFS_LAYER_LOGGER},
528 {SMB_VFS_OP(smb_full_audit_sys_acl_set_permset), SMB_VFS_OP_SYS_ACL_SET_PERMSET,
529 SMB_VFS_LAYER_LOGGER},
530 {SMB_VFS_OP(smb_full_audit_sys_acl_valid), SMB_VFS_OP_SYS_ACL_VALID,
531 SMB_VFS_LAYER_LOGGER},
532 {SMB_VFS_OP(smb_full_audit_sys_acl_set_file), SMB_VFS_OP_SYS_ACL_SET_FILE,
533 SMB_VFS_LAYER_LOGGER},
534 {SMB_VFS_OP(smb_full_audit_sys_acl_set_fd), SMB_VFS_OP_SYS_ACL_SET_FD,
535 SMB_VFS_LAYER_LOGGER},
536 {SMB_VFS_OP(smb_full_audit_sys_acl_delete_def_file), SMB_VFS_OP_SYS_ACL_DELETE_DEF_FILE,
537 SMB_VFS_LAYER_LOGGER},
538 {SMB_VFS_OP(smb_full_audit_sys_acl_get_perm), SMB_VFS_OP_SYS_ACL_GET_PERM,
539 SMB_VFS_LAYER_LOGGER},
540 {SMB_VFS_OP(smb_full_audit_sys_acl_free_text), SMB_VFS_OP_SYS_ACL_FREE_TEXT,
541 SMB_VFS_LAYER_LOGGER},
542 {SMB_VFS_OP(smb_full_audit_sys_acl_free_acl), SMB_VFS_OP_SYS_ACL_FREE_ACL,
543 SMB_VFS_LAYER_LOGGER},
544 {SMB_VFS_OP(smb_full_audit_sys_acl_free_qualifier), SMB_VFS_OP_SYS_ACL_FREE_QUALIFIER,
545 SMB_VFS_LAYER_LOGGER},
547 /* EA operations. */
549 {SMB_VFS_OP(smb_full_audit_getxattr), SMB_VFS_OP_GETXATTR,
550 SMB_VFS_LAYER_LOGGER},
551 {SMB_VFS_OP(smb_full_audit_lgetxattr), SMB_VFS_OP_LGETXATTR,
552 SMB_VFS_LAYER_LOGGER},
553 {SMB_VFS_OP(smb_full_audit_fgetxattr), SMB_VFS_OP_FGETXATTR,
554 SMB_VFS_LAYER_LOGGER},
555 {SMB_VFS_OP(smb_full_audit_listxattr), SMB_VFS_OP_LISTXATTR,
556 SMB_VFS_LAYER_LOGGER},
557 {SMB_VFS_OP(smb_full_audit_llistxattr), SMB_VFS_OP_LLISTXATTR,
558 SMB_VFS_LAYER_LOGGER},
559 {SMB_VFS_OP(smb_full_audit_flistxattr), SMB_VFS_OP_FLISTXATTR,
560 SMB_VFS_LAYER_LOGGER},
561 {SMB_VFS_OP(smb_full_audit_removexattr), SMB_VFS_OP_REMOVEXATTR,
562 SMB_VFS_LAYER_LOGGER},
563 {SMB_VFS_OP(smb_full_audit_lremovexattr), SMB_VFS_OP_LREMOVEXATTR,
564 SMB_VFS_LAYER_LOGGER},
565 {SMB_VFS_OP(smb_full_audit_fremovexattr), SMB_VFS_OP_FREMOVEXATTR,
566 SMB_VFS_LAYER_LOGGER},
567 {SMB_VFS_OP(smb_full_audit_setxattr), SMB_VFS_OP_SETXATTR,
568 SMB_VFS_LAYER_LOGGER},
569 {SMB_VFS_OP(smb_full_audit_lsetxattr), SMB_VFS_OP_LSETXATTR,
570 SMB_VFS_LAYER_LOGGER},
571 {SMB_VFS_OP(smb_full_audit_fsetxattr), SMB_VFS_OP_FSETXATTR,
572 SMB_VFS_LAYER_LOGGER},
574 {SMB_VFS_OP(smb_full_audit_aio_read), SMB_VFS_OP_AIO_READ,
575 SMB_VFS_LAYER_LOGGER},
576 {SMB_VFS_OP(smb_full_audit_aio_write), SMB_VFS_OP_AIO_WRITE,
577 SMB_VFS_LAYER_LOGGER},
578 {SMB_VFS_OP(smb_full_audit_aio_return), SMB_VFS_OP_AIO_RETURN,
579 SMB_VFS_LAYER_LOGGER},
580 {SMB_VFS_OP(smb_full_audit_aio_cancel), SMB_VFS_OP_AIO_CANCEL,
581 SMB_VFS_LAYER_LOGGER},
582 {SMB_VFS_OP(smb_full_audit_aio_error), SMB_VFS_OP_AIO_ERROR,
583 SMB_VFS_LAYER_LOGGER},
584 {SMB_VFS_OP(smb_full_audit_aio_fsync), SMB_VFS_OP_AIO_FSYNC,
585 SMB_VFS_LAYER_LOGGER},
586 {SMB_VFS_OP(smb_full_audit_aio_suspend),SMB_VFS_OP_AIO_SUSPEND,
587 SMB_VFS_LAYER_LOGGER},
588 {SMB_VFS_OP(smb_full_audit_aio_force),SMB_VFS_OP_AIO_FORCE,
589 SMB_VFS_LAYER_LOGGER},
591 /* Finish VFS operations definition */
593 {SMB_VFS_OP(NULL), SMB_VFS_OP_NOOP,
594 SMB_VFS_LAYER_NOOP}
597 /* The following array *must* be in the same order as defined in vfs.h */
599 static struct {
600 vfs_op_type type;
601 const char *name;
602 } vfs_op_names[] = {
603 { SMB_VFS_OP_CONNECT, "connect" },
604 { SMB_VFS_OP_DISCONNECT, "disconnect" },
605 { SMB_VFS_OP_DISK_FREE, "disk_free" },
606 { SMB_VFS_OP_GET_QUOTA, "get_quota" },
607 { SMB_VFS_OP_SET_QUOTA, "set_quota" },
608 { SMB_VFS_OP_GET_SHADOW_COPY_DATA, "get_shadow_copy_data" },
609 { SMB_VFS_OP_STATVFS, "statvfs" },
610 { SMB_VFS_OP_FS_CAPABILITIES, "fs_capabilities" },
611 { SMB_VFS_OP_OPENDIR, "opendir" },
612 { SMB_VFS_OP_READDIR, "readdir" },
613 { SMB_VFS_OP_SEEKDIR, "seekdir" },
614 { SMB_VFS_OP_TELLDIR, "telldir" },
615 { SMB_VFS_OP_REWINDDIR, "rewinddir" },
616 { SMB_VFS_OP_MKDIR, "mkdir" },
617 { SMB_VFS_OP_RMDIR, "rmdir" },
618 { SMB_VFS_OP_CLOSEDIR, "closedir" },
619 { SMB_VFS_OP_INIT_SEARCH_OP, "init_search_op" },
620 { SMB_VFS_OP_OPEN, "open" },
621 { SMB_VFS_OP_CREATE_FILE, "create_file" },
622 { SMB_VFS_OP_CLOSE, "close" },
623 { SMB_VFS_OP_READ, "read" },
624 { SMB_VFS_OP_PREAD, "pread" },
625 { SMB_VFS_OP_WRITE, "write" },
626 { SMB_VFS_OP_PWRITE, "pwrite" },
627 { SMB_VFS_OP_LSEEK, "lseek" },
628 { SMB_VFS_OP_SENDFILE, "sendfile" },
629 { SMB_VFS_OP_RECVFILE, "recvfile" },
630 { SMB_VFS_OP_RENAME, "rename" },
631 { SMB_VFS_OP_FSYNC, "fsync" },
632 { SMB_VFS_OP_STAT, "stat" },
633 { SMB_VFS_OP_FSTAT, "fstat" },
634 { SMB_VFS_OP_LSTAT, "lstat" },
635 { SMB_VFS_OP_GET_ALLOC_SIZE, "get_alloc_size" },
636 { SMB_VFS_OP_UNLINK, "unlink" },
637 { SMB_VFS_OP_CHMOD, "chmod" },
638 { SMB_VFS_OP_FCHMOD, "fchmod" },
639 { SMB_VFS_OP_CHOWN, "chown" },
640 { SMB_VFS_OP_FCHOWN, "fchown" },
641 { SMB_VFS_OP_LCHOWN, "lchown" },
642 { SMB_VFS_OP_CHDIR, "chdir" },
643 { SMB_VFS_OP_GETWD, "getwd" },
644 { SMB_VFS_OP_NTIMES, "ntimes" },
645 { SMB_VFS_OP_FTRUNCATE, "ftruncate" },
646 { SMB_VFS_OP_LOCK, "lock" },
647 { SMB_VFS_OP_KERNEL_FLOCK, "kernel_flock" },
648 { SMB_VFS_OP_LINUX_SETLEASE, "linux_setlease" },
649 { SMB_VFS_OP_GETLOCK, "getlock" },
650 { SMB_VFS_OP_SYMLINK, "symlink" },
651 { SMB_VFS_OP_READLINK, "readlink" },
652 { SMB_VFS_OP_LINK, "link" },
653 { SMB_VFS_OP_MKNOD, "mknod" },
654 { SMB_VFS_OP_REALPATH, "realpath" },
655 { SMB_VFS_OP_NOTIFY_WATCH, "notify_watch" },
656 { SMB_VFS_OP_CHFLAGS, "chflags" },
657 { SMB_VFS_OP_FILE_ID_CREATE, "file_id_create" },
658 { SMB_VFS_OP_STREAMINFO, "streaminfo" },
659 { SMB_VFS_OP_GET_REAL_FILENAME, "get_real_filename" },
660 { SMB_VFS_OP_BRL_LOCK_WINDOWS, "brl_lock_windows" },
661 { SMB_VFS_OP_BRL_UNLOCK_WINDOWS, "brl_unlock_windows" },
662 { SMB_VFS_OP_BRL_CANCEL_WINDOWS, "brl_cancel_windows" },
663 { SMB_VFS_OP_FGET_NT_ACL, "fget_nt_acl" },
664 { SMB_VFS_OP_GET_NT_ACL, "get_nt_acl" },
665 { SMB_VFS_OP_FSET_NT_ACL, "fset_nt_acl" },
666 { SMB_VFS_OP_CHMOD_ACL, "chmod_acl" },
667 { SMB_VFS_OP_FCHMOD_ACL, "fchmod_acl" },
668 { SMB_VFS_OP_SYS_ACL_GET_ENTRY, "sys_acl_get_entry" },
669 { SMB_VFS_OP_SYS_ACL_GET_TAG_TYPE, "sys_acl_get_tag_type" },
670 { SMB_VFS_OP_SYS_ACL_GET_PERMSET, "sys_acl_get_permset" },
671 { SMB_VFS_OP_SYS_ACL_GET_QUALIFIER, "sys_acl_get_qualifier" },
672 { SMB_VFS_OP_SYS_ACL_GET_FILE, "sys_acl_get_file" },
673 { SMB_VFS_OP_SYS_ACL_GET_FD, "sys_acl_get_fd" },
674 { SMB_VFS_OP_SYS_ACL_CLEAR_PERMS, "sys_acl_clear_perms" },
675 { SMB_VFS_OP_SYS_ACL_ADD_PERM, "sys_acl_add_perm" },
676 { SMB_VFS_OP_SYS_ACL_TO_TEXT, "sys_acl_to_text" },
677 { SMB_VFS_OP_SYS_ACL_INIT, "sys_acl_init" },
678 { SMB_VFS_OP_SYS_ACL_CREATE_ENTRY, "sys_acl_create_entry" },
679 { SMB_VFS_OP_SYS_ACL_SET_TAG_TYPE, "sys_acl_set_tag_type" },
680 { SMB_VFS_OP_SYS_ACL_SET_QUALIFIER, "sys_acl_set_qualifier" },
681 { SMB_VFS_OP_SYS_ACL_SET_PERMSET, "sys_acl_set_permset" },
682 { SMB_VFS_OP_SYS_ACL_VALID, "sys_acl_valid" },
683 { SMB_VFS_OP_SYS_ACL_SET_FILE, "sys_acl_set_file" },
684 { SMB_VFS_OP_SYS_ACL_SET_FD, "sys_acl_set_fd" },
685 { SMB_VFS_OP_SYS_ACL_DELETE_DEF_FILE, "sys_acl_delete_def_file" },
686 { SMB_VFS_OP_SYS_ACL_GET_PERM, "sys_acl_get_perm" },
687 { SMB_VFS_OP_SYS_ACL_FREE_TEXT, "sys_acl_free_text" },
688 { SMB_VFS_OP_SYS_ACL_FREE_ACL, "sys_acl_free_acl" },
689 { SMB_VFS_OP_SYS_ACL_FREE_QUALIFIER, "sys_acl_free_qualifier" },
690 { SMB_VFS_OP_GETXATTR, "getxattr" },
691 { SMB_VFS_OP_LGETXATTR, "lgetxattr" },
692 { SMB_VFS_OP_FGETXATTR, "fgetxattr" },
693 { SMB_VFS_OP_LISTXATTR, "listxattr" },
694 { SMB_VFS_OP_LLISTXATTR, "llistxattr" },
695 { SMB_VFS_OP_FLISTXATTR, "flistxattr" },
696 { SMB_VFS_OP_REMOVEXATTR, "removexattr" },
697 { SMB_VFS_OP_LREMOVEXATTR, "lremovexattr" },
698 { SMB_VFS_OP_FREMOVEXATTR, "fremovexattr" },
699 { SMB_VFS_OP_SETXATTR, "setxattr" },
700 { SMB_VFS_OP_LSETXATTR, "lsetxattr" },
701 { SMB_VFS_OP_FSETXATTR, "fsetxattr" },
702 { SMB_VFS_OP_AIO_READ, "aio_read" },
703 { SMB_VFS_OP_AIO_WRITE, "aio_write" },
704 { SMB_VFS_OP_AIO_RETURN,"aio_return" },
705 { SMB_VFS_OP_AIO_CANCEL,"aio_cancel" },
706 { SMB_VFS_OP_AIO_ERROR, "aio_error" },
707 { SMB_VFS_OP_AIO_FSYNC, "aio_fsync" },
708 { SMB_VFS_OP_AIO_SUSPEND,"aio_suspend" },
709 { SMB_VFS_OP_AIO_FORCE, "aio_force" },
710 { SMB_VFS_OP_IS_OFFLINE, "aio_is_offline" },
711 { SMB_VFS_OP_SET_OFFLINE, "aio_set_offline" },
712 { SMB_VFS_OP_LAST, NULL }
715 static int audit_syslog_facility(vfs_handle_struct *handle)
717 static const struct enum_list enum_log_facilities[] = {
718 { LOG_USER, "USER" },
719 { LOG_LOCAL0, "LOCAL0" },
720 { LOG_LOCAL1, "LOCAL1" },
721 { LOG_LOCAL2, "LOCAL2" },
722 { LOG_LOCAL3, "LOCAL3" },
723 { LOG_LOCAL4, "LOCAL4" },
724 { LOG_LOCAL5, "LOCAL5" },
725 { LOG_LOCAL6, "LOCAL6" },
726 { LOG_LOCAL7, "LOCAL7" }
729 int facility;
731 facility = lp_parm_enum(SNUM(handle->conn), "full_audit", "facility", enum_log_facilities, LOG_USER);
733 return facility;
736 static int audit_syslog_priority(vfs_handle_struct *handle)
738 static const struct enum_list enum_log_priorities[] = {
739 { LOG_EMERG, "EMERG" },
740 { LOG_ALERT, "ALERT" },
741 { LOG_CRIT, "CRIT" },
742 { LOG_ERR, "ERR" },
743 { LOG_WARNING, "WARNING" },
744 { LOG_NOTICE, "NOTICE" },
745 { LOG_INFO, "INFO" },
746 { LOG_DEBUG, "DEBUG" }
749 int priority;
751 priority = lp_parm_enum(SNUM(handle->conn), "full_audit", "priority",
752 enum_log_priorities, LOG_NOTICE);
753 if (priority == -1) {
754 priority = LOG_WARNING;
757 return priority;
760 static char *audit_prefix(TALLOC_CTX *ctx, connection_struct *conn)
762 char *prefix = NULL;
763 char *result;
765 prefix = talloc_strdup(ctx,
766 lp_parm_const_string(SNUM(conn), "full_audit",
767 "prefix", "%u|%I"));
768 if (!prefix) {
769 return NULL;
771 result = talloc_sub_advanced(ctx,
772 lp_servicename(SNUM(conn)),
773 conn->server_info->unix_name,
774 conn->connectpath,
775 conn->server_info->utok.gid,
776 conn->server_info->sanitized_username,
777 pdb_get_domain(conn->server_info->sam_account),
778 prefix);
779 TALLOC_FREE(prefix);
780 return result;
783 static bool log_success(vfs_handle_struct *handle, vfs_op_type op)
785 struct vfs_full_audit_private_data *pd = NULL;
787 SMB_VFS_HANDLE_GET_DATA(handle, pd,
788 struct vfs_full_audit_private_data,
789 return True);
791 if (pd->success_ops == NULL) {
792 return True;
795 return bitmap_query(pd->success_ops, op);
798 static bool log_failure(vfs_handle_struct *handle, vfs_op_type op)
800 struct vfs_full_audit_private_data *pd = NULL;
802 SMB_VFS_HANDLE_GET_DATA(handle, pd,
803 struct vfs_full_audit_private_data,
804 return True);
806 if (pd->failure_ops == NULL)
807 return True;
809 return bitmap_query(pd->failure_ops, op);
812 static void init_bitmap(struct bitmap **bm, const char **ops)
814 bool log_all = False;
816 if (*bm != NULL)
817 return;
819 *bm = bitmap_allocate(SMB_VFS_OP_LAST);
821 if (*bm == NULL) {
822 DEBUG(0, ("Could not alloc bitmap -- "
823 "defaulting to logging everything\n"));
824 return;
827 while (*ops != NULL) {
828 int i;
829 bool found = False;
831 if (strequal(*ops, "all")) {
832 log_all = True;
833 break;
836 if (strequal(*ops, "none")) {
837 break;
840 for (i=0; i<SMB_VFS_OP_LAST; i++) {
841 if (vfs_op_names[i].name == NULL) {
842 smb_panic("vfs_full_audit.c: name table not "
843 "in sync with vfs.h\n");
846 if (strequal(*ops, vfs_op_names[i].name)) {
847 bitmap_set(*bm, i);
848 found = True;
851 if (!found) {
852 DEBUG(0, ("Could not find opname %s, logging all\n",
853 *ops));
854 log_all = True;
855 break;
857 ops += 1;
860 if (log_all) {
861 /* The query functions default to True */
862 bitmap_free(*bm);
863 *bm = NULL;
867 static const char *audit_opname(vfs_op_type op)
869 if (op >= SMB_VFS_OP_LAST)
870 return "INVALID VFS OP";
871 return vfs_op_names[op].name;
874 static void do_log(vfs_op_type op, bool success, vfs_handle_struct *handle,
875 const char *format, ...)
877 fstring err_msg;
878 char *audit_pre = NULL;
879 va_list ap;
880 char *op_msg = NULL;
882 if (success && (!log_success(handle, op)))
883 return;
885 if (!success && (!log_failure(handle, op)))
886 return;
888 if (success)
889 fstrcpy(err_msg, "ok");
890 else
891 fstr_sprintf(err_msg, "fail (%s)", strerror(errno));
893 va_start(ap, format);
894 op_msg = talloc_vasprintf(talloc_tos(), format, ap);
895 va_end(ap);
897 if (!op_msg) {
898 return;
901 audit_pre = audit_prefix(talloc_tos(), handle->conn);
902 syslog(audit_syslog_priority(handle), "%s|%s|%s|%s\n",
903 audit_pre ? audit_pre : "",
904 audit_opname(op), err_msg, op_msg);
906 TALLOC_FREE(audit_pre);
907 TALLOC_FREE(op_msg);
909 return;
912 /* Free function for the private data. */
914 static void free_private_data(void **p_data)
916 struct vfs_full_audit_private_data *pd = *(struct vfs_full_audit_private_data **)p_data;
918 if (pd->success_ops) {
919 bitmap_free(pd->success_ops);
921 if (pd->failure_ops) {
922 bitmap_free(pd->failure_ops);
924 SAFE_FREE(pd);
925 *p_data = NULL;
928 /* Implementation of vfs_ops. Pass everything on to the default
929 operation but log event first. */
931 static int smb_full_audit_connect(vfs_handle_struct *handle,
932 const char *svc, const char *user)
934 int result;
935 struct vfs_full_audit_private_data *pd = NULL;
936 const char *none[] = { NULL };
937 const char *all [] = { "all" };
939 if (!handle) {
940 return -1;
943 pd = SMB_MALLOC_P(struct vfs_full_audit_private_data);
944 if (!pd) {
945 return -1;
947 ZERO_STRUCTP(pd);
949 openlog("smbd_audit", 0, audit_syslog_facility(handle));
951 init_bitmap(&pd->success_ops,
952 lp_parm_string_list(SNUM(handle->conn), "full_audit", "success",
953 none));
954 init_bitmap(&pd->failure_ops,
955 lp_parm_string_list(SNUM(handle->conn), "full_audit", "failure",
956 all));
958 /* Store the private data. */
959 SMB_VFS_HANDLE_SET_DATA(handle, pd, free_private_data,
960 struct vfs_full_audit_private_data, return -1);
962 result = SMB_VFS_NEXT_CONNECT(handle, svc, user);
964 do_log(SMB_VFS_OP_CONNECT, True, handle,
965 "%s", svc);
967 return result;
970 static void smb_full_audit_disconnect(vfs_handle_struct *handle)
972 SMB_VFS_NEXT_DISCONNECT(handle);
974 do_log(SMB_VFS_OP_DISCONNECT, True, handle,
975 "%s", lp_servicename(SNUM(handle->conn)));
977 /* The bitmaps will be disconnected when the private
978 data is deleted. */
980 return;
983 static uint64_t smb_full_audit_disk_free(vfs_handle_struct *handle,
984 const char *path,
985 bool small_query, uint64_t *bsize,
986 uint64_t *dfree, uint64_t *dsize)
988 uint64_t result;
990 result = SMB_VFS_NEXT_DISK_FREE(handle, path, small_query, bsize,
991 dfree, dsize);
993 /* Don't have a reasonable notion of failure here */
995 do_log(SMB_VFS_OP_DISK_FREE, True, handle, "%s", path);
997 return result;
1000 static int smb_full_audit_get_quota(struct vfs_handle_struct *handle,
1001 enum SMB_QUOTA_TYPE qtype, unid_t id,
1002 SMB_DISK_QUOTA *qt)
1004 int result;
1006 result = SMB_VFS_NEXT_GET_QUOTA(handle, qtype, id, qt);
1008 do_log(SMB_VFS_OP_GET_QUOTA, (result >= 0), handle, "");
1010 return result;
1014 static int smb_full_audit_set_quota(struct vfs_handle_struct *handle,
1015 enum SMB_QUOTA_TYPE qtype, unid_t id,
1016 SMB_DISK_QUOTA *qt)
1018 int result;
1020 result = SMB_VFS_NEXT_SET_QUOTA(handle, qtype, id, qt);
1022 do_log(SMB_VFS_OP_SET_QUOTA, (result >= 0), handle, "");
1024 return result;
1027 static int smb_full_audit_get_shadow_copy_data(struct vfs_handle_struct *handle,
1028 struct files_struct *fsp,
1029 SHADOW_COPY_DATA *shadow_copy_data, bool labels)
1031 int result;
1033 result = SMB_VFS_NEXT_GET_SHADOW_COPY_DATA(handle, fsp, shadow_copy_data, labels);
1035 do_log(SMB_VFS_OP_GET_SHADOW_COPY_DATA, (result >= 0), handle, "");
1037 return result;
1040 static int smb_full_audit_statvfs(struct vfs_handle_struct *handle,
1041 const char *path,
1042 struct vfs_statvfs_struct *statbuf)
1044 int result;
1046 result = SMB_VFS_NEXT_STATVFS(handle, path, statbuf);
1048 do_log(SMB_VFS_OP_STATVFS, (result >= 0), handle, "");
1050 return result;
1053 static int smb_full_audit_fs_capabilities(struct vfs_handle_struct *handle)
1055 int result;
1057 result = SMB_VFS_NEXT_FS_CAPABILITIES(handle);
1059 do_log(SMB_VFS_OP_FS_CAPABILITIES, true, handle, "");
1061 return result;
1064 static SMB_STRUCT_DIR *smb_full_audit_opendir(vfs_handle_struct *handle,
1065 const char *fname, const char *mask, uint32 attr)
1067 SMB_STRUCT_DIR *result;
1069 result = SMB_VFS_NEXT_OPENDIR(handle, fname, mask, attr);
1071 do_log(SMB_VFS_OP_OPENDIR, (result != NULL), handle, "%s", fname);
1073 return result;
1076 static SMB_STRUCT_DIRENT *smb_full_audit_readdir(vfs_handle_struct *handle,
1077 SMB_STRUCT_DIR *dirp, SMB_STRUCT_STAT *sbuf)
1079 SMB_STRUCT_DIRENT *result;
1081 result = SMB_VFS_NEXT_READDIR(handle, dirp, sbuf);
1083 /* This operation has no reasonable error condition
1084 * (End of dir is also failure), so always succeed.
1086 do_log(SMB_VFS_OP_READDIR, True, handle, "");
1088 return result;
1091 static void smb_full_audit_seekdir(vfs_handle_struct *handle,
1092 SMB_STRUCT_DIR *dirp, long offset)
1094 SMB_VFS_NEXT_SEEKDIR(handle, dirp, offset);
1096 do_log(SMB_VFS_OP_SEEKDIR, True, handle, "");
1097 return;
1100 static long smb_full_audit_telldir(vfs_handle_struct *handle,
1101 SMB_STRUCT_DIR *dirp)
1103 long result;
1105 result = SMB_VFS_NEXT_TELLDIR(handle, dirp);
1107 do_log(SMB_VFS_OP_TELLDIR, True, handle, "");
1109 return result;
1112 static void smb_full_audit_rewinddir(vfs_handle_struct *handle,
1113 SMB_STRUCT_DIR *dirp)
1115 SMB_VFS_NEXT_REWINDDIR(handle, dirp);
1117 do_log(SMB_VFS_OP_REWINDDIR, True, handle, "");
1118 return;
1121 static int smb_full_audit_mkdir(vfs_handle_struct *handle,
1122 const char *path, mode_t mode)
1124 int result;
1126 result = SMB_VFS_NEXT_MKDIR(handle, path, mode);
1128 do_log(SMB_VFS_OP_MKDIR, (result >= 0), handle, "%s", path);
1130 return result;
1133 static int smb_full_audit_rmdir(vfs_handle_struct *handle,
1134 const char *path)
1136 int result;
1138 result = SMB_VFS_NEXT_RMDIR(handle, path);
1140 do_log(SMB_VFS_OP_RMDIR, (result >= 0), handle, "%s", path);
1142 return result;
1145 static int smb_full_audit_closedir(vfs_handle_struct *handle,
1146 SMB_STRUCT_DIR *dirp)
1148 int result;
1150 result = SMB_VFS_NEXT_CLOSEDIR(handle, dirp);
1152 do_log(SMB_VFS_OP_CLOSEDIR, (result >= 0), handle, "");
1154 return result;
1157 static void smb_full_audit_init_search_op(vfs_handle_struct *handle,
1158 SMB_STRUCT_DIR *dirp)
1160 SMB_VFS_NEXT_INIT_SEARCH_OP(handle, dirp);
1162 do_log(SMB_VFS_OP_INIT_SEARCH_OP, True, handle, "");
1163 return;
1166 static int smb_full_audit_open(vfs_handle_struct *handle,
1167 const char *fname, files_struct *fsp, int flags, mode_t mode)
1169 int result;
1171 result = SMB_VFS_NEXT_OPEN(handle, fname, fsp, flags, mode);
1173 do_log(SMB_VFS_OP_OPEN, (result >= 0), handle, "%s|%s",
1174 ((flags & O_WRONLY) || (flags & O_RDWR))?"w":"r",
1175 fname);
1177 return result;
1180 static NTSTATUS smb_full_audit_create_file(vfs_handle_struct *handle,
1181 struct smb_request *req,
1182 uint16_t root_dir_fid,
1183 const char *fname,
1184 uint32_t create_file_flags,
1185 uint32_t access_mask,
1186 uint32_t share_access,
1187 uint32_t create_disposition,
1188 uint32_t create_options,
1189 uint32_t file_attributes,
1190 uint32_t oplock_request,
1191 uint64_t allocation_size,
1192 struct security_descriptor *sd,
1193 struct ea_list *ea_list,
1194 files_struct **result_fsp,
1195 int *pinfo,
1196 SMB_STRUCT_STAT *psbuf)
1198 NTSTATUS result;
1200 result = SMB_VFS_NEXT_CREATE_FILE(
1201 handle, /* handle */
1202 req, /* req */
1203 root_dir_fid, /* root_dir_fid */
1204 fname, /* fname */
1205 create_file_flags, /* create_file_flags */
1206 access_mask, /* access_mask */
1207 share_access, /* share_access */
1208 create_disposition, /* create_disposition*/
1209 create_options, /* create_options */
1210 file_attributes, /* file_attributes */
1211 oplock_request, /* oplock_request */
1212 allocation_size, /* allocation_size */
1213 sd, /* sd */
1214 ea_list, /* ea_list */
1215 result_fsp, /* result */
1216 pinfo, /* pinfo */
1217 psbuf); /* psbuf */
1219 do_log(SMB_VFS_OP_CREATE_FILE, (NT_STATUS_IS_OK(result)), handle, "0x%x|%s",
1220 access_mask, fname);
1222 return result;
1225 static int smb_full_audit_close(vfs_handle_struct *handle, files_struct *fsp)
1227 int result;
1229 result = SMB_VFS_NEXT_CLOSE(handle, fsp);
1231 do_log(SMB_VFS_OP_CLOSE, (result >= 0), handle, "%s", fsp->fsp_name);
1233 return result;
1236 static ssize_t smb_full_audit_read(vfs_handle_struct *handle, files_struct *fsp,
1237 void *data, size_t n)
1239 ssize_t result;
1241 result = SMB_VFS_NEXT_READ(handle, fsp, data, n);
1243 do_log(SMB_VFS_OP_READ, (result >= 0), handle, "%s", fsp->fsp_name);
1245 return result;
1248 static ssize_t smb_full_audit_pread(vfs_handle_struct *handle, files_struct *fsp,
1249 void *data, size_t n, SMB_OFF_T offset)
1251 ssize_t result;
1253 result = SMB_VFS_NEXT_PREAD(handle, fsp, data, n, offset);
1255 do_log(SMB_VFS_OP_PREAD, (result >= 0), handle, "%s", fsp->fsp_name);
1257 return result;
1260 static ssize_t smb_full_audit_write(vfs_handle_struct *handle, files_struct *fsp,
1261 const void *data, size_t n)
1263 ssize_t result;
1265 result = SMB_VFS_NEXT_WRITE(handle, fsp, data, n);
1267 do_log(SMB_VFS_OP_WRITE, (result >= 0), handle, "%s", fsp->fsp_name);
1269 return result;
1272 static ssize_t smb_full_audit_pwrite(vfs_handle_struct *handle, files_struct *fsp,
1273 const void *data, size_t n,
1274 SMB_OFF_T offset)
1276 ssize_t result;
1278 result = SMB_VFS_NEXT_PWRITE(handle, fsp, data, n, offset);
1280 do_log(SMB_VFS_OP_PWRITE, (result >= 0), handle, "%s", fsp->fsp_name);
1282 return result;
1285 static SMB_OFF_T smb_full_audit_lseek(vfs_handle_struct *handle, files_struct *fsp,
1286 SMB_OFF_T offset, int whence)
1288 ssize_t result;
1290 result = SMB_VFS_NEXT_LSEEK(handle, fsp, offset, whence);
1292 do_log(SMB_VFS_OP_LSEEK, (result != (ssize_t)-1), handle,
1293 "%s", fsp->fsp_name);
1295 return result;
1298 static ssize_t smb_full_audit_sendfile(vfs_handle_struct *handle, int tofd,
1299 files_struct *fromfsp,
1300 const DATA_BLOB *hdr, SMB_OFF_T offset,
1301 size_t n)
1303 ssize_t result;
1305 result = SMB_VFS_NEXT_SENDFILE(handle, tofd, fromfsp, hdr, offset, n);
1307 do_log(SMB_VFS_OP_SENDFILE, (result >= 0), handle,
1308 "%s", fromfsp->fsp_name);
1310 return result;
1313 static ssize_t smb_full_audit_recvfile(vfs_handle_struct *handle, int fromfd,
1314 files_struct *tofsp,
1315 SMB_OFF_T offset,
1316 size_t n)
1318 ssize_t result;
1320 result = SMB_VFS_NEXT_RECVFILE(handle, fromfd, tofsp, offset, n);
1322 do_log(SMB_VFS_OP_RECVFILE, (result >= 0), handle,
1323 "%s", tofsp->fsp_name);
1325 return result;
1328 static int smb_full_audit_rename(vfs_handle_struct *handle,
1329 const char *oldname, const char *newname)
1331 int result;
1333 result = SMB_VFS_NEXT_RENAME(handle, oldname, newname);
1335 do_log(SMB_VFS_OP_RENAME, (result >= 0), handle, "%s|%s", oldname, newname);
1337 return result;
1340 static int smb_full_audit_fsync(vfs_handle_struct *handle, files_struct *fsp)
1342 int result;
1344 result = SMB_VFS_NEXT_FSYNC(handle, fsp);
1346 do_log(SMB_VFS_OP_FSYNC, (result >= 0), handle, "%s", fsp->fsp_name);
1348 return result;
1351 static int smb_full_audit_stat(vfs_handle_struct *handle,
1352 const char *fname, SMB_STRUCT_STAT *sbuf)
1354 int result;
1356 result = SMB_VFS_NEXT_STAT(handle, fname, sbuf);
1358 do_log(SMB_VFS_OP_STAT, (result >= 0), handle, "%s", fname);
1360 return result;
1363 static int smb_full_audit_fstat(vfs_handle_struct *handle, files_struct *fsp,
1364 SMB_STRUCT_STAT *sbuf)
1366 int result;
1368 result = SMB_VFS_NEXT_FSTAT(handle, fsp, sbuf);
1370 do_log(SMB_VFS_OP_FSTAT, (result >= 0), handle, "%s", fsp->fsp_name);
1372 return result;
1375 static int smb_full_audit_lstat(vfs_handle_struct *handle,
1376 const char *path, SMB_STRUCT_STAT *sbuf)
1378 int result;
1380 result = SMB_VFS_NEXT_LSTAT(handle, path, sbuf);
1382 do_log(SMB_VFS_OP_LSTAT, (result >= 0), handle, "%s", path);
1384 return result;
1387 static int smb_full_audit_get_alloc_size(vfs_handle_struct *handle,
1388 files_struct *fsp, const SMB_STRUCT_STAT *sbuf)
1390 int result;
1392 result = SMB_VFS_NEXT_GET_ALLOC_SIZE(handle, fsp, sbuf);
1394 do_log(SMB_VFS_OP_GET_ALLOC_SIZE, (result >= 0), handle, "%d", result);
1396 return result;
1399 static int smb_full_audit_unlink(vfs_handle_struct *handle,
1400 const char *path)
1402 int result;
1404 result = SMB_VFS_NEXT_UNLINK(handle, path);
1406 do_log(SMB_VFS_OP_UNLINK, (result >= 0), handle, "%s", path);
1408 return result;
1411 static int smb_full_audit_chmod(vfs_handle_struct *handle,
1412 const char *path, mode_t mode)
1414 int result;
1416 result = SMB_VFS_NEXT_CHMOD(handle, path, mode);
1418 do_log(SMB_VFS_OP_CHMOD, (result >= 0), handle, "%s|%o", path, mode);
1420 return result;
1423 static int smb_full_audit_fchmod(vfs_handle_struct *handle, files_struct *fsp,
1424 mode_t mode)
1426 int result;
1428 result = SMB_VFS_NEXT_FCHMOD(handle, fsp, mode);
1430 do_log(SMB_VFS_OP_FCHMOD, (result >= 0), handle,
1431 "%s|%o", fsp->fsp_name, mode);
1433 return result;
1436 static int smb_full_audit_chown(vfs_handle_struct *handle,
1437 const char *path, uid_t uid, gid_t gid)
1439 int result;
1441 result = SMB_VFS_NEXT_CHOWN(handle, path, uid, gid);
1443 do_log(SMB_VFS_OP_CHOWN, (result >= 0), handle, "%s|%ld|%ld",
1444 path, (long int)uid, (long int)gid);
1446 return result;
1449 static int smb_full_audit_fchown(vfs_handle_struct *handle, files_struct *fsp,
1450 uid_t uid, gid_t gid)
1452 int result;
1454 result = SMB_VFS_NEXT_FCHOWN(handle, fsp, uid, gid);
1456 do_log(SMB_VFS_OP_FCHOWN, (result >= 0), handle, "%s|%ld|%ld",
1457 fsp->fsp_name, (long int)uid, (long int)gid);
1459 return result;
1462 static int smb_full_audit_lchown(vfs_handle_struct *handle,
1463 const char *path, uid_t uid, gid_t gid)
1465 int result;
1467 result = SMB_VFS_NEXT_LCHOWN(handle, path, uid, gid);
1469 do_log(SMB_VFS_OP_LCHOWN, (result >= 0), handle, "%s|%ld|%ld",
1470 path, (long int)uid, (long int)gid);
1472 return result;
1475 static int smb_full_audit_chdir(vfs_handle_struct *handle,
1476 const char *path)
1478 int result;
1480 result = SMB_VFS_NEXT_CHDIR(handle, path);
1482 do_log(SMB_VFS_OP_CHDIR, (result >= 0), handle, "chdir|%s", path);
1484 return result;
1487 static char *smb_full_audit_getwd(vfs_handle_struct *handle,
1488 char *path)
1490 char *result;
1492 result = SMB_VFS_NEXT_GETWD(handle, path);
1494 do_log(SMB_VFS_OP_GETWD, (result != NULL), handle, "%s", path);
1496 return result;
1499 static int smb_full_audit_ntimes(vfs_handle_struct *handle,
1500 const char *path, struct smb_file_time *ft)
1502 int result;
1504 result = SMB_VFS_NEXT_NTIMES(handle, path, ft);
1506 do_log(SMB_VFS_OP_NTIMES, (result >= 0), handle, "%s", path);
1508 return result;
1511 static int smb_full_audit_ftruncate(vfs_handle_struct *handle, files_struct *fsp,
1512 SMB_OFF_T len)
1514 int result;
1516 result = SMB_VFS_NEXT_FTRUNCATE(handle, fsp, len);
1518 do_log(SMB_VFS_OP_FTRUNCATE, (result >= 0), handle,
1519 "%s", fsp->fsp_name);
1521 return result;
1524 static bool smb_full_audit_lock(vfs_handle_struct *handle, files_struct *fsp,
1525 int op, SMB_OFF_T offset, SMB_OFF_T count, int type)
1527 bool result;
1529 result = SMB_VFS_NEXT_LOCK(handle, fsp, op, offset, count, type);
1531 do_log(SMB_VFS_OP_LOCK, result, handle, "%s", fsp->fsp_name);
1533 return result;
1536 static int smb_full_audit_kernel_flock(struct vfs_handle_struct *handle,
1537 struct files_struct *fsp,
1538 uint32 share_mode)
1540 int result;
1542 result = SMB_VFS_NEXT_KERNEL_FLOCK(handle, fsp, share_mode);
1544 do_log(SMB_VFS_OP_KERNEL_FLOCK, (result >= 0), handle, "%s",
1545 fsp->fsp_name);
1547 return result;
1550 static int smb_full_audit_linux_setlease(vfs_handle_struct *handle, files_struct *fsp,
1551 int leasetype)
1553 int result;
1555 result = SMB_VFS_NEXT_LINUX_SETLEASE(handle, fsp, leasetype);
1557 do_log(SMB_VFS_OP_LINUX_SETLEASE, (result >= 0), handle, "%s",
1558 fsp->fsp_name);
1560 return result;
1563 static bool smb_full_audit_getlock(vfs_handle_struct *handle, files_struct *fsp,
1564 SMB_OFF_T *poffset, SMB_OFF_T *pcount, int *ptype, pid_t *ppid)
1566 bool result;
1568 result = SMB_VFS_NEXT_GETLOCK(handle, fsp, poffset, pcount, ptype, ppid);
1570 do_log(SMB_VFS_OP_GETLOCK, result, handle, "%s", fsp->fsp_name);
1572 return result;
1575 static int smb_full_audit_symlink(vfs_handle_struct *handle,
1576 const char *oldpath, const char *newpath)
1578 int result;
1580 result = SMB_VFS_NEXT_SYMLINK(handle, oldpath, newpath);
1582 do_log(SMB_VFS_OP_SYMLINK, (result >= 0), handle,
1583 "%s|%s", oldpath, newpath);
1585 return result;
1588 static int smb_full_audit_readlink(vfs_handle_struct *handle,
1589 const char *path, char *buf, size_t bufsiz)
1591 int result;
1593 result = SMB_VFS_NEXT_READLINK(handle, path, buf, bufsiz);
1595 do_log(SMB_VFS_OP_READLINK, (result >= 0), handle, "%s", path);
1597 return result;
1600 static int smb_full_audit_link(vfs_handle_struct *handle,
1601 const char *oldpath, const char *newpath)
1603 int result;
1605 result = SMB_VFS_NEXT_LINK(handle, oldpath, newpath);
1607 do_log(SMB_VFS_OP_LINK, (result >= 0), handle,
1608 "%s|%s", oldpath, newpath);
1610 return result;
1613 static int smb_full_audit_mknod(vfs_handle_struct *handle,
1614 const char *pathname, mode_t mode, SMB_DEV_T dev)
1616 int result;
1618 result = SMB_VFS_NEXT_MKNOD(handle, pathname, mode, dev);
1620 do_log(SMB_VFS_OP_MKNOD, (result >= 0), handle, "%s", pathname);
1622 return result;
1625 static char *smb_full_audit_realpath(vfs_handle_struct *handle,
1626 const char *path, char *resolved_path)
1628 char *result;
1630 result = SMB_VFS_NEXT_REALPATH(handle, path, resolved_path);
1632 do_log(SMB_VFS_OP_REALPATH, (result != NULL), handle, "%s", path);
1634 return result;
1637 static NTSTATUS smb_full_audit_notify_watch(struct vfs_handle_struct *handle,
1638 struct sys_notify_context *ctx,
1639 struct notify_entry *e,
1640 void (*callback)(struct sys_notify_context *ctx,
1641 void *private_data,
1642 struct notify_event *ev),
1643 void *private_data, void *handle_p)
1645 NTSTATUS result;
1647 result = SMB_VFS_NEXT_NOTIFY_WATCH(handle, ctx, e, callback, private_data, handle_p);
1649 do_log(SMB_VFS_OP_NOTIFY_WATCH, NT_STATUS_IS_OK(result), handle, "");
1651 return result;
1654 static int smb_full_audit_chflags(vfs_handle_struct *handle,
1655 const char *path, unsigned int flags)
1657 int result;
1659 result = SMB_VFS_NEXT_CHFLAGS(handle, path, flags);
1661 do_log(SMB_VFS_OP_CHFLAGS, (result != 0), handle, "%s", path);
1663 return result;
1666 static struct file_id smb_full_audit_file_id_create(struct vfs_handle_struct *handle,
1667 const SMB_STRUCT_STAT *sbuf)
1669 struct file_id id_zero;
1670 struct file_id result;
1672 ZERO_STRUCT(id_zero);
1674 result = SMB_VFS_NEXT_FILE_ID_CREATE(handle, sbuf);
1676 do_log(SMB_VFS_OP_FILE_ID_CREATE,
1677 !file_id_equal(&id_zero, &result),
1678 handle, "%s", file_id_string_tos(&result));
1680 return result;
1683 static NTSTATUS smb_full_audit_streaminfo(vfs_handle_struct *handle,
1684 struct files_struct *fsp,
1685 const char *fname,
1686 TALLOC_CTX *mem_ctx,
1687 unsigned int *pnum_streams,
1688 struct stream_struct **pstreams)
1690 NTSTATUS result;
1692 result = SMB_VFS_NEXT_STREAMINFO(handle, fsp, fname, mem_ctx,
1693 pnum_streams, pstreams);
1695 do_log(SMB_VFS_OP_STREAMINFO, NT_STATUS_IS_OK(result), handle,
1696 "%s", fname);
1698 return result;
1701 static int smb_full_audit_get_real_filename(struct vfs_handle_struct *handle,
1702 const char *path,
1703 const char *name,
1704 TALLOC_CTX *mem_ctx,
1705 char **found_name)
1707 int result;
1709 result = SMB_VFS_NEXT_GET_REAL_FILENAME(handle, path, name, mem_ctx,
1710 found_name);
1712 do_log(SMB_VFS_OP_GET_REAL_FILENAME, (result == 0), handle,
1713 "%s/%s->%s", path, name, (result == 0) ? "" : *found_name);
1715 return result;
1718 static NTSTATUS smb_full_audit_brl_lock_windows(struct vfs_handle_struct *handle,
1719 struct byte_range_lock *br_lck,
1720 struct lock_struct *plock,
1721 bool blocking_lock,
1722 struct blocking_lock_record *blr)
1724 NTSTATUS result;
1726 result = SMB_VFS_NEXT_BRL_LOCK_WINDOWS(handle, br_lck, plock,
1727 blocking_lock, blr);
1729 do_log(SMB_VFS_OP_BRL_LOCK_WINDOWS, NT_STATUS_IS_OK(result), handle,
1730 "%s:%llu-%llu. type=%d. blocking=%d", br_lck->fsp->fsp_name,
1731 plock->start, plock->size, plock->lock_type, blocking_lock );
1733 return result;
1736 static bool smb_full_audit_brl_unlock_windows(struct vfs_handle_struct *handle,
1737 struct messaging_context *msg_ctx,
1738 struct byte_range_lock *br_lck,
1739 const struct lock_struct *plock)
1741 bool result;
1743 result = SMB_VFS_NEXT_BRL_UNLOCK_WINDOWS(handle, msg_ctx, br_lck,
1744 plock);
1746 do_log(SMB_VFS_OP_BRL_UNLOCK_WINDOWS, (result == 0), handle,
1747 "%s:%llu-%llu:%d", br_lck->fsp->fsp_name, plock->start,
1748 plock->size, plock->lock_type);
1750 return result;
1753 static bool smb_full_audit_brl_cancel_windows(struct vfs_handle_struct *handle,
1754 struct byte_range_lock *br_lck,
1755 struct lock_struct *plock,
1756 struct blocking_lock_record *blr)
1758 bool result;
1760 result = SMB_VFS_NEXT_BRL_CANCEL_WINDOWS(handle, br_lck, plock, blr);
1762 do_log(SMB_VFS_OP_BRL_CANCEL_WINDOWS, (result == 0), handle,
1763 "%s:%llu-%llu:%d", br_lck->fsp->fsp_name, plock->start,
1764 plock->size);
1766 return result;
1769 static NTSTATUS smb_full_audit_fget_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
1770 uint32 security_info,
1771 SEC_DESC **ppdesc)
1773 NTSTATUS result;
1775 result = SMB_VFS_NEXT_FGET_NT_ACL(handle, fsp, security_info, ppdesc);
1777 do_log(SMB_VFS_OP_FGET_NT_ACL, NT_STATUS_IS_OK(result), handle,
1778 "%s", fsp->fsp_name);
1780 return result;
1783 static NTSTATUS smb_full_audit_get_nt_acl(vfs_handle_struct *handle,
1784 const char *name,
1785 uint32 security_info,
1786 SEC_DESC **ppdesc)
1788 NTSTATUS result;
1790 result = SMB_VFS_NEXT_GET_NT_ACL(handle, name, security_info, ppdesc);
1792 do_log(SMB_VFS_OP_GET_NT_ACL, NT_STATUS_IS_OK(result), handle,
1793 "%s", name);
1795 return result;
1798 static NTSTATUS smb_full_audit_fset_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
1799 uint32 security_info_sent,
1800 const SEC_DESC *psd)
1802 NTSTATUS result;
1804 result = SMB_VFS_NEXT_FSET_NT_ACL(handle, fsp, security_info_sent, psd);
1806 do_log(SMB_VFS_OP_FSET_NT_ACL, NT_STATUS_IS_OK(result), handle, "%s", fsp->fsp_name);
1808 return result;
1811 static int smb_full_audit_chmod_acl(vfs_handle_struct *handle,
1812 const char *path, mode_t mode)
1814 int result;
1816 result = SMB_VFS_NEXT_CHMOD_ACL(handle, path, mode);
1818 do_log(SMB_VFS_OP_CHMOD_ACL, (result >= 0), handle,
1819 "%s|%o", path, mode);
1821 return result;
1824 static int smb_full_audit_fchmod_acl(vfs_handle_struct *handle, files_struct *fsp,
1825 mode_t mode)
1827 int result;
1829 result = SMB_VFS_NEXT_FCHMOD_ACL(handle, fsp, mode);
1831 do_log(SMB_VFS_OP_FCHMOD_ACL, (result >= 0), handle,
1832 "%s|%o", fsp->fsp_name, mode);
1834 return result;
1837 static int smb_full_audit_sys_acl_get_entry(vfs_handle_struct *handle,
1839 SMB_ACL_T theacl, int entry_id,
1840 SMB_ACL_ENTRY_T *entry_p)
1842 int result;
1844 result = SMB_VFS_NEXT_SYS_ACL_GET_ENTRY(handle, theacl, entry_id,
1845 entry_p);
1847 do_log(SMB_VFS_OP_SYS_ACL_GET_ENTRY, (result >= 0), handle,
1848 "");
1850 return result;
1853 static int smb_full_audit_sys_acl_get_tag_type(vfs_handle_struct *handle,
1855 SMB_ACL_ENTRY_T entry_d,
1856 SMB_ACL_TAG_T *tag_type_p)
1858 int result;
1860 result = SMB_VFS_NEXT_SYS_ACL_GET_TAG_TYPE(handle, entry_d,
1861 tag_type_p);
1863 do_log(SMB_VFS_OP_SYS_ACL_GET_TAG_TYPE, (result >= 0), handle,
1864 "");
1866 return result;
1869 static int smb_full_audit_sys_acl_get_permset(vfs_handle_struct *handle,
1871 SMB_ACL_ENTRY_T entry_d,
1872 SMB_ACL_PERMSET_T *permset_p)
1874 int result;
1876 result = SMB_VFS_NEXT_SYS_ACL_GET_PERMSET(handle, entry_d,
1877 permset_p);
1879 do_log(SMB_VFS_OP_SYS_ACL_GET_PERMSET, (result >= 0), handle,
1880 "");
1882 return result;
1885 static void * smb_full_audit_sys_acl_get_qualifier(vfs_handle_struct *handle,
1887 SMB_ACL_ENTRY_T entry_d)
1889 void *result;
1891 result = SMB_VFS_NEXT_SYS_ACL_GET_QUALIFIER(handle, entry_d);
1893 do_log(SMB_VFS_OP_SYS_ACL_GET_QUALIFIER, (result != NULL), handle,
1894 "");
1896 return result;
1899 static SMB_ACL_T smb_full_audit_sys_acl_get_file(vfs_handle_struct *handle,
1900 const char *path_p,
1901 SMB_ACL_TYPE_T type)
1903 SMB_ACL_T result;
1905 result = SMB_VFS_NEXT_SYS_ACL_GET_FILE(handle, path_p, type);
1907 do_log(SMB_VFS_OP_SYS_ACL_GET_FILE, (result != NULL), handle,
1908 "%s", path_p);
1910 return result;
1913 static SMB_ACL_T smb_full_audit_sys_acl_get_fd(vfs_handle_struct *handle,
1914 files_struct *fsp)
1916 SMB_ACL_T result;
1918 result = SMB_VFS_NEXT_SYS_ACL_GET_FD(handle, fsp);
1920 do_log(SMB_VFS_OP_SYS_ACL_GET_FD, (result != NULL), handle,
1921 "%s", fsp->fsp_name);
1923 return result;
1926 static int smb_full_audit_sys_acl_clear_perms(vfs_handle_struct *handle,
1928 SMB_ACL_PERMSET_T permset)
1930 int result;
1932 result = SMB_VFS_NEXT_SYS_ACL_CLEAR_PERMS(handle, permset);
1934 do_log(SMB_VFS_OP_SYS_ACL_CLEAR_PERMS, (result >= 0), handle,
1935 "");
1937 return result;
1940 static int smb_full_audit_sys_acl_add_perm(vfs_handle_struct *handle,
1942 SMB_ACL_PERMSET_T permset,
1943 SMB_ACL_PERM_T perm)
1945 int result;
1947 result = SMB_VFS_NEXT_SYS_ACL_ADD_PERM(handle, permset, perm);
1949 do_log(SMB_VFS_OP_SYS_ACL_ADD_PERM, (result >= 0), handle,
1950 "");
1952 return result;
1955 static char * smb_full_audit_sys_acl_to_text(vfs_handle_struct *handle,
1956 SMB_ACL_T theacl,
1957 ssize_t *plen)
1959 char * result;
1961 result = SMB_VFS_NEXT_SYS_ACL_TO_TEXT(handle, theacl, plen);
1963 do_log(SMB_VFS_OP_SYS_ACL_TO_TEXT, (result != NULL), handle,
1964 "");
1966 return result;
1969 static SMB_ACL_T smb_full_audit_sys_acl_init(vfs_handle_struct *handle,
1971 int count)
1973 SMB_ACL_T result;
1975 result = SMB_VFS_NEXT_SYS_ACL_INIT(handle, count);
1977 do_log(SMB_VFS_OP_SYS_ACL_INIT, (result != NULL), handle,
1978 "");
1980 return result;
1983 static int smb_full_audit_sys_acl_create_entry(vfs_handle_struct *handle,
1984 SMB_ACL_T *pacl,
1985 SMB_ACL_ENTRY_T *pentry)
1987 int result;
1989 result = SMB_VFS_NEXT_SYS_ACL_CREATE_ENTRY(handle, pacl, pentry);
1991 do_log(SMB_VFS_OP_SYS_ACL_CREATE_ENTRY, (result >= 0), handle,
1992 "");
1994 return result;
1997 static int smb_full_audit_sys_acl_set_tag_type(vfs_handle_struct *handle,
1999 SMB_ACL_ENTRY_T entry,
2000 SMB_ACL_TAG_T tagtype)
2002 int result;
2004 result = SMB_VFS_NEXT_SYS_ACL_SET_TAG_TYPE(handle, entry,
2005 tagtype);
2007 do_log(SMB_VFS_OP_SYS_ACL_SET_TAG_TYPE, (result >= 0), handle,
2008 "");
2010 return result;
2013 static int smb_full_audit_sys_acl_set_qualifier(vfs_handle_struct *handle,
2015 SMB_ACL_ENTRY_T entry,
2016 void *qual)
2018 int result;
2020 result = SMB_VFS_NEXT_SYS_ACL_SET_QUALIFIER(handle, entry, qual);
2022 do_log(SMB_VFS_OP_SYS_ACL_SET_QUALIFIER, (result >= 0), handle,
2023 "");
2025 return result;
2028 static int smb_full_audit_sys_acl_set_permset(vfs_handle_struct *handle,
2030 SMB_ACL_ENTRY_T entry,
2031 SMB_ACL_PERMSET_T permset)
2033 int result;
2035 result = SMB_VFS_NEXT_SYS_ACL_SET_PERMSET(handle, entry, permset);
2037 do_log(SMB_VFS_OP_SYS_ACL_SET_PERMSET, (result >= 0), handle,
2038 "");
2040 return result;
2043 static int smb_full_audit_sys_acl_valid(vfs_handle_struct *handle,
2045 SMB_ACL_T theacl )
2047 int result;
2049 result = SMB_VFS_NEXT_SYS_ACL_VALID(handle, theacl);
2051 do_log(SMB_VFS_OP_SYS_ACL_VALID, (result >= 0), handle,
2052 "");
2054 return result;
2057 static int smb_full_audit_sys_acl_set_file(vfs_handle_struct *handle,
2059 const char *name, SMB_ACL_TYPE_T acltype,
2060 SMB_ACL_T theacl)
2062 int result;
2064 result = SMB_VFS_NEXT_SYS_ACL_SET_FILE(handle, name, acltype,
2065 theacl);
2067 do_log(SMB_VFS_OP_SYS_ACL_SET_FILE, (result >= 0), handle,
2068 "%s", name);
2070 return result;
2073 static int smb_full_audit_sys_acl_set_fd(vfs_handle_struct *handle, files_struct *fsp,
2074 SMB_ACL_T theacl)
2076 int result;
2078 result = SMB_VFS_NEXT_SYS_ACL_SET_FD(handle, fsp, theacl);
2080 do_log(SMB_VFS_OP_SYS_ACL_SET_FD, (result >= 0), handle,
2081 "%s", fsp->fsp_name);
2083 return result;
2086 static int smb_full_audit_sys_acl_delete_def_file(vfs_handle_struct *handle,
2088 const char *path)
2090 int result;
2092 result = SMB_VFS_NEXT_SYS_ACL_DELETE_DEF_FILE(handle, path);
2094 do_log(SMB_VFS_OP_SYS_ACL_DELETE_DEF_FILE, (result >= 0), handle,
2095 "%s", path);
2097 return result;
2100 static int smb_full_audit_sys_acl_get_perm(vfs_handle_struct *handle,
2102 SMB_ACL_PERMSET_T permset,
2103 SMB_ACL_PERM_T perm)
2105 int result;
2107 result = SMB_VFS_NEXT_SYS_ACL_GET_PERM(handle, permset, perm);
2109 do_log(SMB_VFS_OP_SYS_ACL_GET_PERM, (result >= 0), handle,
2110 "");
2112 return result;
2115 static int smb_full_audit_sys_acl_free_text(vfs_handle_struct *handle,
2117 char *text)
2119 int result;
2121 result = SMB_VFS_NEXT_SYS_ACL_FREE_TEXT(handle, text);
2123 do_log(SMB_VFS_OP_SYS_ACL_FREE_TEXT, (result >= 0), handle,
2124 "");
2126 return result;
2129 static int smb_full_audit_sys_acl_free_acl(vfs_handle_struct *handle,
2131 SMB_ACL_T posix_acl)
2133 int result;
2135 result = SMB_VFS_NEXT_SYS_ACL_FREE_ACL(handle, posix_acl);
2137 do_log(SMB_VFS_OP_SYS_ACL_FREE_ACL, (result >= 0), handle,
2138 "");
2140 return result;
2143 static int smb_full_audit_sys_acl_free_qualifier(vfs_handle_struct *handle,
2144 void *qualifier,
2145 SMB_ACL_TAG_T tagtype)
2147 int result;
2149 result = SMB_VFS_NEXT_SYS_ACL_FREE_QUALIFIER(handle, qualifier,
2150 tagtype);
2152 do_log(SMB_VFS_OP_SYS_ACL_FREE_QUALIFIER, (result >= 0), handle,
2153 "");
2155 return result;
2158 static ssize_t smb_full_audit_getxattr(struct vfs_handle_struct *handle,
2159 const char *path,
2160 const char *name, void *value, size_t size)
2162 ssize_t result;
2164 result = SMB_VFS_NEXT_GETXATTR(handle, path, name, value, size);
2166 do_log(SMB_VFS_OP_GETXATTR, (result >= 0), handle,
2167 "%s|%s", path, name);
2169 return result;
2172 static ssize_t smb_full_audit_lgetxattr(struct vfs_handle_struct *handle,
2173 const char *path, const char *name,
2174 void *value, size_t size)
2176 ssize_t result;
2178 result = SMB_VFS_NEXT_LGETXATTR(handle, path, name, value, size);
2180 do_log(SMB_VFS_OP_LGETXATTR, (result >= 0), handle,
2181 "%s|%s", path, name);
2183 return result;
2186 static ssize_t smb_full_audit_fgetxattr(struct vfs_handle_struct *handle,
2187 struct files_struct *fsp,
2188 const char *name, void *value, size_t size)
2190 ssize_t result;
2192 result = SMB_VFS_NEXT_FGETXATTR(handle, fsp, name, value, size);
2194 do_log(SMB_VFS_OP_FGETXATTR, (result >= 0), handle,
2195 "%s|%s", fsp->fsp_name, name);
2197 return result;
2200 static ssize_t smb_full_audit_listxattr(struct vfs_handle_struct *handle,
2201 const char *path, char *list, size_t size)
2203 ssize_t result;
2205 result = SMB_VFS_NEXT_LISTXATTR(handle, path, list, size);
2207 do_log(SMB_VFS_OP_LISTXATTR, (result >= 0), handle, "%s", path);
2209 return result;
2212 static ssize_t smb_full_audit_llistxattr(struct vfs_handle_struct *handle,
2213 const char *path, char *list, size_t size)
2215 ssize_t result;
2217 result = SMB_VFS_NEXT_LLISTXATTR(handle, path, list, size);
2219 do_log(SMB_VFS_OP_LLISTXATTR, (result >= 0), handle, "%s", path);
2221 return result;
2224 static ssize_t smb_full_audit_flistxattr(struct vfs_handle_struct *handle,
2225 struct files_struct *fsp, char *list,
2226 size_t size)
2228 ssize_t result;
2230 result = SMB_VFS_NEXT_FLISTXATTR(handle, fsp, list, size);
2232 do_log(SMB_VFS_OP_FLISTXATTR, (result >= 0), handle,
2233 "%s", fsp->fsp_name);
2235 return result;
2238 static int smb_full_audit_removexattr(struct vfs_handle_struct *handle,
2239 const char *path,
2240 const char *name)
2242 int result;
2244 result = SMB_VFS_NEXT_REMOVEXATTR(handle, path, name);
2246 do_log(SMB_VFS_OP_REMOVEXATTR, (result >= 0), handle,
2247 "%s|%s", path, name);
2249 return result;
2252 static int smb_full_audit_lremovexattr(struct vfs_handle_struct *handle,
2253 const char *path,
2254 const char *name)
2256 int result;
2258 result = SMB_VFS_NEXT_LREMOVEXATTR(handle, path, name);
2260 do_log(SMB_VFS_OP_LREMOVEXATTR, (result >= 0), handle,
2261 "%s|%s", path, name);
2263 return result;
2266 static int smb_full_audit_fremovexattr(struct vfs_handle_struct *handle,
2267 struct files_struct *fsp,
2268 const char *name)
2270 int result;
2272 result = SMB_VFS_NEXT_FREMOVEXATTR(handle, fsp, name);
2274 do_log(SMB_VFS_OP_FREMOVEXATTR, (result >= 0), handle,
2275 "%s|%s", fsp->fsp_name, name);
2277 return result;
2280 static int smb_full_audit_setxattr(struct vfs_handle_struct *handle,
2281 const char *path,
2282 const char *name, const void *value, size_t size,
2283 int flags)
2285 int result;
2287 result = SMB_VFS_NEXT_SETXATTR(handle, path, name, value, size,
2288 flags);
2290 do_log(SMB_VFS_OP_SETXATTR, (result >= 0), handle,
2291 "%s|%s", path, name);
2293 return result;
2296 static int smb_full_audit_lsetxattr(struct vfs_handle_struct *handle,
2297 const char *path,
2298 const char *name, const void *value, size_t size,
2299 int flags)
2301 int result;
2303 result = SMB_VFS_NEXT_LSETXATTR(handle, path, name, value, size,
2304 flags);
2306 do_log(SMB_VFS_OP_LSETXATTR, (result >= 0), handle,
2307 "%s|%s", path, name);
2309 return result;
2312 static int smb_full_audit_fsetxattr(struct vfs_handle_struct *handle,
2313 struct files_struct *fsp, const char *name,
2314 const void *value, size_t size, int flags)
2316 int result;
2318 result = SMB_VFS_NEXT_FSETXATTR(handle, fsp, name, value, size, flags);
2320 do_log(SMB_VFS_OP_FSETXATTR, (result >= 0), handle,
2321 "%s|%s", fsp->fsp_name, name);
2323 return result;
2326 static int smb_full_audit_aio_read(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb)
2328 int result;
2330 result = SMB_VFS_NEXT_AIO_READ(handle, fsp, aiocb);
2331 do_log(SMB_VFS_OP_AIO_READ, (result >= 0), handle,
2332 "%s", fsp->fsp_name);
2334 return result;
2337 static int smb_full_audit_aio_write(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb)
2339 int result;
2341 result = SMB_VFS_NEXT_AIO_WRITE(handle, fsp, aiocb);
2342 do_log(SMB_VFS_OP_AIO_WRITE, (result >= 0), handle,
2343 "%s", fsp->fsp_name);
2345 return result;
2348 static ssize_t smb_full_audit_aio_return(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb)
2350 int result;
2352 result = SMB_VFS_NEXT_AIO_RETURN(handle, fsp, aiocb);
2353 do_log(SMB_VFS_OP_AIO_RETURN, (result >= 0), handle,
2354 "%s", fsp->fsp_name);
2356 return result;
2359 static int smb_full_audit_aio_cancel(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb)
2361 int result;
2363 result = SMB_VFS_NEXT_AIO_CANCEL(handle, fsp, aiocb);
2364 do_log(SMB_VFS_OP_AIO_CANCEL, (result >= 0), handle,
2365 "%s", fsp->fsp_name);
2367 return result;
2370 static int smb_full_audit_aio_error(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb)
2372 int result;
2374 result = SMB_VFS_NEXT_AIO_ERROR(handle, fsp, aiocb);
2375 do_log(SMB_VFS_OP_AIO_ERROR, (result >= 0), handle,
2376 "%s", fsp->fsp_name);
2378 return result;
2381 static int smb_full_audit_aio_fsync(struct vfs_handle_struct *handle, struct files_struct *fsp, int op, SMB_STRUCT_AIOCB *aiocb)
2383 int result;
2385 result = SMB_VFS_NEXT_AIO_FSYNC(handle, fsp, op, aiocb);
2386 do_log(SMB_VFS_OP_AIO_FSYNC, (result >= 0), handle,
2387 "%s", fsp->fsp_name);
2389 return result;
2392 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)
2394 int result;
2396 result = SMB_VFS_NEXT_AIO_SUSPEND(handle, fsp, aiocb, n, ts);
2397 do_log(SMB_VFS_OP_AIO_SUSPEND, (result >= 0), handle,
2398 "%s", fsp->fsp_name);
2400 return result;
2403 static bool smb_full_audit_aio_force(struct vfs_handle_struct *handle,
2404 struct files_struct *fsp)
2406 bool result;
2408 result = SMB_VFS_NEXT_AIO_FORCE(handle, fsp);
2409 do_log(SMB_VFS_OP_AIO_FORCE, result, handle,
2410 "%s", fsp->fsp_name);
2412 return result;
2415 NTSTATUS vfs_full_audit_init(void);
2416 NTSTATUS vfs_full_audit_init(void)
2418 NTSTATUS ret = smb_register_vfs(SMB_VFS_INTERFACE_VERSION,
2419 "full_audit", audit_op_tuples);
2421 if (!NT_STATUS_IS_OK(ret))
2422 return ret;
2424 vfs_full_audit_debug_level = debug_add_class("full_audit");
2425 if (vfs_full_audit_debug_level == -1) {
2426 vfs_full_audit_debug_level = DBGC_VFS;
2427 DEBUG(0, ("vfs_full_audit: Couldn't register custom debugging "
2428 "class!\n"));
2429 } else {
2430 DEBUG(10, ("vfs_full_audit: Debug class number of "
2431 "'full_audit': %d\n", vfs_full_audit_debug_level));
2434 return ret;