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.
61 #include "system/filesys.h"
62 #include "system/syslog.h"
63 #include "smbd/smbd.h"
64 #include "../librpc/gen_ndr/ndr_netlogon.h"
67 #include "lib/param/loadparm.h"
68 #include "lib/util/bitmap.h"
69 #include "lib/util/tevent_unix.h"
70 #include "libcli/security/sddl.h"
71 #include "passdb/machine_sid.h"
73 static int vfs_full_audit_debug_level = DBGC_VFS;
75 struct vfs_full_audit_private_data {
76 struct bitmap *success_ops;
77 struct bitmap *failure_ops;
85 #define DBGC_CLASS vfs_full_audit_debug_level
87 typedef enum _vfs_op_type {
92 SMB_VFS_OP_CONNECT = 0,
93 SMB_VFS_OP_DISCONNECT,
97 SMB_VFS_OP_GET_SHADOW_COPY_DATA,
99 SMB_VFS_OP_FS_CAPABILITIES,
100 SMB_VFS_OP_GET_DFS_REFERRALS,
102 /* Directory operations */
105 SMB_VFS_OP_FDOPENDIR,
109 SMB_VFS_OP_REWINDDIR,
113 SMB_VFS_OP_INIT_SEARCH_OP,
115 /* File operations */
118 SMB_VFS_OP_CREATE_FILE,
122 SMB_VFS_OP_PREAD_SEND,
123 SMB_VFS_OP_PREAD_RECV,
126 SMB_VFS_OP_PWRITE_SEND,
127 SMB_VFS_OP_PWRITE_RECV,
133 SMB_VFS_OP_FSYNC_SEND,
134 SMB_VFS_OP_FSYNC_RECV,
138 SMB_VFS_OP_GET_ALLOC_SIZE,
148 SMB_VFS_OP_FTRUNCATE,
149 SMB_VFS_OP_FALLOCATE,
151 SMB_VFS_OP_KERNEL_FLOCK,
152 SMB_VFS_OP_LINUX_SETLEASE,
160 SMB_VFS_OP_FILE_ID_CREATE,
161 SMB_VFS_OP_STREAMINFO,
162 SMB_VFS_OP_GET_REAL_FILENAME,
163 SMB_VFS_OP_CONNECTPATH,
164 SMB_VFS_OP_BRL_LOCK_WINDOWS,
165 SMB_VFS_OP_BRL_UNLOCK_WINDOWS,
166 SMB_VFS_OP_BRL_CANCEL_WINDOWS,
167 SMB_VFS_OP_STRICT_LOCK,
168 SMB_VFS_OP_STRICT_UNLOCK,
169 SMB_VFS_OP_TRANSLATE_NAME,
171 SMB_VFS_OP_OFFLOAD_READ_SEND,
172 SMB_VFS_OP_OFFLOAD_READ_RECV,
173 SMB_VFS_OP_OFFLOAD_WRITE_SEND,
174 SMB_VFS_OP_OFFLOAD_WRITE_RECV,
175 SMB_VFS_OP_GET_COMPRESSION,
176 SMB_VFS_OP_SET_COMPRESSION,
177 SMB_VFS_OP_SNAP_CHECK_PATH,
178 SMB_VFS_OP_SNAP_CREATE,
179 SMB_VFS_OP_SNAP_DELETE,
181 /* DOS attribute operations. */
182 SMB_VFS_OP_GET_DOS_ATTRIBUTES,
183 SMB_VFS_OP_FGET_DOS_ATTRIBUTES,
184 SMB_VFS_OP_SET_DOS_ATTRIBUTES,
185 SMB_VFS_OP_FSET_DOS_ATTRIBUTES,
187 /* NT ACL operations. */
189 SMB_VFS_OP_FGET_NT_ACL,
190 SMB_VFS_OP_GET_NT_ACL,
191 SMB_VFS_OP_FSET_NT_ACL,
192 SMB_VFS_OP_AUDIT_FILE,
194 /* POSIX ACL operations. */
196 SMB_VFS_OP_CHMOD_ACL,
197 SMB_VFS_OP_FCHMOD_ACL,
199 SMB_VFS_OP_SYS_ACL_GET_FILE,
200 SMB_VFS_OP_SYS_ACL_GET_FD,
201 SMB_VFS_OP_SYS_ACL_BLOB_GET_FILE,
202 SMB_VFS_OP_SYS_ACL_BLOB_GET_FD,
203 SMB_VFS_OP_SYS_ACL_SET_FILE,
204 SMB_VFS_OP_SYS_ACL_SET_FD,
205 SMB_VFS_OP_SYS_ACL_DELETE_DEF_FILE,
209 SMB_VFS_OP_FGETXATTR,
210 SMB_VFS_OP_LISTXATTR,
211 SMB_VFS_OP_FLISTXATTR,
212 SMB_VFS_OP_REMOVEXATTR,
213 SMB_VFS_OP_FREMOVEXATTR,
215 SMB_VFS_OP_FSETXATTR,
218 SMB_VFS_OP_AIO_FORCE,
220 /* offline operations */
221 SMB_VFS_OP_IS_OFFLINE,
222 SMB_VFS_OP_SET_OFFLINE,
224 /* Durable handle operations. */
225 SMB_VFS_OP_DURABLE_COOKIE,
226 SMB_VFS_OP_DURABLE_DISCONNECT,
227 SMB_VFS_OP_DURABLE_RECONNECT,
229 SMB_VFS_OP_READDIR_ATTR,
231 /* This should always be last enum value */
236 /* The following array *must* be in the same order as defined in vfs_op_type */
242 { SMB_VFS_OP_CONNECT, "connect" },
243 { SMB_VFS_OP_DISCONNECT, "disconnect" },
244 { SMB_VFS_OP_DISK_FREE, "disk_free" },
245 { SMB_VFS_OP_GET_QUOTA, "get_quota" },
246 { SMB_VFS_OP_SET_QUOTA, "set_quota" },
247 { SMB_VFS_OP_GET_SHADOW_COPY_DATA, "get_shadow_copy_data" },
248 { SMB_VFS_OP_STATVFS, "statvfs" },
249 { SMB_VFS_OP_FS_CAPABILITIES, "fs_capabilities" },
250 { SMB_VFS_OP_GET_DFS_REFERRALS, "get_dfs_referrals" },
251 { SMB_VFS_OP_OPENDIR, "opendir" },
252 { SMB_VFS_OP_FDOPENDIR, "fdopendir" },
253 { SMB_VFS_OP_READDIR, "readdir" },
254 { SMB_VFS_OP_SEEKDIR, "seekdir" },
255 { SMB_VFS_OP_TELLDIR, "telldir" },
256 { SMB_VFS_OP_REWINDDIR, "rewinddir" },
257 { SMB_VFS_OP_MKDIR, "mkdir" },
258 { SMB_VFS_OP_RMDIR, "rmdir" },
259 { SMB_VFS_OP_CLOSEDIR, "closedir" },
260 { SMB_VFS_OP_INIT_SEARCH_OP, "init_search_op" },
261 { SMB_VFS_OP_OPEN, "open" },
262 { SMB_VFS_OP_CREATE_FILE, "create_file" },
263 { SMB_VFS_OP_CLOSE, "close" },
264 { SMB_VFS_OP_READ, "read" },
265 { SMB_VFS_OP_PREAD, "pread" },
266 { SMB_VFS_OP_PREAD_SEND, "pread_send" },
267 { SMB_VFS_OP_PREAD_RECV, "pread_recv" },
268 { SMB_VFS_OP_WRITE, "write" },
269 { SMB_VFS_OP_PWRITE, "pwrite" },
270 { SMB_VFS_OP_PWRITE_SEND, "pwrite_send" },
271 { SMB_VFS_OP_PWRITE_RECV, "pwrite_recv" },
272 { SMB_VFS_OP_LSEEK, "lseek" },
273 { SMB_VFS_OP_SENDFILE, "sendfile" },
274 { SMB_VFS_OP_RECVFILE, "recvfile" },
275 { SMB_VFS_OP_RENAME, "rename" },
276 { SMB_VFS_OP_FSYNC, "fsync" },
277 { SMB_VFS_OP_FSYNC_SEND, "fsync_send" },
278 { SMB_VFS_OP_FSYNC_RECV, "fsync_recv" },
279 { SMB_VFS_OP_STAT, "stat" },
280 { SMB_VFS_OP_FSTAT, "fstat" },
281 { SMB_VFS_OP_LSTAT, "lstat" },
282 { SMB_VFS_OP_GET_ALLOC_SIZE, "get_alloc_size" },
283 { SMB_VFS_OP_UNLINK, "unlink" },
284 { SMB_VFS_OP_CHMOD, "chmod" },
285 { SMB_VFS_OP_FCHMOD, "fchmod" },
286 { SMB_VFS_OP_CHOWN, "chown" },
287 { SMB_VFS_OP_FCHOWN, "fchown" },
288 { SMB_VFS_OP_LCHOWN, "lchown" },
289 { SMB_VFS_OP_CHDIR, "chdir" },
290 { SMB_VFS_OP_GETWD, "getwd" },
291 { SMB_VFS_OP_NTIMES, "ntimes" },
292 { SMB_VFS_OP_FTRUNCATE, "ftruncate" },
293 { SMB_VFS_OP_FALLOCATE,"fallocate" },
294 { SMB_VFS_OP_LOCK, "lock" },
295 { SMB_VFS_OP_KERNEL_FLOCK, "kernel_flock" },
296 { SMB_VFS_OP_LINUX_SETLEASE, "linux_setlease" },
297 { SMB_VFS_OP_GETLOCK, "getlock" },
298 { SMB_VFS_OP_SYMLINK, "symlink" },
299 { SMB_VFS_OP_READLINK, "readlink" },
300 { SMB_VFS_OP_LINK, "link" },
301 { SMB_VFS_OP_MKNOD, "mknod" },
302 { SMB_VFS_OP_REALPATH, "realpath" },
303 { SMB_VFS_OP_CHFLAGS, "chflags" },
304 { SMB_VFS_OP_FILE_ID_CREATE, "file_id_create" },
305 { SMB_VFS_OP_STREAMINFO, "streaminfo" },
306 { SMB_VFS_OP_GET_REAL_FILENAME, "get_real_filename" },
307 { SMB_VFS_OP_CONNECTPATH, "connectpath" },
308 { SMB_VFS_OP_BRL_LOCK_WINDOWS, "brl_lock_windows" },
309 { SMB_VFS_OP_BRL_UNLOCK_WINDOWS, "brl_unlock_windows" },
310 { SMB_VFS_OP_BRL_CANCEL_WINDOWS, "brl_cancel_windows" },
311 { SMB_VFS_OP_STRICT_LOCK, "strict_lock" },
312 { SMB_VFS_OP_STRICT_UNLOCK, "strict_unlock" },
313 { SMB_VFS_OP_TRANSLATE_NAME, "translate_name" },
314 { SMB_VFS_OP_FSCTL, "fsctl" },
315 { SMB_VFS_OP_OFFLOAD_READ_SEND, "offload_read_send" },
316 { SMB_VFS_OP_OFFLOAD_READ_RECV, "offload_read_recv" },
317 { SMB_VFS_OP_OFFLOAD_WRITE_SEND, "offload_write_send" },
318 { SMB_VFS_OP_OFFLOAD_WRITE_RECV, "offload_write_recv" },
319 { SMB_VFS_OP_GET_COMPRESSION, "get_compression" },
320 { SMB_VFS_OP_SET_COMPRESSION, "set_compression" },
321 { SMB_VFS_OP_SNAP_CHECK_PATH, "snap_check_path" },
322 { SMB_VFS_OP_SNAP_CREATE, "snap_create" },
323 { SMB_VFS_OP_SNAP_DELETE, "snap_delete" },
324 { SMB_VFS_OP_GET_DOS_ATTRIBUTES, "get_dos_attributes" },
325 { SMB_VFS_OP_FGET_DOS_ATTRIBUTES, "fget_dos_attributes" },
326 { SMB_VFS_OP_SET_DOS_ATTRIBUTES, "set_dos_attributes" },
327 { SMB_VFS_OP_FSET_DOS_ATTRIBUTES, "fset_dos_attributes" },
328 { SMB_VFS_OP_FGET_NT_ACL, "fget_nt_acl" },
329 { SMB_VFS_OP_GET_NT_ACL, "get_nt_acl" },
330 { SMB_VFS_OP_FSET_NT_ACL, "fset_nt_acl" },
331 { SMB_VFS_OP_AUDIT_FILE, "audit_file" },
332 { SMB_VFS_OP_CHMOD_ACL, "chmod_acl" },
333 { SMB_VFS_OP_FCHMOD_ACL, "fchmod_acl" },
334 { SMB_VFS_OP_SYS_ACL_GET_FILE, "sys_acl_get_file" },
335 { SMB_VFS_OP_SYS_ACL_GET_FD, "sys_acl_get_fd" },
336 { SMB_VFS_OP_SYS_ACL_BLOB_GET_FILE, "sys_acl_blob_get_file" },
337 { SMB_VFS_OP_SYS_ACL_BLOB_GET_FD, "sys_acl_blob_get_fd" },
338 { SMB_VFS_OP_SYS_ACL_SET_FILE, "sys_acl_set_file" },
339 { SMB_VFS_OP_SYS_ACL_SET_FD, "sys_acl_set_fd" },
340 { SMB_VFS_OP_SYS_ACL_DELETE_DEF_FILE, "sys_acl_delete_def_file" },
341 { SMB_VFS_OP_GETXATTR, "getxattr" },
342 { SMB_VFS_OP_FGETXATTR, "fgetxattr" },
343 { SMB_VFS_OP_LISTXATTR, "listxattr" },
344 { SMB_VFS_OP_FLISTXATTR, "flistxattr" },
345 { SMB_VFS_OP_REMOVEXATTR, "removexattr" },
346 { SMB_VFS_OP_FREMOVEXATTR, "fremovexattr" },
347 { SMB_VFS_OP_SETXATTR, "setxattr" },
348 { SMB_VFS_OP_FSETXATTR, "fsetxattr" },
349 { SMB_VFS_OP_AIO_FORCE, "aio_force" },
350 { SMB_VFS_OP_IS_OFFLINE, "is_offline" },
351 { SMB_VFS_OP_SET_OFFLINE, "set_offline" },
352 { SMB_VFS_OP_DURABLE_COOKIE, "durable_cookie" },
353 { SMB_VFS_OP_DURABLE_DISCONNECT, "durable_disconnect" },
354 { SMB_VFS_OP_DURABLE_RECONNECT, "durable_reconnect" },
355 { SMB_VFS_OP_READDIR_ATTR, "readdir_attr" },
356 { SMB_VFS_OP_LAST, NULL }
359 static int audit_syslog_facility(vfs_handle_struct *handle)
361 static const struct enum_list enum_log_facilities[] = {
362 { LOG_USER, "USER" },
363 { LOG_LOCAL0, "LOCAL0" },
364 { LOG_LOCAL1, "LOCAL1" },
365 { LOG_LOCAL2, "LOCAL2" },
366 { LOG_LOCAL3, "LOCAL3" },
367 { LOG_LOCAL4, "LOCAL4" },
368 { LOG_LOCAL5, "LOCAL5" },
369 { LOG_LOCAL6, "LOCAL6" },
370 { LOG_LOCAL7, "LOCAL7" },
376 facility = lp_parm_enum(SNUM(handle->conn), "full_audit", "facility", enum_log_facilities, LOG_USER);
381 static int audit_syslog_priority(vfs_handle_struct *handle)
383 static const struct enum_list enum_log_priorities[] = {
384 { LOG_EMERG, "EMERG" },
385 { LOG_ALERT, "ALERT" },
386 { LOG_CRIT, "CRIT" },
388 { LOG_WARNING, "WARNING" },
389 { LOG_NOTICE, "NOTICE" },
390 { LOG_INFO, "INFO" },
391 { LOG_DEBUG, "DEBUG" },
397 priority = lp_parm_enum(SNUM(handle->conn), "full_audit", "priority",
398 enum_log_priorities, LOG_NOTICE);
399 if (priority == -1) {
400 priority = LOG_WARNING;
406 static char *audit_prefix(TALLOC_CTX *ctx, connection_struct *conn)
411 prefix = talloc_strdup(ctx,
412 lp_parm_const_string(SNUM(conn), "full_audit",
417 result = talloc_sub_advanced(ctx,
418 lp_servicename(talloc_tos(), SNUM(conn)),
419 conn->session_info->unix_info->unix_name,
421 conn->session_info->unix_token->gid,
422 conn->session_info->unix_info->sanitized_username,
423 conn->session_info->info->domain_name,
429 static bool log_success(struct vfs_full_audit_private_data *pd, vfs_op_type op)
431 if (pd->success_ops == NULL) {
435 return bitmap_query(pd->success_ops, op);
438 static bool log_failure(struct vfs_full_audit_private_data *pd, vfs_op_type op)
440 if (pd->failure_ops == NULL)
443 return bitmap_query(pd->failure_ops, op);
446 static struct bitmap *init_bitmap(TALLOC_CTX *mem_ctx, const char **ops)
454 bm = bitmap_talloc(mem_ctx, SMB_VFS_OP_LAST);
456 DEBUG(0, ("Could not alloc bitmap -- "
457 "defaulting to logging everything\n"));
461 for (; *ops != NULL; ops += 1) {
466 if (strequal(*ops, "all")) {
467 for (i=0; i<SMB_VFS_OP_LAST; i++) {
473 if (strequal(*ops, "none")) {
483 for (i=0; i<SMB_VFS_OP_LAST; i++) {
484 if ((vfs_op_names[i].name == NULL)
485 || (vfs_op_names[i].type != i)) {
486 smb_panic("vfs_full_audit.c: name table not "
487 "in sync with vfs_op_type enums\n");
489 if (strequal(op, vfs_op_names[i].name)) {
498 if (i == SMB_VFS_OP_LAST) {
499 DEBUG(0, ("Could not find opname %s, logging all\n",
508 static const char *audit_opname(vfs_op_type op)
510 if (op >= SMB_VFS_OP_LAST)
511 return "INVALID VFS OP";
512 return vfs_op_names[op].name;
515 static TALLOC_CTX *tmp_do_log_ctx;
517 * Get us a temporary talloc context usable just for DEBUG arguments
519 static TALLOC_CTX *do_log_ctx(void)
521 if (tmp_do_log_ctx == NULL) {
522 tmp_do_log_ctx = talloc_named_const(NULL, 0, "do_log_ctx");
524 return tmp_do_log_ctx;
527 static void do_log(vfs_op_type op, bool success, vfs_handle_struct *handle,
528 const char *format, ...)
530 struct vfs_full_audit_private_data *pd;
532 char *audit_pre = NULL;
536 SMB_VFS_HANDLE_GET_DATA(handle, pd,
537 struct vfs_full_audit_private_data,
540 if (success && (!log_success(pd, op)))
543 if (!success && (!log_failure(pd, op)))
547 fstrcpy(err_msg, "ok");
549 fstr_sprintf(err_msg, "fail (%s)", strerror(errno));
551 va_start(ap, format);
552 op_msg = talloc_vasprintf(talloc_tos(), format, ap);
559 audit_pre = audit_prefix(talloc_tos(), handle->conn);
565 * Specify the facility to interoperate with other syslog
566 * callers (smbd for example).
568 priority = pd->syslog_priority | pd->syslog_facility;
570 syslog(priority, "%s|%s|%s|%s\n",
571 audit_pre ? audit_pre : "",
572 audit_opname(op), err_msg, op_msg);
574 DEBUG(1, ("%s|%s|%s|%s\n",
575 audit_pre ? audit_pre : "",
576 audit_opname(op), err_msg, op_msg));
579 TALLOC_FREE(audit_pre);
581 TALLOC_FREE(tmp_do_log_ctx);
585 * Return a string using the do_log_ctx()
587 static const char *smb_fname_str_do_log(const struct smb_filename *smb_fname)
592 if (smb_fname == NULL) {
595 status = get_full_smb_filename(do_log_ctx(), smb_fname, &fname);
596 if (!NT_STATUS_IS_OK(status)) {
603 * Return an fsp debug string using the do_log_ctx()
605 static const char *fsp_str_do_log(const struct files_struct *fsp)
607 return smb_fname_str_do_log(fsp->fsp_name);
610 /* Implementation of vfs_ops. Pass everything on to the default
611 operation but log event first. */
613 static int smb_full_audit_connect(vfs_handle_struct *handle,
614 const char *svc, const char *user)
617 struct vfs_full_audit_private_data *pd = NULL;
619 result = SMB_VFS_NEXT_CONNECT(handle, svc, user);
624 pd = talloc_zero(handle, struct vfs_full_audit_private_data);
626 SMB_VFS_NEXT_DISCONNECT(handle);
630 pd->syslog_facility = audit_syslog_facility(handle);
631 if (pd->syslog_facility == -1) {
632 DEBUG(1, ("%s: Unknown facility %s\n", __func__,
633 lp_parm_const_string(SNUM(handle->conn),
634 "full_audit", "facility",
636 SMB_VFS_NEXT_DISCONNECT(handle);
640 pd->syslog_priority = audit_syslog_priority(handle);
642 pd->log_secdesc = lp_parm_bool(SNUM(handle->conn),
643 "full_audit", "log_secdesc", false);
645 pd->do_syslog = lp_parm_bool(SNUM(handle->conn),
646 "full_audit", "syslog", true);
650 openlog("smbd_audit", 0, pd->syslog_facility);
654 pd->success_ops = init_bitmap(
655 pd, lp_parm_string_list(SNUM(handle->conn), "full_audit",
657 pd->failure_ops = init_bitmap(
658 pd, lp_parm_string_list(SNUM(handle->conn), "full_audit",
661 /* Store the private data. */
662 SMB_VFS_HANDLE_SET_DATA(handle, pd, NULL,
663 struct vfs_full_audit_private_data, return -1);
665 do_log(SMB_VFS_OP_CONNECT, True, handle,
671 static void smb_full_audit_disconnect(vfs_handle_struct *handle)
673 SMB_VFS_NEXT_DISCONNECT(handle);
675 do_log(SMB_VFS_OP_DISCONNECT, True, handle,
676 "%s", lp_servicename(talloc_tos(), SNUM(handle->conn)));
678 /* The bitmaps will be disconnected when the private
682 static uint64_t smb_full_audit_disk_free(vfs_handle_struct *handle,
683 const struct smb_filename *smb_fname,
690 result = SMB_VFS_NEXT_DISK_FREE(handle, smb_fname, bsize, dfree, dsize);
692 /* Don't have a reasonable notion of failure here */
694 do_log(SMB_VFS_OP_DISK_FREE, True, handle, "%s", smb_fname->base_name);
699 static int smb_full_audit_get_quota(struct vfs_handle_struct *handle,
700 const struct smb_filename *smb_fname,
701 enum SMB_QUOTA_TYPE qtype,
707 result = SMB_VFS_NEXT_GET_QUOTA(handle, smb_fname, qtype, id, qt);
709 do_log(SMB_VFS_OP_GET_QUOTA, (result >= 0), handle, "%s",
710 smb_fname->base_name);
715 static int smb_full_audit_set_quota(struct vfs_handle_struct *handle,
716 enum SMB_QUOTA_TYPE qtype, unid_t id,
721 result = SMB_VFS_NEXT_SET_QUOTA(handle, qtype, id, qt);
723 do_log(SMB_VFS_OP_SET_QUOTA, (result >= 0), handle, "");
728 static int smb_full_audit_get_shadow_copy_data(struct vfs_handle_struct *handle,
729 struct files_struct *fsp,
730 struct shadow_copy_data *shadow_copy_data,
735 result = SMB_VFS_NEXT_GET_SHADOW_COPY_DATA(handle, fsp, shadow_copy_data, labels);
737 do_log(SMB_VFS_OP_GET_SHADOW_COPY_DATA, (result >= 0), handle, "");
742 static int smb_full_audit_statvfs(struct vfs_handle_struct *handle,
743 const struct smb_filename *smb_fname,
744 struct vfs_statvfs_struct *statbuf)
748 result = SMB_VFS_NEXT_STATVFS(handle, smb_fname, statbuf);
750 do_log(SMB_VFS_OP_STATVFS, (result >= 0), handle, "");
755 static uint32_t smb_full_audit_fs_capabilities(struct vfs_handle_struct *handle, enum timestamp_set_resolution *p_ts_res)
759 result = SMB_VFS_NEXT_FS_CAPABILITIES(handle, p_ts_res);
761 do_log(SMB_VFS_OP_FS_CAPABILITIES, true, handle, "");
766 static NTSTATUS smb_full_audit_get_dfs_referrals(
767 struct vfs_handle_struct *handle,
768 struct dfs_GetDFSReferral *r)
772 status = SMB_VFS_NEXT_GET_DFS_REFERRALS(handle, r);
774 do_log(SMB_VFS_OP_GET_DFS_REFERRALS, NT_STATUS_IS_OK(status),
780 static NTSTATUS smb_full_audit_snap_check_path(struct vfs_handle_struct *handle,
782 const char *service_path,
787 status = SMB_VFS_NEXT_SNAP_CHECK_PATH(handle, mem_ctx, service_path,
789 do_log(SMB_VFS_OP_SNAP_CHECK_PATH, NT_STATUS_IS_OK(status),
795 static NTSTATUS smb_full_audit_snap_create(struct vfs_handle_struct *handle,
797 const char *base_volume,
805 status = SMB_VFS_NEXT_SNAP_CREATE(handle, mem_ctx, base_volume, tstamp,
806 rw, base_path, snap_path);
807 do_log(SMB_VFS_OP_SNAP_CREATE, NT_STATUS_IS_OK(status), handle, "");
812 static NTSTATUS smb_full_audit_snap_delete(struct vfs_handle_struct *handle,
819 status = SMB_VFS_NEXT_SNAP_DELETE(handle, mem_ctx, base_path,
821 do_log(SMB_VFS_OP_SNAP_DELETE, NT_STATUS_IS_OK(status), handle, "");
826 static DIR *smb_full_audit_opendir(vfs_handle_struct *handle,
827 const struct smb_filename *smb_fname,
833 result = SMB_VFS_NEXT_OPENDIR(handle, smb_fname, mask, attr);
835 do_log(SMB_VFS_OP_OPENDIR, (result != NULL), handle, "%s",
836 smb_fname->base_name);
841 static DIR *smb_full_audit_fdopendir(vfs_handle_struct *handle,
842 files_struct *fsp, const char *mask, uint32_t attr)
846 result = SMB_VFS_NEXT_FDOPENDIR(handle, fsp, mask, attr);
848 do_log(SMB_VFS_OP_FDOPENDIR, (result != NULL), handle, "%s",
849 fsp_str_do_log(fsp));
854 static struct dirent *smb_full_audit_readdir(vfs_handle_struct *handle,
855 DIR *dirp, SMB_STRUCT_STAT *sbuf)
857 struct dirent *result;
859 result = SMB_VFS_NEXT_READDIR(handle, dirp, sbuf);
861 /* This operation has no reasonable error condition
862 * (End of dir is also failure), so always succeed.
864 do_log(SMB_VFS_OP_READDIR, True, handle, "");
869 static void smb_full_audit_seekdir(vfs_handle_struct *handle,
870 DIR *dirp, long offset)
872 SMB_VFS_NEXT_SEEKDIR(handle, dirp, offset);
874 do_log(SMB_VFS_OP_SEEKDIR, True, handle, "");
877 static long smb_full_audit_telldir(vfs_handle_struct *handle,
882 result = SMB_VFS_NEXT_TELLDIR(handle, dirp);
884 do_log(SMB_VFS_OP_TELLDIR, True, handle, "");
889 static void smb_full_audit_rewinddir(vfs_handle_struct *handle,
892 SMB_VFS_NEXT_REWINDDIR(handle, dirp);
894 do_log(SMB_VFS_OP_REWINDDIR, True, handle, "");
897 static int smb_full_audit_mkdir(vfs_handle_struct *handle,
898 const struct smb_filename *smb_fname, mode_t mode)
902 result = SMB_VFS_NEXT_MKDIR(handle, smb_fname, mode);
904 do_log(SMB_VFS_OP_MKDIR, (result >= 0), handle, "%s",
905 smb_fname->base_name);
910 static int smb_full_audit_rmdir(vfs_handle_struct *handle,
911 const struct smb_filename *smb_fname)
915 result = SMB_VFS_NEXT_RMDIR(handle, smb_fname);
917 do_log(SMB_VFS_OP_RMDIR, (result >= 0), handle, "%s",
918 smb_fname->base_name);
923 static int smb_full_audit_closedir(vfs_handle_struct *handle,
928 result = SMB_VFS_NEXT_CLOSEDIR(handle, dirp);
930 do_log(SMB_VFS_OP_CLOSEDIR, (result >= 0), handle, "");
935 static void smb_full_audit_init_search_op(vfs_handle_struct *handle,
938 SMB_VFS_NEXT_INIT_SEARCH_OP(handle, dirp);
940 do_log(SMB_VFS_OP_INIT_SEARCH_OP, True, handle, "");
943 static int smb_full_audit_open(vfs_handle_struct *handle,
944 struct smb_filename *smb_fname,
945 files_struct *fsp, int flags, mode_t mode)
949 result = SMB_VFS_NEXT_OPEN(handle, smb_fname, fsp, flags, mode);
951 do_log(SMB_VFS_OP_OPEN, (result >= 0), handle, "%s|%s",
952 ((flags & O_WRONLY) || (flags & O_RDWR))?"w":"r",
953 smb_fname_str_do_log(smb_fname));
958 static NTSTATUS smb_full_audit_create_file(vfs_handle_struct *handle,
959 struct smb_request *req,
960 uint16_t root_dir_fid,
961 struct smb_filename *smb_fname,
962 uint32_t access_mask,
963 uint32_t share_access,
964 uint32_t create_disposition,
965 uint32_t create_options,
966 uint32_t file_attributes,
967 uint32_t oplock_request,
968 struct smb2_lease *lease,
969 uint64_t allocation_size,
970 uint32_t private_flags,
971 struct security_descriptor *sd,
972 struct ea_list *ea_list,
973 files_struct **result_fsp,
975 const struct smb2_create_blobs *in_context_blobs,
976 struct smb2_create_blobs *out_context_blobs)
979 const char* str_create_disposition;
981 switch (create_disposition) {
983 str_create_disposition = "supersede";
985 case FILE_OVERWRITE_IF:
986 str_create_disposition = "overwrite_if";
989 str_create_disposition = "open";
992 str_create_disposition = "overwrite";
995 str_create_disposition = "create";
998 str_create_disposition = "open_if";
1001 str_create_disposition = "unknown";
1004 result = SMB_VFS_NEXT_CREATE_FILE(
1005 handle, /* handle */
1007 root_dir_fid, /* root_dir_fid */
1008 smb_fname, /* fname */
1009 access_mask, /* access_mask */
1010 share_access, /* share_access */
1011 create_disposition, /* create_disposition*/
1012 create_options, /* create_options */
1013 file_attributes, /* file_attributes */
1014 oplock_request, /* oplock_request */
1016 allocation_size, /* allocation_size */
1019 ea_list, /* ea_list */
1020 result_fsp, /* result */
1022 in_context_blobs, out_context_blobs); /* create context */
1024 do_log(SMB_VFS_OP_CREATE_FILE, (NT_STATUS_IS_OK(result)), handle,
1025 "0x%x|%s|%s|%s", access_mask,
1026 create_options & FILE_DIRECTORY_FILE ? "dir" : "file",
1027 str_create_disposition, smb_fname_str_do_log(smb_fname));
1032 static int smb_full_audit_close(vfs_handle_struct *handle, files_struct *fsp)
1036 result = SMB_VFS_NEXT_CLOSE(handle, fsp);
1038 do_log(SMB_VFS_OP_CLOSE, (result >= 0), handle, "%s",
1039 fsp_str_do_log(fsp));
1044 static ssize_t smb_full_audit_read(vfs_handle_struct *handle, files_struct *fsp,
1045 void *data, size_t n)
1049 result = SMB_VFS_NEXT_READ(handle, fsp, data, n);
1051 do_log(SMB_VFS_OP_READ, (result >= 0), handle, "%s",
1052 fsp_str_do_log(fsp));
1057 static ssize_t smb_full_audit_pread(vfs_handle_struct *handle, files_struct *fsp,
1058 void *data, size_t n, off_t offset)
1062 result = SMB_VFS_NEXT_PREAD(handle, fsp, data, n, offset);
1064 do_log(SMB_VFS_OP_PREAD, (result >= 0), handle, "%s",
1065 fsp_str_do_log(fsp));
1070 struct smb_full_audit_pread_state {
1071 vfs_handle_struct *handle;
1074 struct vfs_aio_state vfs_aio_state;
1077 static void smb_full_audit_pread_done(struct tevent_req *subreq);
1079 static struct tevent_req *smb_full_audit_pread_send(
1080 struct vfs_handle_struct *handle, TALLOC_CTX *mem_ctx,
1081 struct tevent_context *ev, struct files_struct *fsp,
1082 void *data, size_t n, off_t offset)
1084 struct tevent_req *req, *subreq;
1085 struct smb_full_audit_pread_state *state;
1087 req = tevent_req_create(mem_ctx, &state,
1088 struct smb_full_audit_pread_state);
1090 do_log(SMB_VFS_OP_PREAD_SEND, false, handle, "%s",
1091 fsp_str_do_log(fsp));
1094 state->handle = handle;
1097 subreq = SMB_VFS_NEXT_PREAD_SEND(state, ev, handle, fsp, data,
1099 if (tevent_req_nomem(subreq, req)) {
1100 do_log(SMB_VFS_OP_PREAD_SEND, false, handle, "%s",
1101 fsp_str_do_log(fsp));
1102 return tevent_req_post(req, ev);
1104 tevent_req_set_callback(subreq, smb_full_audit_pread_done, req);
1106 do_log(SMB_VFS_OP_PREAD_SEND, true, handle, "%s", fsp_str_do_log(fsp));
1110 static void smb_full_audit_pread_done(struct tevent_req *subreq)
1112 struct tevent_req *req = tevent_req_callback_data(
1113 subreq, struct tevent_req);
1114 struct smb_full_audit_pread_state *state = tevent_req_data(
1115 req, struct smb_full_audit_pread_state);
1117 state->ret = SMB_VFS_PREAD_RECV(subreq, &state->vfs_aio_state);
1118 TALLOC_FREE(subreq);
1119 tevent_req_done(req);
1122 static ssize_t smb_full_audit_pread_recv(struct tevent_req *req,
1123 struct vfs_aio_state *vfs_aio_state)
1125 struct smb_full_audit_pread_state *state = tevent_req_data(
1126 req, struct smb_full_audit_pread_state);
1128 if (tevent_req_is_unix_error(req, &vfs_aio_state->error)) {
1129 do_log(SMB_VFS_OP_PREAD_RECV, false, state->handle, "%s",
1130 fsp_str_do_log(state->fsp));
1134 do_log(SMB_VFS_OP_PREAD_RECV, (state->ret >= 0), state->handle, "%s",
1135 fsp_str_do_log(state->fsp));
1137 *vfs_aio_state = state->vfs_aio_state;
1141 static ssize_t smb_full_audit_write(vfs_handle_struct *handle, files_struct *fsp,
1142 const void *data, size_t n)
1146 result = SMB_VFS_NEXT_WRITE(handle, fsp, data, n);
1148 do_log(SMB_VFS_OP_WRITE, (result >= 0), handle, "%s",
1149 fsp_str_do_log(fsp));
1154 static ssize_t smb_full_audit_pwrite(vfs_handle_struct *handle, files_struct *fsp,
1155 const void *data, size_t n,
1160 result = SMB_VFS_NEXT_PWRITE(handle, fsp, data, n, offset);
1162 do_log(SMB_VFS_OP_PWRITE, (result >= 0), handle, "%s",
1163 fsp_str_do_log(fsp));
1168 struct smb_full_audit_pwrite_state {
1169 vfs_handle_struct *handle;
1172 struct vfs_aio_state vfs_aio_state;
1175 static void smb_full_audit_pwrite_done(struct tevent_req *subreq);
1177 static struct tevent_req *smb_full_audit_pwrite_send(
1178 struct vfs_handle_struct *handle, TALLOC_CTX *mem_ctx,
1179 struct tevent_context *ev, struct files_struct *fsp,
1180 const void *data, size_t n, off_t offset)
1182 struct tevent_req *req, *subreq;
1183 struct smb_full_audit_pwrite_state *state;
1185 req = tevent_req_create(mem_ctx, &state,
1186 struct smb_full_audit_pwrite_state);
1188 do_log(SMB_VFS_OP_PWRITE_SEND, false, handle, "%s",
1189 fsp_str_do_log(fsp));
1192 state->handle = handle;
1195 subreq = SMB_VFS_NEXT_PWRITE_SEND(state, ev, handle, fsp, data,
1197 if (tevent_req_nomem(subreq, req)) {
1198 do_log(SMB_VFS_OP_PWRITE_SEND, false, handle, "%s",
1199 fsp_str_do_log(fsp));
1200 return tevent_req_post(req, ev);
1202 tevent_req_set_callback(subreq, smb_full_audit_pwrite_done, req);
1204 do_log(SMB_VFS_OP_PWRITE_SEND, true, handle, "%s",
1205 fsp_str_do_log(fsp));
1209 static void smb_full_audit_pwrite_done(struct tevent_req *subreq)
1211 struct tevent_req *req = tevent_req_callback_data(
1212 subreq, struct tevent_req);
1213 struct smb_full_audit_pwrite_state *state = tevent_req_data(
1214 req, struct smb_full_audit_pwrite_state);
1216 state->ret = SMB_VFS_PWRITE_RECV(subreq, &state->vfs_aio_state);
1217 TALLOC_FREE(subreq);
1218 tevent_req_done(req);
1221 static ssize_t smb_full_audit_pwrite_recv(struct tevent_req *req,
1222 struct vfs_aio_state *vfs_aio_state)
1224 struct smb_full_audit_pwrite_state *state = tevent_req_data(
1225 req, struct smb_full_audit_pwrite_state);
1227 if (tevent_req_is_unix_error(req, &vfs_aio_state->error)) {
1228 do_log(SMB_VFS_OP_PWRITE_RECV, false, state->handle, "%s",
1229 fsp_str_do_log(state->fsp));
1233 do_log(SMB_VFS_OP_PWRITE_RECV, (state->ret >= 0), state->handle, "%s",
1234 fsp_str_do_log(state->fsp));
1236 *vfs_aio_state = state->vfs_aio_state;
1240 static off_t smb_full_audit_lseek(vfs_handle_struct *handle, files_struct *fsp,
1241 off_t offset, int whence)
1245 result = SMB_VFS_NEXT_LSEEK(handle, fsp, offset, whence);
1247 do_log(SMB_VFS_OP_LSEEK, (result != (ssize_t)-1), handle,
1248 "%s", fsp_str_do_log(fsp));
1253 static ssize_t smb_full_audit_sendfile(vfs_handle_struct *handle, int tofd,
1254 files_struct *fromfsp,
1255 const DATA_BLOB *hdr, off_t offset,
1260 result = SMB_VFS_NEXT_SENDFILE(handle, tofd, fromfsp, hdr, offset, n);
1262 do_log(SMB_VFS_OP_SENDFILE, (result >= 0), handle,
1263 "%s", fsp_str_do_log(fromfsp));
1268 static ssize_t smb_full_audit_recvfile(vfs_handle_struct *handle, int fromfd,
1269 files_struct *tofsp,
1275 result = SMB_VFS_NEXT_RECVFILE(handle, fromfd, tofsp, offset, n);
1277 do_log(SMB_VFS_OP_RECVFILE, (result >= 0), handle,
1278 "%s", fsp_str_do_log(tofsp));
1283 static int smb_full_audit_rename(vfs_handle_struct *handle,
1284 const struct smb_filename *smb_fname_src,
1285 const struct smb_filename *smb_fname_dst)
1289 result = SMB_VFS_NEXT_RENAME(handle, smb_fname_src, smb_fname_dst);
1291 do_log(SMB_VFS_OP_RENAME, (result >= 0), handle, "%s|%s",
1292 smb_fname_str_do_log(smb_fname_src),
1293 smb_fname_str_do_log(smb_fname_dst));
1298 static int smb_full_audit_fsync(vfs_handle_struct *handle, files_struct *fsp)
1302 result = SMB_VFS_NEXT_FSYNC(handle, fsp);
1304 do_log(SMB_VFS_OP_FSYNC, (result >= 0), handle, "%s",
1305 fsp_str_do_log(fsp));
1310 struct smb_full_audit_fsync_state {
1311 vfs_handle_struct *handle;
1314 struct vfs_aio_state vfs_aio_state;
1317 static void smb_full_audit_fsync_done(struct tevent_req *subreq);
1319 static struct tevent_req *smb_full_audit_fsync_send(
1320 struct vfs_handle_struct *handle, TALLOC_CTX *mem_ctx,
1321 struct tevent_context *ev, struct files_struct *fsp)
1323 struct tevent_req *req, *subreq;
1324 struct smb_full_audit_fsync_state *state;
1326 req = tevent_req_create(mem_ctx, &state,
1327 struct smb_full_audit_fsync_state);
1329 do_log(SMB_VFS_OP_FSYNC_SEND, false, handle, "%s",
1330 fsp_str_do_log(fsp));
1333 state->handle = handle;
1336 subreq = SMB_VFS_NEXT_FSYNC_SEND(state, ev, handle, fsp);
1337 if (tevent_req_nomem(subreq, req)) {
1338 do_log(SMB_VFS_OP_FSYNC_SEND, false, handle, "%s",
1339 fsp_str_do_log(fsp));
1340 return tevent_req_post(req, ev);
1342 tevent_req_set_callback(subreq, smb_full_audit_fsync_done, req);
1344 do_log(SMB_VFS_OP_FSYNC_SEND, true, handle, "%s", fsp_str_do_log(fsp));
1348 static void smb_full_audit_fsync_done(struct tevent_req *subreq)
1350 struct tevent_req *req = tevent_req_callback_data(
1351 subreq, struct tevent_req);
1352 struct smb_full_audit_fsync_state *state = tevent_req_data(
1353 req, struct smb_full_audit_fsync_state);
1355 state->ret = SMB_VFS_FSYNC_RECV(subreq, &state->vfs_aio_state);
1356 TALLOC_FREE(subreq);
1357 tevent_req_done(req);
1360 static int smb_full_audit_fsync_recv(struct tevent_req *req,
1361 struct vfs_aio_state *vfs_aio_state)
1363 struct smb_full_audit_fsync_state *state = tevent_req_data(
1364 req, struct smb_full_audit_fsync_state);
1366 if (tevent_req_is_unix_error(req, &vfs_aio_state->error)) {
1367 do_log(SMB_VFS_OP_FSYNC_RECV, false, state->handle, "%s",
1368 fsp_str_do_log(state->fsp));
1372 do_log(SMB_VFS_OP_FSYNC_RECV, (state->ret >= 0), state->handle, "%s",
1373 fsp_str_do_log(state->fsp));
1375 *vfs_aio_state = state->vfs_aio_state;
1379 static int smb_full_audit_stat(vfs_handle_struct *handle,
1380 struct smb_filename *smb_fname)
1384 result = SMB_VFS_NEXT_STAT(handle, smb_fname);
1386 do_log(SMB_VFS_OP_STAT, (result >= 0), handle, "%s",
1387 smb_fname_str_do_log(smb_fname));
1392 static int smb_full_audit_fstat(vfs_handle_struct *handle, files_struct *fsp,
1393 SMB_STRUCT_STAT *sbuf)
1397 result = SMB_VFS_NEXT_FSTAT(handle, fsp, sbuf);
1399 do_log(SMB_VFS_OP_FSTAT, (result >= 0), handle, "%s",
1400 fsp_str_do_log(fsp));
1405 static int smb_full_audit_lstat(vfs_handle_struct *handle,
1406 struct smb_filename *smb_fname)
1410 result = SMB_VFS_NEXT_LSTAT(handle, smb_fname);
1412 do_log(SMB_VFS_OP_LSTAT, (result >= 0), handle, "%s",
1413 smb_fname_str_do_log(smb_fname));
1418 static uint64_t smb_full_audit_get_alloc_size(vfs_handle_struct *handle,
1419 files_struct *fsp, const SMB_STRUCT_STAT *sbuf)
1423 result = SMB_VFS_NEXT_GET_ALLOC_SIZE(handle, fsp, sbuf);
1425 do_log(SMB_VFS_OP_GET_ALLOC_SIZE, (result != (uint64_t)-1), handle,
1431 static int smb_full_audit_unlink(vfs_handle_struct *handle,
1432 const struct smb_filename *smb_fname)
1436 result = SMB_VFS_NEXT_UNLINK(handle, smb_fname);
1438 do_log(SMB_VFS_OP_UNLINK, (result >= 0), handle, "%s",
1439 smb_fname_str_do_log(smb_fname));
1444 static int smb_full_audit_chmod(vfs_handle_struct *handle,
1445 const struct smb_filename *smb_fname,
1450 result = SMB_VFS_NEXT_CHMOD(handle, smb_fname, mode);
1452 do_log(SMB_VFS_OP_CHMOD, (result >= 0), handle, "%s|%o",
1453 smb_fname->base_name,
1459 static int smb_full_audit_fchmod(vfs_handle_struct *handle, files_struct *fsp,
1464 result = SMB_VFS_NEXT_FCHMOD(handle, fsp, mode);
1466 do_log(SMB_VFS_OP_FCHMOD, (result >= 0), handle,
1467 "%s|%o", fsp_str_do_log(fsp), mode);
1472 static int smb_full_audit_chown(vfs_handle_struct *handle,
1473 const struct smb_filename *smb_fname,
1479 result = SMB_VFS_NEXT_CHOWN(handle, smb_fname, uid, gid);
1481 do_log(SMB_VFS_OP_CHOWN, (result >= 0), handle, "%s|%ld|%ld",
1482 smb_fname->base_name, (long int)uid, (long int)gid);
1487 static int smb_full_audit_fchown(vfs_handle_struct *handle, files_struct *fsp,
1488 uid_t uid, gid_t gid)
1492 result = SMB_VFS_NEXT_FCHOWN(handle, fsp, uid, gid);
1494 do_log(SMB_VFS_OP_FCHOWN, (result >= 0), handle, "%s|%ld|%ld",
1495 fsp_str_do_log(fsp), (long int)uid, (long int)gid);
1500 static int smb_full_audit_lchown(vfs_handle_struct *handle,
1501 const struct smb_filename *smb_fname,
1507 result = SMB_VFS_NEXT_LCHOWN(handle, smb_fname, uid, gid);
1509 do_log(SMB_VFS_OP_LCHOWN, (result >= 0), handle, "%s|%ld|%ld",
1510 smb_fname->base_name, (long int)uid, (long int)gid);
1515 static int smb_full_audit_chdir(vfs_handle_struct *handle,
1516 const struct smb_filename *smb_fname)
1520 result = SMB_VFS_NEXT_CHDIR(handle, smb_fname);
1522 do_log(SMB_VFS_OP_CHDIR, (result >= 0), handle, "chdir|%s",
1523 smb_fname->base_name);
1528 static struct smb_filename *smb_full_audit_getwd(vfs_handle_struct *handle,
1531 struct smb_filename *result;
1533 result = SMB_VFS_NEXT_GETWD(handle, ctx);
1535 do_log(SMB_VFS_OP_GETWD, (result != NULL), handle, "%s",
1536 result == NULL? "" : result->base_name);
1541 static int smb_full_audit_ntimes(vfs_handle_struct *handle,
1542 const struct smb_filename *smb_fname,
1543 struct smb_file_time *ft)
1547 result = SMB_VFS_NEXT_NTIMES(handle, smb_fname, ft);
1549 do_log(SMB_VFS_OP_NTIMES, (result >= 0), handle, "%s",
1550 smb_fname_str_do_log(smb_fname));
1555 static int smb_full_audit_ftruncate(vfs_handle_struct *handle, files_struct *fsp,
1560 result = SMB_VFS_NEXT_FTRUNCATE(handle, fsp, len);
1562 do_log(SMB_VFS_OP_FTRUNCATE, (result >= 0), handle,
1563 "%s", fsp_str_do_log(fsp));
1568 static int smb_full_audit_fallocate(vfs_handle_struct *handle, files_struct *fsp,
1575 result = SMB_VFS_NEXT_FALLOCATE(handle, fsp, mode, offset, len);
1577 do_log(SMB_VFS_OP_FALLOCATE, (result >= 0), handle,
1578 "%s", fsp_str_do_log(fsp));
1583 static bool smb_full_audit_lock(vfs_handle_struct *handle, files_struct *fsp,
1584 int op, off_t offset, off_t count, int type)
1588 result = SMB_VFS_NEXT_LOCK(handle, fsp, op, offset, count, type);
1590 do_log(SMB_VFS_OP_LOCK, result, handle, "%s", fsp_str_do_log(fsp));
1595 static int smb_full_audit_kernel_flock(struct vfs_handle_struct *handle,
1596 struct files_struct *fsp,
1597 uint32_t share_mode, uint32_t access_mask)
1601 result = SMB_VFS_NEXT_KERNEL_FLOCK(handle, fsp, share_mode, access_mask);
1603 do_log(SMB_VFS_OP_KERNEL_FLOCK, (result >= 0), handle, "%s",
1604 fsp_str_do_log(fsp));
1609 static int smb_full_audit_linux_setlease(vfs_handle_struct *handle, files_struct *fsp,
1614 result = SMB_VFS_NEXT_LINUX_SETLEASE(handle, fsp, leasetype);
1616 do_log(SMB_VFS_OP_LINUX_SETLEASE, (result >= 0), handle, "%s",
1617 fsp_str_do_log(fsp));
1622 static bool smb_full_audit_getlock(vfs_handle_struct *handle, files_struct *fsp,
1623 off_t *poffset, off_t *pcount, int *ptype, pid_t *ppid)
1627 result = SMB_VFS_NEXT_GETLOCK(handle, fsp, poffset, pcount, ptype, ppid);
1629 do_log(SMB_VFS_OP_GETLOCK, result, handle, "%s", fsp_str_do_log(fsp));
1634 static int smb_full_audit_symlink(vfs_handle_struct *handle,
1635 const char *link_contents,
1636 const struct smb_filename *new_smb_fname)
1640 result = SMB_VFS_NEXT_SYMLINK(handle, link_contents, new_smb_fname);
1642 do_log(SMB_VFS_OP_SYMLINK, (result >= 0), handle,
1643 "%s|%s", link_contents, new_smb_fname->base_name);
1648 static int smb_full_audit_readlink(vfs_handle_struct *handle,
1649 const struct smb_filename *smb_fname,
1655 result = SMB_VFS_NEXT_READLINK(handle, smb_fname, buf, bufsiz);
1657 do_log(SMB_VFS_OP_READLINK, (result >= 0), handle, "%s",
1658 smb_fname->base_name);
1663 static int smb_full_audit_link(vfs_handle_struct *handle,
1664 const struct smb_filename *old_smb_fname,
1665 const struct smb_filename *new_smb_fname)
1669 result = SMB_VFS_NEXT_LINK(handle, old_smb_fname, new_smb_fname);
1671 do_log(SMB_VFS_OP_LINK, (result >= 0), handle,
1672 "%s|%s", old_smb_fname->base_name, new_smb_fname->base_name);
1677 static int smb_full_audit_mknod(vfs_handle_struct *handle,
1678 const struct smb_filename *smb_fname,
1684 result = SMB_VFS_NEXT_MKNOD(handle, smb_fname, mode, dev);
1686 do_log(SMB_VFS_OP_MKNOD, (result >= 0), handle, "%s",
1687 smb_fname->base_name);
1692 static struct smb_filename *smb_full_audit_realpath(vfs_handle_struct *handle,
1694 const struct smb_filename *smb_fname)
1696 struct smb_filename *result_fname = NULL;
1698 result_fname = SMB_VFS_NEXT_REALPATH(handle, ctx, smb_fname);
1700 do_log(SMB_VFS_OP_REALPATH, (result_fname != NULL), handle, "%s",
1701 smb_fname->base_name);
1703 return result_fname;
1706 static int smb_full_audit_chflags(vfs_handle_struct *handle,
1707 const struct smb_filename *smb_fname,
1712 result = SMB_VFS_NEXT_CHFLAGS(handle, smb_fname, flags);
1714 do_log(SMB_VFS_OP_CHFLAGS, (result != 0), handle, "%s",
1715 smb_fname->base_name);
1720 static struct file_id smb_full_audit_file_id_create(struct vfs_handle_struct *handle,
1721 const SMB_STRUCT_STAT *sbuf)
1723 struct file_id id_zero;
1724 struct file_id result;
1726 ZERO_STRUCT(id_zero);
1728 result = SMB_VFS_NEXT_FILE_ID_CREATE(handle, sbuf);
1730 do_log(SMB_VFS_OP_FILE_ID_CREATE,
1731 !file_id_equal(&id_zero, &result),
1732 handle, "%s", file_id_string_tos(&result));
1737 static NTSTATUS smb_full_audit_streaminfo(vfs_handle_struct *handle,
1738 struct files_struct *fsp,
1739 const struct smb_filename *smb_fname,
1740 TALLOC_CTX *mem_ctx,
1741 unsigned int *pnum_streams,
1742 struct stream_struct **pstreams)
1746 result = SMB_VFS_NEXT_STREAMINFO(handle, fsp, smb_fname, mem_ctx,
1747 pnum_streams, pstreams);
1749 do_log(SMB_VFS_OP_STREAMINFO, NT_STATUS_IS_OK(result), handle,
1750 "%s", smb_fname->base_name);
1755 static int smb_full_audit_get_real_filename(struct vfs_handle_struct *handle,
1758 TALLOC_CTX *mem_ctx,
1763 result = SMB_VFS_NEXT_GET_REAL_FILENAME(handle, path, name, mem_ctx,
1766 do_log(SMB_VFS_OP_GET_REAL_FILENAME, (result == 0), handle,
1767 "%s/%s->%s", path, name, (result == 0) ? "" : *found_name);
1772 static const char *smb_full_audit_connectpath(vfs_handle_struct *handle,
1773 const struct smb_filename *smb_fname)
1777 result = SMB_VFS_NEXT_CONNECTPATH(handle, smb_fname);
1779 do_log(SMB_VFS_OP_CONNECTPATH, result != NULL, handle,
1780 "%s", smb_fname->base_name);
1785 static NTSTATUS smb_full_audit_brl_lock_windows(struct vfs_handle_struct *handle,
1786 struct byte_range_lock *br_lck,
1787 struct lock_struct *plock,
1792 result = SMB_VFS_NEXT_BRL_LOCK_WINDOWS(handle, br_lck, plock,
1795 do_log(SMB_VFS_OP_BRL_LOCK_WINDOWS, NT_STATUS_IS_OK(result), handle,
1796 "%s:%llu-%llu. type=%d. blocking=%d",
1797 fsp_str_do_log(brl_fsp(br_lck)),
1798 plock->start, plock->size, plock->lock_type, blocking_lock);
1803 static bool smb_full_audit_brl_unlock_windows(struct vfs_handle_struct *handle,
1804 struct messaging_context *msg_ctx,
1805 struct byte_range_lock *br_lck,
1806 const struct lock_struct *plock)
1810 result = SMB_VFS_NEXT_BRL_UNLOCK_WINDOWS(handle, msg_ctx, br_lck,
1813 do_log(SMB_VFS_OP_BRL_UNLOCK_WINDOWS, (result == 0), handle,
1814 "%s:%llu-%llu:%d", fsp_str_do_log(brl_fsp(br_lck)),
1816 plock->size, plock->lock_type);
1821 static bool smb_full_audit_brl_cancel_windows(struct vfs_handle_struct *handle,
1822 struct byte_range_lock *br_lck,
1823 struct lock_struct *plock)
1827 result = SMB_VFS_NEXT_BRL_CANCEL_WINDOWS(handle, br_lck, plock);
1829 do_log(SMB_VFS_OP_BRL_CANCEL_WINDOWS, (result == 0), handle,
1830 "%s:%llu-%llu:%d", fsp_str_do_log(brl_fsp(br_lck)),
1832 plock->size, plock->lock_type);
1837 static bool smb_full_audit_strict_lock(struct vfs_handle_struct *handle,
1838 struct files_struct *fsp,
1839 struct lock_struct *plock)
1843 result = SMB_VFS_NEXT_STRICT_LOCK(handle, fsp, plock);
1845 do_log(SMB_VFS_OP_STRICT_LOCK, result, handle,
1846 "%s:%llu-%llu:%d", fsp_str_do_log(fsp), plock->start,
1847 plock->size, plock->lock_type);
1852 static void smb_full_audit_strict_unlock(struct vfs_handle_struct *handle,
1853 struct files_struct *fsp,
1854 struct lock_struct *plock)
1856 SMB_VFS_NEXT_STRICT_UNLOCK(handle, fsp, plock);
1858 do_log(SMB_VFS_OP_STRICT_UNLOCK, true, handle,
1859 "%s:%llu-%llu:%d", fsp_str_do_log(fsp), plock->start,
1860 plock->size, plock->lock_type);
1863 static NTSTATUS smb_full_audit_translate_name(struct vfs_handle_struct *handle,
1865 enum vfs_translate_direction direction,
1866 TALLOC_CTX *mem_ctx,
1871 result = SMB_VFS_NEXT_TRANSLATE_NAME(handle, name, direction, mem_ctx,
1874 do_log(SMB_VFS_OP_TRANSLATE_NAME, NT_STATUS_IS_OK(result), handle, "");
1879 static NTSTATUS smb_full_audit_fsctl(struct vfs_handle_struct *handle,
1880 struct files_struct *fsp,
1884 const uint8_t *_in_data,
1886 uint8_t **_out_data,
1887 uint32_t max_out_len,
1892 result = SMB_VFS_NEXT_FSCTL(handle,
1903 do_log(SMB_VFS_OP_FSCTL, NT_STATUS_IS_OK(result), handle, "");
1908 static struct tevent_req *smb_full_audit_offload_read_send(
1909 TALLOC_CTX *mem_ctx,
1910 struct tevent_context *ev,
1911 struct vfs_handle_struct *handle,
1912 struct files_struct *fsp,
1918 struct tevent_req *req = NULL;
1920 req = SMB_VFS_NEXT_OFFLOAD_READ_SEND(mem_ctx, ev, handle, fsp,
1921 fsctl, ttl, offset, to_copy);
1923 do_log(SMB_VFS_OP_OFFLOAD_READ_SEND, req, handle, "");
1928 static NTSTATUS smb_full_audit_offload_read_recv(
1929 struct tevent_req *req,
1930 struct vfs_handle_struct *handle,
1931 TALLOC_CTX *mem_ctx,
1932 DATA_BLOB *_token_blob)
1936 status = SMB_VFS_NEXT_OFFLOAD_READ_RECV(req, handle, mem_ctx,
1939 do_log(SMB_VFS_OP_OFFLOAD_READ_RECV, NT_STATUS_IS_OK(status), handle, "");
1944 static struct tevent_req *smb_full_audit_offload_write_send(struct vfs_handle_struct *handle,
1945 TALLOC_CTX *mem_ctx,
1946 struct tevent_context *ev,
1949 off_t transfer_offset,
1950 struct files_struct *dest_fsp,
1955 struct tevent_req *req;
1957 req = SMB_VFS_NEXT_OFFLOAD_WRITE_SEND(handle, mem_ctx, ev,
1958 fsctl, token, transfer_offset,
1959 dest_fsp, dest_off, num,
1962 do_log(SMB_VFS_OP_OFFLOAD_WRITE_SEND, req, handle, "");
1967 static NTSTATUS smb_full_audit_offload_write_recv(struct vfs_handle_struct *handle,
1968 struct tevent_req *req,
1973 result = SMB_VFS_NEXT_OFFLOAD_WRITE_RECV(handle, req, copied);
1975 do_log(SMB_VFS_OP_OFFLOAD_WRITE_RECV, NT_STATUS_IS_OK(result), handle, "");
1980 static NTSTATUS smb_full_audit_get_compression(vfs_handle_struct *handle,
1981 TALLOC_CTX *mem_ctx,
1982 struct files_struct *fsp,
1983 struct smb_filename *smb_fname,
1984 uint16_t *_compression_fmt)
1988 result = SMB_VFS_NEXT_GET_COMPRESSION(handle, mem_ctx, fsp, smb_fname,
1991 do_log(SMB_VFS_OP_GET_COMPRESSION, NT_STATUS_IS_OK(result), handle,
1993 (fsp ? fsp_str_do_log(fsp) : smb_fname_str_do_log(smb_fname)));
1998 static NTSTATUS smb_full_audit_set_compression(vfs_handle_struct *handle,
1999 TALLOC_CTX *mem_ctx,
2000 struct files_struct *fsp,
2001 uint16_t compression_fmt)
2005 result = SMB_VFS_NEXT_SET_COMPRESSION(handle, mem_ctx, fsp,
2008 do_log(SMB_VFS_OP_SET_COMPRESSION, NT_STATUS_IS_OK(result), handle,
2009 "%s", fsp_str_do_log(fsp));
2014 static NTSTATUS smb_full_audit_readdir_attr(struct vfs_handle_struct *handle,
2015 const struct smb_filename *fname,
2016 TALLOC_CTX *mem_ctx,
2017 struct readdir_attr_data **pattr_data)
2021 status = SMB_VFS_NEXT_READDIR_ATTR(handle, fname, mem_ctx, pattr_data);
2023 do_log(SMB_VFS_OP_READDIR_ATTR, NT_STATUS_IS_OK(status), handle, "%s",
2024 smb_fname_str_do_log(fname));
2029 static NTSTATUS smb_full_audit_get_dos_attributes(
2030 struct vfs_handle_struct *handle,
2031 struct smb_filename *smb_fname,
2036 status = SMB_VFS_NEXT_GET_DOS_ATTRIBUTES(handle,
2040 do_log(SMB_VFS_OP_GET_DOS_ATTRIBUTES,
2041 NT_STATUS_IS_OK(status),
2044 smb_fname_str_do_log(smb_fname));
2049 static NTSTATUS smb_full_audit_fget_dos_attributes(
2050 struct vfs_handle_struct *handle,
2051 struct files_struct *fsp,
2056 status = SMB_VFS_NEXT_FGET_DOS_ATTRIBUTES(handle,
2060 do_log(SMB_VFS_OP_FGET_DOS_ATTRIBUTES,
2061 NT_STATUS_IS_OK(status),
2064 fsp_str_do_log(fsp));
2069 static NTSTATUS smb_full_audit_set_dos_attributes(
2070 struct vfs_handle_struct *handle,
2071 const struct smb_filename *smb_fname,
2076 status = SMB_VFS_NEXT_SET_DOS_ATTRIBUTES(handle,
2080 do_log(SMB_VFS_OP_SET_DOS_ATTRIBUTES,
2081 NT_STATUS_IS_OK(status),
2084 smb_fname_str_do_log(smb_fname));
2089 static NTSTATUS smb_full_audit_fset_dos_attributes(
2090 struct vfs_handle_struct *handle,
2091 struct files_struct *fsp,
2096 status = SMB_VFS_NEXT_FSET_DOS_ATTRIBUTES(handle,
2100 do_log(SMB_VFS_OP_FSET_DOS_ATTRIBUTES,
2101 NT_STATUS_IS_OK(status),
2104 fsp_str_do_log(fsp));
2109 static NTSTATUS smb_full_audit_fget_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
2110 uint32_t security_info,
2111 TALLOC_CTX *mem_ctx,
2112 struct security_descriptor **ppdesc)
2116 result = SMB_VFS_NEXT_FGET_NT_ACL(handle, fsp, security_info,
2119 do_log(SMB_VFS_OP_FGET_NT_ACL, NT_STATUS_IS_OK(result), handle,
2120 "%s", fsp_str_do_log(fsp));
2125 static NTSTATUS smb_full_audit_get_nt_acl(vfs_handle_struct *handle,
2126 const struct smb_filename *smb_fname,
2127 uint32_t security_info,
2128 TALLOC_CTX *mem_ctx,
2129 struct security_descriptor **ppdesc)
2133 result = SMB_VFS_NEXT_GET_NT_ACL(handle, smb_fname, security_info,
2136 do_log(SMB_VFS_OP_GET_NT_ACL, NT_STATUS_IS_OK(result), handle,
2137 "%s", smb_fname_str_do_log(smb_fname));
2142 static NTSTATUS smb_full_audit_fset_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
2143 uint32_t security_info_sent,
2144 const struct security_descriptor *psd)
2146 struct vfs_full_audit_private_data *pd;
2150 SMB_VFS_HANDLE_GET_DATA(handle, pd,
2151 struct vfs_full_audit_private_data,
2152 return NT_STATUS_INTERNAL_ERROR);
2154 if (pd->log_secdesc) {
2155 sd = sddl_encode(talloc_tos(), psd, get_global_sam_sid());
2158 result = SMB_VFS_NEXT_FSET_NT_ACL(handle, fsp, security_info_sent, psd);
2160 do_log(SMB_VFS_OP_FSET_NT_ACL, NT_STATUS_IS_OK(result), handle,
2161 "%s [%s]", fsp_str_do_log(fsp), sd ? sd : "");
2168 static NTSTATUS smb_full_audit_audit_file(struct vfs_handle_struct *handle,
2169 struct smb_filename *file,
2170 struct security_acl *sacl,
2171 uint32_t access_requested,
2172 uint32_t access_denied)
2176 result = SMB_VFS_NEXT_AUDIT_FILE(handle,
2182 do_log(SMB_VFS_OP_AUDIT_FILE, NT_STATUS_IS_OK(result), handle,
2183 "%s", smb_fname_str_do_log(file));
2188 static int smb_full_audit_chmod_acl(vfs_handle_struct *handle,
2189 const struct smb_filename *smb_fname,
2194 result = SMB_VFS_NEXT_CHMOD_ACL(handle, smb_fname, mode);
2196 do_log(SMB_VFS_OP_CHMOD_ACL, (result >= 0), handle,
2197 "%s|%o", smb_fname->base_name, mode);
2202 static int smb_full_audit_fchmod_acl(vfs_handle_struct *handle, files_struct *fsp,
2207 result = SMB_VFS_NEXT_FCHMOD_ACL(handle, fsp, mode);
2209 do_log(SMB_VFS_OP_FCHMOD_ACL, (result >= 0), handle,
2210 "%s|%o", fsp_str_do_log(fsp), mode);
2215 static SMB_ACL_T smb_full_audit_sys_acl_get_file(vfs_handle_struct *handle,
2216 const struct smb_filename *smb_fname,
2217 SMB_ACL_TYPE_T type,
2218 TALLOC_CTX *mem_ctx)
2222 result = SMB_VFS_NEXT_SYS_ACL_GET_FILE(handle, smb_fname,
2225 do_log(SMB_VFS_OP_SYS_ACL_GET_FILE, (result != NULL), handle,
2226 "%s", smb_fname->base_name);
2231 static SMB_ACL_T smb_full_audit_sys_acl_get_fd(vfs_handle_struct *handle,
2232 files_struct *fsp, TALLOC_CTX *mem_ctx)
2236 result = SMB_VFS_NEXT_SYS_ACL_GET_FD(handle, fsp, mem_ctx);
2238 do_log(SMB_VFS_OP_SYS_ACL_GET_FD, (result != NULL), handle,
2239 "%s", fsp_str_do_log(fsp));
2244 static int smb_full_audit_sys_acl_blob_get_file(vfs_handle_struct *handle,
2245 const struct smb_filename *smb_fname,
2246 TALLOC_CTX *mem_ctx,
2247 char **blob_description,
2252 result = SMB_VFS_NEXT_SYS_ACL_BLOB_GET_FILE(handle, smb_fname,
2253 mem_ctx, blob_description, blob);
2255 do_log(SMB_VFS_OP_SYS_ACL_BLOB_GET_FILE, (result >= 0), handle,
2256 "%s", smb_fname->base_name);
2261 static int smb_full_audit_sys_acl_blob_get_fd(vfs_handle_struct *handle,
2263 TALLOC_CTX *mem_ctx,
2264 char **blob_description,
2269 result = SMB_VFS_NEXT_SYS_ACL_BLOB_GET_FD(handle, fsp, mem_ctx, blob_description, blob);
2271 do_log(SMB_VFS_OP_SYS_ACL_BLOB_GET_FD, (result >= 0), handle,
2272 "%s", fsp_str_do_log(fsp));
2277 static int smb_full_audit_sys_acl_set_file(vfs_handle_struct *handle,
2278 const struct smb_filename *smb_fname,
2279 SMB_ACL_TYPE_T acltype,
2284 result = SMB_VFS_NEXT_SYS_ACL_SET_FILE(handle, smb_fname, acltype,
2287 do_log(SMB_VFS_OP_SYS_ACL_SET_FILE, (result >= 0), handle,
2288 "%s", smb_fname->base_name);
2293 static int smb_full_audit_sys_acl_set_fd(vfs_handle_struct *handle, files_struct *fsp,
2298 result = SMB_VFS_NEXT_SYS_ACL_SET_FD(handle, fsp, theacl);
2300 do_log(SMB_VFS_OP_SYS_ACL_SET_FD, (result >= 0), handle,
2301 "%s", fsp_str_do_log(fsp));
2306 static int smb_full_audit_sys_acl_delete_def_file(vfs_handle_struct *handle,
2307 const struct smb_filename *smb_fname)
2311 result = SMB_VFS_NEXT_SYS_ACL_DELETE_DEF_FILE(handle, smb_fname);
2313 do_log(SMB_VFS_OP_SYS_ACL_DELETE_DEF_FILE, (result >= 0), handle,
2314 "%s", smb_fname->base_name);
2319 static ssize_t smb_full_audit_getxattr(struct vfs_handle_struct *handle,
2320 const struct smb_filename *smb_fname,
2321 const char *name, void *value, size_t size)
2325 result = SMB_VFS_NEXT_GETXATTR(handle, smb_fname, name, value, size);
2327 do_log(SMB_VFS_OP_GETXATTR, (result >= 0), handle,
2328 "%s|%s", smb_fname->base_name, name);
2333 static ssize_t smb_full_audit_fgetxattr(struct vfs_handle_struct *handle,
2334 struct files_struct *fsp,
2335 const char *name, void *value, size_t size)
2339 result = SMB_VFS_NEXT_FGETXATTR(handle, fsp, name, value, size);
2341 do_log(SMB_VFS_OP_FGETXATTR, (result >= 0), handle,
2342 "%s|%s", fsp_str_do_log(fsp), name);
2347 static ssize_t smb_full_audit_listxattr(struct vfs_handle_struct *handle,
2348 const struct smb_filename *smb_fname,
2354 result = SMB_VFS_NEXT_LISTXATTR(handle, smb_fname, list, size);
2356 do_log(SMB_VFS_OP_LISTXATTR, (result >= 0), handle, "%s",
2357 smb_fname->base_name);
2362 static ssize_t smb_full_audit_flistxattr(struct vfs_handle_struct *handle,
2363 struct files_struct *fsp, char *list,
2368 result = SMB_VFS_NEXT_FLISTXATTR(handle, fsp, list, size);
2370 do_log(SMB_VFS_OP_FLISTXATTR, (result >= 0), handle,
2371 "%s", fsp_str_do_log(fsp));
2376 static int smb_full_audit_removexattr(struct vfs_handle_struct *handle,
2377 const struct smb_filename *smb_fname,
2382 result = SMB_VFS_NEXT_REMOVEXATTR(handle, smb_fname, name);
2384 do_log(SMB_VFS_OP_REMOVEXATTR, (result >= 0), handle,
2385 "%s|%s", smb_fname->base_name, name);
2390 static int smb_full_audit_fremovexattr(struct vfs_handle_struct *handle,
2391 struct files_struct *fsp,
2396 result = SMB_VFS_NEXT_FREMOVEXATTR(handle, fsp, name);
2398 do_log(SMB_VFS_OP_FREMOVEXATTR, (result >= 0), handle,
2399 "%s|%s", fsp_str_do_log(fsp), name);
2404 static int smb_full_audit_setxattr(struct vfs_handle_struct *handle,
2405 const struct smb_filename *smb_fname,
2406 const char *name, const void *value, size_t size,
2411 result = SMB_VFS_NEXT_SETXATTR(handle, smb_fname, name, value, size,
2414 do_log(SMB_VFS_OP_SETXATTR, (result >= 0), handle,
2415 "%s|%s", smb_fname->base_name, name);
2420 static int smb_full_audit_fsetxattr(struct vfs_handle_struct *handle,
2421 struct files_struct *fsp, const char *name,
2422 const void *value, size_t size, int flags)
2426 result = SMB_VFS_NEXT_FSETXATTR(handle, fsp, name, value, size, flags);
2428 do_log(SMB_VFS_OP_FSETXATTR, (result >= 0), handle,
2429 "%s|%s", fsp_str_do_log(fsp), name);
2434 static bool smb_full_audit_aio_force(struct vfs_handle_struct *handle,
2435 struct files_struct *fsp)
2439 result = SMB_VFS_NEXT_AIO_FORCE(handle, fsp);
2440 do_log(SMB_VFS_OP_AIO_FORCE, result, handle,
2441 "%s", fsp_str_do_log(fsp));
2446 static NTSTATUS smb_full_audit_durable_cookie(struct vfs_handle_struct *handle,
2447 struct files_struct *fsp,
2448 TALLOC_CTX *mem_ctx,
2453 result = SMB_VFS_NEXT_DURABLE_COOKIE(handle,
2458 do_log(SMB_VFS_OP_DURABLE_COOKIE, NT_STATUS_IS_OK(result), handle,
2459 "%s", fsp_str_do_log(fsp));
2464 static NTSTATUS smb_full_audit_durable_disconnect(
2465 struct vfs_handle_struct *handle,
2466 struct files_struct *fsp,
2467 const DATA_BLOB old_cookie,
2468 TALLOC_CTX *mem_ctx,
2469 DATA_BLOB *new_cookie)
2473 result = SMB_VFS_NEXT_DURABLE_DISCONNECT(handle,
2479 do_log(SMB_VFS_OP_DURABLE_DISCONNECT, NT_STATUS_IS_OK(result), handle,
2480 "%s", fsp_str_do_log(fsp));
2485 static NTSTATUS smb_full_audit_durable_reconnect(
2486 struct vfs_handle_struct *handle,
2487 struct smb_request *smb1req,
2488 struct smbXsrv_open *op,
2489 const DATA_BLOB old_cookie,
2490 TALLOC_CTX *mem_ctx,
2491 struct files_struct **fsp,
2492 DATA_BLOB *new_cookie)
2496 result = SMB_VFS_NEXT_DURABLE_RECONNECT(handle,
2504 do_log(SMB_VFS_OP_DURABLE_RECONNECT,
2505 NT_STATUS_IS_OK(result),
2512 static struct vfs_fn_pointers vfs_full_audit_fns = {
2514 /* Disk operations */
2516 .connect_fn = smb_full_audit_connect,
2517 .disconnect_fn = smb_full_audit_disconnect,
2518 .disk_free_fn = smb_full_audit_disk_free,
2519 .get_quota_fn = smb_full_audit_get_quota,
2520 .set_quota_fn = smb_full_audit_set_quota,
2521 .get_shadow_copy_data_fn = smb_full_audit_get_shadow_copy_data,
2522 .statvfs_fn = smb_full_audit_statvfs,
2523 .fs_capabilities_fn = smb_full_audit_fs_capabilities,
2524 .get_dfs_referrals_fn = smb_full_audit_get_dfs_referrals,
2525 .opendir_fn = smb_full_audit_opendir,
2526 .fdopendir_fn = smb_full_audit_fdopendir,
2527 .readdir_fn = smb_full_audit_readdir,
2528 .seekdir_fn = smb_full_audit_seekdir,
2529 .telldir_fn = smb_full_audit_telldir,
2530 .rewind_dir_fn = smb_full_audit_rewinddir,
2531 .mkdir_fn = smb_full_audit_mkdir,
2532 .rmdir_fn = smb_full_audit_rmdir,
2533 .closedir_fn = smb_full_audit_closedir,
2534 .init_search_op_fn = smb_full_audit_init_search_op,
2535 .open_fn = smb_full_audit_open,
2536 .create_file_fn = smb_full_audit_create_file,
2537 .close_fn = smb_full_audit_close,
2538 .read_fn = smb_full_audit_read,
2539 .pread_fn = smb_full_audit_pread,
2540 .pread_send_fn = smb_full_audit_pread_send,
2541 .pread_recv_fn = smb_full_audit_pread_recv,
2542 .write_fn = smb_full_audit_write,
2543 .pwrite_fn = smb_full_audit_pwrite,
2544 .pwrite_send_fn = smb_full_audit_pwrite_send,
2545 .pwrite_recv_fn = smb_full_audit_pwrite_recv,
2546 .lseek_fn = smb_full_audit_lseek,
2547 .sendfile_fn = smb_full_audit_sendfile,
2548 .recvfile_fn = smb_full_audit_recvfile,
2549 .rename_fn = smb_full_audit_rename,
2550 .fsync_fn = smb_full_audit_fsync,
2551 .fsync_send_fn = smb_full_audit_fsync_send,
2552 .fsync_recv_fn = smb_full_audit_fsync_recv,
2553 .stat_fn = smb_full_audit_stat,
2554 .fstat_fn = smb_full_audit_fstat,
2555 .lstat_fn = smb_full_audit_lstat,
2556 .get_alloc_size_fn = smb_full_audit_get_alloc_size,
2557 .unlink_fn = smb_full_audit_unlink,
2558 .chmod_fn = smb_full_audit_chmod,
2559 .fchmod_fn = smb_full_audit_fchmod,
2560 .chown_fn = smb_full_audit_chown,
2561 .fchown_fn = smb_full_audit_fchown,
2562 .lchown_fn = smb_full_audit_lchown,
2563 .chdir_fn = smb_full_audit_chdir,
2564 .getwd_fn = smb_full_audit_getwd,
2565 .ntimes_fn = smb_full_audit_ntimes,
2566 .ftruncate_fn = smb_full_audit_ftruncate,
2567 .fallocate_fn = smb_full_audit_fallocate,
2568 .lock_fn = smb_full_audit_lock,
2569 .kernel_flock_fn = smb_full_audit_kernel_flock,
2570 .linux_setlease_fn = smb_full_audit_linux_setlease,
2571 .getlock_fn = smb_full_audit_getlock,
2572 .symlink_fn = smb_full_audit_symlink,
2573 .readlink_fn = smb_full_audit_readlink,
2574 .link_fn = smb_full_audit_link,
2575 .mknod_fn = smb_full_audit_mknod,
2576 .realpath_fn = smb_full_audit_realpath,
2577 .chflags_fn = smb_full_audit_chflags,
2578 .file_id_create_fn = smb_full_audit_file_id_create,
2579 .offload_read_send_fn = smb_full_audit_offload_read_send,
2580 .offload_read_recv_fn = smb_full_audit_offload_read_recv,
2581 .offload_write_send_fn = smb_full_audit_offload_write_send,
2582 .offload_write_recv_fn = smb_full_audit_offload_write_recv,
2583 .get_compression_fn = smb_full_audit_get_compression,
2584 .set_compression_fn = smb_full_audit_set_compression,
2585 .snap_check_path_fn = smb_full_audit_snap_check_path,
2586 .snap_create_fn = smb_full_audit_snap_create,
2587 .snap_delete_fn = smb_full_audit_snap_delete,
2588 .streaminfo_fn = smb_full_audit_streaminfo,
2589 .get_real_filename_fn = smb_full_audit_get_real_filename,
2590 .connectpath_fn = smb_full_audit_connectpath,
2591 .brl_lock_windows_fn = smb_full_audit_brl_lock_windows,
2592 .brl_unlock_windows_fn = smb_full_audit_brl_unlock_windows,
2593 .brl_cancel_windows_fn = smb_full_audit_brl_cancel_windows,
2594 .strict_lock_fn = smb_full_audit_strict_lock,
2595 .strict_unlock_fn = smb_full_audit_strict_unlock,
2596 .translate_name_fn = smb_full_audit_translate_name,
2597 .fsctl_fn = smb_full_audit_fsctl,
2598 .get_dos_attributes_fn = smb_full_audit_get_dos_attributes,
2599 .fget_dos_attributes_fn = smb_full_audit_fget_dos_attributes,
2600 .set_dos_attributes_fn = smb_full_audit_set_dos_attributes,
2601 .fset_dos_attributes_fn = smb_full_audit_fset_dos_attributes,
2602 .fget_nt_acl_fn = smb_full_audit_fget_nt_acl,
2603 .get_nt_acl_fn = smb_full_audit_get_nt_acl,
2604 .fset_nt_acl_fn = smb_full_audit_fset_nt_acl,
2605 .audit_file_fn = smb_full_audit_audit_file,
2606 .chmod_acl_fn = smb_full_audit_chmod_acl,
2607 .fchmod_acl_fn = smb_full_audit_fchmod_acl,
2608 .sys_acl_get_file_fn = smb_full_audit_sys_acl_get_file,
2609 .sys_acl_get_fd_fn = smb_full_audit_sys_acl_get_fd,
2610 .sys_acl_blob_get_file_fn = smb_full_audit_sys_acl_blob_get_file,
2611 .sys_acl_blob_get_fd_fn = smb_full_audit_sys_acl_blob_get_fd,
2612 .sys_acl_set_file_fn = smb_full_audit_sys_acl_set_file,
2613 .sys_acl_set_fd_fn = smb_full_audit_sys_acl_set_fd,
2614 .sys_acl_delete_def_file_fn = smb_full_audit_sys_acl_delete_def_file,
2615 .getxattr_fn = smb_full_audit_getxattr,
2616 .fgetxattr_fn = smb_full_audit_fgetxattr,
2617 .listxattr_fn = smb_full_audit_listxattr,
2618 .flistxattr_fn = smb_full_audit_flistxattr,
2619 .removexattr_fn = smb_full_audit_removexattr,
2620 .fremovexattr_fn = smb_full_audit_fremovexattr,
2621 .setxattr_fn = smb_full_audit_setxattr,
2622 .fsetxattr_fn = smb_full_audit_fsetxattr,
2623 .aio_force_fn = smb_full_audit_aio_force,
2624 .durable_cookie_fn = smb_full_audit_durable_cookie,
2625 .durable_disconnect_fn = smb_full_audit_durable_disconnect,
2626 .durable_reconnect_fn = smb_full_audit_durable_reconnect,
2627 .readdir_attr_fn = smb_full_audit_readdir_attr
2632 NTSTATUS vfs_full_audit_init(TALLOC_CTX *ctx)
2636 smb_vfs_assert_all_fns(&vfs_full_audit_fns, "full_audit");
2638 ret = smb_register_vfs(SMB_VFS_INTERFACE_VERSION, "full_audit",
2639 &vfs_full_audit_fns);
2641 if (!NT_STATUS_IS_OK(ret))
2644 vfs_full_audit_debug_level = debug_add_class("full_audit");
2645 if (vfs_full_audit_debug_level == -1) {
2646 vfs_full_audit_debug_level = DBGC_VFS;
2647 DEBUG(0, ("vfs_full_audit: Couldn't register custom debugging "
2650 DEBUG(10, ("vfs_full_audit: Debug class number of "
2651 "'full_audit': %d\n", vfs_full_audit_debug_level));