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 /* The following array *must* be in the same order as defined in vfs.h */
78 { SMB_VFS_OP_CONNECT, "connect" },
79 { SMB_VFS_OP_DISCONNECT, "disconnect" },
80 { SMB_VFS_OP_DISK_FREE, "disk_free" },
81 { SMB_VFS_OP_GET_QUOTA, "get_quota" },
82 { SMB_VFS_OP_SET_QUOTA, "set_quota" },
83 { SMB_VFS_OP_GET_SHADOW_COPY_DATA, "get_shadow_copy_data" },
84 { SMB_VFS_OP_STATVFS, "statvfs" },
85 { SMB_VFS_OP_FS_CAPABILITIES, "fs_capabilities" },
86 { SMB_VFS_OP_OPENDIR, "opendir" },
87 { SMB_VFS_OP_READDIR, "readdir" },
88 { SMB_VFS_OP_SEEKDIR, "seekdir" },
89 { SMB_VFS_OP_TELLDIR, "telldir" },
90 { SMB_VFS_OP_REWINDDIR, "rewinddir" },
91 { SMB_VFS_OP_MKDIR, "mkdir" },
92 { SMB_VFS_OP_RMDIR, "rmdir" },
93 { SMB_VFS_OP_CLOSEDIR, "closedir" },
94 { SMB_VFS_OP_INIT_SEARCH_OP, "init_search_op" },
95 { SMB_VFS_OP_OPEN, "open" },
96 { SMB_VFS_OP_CREATE_FILE, "create_file" },
97 { SMB_VFS_OP_CLOSE, "close" },
98 { SMB_VFS_OP_READ, "read" },
99 { SMB_VFS_OP_PREAD, "pread" },
100 { SMB_VFS_OP_WRITE, "write" },
101 { SMB_VFS_OP_PWRITE, "pwrite" },
102 { SMB_VFS_OP_LSEEK, "lseek" },
103 { SMB_VFS_OP_SENDFILE, "sendfile" },
104 { SMB_VFS_OP_RECVFILE, "recvfile" },
105 { SMB_VFS_OP_RENAME, "rename" },
106 { SMB_VFS_OP_FSYNC, "fsync" },
107 { SMB_VFS_OP_STAT, "stat" },
108 { SMB_VFS_OP_FSTAT, "fstat" },
109 { SMB_VFS_OP_LSTAT, "lstat" },
110 { SMB_VFS_OP_GET_ALLOC_SIZE, "get_alloc_size" },
111 { SMB_VFS_OP_UNLINK, "unlink" },
112 { SMB_VFS_OP_CHMOD, "chmod" },
113 { SMB_VFS_OP_FCHMOD, "fchmod" },
114 { SMB_VFS_OP_CHOWN, "chown" },
115 { SMB_VFS_OP_FCHOWN, "fchown" },
116 { SMB_VFS_OP_LCHOWN, "lchown" },
117 { SMB_VFS_OP_CHDIR, "chdir" },
118 { SMB_VFS_OP_GETWD, "getwd" },
119 { SMB_VFS_OP_NTIMES, "ntimes" },
120 { SMB_VFS_OP_FTRUNCATE, "ftruncate" },
121 { SMB_VFS_OP_LOCK, "lock" },
122 { SMB_VFS_OP_KERNEL_FLOCK, "kernel_flock" },
123 { SMB_VFS_OP_LINUX_SETLEASE, "linux_setlease" },
124 { SMB_VFS_OP_GETLOCK, "getlock" },
125 { SMB_VFS_OP_SYMLINK, "symlink" },
126 { SMB_VFS_OP_READLINK, "readlink" },
127 { SMB_VFS_OP_LINK, "link" },
128 { SMB_VFS_OP_MKNOD, "mknod" },
129 { SMB_VFS_OP_REALPATH, "realpath" },
130 { SMB_VFS_OP_NOTIFY_WATCH, "notify_watch" },
131 { SMB_VFS_OP_CHFLAGS, "chflags" },
132 { SMB_VFS_OP_FILE_ID_CREATE, "file_id_create" },
133 { SMB_VFS_OP_STREAMINFO, "streaminfo" },
134 { SMB_VFS_OP_GET_REAL_FILENAME, "get_real_filename" },
135 { SMB_VFS_OP_CONNECTPATH, "connectpath" },
136 { SMB_VFS_OP_BRL_LOCK_WINDOWS, "brl_lock_windows" },
137 { SMB_VFS_OP_BRL_UNLOCK_WINDOWS, "brl_unlock_windows" },
138 { SMB_VFS_OP_BRL_CANCEL_WINDOWS, "brl_cancel_windows" },
139 { SMB_VFS_OP_STRICT_LOCK, "strict_lock" },
140 { SMB_VFS_OP_STRICT_UNLOCK, "strict_unlock" },
141 { SMB_VFS_OP_FGET_NT_ACL, "fget_nt_acl" },
142 { SMB_VFS_OP_GET_NT_ACL, "get_nt_acl" },
143 { SMB_VFS_OP_FSET_NT_ACL, "fset_nt_acl" },
144 { SMB_VFS_OP_CHMOD_ACL, "chmod_acl" },
145 { SMB_VFS_OP_FCHMOD_ACL, "fchmod_acl" },
146 { SMB_VFS_OP_SYS_ACL_GET_ENTRY, "sys_acl_get_entry" },
147 { SMB_VFS_OP_SYS_ACL_GET_TAG_TYPE, "sys_acl_get_tag_type" },
148 { SMB_VFS_OP_SYS_ACL_GET_PERMSET, "sys_acl_get_permset" },
149 { SMB_VFS_OP_SYS_ACL_GET_QUALIFIER, "sys_acl_get_qualifier" },
150 { SMB_VFS_OP_SYS_ACL_GET_FILE, "sys_acl_get_file" },
151 { SMB_VFS_OP_SYS_ACL_GET_FD, "sys_acl_get_fd" },
152 { SMB_VFS_OP_SYS_ACL_CLEAR_PERMS, "sys_acl_clear_perms" },
153 { SMB_VFS_OP_SYS_ACL_ADD_PERM, "sys_acl_add_perm" },
154 { SMB_VFS_OP_SYS_ACL_TO_TEXT, "sys_acl_to_text" },
155 { SMB_VFS_OP_SYS_ACL_INIT, "sys_acl_init" },
156 { SMB_VFS_OP_SYS_ACL_CREATE_ENTRY, "sys_acl_create_entry" },
157 { SMB_VFS_OP_SYS_ACL_SET_TAG_TYPE, "sys_acl_set_tag_type" },
158 { SMB_VFS_OP_SYS_ACL_SET_QUALIFIER, "sys_acl_set_qualifier" },
159 { SMB_VFS_OP_SYS_ACL_SET_PERMSET, "sys_acl_set_permset" },
160 { SMB_VFS_OP_SYS_ACL_VALID, "sys_acl_valid" },
161 { SMB_VFS_OP_SYS_ACL_SET_FILE, "sys_acl_set_file" },
162 { SMB_VFS_OP_SYS_ACL_SET_FD, "sys_acl_set_fd" },
163 { SMB_VFS_OP_SYS_ACL_DELETE_DEF_FILE, "sys_acl_delete_def_file" },
164 { SMB_VFS_OP_SYS_ACL_GET_PERM, "sys_acl_get_perm" },
165 { SMB_VFS_OP_SYS_ACL_FREE_TEXT, "sys_acl_free_text" },
166 { SMB_VFS_OP_SYS_ACL_FREE_ACL, "sys_acl_free_acl" },
167 { SMB_VFS_OP_SYS_ACL_FREE_QUALIFIER, "sys_acl_free_qualifier" },
168 { SMB_VFS_OP_GETXATTR, "getxattr" },
169 { SMB_VFS_OP_LGETXATTR, "lgetxattr" },
170 { SMB_VFS_OP_FGETXATTR, "fgetxattr" },
171 { SMB_VFS_OP_LISTXATTR, "listxattr" },
172 { SMB_VFS_OP_LLISTXATTR, "llistxattr" },
173 { SMB_VFS_OP_FLISTXATTR, "flistxattr" },
174 { SMB_VFS_OP_REMOVEXATTR, "removexattr" },
175 { SMB_VFS_OP_LREMOVEXATTR, "lremovexattr" },
176 { SMB_VFS_OP_FREMOVEXATTR, "fremovexattr" },
177 { SMB_VFS_OP_SETXATTR, "setxattr" },
178 { SMB_VFS_OP_LSETXATTR, "lsetxattr" },
179 { SMB_VFS_OP_FSETXATTR, "fsetxattr" },
180 { SMB_VFS_OP_AIO_READ, "aio_read" },
181 { SMB_VFS_OP_AIO_WRITE, "aio_write" },
182 { SMB_VFS_OP_AIO_RETURN,"aio_return" },
183 { SMB_VFS_OP_AIO_CANCEL,"aio_cancel" },
184 { SMB_VFS_OP_AIO_ERROR, "aio_error" },
185 { SMB_VFS_OP_AIO_FSYNC, "aio_fsync" },
186 { SMB_VFS_OP_AIO_SUSPEND,"aio_suspend" },
187 { SMB_VFS_OP_AIO_FORCE, "aio_force" },
188 { SMB_VFS_OP_IS_OFFLINE, "aio_is_offline" },
189 { SMB_VFS_OP_SET_OFFLINE, "aio_set_offline" },
190 { SMB_VFS_OP_LAST, NULL }
193 static int audit_syslog_facility(vfs_handle_struct *handle)
195 static const struct enum_list enum_log_facilities[] = {
196 { LOG_USER, "USER" },
197 { LOG_LOCAL0, "LOCAL0" },
198 { LOG_LOCAL1, "LOCAL1" },
199 { LOG_LOCAL2, "LOCAL2" },
200 { LOG_LOCAL3, "LOCAL3" },
201 { LOG_LOCAL4, "LOCAL4" },
202 { LOG_LOCAL5, "LOCAL5" },
203 { LOG_LOCAL6, "LOCAL6" },
204 { LOG_LOCAL7, "LOCAL7" }
209 facility = lp_parm_enum(SNUM(handle->conn), "full_audit", "facility", enum_log_facilities, LOG_USER);
214 static int audit_syslog_priority(vfs_handle_struct *handle)
216 static const struct enum_list enum_log_priorities[] = {
217 { LOG_EMERG, "EMERG" },
218 { LOG_ALERT, "ALERT" },
219 { LOG_CRIT, "CRIT" },
221 { LOG_WARNING, "WARNING" },
222 { LOG_NOTICE, "NOTICE" },
223 { LOG_INFO, "INFO" },
224 { LOG_DEBUG, "DEBUG" }
229 priority = lp_parm_enum(SNUM(handle->conn), "full_audit", "priority",
230 enum_log_priorities, LOG_NOTICE);
231 if (priority == -1) {
232 priority = LOG_WARNING;
238 static char *audit_prefix(TALLOC_CTX *ctx, connection_struct *conn)
243 prefix = talloc_strdup(ctx,
244 lp_parm_const_string(SNUM(conn), "full_audit",
249 result = talloc_sub_advanced(ctx,
250 lp_servicename(SNUM(conn)),
251 conn->server_info->unix_name,
253 conn->server_info->utok.gid,
254 conn->server_info->sanitized_username,
255 pdb_get_domain(conn->server_info->sam_account),
261 static bool log_success(vfs_handle_struct *handle, vfs_op_type op)
263 struct vfs_full_audit_private_data *pd = NULL;
265 SMB_VFS_HANDLE_GET_DATA(handle, pd,
266 struct vfs_full_audit_private_data,
269 if (pd->success_ops == NULL) {
273 return bitmap_query(pd->success_ops, op);
276 static bool log_failure(vfs_handle_struct *handle, vfs_op_type op)
278 struct vfs_full_audit_private_data *pd = NULL;
280 SMB_VFS_HANDLE_GET_DATA(handle, pd,
281 struct vfs_full_audit_private_data,
284 if (pd->failure_ops == NULL)
287 return bitmap_query(pd->failure_ops, op);
290 static void init_bitmap(struct bitmap **bm, const char **ops)
292 bool log_all = False;
297 *bm = bitmap_allocate(SMB_VFS_OP_LAST);
300 DEBUG(0, ("Could not alloc bitmap -- "
301 "defaulting to logging everything\n"));
305 while (*ops != NULL) {
309 if (strequal(*ops, "all")) {
314 if (strequal(*ops, "none")) {
318 for (i=0; i<SMB_VFS_OP_LAST; i++) {
319 if (vfs_op_names[i].name == NULL) {
320 smb_panic("vfs_full_audit.c: name table not "
321 "in sync with vfs.h\n");
324 if (strequal(*ops, vfs_op_names[i].name)) {
330 DEBUG(0, ("Could not find opname %s, logging all\n",
339 /* The query functions default to True */
345 static const char *audit_opname(vfs_op_type op)
347 if (op >= SMB_VFS_OP_LAST)
348 return "INVALID VFS OP";
349 return vfs_op_names[op].name;
352 static TALLOC_CTX *tmp_do_log_ctx;
354 * Get us a temporary talloc context usable just for DEBUG arguments
356 static TALLOC_CTX *do_log_ctx(void)
358 if (tmp_do_log_ctx == NULL) {
359 tmp_do_log_ctx = talloc_named_const(NULL, 0, "do_log_ctx");
361 return tmp_do_log_ctx;
364 static void do_log(vfs_op_type op, bool success, vfs_handle_struct *handle,
365 const char *format, ...)
368 char *audit_pre = NULL;
372 if (success && (!log_success(handle, op)))
375 if (!success && (!log_failure(handle, op)))
379 fstrcpy(err_msg, "ok");
381 fstr_sprintf(err_msg, "fail (%s)", strerror(errno));
383 va_start(ap, format);
384 op_msg = talloc_vasprintf(talloc_tos(), format, ap);
391 audit_pre = audit_prefix(talloc_tos(), handle->conn);
392 syslog(audit_syslog_priority(handle), "%s|%s|%s|%s\n",
393 audit_pre ? audit_pre : "",
394 audit_opname(op), err_msg, op_msg);
397 TALLOC_FREE(audit_pre);
399 TALLOC_FREE(tmp_do_log_ctx);
405 * Return a string using the do_log_ctx()
407 static const char *smb_fname_str_do_log(const struct smb_filename *smb_fname)
412 if (smb_fname == NULL) {
415 status = get_full_smb_filename(do_log_ctx(), smb_fname, &fname);
416 if (!NT_STATUS_IS_OK(status)) {
423 * Return an fsp debug string using the do_log_ctx()
425 static const char *fsp_str_do_log(const struct files_struct *fsp)
427 return smb_fname_str_do_log(fsp->fsp_name);
430 /* Free function for the private data. */
432 static void free_private_data(void **p_data)
434 struct vfs_full_audit_private_data *pd = *(struct vfs_full_audit_private_data **)p_data;
436 if (pd->success_ops) {
437 bitmap_free(pd->success_ops);
439 if (pd->failure_ops) {
440 bitmap_free(pd->failure_ops);
446 /* Implementation of vfs_ops. Pass everything on to the default
447 operation but log event first. */
449 static int smb_full_audit_connect(vfs_handle_struct *handle,
450 const char *svc, const char *user)
453 struct vfs_full_audit_private_data *pd = NULL;
454 const char *none[] = { NULL };
455 const char *all [] = { "all" };
461 pd = SMB_MALLOC_P(struct vfs_full_audit_private_data);
467 openlog("smbd_audit", 0, audit_syslog_facility(handle));
469 init_bitmap(&pd->success_ops,
470 lp_parm_string_list(SNUM(handle->conn), "full_audit", "success",
472 init_bitmap(&pd->failure_ops,
473 lp_parm_string_list(SNUM(handle->conn), "full_audit", "failure",
476 /* Store the private data. */
477 SMB_VFS_HANDLE_SET_DATA(handle, pd, free_private_data,
478 struct vfs_full_audit_private_data, return -1);
480 result = SMB_VFS_NEXT_CONNECT(handle, svc, user);
482 do_log(SMB_VFS_OP_CONNECT, True, handle,
488 static void smb_full_audit_disconnect(vfs_handle_struct *handle)
490 SMB_VFS_NEXT_DISCONNECT(handle);
492 do_log(SMB_VFS_OP_DISCONNECT, True, handle,
493 "%s", lp_servicename(SNUM(handle->conn)));
495 /* The bitmaps will be disconnected when the private
501 static uint64_t smb_full_audit_disk_free(vfs_handle_struct *handle,
503 bool small_query, uint64_t *bsize,
504 uint64_t *dfree, uint64_t *dsize)
508 result = SMB_VFS_NEXT_DISK_FREE(handle, path, small_query, bsize,
511 /* Don't have a reasonable notion of failure here */
513 do_log(SMB_VFS_OP_DISK_FREE, True, handle, "%s", path);
518 static int smb_full_audit_get_quota(struct vfs_handle_struct *handle,
519 enum SMB_QUOTA_TYPE qtype, unid_t id,
524 result = SMB_VFS_NEXT_GET_QUOTA(handle, qtype, id, qt);
526 do_log(SMB_VFS_OP_GET_QUOTA, (result >= 0), handle, "");
532 static int smb_full_audit_set_quota(struct vfs_handle_struct *handle,
533 enum SMB_QUOTA_TYPE qtype, unid_t id,
538 result = SMB_VFS_NEXT_SET_QUOTA(handle, qtype, id, qt);
540 do_log(SMB_VFS_OP_SET_QUOTA, (result >= 0), handle, "");
545 static int smb_full_audit_get_shadow_copy_data(struct vfs_handle_struct *handle,
546 struct files_struct *fsp,
547 SHADOW_COPY_DATA *shadow_copy_data, bool labels)
551 result = SMB_VFS_NEXT_GET_SHADOW_COPY_DATA(handle, fsp, shadow_copy_data, labels);
553 do_log(SMB_VFS_OP_GET_SHADOW_COPY_DATA, (result >= 0), handle, "");
558 static int smb_full_audit_statvfs(struct vfs_handle_struct *handle,
560 struct vfs_statvfs_struct *statbuf)
564 result = SMB_VFS_NEXT_STATVFS(handle, path, statbuf);
566 do_log(SMB_VFS_OP_STATVFS, (result >= 0), handle, "");
571 static uint32_t smb_full_audit_fs_capabilities(struct vfs_handle_struct *handle)
575 result = SMB_VFS_NEXT_FS_CAPABILITIES(handle);
577 do_log(SMB_VFS_OP_FS_CAPABILITIES, true, handle, "");
582 static SMB_STRUCT_DIR *smb_full_audit_opendir(vfs_handle_struct *handle,
583 const char *fname, const char *mask, uint32 attr)
585 SMB_STRUCT_DIR *result;
587 result = SMB_VFS_NEXT_OPENDIR(handle, fname, mask, attr);
589 do_log(SMB_VFS_OP_OPENDIR, (result != NULL), handle, "%s", fname);
594 static SMB_STRUCT_DIRENT *smb_full_audit_readdir(vfs_handle_struct *handle,
595 SMB_STRUCT_DIR *dirp, SMB_STRUCT_STAT *sbuf)
597 SMB_STRUCT_DIRENT *result;
599 result = SMB_VFS_NEXT_READDIR(handle, dirp, sbuf);
601 /* This operation has no reasonable error condition
602 * (End of dir is also failure), so always succeed.
604 do_log(SMB_VFS_OP_READDIR, True, handle, "");
609 static void smb_full_audit_seekdir(vfs_handle_struct *handle,
610 SMB_STRUCT_DIR *dirp, long offset)
612 SMB_VFS_NEXT_SEEKDIR(handle, dirp, offset);
614 do_log(SMB_VFS_OP_SEEKDIR, True, handle, "");
618 static long smb_full_audit_telldir(vfs_handle_struct *handle,
619 SMB_STRUCT_DIR *dirp)
623 result = SMB_VFS_NEXT_TELLDIR(handle, dirp);
625 do_log(SMB_VFS_OP_TELLDIR, True, handle, "");
630 static void smb_full_audit_rewinddir(vfs_handle_struct *handle,
631 SMB_STRUCT_DIR *dirp)
633 SMB_VFS_NEXT_REWINDDIR(handle, dirp);
635 do_log(SMB_VFS_OP_REWINDDIR, True, handle, "");
639 static int smb_full_audit_mkdir(vfs_handle_struct *handle,
640 const char *path, mode_t mode)
644 result = SMB_VFS_NEXT_MKDIR(handle, path, mode);
646 do_log(SMB_VFS_OP_MKDIR, (result >= 0), handle, "%s", path);
651 static int smb_full_audit_rmdir(vfs_handle_struct *handle,
656 result = SMB_VFS_NEXT_RMDIR(handle, path);
658 do_log(SMB_VFS_OP_RMDIR, (result >= 0), handle, "%s", path);
663 static int smb_full_audit_closedir(vfs_handle_struct *handle,
664 SMB_STRUCT_DIR *dirp)
668 result = SMB_VFS_NEXT_CLOSEDIR(handle, dirp);
670 do_log(SMB_VFS_OP_CLOSEDIR, (result >= 0), handle, "");
675 static void smb_full_audit_init_search_op(vfs_handle_struct *handle,
676 SMB_STRUCT_DIR *dirp)
678 SMB_VFS_NEXT_INIT_SEARCH_OP(handle, dirp);
680 do_log(SMB_VFS_OP_INIT_SEARCH_OP, True, handle, "");
684 static int smb_full_audit_open(vfs_handle_struct *handle,
685 struct smb_filename *smb_fname,
686 files_struct *fsp, int flags, mode_t mode)
690 result = SMB_VFS_NEXT_OPEN(handle, smb_fname, fsp, flags, mode);
692 do_log(SMB_VFS_OP_OPEN, (result >= 0), handle, "%s|%s",
693 ((flags & O_WRONLY) || (flags & O_RDWR))?"w":"r",
694 smb_fname_str_do_log(smb_fname));
699 static NTSTATUS smb_full_audit_create_file(vfs_handle_struct *handle,
700 struct smb_request *req,
701 uint16_t root_dir_fid,
702 struct smb_filename *smb_fname,
703 uint32_t access_mask,
704 uint32_t share_access,
705 uint32_t create_disposition,
706 uint32_t create_options,
707 uint32_t file_attributes,
708 uint32_t oplock_request,
709 uint64_t allocation_size,
710 struct security_descriptor *sd,
711 struct ea_list *ea_list,
712 files_struct **result_fsp,
717 result = SMB_VFS_NEXT_CREATE_FILE(
720 root_dir_fid, /* root_dir_fid */
721 smb_fname, /* fname */
722 access_mask, /* access_mask */
723 share_access, /* share_access */
724 create_disposition, /* create_disposition*/
725 create_options, /* create_options */
726 file_attributes, /* file_attributes */
727 oplock_request, /* oplock_request */
728 allocation_size, /* allocation_size */
730 ea_list, /* ea_list */
731 result_fsp, /* result */
734 do_log(SMB_VFS_OP_CREATE_FILE, (NT_STATUS_IS_OK(result)), handle, "0x%x|%s",
735 access_mask, smb_fname_str_do_log(smb_fname));
740 static int smb_full_audit_close(vfs_handle_struct *handle, files_struct *fsp)
744 result = SMB_VFS_NEXT_CLOSE(handle, fsp);
746 do_log(SMB_VFS_OP_CLOSE, (result >= 0), handle, "%s",
747 fsp_str_do_log(fsp));
752 static ssize_t smb_full_audit_read(vfs_handle_struct *handle, files_struct *fsp,
753 void *data, size_t n)
757 result = SMB_VFS_NEXT_READ(handle, fsp, data, n);
759 do_log(SMB_VFS_OP_READ, (result >= 0), handle, "%s",
760 fsp_str_do_log(fsp));
765 static ssize_t smb_full_audit_pread(vfs_handle_struct *handle, files_struct *fsp,
766 void *data, size_t n, SMB_OFF_T offset)
770 result = SMB_VFS_NEXT_PREAD(handle, fsp, data, n, offset);
772 do_log(SMB_VFS_OP_PREAD, (result >= 0), handle, "%s",
773 fsp_str_do_log(fsp));
778 static ssize_t smb_full_audit_write(vfs_handle_struct *handle, files_struct *fsp,
779 const void *data, size_t n)
783 result = SMB_VFS_NEXT_WRITE(handle, fsp, data, n);
785 do_log(SMB_VFS_OP_WRITE, (result >= 0), handle, "%s",
786 fsp_str_do_log(fsp));
791 static ssize_t smb_full_audit_pwrite(vfs_handle_struct *handle, files_struct *fsp,
792 const void *data, size_t n,
797 result = SMB_VFS_NEXT_PWRITE(handle, fsp, data, n, offset);
799 do_log(SMB_VFS_OP_PWRITE, (result >= 0), handle, "%s",
800 fsp_str_do_log(fsp));
805 static SMB_OFF_T smb_full_audit_lseek(vfs_handle_struct *handle, files_struct *fsp,
806 SMB_OFF_T offset, int whence)
810 result = SMB_VFS_NEXT_LSEEK(handle, fsp, offset, whence);
812 do_log(SMB_VFS_OP_LSEEK, (result != (ssize_t)-1), handle,
813 "%s", fsp_str_do_log(fsp));
818 static ssize_t smb_full_audit_sendfile(vfs_handle_struct *handle, int tofd,
819 files_struct *fromfsp,
820 const DATA_BLOB *hdr, SMB_OFF_T offset,
825 result = SMB_VFS_NEXT_SENDFILE(handle, tofd, fromfsp, hdr, offset, n);
827 do_log(SMB_VFS_OP_SENDFILE, (result >= 0), handle,
828 "%s", fsp_str_do_log(fromfsp));
833 static ssize_t smb_full_audit_recvfile(vfs_handle_struct *handle, int fromfd,
840 result = SMB_VFS_NEXT_RECVFILE(handle, fromfd, tofsp, offset, n);
842 do_log(SMB_VFS_OP_RECVFILE, (result >= 0), handle,
843 "%s", fsp_str_do_log(tofsp));
848 static int smb_full_audit_rename(vfs_handle_struct *handle,
849 const struct smb_filename *smb_fname_src,
850 const struct smb_filename *smb_fname_dst)
854 result = SMB_VFS_NEXT_RENAME(handle, smb_fname_src, smb_fname_dst);
856 do_log(SMB_VFS_OP_RENAME, (result >= 0), handle, "%s|%s",
857 smb_fname_str_do_log(smb_fname_src),
858 smb_fname_str_do_log(smb_fname_dst));
863 static int smb_full_audit_fsync(vfs_handle_struct *handle, files_struct *fsp)
867 result = SMB_VFS_NEXT_FSYNC(handle, fsp);
869 do_log(SMB_VFS_OP_FSYNC, (result >= 0), handle, "%s",
870 fsp_str_do_log(fsp));
875 static int smb_full_audit_stat(vfs_handle_struct *handle,
876 struct smb_filename *smb_fname)
880 result = SMB_VFS_NEXT_STAT(handle, smb_fname);
882 do_log(SMB_VFS_OP_STAT, (result >= 0), handle, "%s",
883 smb_fname_str_do_log(smb_fname));
888 static int smb_full_audit_fstat(vfs_handle_struct *handle, files_struct *fsp,
889 SMB_STRUCT_STAT *sbuf)
893 result = SMB_VFS_NEXT_FSTAT(handle, fsp, sbuf);
895 do_log(SMB_VFS_OP_FSTAT, (result >= 0), handle, "%s",
896 fsp_str_do_log(fsp));
901 static int smb_full_audit_lstat(vfs_handle_struct *handle,
902 struct smb_filename *smb_fname)
906 result = SMB_VFS_NEXT_LSTAT(handle, smb_fname);
908 do_log(SMB_VFS_OP_LSTAT, (result >= 0), handle, "%s",
909 smb_fname_str_do_log(smb_fname));
914 static uint64_t smb_full_audit_get_alloc_size(vfs_handle_struct *handle,
915 files_struct *fsp, const SMB_STRUCT_STAT *sbuf)
919 result = SMB_VFS_NEXT_GET_ALLOC_SIZE(handle, fsp, sbuf);
921 do_log(SMB_VFS_OP_GET_ALLOC_SIZE, (result >= 0), handle, "%d", result);
926 static int smb_full_audit_unlink(vfs_handle_struct *handle,
927 const struct smb_filename *smb_fname)
931 result = SMB_VFS_NEXT_UNLINK(handle, smb_fname);
933 do_log(SMB_VFS_OP_UNLINK, (result >= 0), handle, "%s",
934 smb_fname_str_do_log(smb_fname));
939 static int smb_full_audit_chmod(vfs_handle_struct *handle,
940 const char *path, mode_t mode)
944 result = SMB_VFS_NEXT_CHMOD(handle, path, mode);
946 do_log(SMB_VFS_OP_CHMOD, (result >= 0), handle, "%s|%o", path, mode);
951 static int smb_full_audit_fchmod(vfs_handle_struct *handle, files_struct *fsp,
956 result = SMB_VFS_NEXT_FCHMOD(handle, fsp, mode);
958 do_log(SMB_VFS_OP_FCHMOD, (result >= 0), handle,
959 "%s|%o", fsp_str_do_log(fsp), mode);
964 static int smb_full_audit_chown(vfs_handle_struct *handle,
965 const char *path, uid_t uid, gid_t gid)
969 result = SMB_VFS_NEXT_CHOWN(handle, path, uid, gid);
971 do_log(SMB_VFS_OP_CHOWN, (result >= 0), handle, "%s|%ld|%ld",
972 path, (long int)uid, (long int)gid);
977 static int smb_full_audit_fchown(vfs_handle_struct *handle, files_struct *fsp,
978 uid_t uid, gid_t gid)
982 result = SMB_VFS_NEXT_FCHOWN(handle, fsp, uid, gid);
984 do_log(SMB_VFS_OP_FCHOWN, (result >= 0), handle, "%s|%ld|%ld",
985 fsp_str_do_log(fsp), (long int)uid, (long int)gid);
990 static int smb_full_audit_lchown(vfs_handle_struct *handle,
991 const char *path, uid_t uid, gid_t gid)
995 result = SMB_VFS_NEXT_LCHOWN(handle, path, uid, gid);
997 do_log(SMB_VFS_OP_LCHOWN, (result >= 0), handle, "%s|%ld|%ld",
998 path, (long int)uid, (long int)gid);
1003 static int smb_full_audit_chdir(vfs_handle_struct *handle,
1008 result = SMB_VFS_NEXT_CHDIR(handle, path);
1010 do_log(SMB_VFS_OP_CHDIR, (result >= 0), handle, "chdir|%s", path);
1015 static char *smb_full_audit_getwd(vfs_handle_struct *handle,
1020 result = SMB_VFS_NEXT_GETWD(handle, path);
1022 do_log(SMB_VFS_OP_GETWD, (result != NULL), handle, "%s", path);
1027 static int smb_full_audit_ntimes(vfs_handle_struct *handle,
1028 const struct smb_filename *smb_fname,
1029 struct smb_file_time *ft)
1033 result = SMB_VFS_NEXT_NTIMES(handle, smb_fname, ft);
1035 do_log(SMB_VFS_OP_NTIMES, (result >= 0), handle, "%s",
1036 smb_fname_str_do_log(smb_fname));
1041 static int smb_full_audit_ftruncate(vfs_handle_struct *handle, files_struct *fsp,
1046 result = SMB_VFS_NEXT_FTRUNCATE(handle, fsp, len);
1048 do_log(SMB_VFS_OP_FTRUNCATE, (result >= 0), handle,
1049 "%s", fsp_str_do_log(fsp));
1054 static bool smb_full_audit_lock(vfs_handle_struct *handle, files_struct *fsp,
1055 int op, SMB_OFF_T offset, SMB_OFF_T count, int type)
1059 result = SMB_VFS_NEXT_LOCK(handle, fsp, op, offset, count, type);
1061 do_log(SMB_VFS_OP_LOCK, result, handle, "%s", fsp_str_do_log(fsp));
1066 static int smb_full_audit_kernel_flock(struct vfs_handle_struct *handle,
1067 struct files_struct *fsp,
1072 result = SMB_VFS_NEXT_KERNEL_FLOCK(handle, fsp, share_mode);
1074 do_log(SMB_VFS_OP_KERNEL_FLOCK, (result >= 0), handle, "%s",
1075 fsp_str_do_log(fsp));
1080 static int smb_full_audit_linux_setlease(vfs_handle_struct *handle, files_struct *fsp,
1085 result = SMB_VFS_NEXT_LINUX_SETLEASE(handle, fsp, leasetype);
1087 do_log(SMB_VFS_OP_LINUX_SETLEASE, (result >= 0), handle, "%s",
1088 fsp_str_do_log(fsp));
1093 static bool smb_full_audit_getlock(vfs_handle_struct *handle, files_struct *fsp,
1094 SMB_OFF_T *poffset, SMB_OFF_T *pcount, int *ptype, pid_t *ppid)
1098 result = SMB_VFS_NEXT_GETLOCK(handle, fsp, poffset, pcount, ptype, ppid);
1100 do_log(SMB_VFS_OP_GETLOCK, result, handle, "%s", fsp_str_do_log(fsp));
1105 static int smb_full_audit_symlink(vfs_handle_struct *handle,
1106 const char *oldpath, const char *newpath)
1110 result = SMB_VFS_NEXT_SYMLINK(handle, oldpath, newpath);
1112 do_log(SMB_VFS_OP_SYMLINK, (result >= 0), handle,
1113 "%s|%s", oldpath, newpath);
1118 static int smb_full_audit_readlink(vfs_handle_struct *handle,
1119 const char *path, char *buf, size_t bufsiz)
1123 result = SMB_VFS_NEXT_READLINK(handle, path, buf, bufsiz);
1125 do_log(SMB_VFS_OP_READLINK, (result >= 0), handle, "%s", path);
1130 static int smb_full_audit_link(vfs_handle_struct *handle,
1131 const char *oldpath, const char *newpath)
1135 result = SMB_VFS_NEXT_LINK(handle, oldpath, newpath);
1137 do_log(SMB_VFS_OP_LINK, (result >= 0), handle,
1138 "%s|%s", oldpath, newpath);
1143 static int smb_full_audit_mknod(vfs_handle_struct *handle,
1144 const char *pathname, mode_t mode, SMB_DEV_T dev)
1148 result = SMB_VFS_NEXT_MKNOD(handle, pathname, mode, dev);
1150 do_log(SMB_VFS_OP_MKNOD, (result >= 0), handle, "%s", pathname);
1155 static char *smb_full_audit_realpath(vfs_handle_struct *handle,
1156 const char *path, char *resolved_path)
1160 result = SMB_VFS_NEXT_REALPATH(handle, path, resolved_path);
1162 do_log(SMB_VFS_OP_REALPATH, (result != NULL), handle, "%s", path);
1167 static NTSTATUS smb_full_audit_notify_watch(struct vfs_handle_struct *handle,
1168 struct sys_notify_context *ctx,
1169 struct notify_entry *e,
1170 void (*callback)(struct sys_notify_context *ctx,
1172 struct notify_event *ev),
1173 void *private_data, void *handle_p)
1177 result = SMB_VFS_NEXT_NOTIFY_WATCH(handle, ctx, e, callback, private_data, handle_p);
1179 do_log(SMB_VFS_OP_NOTIFY_WATCH, NT_STATUS_IS_OK(result), handle, "");
1184 static int smb_full_audit_chflags(vfs_handle_struct *handle,
1185 const char *path, unsigned int flags)
1189 result = SMB_VFS_NEXT_CHFLAGS(handle, path, flags);
1191 do_log(SMB_VFS_OP_CHFLAGS, (result != 0), handle, "%s", path);
1196 static struct file_id smb_full_audit_file_id_create(struct vfs_handle_struct *handle,
1197 const SMB_STRUCT_STAT *sbuf)
1199 struct file_id id_zero;
1200 struct file_id result;
1202 ZERO_STRUCT(id_zero);
1204 result = SMB_VFS_NEXT_FILE_ID_CREATE(handle, sbuf);
1206 do_log(SMB_VFS_OP_FILE_ID_CREATE,
1207 !file_id_equal(&id_zero, &result),
1208 handle, "%s", file_id_string_tos(&result));
1213 static NTSTATUS smb_full_audit_streaminfo(vfs_handle_struct *handle,
1214 struct files_struct *fsp,
1216 TALLOC_CTX *mem_ctx,
1217 unsigned int *pnum_streams,
1218 struct stream_struct **pstreams)
1222 result = SMB_VFS_NEXT_STREAMINFO(handle, fsp, fname, mem_ctx,
1223 pnum_streams, pstreams);
1225 do_log(SMB_VFS_OP_STREAMINFO, NT_STATUS_IS_OK(result), handle,
1231 static int smb_full_audit_get_real_filename(struct vfs_handle_struct *handle,
1234 TALLOC_CTX *mem_ctx,
1239 result = SMB_VFS_NEXT_GET_REAL_FILENAME(handle, path, name, mem_ctx,
1242 do_log(SMB_VFS_OP_GET_REAL_FILENAME, (result == 0), handle,
1243 "%s/%s->%s", path, name, (result == 0) ? "" : *found_name);
1248 static const char *smb_full_audit_connectpath(vfs_handle_struct *handle,
1253 result = SMB_VFS_NEXT_CONNECTPATH(handle, fname);
1255 do_log(SMB_VFS_OP_CONNECTPATH, result != NULL, handle,
1261 static NTSTATUS smb_full_audit_brl_lock_windows(struct vfs_handle_struct *handle,
1262 struct byte_range_lock *br_lck,
1263 struct lock_struct *plock,
1265 struct blocking_lock_record *blr)
1269 result = SMB_VFS_NEXT_BRL_LOCK_WINDOWS(handle, br_lck, plock,
1270 blocking_lock, blr);
1272 do_log(SMB_VFS_OP_BRL_LOCK_WINDOWS, NT_STATUS_IS_OK(result), handle,
1273 "%s:%llu-%llu. type=%d. blocking=%d", fsp_str_do_log(br_lck->fsp),
1274 plock->start, plock->size, plock->lock_type, blocking_lock );
1279 static bool smb_full_audit_brl_unlock_windows(struct vfs_handle_struct *handle,
1280 struct messaging_context *msg_ctx,
1281 struct byte_range_lock *br_lck,
1282 const struct lock_struct *plock)
1286 result = SMB_VFS_NEXT_BRL_UNLOCK_WINDOWS(handle, msg_ctx, br_lck,
1289 do_log(SMB_VFS_OP_BRL_UNLOCK_WINDOWS, (result == 0), handle,
1290 "%s:%llu-%llu:%d", fsp_str_do_log(br_lck->fsp), plock->start,
1291 plock->size, plock->lock_type);
1296 static bool smb_full_audit_brl_cancel_windows(struct vfs_handle_struct *handle,
1297 struct byte_range_lock *br_lck,
1298 struct lock_struct *plock,
1299 struct blocking_lock_record *blr)
1303 result = SMB_VFS_NEXT_BRL_CANCEL_WINDOWS(handle, br_lck, plock, blr);
1305 do_log(SMB_VFS_OP_BRL_CANCEL_WINDOWS, (result == 0), handle,
1306 "%s:%llu-%llu:%d", fsp_str_do_log(br_lck->fsp), plock->start,
1312 static bool smb_full_audit_strict_lock(struct vfs_handle_struct *handle,
1313 struct files_struct *fsp,
1314 struct lock_struct *plock)
1318 result = SMB_VFS_NEXT_STRICT_LOCK(handle, fsp, plock);
1320 do_log(SMB_VFS_OP_STRICT_LOCK, result, handle,
1321 "%s:%llu-%llu:%d", fsp_str_do_log(fsp), plock->start,
1327 static void smb_full_audit_strict_unlock(struct vfs_handle_struct *handle,
1328 struct files_struct *fsp,
1329 struct lock_struct *plock)
1331 SMB_VFS_NEXT_STRICT_UNLOCK(handle, fsp, plock);
1333 do_log(SMB_VFS_OP_STRICT_UNLOCK, true, handle,
1334 "%s:%llu-%llu:%d", fsp_str_do_log(fsp), plock->start,
1340 static NTSTATUS smb_full_audit_fget_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
1341 uint32 security_info,
1346 result = SMB_VFS_NEXT_FGET_NT_ACL(handle, fsp, security_info, ppdesc);
1348 do_log(SMB_VFS_OP_FGET_NT_ACL, NT_STATUS_IS_OK(result), handle,
1349 "%s", fsp_str_do_log(fsp));
1354 static NTSTATUS smb_full_audit_get_nt_acl(vfs_handle_struct *handle,
1356 uint32 security_info,
1361 result = SMB_VFS_NEXT_GET_NT_ACL(handle, name, security_info, ppdesc);
1363 do_log(SMB_VFS_OP_GET_NT_ACL, NT_STATUS_IS_OK(result), handle,
1369 static NTSTATUS smb_full_audit_fset_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
1370 uint32 security_info_sent,
1371 const SEC_DESC *psd)
1375 result = SMB_VFS_NEXT_FSET_NT_ACL(handle, fsp, security_info_sent, psd);
1377 do_log(SMB_VFS_OP_FSET_NT_ACL, NT_STATUS_IS_OK(result), handle, "%s",
1378 fsp_str_do_log(fsp));
1383 static int smb_full_audit_chmod_acl(vfs_handle_struct *handle,
1384 const char *path, mode_t mode)
1388 result = SMB_VFS_NEXT_CHMOD_ACL(handle, path, mode);
1390 do_log(SMB_VFS_OP_CHMOD_ACL, (result >= 0), handle,
1391 "%s|%o", path, mode);
1396 static int smb_full_audit_fchmod_acl(vfs_handle_struct *handle, files_struct *fsp,
1401 result = SMB_VFS_NEXT_FCHMOD_ACL(handle, fsp, mode);
1403 do_log(SMB_VFS_OP_FCHMOD_ACL, (result >= 0), handle,
1404 "%s|%o", fsp_str_do_log(fsp), mode);
1409 static int smb_full_audit_sys_acl_get_entry(vfs_handle_struct *handle,
1411 SMB_ACL_T theacl, int entry_id,
1412 SMB_ACL_ENTRY_T *entry_p)
1416 result = SMB_VFS_NEXT_SYS_ACL_GET_ENTRY(handle, theacl, entry_id,
1419 do_log(SMB_VFS_OP_SYS_ACL_GET_ENTRY, (result >= 0), handle,
1425 static int smb_full_audit_sys_acl_get_tag_type(vfs_handle_struct *handle,
1427 SMB_ACL_ENTRY_T entry_d,
1428 SMB_ACL_TAG_T *tag_type_p)
1432 result = SMB_VFS_NEXT_SYS_ACL_GET_TAG_TYPE(handle, entry_d,
1435 do_log(SMB_VFS_OP_SYS_ACL_GET_TAG_TYPE, (result >= 0), handle,
1441 static int smb_full_audit_sys_acl_get_permset(vfs_handle_struct *handle,
1443 SMB_ACL_ENTRY_T entry_d,
1444 SMB_ACL_PERMSET_T *permset_p)
1448 result = SMB_VFS_NEXT_SYS_ACL_GET_PERMSET(handle, entry_d,
1451 do_log(SMB_VFS_OP_SYS_ACL_GET_PERMSET, (result >= 0), handle,
1457 static void * smb_full_audit_sys_acl_get_qualifier(vfs_handle_struct *handle,
1459 SMB_ACL_ENTRY_T entry_d)
1463 result = SMB_VFS_NEXT_SYS_ACL_GET_QUALIFIER(handle, entry_d);
1465 do_log(SMB_VFS_OP_SYS_ACL_GET_QUALIFIER, (result != NULL), handle,
1471 static SMB_ACL_T smb_full_audit_sys_acl_get_file(vfs_handle_struct *handle,
1473 SMB_ACL_TYPE_T type)
1477 result = SMB_VFS_NEXT_SYS_ACL_GET_FILE(handle, path_p, type);
1479 do_log(SMB_VFS_OP_SYS_ACL_GET_FILE, (result != NULL), handle,
1485 static SMB_ACL_T smb_full_audit_sys_acl_get_fd(vfs_handle_struct *handle,
1490 result = SMB_VFS_NEXT_SYS_ACL_GET_FD(handle, fsp);
1492 do_log(SMB_VFS_OP_SYS_ACL_GET_FD, (result != NULL), handle,
1493 "%s", fsp_str_do_log(fsp));
1498 static int smb_full_audit_sys_acl_clear_perms(vfs_handle_struct *handle,
1500 SMB_ACL_PERMSET_T permset)
1504 result = SMB_VFS_NEXT_SYS_ACL_CLEAR_PERMS(handle, permset);
1506 do_log(SMB_VFS_OP_SYS_ACL_CLEAR_PERMS, (result >= 0), handle,
1512 static int smb_full_audit_sys_acl_add_perm(vfs_handle_struct *handle,
1514 SMB_ACL_PERMSET_T permset,
1515 SMB_ACL_PERM_T perm)
1519 result = SMB_VFS_NEXT_SYS_ACL_ADD_PERM(handle, permset, perm);
1521 do_log(SMB_VFS_OP_SYS_ACL_ADD_PERM, (result >= 0), handle,
1527 static char * smb_full_audit_sys_acl_to_text(vfs_handle_struct *handle,
1533 result = SMB_VFS_NEXT_SYS_ACL_TO_TEXT(handle, theacl, plen);
1535 do_log(SMB_VFS_OP_SYS_ACL_TO_TEXT, (result != NULL), handle,
1541 static SMB_ACL_T smb_full_audit_sys_acl_init(vfs_handle_struct *handle,
1547 result = SMB_VFS_NEXT_SYS_ACL_INIT(handle, count);
1549 do_log(SMB_VFS_OP_SYS_ACL_INIT, (result != NULL), handle,
1555 static int smb_full_audit_sys_acl_create_entry(vfs_handle_struct *handle,
1557 SMB_ACL_ENTRY_T *pentry)
1561 result = SMB_VFS_NEXT_SYS_ACL_CREATE_ENTRY(handle, pacl, pentry);
1563 do_log(SMB_VFS_OP_SYS_ACL_CREATE_ENTRY, (result >= 0), handle,
1569 static int smb_full_audit_sys_acl_set_tag_type(vfs_handle_struct *handle,
1571 SMB_ACL_ENTRY_T entry,
1572 SMB_ACL_TAG_T tagtype)
1576 result = SMB_VFS_NEXT_SYS_ACL_SET_TAG_TYPE(handle, entry,
1579 do_log(SMB_VFS_OP_SYS_ACL_SET_TAG_TYPE, (result >= 0), handle,
1585 static int smb_full_audit_sys_acl_set_qualifier(vfs_handle_struct *handle,
1587 SMB_ACL_ENTRY_T entry,
1592 result = SMB_VFS_NEXT_SYS_ACL_SET_QUALIFIER(handle, entry, qual);
1594 do_log(SMB_VFS_OP_SYS_ACL_SET_QUALIFIER, (result >= 0), handle,
1600 static int smb_full_audit_sys_acl_set_permset(vfs_handle_struct *handle,
1602 SMB_ACL_ENTRY_T entry,
1603 SMB_ACL_PERMSET_T permset)
1607 result = SMB_VFS_NEXT_SYS_ACL_SET_PERMSET(handle, entry, permset);
1609 do_log(SMB_VFS_OP_SYS_ACL_SET_PERMSET, (result >= 0), handle,
1615 static int smb_full_audit_sys_acl_valid(vfs_handle_struct *handle,
1621 result = SMB_VFS_NEXT_SYS_ACL_VALID(handle, theacl);
1623 do_log(SMB_VFS_OP_SYS_ACL_VALID, (result >= 0), handle,
1629 static int smb_full_audit_sys_acl_set_file(vfs_handle_struct *handle,
1631 const char *name, SMB_ACL_TYPE_T acltype,
1636 result = SMB_VFS_NEXT_SYS_ACL_SET_FILE(handle, name, acltype,
1639 do_log(SMB_VFS_OP_SYS_ACL_SET_FILE, (result >= 0), handle,
1645 static int smb_full_audit_sys_acl_set_fd(vfs_handle_struct *handle, files_struct *fsp,
1650 result = SMB_VFS_NEXT_SYS_ACL_SET_FD(handle, fsp, theacl);
1652 do_log(SMB_VFS_OP_SYS_ACL_SET_FD, (result >= 0), handle,
1653 "%s", fsp_str_do_log(fsp));
1658 static int smb_full_audit_sys_acl_delete_def_file(vfs_handle_struct *handle,
1664 result = SMB_VFS_NEXT_SYS_ACL_DELETE_DEF_FILE(handle, path);
1666 do_log(SMB_VFS_OP_SYS_ACL_DELETE_DEF_FILE, (result >= 0), handle,
1672 static int smb_full_audit_sys_acl_get_perm(vfs_handle_struct *handle,
1674 SMB_ACL_PERMSET_T permset,
1675 SMB_ACL_PERM_T perm)
1679 result = SMB_VFS_NEXT_SYS_ACL_GET_PERM(handle, permset, perm);
1681 do_log(SMB_VFS_OP_SYS_ACL_GET_PERM, (result >= 0), handle,
1687 static int smb_full_audit_sys_acl_free_text(vfs_handle_struct *handle,
1693 result = SMB_VFS_NEXT_SYS_ACL_FREE_TEXT(handle, text);
1695 do_log(SMB_VFS_OP_SYS_ACL_FREE_TEXT, (result >= 0), handle,
1701 static int smb_full_audit_sys_acl_free_acl(vfs_handle_struct *handle,
1703 SMB_ACL_T posix_acl)
1707 result = SMB_VFS_NEXT_SYS_ACL_FREE_ACL(handle, posix_acl);
1709 do_log(SMB_VFS_OP_SYS_ACL_FREE_ACL, (result >= 0), handle,
1715 static int smb_full_audit_sys_acl_free_qualifier(vfs_handle_struct *handle,
1717 SMB_ACL_TAG_T tagtype)
1721 result = SMB_VFS_NEXT_SYS_ACL_FREE_QUALIFIER(handle, qualifier,
1724 do_log(SMB_VFS_OP_SYS_ACL_FREE_QUALIFIER, (result >= 0), handle,
1730 static ssize_t smb_full_audit_getxattr(struct vfs_handle_struct *handle,
1732 const char *name, void *value, size_t size)
1736 result = SMB_VFS_NEXT_GETXATTR(handle, path, name, value, size);
1738 do_log(SMB_VFS_OP_GETXATTR, (result >= 0), handle,
1739 "%s|%s", path, name);
1744 static ssize_t smb_full_audit_lgetxattr(struct vfs_handle_struct *handle,
1745 const char *path, const char *name,
1746 void *value, size_t size)
1750 result = SMB_VFS_NEXT_LGETXATTR(handle, path, name, value, size);
1752 do_log(SMB_VFS_OP_LGETXATTR, (result >= 0), handle,
1753 "%s|%s", path, name);
1758 static ssize_t smb_full_audit_fgetxattr(struct vfs_handle_struct *handle,
1759 struct files_struct *fsp,
1760 const char *name, void *value, size_t size)
1764 result = SMB_VFS_NEXT_FGETXATTR(handle, fsp, name, value, size);
1766 do_log(SMB_VFS_OP_FGETXATTR, (result >= 0), handle,
1767 "%s|%s", fsp_str_do_log(fsp), name);
1772 static ssize_t smb_full_audit_listxattr(struct vfs_handle_struct *handle,
1773 const char *path, char *list, size_t size)
1777 result = SMB_VFS_NEXT_LISTXATTR(handle, path, list, size);
1779 do_log(SMB_VFS_OP_LISTXATTR, (result >= 0), handle, "%s", path);
1784 static ssize_t smb_full_audit_llistxattr(struct vfs_handle_struct *handle,
1785 const char *path, char *list, size_t size)
1789 result = SMB_VFS_NEXT_LLISTXATTR(handle, path, list, size);
1791 do_log(SMB_VFS_OP_LLISTXATTR, (result >= 0), handle, "%s", path);
1796 static ssize_t smb_full_audit_flistxattr(struct vfs_handle_struct *handle,
1797 struct files_struct *fsp, char *list,
1802 result = SMB_VFS_NEXT_FLISTXATTR(handle, fsp, list, size);
1804 do_log(SMB_VFS_OP_FLISTXATTR, (result >= 0), handle,
1805 "%s", fsp_str_do_log(fsp));
1810 static int smb_full_audit_removexattr(struct vfs_handle_struct *handle,
1816 result = SMB_VFS_NEXT_REMOVEXATTR(handle, path, name);
1818 do_log(SMB_VFS_OP_REMOVEXATTR, (result >= 0), handle,
1819 "%s|%s", path, name);
1824 static int smb_full_audit_lremovexattr(struct vfs_handle_struct *handle,
1830 result = SMB_VFS_NEXT_LREMOVEXATTR(handle, path, name);
1832 do_log(SMB_VFS_OP_LREMOVEXATTR, (result >= 0), handle,
1833 "%s|%s", path, name);
1838 static int smb_full_audit_fremovexattr(struct vfs_handle_struct *handle,
1839 struct files_struct *fsp,
1844 result = SMB_VFS_NEXT_FREMOVEXATTR(handle, fsp, name);
1846 do_log(SMB_VFS_OP_FREMOVEXATTR, (result >= 0), handle,
1847 "%s|%s", fsp_str_do_log(fsp), name);
1852 static int smb_full_audit_setxattr(struct vfs_handle_struct *handle,
1854 const char *name, const void *value, size_t size,
1859 result = SMB_VFS_NEXT_SETXATTR(handle, path, name, value, size,
1862 do_log(SMB_VFS_OP_SETXATTR, (result >= 0), handle,
1863 "%s|%s", path, name);
1868 static int smb_full_audit_lsetxattr(struct vfs_handle_struct *handle,
1870 const char *name, const void *value, size_t size,
1875 result = SMB_VFS_NEXT_LSETXATTR(handle, path, name, value, size,
1878 do_log(SMB_VFS_OP_LSETXATTR, (result >= 0), handle,
1879 "%s|%s", path, name);
1884 static int smb_full_audit_fsetxattr(struct vfs_handle_struct *handle,
1885 struct files_struct *fsp, const char *name,
1886 const void *value, size_t size, int flags)
1890 result = SMB_VFS_NEXT_FSETXATTR(handle, fsp, name, value, size, flags);
1892 do_log(SMB_VFS_OP_FSETXATTR, (result >= 0), handle,
1893 "%s|%s", fsp_str_do_log(fsp), name);
1898 static int smb_full_audit_aio_read(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb)
1902 result = SMB_VFS_NEXT_AIO_READ(handle, fsp, aiocb);
1903 do_log(SMB_VFS_OP_AIO_READ, (result >= 0), handle,
1904 "%s", fsp_str_do_log(fsp));
1909 static int smb_full_audit_aio_write(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb)
1913 result = SMB_VFS_NEXT_AIO_WRITE(handle, fsp, aiocb);
1914 do_log(SMB_VFS_OP_AIO_WRITE, (result >= 0), handle,
1915 "%s", fsp_str_do_log(fsp));
1920 static ssize_t smb_full_audit_aio_return(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb)
1924 result = SMB_VFS_NEXT_AIO_RETURN(handle, fsp, aiocb);
1925 do_log(SMB_VFS_OP_AIO_RETURN, (result >= 0), handle,
1926 "%s", fsp_str_do_log(fsp));
1931 static int smb_full_audit_aio_cancel(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb)
1935 result = SMB_VFS_NEXT_AIO_CANCEL(handle, fsp, aiocb);
1936 do_log(SMB_VFS_OP_AIO_CANCEL, (result >= 0), handle,
1937 "%s", fsp_str_do_log(fsp));
1942 static int smb_full_audit_aio_error(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb)
1946 result = SMB_VFS_NEXT_AIO_ERROR(handle, fsp, aiocb);
1947 do_log(SMB_VFS_OP_AIO_ERROR, (result >= 0), handle,
1948 "%s", fsp_str_do_log(fsp));
1953 static int smb_full_audit_aio_fsync(struct vfs_handle_struct *handle, struct files_struct *fsp, int op, SMB_STRUCT_AIOCB *aiocb)
1957 result = SMB_VFS_NEXT_AIO_FSYNC(handle, fsp, op, aiocb);
1958 do_log(SMB_VFS_OP_AIO_FSYNC, (result >= 0), handle,
1959 "%s", fsp_str_do_log(fsp));
1964 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)
1968 result = SMB_VFS_NEXT_AIO_SUSPEND(handle, fsp, aiocb, n, ts);
1969 do_log(SMB_VFS_OP_AIO_SUSPEND, (result >= 0), handle,
1970 "%s", fsp_str_do_log(fsp));
1975 static bool smb_full_audit_aio_force(struct vfs_handle_struct *handle,
1976 struct files_struct *fsp)
1980 result = SMB_VFS_NEXT_AIO_FORCE(handle, fsp);
1981 do_log(SMB_VFS_OP_AIO_FORCE, result, handle,
1982 "%s", fsp_str_do_log(fsp));
1987 static struct vfs_fn_pointers vfs_full_audit_fns = {
1989 /* Disk operations */
1991 .connect_fn = smb_full_audit_connect,
1992 .disconnect = smb_full_audit_disconnect,
1993 .disk_free = smb_full_audit_disk_free,
1994 .get_quota = smb_full_audit_get_quota,
1995 .set_quota = smb_full_audit_set_quota,
1996 .get_shadow_copy_data = smb_full_audit_get_shadow_copy_data,
1997 .statvfs = smb_full_audit_statvfs,
1998 .fs_capabilities = smb_full_audit_fs_capabilities,
1999 .opendir = smb_full_audit_opendir,
2000 .readdir = smb_full_audit_readdir,
2001 .seekdir = smb_full_audit_seekdir,
2002 .telldir = smb_full_audit_telldir,
2003 .rewind_dir = smb_full_audit_rewinddir,
2004 .mkdir = smb_full_audit_mkdir,
2005 .rmdir = smb_full_audit_rmdir,
2006 .closedir = smb_full_audit_closedir,
2007 .init_search_op = smb_full_audit_init_search_op,
2008 .open = smb_full_audit_open,
2009 .create_file = smb_full_audit_create_file,
2010 .close_fn = smb_full_audit_close,
2011 .vfs_read = smb_full_audit_read,
2012 .pread = smb_full_audit_pread,
2013 .write = smb_full_audit_write,
2014 .pwrite = smb_full_audit_pwrite,
2015 .lseek = smb_full_audit_lseek,
2016 .sendfile = smb_full_audit_sendfile,
2017 .recvfile = smb_full_audit_recvfile,
2018 .rename = smb_full_audit_rename,
2019 .fsync = smb_full_audit_fsync,
2020 .stat = smb_full_audit_stat,
2021 .fstat = smb_full_audit_fstat,
2022 .lstat = smb_full_audit_lstat,
2023 .get_alloc_size = smb_full_audit_get_alloc_size,
2024 .unlink = smb_full_audit_unlink,
2025 .chmod = smb_full_audit_chmod,
2026 .fchmod = smb_full_audit_fchmod,
2027 .chown = smb_full_audit_chown,
2028 .fchown = smb_full_audit_fchown,
2029 .lchown = smb_full_audit_lchown,
2030 .chdir = smb_full_audit_chdir,
2031 .getwd = smb_full_audit_getwd,
2032 .ntimes = smb_full_audit_ntimes,
2033 .ftruncate = smb_full_audit_ftruncate,
2034 .lock = smb_full_audit_lock,
2035 .kernel_flock = smb_full_audit_kernel_flock,
2036 .linux_setlease = smb_full_audit_linux_setlease,
2037 .getlock = smb_full_audit_getlock,
2038 .symlink = smb_full_audit_symlink,
2039 .vfs_readlink = smb_full_audit_readlink,
2040 .link = smb_full_audit_link,
2041 .mknod = smb_full_audit_mknod,
2042 .realpath = smb_full_audit_realpath,
2043 .notify_watch = smb_full_audit_notify_watch,
2044 .chflags = smb_full_audit_chflags,
2045 .file_id_create = smb_full_audit_file_id_create,
2046 .streaminfo = smb_full_audit_streaminfo,
2047 .get_real_filename = smb_full_audit_get_real_filename,
2048 .connectpath = smb_full_audit_connectpath,
2049 .brl_lock_windows = smb_full_audit_brl_lock_windows,
2050 .brl_unlock_windows = smb_full_audit_brl_unlock_windows,
2051 .brl_cancel_windows = smb_full_audit_brl_cancel_windows,
2052 .strict_lock = smb_full_audit_strict_lock,
2053 .strict_unlock = smb_full_audit_strict_unlock,
2054 .fget_nt_acl = smb_full_audit_fget_nt_acl,
2055 .get_nt_acl = smb_full_audit_get_nt_acl,
2056 .fset_nt_acl = smb_full_audit_fset_nt_acl,
2057 .chmod_acl = smb_full_audit_chmod_acl,
2058 .fchmod_acl = smb_full_audit_fchmod_acl,
2059 .sys_acl_get_entry = smb_full_audit_sys_acl_get_entry,
2060 .sys_acl_get_tag_type = smb_full_audit_sys_acl_get_tag_type,
2061 .sys_acl_get_permset = smb_full_audit_sys_acl_get_permset,
2062 .sys_acl_get_qualifier = smb_full_audit_sys_acl_get_qualifier,
2063 .sys_acl_get_file = smb_full_audit_sys_acl_get_file,
2064 .sys_acl_get_fd = smb_full_audit_sys_acl_get_fd,
2065 .sys_acl_clear_perms = smb_full_audit_sys_acl_clear_perms,
2066 .sys_acl_add_perm = smb_full_audit_sys_acl_add_perm,
2067 .sys_acl_to_text = smb_full_audit_sys_acl_to_text,
2068 .sys_acl_init = smb_full_audit_sys_acl_init,
2069 .sys_acl_create_entry = smb_full_audit_sys_acl_create_entry,
2070 .sys_acl_set_tag_type = smb_full_audit_sys_acl_set_tag_type,
2071 .sys_acl_set_qualifier = smb_full_audit_sys_acl_set_qualifier,
2072 .sys_acl_set_permset = smb_full_audit_sys_acl_set_permset,
2073 .sys_acl_valid = smb_full_audit_sys_acl_valid,
2074 .sys_acl_set_file = smb_full_audit_sys_acl_set_file,
2075 .sys_acl_set_fd = smb_full_audit_sys_acl_set_fd,
2076 .sys_acl_delete_def_file = smb_full_audit_sys_acl_delete_def_file,
2077 .sys_acl_get_perm = smb_full_audit_sys_acl_get_perm,
2078 .sys_acl_free_text = smb_full_audit_sys_acl_free_text,
2079 .sys_acl_free_acl = smb_full_audit_sys_acl_free_acl,
2080 .sys_acl_free_qualifier = smb_full_audit_sys_acl_free_qualifier,
2081 .getxattr = smb_full_audit_getxattr,
2082 .lgetxattr = smb_full_audit_lgetxattr,
2083 .fgetxattr = smb_full_audit_fgetxattr,
2084 .listxattr = smb_full_audit_listxattr,
2085 .llistxattr = smb_full_audit_llistxattr,
2086 .flistxattr = smb_full_audit_flistxattr,
2087 .removexattr = smb_full_audit_removexattr,
2088 .lremovexattr = smb_full_audit_lremovexattr,
2089 .fremovexattr = smb_full_audit_fremovexattr,
2090 .setxattr = smb_full_audit_setxattr,
2091 .lsetxattr = smb_full_audit_lsetxattr,
2092 .fsetxattr = smb_full_audit_fsetxattr,
2093 .aio_read = smb_full_audit_aio_read,
2094 .aio_write = smb_full_audit_aio_write,
2095 .aio_return_fn = smb_full_audit_aio_return,
2096 .aio_cancel = smb_full_audit_aio_cancel,
2097 .aio_error_fn = smb_full_audit_aio_error,
2098 .aio_fsync = smb_full_audit_aio_fsync,
2099 .aio_suspend = smb_full_audit_aio_suspend,
2100 .aio_force = smb_full_audit_aio_force,
2103 NTSTATUS vfs_full_audit_init(void)
2105 NTSTATUS ret = smb_register_vfs(SMB_VFS_INTERFACE_VERSION,
2106 "full_audit", &vfs_full_audit_fns);
2108 if (!NT_STATUS_IS_OK(ret))
2111 vfs_full_audit_debug_level = debug_add_class("full_audit");
2112 if (vfs_full_audit_debug_level == -1) {
2113 vfs_full_audit_debug_level = DBGC_VFS;
2114 DEBUG(0, ("vfs_full_audit: Couldn't register custom debugging "
2117 DEBUG(10, ("vfs_full_audit: Debug class number of "
2118 "'full_audit': %d\n", vfs_full_audit_debug_level));