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 extern userdom_struct current_user_info;
64 static int vfs_full_audit_debug_level = DBGC_VFS;
66 struct vfs_full_audit_private_data {
67 struct bitmap *success_ops;
68 struct bitmap *failure_ops;
72 #define DBGC_CLASS vfs_full_audit_debug_level
74 /* Function prototypes */
76 static int smb_full_audit_connect(vfs_handle_struct *handle,
77 const char *svc, const char *user);
78 static void smb_full_audit_disconnect(vfs_handle_struct *handle);
79 static SMB_BIG_UINT smb_full_audit_disk_free(vfs_handle_struct *handle,
81 bool small_query, SMB_BIG_UINT *bsize,
82 SMB_BIG_UINT *dfree, SMB_BIG_UINT *dsize);
83 static int smb_full_audit_get_quota(struct vfs_handle_struct *handle,
84 enum SMB_QUOTA_TYPE qtype, unid_t id,
86 static int smb_full_audit_set_quota(struct vfs_handle_struct *handle,
87 enum SMB_QUOTA_TYPE qtype, unid_t id,
89 static int smb_full_audit_get_shadow_copy_data(struct vfs_handle_struct *handle,
90 struct files_struct *fsp,
91 SHADOW_COPY_DATA *shadow_copy_data, bool labels);
92 static int smb_full_audit_statvfs(struct vfs_handle_struct *handle,
94 struct vfs_statvfs_struct *statbuf);
96 static SMB_STRUCT_DIR *smb_full_audit_opendir(vfs_handle_struct *handle,
97 const char *fname, const char *mask, uint32 attr);
98 static SMB_STRUCT_DIRENT *smb_full_audit_readdir(vfs_handle_struct *handle,
99 SMB_STRUCT_DIR *dirp);
100 static void smb_full_audit_seekdir(vfs_handle_struct *handle,
101 SMB_STRUCT_DIR *dirp, long offset);
102 static long smb_full_audit_telldir(vfs_handle_struct *handle,
103 SMB_STRUCT_DIR *dirp);
104 static void smb_full_audit_rewinddir(vfs_handle_struct *handle,
105 SMB_STRUCT_DIR *dirp);
106 static int smb_full_audit_mkdir(vfs_handle_struct *handle,
107 const char *path, mode_t mode);
108 static int smb_full_audit_rmdir(vfs_handle_struct *handle,
110 static int smb_full_audit_closedir(vfs_handle_struct *handle,
111 SMB_STRUCT_DIR *dirp);
112 static int smb_full_audit_open(vfs_handle_struct *handle,
113 const char *fname, files_struct *fsp, int flags, mode_t mode);
114 static int smb_full_audit_close(vfs_handle_struct *handle, files_struct *fsp);
115 static ssize_t smb_full_audit_read(vfs_handle_struct *handle, files_struct *fsp,
116 void *data, size_t n);
117 static ssize_t smb_full_audit_pread(vfs_handle_struct *handle, files_struct *fsp,
118 void *data, size_t n, SMB_OFF_T offset);
119 static ssize_t smb_full_audit_write(vfs_handle_struct *handle, files_struct *fsp,
120 const void *data, size_t n);
121 static ssize_t smb_full_audit_pwrite(vfs_handle_struct *handle, files_struct *fsp,
122 const void *data, size_t n,
124 static SMB_OFF_T smb_full_audit_lseek(vfs_handle_struct *handle, files_struct *fsp,
125 SMB_OFF_T offset, int whence);
126 static ssize_t smb_full_audit_sendfile(vfs_handle_struct *handle, int tofd,
127 files_struct *fromfsp,
128 const DATA_BLOB *hdr, SMB_OFF_T offset,
130 static ssize_t smb_full_audit_recvfile(vfs_handle_struct *handle, int fromfd,
134 static int smb_full_audit_rename(vfs_handle_struct *handle,
135 const char *oldname, const char *newname);
136 static int smb_full_audit_fsync(vfs_handle_struct *handle, files_struct *fsp);
137 static int smb_full_audit_stat(vfs_handle_struct *handle,
138 const char *fname, SMB_STRUCT_STAT *sbuf);
139 static int smb_full_audit_fstat(vfs_handle_struct *handle, files_struct *fsp,
140 SMB_STRUCT_STAT *sbuf);
141 static int smb_full_audit_lstat(vfs_handle_struct *handle,
142 const char *path, SMB_STRUCT_STAT *sbuf);
143 static int smb_full_audit_unlink(vfs_handle_struct *handle,
145 static int smb_full_audit_chmod(vfs_handle_struct *handle,
146 const char *path, mode_t mode);
147 static int smb_full_audit_fchmod(vfs_handle_struct *handle, files_struct *fsp,
149 static int smb_full_audit_chown(vfs_handle_struct *handle,
150 const char *path, uid_t uid, gid_t gid);
151 static int smb_full_audit_fchown(vfs_handle_struct *handle, files_struct *fsp,
152 uid_t uid, gid_t gid);
153 static int smb_full_audit_lchown(vfs_handle_struct *handle,
154 const char *path, uid_t uid, gid_t gid);
155 static int smb_full_audit_chdir(vfs_handle_struct *handle,
157 static char *smb_full_audit_getwd(vfs_handle_struct *handle,
159 static int smb_full_audit_ntimes(vfs_handle_struct *handle,
160 const char *path, const struct timespec ts[2]);
161 static int smb_full_audit_ftruncate(vfs_handle_struct *handle, files_struct *fsp,
163 static bool smb_full_audit_lock(vfs_handle_struct *handle, files_struct *fsp,
164 int op, SMB_OFF_T offset, SMB_OFF_T count, int type);
165 static int smb_full_audit_kernel_flock(struct vfs_handle_struct *handle,
166 struct files_struct *fsp,
168 static int smb_full_audit_linux_setlease(vfs_handle_struct *handle, files_struct *fsp,
170 static bool smb_full_audit_getlock(vfs_handle_struct *handle, files_struct *fsp,
171 SMB_OFF_T *poffset, SMB_OFF_T *pcount, int *ptype, pid_t *ppid);
172 static int smb_full_audit_symlink(vfs_handle_struct *handle,
173 const char *oldpath, const char *newpath);
174 static int smb_full_audit_readlink(vfs_handle_struct *handle,
175 const char *path, char *buf, size_t bufsiz);
176 static int smb_full_audit_link(vfs_handle_struct *handle,
177 const char *oldpath, const char *newpath);
178 static int smb_full_audit_mknod(vfs_handle_struct *handle,
179 const char *pathname, mode_t mode, SMB_DEV_T dev);
180 static char *smb_full_audit_realpath(vfs_handle_struct *handle,
181 const char *path, char *resolved_path);
182 static NTSTATUS smb_full_audit_notify_watch(struct vfs_handle_struct *handle,
183 struct sys_notify_context *ctx,
184 struct notify_entry *e,
185 void (*callback)(struct sys_notify_context *ctx,
187 struct notify_event *ev),
188 void *private_data, void *handle_p);
189 static int smb_full_audit_chflags(vfs_handle_struct *handle,
190 const char *path, unsigned int flags);
191 static struct file_id smb_full_audit_file_id_create(struct vfs_handle_struct *handle,
192 SMB_DEV_T dev, SMB_INO_T inode);
193 static NTSTATUS smb_full_audit_fget_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
194 uint32 security_info,
196 static NTSTATUS smb_full_audit_get_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
197 const char *name, uint32 security_info,
199 static NTSTATUS smb_full_audit_fset_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
200 uint32 security_info_sent,
202 static int smb_full_audit_chmod_acl(vfs_handle_struct *handle,
203 const char *path, mode_t mode);
204 static int smb_full_audit_fchmod_acl(vfs_handle_struct *handle, files_struct *fsp,
206 static int smb_full_audit_sys_acl_get_entry(vfs_handle_struct *handle,
207 SMB_ACL_T theacl, int entry_id,
208 SMB_ACL_ENTRY_T *entry_p);
209 static int smb_full_audit_sys_acl_get_tag_type(vfs_handle_struct *handle,
210 SMB_ACL_ENTRY_T entry_d,
211 SMB_ACL_TAG_T *tag_type_p);
212 static int smb_full_audit_sys_acl_get_permset(vfs_handle_struct *handle,
213 SMB_ACL_ENTRY_T entry_d,
214 SMB_ACL_PERMSET_T *permset_p);
215 static void * smb_full_audit_sys_acl_get_qualifier(vfs_handle_struct *handle,
216 SMB_ACL_ENTRY_T entry_d);
217 static SMB_ACL_T smb_full_audit_sys_acl_get_file(vfs_handle_struct *handle,
219 SMB_ACL_TYPE_T type);
220 static SMB_ACL_T smb_full_audit_sys_acl_get_fd(vfs_handle_struct *handle,
222 static int smb_full_audit_sys_acl_clear_perms(vfs_handle_struct *handle,
223 SMB_ACL_PERMSET_T permset);
224 static int smb_full_audit_sys_acl_add_perm(vfs_handle_struct *handle,
225 SMB_ACL_PERMSET_T permset,
226 SMB_ACL_PERM_T perm);
227 static char * smb_full_audit_sys_acl_to_text(vfs_handle_struct *handle,
230 static SMB_ACL_T smb_full_audit_sys_acl_init(vfs_handle_struct *handle,
232 static int smb_full_audit_sys_acl_create_entry(vfs_handle_struct *handle,
234 SMB_ACL_ENTRY_T *pentry);
235 static int smb_full_audit_sys_acl_set_tag_type(vfs_handle_struct *handle,
236 SMB_ACL_ENTRY_T entry,
237 SMB_ACL_TAG_T tagtype);
238 static int smb_full_audit_sys_acl_set_qualifier(vfs_handle_struct *handle,
239 SMB_ACL_ENTRY_T entry,
241 static int smb_full_audit_sys_acl_set_permset(vfs_handle_struct *handle,
242 SMB_ACL_ENTRY_T entry,
243 SMB_ACL_PERMSET_T permset);
244 static int smb_full_audit_sys_acl_valid(vfs_handle_struct *handle,
246 static int smb_full_audit_sys_acl_set_file(vfs_handle_struct *handle,
247 const char *name, SMB_ACL_TYPE_T acltype,
249 static int smb_full_audit_sys_acl_set_fd(vfs_handle_struct *handle, files_struct *fsp,
251 static int smb_full_audit_sys_acl_delete_def_file(vfs_handle_struct *handle,
253 static int smb_full_audit_sys_acl_get_perm(vfs_handle_struct *handle,
254 SMB_ACL_PERMSET_T permset,
255 SMB_ACL_PERM_T perm);
256 static int smb_full_audit_sys_acl_free_text(vfs_handle_struct *handle,
258 static int smb_full_audit_sys_acl_free_acl(vfs_handle_struct *handle,
259 SMB_ACL_T posix_acl);
260 static int smb_full_audit_sys_acl_free_qualifier(vfs_handle_struct *handle,
262 SMB_ACL_TAG_T tagtype);
263 static ssize_t smb_full_audit_getxattr(struct vfs_handle_struct *handle,
265 const char *name, void *value, size_t size);
266 static ssize_t smb_full_audit_lgetxattr(struct vfs_handle_struct *handle,
267 const char *path, const char *name,
268 void *value, size_t size);
269 static ssize_t smb_full_audit_fgetxattr(struct vfs_handle_struct *handle,
270 struct files_struct *fsp,
271 const char *name, void *value, size_t size);
272 static ssize_t smb_full_audit_listxattr(struct vfs_handle_struct *handle,
273 const char *path, char *list, size_t size);
274 static ssize_t smb_full_audit_llistxattr(struct vfs_handle_struct *handle,
275 const char *path, char *list, size_t size);
276 static ssize_t smb_full_audit_flistxattr(struct vfs_handle_struct *handle,
277 struct files_struct *fsp, char *list,
279 static int smb_full_audit_removexattr(struct vfs_handle_struct *handle,
282 static int smb_full_audit_lremovexattr(struct vfs_handle_struct *handle,
285 static int smb_full_audit_fremovexattr(struct vfs_handle_struct *handle,
286 struct files_struct *fsp,
288 static int smb_full_audit_setxattr(struct vfs_handle_struct *handle,
290 const char *name, const void *value, size_t size,
292 static int smb_full_audit_lsetxattr(struct vfs_handle_struct *handle,
294 const char *name, const void *value, size_t size,
296 static int smb_full_audit_fsetxattr(struct vfs_handle_struct *handle,
297 struct files_struct *fsp, const char *name,
298 const void *value, size_t size, int flags);
300 static int smb_full_audit_aio_read(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb);
301 static int smb_full_audit_aio_write(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb);
302 static ssize_t smb_full_audit_aio_return(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb);
303 static int smb_full_audit_aio_cancel(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb);
304 static int smb_full_audit_aio_error(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb);
305 static int smb_full_audit_aio_fsync(struct vfs_handle_struct *handle, struct files_struct *fsp, int op, SMB_STRUCT_AIOCB *aiocb);
306 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);
310 static vfs_op_tuple audit_op_tuples[] = {
312 /* Disk operations */
314 {SMB_VFS_OP(smb_full_audit_connect), SMB_VFS_OP_CONNECT,
315 SMB_VFS_LAYER_LOGGER},
316 {SMB_VFS_OP(smb_full_audit_disconnect), SMB_VFS_OP_DISCONNECT,
317 SMB_VFS_LAYER_LOGGER},
318 {SMB_VFS_OP(smb_full_audit_disk_free), SMB_VFS_OP_DISK_FREE,
319 SMB_VFS_LAYER_LOGGER},
320 {SMB_VFS_OP(smb_full_audit_get_quota), SMB_VFS_OP_GET_QUOTA,
321 SMB_VFS_LAYER_LOGGER},
322 {SMB_VFS_OP(smb_full_audit_set_quota), SMB_VFS_OP_SET_QUOTA,
323 SMB_VFS_LAYER_LOGGER},
324 {SMB_VFS_OP(smb_full_audit_get_shadow_copy_data), SMB_VFS_OP_GET_SHADOW_COPY_DATA,
325 SMB_VFS_LAYER_LOGGER},
326 {SMB_VFS_OP(smb_full_audit_statvfs), SMB_VFS_OP_STATVFS,
327 SMB_VFS_LAYER_LOGGER},
329 /* Directory operations */
331 {SMB_VFS_OP(smb_full_audit_opendir), SMB_VFS_OP_OPENDIR,
332 SMB_VFS_LAYER_LOGGER},
333 {SMB_VFS_OP(smb_full_audit_readdir), SMB_VFS_OP_READDIR,
334 SMB_VFS_LAYER_LOGGER},
335 {SMB_VFS_OP(smb_full_audit_seekdir), SMB_VFS_OP_SEEKDIR,
336 SMB_VFS_LAYER_LOGGER},
337 {SMB_VFS_OP(smb_full_audit_telldir), SMB_VFS_OP_TELLDIR,
338 SMB_VFS_LAYER_LOGGER},
339 {SMB_VFS_OP(smb_full_audit_rewinddir), SMB_VFS_OP_REWINDDIR,
340 SMB_VFS_LAYER_LOGGER},
341 {SMB_VFS_OP(smb_full_audit_mkdir), SMB_VFS_OP_MKDIR,
342 SMB_VFS_LAYER_LOGGER},
343 {SMB_VFS_OP(smb_full_audit_rmdir), SMB_VFS_OP_RMDIR,
344 SMB_VFS_LAYER_LOGGER},
345 {SMB_VFS_OP(smb_full_audit_closedir), SMB_VFS_OP_CLOSEDIR,
346 SMB_VFS_LAYER_LOGGER},
348 /* File operations */
350 {SMB_VFS_OP(smb_full_audit_open), SMB_VFS_OP_OPEN,
351 SMB_VFS_LAYER_LOGGER},
352 {SMB_VFS_OP(smb_full_audit_close), SMB_VFS_OP_CLOSE,
353 SMB_VFS_LAYER_LOGGER},
354 {SMB_VFS_OP(smb_full_audit_read), SMB_VFS_OP_READ,
355 SMB_VFS_LAYER_LOGGER},
356 {SMB_VFS_OP(smb_full_audit_pread), SMB_VFS_OP_PREAD,
357 SMB_VFS_LAYER_LOGGER},
358 {SMB_VFS_OP(smb_full_audit_write), SMB_VFS_OP_WRITE,
359 SMB_VFS_LAYER_LOGGER},
360 {SMB_VFS_OP(smb_full_audit_pwrite), SMB_VFS_OP_PWRITE,
361 SMB_VFS_LAYER_LOGGER},
362 {SMB_VFS_OP(smb_full_audit_lseek), SMB_VFS_OP_LSEEK,
363 SMB_VFS_LAYER_LOGGER},
364 {SMB_VFS_OP(smb_full_audit_sendfile), SMB_VFS_OP_SENDFILE,
365 SMB_VFS_LAYER_LOGGER},
366 {SMB_VFS_OP(smb_full_audit_recvfile), SMB_VFS_OP_RECVFILE,
367 SMB_VFS_LAYER_LOGGER},
368 {SMB_VFS_OP(smb_full_audit_rename), SMB_VFS_OP_RENAME,
369 SMB_VFS_LAYER_LOGGER},
370 {SMB_VFS_OP(smb_full_audit_fsync), SMB_VFS_OP_FSYNC,
371 SMB_VFS_LAYER_LOGGER},
372 {SMB_VFS_OP(smb_full_audit_stat), SMB_VFS_OP_STAT,
373 SMB_VFS_LAYER_LOGGER},
374 {SMB_VFS_OP(smb_full_audit_fstat), SMB_VFS_OP_FSTAT,
375 SMB_VFS_LAYER_LOGGER},
376 {SMB_VFS_OP(smb_full_audit_lstat), SMB_VFS_OP_LSTAT,
377 SMB_VFS_LAYER_LOGGER},
378 {SMB_VFS_OP(smb_full_audit_unlink), SMB_VFS_OP_UNLINK,
379 SMB_VFS_LAYER_LOGGER},
380 {SMB_VFS_OP(smb_full_audit_chmod), SMB_VFS_OP_CHMOD,
381 SMB_VFS_LAYER_LOGGER},
382 {SMB_VFS_OP(smb_full_audit_fchmod), SMB_VFS_OP_FCHMOD,
383 SMB_VFS_LAYER_LOGGER},
384 {SMB_VFS_OP(smb_full_audit_chown), SMB_VFS_OP_CHOWN,
385 SMB_VFS_LAYER_LOGGER},
386 {SMB_VFS_OP(smb_full_audit_fchown), SMB_VFS_OP_FCHOWN,
387 SMB_VFS_LAYER_LOGGER},
388 {SMB_VFS_OP(smb_full_audit_lchown), SMB_VFS_OP_LCHOWN,
389 SMB_VFS_LAYER_LOGGER},
390 {SMB_VFS_OP(smb_full_audit_chdir), SMB_VFS_OP_CHDIR,
391 SMB_VFS_LAYER_LOGGER},
392 {SMB_VFS_OP(smb_full_audit_getwd), SMB_VFS_OP_GETWD,
393 SMB_VFS_LAYER_LOGGER},
394 {SMB_VFS_OP(smb_full_audit_ntimes), SMB_VFS_OP_NTIMES,
395 SMB_VFS_LAYER_LOGGER},
396 {SMB_VFS_OP(smb_full_audit_ftruncate), SMB_VFS_OP_FTRUNCATE,
397 SMB_VFS_LAYER_LOGGER},
398 {SMB_VFS_OP(smb_full_audit_lock), SMB_VFS_OP_LOCK,
399 SMB_VFS_LAYER_LOGGER},
400 {SMB_VFS_OP(smb_full_audit_kernel_flock), SMB_VFS_OP_KERNEL_FLOCK,
401 SMB_VFS_LAYER_LOGGER},
402 {SMB_VFS_OP(smb_full_audit_linux_setlease), SMB_VFS_OP_LINUX_SETLEASE,
403 SMB_VFS_LAYER_LOGGER},
404 {SMB_VFS_OP(smb_full_audit_getlock), SMB_VFS_OP_GETLOCK,
405 SMB_VFS_LAYER_LOGGER},
406 {SMB_VFS_OP(smb_full_audit_symlink), SMB_VFS_OP_SYMLINK,
407 SMB_VFS_LAYER_LOGGER},
408 {SMB_VFS_OP(smb_full_audit_readlink), SMB_VFS_OP_READLINK,
409 SMB_VFS_LAYER_LOGGER},
410 {SMB_VFS_OP(smb_full_audit_link), SMB_VFS_OP_LINK,
411 SMB_VFS_LAYER_LOGGER},
412 {SMB_VFS_OP(smb_full_audit_mknod), SMB_VFS_OP_MKNOD,
413 SMB_VFS_LAYER_LOGGER},
414 {SMB_VFS_OP(smb_full_audit_realpath), SMB_VFS_OP_REALPATH,
415 SMB_VFS_LAYER_LOGGER},
416 {SMB_VFS_OP(smb_full_audit_notify_watch),SMB_VFS_OP_NOTIFY_WATCH,
417 SMB_VFS_LAYER_LOGGER},
418 {SMB_VFS_OP(smb_full_audit_chflags), SMB_VFS_OP_CHFLAGS,
419 SMB_VFS_LAYER_LOGGER},
420 {SMB_VFS_OP(smb_full_audit_file_id_create), SMB_VFS_OP_FILE_ID_CREATE,
421 SMB_VFS_LAYER_LOGGER},
423 /* NT ACL operations. */
425 {SMB_VFS_OP(smb_full_audit_fget_nt_acl), SMB_VFS_OP_FGET_NT_ACL,
426 SMB_VFS_LAYER_LOGGER},
427 {SMB_VFS_OP(smb_full_audit_get_nt_acl), SMB_VFS_OP_GET_NT_ACL,
428 SMB_VFS_LAYER_LOGGER},
429 {SMB_VFS_OP(smb_full_audit_fset_nt_acl), SMB_VFS_OP_FSET_NT_ACL,
430 SMB_VFS_LAYER_LOGGER},
432 /* POSIX ACL operations. */
434 {SMB_VFS_OP(smb_full_audit_chmod_acl), SMB_VFS_OP_CHMOD_ACL,
435 SMB_VFS_LAYER_LOGGER},
436 {SMB_VFS_OP(smb_full_audit_fchmod_acl), SMB_VFS_OP_FCHMOD_ACL,
437 SMB_VFS_LAYER_LOGGER},
438 {SMB_VFS_OP(smb_full_audit_sys_acl_get_entry), SMB_VFS_OP_SYS_ACL_GET_ENTRY,
439 SMB_VFS_LAYER_LOGGER},
440 {SMB_VFS_OP(smb_full_audit_sys_acl_get_tag_type), SMB_VFS_OP_SYS_ACL_GET_TAG_TYPE,
441 SMB_VFS_LAYER_LOGGER},
442 {SMB_VFS_OP(smb_full_audit_sys_acl_get_permset), SMB_VFS_OP_SYS_ACL_GET_PERMSET,
443 SMB_VFS_LAYER_LOGGER},
444 {SMB_VFS_OP(smb_full_audit_sys_acl_get_qualifier), SMB_VFS_OP_SYS_ACL_GET_QUALIFIER,
445 SMB_VFS_LAYER_LOGGER},
446 {SMB_VFS_OP(smb_full_audit_sys_acl_get_file), SMB_VFS_OP_SYS_ACL_GET_FILE,
447 SMB_VFS_LAYER_LOGGER},
448 {SMB_VFS_OP(smb_full_audit_sys_acl_get_fd), SMB_VFS_OP_SYS_ACL_GET_FD,
449 SMB_VFS_LAYER_LOGGER},
450 {SMB_VFS_OP(smb_full_audit_sys_acl_clear_perms), SMB_VFS_OP_SYS_ACL_CLEAR_PERMS,
451 SMB_VFS_LAYER_LOGGER},
452 {SMB_VFS_OP(smb_full_audit_sys_acl_add_perm), SMB_VFS_OP_SYS_ACL_ADD_PERM,
453 SMB_VFS_LAYER_LOGGER},
454 {SMB_VFS_OP(smb_full_audit_sys_acl_to_text), SMB_VFS_OP_SYS_ACL_TO_TEXT,
455 SMB_VFS_LAYER_LOGGER},
456 {SMB_VFS_OP(smb_full_audit_sys_acl_init), SMB_VFS_OP_SYS_ACL_INIT,
457 SMB_VFS_LAYER_LOGGER},
458 {SMB_VFS_OP(smb_full_audit_sys_acl_create_entry), SMB_VFS_OP_SYS_ACL_CREATE_ENTRY,
459 SMB_VFS_LAYER_LOGGER},
460 {SMB_VFS_OP(smb_full_audit_sys_acl_set_tag_type), SMB_VFS_OP_SYS_ACL_SET_TAG_TYPE,
461 SMB_VFS_LAYER_LOGGER},
462 {SMB_VFS_OP(smb_full_audit_sys_acl_set_qualifier), SMB_VFS_OP_SYS_ACL_SET_QUALIFIER,
463 SMB_VFS_LAYER_LOGGER},
464 {SMB_VFS_OP(smb_full_audit_sys_acl_set_permset), SMB_VFS_OP_SYS_ACL_SET_PERMSET,
465 SMB_VFS_LAYER_LOGGER},
466 {SMB_VFS_OP(smb_full_audit_sys_acl_valid), SMB_VFS_OP_SYS_ACL_VALID,
467 SMB_VFS_LAYER_LOGGER},
468 {SMB_VFS_OP(smb_full_audit_sys_acl_set_file), SMB_VFS_OP_SYS_ACL_SET_FILE,
469 SMB_VFS_LAYER_LOGGER},
470 {SMB_VFS_OP(smb_full_audit_sys_acl_set_fd), SMB_VFS_OP_SYS_ACL_SET_FD,
471 SMB_VFS_LAYER_LOGGER},
472 {SMB_VFS_OP(smb_full_audit_sys_acl_delete_def_file), SMB_VFS_OP_SYS_ACL_DELETE_DEF_FILE,
473 SMB_VFS_LAYER_LOGGER},
474 {SMB_VFS_OP(smb_full_audit_sys_acl_get_perm), SMB_VFS_OP_SYS_ACL_GET_PERM,
475 SMB_VFS_LAYER_LOGGER},
476 {SMB_VFS_OP(smb_full_audit_sys_acl_free_text), SMB_VFS_OP_SYS_ACL_FREE_TEXT,
477 SMB_VFS_LAYER_LOGGER},
478 {SMB_VFS_OP(smb_full_audit_sys_acl_free_acl), SMB_VFS_OP_SYS_ACL_FREE_ACL,
479 SMB_VFS_LAYER_LOGGER},
480 {SMB_VFS_OP(smb_full_audit_sys_acl_free_qualifier), SMB_VFS_OP_SYS_ACL_FREE_QUALIFIER,
481 SMB_VFS_LAYER_LOGGER},
485 {SMB_VFS_OP(smb_full_audit_getxattr), SMB_VFS_OP_GETXATTR,
486 SMB_VFS_LAYER_LOGGER},
487 {SMB_VFS_OP(smb_full_audit_lgetxattr), SMB_VFS_OP_LGETXATTR,
488 SMB_VFS_LAYER_LOGGER},
489 {SMB_VFS_OP(smb_full_audit_fgetxattr), SMB_VFS_OP_FGETXATTR,
490 SMB_VFS_LAYER_LOGGER},
491 {SMB_VFS_OP(smb_full_audit_listxattr), SMB_VFS_OP_LISTXATTR,
492 SMB_VFS_LAYER_LOGGER},
493 {SMB_VFS_OP(smb_full_audit_llistxattr), SMB_VFS_OP_LLISTXATTR,
494 SMB_VFS_LAYER_LOGGER},
495 {SMB_VFS_OP(smb_full_audit_flistxattr), SMB_VFS_OP_FLISTXATTR,
496 SMB_VFS_LAYER_LOGGER},
497 {SMB_VFS_OP(smb_full_audit_removexattr), SMB_VFS_OP_REMOVEXATTR,
498 SMB_VFS_LAYER_LOGGER},
499 {SMB_VFS_OP(smb_full_audit_lremovexattr), SMB_VFS_OP_LREMOVEXATTR,
500 SMB_VFS_LAYER_LOGGER},
501 {SMB_VFS_OP(smb_full_audit_fremovexattr), SMB_VFS_OP_FREMOVEXATTR,
502 SMB_VFS_LAYER_LOGGER},
503 {SMB_VFS_OP(smb_full_audit_setxattr), SMB_VFS_OP_SETXATTR,
504 SMB_VFS_LAYER_LOGGER},
505 {SMB_VFS_OP(smb_full_audit_lsetxattr), SMB_VFS_OP_LSETXATTR,
506 SMB_VFS_LAYER_LOGGER},
507 {SMB_VFS_OP(smb_full_audit_fsetxattr), SMB_VFS_OP_FSETXATTR,
508 SMB_VFS_LAYER_LOGGER},
510 {SMB_VFS_OP(smb_full_audit_aio_read), SMB_VFS_OP_AIO_READ,
511 SMB_VFS_LAYER_LOGGER},
512 {SMB_VFS_OP(smb_full_audit_aio_write), SMB_VFS_OP_AIO_WRITE,
513 SMB_VFS_LAYER_LOGGER},
514 {SMB_VFS_OP(smb_full_audit_aio_return), SMB_VFS_OP_AIO_RETURN,
515 SMB_VFS_LAYER_LOGGER},
516 {SMB_VFS_OP(smb_full_audit_aio_cancel), SMB_VFS_OP_AIO_CANCEL,
517 SMB_VFS_LAYER_LOGGER},
518 {SMB_VFS_OP(smb_full_audit_aio_error), SMB_VFS_OP_AIO_ERROR,
519 SMB_VFS_LAYER_LOGGER},
520 {SMB_VFS_OP(smb_full_audit_aio_fsync), SMB_VFS_OP_AIO_FSYNC,
521 SMB_VFS_LAYER_LOGGER},
522 {SMB_VFS_OP(smb_full_audit_aio_suspend),SMB_VFS_OP_AIO_SUSPEND,
523 SMB_VFS_LAYER_LOGGER},
525 /* Finish VFS operations definition */
527 {SMB_VFS_OP(NULL), SMB_VFS_OP_NOOP,
531 /* The following array *must* be in the same order as defined in vfs.h */
537 { SMB_VFS_OP_CONNECT, "connect" },
538 { SMB_VFS_OP_DISCONNECT, "disconnect" },
539 { SMB_VFS_OP_DISK_FREE, "disk_free" },
540 { SMB_VFS_OP_GET_QUOTA, "get_quota" },
541 { SMB_VFS_OP_SET_QUOTA, "set_quota" },
542 { SMB_VFS_OP_GET_SHADOW_COPY_DATA, "get_shadow_copy_data" },
543 { SMB_VFS_OP_STATVFS, "statvfs" },
544 { SMB_VFS_OP_FS_CAPABILITIES, "fs_capabilities" },
545 { SMB_VFS_OP_OPENDIR, "opendir" },
546 { SMB_VFS_OP_READDIR, "readdir" },
547 { SMB_VFS_OP_SEEKDIR, "seekdir" },
548 { SMB_VFS_OP_TELLDIR, "telldir" },
549 { SMB_VFS_OP_REWINDDIR, "rewinddir" },
550 { SMB_VFS_OP_MKDIR, "mkdir" },
551 { SMB_VFS_OP_RMDIR, "rmdir" },
552 { SMB_VFS_OP_CLOSEDIR, "closedir" },
553 { SMB_VFS_OP_OPEN, "open" },
554 { SMB_VFS_OP_CLOSE, "close" },
555 { SMB_VFS_OP_READ, "read" },
556 { SMB_VFS_OP_PREAD, "pread" },
557 { SMB_VFS_OP_WRITE, "write" },
558 { SMB_VFS_OP_PWRITE, "pwrite" },
559 { SMB_VFS_OP_LSEEK, "lseek" },
560 { SMB_VFS_OP_SENDFILE, "sendfile" },
561 { SMB_VFS_OP_RENAME, "rename" },
562 { SMB_VFS_OP_FSYNC, "fsync" },
563 { SMB_VFS_OP_STAT, "stat" },
564 { SMB_VFS_OP_FSTAT, "fstat" },
565 { SMB_VFS_OP_LSTAT, "lstat" },
566 { SMB_VFS_OP_UNLINK, "unlink" },
567 { SMB_VFS_OP_CHMOD, "chmod" },
568 { SMB_VFS_OP_FCHMOD, "fchmod" },
569 { SMB_VFS_OP_CHOWN, "chown" },
570 { SMB_VFS_OP_FCHOWN, "fchown" },
571 { SMB_VFS_OP_LCHOWN, "lchown" },
572 { SMB_VFS_OP_CHDIR, "chdir" },
573 { SMB_VFS_OP_GETWD, "getwd" },
574 { SMB_VFS_OP_NTIMES, "ntimes" },
575 { SMB_VFS_OP_FTRUNCATE, "ftruncate" },
576 { SMB_VFS_OP_LOCK, "lock" },
577 { SMB_VFS_OP_KERNEL_FLOCK, "kernel_flock" },
578 { SMB_VFS_OP_LINUX_SETLEASE, "linux_setlease" },
579 { SMB_VFS_OP_GETLOCK, "getlock" },
580 { SMB_VFS_OP_SYMLINK, "symlink" },
581 { SMB_VFS_OP_READLINK, "readlink" },
582 { SMB_VFS_OP_LINK, "link" },
583 { SMB_VFS_OP_MKNOD, "mknod" },
584 { SMB_VFS_OP_REALPATH, "realpath" },
585 { SMB_VFS_OP_NOTIFY_WATCH, "notify_watch" },
586 { SMB_VFS_OP_CHFLAGS, "chflags" },
587 { SMB_VFS_OP_FILE_ID_CREATE, "file_id_create" },
588 { SMB_VFS_OP_FGET_NT_ACL, "fget_nt_acl" },
589 { SMB_VFS_OP_GET_NT_ACL, "get_nt_acl" },
590 { SMB_VFS_OP_FSET_NT_ACL, "fset_nt_acl" },
591 { SMB_VFS_OP_CHMOD_ACL, "chmod_acl" },
592 { SMB_VFS_OP_FCHMOD_ACL, "fchmod_acl" },
593 { SMB_VFS_OP_SYS_ACL_GET_ENTRY, "sys_acl_get_entry" },
594 { SMB_VFS_OP_SYS_ACL_GET_TAG_TYPE, "sys_acl_get_tag_type" },
595 { SMB_VFS_OP_SYS_ACL_GET_PERMSET, "sys_acl_get_permset" },
596 { SMB_VFS_OP_SYS_ACL_GET_QUALIFIER, "sys_acl_get_qualifier" },
597 { SMB_VFS_OP_SYS_ACL_GET_FILE, "sys_acl_get_file" },
598 { SMB_VFS_OP_SYS_ACL_GET_FD, "sys_acl_get_fd" },
599 { SMB_VFS_OP_SYS_ACL_CLEAR_PERMS, "sys_acl_clear_perms" },
600 { SMB_VFS_OP_SYS_ACL_ADD_PERM, "sys_acl_add_perm" },
601 { SMB_VFS_OP_SYS_ACL_TO_TEXT, "sys_acl_to_text" },
602 { SMB_VFS_OP_SYS_ACL_INIT, "sys_acl_init" },
603 { SMB_VFS_OP_SYS_ACL_CREATE_ENTRY, "sys_acl_create_entry" },
604 { SMB_VFS_OP_SYS_ACL_SET_TAG_TYPE, "sys_acl_set_tag_type" },
605 { SMB_VFS_OP_SYS_ACL_SET_QUALIFIER, "sys_acl_set_qualifier" },
606 { SMB_VFS_OP_SYS_ACL_SET_PERMSET, "sys_acl_set_permset" },
607 { SMB_VFS_OP_SYS_ACL_VALID, "sys_acl_valid" },
608 { SMB_VFS_OP_SYS_ACL_SET_FILE, "sys_acl_set_file" },
609 { SMB_VFS_OP_SYS_ACL_SET_FD, "sys_acl_set_fd" },
610 { SMB_VFS_OP_SYS_ACL_DELETE_DEF_FILE, "sys_acl_delete_def_file" },
611 { SMB_VFS_OP_SYS_ACL_GET_PERM, "sys_acl_get_perm" },
612 { SMB_VFS_OP_SYS_ACL_FREE_TEXT, "sys_acl_free_text" },
613 { SMB_VFS_OP_SYS_ACL_FREE_ACL, "sys_acl_free_acl" },
614 { SMB_VFS_OP_SYS_ACL_FREE_QUALIFIER, "sys_acl_free_qualifier" },
615 { SMB_VFS_OP_GETXATTR, "getxattr" },
616 { SMB_VFS_OP_LGETXATTR, "lgetxattr" },
617 { SMB_VFS_OP_FGETXATTR, "fgetxattr" },
618 { SMB_VFS_OP_LISTXATTR, "listxattr" },
619 { SMB_VFS_OP_LLISTXATTR, "llistxattr" },
620 { SMB_VFS_OP_FLISTXATTR, "flistxattr" },
621 { SMB_VFS_OP_REMOVEXATTR, "removexattr" },
622 { SMB_VFS_OP_LREMOVEXATTR, "lremovexattr" },
623 { SMB_VFS_OP_FREMOVEXATTR, "fremovexattr" },
624 { SMB_VFS_OP_SETXATTR, "setxattr" },
625 { SMB_VFS_OP_LSETXATTR, "lsetxattr" },
626 { SMB_VFS_OP_FSETXATTR, "fsetxattr" },
627 { SMB_VFS_OP_AIO_READ, "aio_read" },
628 { SMB_VFS_OP_AIO_WRITE, "aio_write" },
629 { SMB_VFS_OP_AIO_RETURN,"aio_return" },
630 { SMB_VFS_OP_AIO_CANCEL,"aio_cancel" },
631 { SMB_VFS_OP_AIO_ERROR, "aio_error" },
632 { SMB_VFS_OP_AIO_FSYNC, "aio_fsync" },
633 { SMB_VFS_OP_AIO_SUSPEND,"aio_suspend" },
634 { SMB_VFS_OP_AIO_FORCE, "aio_force" },
635 { SMB_VFS_OP_IS_OFFLINE, "aio_is_offline" },
636 { SMB_VFS_OP_SET_OFFLINE, "aio_set_offline" },
637 { SMB_VFS_OP_LAST, NULL }
640 static int audit_syslog_facility(vfs_handle_struct *handle)
642 static const struct enum_list enum_log_facilities[] = {
643 { LOG_USER, "USER" },
644 { LOG_LOCAL0, "LOCAL0" },
645 { LOG_LOCAL1, "LOCAL1" },
646 { LOG_LOCAL2, "LOCAL2" },
647 { LOG_LOCAL3, "LOCAL3" },
648 { LOG_LOCAL4, "LOCAL4" },
649 { LOG_LOCAL5, "LOCAL5" },
650 { LOG_LOCAL6, "LOCAL6" },
651 { LOG_LOCAL7, "LOCAL7" }
656 facility = lp_parm_enum(SNUM(handle->conn), "full_audit", "facility", enum_log_facilities, LOG_USER);
661 static int audit_syslog_priority(vfs_handle_struct *handle)
663 static const struct enum_list enum_log_priorities[] = {
664 { LOG_EMERG, "EMERG" },
665 { LOG_ALERT, "ALERT" },
666 { LOG_CRIT, "CRIT" },
668 { LOG_WARNING, "WARNING" },
669 { LOG_NOTICE, "NOTICE" },
670 { LOG_INFO, "INFO" },
671 { LOG_DEBUG, "DEBUG" }
676 priority = lp_parm_enum(SNUM(handle->conn), "full_audit", "priority",
677 enum_log_priorities, LOG_NOTICE);
678 if (priority == -1) {
679 priority = LOG_WARNING;
685 static char *audit_prefix(TALLOC_CTX *ctx, connection_struct *conn)
689 prefix = talloc_strdup(ctx,
690 lp_parm_const_string(SNUM(conn), "full_audit",
695 return talloc_sub_advanced(ctx,
696 lp_servicename(SNUM(conn)),
697 conn->server_info->unix_name,
699 conn->server_info->gid,
700 get_current_username(),
701 current_user_info.domain,
705 static bool log_success(vfs_handle_struct *handle, vfs_op_type op)
707 struct vfs_full_audit_private_data *pd = NULL;
709 SMB_VFS_HANDLE_GET_DATA(handle, pd,
710 struct vfs_full_audit_private_data,
713 if (pd->success_ops == NULL) {
717 return bitmap_query(pd->success_ops, op);
720 static bool log_failure(vfs_handle_struct *handle, vfs_op_type op)
722 struct vfs_full_audit_private_data *pd = NULL;
724 SMB_VFS_HANDLE_GET_DATA(handle, pd,
725 struct vfs_full_audit_private_data,
728 if (pd->failure_ops == NULL)
731 return bitmap_query(pd->failure_ops, op);
734 static void init_bitmap(struct bitmap **bm, const char **ops)
736 bool log_all = False;
741 *bm = bitmap_allocate(SMB_VFS_OP_LAST);
744 DEBUG(0, ("Could not alloc bitmap -- "
745 "defaulting to logging everything\n"));
749 while (*ops != NULL) {
753 if (strequal(*ops, "all")) {
758 if (strequal(*ops, "none")) {
762 for (i=0; i<SMB_VFS_OP_LAST; i++) {
763 if (vfs_op_names[i].name == NULL) {
764 smb_panic("vfs_full_audit.c: name table not "
765 "in sync with vfs.h\n");
768 if (strequal(*ops, vfs_op_names[i].name)) {
774 DEBUG(0, ("Could not find opname %s, logging all\n",
783 /* The query functions default to True */
789 static const char *audit_opname(vfs_op_type op)
791 if (op >= SMB_VFS_OP_LAST)
792 return "INVALID VFS OP";
793 return vfs_op_names[op].name;
796 static void do_log(vfs_op_type op, bool success, vfs_handle_struct *handle,
797 const char *format, ...)
800 char *audit_pre = NULL;
804 if (success && (!log_success(handle, op)))
807 if (!success && (!log_failure(handle, op)))
811 fstrcpy(err_msg, "ok");
813 fstr_sprintf(err_msg, "fail (%s)", strerror(errno));
815 va_start(ap, format);
816 op_msg = talloc_vasprintf(NULL, format, ap);
823 audit_pre = audit_prefix(NULL, handle->conn);
824 syslog(audit_syslog_priority(handle), "%s|%s|%s|%s\n",
825 audit_pre ? audit_pre : "",
826 audit_opname(op), err_msg, op_msg);
828 TALLOC_FREE(audit_pre);
834 /* Free function for the private data. */
836 static void free_private_data(void **p_data)
838 struct vfs_full_audit_private_data *pd = *(struct vfs_full_audit_private_data **)p_data;
840 if (pd->success_ops) {
841 bitmap_free(pd->success_ops);
843 if (pd->failure_ops) {
844 bitmap_free(pd->failure_ops);
850 /* Implementation of vfs_ops. Pass everything on to the default
851 operation but log event first. */
853 static int smb_full_audit_connect(vfs_handle_struct *handle,
854 const char *svc, const char *user)
857 struct vfs_full_audit_private_data *pd = NULL;
858 const char *none[] = { NULL };
859 const char *all [] = { "all" };
865 pd = SMB_MALLOC_P(struct vfs_full_audit_private_data);
871 openlog("smbd_audit", 0, audit_syslog_facility(handle));
873 init_bitmap(&pd->success_ops,
874 lp_parm_string_list(SNUM(handle->conn), "full_audit", "success",
876 init_bitmap(&pd->failure_ops,
877 lp_parm_string_list(SNUM(handle->conn), "full_audit", "failure",
880 /* Store the private data. */
881 SMB_VFS_HANDLE_SET_DATA(handle, pd, free_private_data,
882 struct vfs_full_audit_private_data, return -1);
884 result = SMB_VFS_NEXT_CONNECT(handle, svc, user);
886 do_log(SMB_VFS_OP_CONNECT, True, handle,
892 static void smb_full_audit_disconnect(vfs_handle_struct *handle)
894 SMB_VFS_NEXT_DISCONNECT(handle);
896 do_log(SMB_VFS_OP_DISCONNECT, True, handle,
897 "%s", lp_servicename(SNUM(handle->conn)));
899 /* The bitmaps will be disconnected when the private
905 static SMB_BIG_UINT smb_full_audit_disk_free(vfs_handle_struct *handle,
907 bool small_query, SMB_BIG_UINT *bsize,
908 SMB_BIG_UINT *dfree, SMB_BIG_UINT *dsize)
912 result = SMB_VFS_NEXT_DISK_FREE(handle, path, small_query, bsize,
915 /* Don't have a reasonable notion of failure here */
917 do_log(SMB_VFS_OP_DISK_FREE, True, handle, "%s", path);
922 static int smb_full_audit_get_quota(struct vfs_handle_struct *handle,
923 enum SMB_QUOTA_TYPE qtype, unid_t id,
928 result = SMB_VFS_NEXT_GET_QUOTA(handle, qtype, id, qt);
930 do_log(SMB_VFS_OP_GET_QUOTA, (result >= 0), handle, "");
936 static int smb_full_audit_set_quota(struct vfs_handle_struct *handle,
937 enum SMB_QUOTA_TYPE qtype, unid_t id,
942 result = SMB_VFS_NEXT_SET_QUOTA(handle, qtype, id, qt);
944 do_log(SMB_VFS_OP_SET_QUOTA, (result >= 0), handle, "");
949 static int smb_full_audit_get_shadow_copy_data(struct vfs_handle_struct *handle,
950 struct files_struct *fsp,
951 SHADOW_COPY_DATA *shadow_copy_data, bool labels)
955 result = SMB_VFS_NEXT_GET_SHADOW_COPY_DATA(handle, fsp, shadow_copy_data, labels);
957 do_log(SMB_VFS_OP_GET_SHADOW_COPY_DATA, (result >= 0), handle, "");
962 static int smb_full_audit_statvfs(struct vfs_handle_struct *handle,
964 struct vfs_statvfs_struct *statbuf)
968 result = SMB_VFS_NEXT_STATVFS(handle, path, statbuf);
970 do_log(SMB_VFS_OP_STATVFS, (result >= 0), handle, "");
975 static SMB_STRUCT_DIR *smb_full_audit_opendir(vfs_handle_struct *handle,
976 const char *fname, const char *mask, uint32 attr)
978 SMB_STRUCT_DIR *result;
980 result = SMB_VFS_NEXT_OPENDIR(handle, fname, mask, attr);
982 do_log(SMB_VFS_OP_OPENDIR, (result != NULL), handle, "%s", fname);
987 static SMB_STRUCT_DIRENT *smb_full_audit_readdir(vfs_handle_struct *handle,
988 SMB_STRUCT_DIR *dirp)
990 SMB_STRUCT_DIRENT *result;
992 result = SMB_VFS_NEXT_READDIR(handle, dirp);
994 /* This operation has no reasonable error condition
995 * (End of dir is also failure), so always succeed.
997 do_log(SMB_VFS_OP_READDIR, True, handle, "");
1002 static void smb_full_audit_seekdir(vfs_handle_struct *handle,
1003 SMB_STRUCT_DIR *dirp, long offset)
1005 SMB_VFS_NEXT_SEEKDIR(handle, dirp, offset);
1007 do_log(SMB_VFS_OP_SEEKDIR, True, handle, "");
1011 static long smb_full_audit_telldir(vfs_handle_struct *handle,
1012 SMB_STRUCT_DIR *dirp)
1016 result = SMB_VFS_NEXT_TELLDIR(handle, dirp);
1018 do_log(SMB_VFS_OP_TELLDIR, True, handle, "");
1023 static void smb_full_audit_rewinddir(vfs_handle_struct *handle,
1024 SMB_STRUCT_DIR *dirp)
1026 SMB_VFS_NEXT_REWINDDIR(handle, dirp);
1028 do_log(SMB_VFS_OP_REWINDDIR, True, handle, "");
1032 static int smb_full_audit_mkdir(vfs_handle_struct *handle,
1033 const char *path, mode_t mode)
1037 result = SMB_VFS_NEXT_MKDIR(handle, path, mode);
1039 do_log(SMB_VFS_OP_MKDIR, (result >= 0), handle, "%s", path);
1044 static int smb_full_audit_rmdir(vfs_handle_struct *handle,
1049 result = SMB_VFS_NEXT_RMDIR(handle, path);
1051 do_log(SMB_VFS_OP_RMDIR, (result >= 0), handle, "%s", path);
1056 static int smb_full_audit_closedir(vfs_handle_struct *handle,
1057 SMB_STRUCT_DIR *dirp)
1061 result = SMB_VFS_NEXT_CLOSEDIR(handle, dirp);
1063 do_log(SMB_VFS_OP_CLOSEDIR, (result >= 0), handle, "");
1068 static int smb_full_audit_open(vfs_handle_struct *handle,
1069 const char *fname, files_struct *fsp, int flags, mode_t mode)
1073 result = SMB_VFS_NEXT_OPEN(handle, fname, fsp, flags, mode);
1075 do_log(SMB_VFS_OP_OPEN, (result >= 0), handle, "%s|%s",
1076 ((flags & O_WRONLY) || (flags & O_RDWR))?"w":"r",
1082 static int smb_full_audit_close(vfs_handle_struct *handle, files_struct *fsp)
1086 result = SMB_VFS_NEXT_CLOSE(handle, fsp);
1088 do_log(SMB_VFS_OP_CLOSE, (result >= 0), handle, "%s", fsp->fsp_name);
1093 static ssize_t smb_full_audit_read(vfs_handle_struct *handle, files_struct *fsp,
1094 void *data, size_t n)
1098 result = SMB_VFS_NEXT_READ(handle, fsp, data, n);
1100 do_log(SMB_VFS_OP_READ, (result >= 0), handle, "%s", fsp->fsp_name);
1105 static ssize_t smb_full_audit_pread(vfs_handle_struct *handle, files_struct *fsp,
1106 void *data, size_t n, SMB_OFF_T offset)
1110 result = SMB_VFS_NEXT_PREAD(handle, fsp, data, n, offset);
1112 do_log(SMB_VFS_OP_PREAD, (result >= 0), handle, "%s", fsp->fsp_name);
1117 static ssize_t smb_full_audit_write(vfs_handle_struct *handle, files_struct *fsp,
1118 const void *data, size_t n)
1122 result = SMB_VFS_NEXT_WRITE(handle, fsp, data, n);
1124 do_log(SMB_VFS_OP_WRITE, (result >= 0), handle, "%s", fsp->fsp_name);
1129 static ssize_t smb_full_audit_pwrite(vfs_handle_struct *handle, files_struct *fsp,
1130 const void *data, size_t n,
1135 result = SMB_VFS_NEXT_PWRITE(handle, fsp, data, n, offset);
1137 do_log(SMB_VFS_OP_PWRITE, (result >= 0), handle, "%s", fsp->fsp_name);
1142 static SMB_OFF_T smb_full_audit_lseek(vfs_handle_struct *handle, files_struct *fsp,
1143 SMB_OFF_T offset, int whence)
1147 result = SMB_VFS_NEXT_LSEEK(handle, fsp, offset, whence);
1149 do_log(SMB_VFS_OP_LSEEK, (result != (ssize_t)-1), handle,
1150 "%s", fsp->fsp_name);
1155 static ssize_t smb_full_audit_sendfile(vfs_handle_struct *handle, int tofd,
1156 files_struct *fromfsp,
1157 const DATA_BLOB *hdr, SMB_OFF_T offset,
1162 result = SMB_VFS_NEXT_SENDFILE(handle, tofd, fromfsp, hdr, offset, n);
1164 do_log(SMB_VFS_OP_SENDFILE, (result >= 0), handle,
1165 "%s", fromfsp->fsp_name);
1170 static ssize_t smb_full_audit_recvfile(vfs_handle_struct *handle, int fromfd,
1171 files_struct *tofsp,
1177 result = SMB_VFS_NEXT_RECVFILE(handle, fromfd, tofsp, offset, n);
1179 do_log(SMB_VFS_OP_RECVFILE, (result >= 0), handle,
1180 "%s", tofsp->fsp_name);
1185 static int smb_full_audit_rename(vfs_handle_struct *handle,
1186 const char *oldname, const char *newname)
1190 result = SMB_VFS_NEXT_RENAME(handle, oldname, newname);
1192 do_log(SMB_VFS_OP_RENAME, (result >= 0), handle, "%s|%s", oldname, newname);
1197 static int smb_full_audit_fsync(vfs_handle_struct *handle, files_struct *fsp)
1201 result = SMB_VFS_NEXT_FSYNC(handle, fsp);
1203 do_log(SMB_VFS_OP_FSYNC, (result >= 0), handle, "%s", fsp->fsp_name);
1208 static int smb_full_audit_stat(vfs_handle_struct *handle,
1209 const char *fname, SMB_STRUCT_STAT *sbuf)
1213 result = SMB_VFS_NEXT_STAT(handle, fname, sbuf);
1215 do_log(SMB_VFS_OP_STAT, (result >= 0), handle, "%s", fname);
1220 static int smb_full_audit_fstat(vfs_handle_struct *handle, files_struct *fsp,
1221 SMB_STRUCT_STAT *sbuf)
1225 result = SMB_VFS_NEXT_FSTAT(handle, fsp, sbuf);
1227 do_log(SMB_VFS_OP_FSTAT, (result >= 0), handle, "%s", fsp->fsp_name);
1232 static int smb_full_audit_lstat(vfs_handle_struct *handle,
1233 const char *path, SMB_STRUCT_STAT *sbuf)
1237 result = SMB_VFS_NEXT_LSTAT(handle, path, sbuf);
1239 do_log(SMB_VFS_OP_LSTAT, (result >= 0), handle, "%s", path);
1244 static int smb_full_audit_unlink(vfs_handle_struct *handle,
1249 result = SMB_VFS_NEXT_UNLINK(handle, path);
1251 do_log(SMB_VFS_OP_UNLINK, (result >= 0), handle, "%s", path);
1256 static int smb_full_audit_chmod(vfs_handle_struct *handle,
1257 const char *path, mode_t mode)
1261 result = SMB_VFS_NEXT_CHMOD(handle, path, mode);
1263 do_log(SMB_VFS_OP_CHMOD, (result >= 0), handle, "%s|%o", path, mode);
1268 static int smb_full_audit_fchmod(vfs_handle_struct *handle, files_struct *fsp,
1273 result = SMB_VFS_NEXT_FCHMOD(handle, fsp, mode);
1275 do_log(SMB_VFS_OP_FCHMOD, (result >= 0), handle,
1276 "%s|%o", fsp->fsp_name, mode);
1281 static int smb_full_audit_chown(vfs_handle_struct *handle,
1282 const char *path, uid_t uid, gid_t gid)
1286 result = SMB_VFS_NEXT_CHOWN(handle, path, uid, gid);
1288 do_log(SMB_VFS_OP_CHOWN, (result >= 0), handle, "%s|%ld|%ld",
1289 path, (long int)uid, (long int)gid);
1294 static int smb_full_audit_fchown(vfs_handle_struct *handle, files_struct *fsp,
1295 uid_t uid, gid_t gid)
1299 result = SMB_VFS_NEXT_FCHOWN(handle, fsp, uid, gid);
1301 do_log(SMB_VFS_OP_FCHOWN, (result >= 0), handle, "%s|%ld|%ld",
1302 fsp->fsp_name, (long int)uid, (long int)gid);
1307 static int smb_full_audit_lchown(vfs_handle_struct *handle,
1308 const char *path, uid_t uid, gid_t gid)
1312 result = SMB_VFS_NEXT_LCHOWN(handle, path, uid, gid);
1314 do_log(SMB_VFS_OP_LCHOWN, (result >= 0), handle, "%s|%ld|%ld",
1315 path, (long int)uid, (long int)gid);
1320 static int smb_full_audit_chdir(vfs_handle_struct *handle,
1325 result = SMB_VFS_NEXT_CHDIR(handle, path);
1327 do_log(SMB_VFS_OP_CHDIR, (result >= 0), handle, "chdir|%s", path);
1332 static char *smb_full_audit_getwd(vfs_handle_struct *handle,
1337 result = SMB_VFS_NEXT_GETWD(handle, path);
1339 do_log(SMB_VFS_OP_GETWD, (result != NULL), handle, "%s", path);
1344 static int smb_full_audit_ntimes(vfs_handle_struct *handle,
1345 const char *path, const struct timespec ts[2])
1349 result = SMB_VFS_NEXT_NTIMES(handle, path, ts);
1351 do_log(SMB_VFS_OP_NTIMES, (result >= 0), handle, "%s", path);
1356 static int smb_full_audit_ftruncate(vfs_handle_struct *handle, files_struct *fsp,
1361 result = SMB_VFS_NEXT_FTRUNCATE(handle, fsp, len);
1363 do_log(SMB_VFS_OP_FTRUNCATE, (result >= 0), handle,
1364 "%s", fsp->fsp_name);
1369 static bool smb_full_audit_lock(vfs_handle_struct *handle, files_struct *fsp,
1370 int op, SMB_OFF_T offset, SMB_OFF_T count, int type)
1374 result = SMB_VFS_NEXT_LOCK(handle, fsp, op, offset, count, type);
1376 do_log(SMB_VFS_OP_LOCK, result, handle, "%s", fsp->fsp_name);
1381 static int smb_full_audit_kernel_flock(struct vfs_handle_struct *handle,
1382 struct files_struct *fsp,
1387 result = SMB_VFS_NEXT_KERNEL_FLOCK(handle, fsp, share_mode);
1389 do_log(SMB_VFS_OP_KERNEL_FLOCK, (result >= 0), handle, "%s",
1395 static int smb_full_audit_linux_setlease(vfs_handle_struct *handle, files_struct *fsp,
1400 result = SMB_VFS_NEXT_LINUX_SETLEASE(handle, fsp, leasetype);
1402 do_log(SMB_VFS_OP_LINUX_SETLEASE, (result >= 0), handle, "%s",
1408 static bool smb_full_audit_getlock(vfs_handle_struct *handle, files_struct *fsp,
1409 SMB_OFF_T *poffset, SMB_OFF_T *pcount, int *ptype, pid_t *ppid)
1413 result = SMB_VFS_NEXT_GETLOCK(handle, fsp, poffset, pcount, ptype, ppid);
1415 do_log(SMB_VFS_OP_GETLOCK, result, handle, "%s", fsp->fsp_name);
1420 static int smb_full_audit_symlink(vfs_handle_struct *handle,
1421 const char *oldpath, const char *newpath)
1425 result = SMB_VFS_NEXT_SYMLINK(handle, oldpath, newpath);
1427 do_log(SMB_VFS_OP_SYMLINK, (result >= 0), handle,
1428 "%s|%s", oldpath, newpath);
1433 static int smb_full_audit_readlink(vfs_handle_struct *handle,
1434 const char *path, char *buf, size_t bufsiz)
1438 result = SMB_VFS_NEXT_READLINK(handle, path, buf, bufsiz);
1440 do_log(SMB_VFS_OP_READLINK, (result >= 0), handle, "%s", path);
1445 static int smb_full_audit_link(vfs_handle_struct *handle,
1446 const char *oldpath, const char *newpath)
1450 result = SMB_VFS_NEXT_LINK(handle, oldpath, newpath);
1452 do_log(SMB_VFS_OP_LINK, (result >= 0), handle,
1453 "%s|%s", oldpath, newpath);
1458 static int smb_full_audit_mknod(vfs_handle_struct *handle,
1459 const char *pathname, mode_t mode, SMB_DEV_T dev)
1463 result = SMB_VFS_NEXT_MKNOD(handle, pathname, mode, dev);
1465 do_log(SMB_VFS_OP_MKNOD, (result >= 0), handle, "%s", pathname);
1470 static char *smb_full_audit_realpath(vfs_handle_struct *handle,
1471 const char *path, char *resolved_path)
1475 result = SMB_VFS_NEXT_REALPATH(handle, path, resolved_path);
1477 do_log(SMB_VFS_OP_REALPATH, (result != NULL), handle, "%s", path);
1482 static NTSTATUS smb_full_audit_notify_watch(struct vfs_handle_struct *handle,
1483 struct sys_notify_context *ctx,
1484 struct notify_entry *e,
1485 void (*callback)(struct sys_notify_context *ctx,
1487 struct notify_event *ev),
1488 void *private_data, void *handle_p)
1492 result = SMB_VFS_NEXT_NOTIFY_WATCH(handle, ctx, e, callback, private_data, handle_p);
1494 do_log(SMB_VFS_OP_NOTIFY_WATCH, NT_STATUS_IS_OK(result), handle, "");
1499 static int smb_full_audit_chflags(vfs_handle_struct *handle,
1500 const char *path, unsigned int flags)
1504 result = SMB_VFS_NEXT_CHFLAGS(handle, path, flags);
1506 do_log(SMB_VFS_OP_CHFLAGS, (result != 0), handle, "%s", path);
1511 static struct file_id smb_full_audit_file_id_create(struct vfs_handle_struct *handle,
1512 SMB_DEV_T dev, SMB_INO_T inode)
1514 struct file_id id_zero;
1515 struct file_id result;
1517 ZERO_STRUCT(id_zero);
1519 result = SMB_VFS_NEXT_FILE_ID_CREATE(handle, dev, inode);
1521 do_log(SMB_VFS_OP_FILE_ID_CREATE,
1522 !file_id_equal(&id_zero, &result),
1523 handle, "%s", file_id_string_tos(&result));
1528 static NTSTATUS smb_full_audit_fget_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
1529 uint32 security_info,
1534 result = SMB_VFS_NEXT_FGET_NT_ACL(handle, fsp, security_info, ppdesc);
1536 do_log(SMB_VFS_OP_FGET_NT_ACL, NT_STATUS_IS_OK(result), handle,
1537 "%s", fsp->fsp_name);
1542 static NTSTATUS smb_full_audit_get_nt_acl(vfs_handle_struct *handle,
1545 uint32 security_info,
1550 result = SMB_VFS_NEXT_GET_NT_ACL(handle, name, security_info, ppdesc);
1552 do_log(SMB_VFS_OP_GET_NT_ACL, NT_STATUS_IS_OK(result), handle,
1553 "%s", fsp->fsp_name);
1558 static NTSTATUS smb_full_audit_fset_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
1559 uint32 security_info_sent,
1564 result = SMB_VFS_NEXT_FSET_NT_ACL(handle, fsp, security_info_sent, psd);
1566 do_log(SMB_VFS_OP_FSET_NT_ACL, NT_STATUS_IS_OK(result), handle, "%s", fsp->fsp_name);
1571 static int smb_full_audit_chmod_acl(vfs_handle_struct *handle,
1572 const char *path, mode_t mode)
1576 result = SMB_VFS_NEXT_CHMOD_ACL(handle, path, mode);
1578 do_log(SMB_VFS_OP_CHMOD_ACL, (result >= 0), handle,
1579 "%s|%o", path, mode);
1584 static int smb_full_audit_fchmod_acl(vfs_handle_struct *handle, files_struct *fsp,
1589 result = SMB_VFS_NEXT_FCHMOD_ACL(handle, fsp, mode);
1591 do_log(SMB_VFS_OP_FCHMOD_ACL, (result >= 0), handle,
1592 "%s|%o", fsp->fsp_name, mode);
1597 static int smb_full_audit_sys_acl_get_entry(vfs_handle_struct *handle,
1599 SMB_ACL_T theacl, int entry_id,
1600 SMB_ACL_ENTRY_T *entry_p)
1604 result = SMB_VFS_NEXT_SYS_ACL_GET_ENTRY(handle, theacl, entry_id,
1607 do_log(SMB_VFS_OP_SYS_ACL_GET_ENTRY, (result >= 0), handle,
1613 static int smb_full_audit_sys_acl_get_tag_type(vfs_handle_struct *handle,
1615 SMB_ACL_ENTRY_T entry_d,
1616 SMB_ACL_TAG_T *tag_type_p)
1620 result = SMB_VFS_NEXT_SYS_ACL_GET_TAG_TYPE(handle, entry_d,
1623 do_log(SMB_VFS_OP_SYS_ACL_GET_TAG_TYPE, (result >= 0), handle,
1629 static int smb_full_audit_sys_acl_get_permset(vfs_handle_struct *handle,
1631 SMB_ACL_ENTRY_T entry_d,
1632 SMB_ACL_PERMSET_T *permset_p)
1636 result = SMB_VFS_NEXT_SYS_ACL_GET_PERMSET(handle, entry_d,
1639 do_log(SMB_VFS_OP_SYS_ACL_GET_PERMSET, (result >= 0), handle,
1645 static void * smb_full_audit_sys_acl_get_qualifier(vfs_handle_struct *handle,
1647 SMB_ACL_ENTRY_T entry_d)
1651 result = SMB_VFS_NEXT_SYS_ACL_GET_QUALIFIER(handle, entry_d);
1653 do_log(SMB_VFS_OP_SYS_ACL_GET_QUALIFIER, (result != NULL), handle,
1659 static SMB_ACL_T smb_full_audit_sys_acl_get_file(vfs_handle_struct *handle,
1661 SMB_ACL_TYPE_T type)
1665 result = SMB_VFS_NEXT_SYS_ACL_GET_FILE(handle, path_p, type);
1667 do_log(SMB_VFS_OP_SYS_ACL_GET_FILE, (result != NULL), handle,
1673 static SMB_ACL_T smb_full_audit_sys_acl_get_fd(vfs_handle_struct *handle,
1678 result = SMB_VFS_NEXT_SYS_ACL_GET_FD(handle, fsp);
1680 do_log(SMB_VFS_OP_SYS_ACL_GET_FD, (result != NULL), handle,
1681 "%s", fsp->fsp_name);
1686 static int smb_full_audit_sys_acl_clear_perms(vfs_handle_struct *handle,
1688 SMB_ACL_PERMSET_T permset)
1692 result = SMB_VFS_NEXT_SYS_ACL_CLEAR_PERMS(handle, permset);
1694 do_log(SMB_VFS_OP_SYS_ACL_CLEAR_PERMS, (result >= 0), handle,
1700 static int smb_full_audit_sys_acl_add_perm(vfs_handle_struct *handle,
1702 SMB_ACL_PERMSET_T permset,
1703 SMB_ACL_PERM_T perm)
1707 result = SMB_VFS_NEXT_SYS_ACL_ADD_PERM(handle, permset, perm);
1709 do_log(SMB_VFS_OP_SYS_ACL_ADD_PERM, (result >= 0), handle,
1715 static char * smb_full_audit_sys_acl_to_text(vfs_handle_struct *handle,
1721 result = SMB_VFS_NEXT_SYS_ACL_TO_TEXT(handle, theacl, plen);
1723 do_log(SMB_VFS_OP_SYS_ACL_TO_TEXT, (result != NULL), handle,
1729 static SMB_ACL_T smb_full_audit_sys_acl_init(vfs_handle_struct *handle,
1735 result = SMB_VFS_NEXT_SYS_ACL_INIT(handle, count);
1737 do_log(SMB_VFS_OP_SYS_ACL_INIT, (result != NULL), handle,
1743 static int smb_full_audit_sys_acl_create_entry(vfs_handle_struct *handle,
1745 SMB_ACL_ENTRY_T *pentry)
1749 result = SMB_VFS_NEXT_SYS_ACL_CREATE_ENTRY(handle, pacl, pentry);
1751 do_log(SMB_VFS_OP_SYS_ACL_CREATE_ENTRY, (result >= 0), handle,
1757 static int smb_full_audit_sys_acl_set_tag_type(vfs_handle_struct *handle,
1759 SMB_ACL_ENTRY_T entry,
1760 SMB_ACL_TAG_T tagtype)
1764 result = SMB_VFS_NEXT_SYS_ACL_SET_TAG_TYPE(handle, entry,
1767 do_log(SMB_VFS_OP_SYS_ACL_SET_TAG_TYPE, (result >= 0), handle,
1773 static int smb_full_audit_sys_acl_set_qualifier(vfs_handle_struct *handle,
1775 SMB_ACL_ENTRY_T entry,
1780 result = SMB_VFS_NEXT_SYS_ACL_SET_QUALIFIER(handle, entry, qual);
1782 do_log(SMB_VFS_OP_SYS_ACL_SET_QUALIFIER, (result >= 0), handle,
1788 static int smb_full_audit_sys_acl_set_permset(vfs_handle_struct *handle,
1790 SMB_ACL_ENTRY_T entry,
1791 SMB_ACL_PERMSET_T permset)
1795 result = SMB_VFS_NEXT_SYS_ACL_SET_PERMSET(handle, entry, permset);
1797 do_log(SMB_VFS_OP_SYS_ACL_SET_PERMSET, (result >= 0), handle,
1803 static int smb_full_audit_sys_acl_valid(vfs_handle_struct *handle,
1809 result = SMB_VFS_NEXT_SYS_ACL_VALID(handle, theacl);
1811 do_log(SMB_VFS_OP_SYS_ACL_VALID, (result >= 0), handle,
1817 static int smb_full_audit_sys_acl_set_file(vfs_handle_struct *handle,
1819 const char *name, SMB_ACL_TYPE_T acltype,
1824 result = SMB_VFS_NEXT_SYS_ACL_SET_FILE(handle, name, acltype,
1827 do_log(SMB_VFS_OP_SYS_ACL_SET_FILE, (result >= 0), handle,
1833 static int smb_full_audit_sys_acl_set_fd(vfs_handle_struct *handle, files_struct *fsp,
1838 result = SMB_VFS_NEXT_SYS_ACL_SET_FD(handle, fsp, theacl);
1840 do_log(SMB_VFS_OP_SYS_ACL_SET_FD, (result >= 0), handle,
1841 "%s", fsp->fsp_name);
1846 static int smb_full_audit_sys_acl_delete_def_file(vfs_handle_struct *handle,
1852 result = SMB_VFS_NEXT_SYS_ACL_DELETE_DEF_FILE(handle, path);
1854 do_log(SMB_VFS_OP_SYS_ACL_DELETE_DEF_FILE, (result >= 0), handle,
1860 static int smb_full_audit_sys_acl_get_perm(vfs_handle_struct *handle,
1862 SMB_ACL_PERMSET_T permset,
1863 SMB_ACL_PERM_T perm)
1867 result = SMB_VFS_NEXT_SYS_ACL_GET_PERM(handle, permset, perm);
1869 do_log(SMB_VFS_OP_SYS_ACL_GET_PERM, (result >= 0), handle,
1875 static int smb_full_audit_sys_acl_free_text(vfs_handle_struct *handle,
1881 result = SMB_VFS_NEXT_SYS_ACL_FREE_TEXT(handle, text);
1883 do_log(SMB_VFS_OP_SYS_ACL_FREE_TEXT, (result >= 0), handle,
1889 static int smb_full_audit_sys_acl_free_acl(vfs_handle_struct *handle,
1891 SMB_ACL_T posix_acl)
1895 result = SMB_VFS_NEXT_SYS_ACL_FREE_ACL(handle, posix_acl);
1897 do_log(SMB_VFS_OP_SYS_ACL_FREE_ACL, (result >= 0), handle,
1903 static int smb_full_audit_sys_acl_free_qualifier(vfs_handle_struct *handle,
1905 SMB_ACL_TAG_T tagtype)
1909 result = SMB_VFS_NEXT_SYS_ACL_FREE_QUALIFIER(handle, qualifier,
1912 do_log(SMB_VFS_OP_SYS_ACL_FREE_QUALIFIER, (result >= 0), handle,
1918 static ssize_t smb_full_audit_getxattr(struct vfs_handle_struct *handle,
1920 const char *name, void *value, size_t size)
1924 result = SMB_VFS_NEXT_GETXATTR(handle, path, name, value, size);
1926 do_log(SMB_VFS_OP_GETXATTR, (result >= 0), handle,
1927 "%s|%s", path, name);
1932 static ssize_t smb_full_audit_lgetxattr(struct vfs_handle_struct *handle,
1933 const char *path, const char *name,
1934 void *value, size_t size)
1938 result = SMB_VFS_NEXT_LGETXATTR(handle, path, name, value, size);
1940 do_log(SMB_VFS_OP_LGETXATTR, (result >= 0), handle,
1941 "%s|%s", path, name);
1946 static ssize_t smb_full_audit_fgetxattr(struct vfs_handle_struct *handle,
1947 struct files_struct *fsp,
1948 const char *name, void *value, size_t size)
1952 result = SMB_VFS_NEXT_FGETXATTR(handle, fsp, name, value, size);
1954 do_log(SMB_VFS_OP_FGETXATTR, (result >= 0), handle,
1955 "%s|%s", fsp->fsp_name, name);
1960 static ssize_t smb_full_audit_listxattr(struct vfs_handle_struct *handle,
1961 const char *path, char *list, size_t size)
1965 result = SMB_VFS_NEXT_LISTXATTR(handle, path, list, size);
1967 do_log(SMB_VFS_OP_LISTXATTR, (result >= 0), handle, "%s", path);
1972 static ssize_t smb_full_audit_llistxattr(struct vfs_handle_struct *handle,
1973 const char *path, char *list, size_t size)
1977 result = SMB_VFS_NEXT_LLISTXATTR(handle, path, list, size);
1979 do_log(SMB_VFS_OP_LLISTXATTR, (result >= 0), handle, "%s", path);
1984 static ssize_t smb_full_audit_flistxattr(struct vfs_handle_struct *handle,
1985 struct files_struct *fsp, char *list,
1990 result = SMB_VFS_NEXT_FLISTXATTR(handle, fsp, list, size);
1992 do_log(SMB_VFS_OP_FLISTXATTR, (result >= 0), handle,
1993 "%s", fsp->fsp_name);
1998 static int smb_full_audit_removexattr(struct vfs_handle_struct *handle,
2004 result = SMB_VFS_NEXT_REMOVEXATTR(handle, path, name);
2006 do_log(SMB_VFS_OP_REMOVEXATTR, (result >= 0), handle,
2007 "%s|%s", path, name);
2012 static int smb_full_audit_lremovexattr(struct vfs_handle_struct *handle,
2018 result = SMB_VFS_NEXT_LREMOVEXATTR(handle, path, name);
2020 do_log(SMB_VFS_OP_LREMOVEXATTR, (result >= 0), handle,
2021 "%s|%s", path, name);
2026 static int smb_full_audit_fremovexattr(struct vfs_handle_struct *handle,
2027 struct files_struct *fsp,
2032 result = SMB_VFS_NEXT_FREMOVEXATTR(handle, fsp, name);
2034 do_log(SMB_VFS_OP_FREMOVEXATTR, (result >= 0), handle,
2035 "%s|%s", fsp->fsp_name, name);
2040 static int smb_full_audit_setxattr(struct vfs_handle_struct *handle,
2042 const char *name, const void *value, size_t size,
2047 result = SMB_VFS_NEXT_SETXATTR(handle, path, name, value, size,
2050 do_log(SMB_VFS_OP_SETXATTR, (result >= 0), handle,
2051 "%s|%s", path, name);
2056 static int smb_full_audit_lsetxattr(struct vfs_handle_struct *handle,
2058 const char *name, const void *value, size_t size,
2063 result = SMB_VFS_NEXT_LSETXATTR(handle, path, name, value, size,
2066 do_log(SMB_VFS_OP_LSETXATTR, (result >= 0), handle,
2067 "%s|%s", path, name);
2072 static int smb_full_audit_fsetxattr(struct vfs_handle_struct *handle,
2073 struct files_struct *fsp, const char *name,
2074 const void *value, size_t size, int flags)
2078 result = SMB_VFS_NEXT_FSETXATTR(handle, fsp, name, value, size, flags);
2080 do_log(SMB_VFS_OP_FSETXATTR, (result >= 0), handle,
2081 "%s|%s", fsp->fsp_name, name);
2086 static int smb_full_audit_aio_read(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb)
2090 result = SMB_VFS_NEXT_AIO_READ(handle, fsp, aiocb);
2091 do_log(SMB_VFS_OP_AIO_READ, (result >= 0), handle,
2092 "%s", fsp->fsp_name);
2097 static int smb_full_audit_aio_write(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb)
2101 result = SMB_VFS_NEXT_AIO_WRITE(handle, fsp, aiocb);
2102 do_log(SMB_VFS_OP_AIO_WRITE, (result >= 0), handle,
2103 "%s", fsp->fsp_name);
2108 static ssize_t smb_full_audit_aio_return(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb)
2112 result = SMB_VFS_NEXT_AIO_RETURN(handle, fsp, aiocb);
2113 do_log(SMB_VFS_OP_AIO_RETURN, (result >= 0), handle,
2114 "%s", fsp->fsp_name);
2119 static int smb_full_audit_aio_cancel(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb)
2123 result = SMB_VFS_NEXT_AIO_CANCEL(handle, fsp, aiocb);
2124 do_log(SMB_VFS_OP_AIO_CANCEL, (result >= 0), handle,
2125 "%s", fsp->fsp_name);
2130 static int smb_full_audit_aio_error(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb)
2134 result = SMB_VFS_NEXT_AIO_ERROR(handle, fsp, aiocb);
2135 do_log(SMB_VFS_OP_AIO_ERROR, (result >= 0), handle,
2136 "%s", fsp->fsp_name);
2141 static int smb_full_audit_aio_fsync(struct vfs_handle_struct *handle, struct files_struct *fsp, int op, SMB_STRUCT_AIOCB *aiocb)
2145 result = SMB_VFS_NEXT_AIO_FSYNC(handle, fsp, op, aiocb);
2146 do_log(SMB_VFS_OP_AIO_FSYNC, (result >= 0), handle,
2147 "%s", fsp->fsp_name);
2152 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)
2156 result = SMB_VFS_NEXT_AIO_SUSPEND(handle, fsp, aiocb, n, ts);
2157 do_log(SMB_VFS_OP_AIO_SUSPEND, (result >= 0), handle,
2158 "%s", fsp->fsp_name);
2164 NTSTATUS vfs_full_audit_init(void);
2165 NTSTATUS vfs_full_audit_init(void)
2167 NTSTATUS ret = smb_register_vfs(SMB_VFS_INTERFACE_VERSION,
2168 "full_audit", audit_op_tuples);
2170 if (!NT_STATUS_IS_OK(ret))
2173 vfs_full_audit_debug_level = debug_add_class("full_audit");
2174 if (vfs_full_audit_debug_level == -1) {
2175 vfs_full_audit_debug_level = DBGC_VFS;
2176 DEBUG(0, ("vfs_full_audit: Couldn't register custom debugging "
2179 DEBUG(10, ("vfs_full_audit: Debug class number of "
2180 "'full_audit': %d\n", vfs_full_audit_debug_level));