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 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,
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,
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,
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,
148 static ssize_t smb_full_audit_recvfile(vfs_handle_struct *handle, int fromfd,
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,
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,
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,
177 static char *smb_full_audit_getwd(vfs_handle_struct *handle,
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,
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,
188 static int smb_full_audit_linux_setlease(vfs_handle_struct *handle, files_struct *fsp,
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,
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,
217 unsigned int *pnum_streams,
218 struct stream_struct **pstreams);
219 static int smb_full_audit_get_real_filename(struct vfs_handle_struct *handle,
224 static const char *smb_full_audit_connectpath(vfs_handle_struct *handle,
226 static NTSTATUS smb_full_audit_brl_lock_windows(struct vfs_handle_struct *handle,
227 struct byte_range_lock *br_lck,
228 struct lock_struct *plock,
230 struct blocking_lock_record *blr);
231 static bool smb_full_audit_brl_unlock_windows(struct vfs_handle_struct *handle,
232 struct messaging_context *msg_ctx,
233 struct byte_range_lock *br_lck,
234 const struct lock_struct *plock);
235 static bool smb_full_audit_brl_cancel_windows(struct vfs_handle_struct *handle,
236 struct byte_range_lock *br_lck,
237 struct lock_struct *plock,
238 struct blocking_lock_record *blr);
239 static bool smb_full_audit_strict_lock(struct vfs_handle_struct *handle,
240 struct files_struct *fsp,
241 struct lock_struct *plock);
242 static void smb_full_audit_strict_unlock(struct vfs_handle_struct *handle,
243 struct files_struct *fsp,
244 struct lock_struct *plock);
245 static NTSTATUS smb_full_audit_fget_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
246 uint32 security_info,
248 static NTSTATUS smb_full_audit_get_nt_acl(vfs_handle_struct *handle,
249 const char *name, uint32 security_info,
251 static NTSTATUS smb_full_audit_fset_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
252 uint32 security_info_sent,
253 const SEC_DESC *psd);
254 static int smb_full_audit_chmod_acl(vfs_handle_struct *handle,
255 const char *path, mode_t mode);
256 static int smb_full_audit_fchmod_acl(vfs_handle_struct *handle, files_struct *fsp,
258 static int smb_full_audit_sys_acl_get_entry(vfs_handle_struct *handle,
259 SMB_ACL_T theacl, int entry_id,
260 SMB_ACL_ENTRY_T *entry_p);
261 static int smb_full_audit_sys_acl_get_tag_type(vfs_handle_struct *handle,
262 SMB_ACL_ENTRY_T entry_d,
263 SMB_ACL_TAG_T *tag_type_p);
264 static int smb_full_audit_sys_acl_get_permset(vfs_handle_struct *handle,
265 SMB_ACL_ENTRY_T entry_d,
266 SMB_ACL_PERMSET_T *permset_p);
267 static void * smb_full_audit_sys_acl_get_qualifier(vfs_handle_struct *handle,
268 SMB_ACL_ENTRY_T entry_d);
269 static SMB_ACL_T smb_full_audit_sys_acl_get_file(vfs_handle_struct *handle,
271 SMB_ACL_TYPE_T type);
272 static SMB_ACL_T smb_full_audit_sys_acl_get_fd(vfs_handle_struct *handle,
274 static int smb_full_audit_sys_acl_clear_perms(vfs_handle_struct *handle,
275 SMB_ACL_PERMSET_T permset);
276 static int smb_full_audit_sys_acl_add_perm(vfs_handle_struct *handle,
277 SMB_ACL_PERMSET_T permset,
278 SMB_ACL_PERM_T perm);
279 static char * smb_full_audit_sys_acl_to_text(vfs_handle_struct *handle,
282 static SMB_ACL_T smb_full_audit_sys_acl_init(vfs_handle_struct *handle,
284 static int smb_full_audit_sys_acl_create_entry(vfs_handle_struct *handle,
286 SMB_ACL_ENTRY_T *pentry);
287 static int smb_full_audit_sys_acl_set_tag_type(vfs_handle_struct *handle,
288 SMB_ACL_ENTRY_T entry,
289 SMB_ACL_TAG_T tagtype);
290 static int smb_full_audit_sys_acl_set_qualifier(vfs_handle_struct *handle,
291 SMB_ACL_ENTRY_T entry,
293 static int smb_full_audit_sys_acl_set_permset(vfs_handle_struct *handle,
294 SMB_ACL_ENTRY_T entry,
295 SMB_ACL_PERMSET_T permset);
296 static int smb_full_audit_sys_acl_valid(vfs_handle_struct *handle,
298 static int smb_full_audit_sys_acl_set_file(vfs_handle_struct *handle,
299 const char *name, SMB_ACL_TYPE_T acltype,
301 static int smb_full_audit_sys_acl_set_fd(vfs_handle_struct *handle, files_struct *fsp,
303 static int smb_full_audit_sys_acl_delete_def_file(vfs_handle_struct *handle,
305 static int smb_full_audit_sys_acl_get_perm(vfs_handle_struct *handle,
306 SMB_ACL_PERMSET_T permset,
307 SMB_ACL_PERM_T perm);
308 static int smb_full_audit_sys_acl_free_text(vfs_handle_struct *handle,
310 static int smb_full_audit_sys_acl_free_acl(vfs_handle_struct *handle,
311 SMB_ACL_T posix_acl);
312 static int smb_full_audit_sys_acl_free_qualifier(vfs_handle_struct *handle,
314 SMB_ACL_TAG_T tagtype);
315 static ssize_t smb_full_audit_getxattr(struct vfs_handle_struct *handle,
317 const char *name, void *value, size_t size);
318 static ssize_t smb_full_audit_lgetxattr(struct vfs_handle_struct *handle,
319 const char *path, const char *name,
320 void *value, size_t size);
321 static ssize_t smb_full_audit_fgetxattr(struct vfs_handle_struct *handle,
322 struct files_struct *fsp,
323 const char *name, void *value, size_t size);
324 static ssize_t smb_full_audit_listxattr(struct vfs_handle_struct *handle,
325 const char *path, char *list, size_t size);
326 static ssize_t smb_full_audit_llistxattr(struct vfs_handle_struct *handle,
327 const char *path, char *list, size_t size);
328 static ssize_t smb_full_audit_flistxattr(struct vfs_handle_struct *handle,
329 struct files_struct *fsp, char *list,
331 static int smb_full_audit_removexattr(struct vfs_handle_struct *handle,
334 static int smb_full_audit_lremovexattr(struct vfs_handle_struct *handle,
337 static int smb_full_audit_fremovexattr(struct vfs_handle_struct *handle,
338 struct files_struct *fsp,
340 static int smb_full_audit_setxattr(struct vfs_handle_struct *handle,
342 const char *name, const void *value, size_t size,
344 static int smb_full_audit_lsetxattr(struct vfs_handle_struct *handle,
346 const char *name, const void *value, size_t size,
348 static int smb_full_audit_fsetxattr(struct vfs_handle_struct *handle,
349 struct files_struct *fsp, const char *name,
350 const void *value, size_t size, int flags);
352 static int smb_full_audit_aio_read(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb);
353 static int smb_full_audit_aio_write(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb);
354 static ssize_t smb_full_audit_aio_return(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb);
355 static int smb_full_audit_aio_cancel(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb);
356 static int smb_full_audit_aio_error(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb);
357 static int smb_full_audit_aio_fsync(struct vfs_handle_struct *handle, struct files_struct *fsp, int op, SMB_STRUCT_AIOCB *aiocb);
358 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);
359 static bool smb_full_audit_aio_force(struct vfs_handle_struct *handle,
360 struct files_struct *fsp);
364 static vfs_op_tuple audit_op_tuples[] = {
366 /* Disk operations */
368 {SMB_VFS_OP(smb_full_audit_connect), SMB_VFS_OP_CONNECT,
369 SMB_VFS_LAYER_LOGGER},
370 {SMB_VFS_OP(smb_full_audit_disconnect), SMB_VFS_OP_DISCONNECT,
371 SMB_VFS_LAYER_LOGGER},
372 {SMB_VFS_OP(smb_full_audit_disk_free), SMB_VFS_OP_DISK_FREE,
373 SMB_VFS_LAYER_LOGGER},
374 {SMB_VFS_OP(smb_full_audit_get_quota), SMB_VFS_OP_GET_QUOTA,
375 SMB_VFS_LAYER_LOGGER},
376 {SMB_VFS_OP(smb_full_audit_set_quota), SMB_VFS_OP_SET_QUOTA,
377 SMB_VFS_LAYER_LOGGER},
378 {SMB_VFS_OP(smb_full_audit_get_shadow_copy_data), SMB_VFS_OP_GET_SHADOW_COPY_DATA,
379 SMB_VFS_LAYER_LOGGER},
380 {SMB_VFS_OP(smb_full_audit_statvfs), SMB_VFS_OP_STATVFS,
381 SMB_VFS_LAYER_LOGGER},
382 {SMB_VFS_OP(smb_full_audit_fs_capabilities), SMB_VFS_OP_FS_CAPABILITIES,
383 SMB_VFS_LAYER_LOGGER},
385 /* Directory operations */
387 {SMB_VFS_OP(smb_full_audit_opendir), SMB_VFS_OP_OPENDIR,
388 SMB_VFS_LAYER_LOGGER},
389 {SMB_VFS_OP(smb_full_audit_readdir), SMB_VFS_OP_READDIR,
390 SMB_VFS_LAYER_LOGGER},
391 {SMB_VFS_OP(smb_full_audit_seekdir), SMB_VFS_OP_SEEKDIR,
392 SMB_VFS_LAYER_LOGGER},
393 {SMB_VFS_OP(smb_full_audit_telldir), SMB_VFS_OP_TELLDIR,
394 SMB_VFS_LAYER_LOGGER},
395 {SMB_VFS_OP(smb_full_audit_rewinddir), SMB_VFS_OP_REWINDDIR,
396 SMB_VFS_LAYER_LOGGER},
397 {SMB_VFS_OP(smb_full_audit_mkdir), SMB_VFS_OP_MKDIR,
398 SMB_VFS_LAYER_LOGGER},
399 {SMB_VFS_OP(smb_full_audit_rmdir), SMB_VFS_OP_RMDIR,
400 SMB_VFS_LAYER_LOGGER},
401 {SMB_VFS_OP(smb_full_audit_closedir), SMB_VFS_OP_CLOSEDIR,
402 SMB_VFS_LAYER_LOGGER},
403 {SMB_VFS_OP(smb_full_audit_init_search_op), SMB_VFS_OP_INIT_SEARCH_OP,
404 SMB_VFS_LAYER_LOGGER},
406 /* File operations */
408 {SMB_VFS_OP(smb_full_audit_open), SMB_VFS_OP_OPEN,
409 SMB_VFS_LAYER_LOGGER},
410 {SMB_VFS_OP(smb_full_audit_create_file),SMB_VFS_OP_CREATE_FILE,
411 SMB_VFS_LAYER_LOGGER},
412 {SMB_VFS_OP(smb_full_audit_close), SMB_VFS_OP_CLOSE,
413 SMB_VFS_LAYER_LOGGER},
414 {SMB_VFS_OP(smb_full_audit_read), SMB_VFS_OP_READ,
415 SMB_VFS_LAYER_LOGGER},
416 {SMB_VFS_OP(smb_full_audit_pread), SMB_VFS_OP_PREAD,
417 SMB_VFS_LAYER_LOGGER},
418 {SMB_VFS_OP(smb_full_audit_write), SMB_VFS_OP_WRITE,
419 SMB_VFS_LAYER_LOGGER},
420 {SMB_VFS_OP(smb_full_audit_pwrite), SMB_VFS_OP_PWRITE,
421 SMB_VFS_LAYER_LOGGER},
422 {SMB_VFS_OP(smb_full_audit_lseek), SMB_VFS_OP_LSEEK,
423 SMB_VFS_LAYER_LOGGER},
424 {SMB_VFS_OP(smb_full_audit_sendfile), SMB_VFS_OP_SENDFILE,
425 SMB_VFS_LAYER_LOGGER},
426 {SMB_VFS_OP(smb_full_audit_recvfile), SMB_VFS_OP_RECVFILE,
427 SMB_VFS_LAYER_LOGGER},
428 {SMB_VFS_OP(smb_full_audit_rename), SMB_VFS_OP_RENAME,
429 SMB_VFS_LAYER_LOGGER},
430 {SMB_VFS_OP(smb_full_audit_fsync), SMB_VFS_OP_FSYNC,
431 SMB_VFS_LAYER_LOGGER},
432 {SMB_VFS_OP(smb_full_audit_stat), SMB_VFS_OP_STAT,
433 SMB_VFS_LAYER_LOGGER},
434 {SMB_VFS_OP(smb_full_audit_fstat), SMB_VFS_OP_FSTAT,
435 SMB_VFS_LAYER_LOGGER},
436 {SMB_VFS_OP(smb_full_audit_lstat), SMB_VFS_OP_LSTAT,
437 SMB_VFS_LAYER_LOGGER},
438 {SMB_VFS_OP(smb_full_audit_get_alloc_size), SMB_VFS_OP_GET_ALLOC_SIZE,
439 SMB_VFS_LAYER_LOGGER},
440 {SMB_VFS_OP(smb_full_audit_unlink), SMB_VFS_OP_UNLINK,
441 SMB_VFS_LAYER_LOGGER},
442 {SMB_VFS_OP(smb_full_audit_chmod), SMB_VFS_OP_CHMOD,
443 SMB_VFS_LAYER_LOGGER},
444 {SMB_VFS_OP(smb_full_audit_fchmod), SMB_VFS_OP_FCHMOD,
445 SMB_VFS_LAYER_LOGGER},
446 {SMB_VFS_OP(smb_full_audit_chown), SMB_VFS_OP_CHOWN,
447 SMB_VFS_LAYER_LOGGER},
448 {SMB_VFS_OP(smb_full_audit_fchown), SMB_VFS_OP_FCHOWN,
449 SMB_VFS_LAYER_LOGGER},
450 {SMB_VFS_OP(smb_full_audit_lchown), SMB_VFS_OP_LCHOWN,
451 SMB_VFS_LAYER_LOGGER},
452 {SMB_VFS_OP(smb_full_audit_chdir), SMB_VFS_OP_CHDIR,
453 SMB_VFS_LAYER_LOGGER},
454 {SMB_VFS_OP(smb_full_audit_getwd), SMB_VFS_OP_GETWD,
455 SMB_VFS_LAYER_LOGGER},
456 {SMB_VFS_OP(smb_full_audit_ntimes), SMB_VFS_OP_NTIMES,
457 SMB_VFS_LAYER_LOGGER},
458 {SMB_VFS_OP(smb_full_audit_ftruncate), SMB_VFS_OP_FTRUNCATE,
459 SMB_VFS_LAYER_LOGGER},
460 {SMB_VFS_OP(smb_full_audit_lock), SMB_VFS_OP_LOCK,
461 SMB_VFS_LAYER_LOGGER},
462 {SMB_VFS_OP(smb_full_audit_kernel_flock), SMB_VFS_OP_KERNEL_FLOCK,
463 SMB_VFS_LAYER_LOGGER},
464 {SMB_VFS_OP(smb_full_audit_linux_setlease), SMB_VFS_OP_LINUX_SETLEASE,
465 SMB_VFS_LAYER_LOGGER},
466 {SMB_VFS_OP(smb_full_audit_getlock), SMB_VFS_OP_GETLOCK,
467 SMB_VFS_LAYER_LOGGER},
468 {SMB_VFS_OP(smb_full_audit_symlink), SMB_VFS_OP_SYMLINK,
469 SMB_VFS_LAYER_LOGGER},
470 {SMB_VFS_OP(smb_full_audit_readlink), SMB_VFS_OP_READLINK,
471 SMB_VFS_LAYER_LOGGER},
472 {SMB_VFS_OP(smb_full_audit_link), SMB_VFS_OP_LINK,
473 SMB_VFS_LAYER_LOGGER},
474 {SMB_VFS_OP(smb_full_audit_mknod), SMB_VFS_OP_MKNOD,
475 SMB_VFS_LAYER_LOGGER},
476 {SMB_VFS_OP(smb_full_audit_realpath), SMB_VFS_OP_REALPATH,
477 SMB_VFS_LAYER_LOGGER},
478 {SMB_VFS_OP(smb_full_audit_notify_watch),SMB_VFS_OP_NOTIFY_WATCH,
479 SMB_VFS_LAYER_LOGGER},
480 {SMB_VFS_OP(smb_full_audit_chflags), SMB_VFS_OP_CHFLAGS,
481 SMB_VFS_LAYER_LOGGER},
482 {SMB_VFS_OP(smb_full_audit_file_id_create), SMB_VFS_OP_FILE_ID_CREATE,
483 SMB_VFS_LAYER_LOGGER},
484 {SMB_VFS_OP(smb_full_audit_streaminfo), SMB_VFS_OP_STREAMINFO,
485 SMB_VFS_LAYER_LOGGER},
486 {SMB_VFS_OP(smb_full_audit_get_real_filename), SMB_VFS_OP_GET_REAL_FILENAME,
487 SMB_VFS_LAYER_LOGGER},
488 {SMB_VFS_OP(smb_full_audit_connectpath), SMB_VFS_OP_CONNECTPATH,
489 SMB_VFS_LAYER_LOGGER},
490 {SMB_VFS_OP(smb_full_audit_brl_lock_windows), SMB_VFS_OP_BRL_LOCK_WINDOWS,
491 SMB_VFS_LAYER_LOGGER},
492 {SMB_VFS_OP(smb_full_audit_brl_unlock_windows), SMB_VFS_OP_BRL_UNLOCK_WINDOWS,
493 SMB_VFS_LAYER_LOGGER},
494 {SMB_VFS_OP(smb_full_audit_brl_cancel_windows), SMB_VFS_OP_BRL_CANCEL_WINDOWS,
495 SMB_VFS_LAYER_LOGGER},
496 {SMB_VFS_OP(smb_full_audit_strict_lock), SMB_VFS_OP_STRICT_LOCK,
497 SMB_VFS_LAYER_LOGGER},
498 {SMB_VFS_OP(smb_full_audit_strict_unlock), SMB_VFS_OP_STRICT_UNLOCK,
499 SMB_VFS_LAYER_LOGGER},
501 /* NT ACL operations. */
503 {SMB_VFS_OP(smb_full_audit_fget_nt_acl), SMB_VFS_OP_FGET_NT_ACL,
504 SMB_VFS_LAYER_LOGGER},
505 {SMB_VFS_OP(smb_full_audit_get_nt_acl), SMB_VFS_OP_GET_NT_ACL,
506 SMB_VFS_LAYER_LOGGER},
507 {SMB_VFS_OP(smb_full_audit_fset_nt_acl), SMB_VFS_OP_FSET_NT_ACL,
508 SMB_VFS_LAYER_LOGGER},
510 /* POSIX ACL operations. */
512 {SMB_VFS_OP(smb_full_audit_chmod_acl), SMB_VFS_OP_CHMOD_ACL,
513 SMB_VFS_LAYER_LOGGER},
514 {SMB_VFS_OP(smb_full_audit_fchmod_acl), SMB_VFS_OP_FCHMOD_ACL,
515 SMB_VFS_LAYER_LOGGER},
516 {SMB_VFS_OP(smb_full_audit_sys_acl_get_entry), SMB_VFS_OP_SYS_ACL_GET_ENTRY,
517 SMB_VFS_LAYER_LOGGER},
518 {SMB_VFS_OP(smb_full_audit_sys_acl_get_tag_type), SMB_VFS_OP_SYS_ACL_GET_TAG_TYPE,
519 SMB_VFS_LAYER_LOGGER},
520 {SMB_VFS_OP(smb_full_audit_sys_acl_get_permset), SMB_VFS_OP_SYS_ACL_GET_PERMSET,
521 SMB_VFS_LAYER_LOGGER},
522 {SMB_VFS_OP(smb_full_audit_sys_acl_get_qualifier), SMB_VFS_OP_SYS_ACL_GET_QUALIFIER,
523 SMB_VFS_LAYER_LOGGER},
524 {SMB_VFS_OP(smb_full_audit_sys_acl_get_file), SMB_VFS_OP_SYS_ACL_GET_FILE,
525 SMB_VFS_LAYER_LOGGER},
526 {SMB_VFS_OP(smb_full_audit_sys_acl_get_fd), SMB_VFS_OP_SYS_ACL_GET_FD,
527 SMB_VFS_LAYER_LOGGER},
528 {SMB_VFS_OP(smb_full_audit_sys_acl_clear_perms), SMB_VFS_OP_SYS_ACL_CLEAR_PERMS,
529 SMB_VFS_LAYER_LOGGER},
530 {SMB_VFS_OP(smb_full_audit_sys_acl_add_perm), SMB_VFS_OP_SYS_ACL_ADD_PERM,
531 SMB_VFS_LAYER_LOGGER},
532 {SMB_VFS_OP(smb_full_audit_sys_acl_to_text), SMB_VFS_OP_SYS_ACL_TO_TEXT,
533 SMB_VFS_LAYER_LOGGER},
534 {SMB_VFS_OP(smb_full_audit_sys_acl_init), SMB_VFS_OP_SYS_ACL_INIT,
535 SMB_VFS_LAYER_LOGGER},
536 {SMB_VFS_OP(smb_full_audit_sys_acl_create_entry), SMB_VFS_OP_SYS_ACL_CREATE_ENTRY,
537 SMB_VFS_LAYER_LOGGER},
538 {SMB_VFS_OP(smb_full_audit_sys_acl_set_tag_type), SMB_VFS_OP_SYS_ACL_SET_TAG_TYPE,
539 SMB_VFS_LAYER_LOGGER},
540 {SMB_VFS_OP(smb_full_audit_sys_acl_set_qualifier), SMB_VFS_OP_SYS_ACL_SET_QUALIFIER,
541 SMB_VFS_LAYER_LOGGER},
542 {SMB_VFS_OP(smb_full_audit_sys_acl_set_permset), SMB_VFS_OP_SYS_ACL_SET_PERMSET,
543 SMB_VFS_LAYER_LOGGER},
544 {SMB_VFS_OP(smb_full_audit_sys_acl_valid), SMB_VFS_OP_SYS_ACL_VALID,
545 SMB_VFS_LAYER_LOGGER},
546 {SMB_VFS_OP(smb_full_audit_sys_acl_set_file), SMB_VFS_OP_SYS_ACL_SET_FILE,
547 SMB_VFS_LAYER_LOGGER},
548 {SMB_VFS_OP(smb_full_audit_sys_acl_set_fd), SMB_VFS_OP_SYS_ACL_SET_FD,
549 SMB_VFS_LAYER_LOGGER},
550 {SMB_VFS_OP(smb_full_audit_sys_acl_delete_def_file), SMB_VFS_OP_SYS_ACL_DELETE_DEF_FILE,
551 SMB_VFS_LAYER_LOGGER},
552 {SMB_VFS_OP(smb_full_audit_sys_acl_get_perm), SMB_VFS_OP_SYS_ACL_GET_PERM,
553 SMB_VFS_LAYER_LOGGER},
554 {SMB_VFS_OP(smb_full_audit_sys_acl_free_text), SMB_VFS_OP_SYS_ACL_FREE_TEXT,
555 SMB_VFS_LAYER_LOGGER},
556 {SMB_VFS_OP(smb_full_audit_sys_acl_free_acl), SMB_VFS_OP_SYS_ACL_FREE_ACL,
557 SMB_VFS_LAYER_LOGGER},
558 {SMB_VFS_OP(smb_full_audit_sys_acl_free_qualifier), SMB_VFS_OP_SYS_ACL_FREE_QUALIFIER,
559 SMB_VFS_LAYER_LOGGER},
563 {SMB_VFS_OP(smb_full_audit_getxattr), SMB_VFS_OP_GETXATTR,
564 SMB_VFS_LAYER_LOGGER},
565 {SMB_VFS_OP(smb_full_audit_lgetxattr), SMB_VFS_OP_LGETXATTR,
566 SMB_VFS_LAYER_LOGGER},
567 {SMB_VFS_OP(smb_full_audit_fgetxattr), SMB_VFS_OP_FGETXATTR,
568 SMB_VFS_LAYER_LOGGER},
569 {SMB_VFS_OP(smb_full_audit_listxattr), SMB_VFS_OP_LISTXATTR,
570 SMB_VFS_LAYER_LOGGER},
571 {SMB_VFS_OP(smb_full_audit_llistxattr), SMB_VFS_OP_LLISTXATTR,
572 SMB_VFS_LAYER_LOGGER},
573 {SMB_VFS_OP(smb_full_audit_flistxattr), SMB_VFS_OP_FLISTXATTR,
574 SMB_VFS_LAYER_LOGGER},
575 {SMB_VFS_OP(smb_full_audit_removexattr), SMB_VFS_OP_REMOVEXATTR,
576 SMB_VFS_LAYER_LOGGER},
577 {SMB_VFS_OP(smb_full_audit_lremovexattr), SMB_VFS_OP_LREMOVEXATTR,
578 SMB_VFS_LAYER_LOGGER},
579 {SMB_VFS_OP(smb_full_audit_fremovexattr), SMB_VFS_OP_FREMOVEXATTR,
580 SMB_VFS_LAYER_LOGGER},
581 {SMB_VFS_OP(smb_full_audit_setxattr), SMB_VFS_OP_SETXATTR,
582 SMB_VFS_LAYER_LOGGER},
583 {SMB_VFS_OP(smb_full_audit_lsetxattr), SMB_VFS_OP_LSETXATTR,
584 SMB_VFS_LAYER_LOGGER},
585 {SMB_VFS_OP(smb_full_audit_fsetxattr), SMB_VFS_OP_FSETXATTR,
586 SMB_VFS_LAYER_LOGGER},
588 {SMB_VFS_OP(smb_full_audit_aio_read), SMB_VFS_OP_AIO_READ,
589 SMB_VFS_LAYER_LOGGER},
590 {SMB_VFS_OP(smb_full_audit_aio_write), SMB_VFS_OP_AIO_WRITE,
591 SMB_VFS_LAYER_LOGGER},
592 {SMB_VFS_OP(smb_full_audit_aio_return), SMB_VFS_OP_AIO_RETURN,
593 SMB_VFS_LAYER_LOGGER},
594 {SMB_VFS_OP(smb_full_audit_aio_cancel), SMB_VFS_OP_AIO_CANCEL,
595 SMB_VFS_LAYER_LOGGER},
596 {SMB_VFS_OP(smb_full_audit_aio_error), SMB_VFS_OP_AIO_ERROR,
597 SMB_VFS_LAYER_LOGGER},
598 {SMB_VFS_OP(smb_full_audit_aio_fsync), SMB_VFS_OP_AIO_FSYNC,
599 SMB_VFS_LAYER_LOGGER},
600 {SMB_VFS_OP(smb_full_audit_aio_suspend),SMB_VFS_OP_AIO_SUSPEND,
601 SMB_VFS_LAYER_LOGGER},
602 {SMB_VFS_OP(smb_full_audit_aio_force),SMB_VFS_OP_AIO_FORCE,
603 SMB_VFS_LAYER_LOGGER},
605 /* Finish VFS operations definition */
607 {SMB_VFS_OP(NULL), SMB_VFS_OP_NOOP,
611 /* The following array *must* be in the same order as defined in vfs.h */
617 { SMB_VFS_OP_CONNECT, "connect" },
618 { SMB_VFS_OP_DISCONNECT, "disconnect" },
619 { SMB_VFS_OP_DISK_FREE, "disk_free" },
620 { SMB_VFS_OP_GET_QUOTA, "get_quota" },
621 { SMB_VFS_OP_SET_QUOTA, "set_quota" },
622 { SMB_VFS_OP_GET_SHADOW_COPY_DATA, "get_shadow_copy_data" },
623 { SMB_VFS_OP_STATVFS, "statvfs" },
624 { SMB_VFS_OP_FS_CAPABILITIES, "fs_capabilities" },
625 { SMB_VFS_OP_OPENDIR, "opendir" },
626 { SMB_VFS_OP_READDIR, "readdir" },
627 { SMB_VFS_OP_SEEKDIR, "seekdir" },
628 { SMB_VFS_OP_TELLDIR, "telldir" },
629 { SMB_VFS_OP_REWINDDIR, "rewinddir" },
630 { SMB_VFS_OP_MKDIR, "mkdir" },
631 { SMB_VFS_OP_RMDIR, "rmdir" },
632 { SMB_VFS_OP_CLOSEDIR, "closedir" },
633 { SMB_VFS_OP_INIT_SEARCH_OP, "init_search_op" },
634 { SMB_VFS_OP_OPEN, "open" },
635 { SMB_VFS_OP_CREATE_FILE, "create_file" },
636 { SMB_VFS_OP_CLOSE, "close" },
637 { SMB_VFS_OP_READ, "read" },
638 { SMB_VFS_OP_PREAD, "pread" },
639 { SMB_VFS_OP_WRITE, "write" },
640 { SMB_VFS_OP_PWRITE, "pwrite" },
641 { SMB_VFS_OP_LSEEK, "lseek" },
642 { SMB_VFS_OP_SENDFILE, "sendfile" },
643 { SMB_VFS_OP_RECVFILE, "recvfile" },
644 { SMB_VFS_OP_RENAME, "rename" },
645 { SMB_VFS_OP_FSYNC, "fsync" },
646 { SMB_VFS_OP_STAT, "stat" },
647 { SMB_VFS_OP_FSTAT, "fstat" },
648 { SMB_VFS_OP_LSTAT, "lstat" },
649 { SMB_VFS_OP_GET_ALLOC_SIZE, "get_alloc_size" },
650 { SMB_VFS_OP_UNLINK, "unlink" },
651 { SMB_VFS_OP_CHMOD, "chmod" },
652 { SMB_VFS_OP_FCHMOD, "fchmod" },
653 { SMB_VFS_OP_CHOWN, "chown" },
654 { SMB_VFS_OP_FCHOWN, "fchown" },
655 { SMB_VFS_OP_LCHOWN, "lchown" },
656 { SMB_VFS_OP_CHDIR, "chdir" },
657 { SMB_VFS_OP_GETWD, "getwd" },
658 { SMB_VFS_OP_NTIMES, "ntimes" },
659 { SMB_VFS_OP_FTRUNCATE, "ftruncate" },
660 { SMB_VFS_OP_LOCK, "lock" },
661 { SMB_VFS_OP_KERNEL_FLOCK, "kernel_flock" },
662 { SMB_VFS_OP_LINUX_SETLEASE, "linux_setlease" },
663 { SMB_VFS_OP_GETLOCK, "getlock" },
664 { SMB_VFS_OP_SYMLINK, "symlink" },
665 { SMB_VFS_OP_READLINK, "readlink" },
666 { SMB_VFS_OP_LINK, "link" },
667 { SMB_VFS_OP_MKNOD, "mknod" },
668 { SMB_VFS_OP_REALPATH, "realpath" },
669 { SMB_VFS_OP_NOTIFY_WATCH, "notify_watch" },
670 { SMB_VFS_OP_CHFLAGS, "chflags" },
671 { SMB_VFS_OP_FILE_ID_CREATE, "file_id_create" },
672 { SMB_VFS_OP_STREAMINFO, "streaminfo" },
673 { SMB_VFS_OP_GET_REAL_FILENAME, "get_real_filename" },
674 { SMB_VFS_OP_CONNECTPATH, "connectpath" },
675 { SMB_VFS_OP_BRL_LOCK_WINDOWS, "brl_lock_windows" },
676 { SMB_VFS_OP_BRL_UNLOCK_WINDOWS, "brl_unlock_windows" },
677 { SMB_VFS_OP_BRL_CANCEL_WINDOWS, "brl_cancel_windows" },
678 { SMB_VFS_OP_STRICT_LOCK, "strict_lock" },
679 { SMB_VFS_OP_STRICT_UNLOCK, "strict_unlock" },
680 { SMB_VFS_OP_FGET_NT_ACL, "fget_nt_acl" },
681 { SMB_VFS_OP_GET_NT_ACL, "get_nt_acl" },
682 { SMB_VFS_OP_FSET_NT_ACL, "fset_nt_acl" },
683 { SMB_VFS_OP_CHMOD_ACL, "chmod_acl" },
684 { SMB_VFS_OP_FCHMOD_ACL, "fchmod_acl" },
685 { SMB_VFS_OP_SYS_ACL_GET_ENTRY, "sys_acl_get_entry" },
686 { SMB_VFS_OP_SYS_ACL_GET_TAG_TYPE, "sys_acl_get_tag_type" },
687 { SMB_VFS_OP_SYS_ACL_GET_PERMSET, "sys_acl_get_permset" },
688 { SMB_VFS_OP_SYS_ACL_GET_QUALIFIER, "sys_acl_get_qualifier" },
689 { SMB_VFS_OP_SYS_ACL_GET_FILE, "sys_acl_get_file" },
690 { SMB_VFS_OP_SYS_ACL_GET_FD, "sys_acl_get_fd" },
691 { SMB_VFS_OP_SYS_ACL_CLEAR_PERMS, "sys_acl_clear_perms" },
692 { SMB_VFS_OP_SYS_ACL_ADD_PERM, "sys_acl_add_perm" },
693 { SMB_VFS_OP_SYS_ACL_TO_TEXT, "sys_acl_to_text" },
694 { SMB_VFS_OP_SYS_ACL_INIT, "sys_acl_init" },
695 { SMB_VFS_OP_SYS_ACL_CREATE_ENTRY, "sys_acl_create_entry" },
696 { SMB_VFS_OP_SYS_ACL_SET_TAG_TYPE, "sys_acl_set_tag_type" },
697 { SMB_VFS_OP_SYS_ACL_SET_QUALIFIER, "sys_acl_set_qualifier" },
698 { SMB_VFS_OP_SYS_ACL_SET_PERMSET, "sys_acl_set_permset" },
699 { SMB_VFS_OP_SYS_ACL_VALID, "sys_acl_valid" },
700 { SMB_VFS_OP_SYS_ACL_SET_FILE, "sys_acl_set_file" },
701 { SMB_VFS_OP_SYS_ACL_SET_FD, "sys_acl_set_fd" },
702 { SMB_VFS_OP_SYS_ACL_DELETE_DEF_FILE, "sys_acl_delete_def_file" },
703 { SMB_VFS_OP_SYS_ACL_GET_PERM, "sys_acl_get_perm" },
704 { SMB_VFS_OP_SYS_ACL_FREE_TEXT, "sys_acl_free_text" },
705 { SMB_VFS_OP_SYS_ACL_FREE_ACL, "sys_acl_free_acl" },
706 { SMB_VFS_OP_SYS_ACL_FREE_QUALIFIER, "sys_acl_free_qualifier" },
707 { SMB_VFS_OP_GETXATTR, "getxattr" },
708 { SMB_VFS_OP_LGETXATTR, "lgetxattr" },
709 { SMB_VFS_OP_FGETXATTR, "fgetxattr" },
710 { SMB_VFS_OP_LISTXATTR, "listxattr" },
711 { SMB_VFS_OP_LLISTXATTR, "llistxattr" },
712 { SMB_VFS_OP_FLISTXATTR, "flistxattr" },
713 { SMB_VFS_OP_REMOVEXATTR, "removexattr" },
714 { SMB_VFS_OP_LREMOVEXATTR, "lremovexattr" },
715 { SMB_VFS_OP_FREMOVEXATTR, "fremovexattr" },
716 { SMB_VFS_OP_SETXATTR, "setxattr" },
717 { SMB_VFS_OP_LSETXATTR, "lsetxattr" },
718 { SMB_VFS_OP_FSETXATTR, "fsetxattr" },
719 { SMB_VFS_OP_AIO_READ, "aio_read" },
720 { SMB_VFS_OP_AIO_WRITE, "aio_write" },
721 { SMB_VFS_OP_AIO_RETURN,"aio_return" },
722 { SMB_VFS_OP_AIO_CANCEL,"aio_cancel" },
723 { SMB_VFS_OP_AIO_ERROR, "aio_error" },
724 { SMB_VFS_OP_AIO_FSYNC, "aio_fsync" },
725 { SMB_VFS_OP_AIO_SUSPEND,"aio_suspend" },
726 { SMB_VFS_OP_AIO_FORCE, "aio_force" },
727 { SMB_VFS_OP_IS_OFFLINE, "aio_is_offline" },
728 { SMB_VFS_OP_SET_OFFLINE, "aio_set_offline" },
729 { SMB_VFS_OP_LAST, NULL }
732 static int audit_syslog_facility(vfs_handle_struct *handle)
734 static const struct enum_list enum_log_facilities[] = {
735 { LOG_USER, "USER" },
736 { LOG_LOCAL0, "LOCAL0" },
737 { LOG_LOCAL1, "LOCAL1" },
738 { LOG_LOCAL2, "LOCAL2" },
739 { LOG_LOCAL3, "LOCAL3" },
740 { LOG_LOCAL4, "LOCAL4" },
741 { LOG_LOCAL5, "LOCAL5" },
742 { LOG_LOCAL6, "LOCAL6" },
743 { LOG_LOCAL7, "LOCAL7" }
748 facility = lp_parm_enum(SNUM(handle->conn), "full_audit", "facility", enum_log_facilities, LOG_USER);
753 static int audit_syslog_priority(vfs_handle_struct *handle)
755 static const struct enum_list enum_log_priorities[] = {
756 { LOG_EMERG, "EMERG" },
757 { LOG_ALERT, "ALERT" },
758 { LOG_CRIT, "CRIT" },
760 { LOG_WARNING, "WARNING" },
761 { LOG_NOTICE, "NOTICE" },
762 { LOG_INFO, "INFO" },
763 { LOG_DEBUG, "DEBUG" }
768 priority = lp_parm_enum(SNUM(handle->conn), "full_audit", "priority",
769 enum_log_priorities, LOG_NOTICE);
770 if (priority == -1) {
771 priority = LOG_WARNING;
777 static char *audit_prefix(TALLOC_CTX *ctx, connection_struct *conn)
782 prefix = talloc_strdup(ctx,
783 lp_parm_const_string(SNUM(conn), "full_audit",
788 result = talloc_sub_advanced(ctx,
789 lp_servicename(SNUM(conn)),
790 conn->server_info->unix_name,
792 conn->server_info->utok.gid,
793 conn->server_info->sanitized_username,
794 pdb_get_domain(conn->server_info->sam_account),
800 static bool log_success(vfs_handle_struct *handle, vfs_op_type op)
802 struct vfs_full_audit_private_data *pd = NULL;
804 SMB_VFS_HANDLE_GET_DATA(handle, pd,
805 struct vfs_full_audit_private_data,
808 if (pd->success_ops == NULL) {
812 return bitmap_query(pd->success_ops, op);
815 static bool log_failure(vfs_handle_struct *handle, vfs_op_type op)
817 struct vfs_full_audit_private_data *pd = NULL;
819 SMB_VFS_HANDLE_GET_DATA(handle, pd,
820 struct vfs_full_audit_private_data,
823 if (pd->failure_ops == NULL)
826 return bitmap_query(pd->failure_ops, op);
829 static void init_bitmap(struct bitmap **bm, const char **ops)
831 bool log_all = False;
836 *bm = bitmap_allocate(SMB_VFS_OP_LAST);
839 DEBUG(0, ("Could not alloc bitmap -- "
840 "defaulting to logging everything\n"));
844 while (*ops != NULL) {
848 if (strequal(*ops, "all")) {
853 if (strequal(*ops, "none")) {
857 for (i=0; i<SMB_VFS_OP_LAST; i++) {
858 if (vfs_op_names[i].name == NULL) {
859 smb_panic("vfs_full_audit.c: name table not "
860 "in sync with vfs.h\n");
863 if (strequal(*ops, vfs_op_names[i].name)) {
869 DEBUG(0, ("Could not find opname %s, logging all\n",
878 /* The query functions default to True */
884 static const char *audit_opname(vfs_op_type op)
886 if (op >= SMB_VFS_OP_LAST)
887 return "INVALID VFS OP";
888 return vfs_op_names[op].name;
891 static void do_log(vfs_op_type op, bool success, vfs_handle_struct *handle,
892 const char *format, ...)
895 char *audit_pre = NULL;
899 if (success && (!log_success(handle, op)))
902 if (!success && (!log_failure(handle, op)))
906 fstrcpy(err_msg, "ok");
908 fstr_sprintf(err_msg, "fail (%s)", strerror(errno));
910 va_start(ap, format);
911 op_msg = talloc_vasprintf(talloc_tos(), format, ap);
918 audit_pre = audit_prefix(talloc_tos(), handle->conn);
919 syslog(audit_syslog_priority(handle), "%s|%s|%s|%s\n",
920 audit_pre ? audit_pre : "",
921 audit_opname(op), err_msg, op_msg);
923 TALLOC_FREE(audit_pre);
929 /* Free function for the private data. */
931 static void free_private_data(void **p_data)
933 struct vfs_full_audit_private_data *pd = *(struct vfs_full_audit_private_data **)p_data;
935 if (pd->success_ops) {
936 bitmap_free(pd->success_ops);
938 if (pd->failure_ops) {
939 bitmap_free(pd->failure_ops);
945 /* Implementation of vfs_ops. Pass everything on to the default
946 operation but log event first. */
948 static int smb_full_audit_connect(vfs_handle_struct *handle,
949 const char *svc, const char *user)
952 struct vfs_full_audit_private_data *pd = NULL;
953 const char *none[] = { NULL };
954 const char *all [] = { "all" };
960 pd = SMB_MALLOC_P(struct vfs_full_audit_private_data);
966 openlog("smbd_audit", 0, audit_syslog_facility(handle));
968 init_bitmap(&pd->success_ops,
969 lp_parm_string_list(SNUM(handle->conn), "full_audit", "success",
971 init_bitmap(&pd->failure_ops,
972 lp_parm_string_list(SNUM(handle->conn), "full_audit", "failure",
975 /* Store the private data. */
976 SMB_VFS_HANDLE_SET_DATA(handle, pd, free_private_data,
977 struct vfs_full_audit_private_data, return -1);
979 result = SMB_VFS_NEXT_CONNECT(handle, svc, user);
981 do_log(SMB_VFS_OP_CONNECT, True, handle,
987 static void smb_full_audit_disconnect(vfs_handle_struct *handle)
989 SMB_VFS_NEXT_DISCONNECT(handle);
991 do_log(SMB_VFS_OP_DISCONNECT, True, handle,
992 "%s", lp_servicename(SNUM(handle->conn)));
994 /* The bitmaps will be disconnected when the private
1000 static uint64_t smb_full_audit_disk_free(vfs_handle_struct *handle,
1002 bool small_query, uint64_t *bsize,
1003 uint64_t *dfree, uint64_t *dsize)
1007 result = SMB_VFS_NEXT_DISK_FREE(handle, path, small_query, bsize,
1010 /* Don't have a reasonable notion of failure here */
1012 do_log(SMB_VFS_OP_DISK_FREE, True, handle, "%s", path);
1017 static int smb_full_audit_get_quota(struct vfs_handle_struct *handle,
1018 enum SMB_QUOTA_TYPE qtype, unid_t id,
1023 result = SMB_VFS_NEXT_GET_QUOTA(handle, qtype, id, qt);
1025 do_log(SMB_VFS_OP_GET_QUOTA, (result >= 0), handle, "");
1031 static int smb_full_audit_set_quota(struct vfs_handle_struct *handle,
1032 enum SMB_QUOTA_TYPE qtype, unid_t id,
1037 result = SMB_VFS_NEXT_SET_QUOTA(handle, qtype, id, qt);
1039 do_log(SMB_VFS_OP_SET_QUOTA, (result >= 0), handle, "");
1044 static int smb_full_audit_get_shadow_copy_data(struct vfs_handle_struct *handle,
1045 struct files_struct *fsp,
1046 SHADOW_COPY_DATA *shadow_copy_data, bool labels)
1050 result = SMB_VFS_NEXT_GET_SHADOW_COPY_DATA(handle, fsp, shadow_copy_data, labels);
1052 do_log(SMB_VFS_OP_GET_SHADOW_COPY_DATA, (result >= 0), handle, "");
1057 static int smb_full_audit_statvfs(struct vfs_handle_struct *handle,
1059 struct vfs_statvfs_struct *statbuf)
1063 result = SMB_VFS_NEXT_STATVFS(handle, path, statbuf);
1065 do_log(SMB_VFS_OP_STATVFS, (result >= 0), handle, "");
1070 static int smb_full_audit_fs_capabilities(struct vfs_handle_struct *handle)
1074 result = SMB_VFS_NEXT_FS_CAPABILITIES(handle);
1076 do_log(SMB_VFS_OP_FS_CAPABILITIES, true, handle, "");
1081 static SMB_STRUCT_DIR *smb_full_audit_opendir(vfs_handle_struct *handle,
1082 const char *fname, const char *mask, uint32 attr)
1084 SMB_STRUCT_DIR *result;
1086 result = SMB_VFS_NEXT_OPENDIR(handle, fname, mask, attr);
1088 do_log(SMB_VFS_OP_OPENDIR, (result != NULL), handle, "%s", fname);
1093 static SMB_STRUCT_DIRENT *smb_full_audit_readdir(vfs_handle_struct *handle,
1094 SMB_STRUCT_DIR *dirp, SMB_STRUCT_STAT *sbuf)
1096 SMB_STRUCT_DIRENT *result;
1098 result = SMB_VFS_NEXT_READDIR(handle, dirp, sbuf);
1100 /* This operation has no reasonable error condition
1101 * (End of dir is also failure), so always succeed.
1103 do_log(SMB_VFS_OP_READDIR, True, handle, "");
1108 static void smb_full_audit_seekdir(vfs_handle_struct *handle,
1109 SMB_STRUCT_DIR *dirp, long offset)
1111 SMB_VFS_NEXT_SEEKDIR(handle, dirp, offset);
1113 do_log(SMB_VFS_OP_SEEKDIR, True, handle, "");
1117 static long smb_full_audit_telldir(vfs_handle_struct *handle,
1118 SMB_STRUCT_DIR *dirp)
1122 result = SMB_VFS_NEXT_TELLDIR(handle, dirp);
1124 do_log(SMB_VFS_OP_TELLDIR, True, handle, "");
1129 static void smb_full_audit_rewinddir(vfs_handle_struct *handle,
1130 SMB_STRUCT_DIR *dirp)
1132 SMB_VFS_NEXT_REWINDDIR(handle, dirp);
1134 do_log(SMB_VFS_OP_REWINDDIR, True, handle, "");
1138 static int smb_full_audit_mkdir(vfs_handle_struct *handle,
1139 const char *path, mode_t mode)
1143 result = SMB_VFS_NEXT_MKDIR(handle, path, mode);
1145 do_log(SMB_VFS_OP_MKDIR, (result >= 0), handle, "%s", path);
1150 static int smb_full_audit_rmdir(vfs_handle_struct *handle,
1155 result = SMB_VFS_NEXT_RMDIR(handle, path);
1157 do_log(SMB_VFS_OP_RMDIR, (result >= 0), handle, "%s", path);
1162 static int smb_full_audit_closedir(vfs_handle_struct *handle,
1163 SMB_STRUCT_DIR *dirp)
1167 result = SMB_VFS_NEXT_CLOSEDIR(handle, dirp);
1169 do_log(SMB_VFS_OP_CLOSEDIR, (result >= 0), handle, "");
1174 static void smb_full_audit_init_search_op(vfs_handle_struct *handle,
1175 SMB_STRUCT_DIR *dirp)
1177 SMB_VFS_NEXT_INIT_SEARCH_OP(handle, dirp);
1179 do_log(SMB_VFS_OP_INIT_SEARCH_OP, True, handle, "");
1183 static int smb_full_audit_open(vfs_handle_struct *handle,
1184 const char *fname, files_struct *fsp, int flags, mode_t mode)
1188 result = SMB_VFS_NEXT_OPEN(handle, fname, fsp, flags, mode);
1190 do_log(SMB_VFS_OP_OPEN, (result >= 0), handle, "%s|%s",
1191 ((flags & O_WRONLY) || (flags & O_RDWR))?"w":"r",
1197 static NTSTATUS smb_full_audit_create_file(vfs_handle_struct *handle,
1198 struct smb_request *req,
1199 uint16_t root_dir_fid,
1201 uint32_t create_file_flags,
1202 uint32_t access_mask,
1203 uint32_t share_access,
1204 uint32_t create_disposition,
1205 uint32_t create_options,
1206 uint32_t file_attributes,
1207 uint32_t oplock_request,
1208 uint64_t allocation_size,
1209 struct security_descriptor *sd,
1210 struct ea_list *ea_list,
1211 files_struct **result_fsp,
1213 SMB_STRUCT_STAT *psbuf)
1217 result = SMB_VFS_NEXT_CREATE_FILE(
1218 handle, /* handle */
1220 root_dir_fid, /* root_dir_fid */
1222 create_file_flags, /* create_file_flags */
1223 access_mask, /* access_mask */
1224 share_access, /* share_access */
1225 create_disposition, /* create_disposition*/
1226 create_options, /* create_options */
1227 file_attributes, /* file_attributes */
1228 oplock_request, /* oplock_request */
1229 allocation_size, /* allocation_size */
1231 ea_list, /* ea_list */
1232 result_fsp, /* result */
1236 do_log(SMB_VFS_OP_CREATE_FILE, (NT_STATUS_IS_OK(result)), handle, "0x%x|%s",
1237 access_mask, fname);
1242 static int smb_full_audit_close(vfs_handle_struct *handle, files_struct *fsp)
1246 result = SMB_VFS_NEXT_CLOSE(handle, fsp);
1248 do_log(SMB_VFS_OP_CLOSE, (result >= 0), handle, "%s", fsp->fsp_name);
1253 static ssize_t smb_full_audit_read(vfs_handle_struct *handle, files_struct *fsp,
1254 void *data, size_t n)
1258 result = SMB_VFS_NEXT_READ(handle, fsp, data, n);
1260 do_log(SMB_VFS_OP_READ, (result >= 0), handle, "%s", fsp->fsp_name);
1265 static ssize_t smb_full_audit_pread(vfs_handle_struct *handle, files_struct *fsp,
1266 void *data, size_t n, SMB_OFF_T offset)
1270 result = SMB_VFS_NEXT_PREAD(handle, fsp, data, n, offset);
1272 do_log(SMB_VFS_OP_PREAD, (result >= 0), handle, "%s", fsp->fsp_name);
1277 static ssize_t smb_full_audit_write(vfs_handle_struct *handle, files_struct *fsp,
1278 const void *data, size_t n)
1282 result = SMB_VFS_NEXT_WRITE(handle, fsp, data, n);
1284 do_log(SMB_VFS_OP_WRITE, (result >= 0), handle, "%s", fsp->fsp_name);
1289 static ssize_t smb_full_audit_pwrite(vfs_handle_struct *handle, files_struct *fsp,
1290 const void *data, size_t n,
1295 result = SMB_VFS_NEXT_PWRITE(handle, fsp, data, n, offset);
1297 do_log(SMB_VFS_OP_PWRITE, (result >= 0), handle, "%s", fsp->fsp_name);
1302 static SMB_OFF_T smb_full_audit_lseek(vfs_handle_struct *handle, files_struct *fsp,
1303 SMB_OFF_T offset, int whence)
1307 result = SMB_VFS_NEXT_LSEEK(handle, fsp, offset, whence);
1309 do_log(SMB_VFS_OP_LSEEK, (result != (ssize_t)-1), handle,
1310 "%s", fsp->fsp_name);
1315 static ssize_t smb_full_audit_sendfile(vfs_handle_struct *handle, int tofd,
1316 files_struct *fromfsp,
1317 const DATA_BLOB *hdr, SMB_OFF_T offset,
1322 result = SMB_VFS_NEXT_SENDFILE(handle, tofd, fromfsp, hdr, offset, n);
1324 do_log(SMB_VFS_OP_SENDFILE, (result >= 0), handle,
1325 "%s", fromfsp->fsp_name);
1330 static ssize_t smb_full_audit_recvfile(vfs_handle_struct *handle, int fromfd,
1331 files_struct *tofsp,
1337 result = SMB_VFS_NEXT_RECVFILE(handle, fromfd, tofsp, offset, n);
1339 do_log(SMB_VFS_OP_RECVFILE, (result >= 0), handle,
1340 "%s", tofsp->fsp_name);
1345 static int smb_full_audit_rename(vfs_handle_struct *handle,
1346 const char *oldname, const char *newname)
1350 result = SMB_VFS_NEXT_RENAME(handle, oldname, newname);
1352 do_log(SMB_VFS_OP_RENAME, (result >= 0), handle, "%s|%s", oldname, newname);
1357 static int smb_full_audit_fsync(vfs_handle_struct *handle, files_struct *fsp)
1361 result = SMB_VFS_NEXT_FSYNC(handle, fsp);
1363 do_log(SMB_VFS_OP_FSYNC, (result >= 0), handle, "%s", fsp->fsp_name);
1368 static int smb_full_audit_stat(vfs_handle_struct *handle,
1369 const char *fname, SMB_STRUCT_STAT *sbuf)
1373 result = SMB_VFS_NEXT_STAT(handle, fname, sbuf);
1375 do_log(SMB_VFS_OP_STAT, (result >= 0), handle, "%s", fname);
1380 static int smb_full_audit_fstat(vfs_handle_struct *handle, files_struct *fsp,
1381 SMB_STRUCT_STAT *sbuf)
1385 result = SMB_VFS_NEXT_FSTAT(handle, fsp, sbuf);
1387 do_log(SMB_VFS_OP_FSTAT, (result >= 0), handle, "%s", fsp->fsp_name);
1392 static int smb_full_audit_lstat(vfs_handle_struct *handle,
1393 const char *path, SMB_STRUCT_STAT *sbuf)
1397 result = SMB_VFS_NEXT_LSTAT(handle, path, sbuf);
1399 do_log(SMB_VFS_OP_LSTAT, (result >= 0), handle, "%s", path);
1404 static int smb_full_audit_get_alloc_size(vfs_handle_struct *handle,
1405 files_struct *fsp, const SMB_STRUCT_STAT *sbuf)
1409 result = SMB_VFS_NEXT_GET_ALLOC_SIZE(handle, fsp, sbuf);
1411 do_log(SMB_VFS_OP_GET_ALLOC_SIZE, (result >= 0), handle, "%d", result);
1416 static int smb_full_audit_unlink(vfs_handle_struct *handle,
1421 result = SMB_VFS_NEXT_UNLINK(handle, path);
1423 do_log(SMB_VFS_OP_UNLINK, (result >= 0), handle, "%s", path);
1428 static int smb_full_audit_chmod(vfs_handle_struct *handle,
1429 const char *path, mode_t mode)
1433 result = SMB_VFS_NEXT_CHMOD(handle, path, mode);
1435 do_log(SMB_VFS_OP_CHMOD, (result >= 0), handle, "%s|%o", path, mode);
1440 static int smb_full_audit_fchmod(vfs_handle_struct *handle, files_struct *fsp,
1445 result = SMB_VFS_NEXT_FCHMOD(handle, fsp, mode);
1447 do_log(SMB_VFS_OP_FCHMOD, (result >= 0), handle,
1448 "%s|%o", fsp->fsp_name, mode);
1453 static int smb_full_audit_chown(vfs_handle_struct *handle,
1454 const char *path, uid_t uid, gid_t gid)
1458 result = SMB_VFS_NEXT_CHOWN(handle, path, uid, gid);
1460 do_log(SMB_VFS_OP_CHOWN, (result >= 0), handle, "%s|%ld|%ld",
1461 path, (long int)uid, (long int)gid);
1466 static int smb_full_audit_fchown(vfs_handle_struct *handle, files_struct *fsp,
1467 uid_t uid, gid_t gid)
1471 result = SMB_VFS_NEXT_FCHOWN(handle, fsp, uid, gid);
1473 do_log(SMB_VFS_OP_FCHOWN, (result >= 0), handle, "%s|%ld|%ld",
1474 fsp->fsp_name, (long int)uid, (long int)gid);
1479 static int smb_full_audit_lchown(vfs_handle_struct *handle,
1480 const char *path, uid_t uid, gid_t gid)
1484 result = SMB_VFS_NEXT_LCHOWN(handle, path, uid, gid);
1486 do_log(SMB_VFS_OP_LCHOWN, (result >= 0), handle, "%s|%ld|%ld",
1487 path, (long int)uid, (long int)gid);
1492 static int smb_full_audit_chdir(vfs_handle_struct *handle,
1497 result = SMB_VFS_NEXT_CHDIR(handle, path);
1499 do_log(SMB_VFS_OP_CHDIR, (result >= 0), handle, "chdir|%s", path);
1504 static char *smb_full_audit_getwd(vfs_handle_struct *handle,
1509 result = SMB_VFS_NEXT_GETWD(handle, path);
1511 do_log(SMB_VFS_OP_GETWD, (result != NULL), handle, "%s", path);
1516 static int smb_full_audit_ntimes(vfs_handle_struct *handle,
1517 const char *path, struct smb_file_time *ft)
1521 result = SMB_VFS_NEXT_NTIMES(handle, path, ft);
1523 do_log(SMB_VFS_OP_NTIMES, (result >= 0), handle, "%s", path);
1528 static int smb_full_audit_ftruncate(vfs_handle_struct *handle, files_struct *fsp,
1533 result = SMB_VFS_NEXT_FTRUNCATE(handle, fsp, len);
1535 do_log(SMB_VFS_OP_FTRUNCATE, (result >= 0), handle,
1536 "%s", fsp->fsp_name);
1541 static bool smb_full_audit_lock(vfs_handle_struct *handle, files_struct *fsp,
1542 int op, SMB_OFF_T offset, SMB_OFF_T count, int type)
1546 result = SMB_VFS_NEXT_LOCK(handle, fsp, op, offset, count, type);
1548 do_log(SMB_VFS_OP_LOCK, result, handle, "%s", fsp->fsp_name);
1553 static int smb_full_audit_kernel_flock(struct vfs_handle_struct *handle,
1554 struct files_struct *fsp,
1559 result = SMB_VFS_NEXT_KERNEL_FLOCK(handle, fsp, share_mode);
1561 do_log(SMB_VFS_OP_KERNEL_FLOCK, (result >= 0), handle, "%s",
1567 static int smb_full_audit_linux_setlease(vfs_handle_struct *handle, files_struct *fsp,
1572 result = SMB_VFS_NEXT_LINUX_SETLEASE(handle, fsp, leasetype);
1574 do_log(SMB_VFS_OP_LINUX_SETLEASE, (result >= 0), handle, "%s",
1580 static bool smb_full_audit_getlock(vfs_handle_struct *handle, files_struct *fsp,
1581 SMB_OFF_T *poffset, SMB_OFF_T *pcount, int *ptype, pid_t *ppid)
1585 result = SMB_VFS_NEXT_GETLOCK(handle, fsp, poffset, pcount, ptype, ppid);
1587 do_log(SMB_VFS_OP_GETLOCK, result, handle, "%s", fsp->fsp_name);
1592 static int smb_full_audit_symlink(vfs_handle_struct *handle,
1593 const char *oldpath, const char *newpath)
1597 result = SMB_VFS_NEXT_SYMLINK(handle, oldpath, newpath);
1599 do_log(SMB_VFS_OP_SYMLINK, (result >= 0), handle,
1600 "%s|%s", oldpath, newpath);
1605 static int smb_full_audit_readlink(vfs_handle_struct *handle,
1606 const char *path, char *buf, size_t bufsiz)
1610 result = SMB_VFS_NEXT_READLINK(handle, path, buf, bufsiz);
1612 do_log(SMB_VFS_OP_READLINK, (result >= 0), handle, "%s", path);
1617 static int smb_full_audit_link(vfs_handle_struct *handle,
1618 const char *oldpath, const char *newpath)
1622 result = SMB_VFS_NEXT_LINK(handle, oldpath, newpath);
1624 do_log(SMB_VFS_OP_LINK, (result >= 0), handle,
1625 "%s|%s", oldpath, newpath);
1630 static int smb_full_audit_mknod(vfs_handle_struct *handle,
1631 const char *pathname, mode_t mode, SMB_DEV_T dev)
1635 result = SMB_VFS_NEXT_MKNOD(handle, pathname, mode, dev);
1637 do_log(SMB_VFS_OP_MKNOD, (result >= 0), handle, "%s", pathname);
1642 static char *smb_full_audit_realpath(vfs_handle_struct *handle,
1643 const char *path, char *resolved_path)
1647 result = SMB_VFS_NEXT_REALPATH(handle, path, resolved_path);
1649 do_log(SMB_VFS_OP_REALPATH, (result != NULL), handle, "%s", path);
1654 static NTSTATUS smb_full_audit_notify_watch(struct vfs_handle_struct *handle,
1655 struct sys_notify_context *ctx,
1656 struct notify_entry *e,
1657 void (*callback)(struct sys_notify_context *ctx,
1659 struct notify_event *ev),
1660 void *private_data, void *handle_p)
1664 result = SMB_VFS_NEXT_NOTIFY_WATCH(handle, ctx, e, callback, private_data, handle_p);
1666 do_log(SMB_VFS_OP_NOTIFY_WATCH, NT_STATUS_IS_OK(result), handle, "");
1671 static int smb_full_audit_chflags(vfs_handle_struct *handle,
1672 const char *path, unsigned int flags)
1676 result = SMB_VFS_NEXT_CHFLAGS(handle, path, flags);
1678 do_log(SMB_VFS_OP_CHFLAGS, (result != 0), handle, "%s", path);
1683 static struct file_id smb_full_audit_file_id_create(struct vfs_handle_struct *handle,
1684 const SMB_STRUCT_STAT *sbuf)
1686 struct file_id id_zero;
1687 struct file_id result;
1689 ZERO_STRUCT(id_zero);
1691 result = SMB_VFS_NEXT_FILE_ID_CREATE(handle, sbuf);
1693 do_log(SMB_VFS_OP_FILE_ID_CREATE,
1694 !file_id_equal(&id_zero, &result),
1695 handle, "%s", file_id_string_tos(&result));
1700 static NTSTATUS smb_full_audit_streaminfo(vfs_handle_struct *handle,
1701 struct files_struct *fsp,
1703 TALLOC_CTX *mem_ctx,
1704 unsigned int *pnum_streams,
1705 struct stream_struct **pstreams)
1709 result = SMB_VFS_NEXT_STREAMINFO(handle, fsp, fname, mem_ctx,
1710 pnum_streams, pstreams);
1712 do_log(SMB_VFS_OP_STREAMINFO, NT_STATUS_IS_OK(result), handle,
1718 static int smb_full_audit_get_real_filename(struct vfs_handle_struct *handle,
1721 TALLOC_CTX *mem_ctx,
1726 result = SMB_VFS_NEXT_GET_REAL_FILENAME(handle, path, name, mem_ctx,
1729 do_log(SMB_VFS_OP_GET_REAL_FILENAME, (result == 0), handle,
1730 "%s/%s->%s", path, name, (result == 0) ? "" : *found_name);
1735 static const char *smb_full_audit_connectpath(vfs_handle_struct *handle,
1740 result = SMB_VFS_NEXT_CONNECTPATH(handle, fname);
1742 do_log(SMB_VFS_OP_CONNECTPATH, result != NULL, handle,
1748 static NTSTATUS smb_full_audit_brl_lock_windows(struct vfs_handle_struct *handle,
1749 struct byte_range_lock *br_lck,
1750 struct lock_struct *plock,
1752 struct blocking_lock_record *blr)
1756 result = SMB_VFS_NEXT_BRL_LOCK_WINDOWS(handle, br_lck, plock,
1757 blocking_lock, blr);
1759 do_log(SMB_VFS_OP_BRL_LOCK_WINDOWS, NT_STATUS_IS_OK(result), handle,
1760 "%s:%llu-%llu. type=%d. blocking=%d", br_lck->fsp->fsp_name,
1761 plock->start, plock->size, plock->lock_type, blocking_lock );
1766 static bool smb_full_audit_brl_unlock_windows(struct vfs_handle_struct *handle,
1767 struct messaging_context *msg_ctx,
1768 struct byte_range_lock *br_lck,
1769 const struct lock_struct *plock)
1773 result = SMB_VFS_NEXT_BRL_UNLOCK_WINDOWS(handle, msg_ctx, br_lck,
1776 do_log(SMB_VFS_OP_BRL_UNLOCK_WINDOWS, (result == 0), handle,
1777 "%s:%llu-%llu:%d", br_lck->fsp->fsp_name, plock->start,
1778 plock->size, plock->lock_type);
1783 static bool smb_full_audit_brl_cancel_windows(struct vfs_handle_struct *handle,
1784 struct byte_range_lock *br_lck,
1785 struct lock_struct *plock,
1786 struct blocking_lock_record *blr)
1790 result = SMB_VFS_NEXT_BRL_CANCEL_WINDOWS(handle, br_lck, plock, blr);
1792 do_log(SMB_VFS_OP_BRL_CANCEL_WINDOWS, (result == 0), handle,
1793 "%s:%llu-%llu:%d", br_lck->fsp->fsp_name, plock->start,
1799 static bool smb_full_audit_strict_lock(struct vfs_handle_struct *handle,
1800 struct files_struct *fsp,
1801 struct lock_struct *plock)
1805 result = SMB_VFS_NEXT_STRICT_LOCK(handle, fsp, plock);
1807 do_log(SMB_VFS_OP_STRICT_LOCK, result, handle,
1808 "%s:%llu-%llu:%d", fsp->fsp_name, plock->start,
1814 static void smb_full_audit_strict_unlock(struct vfs_handle_struct *handle,
1815 struct files_struct *fsp,
1816 struct lock_struct *plock)
1818 SMB_VFS_NEXT_STRICT_UNLOCK(handle, fsp, plock);
1820 do_log(SMB_VFS_OP_STRICT_UNLOCK, true, handle,
1821 "%s:%llu-%llu:%d", fsp->fsp_name, plock->start,
1827 static NTSTATUS smb_full_audit_fget_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
1828 uint32 security_info,
1833 result = SMB_VFS_NEXT_FGET_NT_ACL(handle, fsp, security_info, ppdesc);
1835 do_log(SMB_VFS_OP_FGET_NT_ACL, NT_STATUS_IS_OK(result), handle,
1836 "%s", fsp->fsp_name);
1841 static NTSTATUS smb_full_audit_get_nt_acl(vfs_handle_struct *handle,
1843 uint32 security_info,
1848 result = SMB_VFS_NEXT_GET_NT_ACL(handle, name, security_info, ppdesc);
1850 do_log(SMB_VFS_OP_GET_NT_ACL, NT_STATUS_IS_OK(result), handle,
1856 static NTSTATUS smb_full_audit_fset_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
1857 uint32 security_info_sent,
1858 const SEC_DESC *psd)
1862 result = SMB_VFS_NEXT_FSET_NT_ACL(handle, fsp, security_info_sent, psd);
1864 do_log(SMB_VFS_OP_FSET_NT_ACL, NT_STATUS_IS_OK(result), handle, "%s", fsp->fsp_name);
1869 static int smb_full_audit_chmod_acl(vfs_handle_struct *handle,
1870 const char *path, mode_t mode)
1874 result = SMB_VFS_NEXT_CHMOD_ACL(handle, path, mode);
1876 do_log(SMB_VFS_OP_CHMOD_ACL, (result >= 0), handle,
1877 "%s|%o", path, mode);
1882 static int smb_full_audit_fchmod_acl(vfs_handle_struct *handle, files_struct *fsp,
1887 result = SMB_VFS_NEXT_FCHMOD_ACL(handle, fsp, mode);
1889 do_log(SMB_VFS_OP_FCHMOD_ACL, (result >= 0), handle,
1890 "%s|%o", fsp->fsp_name, mode);
1895 static int smb_full_audit_sys_acl_get_entry(vfs_handle_struct *handle,
1897 SMB_ACL_T theacl, int entry_id,
1898 SMB_ACL_ENTRY_T *entry_p)
1902 result = SMB_VFS_NEXT_SYS_ACL_GET_ENTRY(handle, theacl, entry_id,
1905 do_log(SMB_VFS_OP_SYS_ACL_GET_ENTRY, (result >= 0), handle,
1911 static int smb_full_audit_sys_acl_get_tag_type(vfs_handle_struct *handle,
1913 SMB_ACL_ENTRY_T entry_d,
1914 SMB_ACL_TAG_T *tag_type_p)
1918 result = SMB_VFS_NEXT_SYS_ACL_GET_TAG_TYPE(handle, entry_d,
1921 do_log(SMB_VFS_OP_SYS_ACL_GET_TAG_TYPE, (result >= 0), handle,
1927 static int smb_full_audit_sys_acl_get_permset(vfs_handle_struct *handle,
1929 SMB_ACL_ENTRY_T entry_d,
1930 SMB_ACL_PERMSET_T *permset_p)
1934 result = SMB_VFS_NEXT_SYS_ACL_GET_PERMSET(handle, entry_d,
1937 do_log(SMB_VFS_OP_SYS_ACL_GET_PERMSET, (result >= 0), handle,
1943 static void * smb_full_audit_sys_acl_get_qualifier(vfs_handle_struct *handle,
1945 SMB_ACL_ENTRY_T entry_d)
1949 result = SMB_VFS_NEXT_SYS_ACL_GET_QUALIFIER(handle, entry_d);
1951 do_log(SMB_VFS_OP_SYS_ACL_GET_QUALIFIER, (result != NULL), handle,
1957 static SMB_ACL_T smb_full_audit_sys_acl_get_file(vfs_handle_struct *handle,
1959 SMB_ACL_TYPE_T type)
1963 result = SMB_VFS_NEXT_SYS_ACL_GET_FILE(handle, path_p, type);
1965 do_log(SMB_VFS_OP_SYS_ACL_GET_FILE, (result != NULL), handle,
1971 static SMB_ACL_T smb_full_audit_sys_acl_get_fd(vfs_handle_struct *handle,
1976 result = SMB_VFS_NEXT_SYS_ACL_GET_FD(handle, fsp);
1978 do_log(SMB_VFS_OP_SYS_ACL_GET_FD, (result != NULL), handle,
1979 "%s", fsp->fsp_name);
1984 static int smb_full_audit_sys_acl_clear_perms(vfs_handle_struct *handle,
1986 SMB_ACL_PERMSET_T permset)
1990 result = SMB_VFS_NEXT_SYS_ACL_CLEAR_PERMS(handle, permset);
1992 do_log(SMB_VFS_OP_SYS_ACL_CLEAR_PERMS, (result >= 0), handle,
1998 static int smb_full_audit_sys_acl_add_perm(vfs_handle_struct *handle,
2000 SMB_ACL_PERMSET_T permset,
2001 SMB_ACL_PERM_T perm)
2005 result = SMB_VFS_NEXT_SYS_ACL_ADD_PERM(handle, permset, perm);
2007 do_log(SMB_VFS_OP_SYS_ACL_ADD_PERM, (result >= 0), handle,
2013 static char * smb_full_audit_sys_acl_to_text(vfs_handle_struct *handle,
2019 result = SMB_VFS_NEXT_SYS_ACL_TO_TEXT(handle, theacl, plen);
2021 do_log(SMB_VFS_OP_SYS_ACL_TO_TEXT, (result != NULL), handle,
2027 static SMB_ACL_T smb_full_audit_sys_acl_init(vfs_handle_struct *handle,
2033 result = SMB_VFS_NEXT_SYS_ACL_INIT(handle, count);
2035 do_log(SMB_VFS_OP_SYS_ACL_INIT, (result != NULL), handle,
2041 static int smb_full_audit_sys_acl_create_entry(vfs_handle_struct *handle,
2043 SMB_ACL_ENTRY_T *pentry)
2047 result = SMB_VFS_NEXT_SYS_ACL_CREATE_ENTRY(handle, pacl, pentry);
2049 do_log(SMB_VFS_OP_SYS_ACL_CREATE_ENTRY, (result >= 0), handle,
2055 static int smb_full_audit_sys_acl_set_tag_type(vfs_handle_struct *handle,
2057 SMB_ACL_ENTRY_T entry,
2058 SMB_ACL_TAG_T tagtype)
2062 result = SMB_VFS_NEXT_SYS_ACL_SET_TAG_TYPE(handle, entry,
2065 do_log(SMB_VFS_OP_SYS_ACL_SET_TAG_TYPE, (result >= 0), handle,
2071 static int smb_full_audit_sys_acl_set_qualifier(vfs_handle_struct *handle,
2073 SMB_ACL_ENTRY_T entry,
2078 result = SMB_VFS_NEXT_SYS_ACL_SET_QUALIFIER(handle, entry, qual);
2080 do_log(SMB_VFS_OP_SYS_ACL_SET_QUALIFIER, (result >= 0), handle,
2086 static int smb_full_audit_sys_acl_set_permset(vfs_handle_struct *handle,
2088 SMB_ACL_ENTRY_T entry,
2089 SMB_ACL_PERMSET_T permset)
2093 result = SMB_VFS_NEXT_SYS_ACL_SET_PERMSET(handle, entry, permset);
2095 do_log(SMB_VFS_OP_SYS_ACL_SET_PERMSET, (result >= 0), handle,
2101 static int smb_full_audit_sys_acl_valid(vfs_handle_struct *handle,
2107 result = SMB_VFS_NEXT_SYS_ACL_VALID(handle, theacl);
2109 do_log(SMB_VFS_OP_SYS_ACL_VALID, (result >= 0), handle,
2115 static int smb_full_audit_sys_acl_set_file(vfs_handle_struct *handle,
2117 const char *name, SMB_ACL_TYPE_T acltype,
2122 result = SMB_VFS_NEXT_SYS_ACL_SET_FILE(handle, name, acltype,
2125 do_log(SMB_VFS_OP_SYS_ACL_SET_FILE, (result >= 0), handle,
2131 static int smb_full_audit_sys_acl_set_fd(vfs_handle_struct *handle, files_struct *fsp,
2136 result = SMB_VFS_NEXT_SYS_ACL_SET_FD(handle, fsp, theacl);
2138 do_log(SMB_VFS_OP_SYS_ACL_SET_FD, (result >= 0), handle,
2139 "%s", fsp->fsp_name);
2144 static int smb_full_audit_sys_acl_delete_def_file(vfs_handle_struct *handle,
2150 result = SMB_VFS_NEXT_SYS_ACL_DELETE_DEF_FILE(handle, path);
2152 do_log(SMB_VFS_OP_SYS_ACL_DELETE_DEF_FILE, (result >= 0), handle,
2158 static int smb_full_audit_sys_acl_get_perm(vfs_handle_struct *handle,
2160 SMB_ACL_PERMSET_T permset,
2161 SMB_ACL_PERM_T perm)
2165 result = SMB_VFS_NEXT_SYS_ACL_GET_PERM(handle, permset, perm);
2167 do_log(SMB_VFS_OP_SYS_ACL_GET_PERM, (result >= 0), handle,
2173 static int smb_full_audit_sys_acl_free_text(vfs_handle_struct *handle,
2179 result = SMB_VFS_NEXT_SYS_ACL_FREE_TEXT(handle, text);
2181 do_log(SMB_VFS_OP_SYS_ACL_FREE_TEXT, (result >= 0), handle,
2187 static int smb_full_audit_sys_acl_free_acl(vfs_handle_struct *handle,
2189 SMB_ACL_T posix_acl)
2193 result = SMB_VFS_NEXT_SYS_ACL_FREE_ACL(handle, posix_acl);
2195 do_log(SMB_VFS_OP_SYS_ACL_FREE_ACL, (result >= 0), handle,
2201 static int smb_full_audit_sys_acl_free_qualifier(vfs_handle_struct *handle,
2203 SMB_ACL_TAG_T tagtype)
2207 result = SMB_VFS_NEXT_SYS_ACL_FREE_QUALIFIER(handle, qualifier,
2210 do_log(SMB_VFS_OP_SYS_ACL_FREE_QUALIFIER, (result >= 0), handle,
2216 static ssize_t smb_full_audit_getxattr(struct vfs_handle_struct *handle,
2218 const char *name, void *value, size_t size)
2222 result = SMB_VFS_NEXT_GETXATTR(handle, path, name, value, size);
2224 do_log(SMB_VFS_OP_GETXATTR, (result >= 0), handle,
2225 "%s|%s", path, name);
2230 static ssize_t smb_full_audit_lgetxattr(struct vfs_handle_struct *handle,
2231 const char *path, const char *name,
2232 void *value, size_t size)
2236 result = SMB_VFS_NEXT_LGETXATTR(handle, path, name, value, size);
2238 do_log(SMB_VFS_OP_LGETXATTR, (result >= 0), handle,
2239 "%s|%s", path, name);
2244 static ssize_t smb_full_audit_fgetxattr(struct vfs_handle_struct *handle,
2245 struct files_struct *fsp,
2246 const char *name, void *value, size_t size)
2250 result = SMB_VFS_NEXT_FGETXATTR(handle, fsp, name, value, size);
2252 do_log(SMB_VFS_OP_FGETXATTR, (result >= 0), handle,
2253 "%s|%s", fsp->fsp_name, name);
2258 static ssize_t smb_full_audit_listxattr(struct vfs_handle_struct *handle,
2259 const char *path, char *list, size_t size)
2263 result = SMB_VFS_NEXT_LISTXATTR(handle, path, list, size);
2265 do_log(SMB_VFS_OP_LISTXATTR, (result >= 0), handle, "%s", path);
2270 static ssize_t smb_full_audit_llistxattr(struct vfs_handle_struct *handle,
2271 const char *path, char *list, size_t size)
2275 result = SMB_VFS_NEXT_LLISTXATTR(handle, path, list, size);
2277 do_log(SMB_VFS_OP_LLISTXATTR, (result >= 0), handle, "%s", path);
2282 static ssize_t smb_full_audit_flistxattr(struct vfs_handle_struct *handle,
2283 struct files_struct *fsp, char *list,
2288 result = SMB_VFS_NEXT_FLISTXATTR(handle, fsp, list, size);
2290 do_log(SMB_VFS_OP_FLISTXATTR, (result >= 0), handle,
2291 "%s", fsp->fsp_name);
2296 static int smb_full_audit_removexattr(struct vfs_handle_struct *handle,
2302 result = SMB_VFS_NEXT_REMOVEXATTR(handle, path, name);
2304 do_log(SMB_VFS_OP_REMOVEXATTR, (result >= 0), handle,
2305 "%s|%s", path, name);
2310 static int smb_full_audit_lremovexattr(struct vfs_handle_struct *handle,
2316 result = SMB_VFS_NEXT_LREMOVEXATTR(handle, path, name);
2318 do_log(SMB_VFS_OP_LREMOVEXATTR, (result >= 0), handle,
2319 "%s|%s", path, name);
2324 static int smb_full_audit_fremovexattr(struct vfs_handle_struct *handle,
2325 struct files_struct *fsp,
2330 result = SMB_VFS_NEXT_FREMOVEXATTR(handle, fsp, name);
2332 do_log(SMB_VFS_OP_FREMOVEXATTR, (result >= 0), handle,
2333 "%s|%s", fsp->fsp_name, name);
2338 static int smb_full_audit_setxattr(struct vfs_handle_struct *handle,
2340 const char *name, const void *value, size_t size,
2345 result = SMB_VFS_NEXT_SETXATTR(handle, path, name, value, size,
2348 do_log(SMB_VFS_OP_SETXATTR, (result >= 0), handle,
2349 "%s|%s", path, name);
2354 static int smb_full_audit_lsetxattr(struct vfs_handle_struct *handle,
2356 const char *name, const void *value, size_t size,
2361 result = SMB_VFS_NEXT_LSETXATTR(handle, path, name, value, size,
2364 do_log(SMB_VFS_OP_LSETXATTR, (result >= 0), handle,
2365 "%s|%s", path, name);
2370 static int smb_full_audit_fsetxattr(struct vfs_handle_struct *handle,
2371 struct files_struct *fsp, const char *name,
2372 const void *value, size_t size, int flags)
2376 result = SMB_VFS_NEXT_FSETXATTR(handle, fsp, name, value, size, flags);
2378 do_log(SMB_VFS_OP_FSETXATTR, (result >= 0), handle,
2379 "%s|%s", fsp->fsp_name, name);
2384 static int smb_full_audit_aio_read(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb)
2388 result = SMB_VFS_NEXT_AIO_READ(handle, fsp, aiocb);
2389 do_log(SMB_VFS_OP_AIO_READ, (result >= 0), handle,
2390 "%s", fsp->fsp_name);
2395 static int smb_full_audit_aio_write(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb)
2399 result = SMB_VFS_NEXT_AIO_WRITE(handle, fsp, aiocb);
2400 do_log(SMB_VFS_OP_AIO_WRITE, (result >= 0), handle,
2401 "%s", fsp->fsp_name);
2406 static ssize_t smb_full_audit_aio_return(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb)
2410 result = SMB_VFS_NEXT_AIO_RETURN(handle, fsp, aiocb);
2411 do_log(SMB_VFS_OP_AIO_RETURN, (result >= 0), handle,
2412 "%s", fsp->fsp_name);
2417 static int smb_full_audit_aio_cancel(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb)
2421 result = SMB_VFS_NEXT_AIO_CANCEL(handle, fsp, aiocb);
2422 do_log(SMB_VFS_OP_AIO_CANCEL, (result >= 0), handle,
2423 "%s", fsp->fsp_name);
2428 static int smb_full_audit_aio_error(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb)
2432 result = SMB_VFS_NEXT_AIO_ERROR(handle, fsp, aiocb);
2433 do_log(SMB_VFS_OP_AIO_ERROR, (result >= 0), handle,
2434 "%s", fsp->fsp_name);
2439 static int smb_full_audit_aio_fsync(struct vfs_handle_struct *handle, struct files_struct *fsp, int op, SMB_STRUCT_AIOCB *aiocb)
2443 result = SMB_VFS_NEXT_AIO_FSYNC(handle, fsp, op, aiocb);
2444 do_log(SMB_VFS_OP_AIO_FSYNC, (result >= 0), handle,
2445 "%s", fsp->fsp_name);
2450 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)
2454 result = SMB_VFS_NEXT_AIO_SUSPEND(handle, fsp, aiocb, n, ts);
2455 do_log(SMB_VFS_OP_AIO_SUSPEND, (result >= 0), handle,
2456 "%s", fsp->fsp_name);
2461 static bool smb_full_audit_aio_force(struct vfs_handle_struct *handle,
2462 struct files_struct *fsp)
2466 result = SMB_VFS_NEXT_AIO_FORCE(handle, fsp);
2467 do_log(SMB_VFS_OP_AIO_FORCE, result, handle,
2468 "%s", fsp->fsp_name);
2473 NTSTATUS vfs_full_audit_init(void);
2474 NTSTATUS vfs_full_audit_init(void)
2476 NTSTATUS ret = smb_register_vfs(SMB_VFS_INTERFACE_VERSION,
2477 "full_audit", audit_op_tuples);
2479 if (!NT_STATUS_IS_OK(ret))
2482 vfs_full_audit_debug_level = debug_add_class("full_audit");
2483 if (vfs_full_audit_debug_level == -1) {
2484 vfs_full_audit_debug_level = DBGC_VFS;
2485 DEBUG(0, ("vfs_full_audit: Couldn't register custom debugging "
2488 DEBUG(10, ("vfs_full_audit: Debug class number of "
2489 "'full_audit': %d\n", vfs_full_audit_debug_level));