2 * Auditing VFS module for samba. Log selected file operations to syslog
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:
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.
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.
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;
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,
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,
84 static int smb_full_audit_set_quota(struct vfs_handle_struct *handle,
85 enum SMB_QUOTA_TYPE qtype, unid_t id,
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,
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,
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,
109 static int smb_full_audit_closedir(vfs_handle_struct *handle,
110 SMB_STRUCT_DIR *dirp);
111 static void smb_full_audit_init_search_op(vfs_handle_struct *handle,
112 SMB_STRUCT_DIR *dirp);
113 static int smb_full_audit_open(vfs_handle_struct *handle,
114 struct smb_filename *smb_fnmae, files_struct *fsp, int flags, mode_t mode);
115 static NTSTATUS smb_full_audit_create_file(vfs_handle_struct *handle,
116 struct smb_request *req,
117 uint16_t root_dir_fid,
118 struct smb_filename *smb_fname,
119 uint32_t access_mask,
120 uint32_t share_access,
121 uint32_t create_disposition,
122 uint32_t create_options,
123 uint32_t file_attributes,
124 uint32_t oplock_request,
125 uint64_t allocation_size,
126 struct security_descriptor *sd,
127 struct ea_list *ea_list,
128 files_struct **result,
130 static int smb_full_audit_close(vfs_handle_struct *handle, files_struct *fsp);
131 static ssize_t smb_full_audit_read(vfs_handle_struct *handle, files_struct *fsp,
132 void *data, size_t n);
133 static ssize_t smb_full_audit_pread(vfs_handle_struct *handle, files_struct *fsp,
134 void *data, size_t n, SMB_OFF_T offset);
135 static ssize_t smb_full_audit_write(vfs_handle_struct *handle, files_struct *fsp,
136 const void *data, size_t n);
137 static ssize_t smb_full_audit_pwrite(vfs_handle_struct *handle, files_struct *fsp,
138 const void *data, size_t n,
140 static SMB_OFF_T smb_full_audit_lseek(vfs_handle_struct *handle, files_struct *fsp,
141 SMB_OFF_T offset, int whence);
142 static ssize_t smb_full_audit_sendfile(vfs_handle_struct *handle, int tofd,
143 files_struct *fromfsp,
144 const DATA_BLOB *hdr, SMB_OFF_T offset,
146 static ssize_t smb_full_audit_recvfile(vfs_handle_struct *handle, int fromfd,
150 static int smb_full_audit_rename(vfs_handle_struct *handle,
151 const char *oldname, const char *newname);
152 static int smb_full_audit_fsync(vfs_handle_struct *handle, files_struct *fsp);
153 static int smb_full_audit_stat(vfs_handle_struct *handle,
154 const char *fname, SMB_STRUCT_STAT *sbuf);
155 static int smb_full_audit_fstat(vfs_handle_struct *handle, files_struct *fsp,
156 SMB_STRUCT_STAT *sbuf);
157 static int smb_full_audit_lstat(vfs_handle_struct *handle,
158 const char *path, SMB_STRUCT_STAT *sbuf);
159 static int smb_full_audit_get_alloc_size(vfs_handle_struct *handle,
160 files_struct *fsp, const SMB_STRUCT_STAT *sbuf);
161 static int smb_full_audit_unlink(vfs_handle_struct *handle,
163 static int smb_full_audit_chmod(vfs_handle_struct *handle,
164 const char *path, mode_t mode);
165 static int smb_full_audit_fchmod(vfs_handle_struct *handle, files_struct *fsp,
167 static int smb_full_audit_chown(vfs_handle_struct *handle,
168 const char *path, uid_t uid, gid_t gid);
169 static int smb_full_audit_fchown(vfs_handle_struct *handle, files_struct *fsp,
170 uid_t uid, gid_t gid);
171 static int smb_full_audit_lchown(vfs_handle_struct *handle,
172 const char *path, uid_t uid, gid_t gid);
173 static int smb_full_audit_chdir(vfs_handle_struct *handle,
175 static char *smb_full_audit_getwd(vfs_handle_struct *handle,
177 static int smb_full_audit_ntimes(vfs_handle_struct *handle,
178 const char *path, struct smb_file_time *ft);
179 static int smb_full_audit_ftruncate(vfs_handle_struct *handle, files_struct *fsp,
181 static bool smb_full_audit_lock(vfs_handle_struct *handle, files_struct *fsp,
182 int op, SMB_OFF_T offset, SMB_OFF_T count, int type);
183 static int smb_full_audit_kernel_flock(struct vfs_handle_struct *handle,
184 struct files_struct *fsp,
186 static int smb_full_audit_linux_setlease(vfs_handle_struct *handle, files_struct *fsp,
188 static bool smb_full_audit_getlock(vfs_handle_struct *handle, files_struct *fsp,
189 SMB_OFF_T *poffset, SMB_OFF_T *pcount, int *ptype, pid_t *ppid);
190 static int smb_full_audit_symlink(vfs_handle_struct *handle,
191 const char *oldpath, const char *newpath);
192 static int smb_full_audit_readlink(vfs_handle_struct *handle,
193 const char *path, char *buf, size_t bufsiz);
194 static int smb_full_audit_link(vfs_handle_struct *handle,
195 const char *oldpath, const char *newpath);
196 static int smb_full_audit_mknod(vfs_handle_struct *handle,
197 const char *pathname, mode_t mode, SMB_DEV_T dev);
198 static char *smb_full_audit_realpath(vfs_handle_struct *handle,
199 const char *path, char *resolved_path);
200 static NTSTATUS smb_full_audit_notify_watch(struct vfs_handle_struct *handle,
201 struct sys_notify_context *ctx,
202 struct notify_entry *e,
203 void (*callback)(struct sys_notify_context *ctx,
205 struct notify_event *ev),
206 void *private_data, void *handle_p);
207 static int smb_full_audit_chflags(vfs_handle_struct *handle,
208 const char *path, unsigned int flags);
209 static struct file_id smb_full_audit_file_id_create(struct vfs_handle_struct *handle,
210 const SMB_STRUCT_STAT *sbuf);
211 static NTSTATUS smb_full_audit_streaminfo(vfs_handle_struct *handle,
212 struct files_struct *fsp,
215 unsigned int *pnum_streams,
216 struct stream_struct **pstreams);
217 static int smb_full_audit_get_real_filename(struct vfs_handle_struct *handle,
222 static const char *smb_full_audit_connectpath(vfs_handle_struct *handle,
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,
228 struct blocking_lock_record *blr);
229 static bool smb_full_audit_brl_unlock_windows(struct vfs_handle_struct *handle,
230 struct messaging_context *msg_ctx,
231 struct byte_range_lock *br_lck,
232 const struct lock_struct *plock);
233 static bool smb_full_audit_brl_cancel_windows(struct vfs_handle_struct *handle,
234 struct byte_range_lock *br_lck,
235 struct lock_struct *plock,
236 struct blocking_lock_record *blr);
237 static bool smb_full_audit_strict_lock(struct vfs_handle_struct *handle,
238 struct files_struct *fsp,
239 struct lock_struct *plock);
240 static void smb_full_audit_strict_unlock(struct vfs_handle_struct *handle,
241 struct files_struct *fsp,
242 struct lock_struct *plock);
243 static NTSTATUS smb_full_audit_fget_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
244 uint32 security_info,
246 static NTSTATUS smb_full_audit_get_nt_acl(vfs_handle_struct *handle,
247 const char *name, uint32 security_info,
249 static NTSTATUS smb_full_audit_fset_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
250 uint32 security_info_sent,
251 const SEC_DESC *psd);
252 static int smb_full_audit_chmod_acl(vfs_handle_struct *handle,
253 const char *path, mode_t mode);
254 static int smb_full_audit_fchmod_acl(vfs_handle_struct *handle, files_struct *fsp,
256 static int smb_full_audit_sys_acl_get_entry(vfs_handle_struct *handle,
257 SMB_ACL_T theacl, int entry_id,
258 SMB_ACL_ENTRY_T *entry_p);
259 static int smb_full_audit_sys_acl_get_tag_type(vfs_handle_struct *handle,
260 SMB_ACL_ENTRY_T entry_d,
261 SMB_ACL_TAG_T *tag_type_p);
262 static int smb_full_audit_sys_acl_get_permset(vfs_handle_struct *handle,
263 SMB_ACL_ENTRY_T entry_d,
264 SMB_ACL_PERMSET_T *permset_p);
265 static void * smb_full_audit_sys_acl_get_qualifier(vfs_handle_struct *handle,
266 SMB_ACL_ENTRY_T entry_d);
267 static SMB_ACL_T smb_full_audit_sys_acl_get_file(vfs_handle_struct *handle,
269 SMB_ACL_TYPE_T type);
270 static SMB_ACL_T smb_full_audit_sys_acl_get_fd(vfs_handle_struct *handle,
272 static int smb_full_audit_sys_acl_clear_perms(vfs_handle_struct *handle,
273 SMB_ACL_PERMSET_T permset);
274 static int smb_full_audit_sys_acl_add_perm(vfs_handle_struct *handle,
275 SMB_ACL_PERMSET_T permset,
276 SMB_ACL_PERM_T perm);
277 static char * smb_full_audit_sys_acl_to_text(vfs_handle_struct *handle,
280 static SMB_ACL_T smb_full_audit_sys_acl_init(vfs_handle_struct *handle,
282 static int smb_full_audit_sys_acl_create_entry(vfs_handle_struct *handle,
284 SMB_ACL_ENTRY_T *pentry);
285 static int smb_full_audit_sys_acl_set_tag_type(vfs_handle_struct *handle,
286 SMB_ACL_ENTRY_T entry,
287 SMB_ACL_TAG_T tagtype);
288 static int smb_full_audit_sys_acl_set_qualifier(vfs_handle_struct *handle,
289 SMB_ACL_ENTRY_T entry,
291 static int smb_full_audit_sys_acl_set_permset(vfs_handle_struct *handle,
292 SMB_ACL_ENTRY_T entry,
293 SMB_ACL_PERMSET_T permset);
294 static int smb_full_audit_sys_acl_valid(vfs_handle_struct *handle,
296 static int smb_full_audit_sys_acl_set_file(vfs_handle_struct *handle,
297 const char *name, SMB_ACL_TYPE_T acltype,
299 static int smb_full_audit_sys_acl_set_fd(vfs_handle_struct *handle, files_struct *fsp,
301 static int smb_full_audit_sys_acl_delete_def_file(vfs_handle_struct *handle,
303 static int smb_full_audit_sys_acl_get_perm(vfs_handle_struct *handle,
304 SMB_ACL_PERMSET_T permset,
305 SMB_ACL_PERM_T perm);
306 static int smb_full_audit_sys_acl_free_text(vfs_handle_struct *handle,
308 static int smb_full_audit_sys_acl_free_acl(vfs_handle_struct *handle,
309 SMB_ACL_T posix_acl);
310 static int smb_full_audit_sys_acl_free_qualifier(vfs_handle_struct *handle,
312 SMB_ACL_TAG_T tagtype);
313 static ssize_t smb_full_audit_getxattr(struct vfs_handle_struct *handle,
315 const char *name, void *value, size_t size);
316 static ssize_t smb_full_audit_lgetxattr(struct vfs_handle_struct *handle,
317 const char *path, const char *name,
318 void *value, size_t size);
319 static ssize_t smb_full_audit_fgetxattr(struct vfs_handle_struct *handle,
320 struct files_struct *fsp,
321 const char *name, void *value, size_t size);
322 static ssize_t smb_full_audit_listxattr(struct vfs_handle_struct *handle,
323 const char *path, char *list, size_t size);
324 static ssize_t smb_full_audit_llistxattr(struct vfs_handle_struct *handle,
325 const char *path, char *list, size_t size);
326 static ssize_t smb_full_audit_flistxattr(struct vfs_handle_struct *handle,
327 struct files_struct *fsp, char *list,
329 static int smb_full_audit_removexattr(struct vfs_handle_struct *handle,
332 static int smb_full_audit_lremovexattr(struct vfs_handle_struct *handle,
335 static int smb_full_audit_fremovexattr(struct vfs_handle_struct *handle,
336 struct files_struct *fsp,
338 static int smb_full_audit_setxattr(struct vfs_handle_struct *handle,
340 const char *name, const void *value, size_t size,
342 static int smb_full_audit_lsetxattr(struct vfs_handle_struct *handle,
344 const char *name, const void *value, size_t size,
346 static int smb_full_audit_fsetxattr(struct vfs_handle_struct *handle,
347 struct files_struct *fsp, const char *name,
348 const void *value, size_t size, int flags);
350 static int smb_full_audit_aio_read(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb);
351 static int smb_full_audit_aio_write(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb);
352 static ssize_t smb_full_audit_aio_return(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb);
353 static int smb_full_audit_aio_cancel(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb);
354 static int smb_full_audit_aio_error(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb);
355 static int smb_full_audit_aio_fsync(struct vfs_handle_struct *handle, struct files_struct *fsp, int op, SMB_STRUCT_AIOCB *aiocb);
356 static int smb_full_audit_aio_suspend(struct vfs_handle_struct *handle, struct files_struct *fsp, const SMB_STRUCT_AIOCB * const aiocb[], int n, const struct timespec *ts);
357 static bool smb_full_audit_aio_force(struct vfs_handle_struct *handle,
358 struct files_struct *fsp);
362 static vfs_op_tuple audit_op_tuples[] = {
364 /* Disk operations */
366 {SMB_VFS_OP(smb_full_audit_connect), SMB_VFS_OP_CONNECT,
367 SMB_VFS_LAYER_LOGGER},
368 {SMB_VFS_OP(smb_full_audit_disconnect), SMB_VFS_OP_DISCONNECT,
369 SMB_VFS_LAYER_LOGGER},
370 {SMB_VFS_OP(smb_full_audit_disk_free), SMB_VFS_OP_DISK_FREE,
371 SMB_VFS_LAYER_LOGGER},
372 {SMB_VFS_OP(smb_full_audit_get_quota), SMB_VFS_OP_GET_QUOTA,
373 SMB_VFS_LAYER_LOGGER},
374 {SMB_VFS_OP(smb_full_audit_set_quota), SMB_VFS_OP_SET_QUOTA,
375 SMB_VFS_LAYER_LOGGER},
376 {SMB_VFS_OP(smb_full_audit_get_shadow_copy_data), SMB_VFS_OP_GET_SHADOW_COPY_DATA,
377 SMB_VFS_LAYER_LOGGER},
378 {SMB_VFS_OP(smb_full_audit_statvfs), SMB_VFS_OP_STATVFS,
379 SMB_VFS_LAYER_LOGGER},
380 {SMB_VFS_OP(smb_full_audit_fs_capabilities), SMB_VFS_OP_FS_CAPABILITIES,
381 SMB_VFS_LAYER_LOGGER},
383 /* Directory operations */
385 {SMB_VFS_OP(smb_full_audit_opendir), SMB_VFS_OP_OPENDIR,
386 SMB_VFS_LAYER_LOGGER},
387 {SMB_VFS_OP(smb_full_audit_readdir), SMB_VFS_OP_READDIR,
388 SMB_VFS_LAYER_LOGGER},
389 {SMB_VFS_OP(smb_full_audit_seekdir), SMB_VFS_OP_SEEKDIR,
390 SMB_VFS_LAYER_LOGGER},
391 {SMB_VFS_OP(smb_full_audit_telldir), SMB_VFS_OP_TELLDIR,
392 SMB_VFS_LAYER_LOGGER},
393 {SMB_VFS_OP(smb_full_audit_rewinddir), SMB_VFS_OP_REWINDDIR,
394 SMB_VFS_LAYER_LOGGER},
395 {SMB_VFS_OP(smb_full_audit_mkdir), SMB_VFS_OP_MKDIR,
396 SMB_VFS_LAYER_LOGGER},
397 {SMB_VFS_OP(smb_full_audit_rmdir), SMB_VFS_OP_RMDIR,
398 SMB_VFS_LAYER_LOGGER},
399 {SMB_VFS_OP(smb_full_audit_closedir), SMB_VFS_OP_CLOSEDIR,
400 SMB_VFS_LAYER_LOGGER},
401 {SMB_VFS_OP(smb_full_audit_init_search_op), SMB_VFS_OP_INIT_SEARCH_OP,
402 SMB_VFS_LAYER_LOGGER},
404 /* File operations */
406 {SMB_VFS_OP(smb_full_audit_open), SMB_VFS_OP_OPEN,
407 SMB_VFS_LAYER_LOGGER},
408 {SMB_VFS_OP(smb_full_audit_create_file),SMB_VFS_OP_CREATE_FILE,
409 SMB_VFS_LAYER_LOGGER},
410 {SMB_VFS_OP(smb_full_audit_close), SMB_VFS_OP_CLOSE,
411 SMB_VFS_LAYER_LOGGER},
412 {SMB_VFS_OP(smb_full_audit_read), SMB_VFS_OP_READ,
413 SMB_VFS_LAYER_LOGGER},
414 {SMB_VFS_OP(smb_full_audit_pread), SMB_VFS_OP_PREAD,
415 SMB_VFS_LAYER_LOGGER},
416 {SMB_VFS_OP(smb_full_audit_write), SMB_VFS_OP_WRITE,
417 SMB_VFS_LAYER_LOGGER},
418 {SMB_VFS_OP(smb_full_audit_pwrite), SMB_VFS_OP_PWRITE,
419 SMB_VFS_LAYER_LOGGER},
420 {SMB_VFS_OP(smb_full_audit_lseek), SMB_VFS_OP_LSEEK,
421 SMB_VFS_LAYER_LOGGER},
422 {SMB_VFS_OP(smb_full_audit_sendfile), SMB_VFS_OP_SENDFILE,
423 SMB_VFS_LAYER_LOGGER},
424 {SMB_VFS_OP(smb_full_audit_recvfile), SMB_VFS_OP_RECVFILE,
425 SMB_VFS_LAYER_LOGGER},
426 {SMB_VFS_OP(smb_full_audit_rename), SMB_VFS_OP_RENAME,
427 SMB_VFS_LAYER_LOGGER},
428 {SMB_VFS_OP(smb_full_audit_fsync), SMB_VFS_OP_FSYNC,
429 SMB_VFS_LAYER_LOGGER},
430 {SMB_VFS_OP(smb_full_audit_stat), SMB_VFS_OP_STAT,
431 SMB_VFS_LAYER_LOGGER},
432 {SMB_VFS_OP(smb_full_audit_fstat), SMB_VFS_OP_FSTAT,
433 SMB_VFS_LAYER_LOGGER},
434 {SMB_VFS_OP(smb_full_audit_lstat), SMB_VFS_OP_LSTAT,
435 SMB_VFS_LAYER_LOGGER},
436 {SMB_VFS_OP(smb_full_audit_get_alloc_size), SMB_VFS_OP_GET_ALLOC_SIZE,
437 SMB_VFS_LAYER_LOGGER},
438 {SMB_VFS_OP(smb_full_audit_unlink), SMB_VFS_OP_UNLINK,
439 SMB_VFS_LAYER_LOGGER},
440 {SMB_VFS_OP(smb_full_audit_chmod), SMB_VFS_OP_CHMOD,
441 SMB_VFS_LAYER_LOGGER},
442 {SMB_VFS_OP(smb_full_audit_fchmod), SMB_VFS_OP_FCHMOD,
443 SMB_VFS_LAYER_LOGGER},
444 {SMB_VFS_OP(smb_full_audit_chown), SMB_VFS_OP_CHOWN,
445 SMB_VFS_LAYER_LOGGER},
446 {SMB_VFS_OP(smb_full_audit_fchown), SMB_VFS_OP_FCHOWN,
447 SMB_VFS_LAYER_LOGGER},
448 {SMB_VFS_OP(smb_full_audit_lchown), SMB_VFS_OP_LCHOWN,
449 SMB_VFS_LAYER_LOGGER},
450 {SMB_VFS_OP(smb_full_audit_chdir), SMB_VFS_OP_CHDIR,
451 SMB_VFS_LAYER_LOGGER},
452 {SMB_VFS_OP(smb_full_audit_getwd), SMB_VFS_OP_GETWD,
453 SMB_VFS_LAYER_LOGGER},
454 {SMB_VFS_OP(smb_full_audit_ntimes), SMB_VFS_OP_NTIMES,
455 SMB_VFS_LAYER_LOGGER},
456 {SMB_VFS_OP(smb_full_audit_ftruncate), SMB_VFS_OP_FTRUNCATE,
457 SMB_VFS_LAYER_LOGGER},
458 {SMB_VFS_OP(smb_full_audit_lock), SMB_VFS_OP_LOCK,
459 SMB_VFS_LAYER_LOGGER},
460 {SMB_VFS_OP(smb_full_audit_kernel_flock), SMB_VFS_OP_KERNEL_FLOCK,
461 SMB_VFS_LAYER_LOGGER},
462 {SMB_VFS_OP(smb_full_audit_linux_setlease), SMB_VFS_OP_LINUX_SETLEASE,
463 SMB_VFS_LAYER_LOGGER},
464 {SMB_VFS_OP(smb_full_audit_getlock), SMB_VFS_OP_GETLOCK,
465 SMB_VFS_LAYER_LOGGER},
466 {SMB_VFS_OP(smb_full_audit_symlink), SMB_VFS_OP_SYMLINK,
467 SMB_VFS_LAYER_LOGGER},
468 {SMB_VFS_OP(smb_full_audit_readlink), SMB_VFS_OP_READLINK,
469 SMB_VFS_LAYER_LOGGER},
470 {SMB_VFS_OP(smb_full_audit_link), SMB_VFS_OP_LINK,
471 SMB_VFS_LAYER_LOGGER},
472 {SMB_VFS_OP(smb_full_audit_mknod), SMB_VFS_OP_MKNOD,
473 SMB_VFS_LAYER_LOGGER},
474 {SMB_VFS_OP(smb_full_audit_realpath), SMB_VFS_OP_REALPATH,
475 SMB_VFS_LAYER_LOGGER},
476 {SMB_VFS_OP(smb_full_audit_notify_watch),SMB_VFS_OP_NOTIFY_WATCH,
477 SMB_VFS_LAYER_LOGGER},
478 {SMB_VFS_OP(smb_full_audit_chflags), SMB_VFS_OP_CHFLAGS,
479 SMB_VFS_LAYER_LOGGER},
480 {SMB_VFS_OP(smb_full_audit_file_id_create), SMB_VFS_OP_FILE_ID_CREATE,
481 SMB_VFS_LAYER_LOGGER},
482 {SMB_VFS_OP(smb_full_audit_streaminfo), SMB_VFS_OP_STREAMINFO,
483 SMB_VFS_LAYER_LOGGER},
484 {SMB_VFS_OP(smb_full_audit_get_real_filename), SMB_VFS_OP_GET_REAL_FILENAME,
485 SMB_VFS_LAYER_LOGGER},
486 {SMB_VFS_OP(smb_full_audit_connectpath), SMB_VFS_OP_CONNECTPATH,
487 SMB_VFS_LAYER_LOGGER},
488 {SMB_VFS_OP(smb_full_audit_brl_lock_windows), SMB_VFS_OP_BRL_LOCK_WINDOWS,
489 SMB_VFS_LAYER_LOGGER},
490 {SMB_VFS_OP(smb_full_audit_brl_unlock_windows), SMB_VFS_OP_BRL_UNLOCK_WINDOWS,
491 SMB_VFS_LAYER_LOGGER},
492 {SMB_VFS_OP(smb_full_audit_brl_cancel_windows), SMB_VFS_OP_BRL_CANCEL_WINDOWS,
493 SMB_VFS_LAYER_LOGGER},
494 {SMB_VFS_OP(smb_full_audit_strict_lock), SMB_VFS_OP_STRICT_LOCK,
495 SMB_VFS_LAYER_LOGGER},
496 {SMB_VFS_OP(smb_full_audit_strict_unlock), SMB_VFS_OP_STRICT_UNLOCK,
497 SMB_VFS_LAYER_LOGGER},
499 /* NT ACL operations. */
501 {SMB_VFS_OP(smb_full_audit_fget_nt_acl), SMB_VFS_OP_FGET_NT_ACL,
502 SMB_VFS_LAYER_LOGGER},
503 {SMB_VFS_OP(smb_full_audit_get_nt_acl), SMB_VFS_OP_GET_NT_ACL,
504 SMB_VFS_LAYER_LOGGER},
505 {SMB_VFS_OP(smb_full_audit_fset_nt_acl), SMB_VFS_OP_FSET_NT_ACL,
506 SMB_VFS_LAYER_LOGGER},
508 /* POSIX ACL operations. */
510 {SMB_VFS_OP(smb_full_audit_chmod_acl), SMB_VFS_OP_CHMOD_ACL,
511 SMB_VFS_LAYER_LOGGER},
512 {SMB_VFS_OP(smb_full_audit_fchmod_acl), SMB_VFS_OP_FCHMOD_ACL,
513 SMB_VFS_LAYER_LOGGER},
514 {SMB_VFS_OP(smb_full_audit_sys_acl_get_entry), SMB_VFS_OP_SYS_ACL_GET_ENTRY,
515 SMB_VFS_LAYER_LOGGER},
516 {SMB_VFS_OP(smb_full_audit_sys_acl_get_tag_type), SMB_VFS_OP_SYS_ACL_GET_TAG_TYPE,
517 SMB_VFS_LAYER_LOGGER},
518 {SMB_VFS_OP(smb_full_audit_sys_acl_get_permset), SMB_VFS_OP_SYS_ACL_GET_PERMSET,
519 SMB_VFS_LAYER_LOGGER},
520 {SMB_VFS_OP(smb_full_audit_sys_acl_get_qualifier), SMB_VFS_OP_SYS_ACL_GET_QUALIFIER,
521 SMB_VFS_LAYER_LOGGER},
522 {SMB_VFS_OP(smb_full_audit_sys_acl_get_file), SMB_VFS_OP_SYS_ACL_GET_FILE,
523 SMB_VFS_LAYER_LOGGER},
524 {SMB_VFS_OP(smb_full_audit_sys_acl_get_fd), SMB_VFS_OP_SYS_ACL_GET_FD,
525 SMB_VFS_LAYER_LOGGER},
526 {SMB_VFS_OP(smb_full_audit_sys_acl_clear_perms), SMB_VFS_OP_SYS_ACL_CLEAR_PERMS,
527 SMB_VFS_LAYER_LOGGER},
528 {SMB_VFS_OP(smb_full_audit_sys_acl_add_perm), SMB_VFS_OP_SYS_ACL_ADD_PERM,
529 SMB_VFS_LAYER_LOGGER},
530 {SMB_VFS_OP(smb_full_audit_sys_acl_to_text), SMB_VFS_OP_SYS_ACL_TO_TEXT,
531 SMB_VFS_LAYER_LOGGER},
532 {SMB_VFS_OP(smb_full_audit_sys_acl_init), SMB_VFS_OP_SYS_ACL_INIT,
533 SMB_VFS_LAYER_LOGGER},
534 {SMB_VFS_OP(smb_full_audit_sys_acl_create_entry), SMB_VFS_OP_SYS_ACL_CREATE_ENTRY,
535 SMB_VFS_LAYER_LOGGER},
536 {SMB_VFS_OP(smb_full_audit_sys_acl_set_tag_type), SMB_VFS_OP_SYS_ACL_SET_TAG_TYPE,
537 SMB_VFS_LAYER_LOGGER},
538 {SMB_VFS_OP(smb_full_audit_sys_acl_set_qualifier), SMB_VFS_OP_SYS_ACL_SET_QUALIFIER,
539 SMB_VFS_LAYER_LOGGER},
540 {SMB_VFS_OP(smb_full_audit_sys_acl_set_permset), SMB_VFS_OP_SYS_ACL_SET_PERMSET,
541 SMB_VFS_LAYER_LOGGER},
542 {SMB_VFS_OP(smb_full_audit_sys_acl_valid), SMB_VFS_OP_SYS_ACL_VALID,
543 SMB_VFS_LAYER_LOGGER},
544 {SMB_VFS_OP(smb_full_audit_sys_acl_set_file), SMB_VFS_OP_SYS_ACL_SET_FILE,
545 SMB_VFS_LAYER_LOGGER},
546 {SMB_VFS_OP(smb_full_audit_sys_acl_set_fd), SMB_VFS_OP_SYS_ACL_SET_FD,
547 SMB_VFS_LAYER_LOGGER},
548 {SMB_VFS_OP(smb_full_audit_sys_acl_delete_def_file), SMB_VFS_OP_SYS_ACL_DELETE_DEF_FILE,
549 SMB_VFS_LAYER_LOGGER},
550 {SMB_VFS_OP(smb_full_audit_sys_acl_get_perm), SMB_VFS_OP_SYS_ACL_GET_PERM,
551 SMB_VFS_LAYER_LOGGER},
552 {SMB_VFS_OP(smb_full_audit_sys_acl_free_text), SMB_VFS_OP_SYS_ACL_FREE_TEXT,
553 SMB_VFS_LAYER_LOGGER},
554 {SMB_VFS_OP(smb_full_audit_sys_acl_free_acl), SMB_VFS_OP_SYS_ACL_FREE_ACL,
555 SMB_VFS_LAYER_LOGGER},
556 {SMB_VFS_OP(smb_full_audit_sys_acl_free_qualifier), SMB_VFS_OP_SYS_ACL_FREE_QUALIFIER,
557 SMB_VFS_LAYER_LOGGER},
561 {SMB_VFS_OP(smb_full_audit_getxattr), SMB_VFS_OP_GETXATTR,
562 SMB_VFS_LAYER_LOGGER},
563 {SMB_VFS_OP(smb_full_audit_lgetxattr), SMB_VFS_OP_LGETXATTR,
564 SMB_VFS_LAYER_LOGGER},
565 {SMB_VFS_OP(smb_full_audit_fgetxattr), SMB_VFS_OP_FGETXATTR,
566 SMB_VFS_LAYER_LOGGER},
567 {SMB_VFS_OP(smb_full_audit_listxattr), SMB_VFS_OP_LISTXATTR,
568 SMB_VFS_LAYER_LOGGER},
569 {SMB_VFS_OP(smb_full_audit_llistxattr), SMB_VFS_OP_LLISTXATTR,
570 SMB_VFS_LAYER_LOGGER},
571 {SMB_VFS_OP(smb_full_audit_flistxattr), SMB_VFS_OP_FLISTXATTR,
572 SMB_VFS_LAYER_LOGGER},
573 {SMB_VFS_OP(smb_full_audit_removexattr), SMB_VFS_OP_REMOVEXATTR,
574 SMB_VFS_LAYER_LOGGER},
575 {SMB_VFS_OP(smb_full_audit_lremovexattr), SMB_VFS_OP_LREMOVEXATTR,
576 SMB_VFS_LAYER_LOGGER},
577 {SMB_VFS_OP(smb_full_audit_fremovexattr), SMB_VFS_OP_FREMOVEXATTR,
578 SMB_VFS_LAYER_LOGGER},
579 {SMB_VFS_OP(smb_full_audit_setxattr), SMB_VFS_OP_SETXATTR,
580 SMB_VFS_LAYER_LOGGER},
581 {SMB_VFS_OP(smb_full_audit_lsetxattr), SMB_VFS_OP_LSETXATTR,
582 SMB_VFS_LAYER_LOGGER},
583 {SMB_VFS_OP(smb_full_audit_fsetxattr), SMB_VFS_OP_FSETXATTR,
584 SMB_VFS_LAYER_LOGGER},
586 {SMB_VFS_OP(smb_full_audit_aio_read), SMB_VFS_OP_AIO_READ,
587 SMB_VFS_LAYER_LOGGER},
588 {SMB_VFS_OP(smb_full_audit_aio_write), SMB_VFS_OP_AIO_WRITE,
589 SMB_VFS_LAYER_LOGGER},
590 {SMB_VFS_OP(smb_full_audit_aio_return), SMB_VFS_OP_AIO_RETURN,
591 SMB_VFS_LAYER_LOGGER},
592 {SMB_VFS_OP(smb_full_audit_aio_cancel), SMB_VFS_OP_AIO_CANCEL,
593 SMB_VFS_LAYER_LOGGER},
594 {SMB_VFS_OP(smb_full_audit_aio_error), SMB_VFS_OP_AIO_ERROR,
595 SMB_VFS_LAYER_LOGGER},
596 {SMB_VFS_OP(smb_full_audit_aio_fsync), SMB_VFS_OP_AIO_FSYNC,
597 SMB_VFS_LAYER_LOGGER},
598 {SMB_VFS_OP(smb_full_audit_aio_suspend),SMB_VFS_OP_AIO_SUSPEND,
599 SMB_VFS_LAYER_LOGGER},
600 {SMB_VFS_OP(smb_full_audit_aio_force),SMB_VFS_OP_AIO_FORCE,
601 SMB_VFS_LAYER_LOGGER},
603 /* Finish VFS operations definition */
605 {SMB_VFS_OP(NULL), SMB_VFS_OP_NOOP,
609 /* The following array *must* be in the same order as defined in vfs.h */
615 { SMB_VFS_OP_CONNECT, "connect" },
616 { SMB_VFS_OP_DISCONNECT, "disconnect" },
617 { SMB_VFS_OP_DISK_FREE, "disk_free" },
618 { SMB_VFS_OP_GET_QUOTA, "get_quota" },
619 { SMB_VFS_OP_SET_QUOTA, "set_quota" },
620 { SMB_VFS_OP_GET_SHADOW_COPY_DATA, "get_shadow_copy_data" },
621 { SMB_VFS_OP_STATVFS, "statvfs" },
622 { SMB_VFS_OP_FS_CAPABILITIES, "fs_capabilities" },
623 { SMB_VFS_OP_OPENDIR, "opendir" },
624 { SMB_VFS_OP_READDIR, "readdir" },
625 { SMB_VFS_OP_SEEKDIR, "seekdir" },
626 { SMB_VFS_OP_TELLDIR, "telldir" },
627 { SMB_VFS_OP_REWINDDIR, "rewinddir" },
628 { SMB_VFS_OP_MKDIR, "mkdir" },
629 { SMB_VFS_OP_RMDIR, "rmdir" },
630 { SMB_VFS_OP_CLOSEDIR, "closedir" },
631 { SMB_VFS_OP_INIT_SEARCH_OP, "init_search_op" },
632 { SMB_VFS_OP_OPEN, "open" },
633 { SMB_VFS_OP_CREATE_FILE, "create_file" },
634 { SMB_VFS_OP_CLOSE, "close" },
635 { SMB_VFS_OP_READ, "read" },
636 { SMB_VFS_OP_PREAD, "pread" },
637 { SMB_VFS_OP_WRITE, "write" },
638 { SMB_VFS_OP_PWRITE, "pwrite" },
639 { SMB_VFS_OP_LSEEK, "lseek" },
640 { SMB_VFS_OP_SENDFILE, "sendfile" },
641 { SMB_VFS_OP_RECVFILE, "recvfile" },
642 { SMB_VFS_OP_RENAME, "rename" },
643 { SMB_VFS_OP_FSYNC, "fsync" },
644 { SMB_VFS_OP_STAT, "stat" },
645 { SMB_VFS_OP_FSTAT, "fstat" },
646 { SMB_VFS_OP_LSTAT, "lstat" },
647 { SMB_VFS_OP_GET_ALLOC_SIZE, "get_alloc_size" },
648 { SMB_VFS_OP_UNLINK, "unlink" },
649 { SMB_VFS_OP_CHMOD, "chmod" },
650 { SMB_VFS_OP_FCHMOD, "fchmod" },
651 { SMB_VFS_OP_CHOWN, "chown" },
652 { SMB_VFS_OP_FCHOWN, "fchown" },
653 { SMB_VFS_OP_LCHOWN, "lchown" },
654 { SMB_VFS_OP_CHDIR, "chdir" },
655 { SMB_VFS_OP_GETWD, "getwd" },
656 { SMB_VFS_OP_NTIMES, "ntimes" },
657 { SMB_VFS_OP_FTRUNCATE, "ftruncate" },
658 { SMB_VFS_OP_LOCK, "lock" },
659 { SMB_VFS_OP_KERNEL_FLOCK, "kernel_flock" },
660 { SMB_VFS_OP_LINUX_SETLEASE, "linux_setlease" },
661 { SMB_VFS_OP_GETLOCK, "getlock" },
662 { SMB_VFS_OP_SYMLINK, "symlink" },
663 { SMB_VFS_OP_READLINK, "readlink" },
664 { SMB_VFS_OP_LINK, "link" },
665 { SMB_VFS_OP_MKNOD, "mknod" },
666 { SMB_VFS_OP_REALPATH, "realpath" },
667 { SMB_VFS_OP_NOTIFY_WATCH, "notify_watch" },
668 { SMB_VFS_OP_CHFLAGS, "chflags" },
669 { SMB_VFS_OP_FILE_ID_CREATE, "file_id_create" },
670 { SMB_VFS_OP_STREAMINFO, "streaminfo" },
671 { SMB_VFS_OP_GET_REAL_FILENAME, "get_real_filename" },
672 { SMB_VFS_OP_CONNECTPATH, "connectpath" },
673 { SMB_VFS_OP_BRL_LOCK_WINDOWS, "brl_lock_windows" },
674 { SMB_VFS_OP_BRL_UNLOCK_WINDOWS, "brl_unlock_windows" },
675 { SMB_VFS_OP_BRL_CANCEL_WINDOWS, "brl_cancel_windows" },
676 { SMB_VFS_OP_STRICT_LOCK, "strict_lock" },
677 { SMB_VFS_OP_STRICT_UNLOCK, "strict_unlock" },
678 { SMB_VFS_OP_FGET_NT_ACL, "fget_nt_acl" },
679 { SMB_VFS_OP_GET_NT_ACL, "get_nt_acl" },
680 { SMB_VFS_OP_FSET_NT_ACL, "fset_nt_acl" },
681 { SMB_VFS_OP_CHMOD_ACL, "chmod_acl" },
682 { SMB_VFS_OP_FCHMOD_ACL, "fchmod_acl" },
683 { SMB_VFS_OP_SYS_ACL_GET_ENTRY, "sys_acl_get_entry" },
684 { SMB_VFS_OP_SYS_ACL_GET_TAG_TYPE, "sys_acl_get_tag_type" },
685 { SMB_VFS_OP_SYS_ACL_GET_PERMSET, "sys_acl_get_permset" },
686 { SMB_VFS_OP_SYS_ACL_GET_QUALIFIER, "sys_acl_get_qualifier" },
687 { SMB_VFS_OP_SYS_ACL_GET_FILE, "sys_acl_get_file" },
688 { SMB_VFS_OP_SYS_ACL_GET_FD, "sys_acl_get_fd" },
689 { SMB_VFS_OP_SYS_ACL_CLEAR_PERMS, "sys_acl_clear_perms" },
690 { SMB_VFS_OP_SYS_ACL_ADD_PERM, "sys_acl_add_perm" },
691 { SMB_VFS_OP_SYS_ACL_TO_TEXT, "sys_acl_to_text" },
692 { SMB_VFS_OP_SYS_ACL_INIT, "sys_acl_init" },
693 { SMB_VFS_OP_SYS_ACL_CREATE_ENTRY, "sys_acl_create_entry" },
694 { SMB_VFS_OP_SYS_ACL_SET_TAG_TYPE, "sys_acl_set_tag_type" },
695 { SMB_VFS_OP_SYS_ACL_SET_QUALIFIER, "sys_acl_set_qualifier" },
696 { SMB_VFS_OP_SYS_ACL_SET_PERMSET, "sys_acl_set_permset" },
697 { SMB_VFS_OP_SYS_ACL_VALID, "sys_acl_valid" },
698 { SMB_VFS_OP_SYS_ACL_SET_FILE, "sys_acl_set_file" },
699 { SMB_VFS_OP_SYS_ACL_SET_FD, "sys_acl_set_fd" },
700 { SMB_VFS_OP_SYS_ACL_DELETE_DEF_FILE, "sys_acl_delete_def_file" },
701 { SMB_VFS_OP_SYS_ACL_GET_PERM, "sys_acl_get_perm" },
702 { SMB_VFS_OP_SYS_ACL_FREE_TEXT, "sys_acl_free_text" },
703 { SMB_VFS_OP_SYS_ACL_FREE_ACL, "sys_acl_free_acl" },
704 { SMB_VFS_OP_SYS_ACL_FREE_QUALIFIER, "sys_acl_free_qualifier" },
705 { SMB_VFS_OP_GETXATTR, "getxattr" },
706 { SMB_VFS_OP_LGETXATTR, "lgetxattr" },
707 { SMB_VFS_OP_FGETXATTR, "fgetxattr" },
708 { SMB_VFS_OP_LISTXATTR, "listxattr" },
709 { SMB_VFS_OP_LLISTXATTR, "llistxattr" },
710 { SMB_VFS_OP_FLISTXATTR, "flistxattr" },
711 { SMB_VFS_OP_REMOVEXATTR, "removexattr" },
712 { SMB_VFS_OP_LREMOVEXATTR, "lremovexattr" },
713 { SMB_VFS_OP_FREMOVEXATTR, "fremovexattr" },
714 { SMB_VFS_OP_SETXATTR, "setxattr" },
715 { SMB_VFS_OP_LSETXATTR, "lsetxattr" },
716 { SMB_VFS_OP_FSETXATTR, "fsetxattr" },
717 { SMB_VFS_OP_AIO_READ, "aio_read" },
718 { SMB_VFS_OP_AIO_WRITE, "aio_write" },
719 { SMB_VFS_OP_AIO_RETURN,"aio_return" },
720 { SMB_VFS_OP_AIO_CANCEL,"aio_cancel" },
721 { SMB_VFS_OP_AIO_ERROR, "aio_error" },
722 { SMB_VFS_OP_AIO_FSYNC, "aio_fsync" },
723 { SMB_VFS_OP_AIO_SUSPEND,"aio_suspend" },
724 { SMB_VFS_OP_AIO_FORCE, "aio_force" },
725 { SMB_VFS_OP_IS_OFFLINE, "aio_is_offline" },
726 { SMB_VFS_OP_SET_OFFLINE, "aio_set_offline" },
727 { SMB_VFS_OP_LAST, NULL }
730 static int audit_syslog_facility(vfs_handle_struct *handle)
732 static const struct enum_list enum_log_facilities[] = {
733 { LOG_USER, "USER" },
734 { LOG_LOCAL0, "LOCAL0" },
735 { LOG_LOCAL1, "LOCAL1" },
736 { LOG_LOCAL2, "LOCAL2" },
737 { LOG_LOCAL3, "LOCAL3" },
738 { LOG_LOCAL4, "LOCAL4" },
739 { LOG_LOCAL5, "LOCAL5" },
740 { LOG_LOCAL6, "LOCAL6" },
741 { LOG_LOCAL7, "LOCAL7" }
746 facility = lp_parm_enum(SNUM(handle->conn), "full_audit", "facility", enum_log_facilities, LOG_USER);
751 static int audit_syslog_priority(vfs_handle_struct *handle)
753 static const struct enum_list enum_log_priorities[] = {
754 { LOG_EMERG, "EMERG" },
755 { LOG_ALERT, "ALERT" },
756 { LOG_CRIT, "CRIT" },
758 { LOG_WARNING, "WARNING" },
759 { LOG_NOTICE, "NOTICE" },
760 { LOG_INFO, "INFO" },
761 { LOG_DEBUG, "DEBUG" }
766 priority = lp_parm_enum(SNUM(handle->conn), "full_audit", "priority",
767 enum_log_priorities, LOG_NOTICE);
768 if (priority == -1) {
769 priority = LOG_WARNING;
775 static char *audit_prefix(TALLOC_CTX *ctx, connection_struct *conn)
780 prefix = talloc_strdup(ctx,
781 lp_parm_const_string(SNUM(conn), "full_audit",
786 result = talloc_sub_advanced(ctx,
787 lp_servicename(SNUM(conn)),
788 conn->server_info->unix_name,
790 conn->server_info->utok.gid,
791 conn->server_info->sanitized_username,
792 pdb_get_domain(conn->server_info->sam_account),
798 static bool log_success(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,
806 if (pd->success_ops == NULL) {
810 return bitmap_query(pd->success_ops, op);
813 static bool log_failure(vfs_handle_struct *handle, vfs_op_type op)
815 struct vfs_full_audit_private_data *pd = NULL;
817 SMB_VFS_HANDLE_GET_DATA(handle, pd,
818 struct vfs_full_audit_private_data,
821 if (pd->failure_ops == NULL)
824 return bitmap_query(pd->failure_ops, op);
827 static void init_bitmap(struct bitmap **bm, const char **ops)
829 bool log_all = False;
834 *bm = bitmap_allocate(SMB_VFS_OP_LAST);
837 DEBUG(0, ("Could not alloc bitmap -- "
838 "defaulting to logging everything\n"));
842 while (*ops != NULL) {
846 if (strequal(*ops, "all")) {
851 if (strequal(*ops, "none")) {
855 for (i=0; i<SMB_VFS_OP_LAST; i++) {
856 if (vfs_op_names[i].name == NULL) {
857 smb_panic("vfs_full_audit.c: name table not "
858 "in sync with vfs.h\n");
861 if (strequal(*ops, vfs_op_names[i].name)) {
867 DEBUG(0, ("Could not find opname %s, logging all\n",
876 /* The query functions default to True */
882 static const char *audit_opname(vfs_op_type op)
884 if (op >= SMB_VFS_OP_LAST)
885 return "INVALID VFS OP";
886 return vfs_op_names[op].name;
889 static void do_log(vfs_op_type op, bool success, vfs_handle_struct *handle,
890 const char *format, ...)
893 char *audit_pre = NULL;
897 if (success && (!log_success(handle, op)))
900 if (!success && (!log_failure(handle, op)))
904 fstrcpy(err_msg, "ok");
906 fstr_sprintf(err_msg, "fail (%s)", strerror(errno));
908 va_start(ap, format);
909 op_msg = talloc_vasprintf(talloc_tos(), format, ap);
916 audit_pre = audit_prefix(talloc_tos(), handle->conn);
917 syslog(audit_syslog_priority(handle), "%s|%s|%s|%s\n",
918 audit_pre ? audit_pre : "",
919 audit_opname(op), err_msg, op_msg);
921 TALLOC_FREE(audit_pre);
927 /* Free function for the private data. */
929 static void free_private_data(void **p_data)
931 struct vfs_full_audit_private_data *pd = *(struct vfs_full_audit_private_data **)p_data;
933 if (pd->success_ops) {
934 bitmap_free(pd->success_ops);
936 if (pd->failure_ops) {
937 bitmap_free(pd->failure_ops);
943 /* Implementation of vfs_ops. Pass everything on to the default
944 operation but log event first. */
946 static int smb_full_audit_connect(vfs_handle_struct *handle,
947 const char *svc, const char *user)
950 struct vfs_full_audit_private_data *pd = NULL;
951 const char *none[] = { NULL };
952 const char *all [] = { "all" };
958 pd = SMB_MALLOC_P(struct vfs_full_audit_private_data);
964 openlog("smbd_audit", 0, audit_syslog_facility(handle));
966 init_bitmap(&pd->success_ops,
967 lp_parm_string_list(SNUM(handle->conn), "full_audit", "success",
969 init_bitmap(&pd->failure_ops,
970 lp_parm_string_list(SNUM(handle->conn), "full_audit", "failure",
973 /* Store the private data. */
974 SMB_VFS_HANDLE_SET_DATA(handle, pd, free_private_data,
975 struct vfs_full_audit_private_data, return -1);
977 result = SMB_VFS_NEXT_CONNECT(handle, svc, user);
979 do_log(SMB_VFS_OP_CONNECT, True, handle,
985 static void smb_full_audit_disconnect(vfs_handle_struct *handle)
987 SMB_VFS_NEXT_DISCONNECT(handle);
989 do_log(SMB_VFS_OP_DISCONNECT, True, handle,
990 "%s", lp_servicename(SNUM(handle->conn)));
992 /* The bitmaps will be disconnected when the private
998 static uint64_t smb_full_audit_disk_free(vfs_handle_struct *handle,
1000 bool small_query, uint64_t *bsize,
1001 uint64_t *dfree, uint64_t *dsize)
1005 result = SMB_VFS_NEXT_DISK_FREE(handle, path, small_query, bsize,
1008 /* Don't have a reasonable notion of failure here */
1010 do_log(SMB_VFS_OP_DISK_FREE, True, handle, "%s", path);
1015 static int smb_full_audit_get_quota(struct vfs_handle_struct *handle,
1016 enum SMB_QUOTA_TYPE qtype, unid_t id,
1021 result = SMB_VFS_NEXT_GET_QUOTA(handle, qtype, id, qt);
1023 do_log(SMB_VFS_OP_GET_QUOTA, (result >= 0), handle, "");
1029 static int smb_full_audit_set_quota(struct vfs_handle_struct *handle,
1030 enum SMB_QUOTA_TYPE qtype, unid_t id,
1035 result = SMB_VFS_NEXT_SET_QUOTA(handle, qtype, id, qt);
1037 do_log(SMB_VFS_OP_SET_QUOTA, (result >= 0), handle, "");
1042 static int smb_full_audit_get_shadow_copy_data(struct vfs_handle_struct *handle,
1043 struct files_struct *fsp,
1044 SHADOW_COPY_DATA *shadow_copy_data, bool labels)
1048 result = SMB_VFS_NEXT_GET_SHADOW_COPY_DATA(handle, fsp, shadow_copy_data, labels);
1050 do_log(SMB_VFS_OP_GET_SHADOW_COPY_DATA, (result >= 0), handle, "");
1055 static int smb_full_audit_statvfs(struct vfs_handle_struct *handle,
1057 struct vfs_statvfs_struct *statbuf)
1061 result = SMB_VFS_NEXT_STATVFS(handle, path, statbuf);
1063 do_log(SMB_VFS_OP_STATVFS, (result >= 0), handle, "");
1068 static int smb_full_audit_fs_capabilities(struct vfs_handle_struct *handle)
1072 result = SMB_VFS_NEXT_FS_CAPABILITIES(handle);
1074 do_log(SMB_VFS_OP_FS_CAPABILITIES, true, handle, "");
1079 static SMB_STRUCT_DIR *smb_full_audit_opendir(vfs_handle_struct *handle,
1080 const char *fname, const char *mask, uint32 attr)
1082 SMB_STRUCT_DIR *result;
1084 result = SMB_VFS_NEXT_OPENDIR(handle, fname, mask, attr);
1086 do_log(SMB_VFS_OP_OPENDIR, (result != NULL), handle, "%s", fname);
1091 static SMB_STRUCT_DIRENT *smb_full_audit_readdir(vfs_handle_struct *handle,
1092 SMB_STRUCT_DIR *dirp, SMB_STRUCT_STAT *sbuf)
1094 SMB_STRUCT_DIRENT *result;
1096 result = SMB_VFS_NEXT_READDIR(handle, dirp, sbuf);
1098 /* This operation has no reasonable error condition
1099 * (End of dir is also failure), so always succeed.
1101 do_log(SMB_VFS_OP_READDIR, True, handle, "");
1106 static void smb_full_audit_seekdir(vfs_handle_struct *handle,
1107 SMB_STRUCT_DIR *dirp, long offset)
1109 SMB_VFS_NEXT_SEEKDIR(handle, dirp, offset);
1111 do_log(SMB_VFS_OP_SEEKDIR, True, handle, "");
1115 static long smb_full_audit_telldir(vfs_handle_struct *handle,
1116 SMB_STRUCT_DIR *dirp)
1120 result = SMB_VFS_NEXT_TELLDIR(handle, dirp);
1122 do_log(SMB_VFS_OP_TELLDIR, True, handle, "");
1127 static void smb_full_audit_rewinddir(vfs_handle_struct *handle,
1128 SMB_STRUCT_DIR *dirp)
1130 SMB_VFS_NEXT_REWINDDIR(handle, dirp);
1132 do_log(SMB_VFS_OP_REWINDDIR, True, handle, "");
1136 static int smb_full_audit_mkdir(vfs_handle_struct *handle,
1137 const char *path, mode_t mode)
1141 result = SMB_VFS_NEXT_MKDIR(handle, path, mode);
1143 do_log(SMB_VFS_OP_MKDIR, (result >= 0), handle, "%s", path);
1148 static int smb_full_audit_rmdir(vfs_handle_struct *handle,
1153 result = SMB_VFS_NEXT_RMDIR(handle, path);
1155 do_log(SMB_VFS_OP_RMDIR, (result >= 0), handle, "%s", path);
1160 static int smb_full_audit_closedir(vfs_handle_struct *handle,
1161 SMB_STRUCT_DIR *dirp)
1165 result = SMB_VFS_NEXT_CLOSEDIR(handle, dirp);
1167 do_log(SMB_VFS_OP_CLOSEDIR, (result >= 0), handle, "");
1172 static void smb_full_audit_init_search_op(vfs_handle_struct *handle,
1173 SMB_STRUCT_DIR *dirp)
1175 SMB_VFS_NEXT_INIT_SEARCH_OP(handle, dirp);
1177 do_log(SMB_VFS_OP_INIT_SEARCH_OP, True, handle, "");
1181 static int smb_full_audit_open(vfs_handle_struct *handle,
1182 struct smb_filename *smb_fname,
1183 files_struct *fsp, int flags, mode_t mode)
1187 result = SMB_VFS_NEXT_OPEN(handle, smb_fname, fsp, flags, mode);
1189 do_log(SMB_VFS_OP_OPEN, (result >= 0), handle, "%s|%s",
1190 ((flags & O_WRONLY) || (flags & O_RDWR))?"w":"r",
1191 smb_fname_str_dbg(smb_fname));
1196 static NTSTATUS smb_full_audit_create_file(vfs_handle_struct *handle,
1197 struct smb_request *req,
1198 uint16_t root_dir_fid,
1199 struct smb_filename *smb_fname,
1200 uint32_t access_mask,
1201 uint32_t share_access,
1202 uint32_t create_disposition,
1203 uint32_t create_options,
1204 uint32_t file_attributes,
1205 uint32_t oplock_request,
1206 uint64_t allocation_size,
1207 struct security_descriptor *sd,
1208 struct ea_list *ea_list,
1209 files_struct **result_fsp,
1214 result = SMB_VFS_NEXT_CREATE_FILE(
1215 handle, /* handle */
1217 root_dir_fid, /* root_dir_fid */
1218 smb_fname, /* fname */
1219 access_mask, /* access_mask */
1220 share_access, /* share_access */
1221 create_disposition, /* create_disposition*/
1222 create_options, /* create_options */
1223 file_attributes, /* file_attributes */
1224 oplock_request, /* oplock_request */
1225 allocation_size, /* allocation_size */
1227 ea_list, /* ea_list */
1228 result_fsp, /* result */
1231 do_log(SMB_VFS_OP_CREATE_FILE, (NT_STATUS_IS_OK(result)), handle, "0x%x|%s",
1232 access_mask, smb_fname_str_dbg(smb_fname));
1237 static int smb_full_audit_close(vfs_handle_struct *handle, files_struct *fsp)
1241 result = SMB_VFS_NEXT_CLOSE(handle, fsp);
1243 do_log(SMB_VFS_OP_CLOSE, (result >= 0), handle, "%s", fsp->fsp_name);
1248 static ssize_t smb_full_audit_read(vfs_handle_struct *handle, files_struct *fsp,
1249 void *data, size_t n)
1253 result = SMB_VFS_NEXT_READ(handle, fsp, data, n);
1255 do_log(SMB_VFS_OP_READ, (result >= 0), handle, "%s", fsp->fsp_name);
1260 static ssize_t smb_full_audit_pread(vfs_handle_struct *handle, files_struct *fsp,
1261 void *data, size_t n, SMB_OFF_T offset)
1265 result = SMB_VFS_NEXT_PREAD(handle, fsp, data, n, offset);
1267 do_log(SMB_VFS_OP_PREAD, (result >= 0), handle, "%s", fsp->fsp_name);
1272 static ssize_t smb_full_audit_write(vfs_handle_struct *handle, files_struct *fsp,
1273 const void *data, size_t n)
1277 result = SMB_VFS_NEXT_WRITE(handle, fsp, data, n);
1279 do_log(SMB_VFS_OP_WRITE, (result >= 0), handle, "%s", fsp->fsp_name);
1284 static ssize_t smb_full_audit_pwrite(vfs_handle_struct *handle, files_struct *fsp,
1285 const void *data, size_t n,
1290 result = SMB_VFS_NEXT_PWRITE(handle, fsp, data, n, offset);
1292 do_log(SMB_VFS_OP_PWRITE, (result >= 0), handle, "%s", fsp->fsp_name);
1297 static SMB_OFF_T smb_full_audit_lseek(vfs_handle_struct *handle, files_struct *fsp,
1298 SMB_OFF_T offset, int whence)
1302 result = SMB_VFS_NEXT_LSEEK(handle, fsp, offset, whence);
1304 do_log(SMB_VFS_OP_LSEEK, (result != (ssize_t)-1), handle,
1305 "%s", fsp->fsp_name);
1310 static ssize_t smb_full_audit_sendfile(vfs_handle_struct *handle, int tofd,
1311 files_struct *fromfsp,
1312 const DATA_BLOB *hdr, SMB_OFF_T offset,
1317 result = SMB_VFS_NEXT_SENDFILE(handle, tofd, fromfsp, hdr, offset, n);
1319 do_log(SMB_VFS_OP_SENDFILE, (result >= 0), handle,
1320 "%s", fromfsp->fsp_name);
1325 static ssize_t smb_full_audit_recvfile(vfs_handle_struct *handle, int fromfd,
1326 files_struct *tofsp,
1332 result = SMB_VFS_NEXT_RECVFILE(handle, fromfd, tofsp, offset, n);
1334 do_log(SMB_VFS_OP_RECVFILE, (result >= 0), handle,
1335 "%s", tofsp->fsp_name);
1340 static int smb_full_audit_rename(vfs_handle_struct *handle,
1341 const char *oldname, const char *newname)
1345 result = SMB_VFS_NEXT_RENAME(handle, oldname, newname);
1347 do_log(SMB_VFS_OP_RENAME, (result >= 0), handle, "%s|%s", oldname, newname);
1352 static int smb_full_audit_fsync(vfs_handle_struct *handle, files_struct *fsp)
1356 result = SMB_VFS_NEXT_FSYNC(handle, fsp);
1358 do_log(SMB_VFS_OP_FSYNC, (result >= 0), handle, "%s", fsp->fsp_name);
1363 static int smb_full_audit_stat(vfs_handle_struct *handle,
1364 const char *fname, SMB_STRUCT_STAT *sbuf)
1368 result = SMB_VFS_NEXT_STAT(handle, fname, sbuf);
1370 do_log(SMB_VFS_OP_STAT, (result >= 0), handle, "%s", fname);
1375 static int smb_full_audit_fstat(vfs_handle_struct *handle, files_struct *fsp,
1376 SMB_STRUCT_STAT *sbuf)
1380 result = SMB_VFS_NEXT_FSTAT(handle, fsp, sbuf);
1382 do_log(SMB_VFS_OP_FSTAT, (result >= 0), handle, "%s", fsp->fsp_name);
1387 static int smb_full_audit_lstat(vfs_handle_struct *handle,
1388 const char *path, SMB_STRUCT_STAT *sbuf)
1392 result = SMB_VFS_NEXT_LSTAT(handle, path, sbuf);
1394 do_log(SMB_VFS_OP_LSTAT, (result >= 0), handle, "%s", path);
1399 static int smb_full_audit_get_alloc_size(vfs_handle_struct *handle,
1400 files_struct *fsp, const SMB_STRUCT_STAT *sbuf)
1404 result = SMB_VFS_NEXT_GET_ALLOC_SIZE(handle, fsp, sbuf);
1406 do_log(SMB_VFS_OP_GET_ALLOC_SIZE, (result >= 0), handle, "%d", result);
1411 static int smb_full_audit_unlink(vfs_handle_struct *handle,
1416 result = SMB_VFS_NEXT_UNLINK(handle, path);
1418 do_log(SMB_VFS_OP_UNLINK, (result >= 0), handle, "%s", path);
1423 static int smb_full_audit_chmod(vfs_handle_struct *handle,
1424 const char *path, mode_t mode)
1428 result = SMB_VFS_NEXT_CHMOD(handle, path, mode);
1430 do_log(SMB_VFS_OP_CHMOD, (result >= 0), handle, "%s|%o", path, mode);
1435 static int smb_full_audit_fchmod(vfs_handle_struct *handle, files_struct *fsp,
1440 result = SMB_VFS_NEXT_FCHMOD(handle, fsp, mode);
1442 do_log(SMB_VFS_OP_FCHMOD, (result >= 0), handle,
1443 "%s|%o", fsp->fsp_name, mode);
1448 static int smb_full_audit_chown(vfs_handle_struct *handle,
1449 const char *path, uid_t uid, gid_t gid)
1453 result = SMB_VFS_NEXT_CHOWN(handle, path, uid, gid);
1455 do_log(SMB_VFS_OP_CHOWN, (result >= 0), handle, "%s|%ld|%ld",
1456 path, (long int)uid, (long int)gid);
1461 static int smb_full_audit_fchown(vfs_handle_struct *handle, files_struct *fsp,
1462 uid_t uid, gid_t gid)
1466 result = SMB_VFS_NEXT_FCHOWN(handle, fsp, uid, gid);
1468 do_log(SMB_VFS_OP_FCHOWN, (result >= 0), handle, "%s|%ld|%ld",
1469 fsp->fsp_name, (long int)uid, (long int)gid);
1474 static int smb_full_audit_lchown(vfs_handle_struct *handle,
1475 const char *path, uid_t uid, gid_t gid)
1479 result = SMB_VFS_NEXT_LCHOWN(handle, path, uid, gid);
1481 do_log(SMB_VFS_OP_LCHOWN, (result >= 0), handle, "%s|%ld|%ld",
1482 path, (long int)uid, (long int)gid);
1487 static int smb_full_audit_chdir(vfs_handle_struct *handle,
1492 result = SMB_VFS_NEXT_CHDIR(handle, path);
1494 do_log(SMB_VFS_OP_CHDIR, (result >= 0), handle, "chdir|%s", path);
1499 static char *smb_full_audit_getwd(vfs_handle_struct *handle,
1504 result = SMB_VFS_NEXT_GETWD(handle, path);
1506 do_log(SMB_VFS_OP_GETWD, (result != NULL), handle, "%s", path);
1511 static int smb_full_audit_ntimes(vfs_handle_struct *handle,
1512 const char *path, struct smb_file_time *ft)
1516 result = SMB_VFS_NEXT_NTIMES(handle, path, ft);
1518 do_log(SMB_VFS_OP_NTIMES, (result >= 0), handle, "%s", path);
1523 static int smb_full_audit_ftruncate(vfs_handle_struct *handle, files_struct *fsp,
1528 result = SMB_VFS_NEXT_FTRUNCATE(handle, fsp, len);
1530 do_log(SMB_VFS_OP_FTRUNCATE, (result >= 0), handle,
1531 "%s", fsp->fsp_name);
1536 static bool smb_full_audit_lock(vfs_handle_struct *handle, files_struct *fsp,
1537 int op, SMB_OFF_T offset, SMB_OFF_T count, int type)
1541 result = SMB_VFS_NEXT_LOCK(handle, fsp, op, offset, count, type);
1543 do_log(SMB_VFS_OP_LOCK, result, handle, "%s", fsp->fsp_name);
1548 static int smb_full_audit_kernel_flock(struct vfs_handle_struct *handle,
1549 struct files_struct *fsp,
1554 result = SMB_VFS_NEXT_KERNEL_FLOCK(handle, fsp, share_mode);
1556 do_log(SMB_VFS_OP_KERNEL_FLOCK, (result >= 0), handle, "%s",
1562 static int smb_full_audit_linux_setlease(vfs_handle_struct *handle, files_struct *fsp,
1567 result = SMB_VFS_NEXT_LINUX_SETLEASE(handle, fsp, leasetype);
1569 do_log(SMB_VFS_OP_LINUX_SETLEASE, (result >= 0), handle, "%s",
1575 static bool smb_full_audit_getlock(vfs_handle_struct *handle, files_struct *fsp,
1576 SMB_OFF_T *poffset, SMB_OFF_T *pcount, int *ptype, pid_t *ppid)
1580 result = SMB_VFS_NEXT_GETLOCK(handle, fsp, poffset, pcount, ptype, ppid);
1582 do_log(SMB_VFS_OP_GETLOCK, result, handle, "%s", fsp->fsp_name);
1587 static int smb_full_audit_symlink(vfs_handle_struct *handle,
1588 const char *oldpath, const char *newpath)
1592 result = SMB_VFS_NEXT_SYMLINK(handle, oldpath, newpath);
1594 do_log(SMB_VFS_OP_SYMLINK, (result >= 0), handle,
1595 "%s|%s", oldpath, newpath);
1600 static int smb_full_audit_readlink(vfs_handle_struct *handle,
1601 const char *path, char *buf, size_t bufsiz)
1605 result = SMB_VFS_NEXT_READLINK(handle, path, buf, bufsiz);
1607 do_log(SMB_VFS_OP_READLINK, (result >= 0), handle, "%s", path);
1612 static int smb_full_audit_link(vfs_handle_struct *handle,
1613 const char *oldpath, const char *newpath)
1617 result = SMB_VFS_NEXT_LINK(handle, oldpath, newpath);
1619 do_log(SMB_VFS_OP_LINK, (result >= 0), handle,
1620 "%s|%s", oldpath, newpath);
1625 static int smb_full_audit_mknod(vfs_handle_struct *handle,
1626 const char *pathname, mode_t mode, SMB_DEV_T dev)
1630 result = SMB_VFS_NEXT_MKNOD(handle, pathname, mode, dev);
1632 do_log(SMB_VFS_OP_MKNOD, (result >= 0), handle, "%s", pathname);
1637 static char *smb_full_audit_realpath(vfs_handle_struct *handle,
1638 const char *path, char *resolved_path)
1642 result = SMB_VFS_NEXT_REALPATH(handle, path, resolved_path);
1644 do_log(SMB_VFS_OP_REALPATH, (result != NULL), handle, "%s", path);
1649 static NTSTATUS smb_full_audit_notify_watch(struct vfs_handle_struct *handle,
1650 struct sys_notify_context *ctx,
1651 struct notify_entry *e,
1652 void (*callback)(struct sys_notify_context *ctx,
1654 struct notify_event *ev),
1655 void *private_data, void *handle_p)
1659 result = SMB_VFS_NEXT_NOTIFY_WATCH(handle, ctx, e, callback, private_data, handle_p);
1661 do_log(SMB_VFS_OP_NOTIFY_WATCH, NT_STATUS_IS_OK(result), handle, "");
1666 static int smb_full_audit_chflags(vfs_handle_struct *handle,
1667 const char *path, unsigned int flags)
1671 result = SMB_VFS_NEXT_CHFLAGS(handle, path, flags);
1673 do_log(SMB_VFS_OP_CHFLAGS, (result != 0), handle, "%s", path);
1678 static struct file_id smb_full_audit_file_id_create(struct vfs_handle_struct *handle,
1679 const SMB_STRUCT_STAT *sbuf)
1681 struct file_id id_zero;
1682 struct file_id result;
1684 ZERO_STRUCT(id_zero);
1686 result = SMB_VFS_NEXT_FILE_ID_CREATE(handle, sbuf);
1688 do_log(SMB_VFS_OP_FILE_ID_CREATE,
1689 !file_id_equal(&id_zero, &result),
1690 handle, "%s", file_id_string_tos(&result));
1695 static NTSTATUS smb_full_audit_streaminfo(vfs_handle_struct *handle,
1696 struct files_struct *fsp,
1698 TALLOC_CTX *mem_ctx,
1699 unsigned int *pnum_streams,
1700 struct stream_struct **pstreams)
1704 result = SMB_VFS_NEXT_STREAMINFO(handle, fsp, fname, mem_ctx,
1705 pnum_streams, pstreams);
1707 do_log(SMB_VFS_OP_STREAMINFO, NT_STATUS_IS_OK(result), handle,
1713 static int smb_full_audit_get_real_filename(struct vfs_handle_struct *handle,
1716 TALLOC_CTX *mem_ctx,
1721 result = SMB_VFS_NEXT_GET_REAL_FILENAME(handle, path, name, mem_ctx,
1724 do_log(SMB_VFS_OP_GET_REAL_FILENAME, (result == 0), handle,
1725 "%s/%s->%s", path, name, (result == 0) ? "" : *found_name);
1730 static const char *smb_full_audit_connectpath(vfs_handle_struct *handle,
1735 result = SMB_VFS_NEXT_CONNECTPATH(handle, fname);
1737 do_log(SMB_VFS_OP_CONNECTPATH, result != NULL, handle,
1743 static NTSTATUS smb_full_audit_brl_lock_windows(struct vfs_handle_struct *handle,
1744 struct byte_range_lock *br_lck,
1745 struct lock_struct *plock,
1747 struct blocking_lock_record *blr)
1751 result = SMB_VFS_NEXT_BRL_LOCK_WINDOWS(handle, br_lck, plock,
1752 blocking_lock, blr);
1754 do_log(SMB_VFS_OP_BRL_LOCK_WINDOWS, NT_STATUS_IS_OK(result), handle,
1755 "%s:%llu-%llu. type=%d. blocking=%d", br_lck->fsp->fsp_name,
1756 plock->start, plock->size, plock->lock_type, blocking_lock );
1761 static bool smb_full_audit_brl_unlock_windows(struct vfs_handle_struct *handle,
1762 struct messaging_context *msg_ctx,
1763 struct byte_range_lock *br_lck,
1764 const struct lock_struct *plock)
1768 result = SMB_VFS_NEXT_BRL_UNLOCK_WINDOWS(handle, msg_ctx, br_lck,
1771 do_log(SMB_VFS_OP_BRL_UNLOCK_WINDOWS, (result == 0), handle,
1772 "%s:%llu-%llu:%d", br_lck->fsp->fsp_name, plock->start,
1773 plock->size, plock->lock_type);
1778 static bool smb_full_audit_brl_cancel_windows(struct vfs_handle_struct *handle,
1779 struct byte_range_lock *br_lck,
1780 struct lock_struct *plock,
1781 struct blocking_lock_record *blr)
1785 result = SMB_VFS_NEXT_BRL_CANCEL_WINDOWS(handle, br_lck, plock, blr);
1787 do_log(SMB_VFS_OP_BRL_CANCEL_WINDOWS, (result == 0), handle,
1788 "%s:%llu-%llu:%d", br_lck->fsp->fsp_name, plock->start,
1794 static bool smb_full_audit_strict_lock(struct vfs_handle_struct *handle,
1795 struct files_struct *fsp,
1796 struct lock_struct *plock)
1800 result = SMB_VFS_NEXT_STRICT_LOCK(handle, fsp, plock);
1802 do_log(SMB_VFS_OP_STRICT_LOCK, result, handle,
1803 "%s:%llu-%llu:%d", fsp->fsp_name, plock->start,
1809 static void smb_full_audit_strict_unlock(struct vfs_handle_struct *handle,
1810 struct files_struct *fsp,
1811 struct lock_struct *plock)
1813 SMB_VFS_NEXT_STRICT_UNLOCK(handle, fsp, plock);
1815 do_log(SMB_VFS_OP_STRICT_UNLOCK, true, handle,
1816 "%s:%llu-%llu:%d", fsp->fsp_name, plock->start,
1822 static NTSTATUS smb_full_audit_fget_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
1823 uint32 security_info,
1828 result = SMB_VFS_NEXT_FGET_NT_ACL(handle, fsp, security_info, ppdesc);
1830 do_log(SMB_VFS_OP_FGET_NT_ACL, NT_STATUS_IS_OK(result), handle,
1831 "%s", fsp->fsp_name);
1836 static NTSTATUS smb_full_audit_get_nt_acl(vfs_handle_struct *handle,
1838 uint32 security_info,
1843 result = SMB_VFS_NEXT_GET_NT_ACL(handle, name, security_info, ppdesc);
1845 do_log(SMB_VFS_OP_GET_NT_ACL, NT_STATUS_IS_OK(result), handle,
1851 static NTSTATUS smb_full_audit_fset_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
1852 uint32 security_info_sent,
1853 const SEC_DESC *psd)
1857 result = SMB_VFS_NEXT_FSET_NT_ACL(handle, fsp, security_info_sent, psd);
1859 do_log(SMB_VFS_OP_FSET_NT_ACL, NT_STATUS_IS_OK(result), handle, "%s", fsp->fsp_name);
1864 static int smb_full_audit_chmod_acl(vfs_handle_struct *handle,
1865 const char *path, mode_t mode)
1869 result = SMB_VFS_NEXT_CHMOD_ACL(handle, path, mode);
1871 do_log(SMB_VFS_OP_CHMOD_ACL, (result >= 0), handle,
1872 "%s|%o", path, mode);
1877 static int smb_full_audit_fchmod_acl(vfs_handle_struct *handle, files_struct *fsp,
1882 result = SMB_VFS_NEXT_FCHMOD_ACL(handle, fsp, mode);
1884 do_log(SMB_VFS_OP_FCHMOD_ACL, (result >= 0), handle,
1885 "%s|%o", fsp->fsp_name, mode);
1890 static int smb_full_audit_sys_acl_get_entry(vfs_handle_struct *handle,
1892 SMB_ACL_T theacl, int entry_id,
1893 SMB_ACL_ENTRY_T *entry_p)
1897 result = SMB_VFS_NEXT_SYS_ACL_GET_ENTRY(handle, theacl, entry_id,
1900 do_log(SMB_VFS_OP_SYS_ACL_GET_ENTRY, (result >= 0), handle,
1906 static int smb_full_audit_sys_acl_get_tag_type(vfs_handle_struct *handle,
1908 SMB_ACL_ENTRY_T entry_d,
1909 SMB_ACL_TAG_T *tag_type_p)
1913 result = SMB_VFS_NEXT_SYS_ACL_GET_TAG_TYPE(handle, entry_d,
1916 do_log(SMB_VFS_OP_SYS_ACL_GET_TAG_TYPE, (result >= 0), handle,
1922 static int smb_full_audit_sys_acl_get_permset(vfs_handle_struct *handle,
1924 SMB_ACL_ENTRY_T entry_d,
1925 SMB_ACL_PERMSET_T *permset_p)
1929 result = SMB_VFS_NEXT_SYS_ACL_GET_PERMSET(handle, entry_d,
1932 do_log(SMB_VFS_OP_SYS_ACL_GET_PERMSET, (result >= 0), handle,
1938 static void * smb_full_audit_sys_acl_get_qualifier(vfs_handle_struct *handle,
1940 SMB_ACL_ENTRY_T entry_d)
1944 result = SMB_VFS_NEXT_SYS_ACL_GET_QUALIFIER(handle, entry_d);
1946 do_log(SMB_VFS_OP_SYS_ACL_GET_QUALIFIER, (result != NULL), handle,
1952 static SMB_ACL_T smb_full_audit_sys_acl_get_file(vfs_handle_struct *handle,
1954 SMB_ACL_TYPE_T type)
1958 result = SMB_VFS_NEXT_SYS_ACL_GET_FILE(handle, path_p, type);
1960 do_log(SMB_VFS_OP_SYS_ACL_GET_FILE, (result != NULL), handle,
1966 static SMB_ACL_T smb_full_audit_sys_acl_get_fd(vfs_handle_struct *handle,
1971 result = SMB_VFS_NEXT_SYS_ACL_GET_FD(handle, fsp);
1973 do_log(SMB_VFS_OP_SYS_ACL_GET_FD, (result != NULL), handle,
1974 "%s", fsp->fsp_name);
1979 static int smb_full_audit_sys_acl_clear_perms(vfs_handle_struct *handle,
1981 SMB_ACL_PERMSET_T permset)
1985 result = SMB_VFS_NEXT_SYS_ACL_CLEAR_PERMS(handle, permset);
1987 do_log(SMB_VFS_OP_SYS_ACL_CLEAR_PERMS, (result >= 0), handle,
1993 static int smb_full_audit_sys_acl_add_perm(vfs_handle_struct *handle,
1995 SMB_ACL_PERMSET_T permset,
1996 SMB_ACL_PERM_T perm)
2000 result = SMB_VFS_NEXT_SYS_ACL_ADD_PERM(handle, permset, perm);
2002 do_log(SMB_VFS_OP_SYS_ACL_ADD_PERM, (result >= 0), handle,
2008 static char * smb_full_audit_sys_acl_to_text(vfs_handle_struct *handle,
2014 result = SMB_VFS_NEXT_SYS_ACL_TO_TEXT(handle, theacl, plen);
2016 do_log(SMB_VFS_OP_SYS_ACL_TO_TEXT, (result != NULL), handle,
2022 static SMB_ACL_T smb_full_audit_sys_acl_init(vfs_handle_struct *handle,
2028 result = SMB_VFS_NEXT_SYS_ACL_INIT(handle, count);
2030 do_log(SMB_VFS_OP_SYS_ACL_INIT, (result != NULL), handle,
2036 static int smb_full_audit_sys_acl_create_entry(vfs_handle_struct *handle,
2038 SMB_ACL_ENTRY_T *pentry)
2042 result = SMB_VFS_NEXT_SYS_ACL_CREATE_ENTRY(handle, pacl, pentry);
2044 do_log(SMB_VFS_OP_SYS_ACL_CREATE_ENTRY, (result >= 0), handle,
2050 static int smb_full_audit_sys_acl_set_tag_type(vfs_handle_struct *handle,
2052 SMB_ACL_ENTRY_T entry,
2053 SMB_ACL_TAG_T tagtype)
2057 result = SMB_VFS_NEXT_SYS_ACL_SET_TAG_TYPE(handle, entry,
2060 do_log(SMB_VFS_OP_SYS_ACL_SET_TAG_TYPE, (result >= 0), handle,
2066 static int smb_full_audit_sys_acl_set_qualifier(vfs_handle_struct *handle,
2068 SMB_ACL_ENTRY_T entry,
2073 result = SMB_VFS_NEXT_SYS_ACL_SET_QUALIFIER(handle, entry, qual);
2075 do_log(SMB_VFS_OP_SYS_ACL_SET_QUALIFIER, (result >= 0), handle,
2081 static int smb_full_audit_sys_acl_set_permset(vfs_handle_struct *handle,
2083 SMB_ACL_ENTRY_T entry,
2084 SMB_ACL_PERMSET_T permset)
2088 result = SMB_VFS_NEXT_SYS_ACL_SET_PERMSET(handle, entry, permset);
2090 do_log(SMB_VFS_OP_SYS_ACL_SET_PERMSET, (result >= 0), handle,
2096 static int smb_full_audit_sys_acl_valid(vfs_handle_struct *handle,
2102 result = SMB_VFS_NEXT_SYS_ACL_VALID(handle, theacl);
2104 do_log(SMB_VFS_OP_SYS_ACL_VALID, (result >= 0), handle,
2110 static int smb_full_audit_sys_acl_set_file(vfs_handle_struct *handle,
2112 const char *name, SMB_ACL_TYPE_T acltype,
2117 result = SMB_VFS_NEXT_SYS_ACL_SET_FILE(handle, name, acltype,
2120 do_log(SMB_VFS_OP_SYS_ACL_SET_FILE, (result >= 0), handle,
2126 static int smb_full_audit_sys_acl_set_fd(vfs_handle_struct *handle, files_struct *fsp,
2131 result = SMB_VFS_NEXT_SYS_ACL_SET_FD(handle, fsp, theacl);
2133 do_log(SMB_VFS_OP_SYS_ACL_SET_FD, (result >= 0), handle,
2134 "%s", fsp->fsp_name);
2139 static int smb_full_audit_sys_acl_delete_def_file(vfs_handle_struct *handle,
2145 result = SMB_VFS_NEXT_SYS_ACL_DELETE_DEF_FILE(handle, path);
2147 do_log(SMB_VFS_OP_SYS_ACL_DELETE_DEF_FILE, (result >= 0), handle,
2153 static int smb_full_audit_sys_acl_get_perm(vfs_handle_struct *handle,
2155 SMB_ACL_PERMSET_T permset,
2156 SMB_ACL_PERM_T perm)
2160 result = SMB_VFS_NEXT_SYS_ACL_GET_PERM(handle, permset, perm);
2162 do_log(SMB_VFS_OP_SYS_ACL_GET_PERM, (result >= 0), handle,
2168 static int smb_full_audit_sys_acl_free_text(vfs_handle_struct *handle,
2174 result = SMB_VFS_NEXT_SYS_ACL_FREE_TEXT(handle, text);
2176 do_log(SMB_VFS_OP_SYS_ACL_FREE_TEXT, (result >= 0), handle,
2182 static int smb_full_audit_sys_acl_free_acl(vfs_handle_struct *handle,
2184 SMB_ACL_T posix_acl)
2188 result = SMB_VFS_NEXT_SYS_ACL_FREE_ACL(handle, posix_acl);
2190 do_log(SMB_VFS_OP_SYS_ACL_FREE_ACL, (result >= 0), handle,
2196 static int smb_full_audit_sys_acl_free_qualifier(vfs_handle_struct *handle,
2198 SMB_ACL_TAG_T tagtype)
2202 result = SMB_VFS_NEXT_SYS_ACL_FREE_QUALIFIER(handle, qualifier,
2205 do_log(SMB_VFS_OP_SYS_ACL_FREE_QUALIFIER, (result >= 0), handle,
2211 static ssize_t smb_full_audit_getxattr(struct vfs_handle_struct *handle,
2213 const char *name, void *value, size_t size)
2217 result = SMB_VFS_NEXT_GETXATTR(handle, path, name, value, size);
2219 do_log(SMB_VFS_OP_GETXATTR, (result >= 0), handle,
2220 "%s|%s", path, name);
2225 static ssize_t smb_full_audit_lgetxattr(struct vfs_handle_struct *handle,
2226 const char *path, const char *name,
2227 void *value, size_t size)
2231 result = SMB_VFS_NEXT_LGETXATTR(handle, path, name, value, size);
2233 do_log(SMB_VFS_OP_LGETXATTR, (result >= 0), handle,
2234 "%s|%s", path, name);
2239 static ssize_t smb_full_audit_fgetxattr(struct vfs_handle_struct *handle,
2240 struct files_struct *fsp,
2241 const char *name, void *value, size_t size)
2245 result = SMB_VFS_NEXT_FGETXATTR(handle, fsp, name, value, size);
2247 do_log(SMB_VFS_OP_FGETXATTR, (result >= 0), handle,
2248 "%s|%s", fsp->fsp_name, name);
2253 static ssize_t smb_full_audit_listxattr(struct vfs_handle_struct *handle,
2254 const char *path, char *list, size_t size)
2258 result = SMB_VFS_NEXT_LISTXATTR(handle, path, list, size);
2260 do_log(SMB_VFS_OP_LISTXATTR, (result >= 0), handle, "%s", path);
2265 static ssize_t smb_full_audit_llistxattr(struct vfs_handle_struct *handle,
2266 const char *path, char *list, size_t size)
2270 result = SMB_VFS_NEXT_LLISTXATTR(handle, path, list, size);
2272 do_log(SMB_VFS_OP_LLISTXATTR, (result >= 0), handle, "%s", path);
2277 static ssize_t smb_full_audit_flistxattr(struct vfs_handle_struct *handle,
2278 struct files_struct *fsp, char *list,
2283 result = SMB_VFS_NEXT_FLISTXATTR(handle, fsp, list, size);
2285 do_log(SMB_VFS_OP_FLISTXATTR, (result >= 0), handle,
2286 "%s", fsp->fsp_name);
2291 static int smb_full_audit_removexattr(struct vfs_handle_struct *handle,
2297 result = SMB_VFS_NEXT_REMOVEXATTR(handle, path, name);
2299 do_log(SMB_VFS_OP_REMOVEXATTR, (result >= 0), handle,
2300 "%s|%s", path, name);
2305 static int smb_full_audit_lremovexattr(struct vfs_handle_struct *handle,
2311 result = SMB_VFS_NEXT_LREMOVEXATTR(handle, path, name);
2313 do_log(SMB_VFS_OP_LREMOVEXATTR, (result >= 0), handle,
2314 "%s|%s", path, name);
2319 static int smb_full_audit_fremovexattr(struct vfs_handle_struct *handle,
2320 struct files_struct *fsp,
2325 result = SMB_VFS_NEXT_FREMOVEXATTR(handle, fsp, name);
2327 do_log(SMB_VFS_OP_FREMOVEXATTR, (result >= 0), handle,
2328 "%s|%s", fsp->fsp_name, name);
2333 static int smb_full_audit_setxattr(struct vfs_handle_struct *handle,
2335 const char *name, const void *value, size_t size,
2340 result = SMB_VFS_NEXT_SETXATTR(handle, path, name, value, size,
2343 do_log(SMB_VFS_OP_SETXATTR, (result >= 0), handle,
2344 "%s|%s", path, name);
2349 static int smb_full_audit_lsetxattr(struct vfs_handle_struct *handle,
2351 const char *name, const void *value, size_t size,
2356 result = SMB_VFS_NEXT_LSETXATTR(handle, path, name, value, size,
2359 do_log(SMB_VFS_OP_LSETXATTR, (result >= 0), handle,
2360 "%s|%s", path, name);
2365 static int smb_full_audit_fsetxattr(struct vfs_handle_struct *handle,
2366 struct files_struct *fsp, const char *name,
2367 const void *value, size_t size, int flags)
2371 result = SMB_VFS_NEXT_FSETXATTR(handle, fsp, name, value, size, flags);
2373 do_log(SMB_VFS_OP_FSETXATTR, (result >= 0), handle,
2374 "%s|%s", fsp->fsp_name, name);
2379 static int smb_full_audit_aio_read(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb)
2383 result = SMB_VFS_NEXT_AIO_READ(handle, fsp, aiocb);
2384 do_log(SMB_VFS_OP_AIO_READ, (result >= 0), handle,
2385 "%s", fsp->fsp_name);
2390 static int smb_full_audit_aio_write(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb)
2394 result = SMB_VFS_NEXT_AIO_WRITE(handle, fsp, aiocb);
2395 do_log(SMB_VFS_OP_AIO_WRITE, (result >= 0), handle,
2396 "%s", fsp->fsp_name);
2401 static ssize_t smb_full_audit_aio_return(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb)
2405 result = SMB_VFS_NEXT_AIO_RETURN(handle, fsp, aiocb);
2406 do_log(SMB_VFS_OP_AIO_RETURN, (result >= 0), handle,
2407 "%s", fsp->fsp_name);
2412 static int smb_full_audit_aio_cancel(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb)
2416 result = SMB_VFS_NEXT_AIO_CANCEL(handle, fsp, aiocb);
2417 do_log(SMB_VFS_OP_AIO_CANCEL, (result >= 0), handle,
2418 "%s", fsp->fsp_name);
2423 static int smb_full_audit_aio_error(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb)
2427 result = SMB_VFS_NEXT_AIO_ERROR(handle, fsp, aiocb);
2428 do_log(SMB_VFS_OP_AIO_ERROR, (result >= 0), handle,
2429 "%s", fsp->fsp_name);
2434 static int smb_full_audit_aio_fsync(struct vfs_handle_struct *handle, struct files_struct *fsp, int op, SMB_STRUCT_AIOCB *aiocb)
2438 result = SMB_VFS_NEXT_AIO_FSYNC(handle, fsp, op, aiocb);
2439 do_log(SMB_VFS_OP_AIO_FSYNC, (result >= 0), handle,
2440 "%s", fsp->fsp_name);
2445 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)
2449 result = SMB_VFS_NEXT_AIO_SUSPEND(handle, fsp, aiocb, n, ts);
2450 do_log(SMB_VFS_OP_AIO_SUSPEND, (result >= 0), handle,
2451 "%s", fsp->fsp_name);
2456 static bool smb_full_audit_aio_force(struct vfs_handle_struct *handle,
2457 struct files_struct *fsp)
2461 result = SMB_VFS_NEXT_AIO_FORCE(handle, fsp);
2462 do_log(SMB_VFS_OP_AIO_FORCE, result, handle,
2463 "%s", fsp->fsp_name);
2468 NTSTATUS vfs_full_audit_init(void);
2469 NTSTATUS vfs_full_audit_init(void)
2471 NTSTATUS ret = smb_register_vfs(SMB_VFS_INTERFACE_VERSION,
2472 "full_audit", audit_op_tuples);
2474 if (!NT_STATUS_IS_OK(ret))
2477 vfs_full_audit_debug_level = debug_add_class("full_audit");
2478 if (vfs_full_audit_debug_level == -1) {
2479 vfs_full_audit_debug_level = DBGC_VFS;
2480 DEBUG(0, ("vfs_full_audit: Couldn't register custom debugging "
2483 DEBUG(10, ("vfs_full_audit: Debug class number of "
2484 "'full_audit': %d\n", vfs_full_audit_debug_level));