2 * Auditing VFS module for samba. Log selected file operations to syslog
5 * Copyright (C) Tim Potter, 1999-2000
6 * Copyright (C) Alexander Bokovoy, 2002
7 * Copyright (C) John H Terpstra, 2003
8 * Copyright (C) Stefan (metze) Metzmacher, 2003
9 * Copyright (C) Volker Lendecke, 2004
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 3 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, see <http://www.gnu.org/licenses/>.
26 * This module implements parseable logging for all Samba VFS operations.
28 * You use it as follows:
32 * vfs objects = full_audit
33 * full_audit:prefix = %u|%I
34 * full_audit:success = open opendir
35 * full_audit:failure = all
37 * vfs op can be "all" which means log all operations.
38 * vfs op can be "none" which means no logging.
40 * This leads to syslog entries of the form:
41 * smbd_audit: nobody|192.168.234.1|opendir|ok|.
42 * smbd_audit: nobody|192.168.234.1|open|fail (File not found)|r|x.txt
44 * where "nobody" is the connected username and "192.168.234.1" is the
45 * client's IP address.
49 * prefix: A macro expansion template prepended to the syslog entry.
51 * success: A list of VFS operations for which a successful completion should
52 * be logged. Defaults to no logging at all. The special operation "all" logs
53 * - you guessed it - everything.
55 * failure: A list of VFS operations for which failure to complete should be
56 * logged. Defaults to logging everything.
62 static int vfs_full_audit_debug_level = DBGC_VFS;
64 struct vfs_full_audit_private_data {
65 struct bitmap *success_ops;
66 struct bitmap *failure_ops;
70 #define DBGC_CLASS vfs_full_audit_debug_level
72 /* Function prototypes */
74 static int smb_full_audit_connect(vfs_handle_struct *handle,
75 const char *svc, const char *user);
76 static void smb_full_audit_disconnect(vfs_handle_struct *handle);
77 static uint64_t smb_full_audit_disk_free(vfs_handle_struct *handle,
79 bool small_query, uint64_t *bsize,
80 uint64_t *dfree, uint64_t *dsize);
81 static int smb_full_audit_get_quota(struct vfs_handle_struct *handle,
82 enum SMB_QUOTA_TYPE qtype, unid_t id,
84 static int smb_full_audit_set_quota(struct vfs_handle_struct *handle,
85 enum SMB_QUOTA_TYPE qtype, unid_t id,
87 static int smb_full_audit_get_shadow_copy_data(struct vfs_handle_struct *handle,
88 struct files_struct *fsp,
89 SHADOW_COPY_DATA *shadow_copy_data, bool labels);
90 static int smb_full_audit_statvfs(struct vfs_handle_struct *handle,
92 struct vfs_statvfs_struct *statbuf);
94 static SMB_STRUCT_DIR *smb_full_audit_opendir(vfs_handle_struct *handle,
95 const char *fname, const char *mask, uint32 attr);
96 static SMB_STRUCT_DIRENT *smb_full_audit_readdir(vfs_handle_struct *handle,
98 SMB_STRUCT_STAT *sbuf);
99 static void smb_full_audit_seekdir(vfs_handle_struct *handle,
100 SMB_STRUCT_DIR *dirp, long offset);
101 static long smb_full_audit_telldir(vfs_handle_struct *handle,
102 SMB_STRUCT_DIR *dirp);
103 static void smb_full_audit_rewinddir(vfs_handle_struct *handle,
104 SMB_STRUCT_DIR *dirp);
105 static int smb_full_audit_mkdir(vfs_handle_struct *handle,
106 const char *path, mode_t mode);
107 static int smb_full_audit_rmdir(vfs_handle_struct *handle,
109 static int smb_full_audit_closedir(vfs_handle_struct *handle,
110 SMB_STRUCT_DIR *dirp);
111 static void smb_full_audit_init_search_op(vfs_handle_struct *handle,
112 SMB_STRUCT_DIR *dirp);
113 static int smb_full_audit_open(vfs_handle_struct *handle,
114 const char *fname, files_struct *fsp, int flags, mode_t mode);
115 static NTSTATUS smb_full_audit_create_file(vfs_handle_struct *handle,
116 struct smb_request *req,
117 uint16_t root_dir_fid,
119 uint32_t create_file_flags,
120 uint32_t access_mask,
121 uint32_t share_access,
122 uint32_t create_disposition,
123 uint32_t create_options,
124 uint32_t file_attributes,
125 uint32_t oplock_request,
126 uint64_t allocation_size,
127 struct security_descriptor *sd,
128 struct ea_list *ea_list,
129 files_struct **result,
131 SMB_STRUCT_STAT *psbuf);
132 static int smb_full_audit_close(vfs_handle_struct *handle, files_struct *fsp);
133 static ssize_t smb_full_audit_read(vfs_handle_struct *handle, files_struct *fsp,
134 void *data, size_t n);
135 static ssize_t smb_full_audit_pread(vfs_handle_struct *handle, files_struct *fsp,
136 void *data, size_t n, SMB_OFF_T offset);
137 static ssize_t smb_full_audit_write(vfs_handle_struct *handle, files_struct *fsp,
138 const void *data, size_t n);
139 static ssize_t smb_full_audit_pwrite(vfs_handle_struct *handle, files_struct *fsp,
140 const void *data, size_t n,
142 static SMB_OFF_T smb_full_audit_lseek(vfs_handle_struct *handle, files_struct *fsp,
143 SMB_OFF_T offset, int whence);
144 static ssize_t smb_full_audit_sendfile(vfs_handle_struct *handle, int tofd,
145 files_struct *fromfsp,
146 const DATA_BLOB *hdr, SMB_OFF_T offset,
148 static ssize_t smb_full_audit_recvfile(vfs_handle_struct *handle, int fromfd,
152 static int smb_full_audit_rename(vfs_handle_struct *handle,
153 const char *oldname, const char *newname);
154 static int smb_full_audit_fsync(vfs_handle_struct *handle, files_struct *fsp);
155 static int smb_full_audit_stat(vfs_handle_struct *handle,
156 const char *fname, SMB_STRUCT_STAT *sbuf);
157 static int smb_full_audit_fstat(vfs_handle_struct *handle, files_struct *fsp,
158 SMB_STRUCT_STAT *sbuf);
159 static int smb_full_audit_lstat(vfs_handle_struct *handle,
160 const char *path, SMB_STRUCT_STAT *sbuf);
161 static int smb_full_audit_get_alloc_size(vfs_handle_struct *handle,
162 files_struct *fsp, const SMB_STRUCT_STAT *sbuf);
163 static int smb_full_audit_unlink(vfs_handle_struct *handle,
165 static int smb_full_audit_chmod(vfs_handle_struct *handle,
166 const char *path, mode_t mode);
167 static int smb_full_audit_fchmod(vfs_handle_struct *handle, files_struct *fsp,
169 static int smb_full_audit_chown(vfs_handle_struct *handle,
170 const char *path, uid_t uid, gid_t gid);
171 static int smb_full_audit_fchown(vfs_handle_struct *handle, files_struct *fsp,
172 uid_t uid, gid_t gid);
173 static int smb_full_audit_lchown(vfs_handle_struct *handle,
174 const char *path, uid_t uid, gid_t gid);
175 static int smb_full_audit_chdir(vfs_handle_struct *handle,
177 static char *smb_full_audit_getwd(vfs_handle_struct *handle,
179 static int smb_full_audit_ntimes(vfs_handle_struct *handle,
180 const char *path, struct smb_file_time *ft);
181 static int smb_full_audit_ftruncate(vfs_handle_struct *handle, files_struct *fsp,
183 static bool smb_full_audit_lock(vfs_handle_struct *handle, files_struct *fsp,
184 int op, SMB_OFF_T offset, SMB_OFF_T count, int type);
185 static int smb_full_audit_kernel_flock(struct vfs_handle_struct *handle,
186 struct files_struct *fsp,
188 static int smb_full_audit_linux_setlease(vfs_handle_struct *handle, files_struct *fsp,
190 static bool smb_full_audit_getlock(vfs_handle_struct *handle, files_struct *fsp,
191 SMB_OFF_T *poffset, SMB_OFF_T *pcount, int *ptype, pid_t *ppid);
192 static int smb_full_audit_symlink(vfs_handle_struct *handle,
193 const char *oldpath, const char *newpath);
194 static int smb_full_audit_readlink(vfs_handle_struct *handle,
195 const char *path, char *buf, size_t bufsiz);
196 static int smb_full_audit_link(vfs_handle_struct *handle,
197 const char *oldpath, const char *newpath);
198 static int smb_full_audit_mknod(vfs_handle_struct *handle,
199 const char *pathname, mode_t mode, SMB_DEV_T dev);
200 static char *smb_full_audit_realpath(vfs_handle_struct *handle,
201 const char *path, char *resolved_path);
202 static NTSTATUS smb_full_audit_notify_watch(struct vfs_handle_struct *handle,
203 struct sys_notify_context *ctx,
204 struct notify_entry *e,
205 void (*callback)(struct sys_notify_context *ctx,
207 struct notify_event *ev),
208 void *private_data, void *handle_p);
209 static int smb_full_audit_chflags(vfs_handle_struct *handle,
210 const char *path, unsigned int flags);
211 static struct file_id smb_full_audit_file_id_create(struct vfs_handle_struct *handle,
212 SMB_DEV_T dev, SMB_INO_T inode);
213 static NTSTATUS smb_full_audit_streaminfo(vfs_handle_struct *handle,
214 struct files_struct *fsp,
217 unsigned int *pnum_streams,
218 struct stream_struct **pstreams);
219 static int smb_full_audit_get_real_filename(struct vfs_handle_struct *handle,
224 static NTSTATUS smb_full_audit_fget_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
225 uint32 security_info,
227 static NTSTATUS smb_full_audit_get_nt_acl(vfs_handle_struct *handle,
228 const char *name, uint32 security_info,
230 static NTSTATUS smb_full_audit_fset_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
231 uint32 security_info_sent,
232 const SEC_DESC *psd);
233 static int smb_full_audit_chmod_acl(vfs_handle_struct *handle,
234 const char *path, mode_t mode);
235 static int smb_full_audit_fchmod_acl(vfs_handle_struct *handle, files_struct *fsp,
237 static int smb_full_audit_sys_acl_get_entry(vfs_handle_struct *handle,
238 SMB_ACL_T theacl, int entry_id,
239 SMB_ACL_ENTRY_T *entry_p);
240 static int smb_full_audit_sys_acl_get_tag_type(vfs_handle_struct *handle,
241 SMB_ACL_ENTRY_T entry_d,
242 SMB_ACL_TAG_T *tag_type_p);
243 static int smb_full_audit_sys_acl_get_permset(vfs_handle_struct *handle,
244 SMB_ACL_ENTRY_T entry_d,
245 SMB_ACL_PERMSET_T *permset_p);
246 static void * smb_full_audit_sys_acl_get_qualifier(vfs_handle_struct *handle,
247 SMB_ACL_ENTRY_T entry_d);
248 static SMB_ACL_T smb_full_audit_sys_acl_get_file(vfs_handle_struct *handle,
250 SMB_ACL_TYPE_T type);
251 static SMB_ACL_T smb_full_audit_sys_acl_get_fd(vfs_handle_struct *handle,
253 static int smb_full_audit_sys_acl_clear_perms(vfs_handle_struct *handle,
254 SMB_ACL_PERMSET_T permset);
255 static int smb_full_audit_sys_acl_add_perm(vfs_handle_struct *handle,
256 SMB_ACL_PERMSET_T permset,
257 SMB_ACL_PERM_T perm);
258 static char * smb_full_audit_sys_acl_to_text(vfs_handle_struct *handle,
261 static SMB_ACL_T smb_full_audit_sys_acl_init(vfs_handle_struct *handle,
263 static int smb_full_audit_sys_acl_create_entry(vfs_handle_struct *handle,
265 SMB_ACL_ENTRY_T *pentry);
266 static int smb_full_audit_sys_acl_set_tag_type(vfs_handle_struct *handle,
267 SMB_ACL_ENTRY_T entry,
268 SMB_ACL_TAG_T tagtype);
269 static int smb_full_audit_sys_acl_set_qualifier(vfs_handle_struct *handle,
270 SMB_ACL_ENTRY_T entry,
272 static int smb_full_audit_sys_acl_set_permset(vfs_handle_struct *handle,
273 SMB_ACL_ENTRY_T entry,
274 SMB_ACL_PERMSET_T permset);
275 static int smb_full_audit_sys_acl_valid(vfs_handle_struct *handle,
277 static int smb_full_audit_sys_acl_set_file(vfs_handle_struct *handle,
278 const char *name, SMB_ACL_TYPE_T acltype,
280 static int smb_full_audit_sys_acl_set_fd(vfs_handle_struct *handle, files_struct *fsp,
282 static int smb_full_audit_sys_acl_delete_def_file(vfs_handle_struct *handle,
284 static int smb_full_audit_sys_acl_get_perm(vfs_handle_struct *handle,
285 SMB_ACL_PERMSET_T permset,
286 SMB_ACL_PERM_T perm);
287 static int smb_full_audit_sys_acl_free_text(vfs_handle_struct *handle,
289 static int smb_full_audit_sys_acl_free_acl(vfs_handle_struct *handle,
290 SMB_ACL_T posix_acl);
291 static int smb_full_audit_sys_acl_free_qualifier(vfs_handle_struct *handle,
293 SMB_ACL_TAG_T tagtype);
294 static ssize_t smb_full_audit_getxattr(struct vfs_handle_struct *handle,
296 const char *name, void *value, size_t size);
297 static ssize_t smb_full_audit_lgetxattr(struct vfs_handle_struct *handle,
298 const char *path, const char *name,
299 void *value, size_t size);
300 static ssize_t smb_full_audit_fgetxattr(struct vfs_handle_struct *handle,
301 struct files_struct *fsp,
302 const char *name, void *value, size_t size);
303 static ssize_t smb_full_audit_listxattr(struct vfs_handle_struct *handle,
304 const char *path, char *list, size_t size);
305 static ssize_t smb_full_audit_llistxattr(struct vfs_handle_struct *handle,
306 const char *path, char *list, size_t size);
307 static ssize_t smb_full_audit_flistxattr(struct vfs_handle_struct *handle,
308 struct files_struct *fsp, char *list,
310 static int smb_full_audit_removexattr(struct vfs_handle_struct *handle,
313 static int smb_full_audit_lremovexattr(struct vfs_handle_struct *handle,
316 static int smb_full_audit_fremovexattr(struct vfs_handle_struct *handle,
317 struct files_struct *fsp,
319 static int smb_full_audit_setxattr(struct vfs_handle_struct *handle,
321 const char *name, const void *value, size_t size,
323 static int smb_full_audit_lsetxattr(struct vfs_handle_struct *handle,
325 const char *name, const void *value, size_t size,
327 static int smb_full_audit_fsetxattr(struct vfs_handle_struct *handle,
328 struct files_struct *fsp, const char *name,
329 const void *value, size_t size, int flags);
331 static int smb_full_audit_aio_read(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb);
332 static int smb_full_audit_aio_write(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb);
333 static ssize_t smb_full_audit_aio_return(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb);
334 static int smb_full_audit_aio_cancel(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb);
335 static int smb_full_audit_aio_error(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb);
336 static int smb_full_audit_aio_fsync(struct vfs_handle_struct *handle, struct files_struct *fsp, int op, SMB_STRUCT_AIOCB *aiocb);
337 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);
341 static vfs_op_tuple audit_op_tuples[] = {
343 /* Disk operations */
345 {SMB_VFS_OP(smb_full_audit_connect), SMB_VFS_OP_CONNECT,
346 SMB_VFS_LAYER_LOGGER},
347 {SMB_VFS_OP(smb_full_audit_disconnect), SMB_VFS_OP_DISCONNECT,
348 SMB_VFS_LAYER_LOGGER},
349 {SMB_VFS_OP(smb_full_audit_disk_free), SMB_VFS_OP_DISK_FREE,
350 SMB_VFS_LAYER_LOGGER},
351 {SMB_VFS_OP(smb_full_audit_get_quota), SMB_VFS_OP_GET_QUOTA,
352 SMB_VFS_LAYER_LOGGER},
353 {SMB_VFS_OP(smb_full_audit_set_quota), SMB_VFS_OP_SET_QUOTA,
354 SMB_VFS_LAYER_LOGGER},
355 {SMB_VFS_OP(smb_full_audit_get_shadow_copy_data), SMB_VFS_OP_GET_SHADOW_COPY_DATA,
356 SMB_VFS_LAYER_LOGGER},
357 {SMB_VFS_OP(smb_full_audit_statvfs), SMB_VFS_OP_STATVFS,
358 SMB_VFS_LAYER_LOGGER},
360 /* Directory operations */
362 {SMB_VFS_OP(smb_full_audit_opendir), SMB_VFS_OP_OPENDIR,
363 SMB_VFS_LAYER_LOGGER},
364 {SMB_VFS_OP(smb_full_audit_readdir), SMB_VFS_OP_READDIR,
365 SMB_VFS_LAYER_LOGGER},
366 {SMB_VFS_OP(smb_full_audit_seekdir), SMB_VFS_OP_SEEKDIR,
367 SMB_VFS_LAYER_LOGGER},
368 {SMB_VFS_OP(smb_full_audit_telldir), SMB_VFS_OP_TELLDIR,
369 SMB_VFS_LAYER_LOGGER},
370 {SMB_VFS_OP(smb_full_audit_rewinddir), SMB_VFS_OP_REWINDDIR,
371 SMB_VFS_LAYER_LOGGER},
372 {SMB_VFS_OP(smb_full_audit_mkdir), SMB_VFS_OP_MKDIR,
373 SMB_VFS_LAYER_LOGGER},
374 {SMB_VFS_OP(smb_full_audit_rmdir), SMB_VFS_OP_RMDIR,
375 SMB_VFS_LAYER_LOGGER},
376 {SMB_VFS_OP(smb_full_audit_closedir), SMB_VFS_OP_CLOSEDIR,
377 SMB_VFS_LAYER_LOGGER},
378 {SMB_VFS_OP(smb_full_audit_init_search_op), SMB_VFS_OP_INIT_SEARCH_OP,
379 SMB_VFS_LAYER_LOGGER},
381 /* File operations */
383 {SMB_VFS_OP(smb_full_audit_open), SMB_VFS_OP_OPEN,
384 SMB_VFS_LAYER_LOGGER},
385 {SMB_VFS_OP(smb_full_audit_create_file),SMB_VFS_OP_CREATE_FILE,
386 SMB_VFS_LAYER_LOGGER},
387 {SMB_VFS_OP(smb_full_audit_close), SMB_VFS_OP_CLOSE,
388 SMB_VFS_LAYER_LOGGER},
389 {SMB_VFS_OP(smb_full_audit_read), SMB_VFS_OP_READ,
390 SMB_VFS_LAYER_LOGGER},
391 {SMB_VFS_OP(smb_full_audit_pread), SMB_VFS_OP_PREAD,
392 SMB_VFS_LAYER_LOGGER},
393 {SMB_VFS_OP(smb_full_audit_write), SMB_VFS_OP_WRITE,
394 SMB_VFS_LAYER_LOGGER},
395 {SMB_VFS_OP(smb_full_audit_pwrite), SMB_VFS_OP_PWRITE,
396 SMB_VFS_LAYER_LOGGER},
397 {SMB_VFS_OP(smb_full_audit_lseek), SMB_VFS_OP_LSEEK,
398 SMB_VFS_LAYER_LOGGER},
399 {SMB_VFS_OP(smb_full_audit_sendfile), SMB_VFS_OP_SENDFILE,
400 SMB_VFS_LAYER_LOGGER},
401 {SMB_VFS_OP(smb_full_audit_recvfile), SMB_VFS_OP_RECVFILE,
402 SMB_VFS_LAYER_LOGGER},
403 {SMB_VFS_OP(smb_full_audit_rename), SMB_VFS_OP_RENAME,
404 SMB_VFS_LAYER_LOGGER},
405 {SMB_VFS_OP(smb_full_audit_fsync), SMB_VFS_OP_FSYNC,
406 SMB_VFS_LAYER_LOGGER},
407 {SMB_VFS_OP(smb_full_audit_stat), SMB_VFS_OP_STAT,
408 SMB_VFS_LAYER_LOGGER},
409 {SMB_VFS_OP(smb_full_audit_fstat), SMB_VFS_OP_FSTAT,
410 SMB_VFS_LAYER_LOGGER},
411 {SMB_VFS_OP(smb_full_audit_lstat), SMB_VFS_OP_LSTAT,
412 SMB_VFS_LAYER_LOGGER},
413 {SMB_VFS_OP(smb_full_audit_get_alloc_size), SMB_VFS_OP_GET_ALLOC_SIZE,
414 SMB_VFS_LAYER_LOGGER},
415 {SMB_VFS_OP(smb_full_audit_unlink), SMB_VFS_OP_UNLINK,
416 SMB_VFS_LAYER_LOGGER},
417 {SMB_VFS_OP(smb_full_audit_chmod), SMB_VFS_OP_CHMOD,
418 SMB_VFS_LAYER_LOGGER},
419 {SMB_VFS_OP(smb_full_audit_fchmod), SMB_VFS_OP_FCHMOD,
420 SMB_VFS_LAYER_LOGGER},
421 {SMB_VFS_OP(smb_full_audit_chown), SMB_VFS_OP_CHOWN,
422 SMB_VFS_LAYER_LOGGER},
423 {SMB_VFS_OP(smb_full_audit_fchown), SMB_VFS_OP_FCHOWN,
424 SMB_VFS_LAYER_LOGGER},
425 {SMB_VFS_OP(smb_full_audit_lchown), SMB_VFS_OP_LCHOWN,
426 SMB_VFS_LAYER_LOGGER},
427 {SMB_VFS_OP(smb_full_audit_chdir), SMB_VFS_OP_CHDIR,
428 SMB_VFS_LAYER_LOGGER},
429 {SMB_VFS_OP(smb_full_audit_getwd), SMB_VFS_OP_GETWD,
430 SMB_VFS_LAYER_LOGGER},
431 {SMB_VFS_OP(smb_full_audit_ntimes), SMB_VFS_OP_NTIMES,
432 SMB_VFS_LAYER_LOGGER},
433 {SMB_VFS_OP(smb_full_audit_ftruncate), SMB_VFS_OP_FTRUNCATE,
434 SMB_VFS_LAYER_LOGGER},
435 {SMB_VFS_OP(smb_full_audit_lock), SMB_VFS_OP_LOCK,
436 SMB_VFS_LAYER_LOGGER},
437 {SMB_VFS_OP(smb_full_audit_kernel_flock), SMB_VFS_OP_KERNEL_FLOCK,
438 SMB_VFS_LAYER_LOGGER},
439 {SMB_VFS_OP(smb_full_audit_linux_setlease), SMB_VFS_OP_LINUX_SETLEASE,
440 SMB_VFS_LAYER_LOGGER},
441 {SMB_VFS_OP(smb_full_audit_getlock), SMB_VFS_OP_GETLOCK,
442 SMB_VFS_LAYER_LOGGER},
443 {SMB_VFS_OP(smb_full_audit_symlink), SMB_VFS_OP_SYMLINK,
444 SMB_VFS_LAYER_LOGGER},
445 {SMB_VFS_OP(smb_full_audit_readlink), SMB_VFS_OP_READLINK,
446 SMB_VFS_LAYER_LOGGER},
447 {SMB_VFS_OP(smb_full_audit_link), SMB_VFS_OP_LINK,
448 SMB_VFS_LAYER_LOGGER},
449 {SMB_VFS_OP(smb_full_audit_mknod), SMB_VFS_OP_MKNOD,
450 SMB_VFS_LAYER_LOGGER},
451 {SMB_VFS_OP(smb_full_audit_realpath), SMB_VFS_OP_REALPATH,
452 SMB_VFS_LAYER_LOGGER},
453 {SMB_VFS_OP(smb_full_audit_notify_watch),SMB_VFS_OP_NOTIFY_WATCH,
454 SMB_VFS_LAYER_LOGGER},
455 {SMB_VFS_OP(smb_full_audit_chflags), SMB_VFS_OP_CHFLAGS,
456 SMB_VFS_LAYER_LOGGER},
457 {SMB_VFS_OP(smb_full_audit_file_id_create), SMB_VFS_OP_FILE_ID_CREATE,
458 SMB_VFS_LAYER_LOGGER},
459 {SMB_VFS_OP(smb_full_audit_streaminfo), SMB_VFS_OP_STREAMINFO,
460 SMB_VFS_LAYER_LOGGER},
461 {SMB_VFS_OP(smb_full_audit_get_real_filename), SMB_VFS_OP_GET_REAL_FILENAME,
462 SMB_VFS_LAYER_LOGGER},
464 /* NT ACL operations. */
466 {SMB_VFS_OP(smb_full_audit_fget_nt_acl), SMB_VFS_OP_FGET_NT_ACL,
467 SMB_VFS_LAYER_LOGGER},
468 {SMB_VFS_OP(smb_full_audit_get_nt_acl), SMB_VFS_OP_GET_NT_ACL,
469 SMB_VFS_LAYER_LOGGER},
470 {SMB_VFS_OP(smb_full_audit_fset_nt_acl), SMB_VFS_OP_FSET_NT_ACL,
471 SMB_VFS_LAYER_LOGGER},
473 /* POSIX ACL operations. */
475 {SMB_VFS_OP(smb_full_audit_chmod_acl), SMB_VFS_OP_CHMOD_ACL,
476 SMB_VFS_LAYER_LOGGER},
477 {SMB_VFS_OP(smb_full_audit_fchmod_acl), SMB_VFS_OP_FCHMOD_ACL,
478 SMB_VFS_LAYER_LOGGER},
479 {SMB_VFS_OP(smb_full_audit_sys_acl_get_entry), SMB_VFS_OP_SYS_ACL_GET_ENTRY,
480 SMB_VFS_LAYER_LOGGER},
481 {SMB_VFS_OP(smb_full_audit_sys_acl_get_tag_type), SMB_VFS_OP_SYS_ACL_GET_TAG_TYPE,
482 SMB_VFS_LAYER_LOGGER},
483 {SMB_VFS_OP(smb_full_audit_sys_acl_get_permset), SMB_VFS_OP_SYS_ACL_GET_PERMSET,
484 SMB_VFS_LAYER_LOGGER},
485 {SMB_VFS_OP(smb_full_audit_sys_acl_get_qualifier), SMB_VFS_OP_SYS_ACL_GET_QUALIFIER,
486 SMB_VFS_LAYER_LOGGER},
487 {SMB_VFS_OP(smb_full_audit_sys_acl_get_file), SMB_VFS_OP_SYS_ACL_GET_FILE,
488 SMB_VFS_LAYER_LOGGER},
489 {SMB_VFS_OP(smb_full_audit_sys_acl_get_fd), SMB_VFS_OP_SYS_ACL_GET_FD,
490 SMB_VFS_LAYER_LOGGER},
491 {SMB_VFS_OP(smb_full_audit_sys_acl_clear_perms), SMB_VFS_OP_SYS_ACL_CLEAR_PERMS,
492 SMB_VFS_LAYER_LOGGER},
493 {SMB_VFS_OP(smb_full_audit_sys_acl_add_perm), SMB_VFS_OP_SYS_ACL_ADD_PERM,
494 SMB_VFS_LAYER_LOGGER},
495 {SMB_VFS_OP(smb_full_audit_sys_acl_to_text), SMB_VFS_OP_SYS_ACL_TO_TEXT,
496 SMB_VFS_LAYER_LOGGER},
497 {SMB_VFS_OP(smb_full_audit_sys_acl_init), SMB_VFS_OP_SYS_ACL_INIT,
498 SMB_VFS_LAYER_LOGGER},
499 {SMB_VFS_OP(smb_full_audit_sys_acl_create_entry), SMB_VFS_OP_SYS_ACL_CREATE_ENTRY,
500 SMB_VFS_LAYER_LOGGER},
501 {SMB_VFS_OP(smb_full_audit_sys_acl_set_tag_type), SMB_VFS_OP_SYS_ACL_SET_TAG_TYPE,
502 SMB_VFS_LAYER_LOGGER},
503 {SMB_VFS_OP(smb_full_audit_sys_acl_set_qualifier), SMB_VFS_OP_SYS_ACL_SET_QUALIFIER,
504 SMB_VFS_LAYER_LOGGER},
505 {SMB_VFS_OP(smb_full_audit_sys_acl_set_permset), SMB_VFS_OP_SYS_ACL_SET_PERMSET,
506 SMB_VFS_LAYER_LOGGER},
507 {SMB_VFS_OP(smb_full_audit_sys_acl_valid), SMB_VFS_OP_SYS_ACL_VALID,
508 SMB_VFS_LAYER_LOGGER},
509 {SMB_VFS_OP(smb_full_audit_sys_acl_set_file), SMB_VFS_OP_SYS_ACL_SET_FILE,
510 SMB_VFS_LAYER_LOGGER},
511 {SMB_VFS_OP(smb_full_audit_sys_acl_set_fd), SMB_VFS_OP_SYS_ACL_SET_FD,
512 SMB_VFS_LAYER_LOGGER},
513 {SMB_VFS_OP(smb_full_audit_sys_acl_delete_def_file), SMB_VFS_OP_SYS_ACL_DELETE_DEF_FILE,
514 SMB_VFS_LAYER_LOGGER},
515 {SMB_VFS_OP(smb_full_audit_sys_acl_get_perm), SMB_VFS_OP_SYS_ACL_GET_PERM,
516 SMB_VFS_LAYER_LOGGER},
517 {SMB_VFS_OP(smb_full_audit_sys_acl_free_text), SMB_VFS_OP_SYS_ACL_FREE_TEXT,
518 SMB_VFS_LAYER_LOGGER},
519 {SMB_VFS_OP(smb_full_audit_sys_acl_free_acl), SMB_VFS_OP_SYS_ACL_FREE_ACL,
520 SMB_VFS_LAYER_LOGGER},
521 {SMB_VFS_OP(smb_full_audit_sys_acl_free_qualifier), SMB_VFS_OP_SYS_ACL_FREE_QUALIFIER,
522 SMB_VFS_LAYER_LOGGER},
526 {SMB_VFS_OP(smb_full_audit_getxattr), SMB_VFS_OP_GETXATTR,
527 SMB_VFS_LAYER_LOGGER},
528 {SMB_VFS_OP(smb_full_audit_lgetxattr), SMB_VFS_OP_LGETXATTR,
529 SMB_VFS_LAYER_LOGGER},
530 {SMB_VFS_OP(smb_full_audit_fgetxattr), SMB_VFS_OP_FGETXATTR,
531 SMB_VFS_LAYER_LOGGER},
532 {SMB_VFS_OP(smb_full_audit_listxattr), SMB_VFS_OP_LISTXATTR,
533 SMB_VFS_LAYER_LOGGER},
534 {SMB_VFS_OP(smb_full_audit_llistxattr), SMB_VFS_OP_LLISTXATTR,
535 SMB_VFS_LAYER_LOGGER},
536 {SMB_VFS_OP(smb_full_audit_flistxattr), SMB_VFS_OP_FLISTXATTR,
537 SMB_VFS_LAYER_LOGGER},
538 {SMB_VFS_OP(smb_full_audit_removexattr), SMB_VFS_OP_REMOVEXATTR,
539 SMB_VFS_LAYER_LOGGER},
540 {SMB_VFS_OP(smb_full_audit_lremovexattr), SMB_VFS_OP_LREMOVEXATTR,
541 SMB_VFS_LAYER_LOGGER},
542 {SMB_VFS_OP(smb_full_audit_fremovexattr), SMB_VFS_OP_FREMOVEXATTR,
543 SMB_VFS_LAYER_LOGGER},
544 {SMB_VFS_OP(smb_full_audit_setxattr), SMB_VFS_OP_SETXATTR,
545 SMB_VFS_LAYER_LOGGER},
546 {SMB_VFS_OP(smb_full_audit_lsetxattr), SMB_VFS_OP_LSETXATTR,
547 SMB_VFS_LAYER_LOGGER},
548 {SMB_VFS_OP(smb_full_audit_fsetxattr), SMB_VFS_OP_FSETXATTR,
549 SMB_VFS_LAYER_LOGGER},
551 {SMB_VFS_OP(smb_full_audit_aio_read), SMB_VFS_OP_AIO_READ,
552 SMB_VFS_LAYER_LOGGER},
553 {SMB_VFS_OP(smb_full_audit_aio_write), SMB_VFS_OP_AIO_WRITE,
554 SMB_VFS_LAYER_LOGGER},
555 {SMB_VFS_OP(smb_full_audit_aio_return), SMB_VFS_OP_AIO_RETURN,
556 SMB_VFS_LAYER_LOGGER},
557 {SMB_VFS_OP(smb_full_audit_aio_cancel), SMB_VFS_OP_AIO_CANCEL,
558 SMB_VFS_LAYER_LOGGER},
559 {SMB_VFS_OP(smb_full_audit_aio_error), SMB_VFS_OP_AIO_ERROR,
560 SMB_VFS_LAYER_LOGGER},
561 {SMB_VFS_OP(smb_full_audit_aio_fsync), SMB_VFS_OP_AIO_FSYNC,
562 SMB_VFS_LAYER_LOGGER},
563 {SMB_VFS_OP(smb_full_audit_aio_suspend),SMB_VFS_OP_AIO_SUSPEND,
564 SMB_VFS_LAYER_LOGGER},
566 /* Finish VFS operations definition */
568 {SMB_VFS_OP(NULL), SMB_VFS_OP_NOOP,
572 /* The following array *must* be in the same order as defined in vfs.h */
578 { SMB_VFS_OP_CONNECT, "connect" },
579 { SMB_VFS_OP_DISCONNECT, "disconnect" },
580 { SMB_VFS_OP_DISK_FREE, "disk_free" },
581 { SMB_VFS_OP_GET_QUOTA, "get_quota" },
582 { SMB_VFS_OP_SET_QUOTA, "set_quota" },
583 { SMB_VFS_OP_GET_SHADOW_COPY_DATA, "get_shadow_copy_data" },
584 { SMB_VFS_OP_STATVFS, "statvfs" },
585 { SMB_VFS_OP_FS_CAPABILITIES, "fs_capabilities" },
586 { SMB_VFS_OP_OPENDIR, "opendir" },
587 { SMB_VFS_OP_READDIR, "readdir" },
588 { SMB_VFS_OP_SEEKDIR, "seekdir" },
589 { SMB_VFS_OP_TELLDIR, "telldir" },
590 { SMB_VFS_OP_REWINDDIR, "rewinddir" },
591 { SMB_VFS_OP_MKDIR, "mkdir" },
592 { SMB_VFS_OP_RMDIR, "rmdir" },
593 { SMB_VFS_OP_CLOSEDIR, "closedir" },
594 { SMB_VFS_OP_INIT_SEARCH_OP, "init_search_op" },
595 { SMB_VFS_OP_OPEN, "open" },
596 { SMB_VFS_OP_CREATE_FILE, "create_file" },
597 { SMB_VFS_OP_CLOSE, "close" },
598 { SMB_VFS_OP_READ, "read" },
599 { SMB_VFS_OP_PREAD, "pread" },
600 { SMB_VFS_OP_WRITE, "write" },
601 { SMB_VFS_OP_PWRITE, "pwrite" },
602 { SMB_VFS_OP_LSEEK, "lseek" },
603 { SMB_VFS_OP_SENDFILE, "sendfile" },
604 { SMB_VFS_OP_RECVFILE, "recvfile" },
605 { SMB_VFS_OP_RENAME, "rename" },
606 { SMB_VFS_OP_FSYNC, "fsync" },
607 { SMB_VFS_OP_STAT, "stat" },
608 { SMB_VFS_OP_FSTAT, "fstat" },
609 { SMB_VFS_OP_LSTAT, "lstat" },
610 { SMB_VFS_OP_GET_ALLOC_SIZE, "get_alloc_size" },
611 { SMB_VFS_OP_UNLINK, "unlink" },
612 { SMB_VFS_OP_CHMOD, "chmod" },
613 { SMB_VFS_OP_FCHMOD, "fchmod" },
614 { SMB_VFS_OP_CHOWN, "chown" },
615 { SMB_VFS_OP_FCHOWN, "fchown" },
616 { SMB_VFS_OP_LCHOWN, "lchown" },
617 { SMB_VFS_OP_CHDIR, "chdir" },
618 { SMB_VFS_OP_GETWD, "getwd" },
619 { SMB_VFS_OP_NTIMES, "ntimes" },
620 { SMB_VFS_OP_FTRUNCATE, "ftruncate" },
621 { SMB_VFS_OP_LOCK, "lock" },
622 { SMB_VFS_OP_KERNEL_FLOCK, "kernel_flock" },
623 { SMB_VFS_OP_LINUX_SETLEASE, "linux_setlease" },
624 { SMB_VFS_OP_GETLOCK, "getlock" },
625 { SMB_VFS_OP_SYMLINK, "symlink" },
626 { SMB_VFS_OP_READLINK, "readlink" },
627 { SMB_VFS_OP_LINK, "link" },
628 { SMB_VFS_OP_MKNOD, "mknod" },
629 { SMB_VFS_OP_REALPATH, "realpath" },
630 { SMB_VFS_OP_NOTIFY_WATCH, "notify_watch" },
631 { SMB_VFS_OP_CHFLAGS, "chflags" },
632 { SMB_VFS_OP_FILE_ID_CREATE, "file_id_create" },
633 { SMB_VFS_OP_STREAMINFO, "streaminfo" },
634 { SMB_VFS_OP_GET_REAL_FILENAME, "get_real_filename" },
635 { SMB_VFS_OP_FGET_NT_ACL, "fget_nt_acl" },
636 { SMB_VFS_OP_GET_NT_ACL, "get_nt_acl" },
637 { SMB_VFS_OP_FSET_NT_ACL, "fset_nt_acl" },
638 { SMB_VFS_OP_CHMOD_ACL, "chmod_acl" },
639 { SMB_VFS_OP_FCHMOD_ACL, "fchmod_acl" },
640 { SMB_VFS_OP_SYS_ACL_GET_ENTRY, "sys_acl_get_entry" },
641 { SMB_VFS_OP_SYS_ACL_GET_TAG_TYPE, "sys_acl_get_tag_type" },
642 { SMB_VFS_OP_SYS_ACL_GET_PERMSET, "sys_acl_get_permset" },
643 { SMB_VFS_OP_SYS_ACL_GET_QUALIFIER, "sys_acl_get_qualifier" },
644 { SMB_VFS_OP_SYS_ACL_GET_FILE, "sys_acl_get_file" },
645 { SMB_VFS_OP_SYS_ACL_GET_FD, "sys_acl_get_fd" },
646 { SMB_VFS_OP_SYS_ACL_CLEAR_PERMS, "sys_acl_clear_perms" },
647 { SMB_VFS_OP_SYS_ACL_ADD_PERM, "sys_acl_add_perm" },
648 { SMB_VFS_OP_SYS_ACL_TO_TEXT, "sys_acl_to_text" },
649 { SMB_VFS_OP_SYS_ACL_INIT, "sys_acl_init" },
650 { SMB_VFS_OP_SYS_ACL_CREATE_ENTRY, "sys_acl_create_entry" },
651 { SMB_VFS_OP_SYS_ACL_SET_TAG_TYPE, "sys_acl_set_tag_type" },
652 { SMB_VFS_OP_SYS_ACL_SET_QUALIFIER, "sys_acl_set_qualifier" },
653 { SMB_VFS_OP_SYS_ACL_SET_PERMSET, "sys_acl_set_permset" },
654 { SMB_VFS_OP_SYS_ACL_VALID, "sys_acl_valid" },
655 { SMB_VFS_OP_SYS_ACL_SET_FILE, "sys_acl_set_file" },
656 { SMB_VFS_OP_SYS_ACL_SET_FD, "sys_acl_set_fd" },
657 { SMB_VFS_OP_SYS_ACL_DELETE_DEF_FILE, "sys_acl_delete_def_file" },
658 { SMB_VFS_OP_SYS_ACL_GET_PERM, "sys_acl_get_perm" },
659 { SMB_VFS_OP_SYS_ACL_FREE_TEXT, "sys_acl_free_text" },
660 { SMB_VFS_OP_SYS_ACL_FREE_ACL, "sys_acl_free_acl" },
661 { SMB_VFS_OP_SYS_ACL_FREE_QUALIFIER, "sys_acl_free_qualifier" },
662 { SMB_VFS_OP_GETXATTR, "getxattr" },
663 { SMB_VFS_OP_LGETXATTR, "lgetxattr" },
664 { SMB_VFS_OP_FGETXATTR, "fgetxattr" },
665 { SMB_VFS_OP_LISTXATTR, "listxattr" },
666 { SMB_VFS_OP_LLISTXATTR, "llistxattr" },
667 { SMB_VFS_OP_FLISTXATTR, "flistxattr" },
668 { SMB_VFS_OP_REMOVEXATTR, "removexattr" },
669 { SMB_VFS_OP_LREMOVEXATTR, "lremovexattr" },
670 { SMB_VFS_OP_FREMOVEXATTR, "fremovexattr" },
671 { SMB_VFS_OP_SETXATTR, "setxattr" },
672 { SMB_VFS_OP_LSETXATTR, "lsetxattr" },
673 { SMB_VFS_OP_FSETXATTR, "fsetxattr" },
674 { SMB_VFS_OP_AIO_READ, "aio_read" },
675 { SMB_VFS_OP_AIO_WRITE, "aio_write" },
676 { SMB_VFS_OP_AIO_RETURN,"aio_return" },
677 { SMB_VFS_OP_AIO_CANCEL,"aio_cancel" },
678 { SMB_VFS_OP_AIO_ERROR, "aio_error" },
679 { SMB_VFS_OP_AIO_FSYNC, "aio_fsync" },
680 { SMB_VFS_OP_AIO_SUSPEND,"aio_suspend" },
681 { SMB_VFS_OP_AIO_FORCE, "aio_force" },
682 { SMB_VFS_OP_IS_OFFLINE, "aio_is_offline" },
683 { SMB_VFS_OP_SET_OFFLINE, "aio_set_offline" },
684 { SMB_VFS_OP_LAST, NULL }
687 static int audit_syslog_facility(vfs_handle_struct *handle)
689 static const struct enum_list enum_log_facilities[] = {
690 { LOG_USER, "USER" },
691 { LOG_LOCAL0, "LOCAL0" },
692 { LOG_LOCAL1, "LOCAL1" },
693 { LOG_LOCAL2, "LOCAL2" },
694 { LOG_LOCAL3, "LOCAL3" },
695 { LOG_LOCAL4, "LOCAL4" },
696 { LOG_LOCAL5, "LOCAL5" },
697 { LOG_LOCAL6, "LOCAL6" },
698 { LOG_LOCAL7, "LOCAL7" }
703 facility = lp_parm_enum(SNUM(handle->conn), "full_audit", "facility", enum_log_facilities, LOG_USER);
708 static int audit_syslog_priority(vfs_handle_struct *handle)
710 static const struct enum_list enum_log_priorities[] = {
711 { LOG_EMERG, "EMERG" },
712 { LOG_ALERT, "ALERT" },
713 { LOG_CRIT, "CRIT" },
715 { LOG_WARNING, "WARNING" },
716 { LOG_NOTICE, "NOTICE" },
717 { LOG_INFO, "INFO" },
718 { LOG_DEBUG, "DEBUG" }
723 priority = lp_parm_enum(SNUM(handle->conn), "full_audit", "priority",
724 enum_log_priorities, LOG_NOTICE);
725 if (priority == -1) {
726 priority = LOG_WARNING;
732 static char *audit_prefix(TALLOC_CTX *ctx, connection_struct *conn)
737 prefix = talloc_strdup(ctx,
738 lp_parm_const_string(SNUM(conn), "full_audit",
743 result = talloc_sub_advanced(ctx,
744 lp_servicename(SNUM(conn)),
745 conn->server_info->unix_name,
747 conn->server_info->utok.gid,
748 conn->server_info->sanitized_username,
749 pdb_get_domain(conn->server_info->sam_account),
755 static bool log_success(vfs_handle_struct *handle, vfs_op_type op)
757 struct vfs_full_audit_private_data *pd = NULL;
759 SMB_VFS_HANDLE_GET_DATA(handle, pd,
760 struct vfs_full_audit_private_data,
763 if (pd->success_ops == NULL) {
767 return bitmap_query(pd->success_ops, op);
770 static bool log_failure(vfs_handle_struct *handle, vfs_op_type op)
772 struct vfs_full_audit_private_data *pd = NULL;
774 SMB_VFS_HANDLE_GET_DATA(handle, pd,
775 struct vfs_full_audit_private_data,
778 if (pd->failure_ops == NULL)
781 return bitmap_query(pd->failure_ops, op);
784 static void init_bitmap(struct bitmap **bm, const char **ops)
786 bool log_all = False;
791 *bm = bitmap_allocate(SMB_VFS_OP_LAST);
794 DEBUG(0, ("Could not alloc bitmap -- "
795 "defaulting to logging everything\n"));
799 while (*ops != NULL) {
803 if (strequal(*ops, "all")) {
808 if (strequal(*ops, "none")) {
812 for (i=0; i<SMB_VFS_OP_LAST; i++) {
813 if (vfs_op_names[i].name == NULL) {
814 smb_panic("vfs_full_audit.c: name table not "
815 "in sync with vfs.h\n");
818 if (strequal(*ops, vfs_op_names[i].name)) {
824 DEBUG(0, ("Could not find opname %s, logging all\n",
833 /* The query functions default to True */
839 static const char *audit_opname(vfs_op_type op)
841 if (op >= SMB_VFS_OP_LAST)
842 return "INVALID VFS OP";
843 return vfs_op_names[op].name;
846 static void do_log(vfs_op_type op, bool success, vfs_handle_struct *handle,
847 const char *format, ...)
850 char *audit_pre = NULL;
854 if (success && (!log_success(handle, op)))
857 if (!success && (!log_failure(handle, op)))
861 fstrcpy(err_msg, "ok");
863 fstr_sprintf(err_msg, "fail (%s)", strerror(errno));
865 va_start(ap, format);
866 op_msg = talloc_vasprintf(talloc_tos(), format, ap);
873 audit_pre = audit_prefix(talloc_tos(), handle->conn);
874 syslog(audit_syslog_priority(handle), "%s|%s|%s|%s\n",
875 audit_pre ? audit_pre : "",
876 audit_opname(op), err_msg, op_msg);
878 TALLOC_FREE(audit_pre);
884 /* Free function for the private data. */
886 static void free_private_data(void **p_data)
888 struct vfs_full_audit_private_data *pd = *(struct vfs_full_audit_private_data **)p_data;
890 if (pd->success_ops) {
891 bitmap_free(pd->success_ops);
893 if (pd->failure_ops) {
894 bitmap_free(pd->failure_ops);
900 /* Implementation of vfs_ops. Pass everything on to the default
901 operation but log event first. */
903 static int smb_full_audit_connect(vfs_handle_struct *handle,
904 const char *svc, const char *user)
907 struct vfs_full_audit_private_data *pd = NULL;
908 const char *none[] = { NULL };
909 const char *all [] = { "all" };
915 pd = SMB_MALLOC_P(struct vfs_full_audit_private_data);
921 openlog("smbd_audit", 0, audit_syslog_facility(handle));
923 init_bitmap(&pd->success_ops,
924 lp_parm_string_list(SNUM(handle->conn), "full_audit", "success",
926 init_bitmap(&pd->failure_ops,
927 lp_parm_string_list(SNUM(handle->conn), "full_audit", "failure",
930 /* Store the private data. */
931 SMB_VFS_HANDLE_SET_DATA(handle, pd, free_private_data,
932 struct vfs_full_audit_private_data, return -1);
934 result = SMB_VFS_NEXT_CONNECT(handle, svc, user);
936 do_log(SMB_VFS_OP_CONNECT, True, handle,
942 static void smb_full_audit_disconnect(vfs_handle_struct *handle)
944 SMB_VFS_NEXT_DISCONNECT(handle);
946 do_log(SMB_VFS_OP_DISCONNECT, True, handle,
947 "%s", lp_servicename(SNUM(handle->conn)));
949 /* The bitmaps will be disconnected when the private
955 static uint64_t smb_full_audit_disk_free(vfs_handle_struct *handle,
957 bool small_query, uint64_t *bsize,
958 uint64_t *dfree, uint64_t *dsize)
962 result = SMB_VFS_NEXT_DISK_FREE(handle, path, small_query, bsize,
965 /* Don't have a reasonable notion of failure here */
967 do_log(SMB_VFS_OP_DISK_FREE, True, handle, "%s", path);
972 static int smb_full_audit_get_quota(struct vfs_handle_struct *handle,
973 enum SMB_QUOTA_TYPE qtype, unid_t id,
978 result = SMB_VFS_NEXT_GET_QUOTA(handle, qtype, id, qt);
980 do_log(SMB_VFS_OP_GET_QUOTA, (result >= 0), handle, "");
986 static int smb_full_audit_set_quota(struct vfs_handle_struct *handle,
987 enum SMB_QUOTA_TYPE qtype, unid_t id,
992 result = SMB_VFS_NEXT_SET_QUOTA(handle, qtype, id, qt);
994 do_log(SMB_VFS_OP_SET_QUOTA, (result >= 0), handle, "");
999 static int smb_full_audit_get_shadow_copy_data(struct vfs_handle_struct *handle,
1000 struct files_struct *fsp,
1001 SHADOW_COPY_DATA *shadow_copy_data, bool labels)
1005 result = SMB_VFS_NEXT_GET_SHADOW_COPY_DATA(handle, fsp, shadow_copy_data, labels);
1007 do_log(SMB_VFS_OP_GET_SHADOW_COPY_DATA, (result >= 0), handle, "");
1012 static int smb_full_audit_statvfs(struct vfs_handle_struct *handle,
1014 struct vfs_statvfs_struct *statbuf)
1018 result = SMB_VFS_NEXT_STATVFS(handle, path, statbuf);
1020 do_log(SMB_VFS_OP_STATVFS, (result >= 0), handle, "");
1025 static SMB_STRUCT_DIR *smb_full_audit_opendir(vfs_handle_struct *handle,
1026 const char *fname, const char *mask, uint32 attr)
1028 SMB_STRUCT_DIR *result;
1030 result = SMB_VFS_NEXT_OPENDIR(handle, fname, mask, attr);
1032 do_log(SMB_VFS_OP_OPENDIR, (result != NULL), handle, "%s", fname);
1037 static SMB_STRUCT_DIRENT *smb_full_audit_readdir(vfs_handle_struct *handle,
1038 SMB_STRUCT_DIR *dirp, SMB_STRUCT_STAT *sbuf)
1040 SMB_STRUCT_DIRENT *result;
1042 result = SMB_VFS_NEXT_READDIR(handle, dirp, sbuf);
1044 /* This operation has no reasonable error condition
1045 * (End of dir is also failure), so always succeed.
1047 do_log(SMB_VFS_OP_READDIR, True, handle, "");
1052 static void smb_full_audit_seekdir(vfs_handle_struct *handle,
1053 SMB_STRUCT_DIR *dirp, long offset)
1055 SMB_VFS_NEXT_SEEKDIR(handle, dirp, offset);
1057 do_log(SMB_VFS_OP_SEEKDIR, True, handle, "");
1061 static long smb_full_audit_telldir(vfs_handle_struct *handle,
1062 SMB_STRUCT_DIR *dirp)
1066 result = SMB_VFS_NEXT_TELLDIR(handle, dirp);
1068 do_log(SMB_VFS_OP_TELLDIR, True, handle, "");
1073 static void smb_full_audit_rewinddir(vfs_handle_struct *handle,
1074 SMB_STRUCT_DIR *dirp)
1076 SMB_VFS_NEXT_REWINDDIR(handle, dirp);
1078 do_log(SMB_VFS_OP_REWINDDIR, True, handle, "");
1082 static int smb_full_audit_mkdir(vfs_handle_struct *handle,
1083 const char *path, mode_t mode)
1087 result = SMB_VFS_NEXT_MKDIR(handle, path, mode);
1089 do_log(SMB_VFS_OP_MKDIR, (result >= 0), handle, "%s", path);
1094 static int smb_full_audit_rmdir(vfs_handle_struct *handle,
1099 result = SMB_VFS_NEXT_RMDIR(handle, path);
1101 do_log(SMB_VFS_OP_RMDIR, (result >= 0), handle, "%s", path);
1106 static int smb_full_audit_closedir(vfs_handle_struct *handle,
1107 SMB_STRUCT_DIR *dirp)
1111 result = SMB_VFS_NEXT_CLOSEDIR(handle, dirp);
1113 do_log(SMB_VFS_OP_CLOSEDIR, (result >= 0), handle, "");
1118 static void smb_full_audit_init_search_op(vfs_handle_struct *handle,
1119 SMB_STRUCT_DIR *dirp)
1121 SMB_VFS_NEXT_INIT_SEARCH_OP(handle, dirp);
1123 do_log(SMB_VFS_OP_INIT_SEARCH_OP, True, handle, "");
1127 static int smb_full_audit_open(vfs_handle_struct *handle,
1128 const char *fname, files_struct *fsp, int flags, mode_t mode)
1132 result = SMB_VFS_NEXT_OPEN(handle, fname, fsp, flags, mode);
1134 do_log(SMB_VFS_OP_OPEN, (result >= 0), handle, "%s|%s",
1135 ((flags & O_WRONLY) || (flags & O_RDWR))?"w":"r",
1141 static NTSTATUS smb_full_audit_create_file(vfs_handle_struct *handle,
1142 struct smb_request *req,
1143 uint16_t root_dir_fid,
1145 uint32_t create_file_flags,
1146 uint32_t access_mask,
1147 uint32_t share_access,
1148 uint32_t create_disposition,
1149 uint32_t create_options,
1150 uint32_t file_attributes,
1151 uint32_t oplock_request,
1152 uint64_t allocation_size,
1153 struct security_descriptor *sd,
1154 struct ea_list *ea_list,
1155 files_struct **result_fsp,
1157 SMB_STRUCT_STAT *psbuf)
1161 result = SMB_VFS_NEXT_CREATE_FILE(
1162 handle, /* handle */
1164 root_dir_fid, /* root_dir_fid */
1166 create_file_flags, /* create_file_flags */
1167 access_mask, /* access_mask */
1168 share_access, /* share_access */
1169 create_disposition, /* create_disposition*/
1170 create_options, /* create_options */
1171 file_attributes, /* file_attributes */
1172 oplock_request, /* oplock_request */
1173 allocation_size, /* allocation_size */
1175 ea_list, /* ea_list */
1176 result_fsp, /* result */
1180 do_log(SMB_VFS_OP_CREATE_FILE, (NT_STATUS_IS_OK(result)), handle, "0x%x|%s",
1181 access_mask, fname);
1186 static int smb_full_audit_close(vfs_handle_struct *handle, files_struct *fsp)
1190 result = SMB_VFS_NEXT_CLOSE(handle, fsp);
1192 do_log(SMB_VFS_OP_CLOSE, (result >= 0), handle, "%s", fsp->fsp_name);
1197 static ssize_t smb_full_audit_read(vfs_handle_struct *handle, files_struct *fsp,
1198 void *data, size_t n)
1202 result = SMB_VFS_NEXT_READ(handle, fsp, data, n);
1204 do_log(SMB_VFS_OP_READ, (result >= 0), handle, "%s", fsp->fsp_name);
1209 static ssize_t smb_full_audit_pread(vfs_handle_struct *handle, files_struct *fsp,
1210 void *data, size_t n, SMB_OFF_T offset)
1214 result = SMB_VFS_NEXT_PREAD(handle, fsp, data, n, offset);
1216 do_log(SMB_VFS_OP_PREAD, (result >= 0), handle, "%s", fsp->fsp_name);
1221 static ssize_t smb_full_audit_write(vfs_handle_struct *handle, files_struct *fsp,
1222 const void *data, size_t n)
1226 result = SMB_VFS_NEXT_WRITE(handle, fsp, data, n);
1228 do_log(SMB_VFS_OP_WRITE, (result >= 0), handle, "%s", fsp->fsp_name);
1233 static ssize_t smb_full_audit_pwrite(vfs_handle_struct *handle, files_struct *fsp,
1234 const void *data, size_t n,
1239 result = SMB_VFS_NEXT_PWRITE(handle, fsp, data, n, offset);
1241 do_log(SMB_VFS_OP_PWRITE, (result >= 0), handle, "%s", fsp->fsp_name);
1246 static SMB_OFF_T smb_full_audit_lseek(vfs_handle_struct *handle, files_struct *fsp,
1247 SMB_OFF_T offset, int whence)
1251 result = SMB_VFS_NEXT_LSEEK(handle, fsp, offset, whence);
1253 do_log(SMB_VFS_OP_LSEEK, (result != (ssize_t)-1), handle,
1254 "%s", fsp->fsp_name);
1259 static ssize_t smb_full_audit_sendfile(vfs_handle_struct *handle, int tofd,
1260 files_struct *fromfsp,
1261 const DATA_BLOB *hdr, SMB_OFF_T offset,
1266 result = SMB_VFS_NEXT_SENDFILE(handle, tofd, fromfsp, hdr, offset, n);
1268 do_log(SMB_VFS_OP_SENDFILE, (result >= 0), handle,
1269 "%s", fromfsp->fsp_name);
1274 static ssize_t smb_full_audit_recvfile(vfs_handle_struct *handle, int fromfd,
1275 files_struct *tofsp,
1281 result = SMB_VFS_NEXT_RECVFILE(handle, fromfd, tofsp, offset, n);
1283 do_log(SMB_VFS_OP_RECVFILE, (result >= 0), handle,
1284 "%s", tofsp->fsp_name);
1289 static int smb_full_audit_rename(vfs_handle_struct *handle,
1290 const char *oldname, const char *newname)
1294 result = SMB_VFS_NEXT_RENAME(handle, oldname, newname);
1296 do_log(SMB_VFS_OP_RENAME, (result >= 0), handle, "%s|%s", oldname, newname);
1301 static int smb_full_audit_fsync(vfs_handle_struct *handle, files_struct *fsp)
1305 result = SMB_VFS_NEXT_FSYNC(handle, fsp);
1307 do_log(SMB_VFS_OP_FSYNC, (result >= 0), handle, "%s", fsp->fsp_name);
1312 static int smb_full_audit_stat(vfs_handle_struct *handle,
1313 const char *fname, SMB_STRUCT_STAT *sbuf)
1317 result = SMB_VFS_NEXT_STAT(handle, fname, sbuf);
1319 do_log(SMB_VFS_OP_STAT, (result >= 0), handle, "%s", fname);
1324 static int smb_full_audit_fstat(vfs_handle_struct *handle, files_struct *fsp,
1325 SMB_STRUCT_STAT *sbuf)
1329 result = SMB_VFS_NEXT_FSTAT(handle, fsp, sbuf);
1331 do_log(SMB_VFS_OP_FSTAT, (result >= 0), handle, "%s", fsp->fsp_name);
1336 static int smb_full_audit_lstat(vfs_handle_struct *handle,
1337 const char *path, SMB_STRUCT_STAT *sbuf)
1341 result = SMB_VFS_NEXT_LSTAT(handle, path, sbuf);
1343 do_log(SMB_VFS_OP_LSTAT, (result >= 0), handle, "%s", path);
1348 static int smb_full_audit_get_alloc_size(vfs_handle_struct *handle,
1349 files_struct *fsp, const SMB_STRUCT_STAT *sbuf)
1353 result = SMB_VFS_NEXT_GET_ALLOC_SIZE(handle, fsp, sbuf);
1355 do_log(SMB_VFS_OP_GET_ALLOC_SIZE, (result >= 0), handle, "%d", result);
1360 static int smb_full_audit_unlink(vfs_handle_struct *handle,
1365 result = SMB_VFS_NEXT_UNLINK(handle, path);
1367 do_log(SMB_VFS_OP_UNLINK, (result >= 0), handle, "%s", path);
1372 static int smb_full_audit_chmod(vfs_handle_struct *handle,
1373 const char *path, mode_t mode)
1377 result = SMB_VFS_NEXT_CHMOD(handle, path, mode);
1379 do_log(SMB_VFS_OP_CHMOD, (result >= 0), handle, "%s|%o", path, mode);
1384 static int smb_full_audit_fchmod(vfs_handle_struct *handle, files_struct *fsp,
1389 result = SMB_VFS_NEXT_FCHMOD(handle, fsp, mode);
1391 do_log(SMB_VFS_OP_FCHMOD, (result >= 0), handle,
1392 "%s|%o", fsp->fsp_name, mode);
1397 static int smb_full_audit_chown(vfs_handle_struct *handle,
1398 const char *path, uid_t uid, gid_t gid)
1402 result = SMB_VFS_NEXT_CHOWN(handle, path, uid, gid);
1404 do_log(SMB_VFS_OP_CHOWN, (result >= 0), handle, "%s|%ld|%ld",
1405 path, (long int)uid, (long int)gid);
1410 static int smb_full_audit_fchown(vfs_handle_struct *handle, files_struct *fsp,
1411 uid_t uid, gid_t gid)
1415 result = SMB_VFS_NEXT_FCHOWN(handle, fsp, uid, gid);
1417 do_log(SMB_VFS_OP_FCHOWN, (result >= 0), handle, "%s|%ld|%ld",
1418 fsp->fsp_name, (long int)uid, (long int)gid);
1423 static int smb_full_audit_lchown(vfs_handle_struct *handle,
1424 const char *path, uid_t uid, gid_t gid)
1428 result = SMB_VFS_NEXT_LCHOWN(handle, path, uid, gid);
1430 do_log(SMB_VFS_OP_LCHOWN, (result >= 0), handle, "%s|%ld|%ld",
1431 path, (long int)uid, (long int)gid);
1436 static int smb_full_audit_chdir(vfs_handle_struct *handle,
1441 result = SMB_VFS_NEXT_CHDIR(handle, path);
1443 do_log(SMB_VFS_OP_CHDIR, (result >= 0), handle, "chdir|%s", path);
1448 static char *smb_full_audit_getwd(vfs_handle_struct *handle,
1453 result = SMB_VFS_NEXT_GETWD(handle, path);
1455 do_log(SMB_VFS_OP_GETWD, (result != NULL), handle, "%s", path);
1460 static int smb_full_audit_ntimes(vfs_handle_struct *handle,
1461 const char *path, struct smb_file_time *ft)
1465 result = SMB_VFS_NEXT_NTIMES(handle, path, ft);
1467 do_log(SMB_VFS_OP_NTIMES, (result >= 0), handle, "%s", path);
1472 static int smb_full_audit_ftruncate(vfs_handle_struct *handle, files_struct *fsp,
1477 result = SMB_VFS_NEXT_FTRUNCATE(handle, fsp, len);
1479 do_log(SMB_VFS_OP_FTRUNCATE, (result >= 0), handle,
1480 "%s", fsp->fsp_name);
1485 static bool smb_full_audit_lock(vfs_handle_struct *handle, files_struct *fsp,
1486 int op, SMB_OFF_T offset, SMB_OFF_T count, int type)
1490 result = SMB_VFS_NEXT_LOCK(handle, fsp, op, offset, count, type);
1492 do_log(SMB_VFS_OP_LOCK, result, handle, "%s", fsp->fsp_name);
1497 static int smb_full_audit_kernel_flock(struct vfs_handle_struct *handle,
1498 struct files_struct *fsp,
1503 result = SMB_VFS_NEXT_KERNEL_FLOCK(handle, fsp, share_mode);
1505 do_log(SMB_VFS_OP_KERNEL_FLOCK, (result >= 0), handle, "%s",
1511 static int smb_full_audit_linux_setlease(vfs_handle_struct *handle, files_struct *fsp,
1516 result = SMB_VFS_NEXT_LINUX_SETLEASE(handle, fsp, leasetype);
1518 do_log(SMB_VFS_OP_LINUX_SETLEASE, (result >= 0), handle, "%s",
1524 static bool smb_full_audit_getlock(vfs_handle_struct *handle, files_struct *fsp,
1525 SMB_OFF_T *poffset, SMB_OFF_T *pcount, int *ptype, pid_t *ppid)
1529 result = SMB_VFS_NEXT_GETLOCK(handle, fsp, poffset, pcount, ptype, ppid);
1531 do_log(SMB_VFS_OP_GETLOCK, result, handle, "%s", fsp->fsp_name);
1536 static int smb_full_audit_symlink(vfs_handle_struct *handle,
1537 const char *oldpath, const char *newpath)
1541 result = SMB_VFS_NEXT_SYMLINK(handle, oldpath, newpath);
1543 do_log(SMB_VFS_OP_SYMLINK, (result >= 0), handle,
1544 "%s|%s", oldpath, newpath);
1549 static int smb_full_audit_readlink(vfs_handle_struct *handle,
1550 const char *path, char *buf, size_t bufsiz)
1554 result = SMB_VFS_NEXT_READLINK(handle, path, buf, bufsiz);
1556 do_log(SMB_VFS_OP_READLINK, (result >= 0), handle, "%s", path);
1561 static int smb_full_audit_link(vfs_handle_struct *handle,
1562 const char *oldpath, const char *newpath)
1566 result = SMB_VFS_NEXT_LINK(handle, oldpath, newpath);
1568 do_log(SMB_VFS_OP_LINK, (result >= 0), handle,
1569 "%s|%s", oldpath, newpath);
1574 static int smb_full_audit_mknod(vfs_handle_struct *handle,
1575 const char *pathname, mode_t mode, SMB_DEV_T dev)
1579 result = SMB_VFS_NEXT_MKNOD(handle, pathname, mode, dev);
1581 do_log(SMB_VFS_OP_MKNOD, (result >= 0), handle, "%s", pathname);
1586 static char *smb_full_audit_realpath(vfs_handle_struct *handle,
1587 const char *path, char *resolved_path)
1591 result = SMB_VFS_NEXT_REALPATH(handle, path, resolved_path);
1593 do_log(SMB_VFS_OP_REALPATH, (result != NULL), handle, "%s", path);
1598 static NTSTATUS smb_full_audit_notify_watch(struct vfs_handle_struct *handle,
1599 struct sys_notify_context *ctx,
1600 struct notify_entry *e,
1601 void (*callback)(struct sys_notify_context *ctx,
1603 struct notify_event *ev),
1604 void *private_data, void *handle_p)
1608 result = SMB_VFS_NEXT_NOTIFY_WATCH(handle, ctx, e, callback, private_data, handle_p);
1610 do_log(SMB_VFS_OP_NOTIFY_WATCH, NT_STATUS_IS_OK(result), handle, "");
1615 static int smb_full_audit_chflags(vfs_handle_struct *handle,
1616 const char *path, unsigned int flags)
1620 result = SMB_VFS_NEXT_CHFLAGS(handle, path, flags);
1622 do_log(SMB_VFS_OP_CHFLAGS, (result != 0), handle, "%s", path);
1627 static struct file_id smb_full_audit_file_id_create(struct vfs_handle_struct *handle,
1628 SMB_DEV_T dev, SMB_INO_T inode)
1630 struct file_id id_zero;
1631 struct file_id result;
1633 ZERO_STRUCT(id_zero);
1635 result = SMB_VFS_NEXT_FILE_ID_CREATE(handle, dev, inode);
1637 do_log(SMB_VFS_OP_FILE_ID_CREATE,
1638 !file_id_equal(&id_zero, &result),
1639 handle, "%s", file_id_string_tos(&result));
1644 static NTSTATUS smb_full_audit_streaminfo(vfs_handle_struct *handle,
1645 struct files_struct *fsp,
1647 TALLOC_CTX *mem_ctx,
1648 unsigned int *pnum_streams,
1649 struct stream_struct **pstreams)
1653 result = SMB_VFS_NEXT_STREAMINFO(handle, fsp, fname, mem_ctx,
1654 pnum_streams, pstreams);
1656 do_log(SMB_VFS_OP_STREAMINFO, NT_STATUS_IS_OK(result), handle,
1662 static int smb_full_audit_get_real_filename(struct vfs_handle_struct *handle,
1665 TALLOC_CTX *mem_ctx,
1670 result = SMB_VFS_NEXT_GET_REAL_FILENAME(handle, path, name, mem_ctx,
1673 do_log(SMB_VFS_OP_GET_REAL_FILENAME, (result == 0), handle,
1674 "%s/%s->%s", path, name, (result == 0) ? "" : *found_name);
1679 static NTSTATUS smb_full_audit_fget_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
1680 uint32 security_info,
1685 result = SMB_VFS_NEXT_FGET_NT_ACL(handle, fsp, security_info, ppdesc);
1687 do_log(SMB_VFS_OP_FGET_NT_ACL, NT_STATUS_IS_OK(result), handle,
1688 "%s", fsp->fsp_name);
1693 static NTSTATUS smb_full_audit_get_nt_acl(vfs_handle_struct *handle,
1695 uint32 security_info,
1700 result = SMB_VFS_NEXT_GET_NT_ACL(handle, name, security_info, ppdesc);
1702 do_log(SMB_VFS_OP_GET_NT_ACL, NT_STATUS_IS_OK(result), handle,
1708 static NTSTATUS smb_full_audit_fset_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
1709 uint32 security_info_sent,
1710 const SEC_DESC *psd)
1714 result = SMB_VFS_NEXT_FSET_NT_ACL(handle, fsp, security_info_sent, psd);
1716 do_log(SMB_VFS_OP_FSET_NT_ACL, NT_STATUS_IS_OK(result), handle, "%s", fsp->fsp_name);
1721 static int smb_full_audit_chmod_acl(vfs_handle_struct *handle,
1722 const char *path, mode_t mode)
1726 result = SMB_VFS_NEXT_CHMOD_ACL(handle, path, mode);
1728 do_log(SMB_VFS_OP_CHMOD_ACL, (result >= 0), handle,
1729 "%s|%o", path, mode);
1734 static int smb_full_audit_fchmod_acl(vfs_handle_struct *handle, files_struct *fsp,
1739 result = SMB_VFS_NEXT_FCHMOD_ACL(handle, fsp, mode);
1741 do_log(SMB_VFS_OP_FCHMOD_ACL, (result >= 0), handle,
1742 "%s|%o", fsp->fsp_name, mode);
1747 static int smb_full_audit_sys_acl_get_entry(vfs_handle_struct *handle,
1749 SMB_ACL_T theacl, int entry_id,
1750 SMB_ACL_ENTRY_T *entry_p)
1754 result = SMB_VFS_NEXT_SYS_ACL_GET_ENTRY(handle, theacl, entry_id,
1757 do_log(SMB_VFS_OP_SYS_ACL_GET_ENTRY, (result >= 0), handle,
1763 static int smb_full_audit_sys_acl_get_tag_type(vfs_handle_struct *handle,
1765 SMB_ACL_ENTRY_T entry_d,
1766 SMB_ACL_TAG_T *tag_type_p)
1770 result = SMB_VFS_NEXT_SYS_ACL_GET_TAG_TYPE(handle, entry_d,
1773 do_log(SMB_VFS_OP_SYS_ACL_GET_TAG_TYPE, (result >= 0), handle,
1779 static int smb_full_audit_sys_acl_get_permset(vfs_handle_struct *handle,
1781 SMB_ACL_ENTRY_T entry_d,
1782 SMB_ACL_PERMSET_T *permset_p)
1786 result = SMB_VFS_NEXT_SYS_ACL_GET_PERMSET(handle, entry_d,
1789 do_log(SMB_VFS_OP_SYS_ACL_GET_PERMSET, (result >= 0), handle,
1795 static void * smb_full_audit_sys_acl_get_qualifier(vfs_handle_struct *handle,
1797 SMB_ACL_ENTRY_T entry_d)
1801 result = SMB_VFS_NEXT_SYS_ACL_GET_QUALIFIER(handle, entry_d);
1803 do_log(SMB_VFS_OP_SYS_ACL_GET_QUALIFIER, (result != NULL), handle,
1809 static SMB_ACL_T smb_full_audit_sys_acl_get_file(vfs_handle_struct *handle,
1811 SMB_ACL_TYPE_T type)
1815 result = SMB_VFS_NEXT_SYS_ACL_GET_FILE(handle, path_p, type);
1817 do_log(SMB_VFS_OP_SYS_ACL_GET_FILE, (result != NULL), handle,
1823 static SMB_ACL_T smb_full_audit_sys_acl_get_fd(vfs_handle_struct *handle,
1828 result = SMB_VFS_NEXT_SYS_ACL_GET_FD(handle, fsp);
1830 do_log(SMB_VFS_OP_SYS_ACL_GET_FD, (result != NULL), handle,
1831 "%s", fsp->fsp_name);
1836 static int smb_full_audit_sys_acl_clear_perms(vfs_handle_struct *handle,
1838 SMB_ACL_PERMSET_T permset)
1842 result = SMB_VFS_NEXT_SYS_ACL_CLEAR_PERMS(handle, permset);
1844 do_log(SMB_VFS_OP_SYS_ACL_CLEAR_PERMS, (result >= 0), handle,
1850 static int smb_full_audit_sys_acl_add_perm(vfs_handle_struct *handle,
1852 SMB_ACL_PERMSET_T permset,
1853 SMB_ACL_PERM_T perm)
1857 result = SMB_VFS_NEXT_SYS_ACL_ADD_PERM(handle, permset, perm);
1859 do_log(SMB_VFS_OP_SYS_ACL_ADD_PERM, (result >= 0), handle,
1865 static char * smb_full_audit_sys_acl_to_text(vfs_handle_struct *handle,
1871 result = SMB_VFS_NEXT_SYS_ACL_TO_TEXT(handle, theacl, plen);
1873 do_log(SMB_VFS_OP_SYS_ACL_TO_TEXT, (result != NULL), handle,
1879 static SMB_ACL_T smb_full_audit_sys_acl_init(vfs_handle_struct *handle,
1885 result = SMB_VFS_NEXT_SYS_ACL_INIT(handle, count);
1887 do_log(SMB_VFS_OP_SYS_ACL_INIT, (result != NULL), handle,
1893 static int smb_full_audit_sys_acl_create_entry(vfs_handle_struct *handle,
1895 SMB_ACL_ENTRY_T *pentry)
1899 result = SMB_VFS_NEXT_SYS_ACL_CREATE_ENTRY(handle, pacl, pentry);
1901 do_log(SMB_VFS_OP_SYS_ACL_CREATE_ENTRY, (result >= 0), handle,
1907 static int smb_full_audit_sys_acl_set_tag_type(vfs_handle_struct *handle,
1909 SMB_ACL_ENTRY_T entry,
1910 SMB_ACL_TAG_T tagtype)
1914 result = SMB_VFS_NEXT_SYS_ACL_SET_TAG_TYPE(handle, entry,
1917 do_log(SMB_VFS_OP_SYS_ACL_SET_TAG_TYPE, (result >= 0), handle,
1923 static int smb_full_audit_sys_acl_set_qualifier(vfs_handle_struct *handle,
1925 SMB_ACL_ENTRY_T entry,
1930 result = SMB_VFS_NEXT_SYS_ACL_SET_QUALIFIER(handle, entry, qual);
1932 do_log(SMB_VFS_OP_SYS_ACL_SET_QUALIFIER, (result >= 0), handle,
1938 static int smb_full_audit_sys_acl_set_permset(vfs_handle_struct *handle,
1940 SMB_ACL_ENTRY_T entry,
1941 SMB_ACL_PERMSET_T permset)
1945 result = SMB_VFS_NEXT_SYS_ACL_SET_PERMSET(handle, entry, permset);
1947 do_log(SMB_VFS_OP_SYS_ACL_SET_PERMSET, (result >= 0), handle,
1953 static int smb_full_audit_sys_acl_valid(vfs_handle_struct *handle,
1959 result = SMB_VFS_NEXT_SYS_ACL_VALID(handle, theacl);
1961 do_log(SMB_VFS_OP_SYS_ACL_VALID, (result >= 0), handle,
1967 static int smb_full_audit_sys_acl_set_file(vfs_handle_struct *handle,
1969 const char *name, SMB_ACL_TYPE_T acltype,
1974 result = SMB_VFS_NEXT_SYS_ACL_SET_FILE(handle, name, acltype,
1977 do_log(SMB_VFS_OP_SYS_ACL_SET_FILE, (result >= 0), handle,
1983 static int smb_full_audit_sys_acl_set_fd(vfs_handle_struct *handle, files_struct *fsp,
1988 result = SMB_VFS_NEXT_SYS_ACL_SET_FD(handle, fsp, theacl);
1990 do_log(SMB_VFS_OP_SYS_ACL_SET_FD, (result >= 0), handle,
1991 "%s", fsp->fsp_name);
1996 static int smb_full_audit_sys_acl_delete_def_file(vfs_handle_struct *handle,
2002 result = SMB_VFS_NEXT_SYS_ACL_DELETE_DEF_FILE(handle, path);
2004 do_log(SMB_VFS_OP_SYS_ACL_DELETE_DEF_FILE, (result >= 0), handle,
2010 static int smb_full_audit_sys_acl_get_perm(vfs_handle_struct *handle,
2012 SMB_ACL_PERMSET_T permset,
2013 SMB_ACL_PERM_T perm)
2017 result = SMB_VFS_NEXT_SYS_ACL_GET_PERM(handle, permset, perm);
2019 do_log(SMB_VFS_OP_SYS_ACL_GET_PERM, (result >= 0), handle,
2025 static int smb_full_audit_sys_acl_free_text(vfs_handle_struct *handle,
2031 result = SMB_VFS_NEXT_SYS_ACL_FREE_TEXT(handle, text);
2033 do_log(SMB_VFS_OP_SYS_ACL_FREE_TEXT, (result >= 0), handle,
2039 static int smb_full_audit_sys_acl_free_acl(vfs_handle_struct *handle,
2041 SMB_ACL_T posix_acl)
2045 result = SMB_VFS_NEXT_SYS_ACL_FREE_ACL(handle, posix_acl);
2047 do_log(SMB_VFS_OP_SYS_ACL_FREE_ACL, (result >= 0), handle,
2053 static int smb_full_audit_sys_acl_free_qualifier(vfs_handle_struct *handle,
2055 SMB_ACL_TAG_T tagtype)
2059 result = SMB_VFS_NEXT_SYS_ACL_FREE_QUALIFIER(handle, qualifier,
2062 do_log(SMB_VFS_OP_SYS_ACL_FREE_QUALIFIER, (result >= 0), handle,
2068 static ssize_t smb_full_audit_getxattr(struct vfs_handle_struct *handle,
2070 const char *name, void *value, size_t size)
2074 result = SMB_VFS_NEXT_GETXATTR(handle, path, name, value, size);
2076 do_log(SMB_VFS_OP_GETXATTR, (result >= 0), handle,
2077 "%s|%s", path, name);
2082 static ssize_t smb_full_audit_lgetxattr(struct vfs_handle_struct *handle,
2083 const char *path, const char *name,
2084 void *value, size_t size)
2088 result = SMB_VFS_NEXT_LGETXATTR(handle, path, name, value, size);
2090 do_log(SMB_VFS_OP_LGETXATTR, (result >= 0), handle,
2091 "%s|%s", path, name);
2096 static ssize_t smb_full_audit_fgetxattr(struct vfs_handle_struct *handle,
2097 struct files_struct *fsp,
2098 const char *name, void *value, size_t size)
2102 result = SMB_VFS_NEXT_FGETXATTR(handle, fsp, name, value, size);
2104 do_log(SMB_VFS_OP_FGETXATTR, (result >= 0), handle,
2105 "%s|%s", fsp->fsp_name, name);
2110 static ssize_t smb_full_audit_listxattr(struct vfs_handle_struct *handle,
2111 const char *path, char *list, size_t size)
2115 result = SMB_VFS_NEXT_LISTXATTR(handle, path, list, size);
2117 do_log(SMB_VFS_OP_LISTXATTR, (result >= 0), handle, "%s", path);
2122 static ssize_t smb_full_audit_llistxattr(struct vfs_handle_struct *handle,
2123 const char *path, char *list, size_t size)
2127 result = SMB_VFS_NEXT_LLISTXATTR(handle, path, list, size);
2129 do_log(SMB_VFS_OP_LLISTXATTR, (result >= 0), handle, "%s", path);
2134 static ssize_t smb_full_audit_flistxattr(struct vfs_handle_struct *handle,
2135 struct files_struct *fsp, char *list,
2140 result = SMB_VFS_NEXT_FLISTXATTR(handle, fsp, list, size);
2142 do_log(SMB_VFS_OP_FLISTXATTR, (result >= 0), handle,
2143 "%s", fsp->fsp_name);
2148 static int smb_full_audit_removexattr(struct vfs_handle_struct *handle,
2154 result = SMB_VFS_NEXT_REMOVEXATTR(handle, path, name);
2156 do_log(SMB_VFS_OP_REMOVEXATTR, (result >= 0), handle,
2157 "%s|%s", path, name);
2162 static int smb_full_audit_lremovexattr(struct vfs_handle_struct *handle,
2168 result = SMB_VFS_NEXT_LREMOVEXATTR(handle, path, name);
2170 do_log(SMB_VFS_OP_LREMOVEXATTR, (result >= 0), handle,
2171 "%s|%s", path, name);
2176 static int smb_full_audit_fremovexattr(struct vfs_handle_struct *handle,
2177 struct files_struct *fsp,
2182 result = SMB_VFS_NEXT_FREMOVEXATTR(handle, fsp, name);
2184 do_log(SMB_VFS_OP_FREMOVEXATTR, (result >= 0), handle,
2185 "%s|%s", fsp->fsp_name, name);
2190 static int smb_full_audit_setxattr(struct vfs_handle_struct *handle,
2192 const char *name, const void *value, size_t size,
2197 result = SMB_VFS_NEXT_SETXATTR(handle, path, name, value, size,
2200 do_log(SMB_VFS_OP_SETXATTR, (result >= 0), handle,
2201 "%s|%s", path, name);
2206 static int smb_full_audit_lsetxattr(struct vfs_handle_struct *handle,
2208 const char *name, const void *value, size_t size,
2213 result = SMB_VFS_NEXT_LSETXATTR(handle, path, name, value, size,
2216 do_log(SMB_VFS_OP_LSETXATTR, (result >= 0), handle,
2217 "%s|%s", path, name);
2222 static int smb_full_audit_fsetxattr(struct vfs_handle_struct *handle,
2223 struct files_struct *fsp, const char *name,
2224 const void *value, size_t size, int flags)
2228 result = SMB_VFS_NEXT_FSETXATTR(handle, fsp, name, value, size, flags);
2230 do_log(SMB_VFS_OP_FSETXATTR, (result >= 0), handle,
2231 "%s|%s", fsp->fsp_name, name);
2236 static int smb_full_audit_aio_read(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb)
2240 result = SMB_VFS_NEXT_AIO_READ(handle, fsp, aiocb);
2241 do_log(SMB_VFS_OP_AIO_READ, (result >= 0), handle,
2242 "%s", fsp->fsp_name);
2247 static int smb_full_audit_aio_write(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb)
2251 result = SMB_VFS_NEXT_AIO_WRITE(handle, fsp, aiocb);
2252 do_log(SMB_VFS_OP_AIO_WRITE, (result >= 0), handle,
2253 "%s", fsp->fsp_name);
2258 static ssize_t smb_full_audit_aio_return(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb)
2262 result = SMB_VFS_NEXT_AIO_RETURN(handle, fsp, aiocb);
2263 do_log(SMB_VFS_OP_AIO_RETURN, (result >= 0), handle,
2264 "%s", fsp->fsp_name);
2269 static int smb_full_audit_aio_cancel(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb)
2273 result = SMB_VFS_NEXT_AIO_CANCEL(handle, fsp, aiocb);
2274 do_log(SMB_VFS_OP_AIO_CANCEL, (result >= 0), handle,
2275 "%s", fsp->fsp_name);
2280 static int smb_full_audit_aio_error(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb)
2284 result = SMB_VFS_NEXT_AIO_ERROR(handle, fsp, aiocb);
2285 do_log(SMB_VFS_OP_AIO_ERROR, (result >= 0), handle,
2286 "%s", fsp->fsp_name);
2291 static int smb_full_audit_aio_fsync(struct vfs_handle_struct *handle, struct files_struct *fsp, int op, SMB_STRUCT_AIOCB *aiocb)
2295 result = SMB_VFS_NEXT_AIO_FSYNC(handle, fsp, op, aiocb);
2296 do_log(SMB_VFS_OP_AIO_FSYNC, (result >= 0), handle,
2297 "%s", fsp->fsp_name);
2302 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)
2306 result = SMB_VFS_NEXT_AIO_SUSPEND(handle, fsp, aiocb, n, ts);
2307 do_log(SMB_VFS_OP_AIO_SUSPEND, (result >= 0), handle,
2308 "%s", fsp->fsp_name);
2314 NTSTATUS vfs_full_audit_init(void);
2315 NTSTATUS vfs_full_audit_init(void)
2317 NTSTATUS ret = smb_register_vfs(SMB_VFS_INTERFACE_VERSION,
2318 "full_audit", audit_op_tuples);
2320 if (!NT_STATUS_IS_OK(ret))
2323 vfs_full_audit_debug_level = debug_add_class("full_audit");
2324 if (vfs_full_audit_debug_level == -1) {
2325 vfs_full_audit_debug_level = DBGC_VFS;
2326 DEBUG(0, ("vfs_full_audit: Couldn't register custom debugging "
2329 DEBUG(10, ("vfs_full_audit: Debug class number of "
2330 "'full_audit': %d\n", vfs_full_audit_debug_level));