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 2 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, write to the Free Software
23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
27 * This module implements parseable logging for all Samba VFS operations.
29 * You use it as follows:
33 * vfs objects = full_audit
34 * full_audit:prefix = %u|%I
35 * full_audit:success = open opendir
36 * full_audit:failure = all
38 * vfs op can be "all" which means log all operations.
39 * vfs op can be "none" which means no logging.
41 * This leads to syslog entries of the form:
42 * smbd_audit: nobody|192.168.234.1|opendir|ok|.
43 * smbd_audit: nobody|192.168.234.1|open|fail (File not found)|r|x.txt
45 * where "nobody" is the connected username and "192.168.234.1" is the
46 * client's IP address.
50 * prefix: A macro expansion template prepended to the syslog entry.
52 * success: A list of VFS operations for which a successful completion should
53 * be logged. Defaults to no logging at all. The special operation "all" logs
54 * - you guessed it - everything.
56 * failure: A list of VFS operations for which failure to complete should be
57 * logged. Defaults to logging everything.
63 extern userdom_struct current_user_info;
65 static int vfs_full_audit_debug_level = DBGC_VFS;
67 struct vfs_full_audit_private_data {
68 struct bitmap *success_ops;
69 struct bitmap *failure_ops;
73 #define DBGC_CLASS vfs_full_audit_debug_level
75 /* Function prototypes */
77 static int smb_full_audit_connect(vfs_handle_struct *handle,
78 const char *svc, const char *user);
79 static void smb_full_audit_disconnect(vfs_handle_struct *handle);
80 static SMB_BIG_UINT smb_full_audit_disk_free(vfs_handle_struct *handle,
82 BOOL small_query, SMB_BIG_UINT *bsize,
83 SMB_BIG_UINT *dfree, SMB_BIG_UINT *dsize);
84 static int smb_full_audit_get_quota(struct vfs_handle_struct *handle,
85 enum SMB_QUOTA_TYPE qtype, unid_t id,
87 static int smb_full_audit_set_quota(struct vfs_handle_struct *handle,
88 enum SMB_QUOTA_TYPE qtype, unid_t id,
90 static int smb_full_audit_get_shadow_copy_data(struct vfs_handle_struct *handle,
91 struct files_struct *fsp,
92 SHADOW_COPY_DATA *shadow_copy_data, BOOL labels);
93 static int smb_full_audit_statvfs(struct vfs_handle_struct *handle,
95 struct vfs_statvfs_struct *statbuf);
97 static SMB_STRUCT_DIR *smb_full_audit_opendir(vfs_handle_struct *handle,
98 const char *fname, const char *mask, uint32 attr);
99 static SMB_STRUCT_DIRENT *smb_full_audit_readdir(vfs_handle_struct *handle,
100 SMB_STRUCT_DIR *dirp);
101 static void smb_full_audit_seekdir(vfs_handle_struct *handle,
102 SMB_STRUCT_DIR *dirp, long offset);
103 static long smb_full_audit_telldir(vfs_handle_struct *handle,
104 SMB_STRUCT_DIR *dirp);
105 static void smb_full_audit_rewinddir(vfs_handle_struct *handle,
106 SMB_STRUCT_DIR *dirp);
107 static int smb_full_audit_mkdir(vfs_handle_struct *handle,
108 const char *path, mode_t mode);
109 static int smb_full_audit_rmdir(vfs_handle_struct *handle,
111 static int smb_full_audit_closedir(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 int smb_full_audit_close(vfs_handle_struct *handle, files_struct *fsp, int fd);
116 static ssize_t smb_full_audit_read(vfs_handle_struct *handle, files_struct *fsp,
117 int fd, void *data, size_t n);
118 static ssize_t smb_full_audit_pread(vfs_handle_struct *handle, files_struct *fsp,
119 int fd, void *data, size_t n, SMB_OFF_T offset);
120 static ssize_t smb_full_audit_write(vfs_handle_struct *handle, files_struct *fsp,
121 int fd, const void *data, size_t n);
122 static ssize_t smb_full_audit_pwrite(vfs_handle_struct *handle, files_struct *fsp,
123 int fd, const void *data, size_t n,
125 static SMB_OFF_T smb_full_audit_lseek(vfs_handle_struct *handle, files_struct *fsp,
126 int filedes, SMB_OFF_T offset, int whence);
127 static ssize_t smb_full_audit_sendfile(vfs_handle_struct *handle, int tofd,
128 files_struct *fsp, int fromfd,
129 const DATA_BLOB *hdr, SMB_OFF_T offset,
131 static int smb_full_audit_rename(vfs_handle_struct *handle,
132 const char *oldname, const char *newname);
133 static int smb_full_audit_fsync(vfs_handle_struct *handle, files_struct *fsp, int fd);
134 static int smb_full_audit_stat(vfs_handle_struct *handle,
135 const char *fname, SMB_STRUCT_STAT *sbuf);
136 static int smb_full_audit_fstat(vfs_handle_struct *handle, files_struct *fsp, int fd,
137 SMB_STRUCT_STAT *sbuf);
138 static int smb_full_audit_lstat(vfs_handle_struct *handle,
139 const char *path, SMB_STRUCT_STAT *sbuf);
140 static int smb_full_audit_unlink(vfs_handle_struct *handle,
142 static int smb_full_audit_chmod(vfs_handle_struct *handle,
143 const char *path, mode_t mode);
144 static int smb_full_audit_fchmod(vfs_handle_struct *handle, files_struct *fsp, int fd,
146 static int smb_full_audit_chown(vfs_handle_struct *handle,
147 const char *path, uid_t uid, gid_t gid);
148 static int smb_full_audit_fchown(vfs_handle_struct *handle, files_struct *fsp, int fd,
149 uid_t uid, gid_t gid);
150 static int smb_full_audit_lchown(vfs_handle_struct *handle,
151 const char *path, uid_t uid, gid_t gid);
152 static int smb_full_audit_chdir(vfs_handle_struct *handle,
154 static char *smb_full_audit_getwd(vfs_handle_struct *handle,
156 static int smb_full_audit_ntimes(vfs_handle_struct *handle,
157 const char *path, const struct timespec ts[2]);
158 static int smb_full_audit_ftruncate(vfs_handle_struct *handle, files_struct *fsp,
159 int fd, SMB_OFF_T len);
160 static BOOL smb_full_audit_lock(vfs_handle_struct *handle, files_struct *fsp, int fd,
161 int op, SMB_OFF_T offset, SMB_OFF_T count, int type);
162 static int smb_full_audit_kernel_flock(struct vfs_handle_struct *handle,
163 struct files_struct *fsp, int fd,
165 static int smb_full_audit_linux_setlease(vfs_handle_struct *handle, files_struct *fsp,
166 int fd, int leasetype);
167 static BOOL smb_full_audit_getlock(vfs_handle_struct *handle, files_struct *fsp, int fd,
168 SMB_OFF_T *poffset, SMB_OFF_T *pcount, int *ptype, pid_t *ppid);
169 static int smb_full_audit_symlink(vfs_handle_struct *handle,
170 const char *oldpath, const char *newpath);
171 static int smb_full_audit_readlink(vfs_handle_struct *handle,
172 const char *path, char *buf, size_t bufsiz);
173 static int smb_full_audit_link(vfs_handle_struct *handle,
174 const char *oldpath, const char *newpath);
175 static int smb_full_audit_mknod(vfs_handle_struct *handle,
176 const char *pathname, mode_t mode, SMB_DEV_T dev);
177 static char *smb_full_audit_realpath(vfs_handle_struct *handle,
178 const char *path, char *resolved_path);
179 static NTSTATUS smb_full_audit_notify_watch(struct vfs_handle_struct *handle,
180 struct sys_notify_context *ctx,
181 struct notify_entry *e,
182 void (*callback)(struct sys_notify_context *ctx,
184 struct notify_event *ev),
185 void *private_data, void *handle_p);
186 static int smb_full_audit_chflags(vfs_handle_struct *handle,
187 const char *path, uint flags);
188 static size_t smb_full_audit_fget_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
189 int fd, uint32 security_info,
191 static size_t smb_full_audit_get_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
192 const char *name, uint32 security_info,
194 static NTSTATUS smb_full_audit_fset_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
195 int fd, uint32 security_info_sent,
197 static NTSTATUS smb_full_audit_set_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
198 const char *name, uint32 security_info_sent,
200 static int smb_full_audit_chmod_acl(vfs_handle_struct *handle,
201 const char *path, mode_t mode);
202 static int smb_full_audit_fchmod_acl(vfs_handle_struct *handle, files_struct *fsp,
203 int fd, mode_t mode);
204 static int smb_full_audit_sys_acl_get_entry(vfs_handle_struct *handle,
205 SMB_ACL_T theacl, int entry_id,
206 SMB_ACL_ENTRY_T *entry_p);
207 static int smb_full_audit_sys_acl_get_tag_type(vfs_handle_struct *handle,
208 SMB_ACL_ENTRY_T entry_d,
209 SMB_ACL_TAG_T *tag_type_p);
210 static int smb_full_audit_sys_acl_get_permset(vfs_handle_struct *handle,
211 SMB_ACL_ENTRY_T entry_d,
212 SMB_ACL_PERMSET_T *permset_p);
213 static void * smb_full_audit_sys_acl_get_qualifier(vfs_handle_struct *handle,
214 SMB_ACL_ENTRY_T entry_d);
215 static SMB_ACL_T smb_full_audit_sys_acl_get_file(vfs_handle_struct *handle,
217 SMB_ACL_TYPE_T type);
218 static SMB_ACL_T smb_full_audit_sys_acl_get_fd(vfs_handle_struct *handle,
221 static int smb_full_audit_sys_acl_clear_perms(vfs_handle_struct *handle,
222 SMB_ACL_PERMSET_T permset);
223 static int smb_full_audit_sys_acl_add_perm(vfs_handle_struct *handle,
224 SMB_ACL_PERMSET_T permset,
225 SMB_ACL_PERM_T perm);
226 static char * smb_full_audit_sys_acl_to_text(vfs_handle_struct *handle,
229 static SMB_ACL_T smb_full_audit_sys_acl_init(vfs_handle_struct *handle,
231 static int smb_full_audit_sys_acl_create_entry(vfs_handle_struct *handle,
233 SMB_ACL_ENTRY_T *pentry);
234 static int smb_full_audit_sys_acl_set_tag_type(vfs_handle_struct *handle,
235 SMB_ACL_ENTRY_T entry,
236 SMB_ACL_TAG_T tagtype);
237 static int smb_full_audit_sys_acl_set_qualifier(vfs_handle_struct *handle,
238 SMB_ACL_ENTRY_T entry,
240 static int smb_full_audit_sys_acl_set_permset(vfs_handle_struct *handle,
241 SMB_ACL_ENTRY_T entry,
242 SMB_ACL_PERMSET_T permset);
243 static int smb_full_audit_sys_acl_valid(vfs_handle_struct *handle,
245 static int smb_full_audit_sys_acl_set_file(vfs_handle_struct *handle,
246 const char *name, SMB_ACL_TYPE_T acltype,
248 static int smb_full_audit_sys_acl_set_fd(vfs_handle_struct *handle, files_struct *fsp,
249 int fd, SMB_ACL_T theacl);
250 static int smb_full_audit_sys_acl_delete_def_file(vfs_handle_struct *handle,
252 static int smb_full_audit_sys_acl_get_perm(vfs_handle_struct *handle,
253 SMB_ACL_PERMSET_T permset,
254 SMB_ACL_PERM_T perm);
255 static int smb_full_audit_sys_acl_free_text(vfs_handle_struct *handle,
257 static int smb_full_audit_sys_acl_free_acl(vfs_handle_struct *handle,
258 SMB_ACL_T posix_acl);
259 static int smb_full_audit_sys_acl_free_qualifier(vfs_handle_struct *handle,
261 SMB_ACL_TAG_T tagtype);
262 static ssize_t smb_full_audit_getxattr(struct vfs_handle_struct *handle,
264 const char *name, void *value, size_t size);
265 static ssize_t smb_full_audit_lgetxattr(struct vfs_handle_struct *handle,
266 const char *path, const char *name,
267 void *value, size_t size);
268 static ssize_t smb_full_audit_fgetxattr(struct vfs_handle_struct *handle,
269 struct files_struct *fsp, int fd,
270 const char *name, void *value, size_t size);
271 static ssize_t smb_full_audit_listxattr(struct vfs_handle_struct *handle,
272 const char *path, char *list, size_t size);
273 static ssize_t smb_full_audit_llistxattr(struct vfs_handle_struct *handle,
274 const char *path, char *list, size_t size);
275 static ssize_t smb_full_audit_flistxattr(struct vfs_handle_struct *handle,
276 struct files_struct *fsp, int fd, char *list,
278 static int smb_full_audit_removexattr(struct vfs_handle_struct *handle,
281 static int smb_full_audit_lremovexattr(struct vfs_handle_struct *handle,
284 static int smb_full_audit_fremovexattr(struct vfs_handle_struct *handle,
285 struct files_struct *fsp, int fd,
287 static int smb_full_audit_setxattr(struct vfs_handle_struct *handle,
289 const char *name, const void *value, size_t size,
291 static int smb_full_audit_lsetxattr(struct vfs_handle_struct *handle,
293 const char *name, const void *value, size_t size,
295 static int smb_full_audit_fsetxattr(struct vfs_handle_struct *handle,
296 struct files_struct *fsp, int fd, const char *name,
297 const void *value, size_t size, int flags);
299 static int smb_full_audit_aio_read(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb);
300 static int smb_full_audit_aio_write(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb);
301 static ssize_t smb_full_audit_aio_return(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb);
302 static int smb_full_audit_aio_cancel(struct vfs_handle_struct *handle, struct files_struct *fsp, int fd, SMB_STRUCT_AIOCB *aiocb);
303 static int smb_full_audit_aio_error(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb);
304 static int smb_full_audit_aio_fsync(struct vfs_handle_struct *handle, struct files_struct *fsp, int op, SMB_STRUCT_AIOCB *aiocb);
305 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);
309 static vfs_op_tuple audit_op_tuples[] = {
311 /* Disk operations */
313 {SMB_VFS_OP(smb_full_audit_connect), SMB_VFS_OP_CONNECT,
314 SMB_VFS_LAYER_LOGGER},
315 {SMB_VFS_OP(smb_full_audit_disconnect), SMB_VFS_OP_DISCONNECT,
316 SMB_VFS_LAYER_LOGGER},
317 {SMB_VFS_OP(smb_full_audit_disk_free), SMB_VFS_OP_DISK_FREE,
318 SMB_VFS_LAYER_LOGGER},
319 {SMB_VFS_OP(smb_full_audit_get_quota), SMB_VFS_OP_GET_QUOTA,
320 SMB_VFS_LAYER_LOGGER},
321 {SMB_VFS_OP(smb_full_audit_set_quota), SMB_VFS_OP_SET_QUOTA,
322 SMB_VFS_LAYER_LOGGER},
323 {SMB_VFS_OP(smb_full_audit_get_shadow_copy_data), SMB_VFS_OP_GET_SHADOW_COPY_DATA,
324 SMB_VFS_LAYER_LOGGER},
325 {SMB_VFS_OP(smb_full_audit_statvfs), SMB_VFS_OP_STATVFS,
326 SMB_VFS_LAYER_LOGGER},
328 /* Directory operations */
330 {SMB_VFS_OP(smb_full_audit_opendir), SMB_VFS_OP_OPENDIR,
331 SMB_VFS_LAYER_LOGGER},
332 {SMB_VFS_OP(smb_full_audit_readdir), SMB_VFS_OP_READDIR,
333 SMB_VFS_LAYER_LOGGER},
334 {SMB_VFS_OP(smb_full_audit_seekdir), SMB_VFS_OP_SEEKDIR,
335 SMB_VFS_LAYER_LOGGER},
336 {SMB_VFS_OP(smb_full_audit_telldir), SMB_VFS_OP_TELLDIR,
337 SMB_VFS_LAYER_LOGGER},
338 {SMB_VFS_OP(smb_full_audit_rewinddir), SMB_VFS_OP_REWINDDIR,
339 SMB_VFS_LAYER_LOGGER},
340 {SMB_VFS_OP(smb_full_audit_mkdir), SMB_VFS_OP_MKDIR,
341 SMB_VFS_LAYER_LOGGER},
342 {SMB_VFS_OP(smb_full_audit_rmdir), SMB_VFS_OP_RMDIR,
343 SMB_VFS_LAYER_LOGGER},
344 {SMB_VFS_OP(smb_full_audit_closedir), SMB_VFS_OP_CLOSEDIR,
345 SMB_VFS_LAYER_LOGGER},
347 /* File operations */
349 {SMB_VFS_OP(smb_full_audit_open), SMB_VFS_OP_OPEN,
350 SMB_VFS_LAYER_LOGGER},
351 {SMB_VFS_OP(smb_full_audit_close), SMB_VFS_OP_CLOSE,
352 SMB_VFS_LAYER_LOGGER},
353 {SMB_VFS_OP(smb_full_audit_read), SMB_VFS_OP_READ,
354 SMB_VFS_LAYER_LOGGER},
355 {SMB_VFS_OP(smb_full_audit_pread), SMB_VFS_OP_PREAD,
356 SMB_VFS_LAYER_LOGGER},
357 {SMB_VFS_OP(smb_full_audit_write), SMB_VFS_OP_WRITE,
358 SMB_VFS_LAYER_LOGGER},
359 {SMB_VFS_OP(smb_full_audit_pwrite), SMB_VFS_OP_PWRITE,
360 SMB_VFS_LAYER_LOGGER},
361 {SMB_VFS_OP(smb_full_audit_lseek), SMB_VFS_OP_LSEEK,
362 SMB_VFS_LAYER_LOGGER},
363 {SMB_VFS_OP(smb_full_audit_sendfile), SMB_VFS_OP_SENDFILE,
364 SMB_VFS_LAYER_LOGGER},
365 {SMB_VFS_OP(smb_full_audit_rename), SMB_VFS_OP_RENAME,
366 SMB_VFS_LAYER_LOGGER},
367 {SMB_VFS_OP(smb_full_audit_fsync), SMB_VFS_OP_FSYNC,
368 SMB_VFS_LAYER_LOGGER},
369 {SMB_VFS_OP(smb_full_audit_stat), SMB_VFS_OP_STAT,
370 SMB_VFS_LAYER_LOGGER},
371 {SMB_VFS_OP(smb_full_audit_fstat), SMB_VFS_OP_FSTAT,
372 SMB_VFS_LAYER_LOGGER},
373 {SMB_VFS_OP(smb_full_audit_lstat), SMB_VFS_OP_LSTAT,
374 SMB_VFS_LAYER_LOGGER},
375 {SMB_VFS_OP(smb_full_audit_unlink), SMB_VFS_OP_UNLINK,
376 SMB_VFS_LAYER_LOGGER},
377 {SMB_VFS_OP(smb_full_audit_chmod), SMB_VFS_OP_CHMOD,
378 SMB_VFS_LAYER_LOGGER},
379 {SMB_VFS_OP(smb_full_audit_fchmod), SMB_VFS_OP_FCHMOD,
380 SMB_VFS_LAYER_LOGGER},
381 {SMB_VFS_OP(smb_full_audit_chown), SMB_VFS_OP_CHOWN,
382 SMB_VFS_LAYER_LOGGER},
383 {SMB_VFS_OP(smb_full_audit_fchown), SMB_VFS_OP_FCHOWN,
384 SMB_VFS_LAYER_LOGGER},
385 {SMB_VFS_OP(smb_full_audit_lchown), SMB_VFS_OP_LCHOWN,
386 SMB_VFS_LAYER_LOGGER},
387 {SMB_VFS_OP(smb_full_audit_chdir), SMB_VFS_OP_CHDIR,
388 SMB_VFS_LAYER_LOGGER},
389 {SMB_VFS_OP(smb_full_audit_getwd), SMB_VFS_OP_GETWD,
390 SMB_VFS_LAYER_LOGGER},
391 {SMB_VFS_OP(smb_full_audit_ntimes), SMB_VFS_OP_NTIMES,
392 SMB_VFS_LAYER_LOGGER},
393 {SMB_VFS_OP(smb_full_audit_ftruncate), SMB_VFS_OP_FTRUNCATE,
394 SMB_VFS_LAYER_LOGGER},
395 {SMB_VFS_OP(smb_full_audit_lock), SMB_VFS_OP_LOCK,
396 SMB_VFS_LAYER_LOGGER},
397 {SMB_VFS_OP(smb_full_audit_kernel_flock), SMB_VFS_OP_KERNEL_FLOCK,
398 SMB_VFS_LAYER_LOGGER},
399 {SMB_VFS_OP(smb_full_audit_linux_setlease), SMB_VFS_OP_LINUX_SETLEASE,
400 SMB_VFS_LAYER_LOGGER},
401 {SMB_VFS_OP(smb_full_audit_getlock), SMB_VFS_OP_GETLOCK,
402 SMB_VFS_LAYER_LOGGER},
403 {SMB_VFS_OP(smb_full_audit_symlink), SMB_VFS_OP_SYMLINK,
404 SMB_VFS_LAYER_LOGGER},
405 {SMB_VFS_OP(smb_full_audit_readlink), SMB_VFS_OP_READLINK,
406 SMB_VFS_LAYER_LOGGER},
407 {SMB_VFS_OP(smb_full_audit_link), SMB_VFS_OP_LINK,
408 SMB_VFS_LAYER_LOGGER},
409 {SMB_VFS_OP(smb_full_audit_mknod), SMB_VFS_OP_MKNOD,
410 SMB_VFS_LAYER_LOGGER},
411 {SMB_VFS_OP(smb_full_audit_realpath), SMB_VFS_OP_REALPATH,
412 SMB_VFS_LAYER_LOGGER},
413 {SMB_VFS_OP(smb_full_audit_notify_watch),SMB_VFS_OP_NOTIFY_WATCH,
414 SMB_VFS_LAYER_LOGGER},
415 {SMB_VFS_OP(smb_full_audit_chflags), SMB_VFS_OP_CHFLAGS,
416 SMB_VFS_LAYER_LOGGER},
418 /* NT ACL operations. */
420 {SMB_VFS_OP(smb_full_audit_fget_nt_acl), SMB_VFS_OP_FGET_NT_ACL,
421 SMB_VFS_LAYER_LOGGER},
422 {SMB_VFS_OP(smb_full_audit_get_nt_acl), SMB_VFS_OP_GET_NT_ACL,
423 SMB_VFS_LAYER_LOGGER},
424 {SMB_VFS_OP(smb_full_audit_fset_nt_acl), SMB_VFS_OP_FSET_NT_ACL,
425 SMB_VFS_LAYER_LOGGER},
426 {SMB_VFS_OP(smb_full_audit_set_nt_acl), SMB_VFS_OP_SET_NT_ACL,
427 SMB_VFS_LAYER_LOGGER},
429 /* POSIX ACL operations. */
431 {SMB_VFS_OP(smb_full_audit_chmod_acl), SMB_VFS_OP_CHMOD_ACL,
432 SMB_VFS_LAYER_LOGGER},
433 {SMB_VFS_OP(smb_full_audit_fchmod_acl), SMB_VFS_OP_FCHMOD_ACL,
434 SMB_VFS_LAYER_LOGGER},
435 {SMB_VFS_OP(smb_full_audit_sys_acl_get_entry), SMB_VFS_OP_SYS_ACL_GET_ENTRY,
436 SMB_VFS_LAYER_LOGGER},
437 {SMB_VFS_OP(smb_full_audit_sys_acl_get_tag_type), SMB_VFS_OP_SYS_ACL_GET_TAG_TYPE,
438 SMB_VFS_LAYER_LOGGER},
439 {SMB_VFS_OP(smb_full_audit_sys_acl_get_permset), SMB_VFS_OP_SYS_ACL_GET_PERMSET,
440 SMB_VFS_LAYER_LOGGER},
441 {SMB_VFS_OP(smb_full_audit_sys_acl_get_qualifier), SMB_VFS_OP_SYS_ACL_GET_QUALIFIER,
442 SMB_VFS_LAYER_LOGGER},
443 {SMB_VFS_OP(smb_full_audit_sys_acl_get_file), SMB_VFS_OP_SYS_ACL_GET_FILE,
444 SMB_VFS_LAYER_LOGGER},
445 {SMB_VFS_OP(smb_full_audit_sys_acl_get_fd), SMB_VFS_OP_SYS_ACL_GET_FD,
446 SMB_VFS_LAYER_LOGGER},
447 {SMB_VFS_OP(smb_full_audit_sys_acl_clear_perms), SMB_VFS_OP_SYS_ACL_CLEAR_PERMS,
448 SMB_VFS_LAYER_LOGGER},
449 {SMB_VFS_OP(smb_full_audit_sys_acl_add_perm), SMB_VFS_OP_SYS_ACL_ADD_PERM,
450 SMB_VFS_LAYER_LOGGER},
451 {SMB_VFS_OP(smb_full_audit_sys_acl_to_text), SMB_VFS_OP_SYS_ACL_TO_TEXT,
452 SMB_VFS_LAYER_LOGGER},
453 {SMB_VFS_OP(smb_full_audit_sys_acl_init), SMB_VFS_OP_SYS_ACL_INIT,
454 SMB_VFS_LAYER_LOGGER},
455 {SMB_VFS_OP(smb_full_audit_sys_acl_create_entry), SMB_VFS_OP_SYS_ACL_CREATE_ENTRY,
456 SMB_VFS_LAYER_LOGGER},
457 {SMB_VFS_OP(smb_full_audit_sys_acl_set_tag_type), SMB_VFS_OP_SYS_ACL_SET_TAG_TYPE,
458 SMB_VFS_LAYER_LOGGER},
459 {SMB_VFS_OP(smb_full_audit_sys_acl_set_qualifier), SMB_VFS_OP_SYS_ACL_SET_QUALIFIER,
460 SMB_VFS_LAYER_LOGGER},
461 {SMB_VFS_OP(smb_full_audit_sys_acl_set_permset), SMB_VFS_OP_SYS_ACL_SET_PERMSET,
462 SMB_VFS_LAYER_LOGGER},
463 {SMB_VFS_OP(smb_full_audit_sys_acl_valid), SMB_VFS_OP_SYS_ACL_VALID,
464 SMB_VFS_LAYER_LOGGER},
465 {SMB_VFS_OP(smb_full_audit_sys_acl_set_file), SMB_VFS_OP_SYS_ACL_SET_FILE,
466 SMB_VFS_LAYER_LOGGER},
467 {SMB_VFS_OP(smb_full_audit_sys_acl_set_fd), SMB_VFS_OP_SYS_ACL_SET_FD,
468 SMB_VFS_LAYER_LOGGER},
469 {SMB_VFS_OP(smb_full_audit_sys_acl_delete_def_file), SMB_VFS_OP_SYS_ACL_DELETE_DEF_FILE,
470 SMB_VFS_LAYER_LOGGER},
471 {SMB_VFS_OP(smb_full_audit_sys_acl_get_perm), SMB_VFS_OP_SYS_ACL_GET_PERM,
472 SMB_VFS_LAYER_LOGGER},
473 {SMB_VFS_OP(smb_full_audit_sys_acl_free_text), SMB_VFS_OP_SYS_ACL_FREE_TEXT,
474 SMB_VFS_LAYER_LOGGER},
475 {SMB_VFS_OP(smb_full_audit_sys_acl_free_acl), SMB_VFS_OP_SYS_ACL_FREE_ACL,
476 SMB_VFS_LAYER_LOGGER},
477 {SMB_VFS_OP(smb_full_audit_sys_acl_free_qualifier), SMB_VFS_OP_SYS_ACL_FREE_QUALIFIER,
478 SMB_VFS_LAYER_LOGGER},
482 {SMB_VFS_OP(smb_full_audit_getxattr), SMB_VFS_OP_GETXATTR,
483 SMB_VFS_LAYER_LOGGER},
484 {SMB_VFS_OP(smb_full_audit_lgetxattr), SMB_VFS_OP_LGETXATTR,
485 SMB_VFS_LAYER_LOGGER},
486 {SMB_VFS_OP(smb_full_audit_fgetxattr), SMB_VFS_OP_FGETXATTR,
487 SMB_VFS_LAYER_LOGGER},
488 {SMB_VFS_OP(smb_full_audit_listxattr), SMB_VFS_OP_LISTXATTR,
489 SMB_VFS_LAYER_LOGGER},
490 {SMB_VFS_OP(smb_full_audit_llistxattr), SMB_VFS_OP_LLISTXATTR,
491 SMB_VFS_LAYER_LOGGER},
492 {SMB_VFS_OP(smb_full_audit_flistxattr), SMB_VFS_OP_FLISTXATTR,
493 SMB_VFS_LAYER_LOGGER},
494 {SMB_VFS_OP(smb_full_audit_removexattr), SMB_VFS_OP_REMOVEXATTR,
495 SMB_VFS_LAYER_LOGGER},
496 {SMB_VFS_OP(smb_full_audit_lremovexattr), SMB_VFS_OP_LREMOVEXATTR,
497 SMB_VFS_LAYER_LOGGER},
498 {SMB_VFS_OP(smb_full_audit_fremovexattr), SMB_VFS_OP_FREMOVEXATTR,
499 SMB_VFS_LAYER_LOGGER},
500 {SMB_VFS_OP(smb_full_audit_setxattr), SMB_VFS_OP_SETXATTR,
501 SMB_VFS_LAYER_LOGGER},
502 {SMB_VFS_OP(smb_full_audit_lsetxattr), SMB_VFS_OP_LSETXATTR,
503 SMB_VFS_LAYER_LOGGER},
504 {SMB_VFS_OP(smb_full_audit_fsetxattr), SMB_VFS_OP_FSETXATTR,
505 SMB_VFS_LAYER_LOGGER},
507 {SMB_VFS_OP(smb_full_audit_aio_read), SMB_VFS_OP_AIO_READ,
508 SMB_VFS_LAYER_LOGGER},
509 {SMB_VFS_OP(smb_full_audit_aio_write), SMB_VFS_OP_AIO_WRITE,
510 SMB_VFS_LAYER_LOGGER},
511 {SMB_VFS_OP(smb_full_audit_aio_return), SMB_VFS_OP_AIO_RETURN,
512 SMB_VFS_LAYER_LOGGER},
513 {SMB_VFS_OP(smb_full_audit_aio_cancel), SMB_VFS_OP_AIO_CANCEL,
514 SMB_VFS_LAYER_LOGGER},
515 {SMB_VFS_OP(smb_full_audit_aio_error), SMB_VFS_OP_AIO_ERROR,
516 SMB_VFS_LAYER_LOGGER},
517 {SMB_VFS_OP(smb_full_audit_aio_fsync), SMB_VFS_OP_AIO_FSYNC,
518 SMB_VFS_LAYER_LOGGER},
519 {SMB_VFS_OP(smb_full_audit_aio_suspend),SMB_VFS_OP_AIO_SUSPEND,
520 SMB_VFS_LAYER_LOGGER},
522 /* Finish VFS operations definition */
524 {SMB_VFS_OP(NULL), SMB_VFS_OP_NOOP,
528 /* The following array *must* be in the same order as defined in vfs.h */
534 { SMB_VFS_OP_CONNECT, "connect" },
535 { SMB_VFS_OP_DISCONNECT, "disconnect" },
536 { SMB_VFS_OP_DISK_FREE, "disk_free" },
537 { SMB_VFS_OP_GET_QUOTA, "get_quota" },
538 { SMB_VFS_OP_SET_QUOTA, "set_quota" },
539 { SMB_VFS_OP_GET_SHADOW_COPY_DATA, "get_shadow_copy_data" },
540 { SMB_VFS_OP_STATVFS, "statvfs" },
541 { SMB_VFS_OP_OPENDIR, "opendir" },
542 { SMB_VFS_OP_READDIR, "readdir" },
543 { SMB_VFS_OP_SEEKDIR, "seekdir" },
544 { SMB_VFS_OP_TELLDIR, "telldir" },
545 { SMB_VFS_OP_REWINDDIR, "rewinddir" },
546 { SMB_VFS_OP_MKDIR, "mkdir" },
547 { SMB_VFS_OP_RMDIR, "rmdir" },
548 { SMB_VFS_OP_CLOSEDIR, "closedir" },
549 { SMB_VFS_OP_OPEN, "open" },
550 { SMB_VFS_OP_CLOSE, "close" },
551 { SMB_VFS_OP_READ, "read" },
552 { SMB_VFS_OP_PREAD, "pread" },
553 { SMB_VFS_OP_WRITE, "write" },
554 { SMB_VFS_OP_PWRITE, "pwrite" },
555 { SMB_VFS_OP_LSEEK, "lseek" },
556 { SMB_VFS_OP_SENDFILE, "sendfile" },
557 { SMB_VFS_OP_RENAME, "rename" },
558 { SMB_VFS_OP_FSYNC, "fsync" },
559 { SMB_VFS_OP_STAT, "stat" },
560 { SMB_VFS_OP_FSTAT, "fstat" },
561 { SMB_VFS_OP_LSTAT, "lstat" },
562 { SMB_VFS_OP_UNLINK, "unlink" },
563 { SMB_VFS_OP_CHMOD, "chmod" },
564 { SMB_VFS_OP_FCHMOD, "fchmod" },
565 { SMB_VFS_OP_CHOWN, "chown" },
566 { SMB_VFS_OP_FCHOWN, "fchown" },
567 { SMB_VFS_OP_LCHOWN, "lchown" },
568 { SMB_VFS_OP_CHDIR, "chdir" },
569 { SMB_VFS_OP_GETWD, "getwd" },
570 { SMB_VFS_OP_NTIMES, "ntimes" },
571 { SMB_VFS_OP_FTRUNCATE, "ftruncate" },
572 { SMB_VFS_OP_LOCK, "lock" },
573 { SMB_VFS_OP_KERNEL_FLOCK, "kernel_flock" },
574 { SMB_VFS_OP_LINUX_SETLEASE, "linux_setlease" },
575 { SMB_VFS_OP_GETLOCK, "getlock" },
576 { SMB_VFS_OP_SYMLINK, "symlink" },
577 { SMB_VFS_OP_READLINK, "readlink" },
578 { SMB_VFS_OP_LINK, "link" },
579 { SMB_VFS_OP_MKNOD, "mknod" },
580 { SMB_VFS_OP_REALPATH, "realpath" },
581 { SMB_VFS_OP_NOTIFY_WATCH, "notify_watch" },
582 { SMB_VFS_OP_CHFLAGS, "chflags" },
583 { SMB_VFS_OP_FGET_NT_ACL, "fget_nt_acl" },
584 { SMB_VFS_OP_GET_NT_ACL, "get_nt_acl" },
585 { SMB_VFS_OP_FSET_NT_ACL, "fset_nt_acl" },
586 { SMB_VFS_OP_SET_NT_ACL, "set_nt_acl" },
587 { SMB_VFS_OP_CHMOD_ACL, "chmod_acl" },
588 { SMB_VFS_OP_FCHMOD_ACL, "fchmod_acl" },
589 { SMB_VFS_OP_SYS_ACL_GET_ENTRY, "sys_acl_get_entry" },
590 { SMB_VFS_OP_SYS_ACL_GET_TAG_TYPE, "sys_acl_get_tag_type" },
591 { SMB_VFS_OP_SYS_ACL_GET_PERMSET, "sys_acl_get_permset" },
592 { SMB_VFS_OP_SYS_ACL_GET_QUALIFIER, "sys_acl_get_qualifier" },
593 { SMB_VFS_OP_SYS_ACL_GET_FILE, "sys_acl_get_file" },
594 { SMB_VFS_OP_SYS_ACL_GET_FD, "sys_acl_get_fd" },
595 { SMB_VFS_OP_SYS_ACL_CLEAR_PERMS, "sys_acl_clear_perms" },
596 { SMB_VFS_OP_SYS_ACL_ADD_PERM, "sys_acl_add_perm" },
597 { SMB_VFS_OP_SYS_ACL_TO_TEXT, "sys_acl_to_text" },
598 { SMB_VFS_OP_SYS_ACL_INIT, "sys_acl_init" },
599 { SMB_VFS_OP_SYS_ACL_CREATE_ENTRY, "sys_acl_create_entry" },
600 { SMB_VFS_OP_SYS_ACL_SET_TAG_TYPE, "sys_acl_set_tag_type" },
601 { SMB_VFS_OP_SYS_ACL_SET_QUALIFIER, "sys_acl_set_qualifier" },
602 { SMB_VFS_OP_SYS_ACL_SET_PERMSET, "sys_acl_set_permset" },
603 { SMB_VFS_OP_SYS_ACL_VALID, "sys_acl_valid" },
604 { SMB_VFS_OP_SYS_ACL_SET_FILE, "sys_acl_set_file" },
605 { SMB_VFS_OP_SYS_ACL_SET_FD, "sys_acl_set_fd" },
606 { SMB_VFS_OP_SYS_ACL_DELETE_DEF_FILE, "sys_acl_delete_def_file" },
607 { SMB_VFS_OP_SYS_ACL_GET_PERM, "sys_acl_get_perm" },
608 { SMB_VFS_OP_SYS_ACL_FREE_TEXT, "sys_acl_free_text" },
609 { SMB_VFS_OP_SYS_ACL_FREE_ACL, "sys_acl_free_acl" },
610 { SMB_VFS_OP_SYS_ACL_FREE_QUALIFIER, "sys_acl_free_qualifier" },
611 { SMB_VFS_OP_GETXATTR, "getxattr" },
612 { SMB_VFS_OP_LGETXATTR, "lgetxattr" },
613 { SMB_VFS_OP_FGETXATTR, "fgetxattr" },
614 { SMB_VFS_OP_LISTXATTR, "listxattr" },
615 { SMB_VFS_OP_LLISTXATTR, "llistxattr" },
616 { SMB_VFS_OP_FLISTXATTR, "flistxattr" },
617 { SMB_VFS_OP_REMOVEXATTR, "removexattr" },
618 { SMB_VFS_OP_LREMOVEXATTR, "lremovexattr" },
619 { SMB_VFS_OP_FREMOVEXATTR, "fremovexattr" },
620 { SMB_VFS_OP_SETXATTR, "setxattr" },
621 { SMB_VFS_OP_LSETXATTR, "lsetxattr" },
622 { SMB_VFS_OP_FSETXATTR, "fsetxattr" },
623 { SMB_VFS_OP_AIO_READ, "aio_read" },
624 { SMB_VFS_OP_AIO_WRITE, "aio_write" },
625 { SMB_VFS_OP_AIO_RETURN,"aio_return" },
626 { SMB_VFS_OP_AIO_CANCEL,"aio_cancel" },
627 { SMB_VFS_OP_AIO_ERROR, "aio_error" },
628 { SMB_VFS_OP_AIO_FSYNC, "aio_fsync" },
629 { SMB_VFS_OP_AIO_SUSPEND,"aio_suspend" },
630 { SMB_VFS_OP_LAST, NULL }
633 static int audit_syslog_facility(vfs_handle_struct *handle)
635 static const struct enum_list enum_log_facilities[] = {
636 { LOG_USER, "USER" },
637 { LOG_LOCAL0, "LOCAL0" },
638 { LOG_LOCAL1, "LOCAL1" },
639 { LOG_LOCAL2, "LOCAL2" },
640 { LOG_LOCAL3, "LOCAL3" },
641 { LOG_LOCAL4, "LOCAL4" },
642 { LOG_LOCAL5, "LOCAL5" },
643 { LOG_LOCAL6, "LOCAL6" },
644 { LOG_LOCAL7, "LOCAL7" }
649 facility = lp_parm_enum(SNUM(handle->conn), "full_audit", "facility", enum_log_facilities, LOG_USER);
654 static int audit_syslog_priority(vfs_handle_struct *handle)
656 static const struct enum_list enum_log_priorities[] = {
657 { LOG_EMERG, "EMERG" },
658 { LOG_ALERT, "ALERT" },
659 { LOG_CRIT, "CRIT" },
661 { LOG_WARNING, "WARNING" },
662 { LOG_NOTICE, "NOTICE" },
663 { LOG_INFO, "INFO" },
664 { LOG_DEBUG, "DEBUG" }
669 priority = lp_parm_enum(SNUM(handle->conn), "full_audit", "priority", enum_log_priorities, LOG_NOTICE);
674 static char *audit_prefix(connection_struct *conn)
676 static pstring prefix;
678 pstrcpy(prefix, lp_parm_const_string(SNUM(conn), "full_audit",
680 standard_sub_advanced(lp_servicename(SNUM(conn)), conn->user,
681 conn->connectpath, conn->gid,
682 get_current_username(),
683 current_user_info.domain,
684 prefix, sizeof(prefix));
688 static BOOL log_success(vfs_handle_struct *handle, vfs_op_type op)
690 struct vfs_full_audit_private_data *pd = NULL;
692 SMB_VFS_HANDLE_GET_DATA(handle, pd,
693 struct vfs_full_audit_private_data,
696 if (pd->success_ops == NULL) {
700 return bitmap_query(pd->success_ops, op);
703 static BOOL log_failure(vfs_handle_struct *handle, vfs_op_type op)
705 struct vfs_full_audit_private_data *pd = NULL;
707 SMB_VFS_HANDLE_GET_DATA(handle, pd,
708 struct vfs_full_audit_private_data,
711 if (pd->failure_ops == NULL)
714 return bitmap_query(pd->failure_ops, op);
717 static void init_bitmap(struct bitmap **bm, const char **ops)
719 BOOL log_all = False;
724 *bm = bitmap_allocate(SMB_VFS_OP_LAST);
727 DEBUG(0, ("Could not alloc bitmap -- "
728 "defaulting to logging everything\n"));
732 while (*ops != NULL) {
736 if (strequal(*ops, "all")) {
741 if (strequal(*ops, "none")) {
745 for (i=0; i<SMB_VFS_OP_LAST; i++) {
746 if (vfs_op_names[i].name == NULL) {
747 smb_panic("vfs_full_audit.c: name table not "
748 "in sync with vfs.h\n");
751 if (strequal(*ops, vfs_op_names[i].name)) {
757 DEBUG(0, ("Could not find opname %s, logging all\n",
766 /* The query functions default to True */
772 static const char *audit_opname(vfs_op_type op)
774 if (op >= SMB_VFS_OP_LAST)
775 return "INVALID VFS OP";
776 return vfs_op_names[op].name;
779 static void do_log(vfs_op_type op, BOOL success, vfs_handle_struct *handle,
780 const char *format, ...)
786 if (success && (!log_success(handle, op)))
789 if (!success && (!log_failure(handle, op)))
793 fstrcpy(err_msg, "ok");
795 fstr_sprintf(err_msg, "fail (%s)", strerror(errno));
797 va_start(ap, format);
798 vsnprintf(op_msg, sizeof(op_msg), format, ap);
801 syslog(audit_syslog_priority(handle), "%s|%s|%s|%s\n",
802 audit_prefix(handle->conn), audit_opname(op), err_msg, op_msg);
807 /* Free function for the private data. */
809 static void free_private_data(void **p_data)
811 struct vfs_full_audit_private_data *pd = *(struct vfs_full_audit_private_data **)p_data;
813 if (pd->success_ops) {
814 bitmap_free(pd->success_ops);
816 if (pd->failure_ops) {
817 bitmap_free(pd->failure_ops);
823 /* Implementation of vfs_ops. Pass everything on to the default
824 operation but log event first. */
826 static int smb_full_audit_connect(vfs_handle_struct *handle,
827 const char *svc, const char *user)
830 struct vfs_full_audit_private_data *pd = NULL;
831 const char *none[] = { NULL };
832 const char *all [] = { "all" };
838 pd = SMB_MALLOC_P(struct vfs_full_audit_private_data);
844 openlog("smbd_audit", 0, audit_syslog_facility(handle));
846 init_bitmap(&pd->success_ops,
847 lp_parm_string_list(SNUM(handle->conn), "full_audit", "success",
849 init_bitmap(&pd->failure_ops,
850 lp_parm_string_list(SNUM(handle->conn), "full_audit", "failure",
853 /* Store the private data. */
854 SMB_VFS_HANDLE_SET_DATA(handle, pd, free_private_data,
855 struct vfs_full_audit_private_data, return -1);
857 result = SMB_VFS_NEXT_CONNECT(handle, svc, user);
859 do_log(SMB_VFS_OP_CONNECT, True, handle,
865 static void smb_full_audit_disconnect(vfs_handle_struct *handle)
867 SMB_VFS_NEXT_DISCONNECT(handle);
869 do_log(SMB_VFS_OP_DISCONNECT, True, handle,
870 "%s", lp_servicename(SNUM(handle->conn)));
872 /* The bitmaps will be disconnected when the private
878 static SMB_BIG_UINT smb_full_audit_disk_free(vfs_handle_struct *handle,
880 BOOL small_query, SMB_BIG_UINT *bsize,
881 SMB_BIG_UINT *dfree, SMB_BIG_UINT *dsize)
885 result = SMB_VFS_NEXT_DISK_FREE(handle, path, small_query, bsize,
888 /* Don't have a reasonable notion of failure here */
890 do_log(SMB_VFS_OP_DISK_FREE, True, handle, "%s", path);
895 static int smb_full_audit_get_quota(struct vfs_handle_struct *handle,
896 enum SMB_QUOTA_TYPE qtype, unid_t id,
901 result = SMB_VFS_NEXT_GET_QUOTA(handle, qtype, id, qt);
903 do_log(SMB_VFS_OP_GET_QUOTA, (result >= 0), handle, "");
909 static int smb_full_audit_set_quota(struct vfs_handle_struct *handle,
910 enum SMB_QUOTA_TYPE qtype, unid_t id,
915 result = SMB_VFS_NEXT_SET_QUOTA(handle, qtype, id, qt);
917 do_log(SMB_VFS_OP_SET_QUOTA, (result >= 0), handle, "");
922 static int smb_full_audit_get_shadow_copy_data(struct vfs_handle_struct *handle,
923 struct files_struct *fsp,
924 SHADOW_COPY_DATA *shadow_copy_data, BOOL labels)
928 result = SMB_VFS_NEXT_GET_SHADOW_COPY_DATA(handle, fsp, shadow_copy_data, labels);
930 do_log(SMB_VFS_OP_GET_SHADOW_COPY_DATA, (result >= 0), handle, "");
935 static int smb_full_audit_statvfs(struct vfs_handle_struct *handle,
937 struct vfs_statvfs_struct *statbuf)
941 result = SMB_VFS_NEXT_STATVFS(handle, path, statbuf);
943 do_log(SMB_VFS_OP_STATVFS, (result >= 0), handle, "");
948 static SMB_STRUCT_DIR *smb_full_audit_opendir(vfs_handle_struct *handle,
949 const char *fname, const char *mask, uint32 attr)
951 SMB_STRUCT_DIR *result;
953 result = SMB_VFS_NEXT_OPENDIR(handle, fname, mask, attr);
955 do_log(SMB_VFS_OP_OPENDIR, (result != NULL), handle, "%s", fname);
960 static SMB_STRUCT_DIRENT *smb_full_audit_readdir(vfs_handle_struct *handle,
961 SMB_STRUCT_DIR *dirp)
963 SMB_STRUCT_DIRENT *result;
965 result = SMB_VFS_NEXT_READDIR(handle, dirp);
967 /* This operation has no reasonable error condition
968 * (End of dir is also failure), so always succeed.
970 do_log(SMB_VFS_OP_READDIR, True, handle, "");
975 static void smb_full_audit_seekdir(vfs_handle_struct *handle,
976 SMB_STRUCT_DIR *dirp, long offset)
978 SMB_VFS_NEXT_SEEKDIR(handle, dirp, offset);
980 do_log(SMB_VFS_OP_SEEKDIR, True, handle, "");
984 static long smb_full_audit_telldir(vfs_handle_struct *handle,
985 SMB_STRUCT_DIR *dirp)
989 result = SMB_VFS_NEXT_TELLDIR(handle, dirp);
991 do_log(SMB_VFS_OP_TELLDIR, True, handle, "");
996 static void smb_full_audit_rewinddir(vfs_handle_struct *handle,
997 SMB_STRUCT_DIR *dirp)
999 SMB_VFS_NEXT_REWINDDIR(handle, dirp);
1001 do_log(SMB_VFS_OP_REWINDDIR, True, handle, "");
1005 static int smb_full_audit_mkdir(vfs_handle_struct *handle,
1006 const char *path, mode_t mode)
1010 result = SMB_VFS_NEXT_MKDIR(handle, path, mode);
1012 do_log(SMB_VFS_OP_MKDIR, (result >= 0), handle, "%s", path);
1017 static int smb_full_audit_rmdir(vfs_handle_struct *handle,
1022 result = SMB_VFS_NEXT_RMDIR(handle, path);
1024 do_log(SMB_VFS_OP_RMDIR, (result >= 0), handle, "%s", path);
1029 static int smb_full_audit_closedir(vfs_handle_struct *handle,
1030 SMB_STRUCT_DIR *dirp)
1034 result = SMB_VFS_NEXT_CLOSEDIR(handle, dirp);
1036 do_log(SMB_VFS_OP_CLOSEDIR, (result >= 0), handle, "");
1041 static int smb_full_audit_open(vfs_handle_struct *handle,
1042 const char *fname, files_struct *fsp, int flags, mode_t mode)
1046 result = SMB_VFS_NEXT_OPEN(handle, fname, fsp, flags, mode);
1048 do_log(SMB_VFS_OP_OPEN, (result >= 0), handle, "%s|%s",
1049 ((flags & O_WRONLY) || (flags & O_RDWR))?"w":"r",
1055 static int smb_full_audit_close(vfs_handle_struct *handle, files_struct *fsp, int fd)
1059 result = SMB_VFS_NEXT_CLOSE(handle, fsp, fd);
1061 do_log(SMB_VFS_OP_CLOSE, (result >= 0), handle, "%s", fsp->fsp_name);
1066 static ssize_t smb_full_audit_read(vfs_handle_struct *handle, files_struct *fsp,
1067 int fd, void *data, size_t n)
1071 result = SMB_VFS_NEXT_READ(handle, fsp, fd, data, n);
1073 do_log(SMB_VFS_OP_READ, (result >= 0), handle, "%s", fsp->fsp_name);
1078 static ssize_t smb_full_audit_pread(vfs_handle_struct *handle, files_struct *fsp,
1079 int fd, void *data, size_t n, SMB_OFF_T offset)
1083 result = SMB_VFS_NEXT_PREAD(handle, fsp, fd, data, n, offset);
1085 do_log(SMB_VFS_OP_PREAD, (result >= 0), handle, "%s", fsp->fsp_name);
1090 static ssize_t smb_full_audit_write(vfs_handle_struct *handle, files_struct *fsp,
1091 int fd, const void *data, size_t n)
1095 result = SMB_VFS_NEXT_WRITE(handle, fsp, fd, data, n);
1097 do_log(SMB_VFS_OP_WRITE, (result >= 0), handle, "%s", fsp->fsp_name);
1102 static ssize_t smb_full_audit_pwrite(vfs_handle_struct *handle, files_struct *fsp,
1103 int fd, const void *data, size_t n,
1108 result = SMB_VFS_NEXT_PWRITE(handle, fsp, fd, data, n, offset);
1110 do_log(SMB_VFS_OP_PWRITE, (result >= 0), handle, "%s", fsp->fsp_name);
1115 static SMB_OFF_T smb_full_audit_lseek(vfs_handle_struct *handle, files_struct *fsp,
1116 int filedes, SMB_OFF_T offset, int whence)
1120 result = SMB_VFS_NEXT_LSEEK(handle, fsp, filedes, offset, whence);
1122 do_log(SMB_VFS_OP_LSEEK, (result != (ssize_t)-1), handle,
1123 "%s", fsp->fsp_name);
1128 static ssize_t smb_full_audit_sendfile(vfs_handle_struct *handle, int tofd,
1129 files_struct *fsp, int fromfd,
1130 const DATA_BLOB *hdr, SMB_OFF_T offset,
1135 result = SMB_VFS_NEXT_SENDFILE(handle, tofd, fsp, fromfd, hdr,
1138 do_log(SMB_VFS_OP_SENDFILE, (result >= 0), handle,
1139 "%s", fsp->fsp_name);
1144 static int smb_full_audit_rename(vfs_handle_struct *handle,
1145 const char *oldname, const char *newname)
1149 result = SMB_VFS_NEXT_RENAME(handle, oldname, newname);
1151 do_log(SMB_VFS_OP_RENAME, (result >= 0), handle, "%s|%s", oldname, newname);
1156 static int smb_full_audit_fsync(vfs_handle_struct *handle, files_struct *fsp, int fd)
1160 result = SMB_VFS_NEXT_FSYNC(handle, fsp, fd);
1162 do_log(SMB_VFS_OP_FSYNC, (result >= 0), handle, "%s", fsp->fsp_name);
1167 static int smb_full_audit_stat(vfs_handle_struct *handle,
1168 const char *fname, SMB_STRUCT_STAT *sbuf)
1172 result = SMB_VFS_NEXT_STAT(handle, fname, sbuf);
1174 do_log(SMB_VFS_OP_STAT, (result >= 0), handle, "%s", fname);
1179 static int smb_full_audit_fstat(vfs_handle_struct *handle, files_struct *fsp, int fd,
1180 SMB_STRUCT_STAT *sbuf)
1184 result = SMB_VFS_NEXT_FSTAT(handle, fsp, fd, sbuf);
1186 do_log(SMB_VFS_OP_FSTAT, (result >= 0), handle, "%s", fsp->fsp_name);
1191 static int smb_full_audit_lstat(vfs_handle_struct *handle,
1192 const char *path, SMB_STRUCT_STAT *sbuf)
1196 result = SMB_VFS_NEXT_LSTAT(handle, path, sbuf);
1198 do_log(SMB_VFS_OP_LSTAT, (result >= 0), handle, "%s", path);
1203 static int smb_full_audit_unlink(vfs_handle_struct *handle,
1208 result = SMB_VFS_NEXT_UNLINK(handle, path);
1210 do_log(SMB_VFS_OP_UNLINK, (result >= 0), handle, "%s", path);
1215 static int smb_full_audit_chmod(vfs_handle_struct *handle,
1216 const char *path, mode_t mode)
1220 result = SMB_VFS_NEXT_CHMOD(handle, path, mode);
1222 do_log(SMB_VFS_OP_CHMOD, (result >= 0), handle, "%s|%o", path, mode);
1227 static int smb_full_audit_fchmod(vfs_handle_struct *handle, files_struct *fsp, int fd,
1232 result = SMB_VFS_NEXT_FCHMOD(handle, fsp, fd, mode);
1234 do_log(SMB_VFS_OP_FCHMOD, (result >= 0), handle,
1235 "%s|%o", fsp->fsp_name, mode);
1240 static int smb_full_audit_chown(vfs_handle_struct *handle,
1241 const char *path, uid_t uid, gid_t gid)
1245 result = SMB_VFS_NEXT_CHOWN(handle, path, uid, gid);
1247 do_log(SMB_VFS_OP_CHOWN, (result >= 0), handle, "%s|%ld|%ld",
1248 path, (long int)uid, (long int)gid);
1253 static int smb_full_audit_fchown(vfs_handle_struct *handle, files_struct *fsp, int fd,
1254 uid_t uid, gid_t gid)
1258 result = SMB_VFS_NEXT_FCHOWN(handle, fsp, fd, uid, gid);
1260 do_log(SMB_VFS_OP_FCHOWN, (result >= 0), handle, "%s|%ld|%ld",
1261 fsp->fsp_name, (long int)uid, (long int)gid);
1266 static int smb_full_audit_lchown(vfs_handle_struct *handle,
1267 const char *path, uid_t uid, gid_t gid)
1271 result = SMB_VFS_NEXT_LCHOWN(handle, path, uid, gid);
1273 do_log(SMB_VFS_OP_LCHOWN, (result >= 0), handle, "%s|%ld|%ld",
1274 path, (long int)uid, (long int)gid);
1279 static int smb_full_audit_chdir(vfs_handle_struct *handle,
1284 result = SMB_VFS_NEXT_CHDIR(handle, path);
1286 do_log(SMB_VFS_OP_CHDIR, (result >= 0), handle, "chdir|%s", path);
1291 static char *smb_full_audit_getwd(vfs_handle_struct *handle,
1296 result = SMB_VFS_NEXT_GETWD(handle, path);
1298 do_log(SMB_VFS_OP_GETWD, (result != NULL), handle, "%s", path);
1303 static int smb_full_audit_ntimes(vfs_handle_struct *handle,
1304 const char *path, const struct timespec ts[2])
1308 result = SMB_VFS_NEXT_NTIMES(handle, path, ts);
1310 do_log(SMB_VFS_OP_NTIMES, (result >= 0), handle, "%s", path);
1315 static int smb_full_audit_ftruncate(vfs_handle_struct *handle, files_struct *fsp,
1316 int fd, SMB_OFF_T len)
1320 result = SMB_VFS_NEXT_FTRUNCATE(handle, fsp, fd, len);
1322 do_log(SMB_VFS_OP_FTRUNCATE, (result >= 0), handle,
1323 "%s", fsp->fsp_name);
1328 static BOOL smb_full_audit_lock(vfs_handle_struct *handle, files_struct *fsp, int fd,
1329 int op, SMB_OFF_T offset, SMB_OFF_T count, int type)
1333 result = SMB_VFS_NEXT_LOCK(handle, fsp, fd, op, offset, count, type);
1335 do_log(SMB_VFS_OP_LOCK, (result >= 0), handle, "%s", fsp->fsp_name);
1340 static int smb_full_audit_kernel_flock(struct vfs_handle_struct *handle,
1341 struct files_struct *fsp, int fd,
1346 result = SMB_VFS_NEXT_KERNEL_FLOCK(handle, fsp, fd, share_mode);
1348 do_log(SMB_VFS_OP_KERNEL_FLOCK, (result >= 0), handle, "%s",
1354 static int smb_full_audit_linux_setlease(vfs_handle_struct *handle, files_struct *fsp,
1355 int fd, int leasetype)
1359 result = SMB_VFS_NEXT_LINUX_SETLEASE(handle, fsp, fd, leasetype);
1361 do_log(SMB_VFS_OP_LINUX_SETLEASE, (result >= 0), handle, "%s",
1367 static BOOL smb_full_audit_getlock(vfs_handle_struct *handle, files_struct *fsp, int fd,
1368 SMB_OFF_T *poffset, SMB_OFF_T *pcount, int *ptype, pid_t *ppid)
1372 result = SMB_VFS_NEXT_GETLOCK(handle, fsp, fd, poffset, pcount, ptype, ppid);
1374 do_log(SMB_VFS_OP_GETLOCK, (result >= 0), handle, "%s", fsp->fsp_name);
1379 static int smb_full_audit_symlink(vfs_handle_struct *handle,
1380 const char *oldpath, const char *newpath)
1384 result = SMB_VFS_NEXT_SYMLINK(handle, oldpath, newpath);
1386 do_log(SMB_VFS_OP_SYMLINK, (result >= 0), handle,
1387 "%s|%s", oldpath, newpath);
1392 static int smb_full_audit_readlink(vfs_handle_struct *handle,
1393 const char *path, char *buf, size_t bufsiz)
1397 result = SMB_VFS_NEXT_READLINK(handle, path, buf, bufsiz);
1399 do_log(SMB_VFS_OP_READLINK, (result >= 0), handle, "%s", path);
1404 static int smb_full_audit_link(vfs_handle_struct *handle,
1405 const char *oldpath, const char *newpath)
1409 result = SMB_VFS_NEXT_LINK(handle, oldpath, newpath);
1411 do_log(SMB_VFS_OP_LINK, (result >= 0), handle,
1412 "%s|%s", oldpath, newpath);
1417 static int smb_full_audit_mknod(vfs_handle_struct *handle,
1418 const char *pathname, mode_t mode, SMB_DEV_T dev)
1422 result = SMB_VFS_NEXT_MKNOD(handle, pathname, mode, dev);
1424 do_log(SMB_VFS_OP_MKNOD, (result >= 0), handle, "%s", pathname);
1429 static char *smb_full_audit_realpath(vfs_handle_struct *handle,
1430 const char *path, char *resolved_path)
1434 result = SMB_VFS_NEXT_REALPATH(handle, path, resolved_path);
1436 do_log(SMB_VFS_OP_REALPATH, (result != NULL), handle, "%s", path);
1441 static NTSTATUS smb_full_audit_notify_watch(struct vfs_handle_struct *handle,
1442 struct sys_notify_context *ctx,
1443 struct notify_entry *e,
1444 void (*callback)(struct sys_notify_context *ctx,
1446 struct notify_event *ev),
1447 void *private_data, void *handle_p)
1451 result = SMB_VFS_NEXT_NOTIFY_WATCH(handle, ctx, e, callback, private_data, handle_p);
1453 do_log(SMB_VFS_OP_NOTIFY_WATCH, NT_STATUS_IS_OK(result), handle, "");
1458 static int smb_full_audit_chflags(vfs_handle_struct *handle,
1459 const char *path, uint flags)
1463 result = SMB_VFS_NEXT_CHFLAGS(handle, path, flags);
1465 do_log(SMB_VFS_OP_CHFLAGS, (result != 0), handle, "%s", path);
1470 static size_t smb_full_audit_fget_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
1471 int fd, uint32 security_info,
1476 result = SMB_VFS_NEXT_FGET_NT_ACL(handle, fsp, fd, security_info,
1479 do_log(SMB_VFS_OP_FGET_NT_ACL, (result > 0), handle,
1480 "%s", fsp->fsp_name);
1485 static size_t smb_full_audit_get_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
1486 const char *name, uint32 security_info,
1491 result = SMB_VFS_NEXT_GET_NT_ACL(handle, fsp, name, security_info,
1494 do_log(SMB_VFS_OP_GET_NT_ACL, (result > 0), handle,
1495 "%s", fsp->fsp_name);
1500 static NTSTATUS smb_full_audit_fset_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
1501 int fd, uint32 security_info_sent,
1506 result = SMB_VFS_NEXT_FSET_NT_ACL(handle, fsp, fd, security_info_sent,
1509 do_log(SMB_VFS_OP_FSET_NT_ACL, NT_STATUS_IS_OK(result), handle, "%s", fsp->fsp_name);
1514 static NTSTATUS smb_full_audit_set_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
1515 const char *name, uint32 security_info_sent,
1520 result = SMB_VFS_NEXT_SET_NT_ACL(handle, fsp, name, security_info_sent,
1523 do_log(SMB_VFS_OP_SET_NT_ACL, NT_STATUS_IS_OK(result), handle, "%s", fsp->fsp_name);
1528 static int smb_full_audit_chmod_acl(vfs_handle_struct *handle,
1529 const char *path, mode_t mode)
1533 result = SMB_VFS_NEXT_CHMOD_ACL(handle, path, mode);
1535 do_log(SMB_VFS_OP_CHMOD_ACL, (result >= 0), handle,
1536 "%s|%o", path, mode);
1541 static int smb_full_audit_fchmod_acl(vfs_handle_struct *handle, files_struct *fsp,
1542 int fd, mode_t mode)
1546 result = SMB_VFS_NEXT_FCHMOD_ACL(handle, fsp, fd, mode);
1548 do_log(SMB_VFS_OP_FCHMOD_ACL, (result >= 0), handle,
1549 "%s|%o", fsp->fsp_name, mode);
1554 static int smb_full_audit_sys_acl_get_entry(vfs_handle_struct *handle,
1556 SMB_ACL_T theacl, int entry_id,
1557 SMB_ACL_ENTRY_T *entry_p)
1561 result = SMB_VFS_NEXT_SYS_ACL_GET_ENTRY(handle, theacl, entry_id,
1564 do_log(SMB_VFS_OP_SYS_ACL_GET_ENTRY, (result >= 0), handle,
1570 static int smb_full_audit_sys_acl_get_tag_type(vfs_handle_struct *handle,
1572 SMB_ACL_ENTRY_T entry_d,
1573 SMB_ACL_TAG_T *tag_type_p)
1577 result = SMB_VFS_NEXT_SYS_ACL_GET_TAG_TYPE(handle, entry_d,
1580 do_log(SMB_VFS_OP_SYS_ACL_GET_TAG_TYPE, (result >= 0), handle,
1586 static int smb_full_audit_sys_acl_get_permset(vfs_handle_struct *handle,
1588 SMB_ACL_ENTRY_T entry_d,
1589 SMB_ACL_PERMSET_T *permset_p)
1593 result = SMB_VFS_NEXT_SYS_ACL_GET_PERMSET(handle, entry_d,
1596 do_log(SMB_VFS_OP_SYS_ACL_GET_PERMSET, (result >= 0), handle,
1602 static void * smb_full_audit_sys_acl_get_qualifier(vfs_handle_struct *handle,
1604 SMB_ACL_ENTRY_T entry_d)
1608 result = SMB_VFS_NEXT_SYS_ACL_GET_QUALIFIER(handle, entry_d);
1610 do_log(SMB_VFS_OP_SYS_ACL_GET_QUALIFIER, (result != NULL), handle,
1616 static SMB_ACL_T smb_full_audit_sys_acl_get_file(vfs_handle_struct *handle,
1618 SMB_ACL_TYPE_T type)
1622 result = SMB_VFS_NEXT_SYS_ACL_GET_FILE(handle, path_p, type);
1624 do_log(SMB_VFS_OP_SYS_ACL_GET_FILE, (result != NULL), handle,
1630 static SMB_ACL_T smb_full_audit_sys_acl_get_fd(vfs_handle_struct *handle,
1631 files_struct *fsp, int fd)
1635 result = SMB_VFS_NEXT_SYS_ACL_GET_FD(handle, fsp, fd);
1637 do_log(SMB_VFS_OP_SYS_ACL_GET_FD, (result != NULL), handle,
1638 "%s", fsp->fsp_name);
1643 static int smb_full_audit_sys_acl_clear_perms(vfs_handle_struct *handle,
1645 SMB_ACL_PERMSET_T permset)
1649 result = SMB_VFS_NEXT_SYS_ACL_CLEAR_PERMS(handle, permset);
1651 do_log(SMB_VFS_OP_SYS_ACL_CLEAR_PERMS, (result >= 0), handle,
1657 static int smb_full_audit_sys_acl_add_perm(vfs_handle_struct *handle,
1659 SMB_ACL_PERMSET_T permset,
1660 SMB_ACL_PERM_T perm)
1664 result = SMB_VFS_NEXT_SYS_ACL_ADD_PERM(handle, permset, perm);
1666 do_log(SMB_VFS_OP_SYS_ACL_ADD_PERM, (result >= 0), handle,
1672 static char * smb_full_audit_sys_acl_to_text(vfs_handle_struct *handle,
1678 result = SMB_VFS_NEXT_SYS_ACL_TO_TEXT(handle, theacl, plen);
1680 do_log(SMB_VFS_OP_SYS_ACL_TO_TEXT, (result != NULL), handle,
1686 static SMB_ACL_T smb_full_audit_sys_acl_init(vfs_handle_struct *handle,
1692 result = SMB_VFS_NEXT_SYS_ACL_INIT(handle, count);
1694 do_log(SMB_VFS_OP_SYS_ACL_INIT, (result != NULL), handle,
1700 static int smb_full_audit_sys_acl_create_entry(vfs_handle_struct *handle,
1702 SMB_ACL_ENTRY_T *pentry)
1706 result = SMB_VFS_NEXT_SYS_ACL_CREATE_ENTRY(handle, pacl, pentry);
1708 do_log(SMB_VFS_OP_SYS_ACL_CREATE_ENTRY, (result >= 0), handle,
1714 static int smb_full_audit_sys_acl_set_tag_type(vfs_handle_struct *handle,
1716 SMB_ACL_ENTRY_T entry,
1717 SMB_ACL_TAG_T tagtype)
1721 result = SMB_VFS_NEXT_SYS_ACL_SET_TAG_TYPE(handle, entry,
1724 do_log(SMB_VFS_OP_SYS_ACL_SET_TAG_TYPE, (result >= 0), handle,
1730 static int smb_full_audit_sys_acl_set_qualifier(vfs_handle_struct *handle,
1732 SMB_ACL_ENTRY_T entry,
1737 result = SMB_VFS_NEXT_SYS_ACL_SET_QUALIFIER(handle, entry, qual);
1739 do_log(SMB_VFS_OP_SYS_ACL_SET_QUALIFIER, (result >= 0), handle,
1745 static int smb_full_audit_sys_acl_set_permset(vfs_handle_struct *handle,
1747 SMB_ACL_ENTRY_T entry,
1748 SMB_ACL_PERMSET_T permset)
1752 result = SMB_VFS_NEXT_SYS_ACL_SET_PERMSET(handle, entry, permset);
1754 do_log(SMB_VFS_OP_SYS_ACL_SET_PERMSET, (result >= 0), handle,
1760 static int smb_full_audit_sys_acl_valid(vfs_handle_struct *handle,
1766 result = SMB_VFS_NEXT_SYS_ACL_VALID(handle, theacl);
1768 do_log(SMB_VFS_OP_SYS_ACL_VALID, (result >= 0), handle,
1774 static int smb_full_audit_sys_acl_set_file(vfs_handle_struct *handle,
1776 const char *name, SMB_ACL_TYPE_T acltype,
1781 result = SMB_VFS_NEXT_SYS_ACL_SET_FILE(handle, name, acltype,
1784 do_log(SMB_VFS_OP_SYS_ACL_SET_FILE, (result >= 0), handle,
1790 static int smb_full_audit_sys_acl_set_fd(vfs_handle_struct *handle, files_struct *fsp,
1791 int fd, SMB_ACL_T theacl)
1795 result = SMB_VFS_NEXT_SYS_ACL_SET_FD(handle, fsp, fd, theacl);
1797 do_log(SMB_VFS_OP_SYS_ACL_SET_FD, (result >= 0), handle,
1798 "%s", fsp->fsp_name);
1803 static int smb_full_audit_sys_acl_delete_def_file(vfs_handle_struct *handle,
1809 result = SMB_VFS_NEXT_SYS_ACL_DELETE_DEF_FILE(handle, path);
1811 do_log(SMB_VFS_OP_SYS_ACL_DELETE_DEF_FILE, (result >= 0), handle,
1817 static int smb_full_audit_sys_acl_get_perm(vfs_handle_struct *handle,
1819 SMB_ACL_PERMSET_T permset,
1820 SMB_ACL_PERM_T perm)
1824 result = SMB_VFS_NEXT_SYS_ACL_GET_PERM(handle, permset, perm);
1826 do_log(SMB_VFS_OP_SYS_ACL_GET_PERM, (result >= 0), handle,
1832 static int smb_full_audit_sys_acl_free_text(vfs_handle_struct *handle,
1838 result = SMB_VFS_NEXT_SYS_ACL_FREE_TEXT(handle, text);
1840 do_log(SMB_VFS_OP_SYS_ACL_FREE_TEXT, (result >= 0), handle,
1846 static int smb_full_audit_sys_acl_free_acl(vfs_handle_struct *handle,
1848 SMB_ACL_T posix_acl)
1852 result = SMB_VFS_NEXT_SYS_ACL_FREE_ACL(handle, posix_acl);
1854 do_log(SMB_VFS_OP_SYS_ACL_FREE_ACL, (result >= 0), handle,
1860 static int smb_full_audit_sys_acl_free_qualifier(vfs_handle_struct *handle,
1862 SMB_ACL_TAG_T tagtype)
1866 result = SMB_VFS_NEXT_SYS_ACL_FREE_QUALIFIER(handle, qualifier,
1869 do_log(SMB_VFS_OP_SYS_ACL_FREE_QUALIFIER, (result >= 0), handle,
1875 static ssize_t smb_full_audit_getxattr(struct vfs_handle_struct *handle,
1877 const char *name, void *value, size_t size)
1881 result = SMB_VFS_NEXT_GETXATTR(handle, path, name, value, size);
1883 do_log(SMB_VFS_OP_GETXATTR, (result >= 0), handle,
1884 "%s|%s", path, name);
1889 static ssize_t smb_full_audit_lgetxattr(struct vfs_handle_struct *handle,
1890 const char *path, const char *name,
1891 void *value, size_t size)
1895 result = SMB_VFS_NEXT_LGETXATTR(handle, path, name, value, size);
1897 do_log(SMB_VFS_OP_LGETXATTR, (result >= 0), handle,
1898 "%s|%s", path, name);
1903 static ssize_t smb_full_audit_fgetxattr(struct vfs_handle_struct *handle,
1904 struct files_struct *fsp, int fd,
1905 const char *name, void *value, size_t size)
1909 result = SMB_VFS_NEXT_FGETXATTR(handle, fsp, fd, name, value, size);
1911 do_log(SMB_VFS_OP_FGETXATTR, (result >= 0), handle,
1912 "%s|%s", fsp->fsp_name, name);
1917 static ssize_t smb_full_audit_listxattr(struct vfs_handle_struct *handle,
1918 const char *path, char *list, size_t size)
1922 result = SMB_VFS_NEXT_LISTXATTR(handle, path, list, size);
1924 do_log(SMB_VFS_OP_LISTXATTR, (result >= 0), handle, "%s", path);
1929 static ssize_t smb_full_audit_llistxattr(struct vfs_handle_struct *handle,
1930 const char *path, char *list, size_t size)
1934 result = SMB_VFS_NEXT_LLISTXATTR(handle, path, list, size);
1936 do_log(SMB_VFS_OP_LLISTXATTR, (result >= 0), handle, "%s", path);
1941 static ssize_t smb_full_audit_flistxattr(struct vfs_handle_struct *handle,
1942 struct files_struct *fsp, int fd, char *list,
1947 result = SMB_VFS_NEXT_FLISTXATTR(handle, fsp, fd, list, size);
1949 do_log(SMB_VFS_OP_FLISTXATTR, (result >= 0), handle,
1950 "%s", fsp->fsp_name);
1955 static int smb_full_audit_removexattr(struct vfs_handle_struct *handle,
1961 result = SMB_VFS_NEXT_REMOVEXATTR(handle, path, name);
1963 do_log(SMB_VFS_OP_REMOVEXATTR, (result >= 0), handle,
1964 "%s|%s", path, name);
1969 static int smb_full_audit_lremovexattr(struct vfs_handle_struct *handle,
1975 result = SMB_VFS_NEXT_LREMOVEXATTR(handle, path, name);
1977 do_log(SMB_VFS_OP_LREMOVEXATTR, (result >= 0), handle,
1978 "%s|%s", path, name);
1983 static int smb_full_audit_fremovexattr(struct vfs_handle_struct *handle,
1984 struct files_struct *fsp, int fd,
1989 result = SMB_VFS_NEXT_FREMOVEXATTR(handle, fsp, fd, name);
1991 do_log(SMB_VFS_OP_FREMOVEXATTR, (result >= 0), handle,
1992 "%s|%s", fsp->fsp_name, name);
1997 static int smb_full_audit_setxattr(struct vfs_handle_struct *handle,
1999 const char *name, const void *value, size_t size,
2004 result = SMB_VFS_NEXT_SETXATTR(handle, path, name, value, size,
2007 do_log(SMB_VFS_OP_SETXATTR, (result >= 0), handle,
2008 "%s|%s", path, name);
2013 static int smb_full_audit_lsetxattr(struct vfs_handle_struct *handle,
2015 const char *name, const void *value, size_t size,
2020 result = SMB_VFS_NEXT_LSETXATTR(handle, path, name, value, size,
2023 do_log(SMB_VFS_OP_LSETXATTR, (result >= 0), handle,
2024 "%s|%s", path, name);
2029 static int smb_full_audit_fsetxattr(struct vfs_handle_struct *handle,
2030 struct files_struct *fsp, int fd, const char *name,
2031 const void *value, size_t size, int flags)
2035 result = SMB_VFS_NEXT_FSETXATTR(handle, fsp, fd, name, value, size,
2038 do_log(SMB_VFS_OP_FSETXATTR, (result >= 0), handle,
2039 "%s|%s", fsp->fsp_name, name);
2044 static int smb_full_audit_aio_read(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb)
2048 result = SMB_VFS_NEXT_AIO_READ(handle, fsp, aiocb);
2049 do_log(SMB_VFS_OP_AIO_READ, (result >= 0), handle,
2050 "%s", fsp->fsp_name);
2055 static int smb_full_audit_aio_write(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb)
2059 result = SMB_VFS_NEXT_AIO_WRITE(handle, fsp, aiocb);
2060 do_log(SMB_VFS_OP_AIO_WRITE, (result >= 0), handle,
2061 "%s", fsp->fsp_name);
2066 static ssize_t smb_full_audit_aio_return(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb)
2070 result = SMB_VFS_NEXT_AIO_RETURN(handle, fsp, aiocb);
2071 do_log(SMB_VFS_OP_AIO_RETURN, (result >= 0), handle,
2072 "%s", fsp->fsp_name);
2077 static int smb_full_audit_aio_cancel(struct vfs_handle_struct *handle, struct files_struct *fsp, int fd, SMB_STRUCT_AIOCB *aiocb)
2081 result = SMB_VFS_NEXT_AIO_CANCEL(handle, fsp, fd, aiocb);
2082 do_log(SMB_VFS_OP_AIO_CANCEL, (result >= 0), handle,
2083 "%s", fsp->fsp_name);
2088 static int smb_full_audit_aio_error(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb)
2092 result = SMB_VFS_NEXT_AIO_ERROR(handle, fsp, aiocb);
2093 do_log(SMB_VFS_OP_AIO_ERROR, (result >= 0), handle,
2094 "%s", fsp->fsp_name);
2099 static int smb_full_audit_aio_fsync(struct vfs_handle_struct *handle, struct files_struct *fsp, int op, SMB_STRUCT_AIOCB *aiocb)
2103 result = SMB_VFS_NEXT_AIO_FSYNC(handle, fsp, op, aiocb);
2104 do_log(SMB_VFS_OP_AIO_FSYNC, (result >= 0), handle,
2105 "%s", fsp->fsp_name);
2110 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)
2114 result = SMB_VFS_NEXT_AIO_SUSPEND(handle, fsp, aiocb, n, ts);
2115 do_log(SMB_VFS_OP_AIO_SUSPEND, (result >= 0), handle,
2116 "%s", fsp->fsp_name);
2122 NTSTATUS vfs_full_audit_init(void);
2123 NTSTATUS vfs_full_audit_init(void)
2125 NTSTATUS ret = smb_register_vfs(SMB_VFS_INTERFACE_VERSION,
2126 "full_audit", audit_op_tuples);
2128 if (!NT_STATUS_IS_OK(ret))
2131 vfs_full_audit_debug_level = debug_add_class("full_audit");
2132 if (vfs_full_audit_debug_level == -1) {
2133 vfs_full_audit_debug_level = DBGC_VFS;
2134 DEBUG(0, ("vfs_full_audit: Couldn't register custom debugging "
2137 DEBUG(10, ("vfs_full_audit: Debug class number of "
2138 "'full_audit': %d\n", vfs_full_audit_debug_level));