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_COPY_CHUNK_SEND,
172 SMB_VFS_OP_COPY_CHUNK_RECV,
173 SMB_VFS_OP_GET_COMPRESSION,
174 SMB_VFS_OP_SET_COMPRESSION,
175 SMB_VFS_OP_SNAP_CHECK_PATH,
176 SMB_VFS_OP_SNAP_CREATE,
177 SMB_VFS_OP_SNAP_DELETE,
179 /* DOS attribute operations. */
180 SMB_VFS_OP_GET_DOS_ATTRIBUTES,
181 SMB_VFS_OP_FGET_DOS_ATTRIBUTES,
182 SMB_VFS_OP_SET_DOS_ATTRIBUTES,
183 SMB_VFS_OP_FSET_DOS_ATTRIBUTES,
185 /* NT ACL operations. */
187 SMB_VFS_OP_FGET_NT_ACL,
188 SMB_VFS_OP_GET_NT_ACL,
189 SMB_VFS_OP_FSET_NT_ACL,
190 SMB_VFS_OP_AUDIT_FILE,
192 /* POSIX ACL operations. */
194 SMB_VFS_OP_CHMOD_ACL,
195 SMB_VFS_OP_FCHMOD_ACL,
197 SMB_VFS_OP_SYS_ACL_GET_FILE,
198 SMB_VFS_OP_SYS_ACL_GET_FD,
199 SMB_VFS_OP_SYS_ACL_BLOB_GET_FILE,
200 SMB_VFS_OP_SYS_ACL_BLOB_GET_FD,
201 SMB_VFS_OP_SYS_ACL_SET_FILE,
202 SMB_VFS_OP_SYS_ACL_SET_FD,
203 SMB_VFS_OP_SYS_ACL_DELETE_DEF_FILE,
207 SMB_VFS_OP_FGETXATTR,
208 SMB_VFS_OP_LISTXATTR,
209 SMB_VFS_OP_FLISTXATTR,
210 SMB_VFS_OP_REMOVEXATTR,
211 SMB_VFS_OP_FREMOVEXATTR,
213 SMB_VFS_OP_FSETXATTR,
216 SMB_VFS_OP_AIO_FORCE,
218 /* offline operations */
219 SMB_VFS_OP_IS_OFFLINE,
220 SMB_VFS_OP_SET_OFFLINE,
222 /* Durable handle operations. */
223 SMB_VFS_OP_DURABLE_COOKIE,
224 SMB_VFS_OP_DURABLE_DISCONNECT,
225 SMB_VFS_OP_DURABLE_RECONNECT,
227 SMB_VFS_OP_READDIR_ATTR,
229 /* This should always be last enum value */
234 /* The following array *must* be in the same order as defined in vfs_op_type */
240 { SMB_VFS_OP_CONNECT, "connect" },
241 { SMB_VFS_OP_DISCONNECT, "disconnect" },
242 { SMB_VFS_OP_DISK_FREE, "disk_free" },
243 { SMB_VFS_OP_GET_QUOTA, "get_quota" },
244 { SMB_VFS_OP_SET_QUOTA, "set_quota" },
245 { SMB_VFS_OP_GET_SHADOW_COPY_DATA, "get_shadow_copy_data" },
246 { SMB_VFS_OP_STATVFS, "statvfs" },
247 { SMB_VFS_OP_FS_CAPABILITIES, "fs_capabilities" },
248 { SMB_VFS_OP_GET_DFS_REFERRALS, "get_dfs_referrals" },
249 { SMB_VFS_OP_OPENDIR, "opendir" },
250 { SMB_VFS_OP_FDOPENDIR, "fdopendir" },
251 { SMB_VFS_OP_READDIR, "readdir" },
252 { SMB_VFS_OP_SEEKDIR, "seekdir" },
253 { SMB_VFS_OP_TELLDIR, "telldir" },
254 { SMB_VFS_OP_REWINDDIR, "rewinddir" },
255 { SMB_VFS_OP_MKDIR, "mkdir" },
256 { SMB_VFS_OP_RMDIR, "rmdir" },
257 { SMB_VFS_OP_CLOSEDIR, "closedir" },
258 { SMB_VFS_OP_INIT_SEARCH_OP, "init_search_op" },
259 { SMB_VFS_OP_OPEN, "open" },
260 { SMB_VFS_OP_CREATE_FILE, "create_file" },
261 { SMB_VFS_OP_CLOSE, "close" },
262 { SMB_VFS_OP_READ, "read" },
263 { SMB_VFS_OP_PREAD, "pread" },
264 { SMB_VFS_OP_PREAD_SEND, "pread_send" },
265 { SMB_VFS_OP_PREAD_RECV, "pread_recv" },
266 { SMB_VFS_OP_WRITE, "write" },
267 { SMB_VFS_OP_PWRITE, "pwrite" },
268 { SMB_VFS_OP_PWRITE_SEND, "pwrite_send" },
269 { SMB_VFS_OP_PWRITE_RECV, "pwrite_recv" },
270 { SMB_VFS_OP_LSEEK, "lseek" },
271 { SMB_VFS_OP_SENDFILE, "sendfile" },
272 { SMB_VFS_OP_RECVFILE, "recvfile" },
273 { SMB_VFS_OP_RENAME, "rename" },
274 { SMB_VFS_OP_FSYNC, "fsync" },
275 { SMB_VFS_OP_FSYNC_SEND, "fsync_send" },
276 { SMB_VFS_OP_FSYNC_RECV, "fsync_recv" },
277 { SMB_VFS_OP_STAT, "stat" },
278 { SMB_VFS_OP_FSTAT, "fstat" },
279 { SMB_VFS_OP_LSTAT, "lstat" },
280 { SMB_VFS_OP_GET_ALLOC_SIZE, "get_alloc_size" },
281 { SMB_VFS_OP_UNLINK, "unlink" },
282 { SMB_VFS_OP_CHMOD, "chmod" },
283 { SMB_VFS_OP_FCHMOD, "fchmod" },
284 { SMB_VFS_OP_CHOWN, "chown" },
285 { SMB_VFS_OP_FCHOWN, "fchown" },
286 { SMB_VFS_OP_LCHOWN, "lchown" },
287 { SMB_VFS_OP_CHDIR, "chdir" },
288 { SMB_VFS_OP_GETWD, "getwd" },
289 { SMB_VFS_OP_NTIMES, "ntimes" },
290 { SMB_VFS_OP_FTRUNCATE, "ftruncate" },
291 { SMB_VFS_OP_FALLOCATE,"fallocate" },
292 { SMB_VFS_OP_LOCK, "lock" },
293 { SMB_VFS_OP_KERNEL_FLOCK, "kernel_flock" },
294 { SMB_VFS_OP_LINUX_SETLEASE, "linux_setlease" },
295 { SMB_VFS_OP_GETLOCK, "getlock" },
296 { SMB_VFS_OP_SYMLINK, "symlink" },
297 { SMB_VFS_OP_READLINK, "readlink" },
298 { SMB_VFS_OP_LINK, "link" },
299 { SMB_VFS_OP_MKNOD, "mknod" },
300 { SMB_VFS_OP_REALPATH, "realpath" },
301 { SMB_VFS_OP_CHFLAGS, "chflags" },
302 { SMB_VFS_OP_FILE_ID_CREATE, "file_id_create" },
303 { SMB_VFS_OP_STREAMINFO, "streaminfo" },
304 { SMB_VFS_OP_GET_REAL_FILENAME, "get_real_filename" },
305 { SMB_VFS_OP_CONNECTPATH, "connectpath" },
306 { SMB_VFS_OP_BRL_LOCK_WINDOWS, "brl_lock_windows" },
307 { SMB_VFS_OP_BRL_UNLOCK_WINDOWS, "brl_unlock_windows" },
308 { SMB_VFS_OP_BRL_CANCEL_WINDOWS, "brl_cancel_windows" },
309 { SMB_VFS_OP_STRICT_LOCK, "strict_lock" },
310 { SMB_VFS_OP_STRICT_UNLOCK, "strict_unlock" },
311 { SMB_VFS_OP_TRANSLATE_NAME, "translate_name" },
312 { SMB_VFS_OP_FSCTL, "fsctl" },
313 { SMB_VFS_OP_COPY_CHUNK_SEND, "copy_chunk_send" },
314 { SMB_VFS_OP_COPY_CHUNK_RECV, "copy_chunk_recv" },
315 { SMB_VFS_OP_GET_COMPRESSION, "get_compression" },
316 { SMB_VFS_OP_SET_COMPRESSION, "set_compression" },
317 { SMB_VFS_OP_SNAP_CHECK_PATH, "snap_check_path" },
318 { SMB_VFS_OP_SNAP_CREATE, "snap_create" },
319 { SMB_VFS_OP_SNAP_DELETE, "snap_delete" },
320 { SMB_VFS_OP_GET_DOS_ATTRIBUTES, "get_dos_attributes" },
321 { SMB_VFS_OP_FGET_DOS_ATTRIBUTES, "fget_dos_attributes" },
322 { SMB_VFS_OP_SET_DOS_ATTRIBUTES, "set_dos_attributes" },
323 { SMB_VFS_OP_FSET_DOS_ATTRIBUTES, "fset_dos_attributes" },
324 { SMB_VFS_OP_FGET_NT_ACL, "fget_nt_acl" },
325 { SMB_VFS_OP_GET_NT_ACL, "get_nt_acl" },
326 { SMB_VFS_OP_FSET_NT_ACL, "fset_nt_acl" },
327 { SMB_VFS_OP_AUDIT_FILE, "audit_file" },
328 { SMB_VFS_OP_CHMOD_ACL, "chmod_acl" },
329 { SMB_VFS_OP_FCHMOD_ACL, "fchmod_acl" },
330 { SMB_VFS_OP_SYS_ACL_GET_FILE, "sys_acl_get_file" },
331 { SMB_VFS_OP_SYS_ACL_GET_FD, "sys_acl_get_fd" },
332 { SMB_VFS_OP_SYS_ACL_BLOB_GET_FILE, "sys_acl_blob_get_file" },
333 { SMB_VFS_OP_SYS_ACL_BLOB_GET_FD, "sys_acl_blob_get_fd" },
334 { SMB_VFS_OP_SYS_ACL_SET_FILE, "sys_acl_set_file" },
335 { SMB_VFS_OP_SYS_ACL_SET_FD, "sys_acl_set_fd" },
336 { SMB_VFS_OP_SYS_ACL_DELETE_DEF_FILE, "sys_acl_delete_def_file" },
337 { SMB_VFS_OP_GETXATTR, "getxattr" },
338 { SMB_VFS_OP_FGETXATTR, "fgetxattr" },
339 { SMB_VFS_OP_LISTXATTR, "listxattr" },
340 { SMB_VFS_OP_FLISTXATTR, "flistxattr" },
341 { SMB_VFS_OP_REMOVEXATTR, "removexattr" },
342 { SMB_VFS_OP_FREMOVEXATTR, "fremovexattr" },
343 { SMB_VFS_OP_SETXATTR, "setxattr" },
344 { SMB_VFS_OP_FSETXATTR, "fsetxattr" },
345 { SMB_VFS_OP_AIO_FORCE, "aio_force" },
346 { SMB_VFS_OP_IS_OFFLINE, "is_offline" },
347 { SMB_VFS_OP_SET_OFFLINE, "set_offline" },
348 { SMB_VFS_OP_DURABLE_COOKIE, "durable_cookie" },
349 { SMB_VFS_OP_DURABLE_DISCONNECT, "durable_disconnect" },
350 { SMB_VFS_OP_DURABLE_RECONNECT, "durable_reconnect" },
351 { SMB_VFS_OP_READDIR_ATTR, "readdir_attr" },
352 { SMB_VFS_OP_LAST, NULL }
355 static int audit_syslog_facility(vfs_handle_struct *handle)
357 static const struct enum_list enum_log_facilities[] = {
358 { LOG_USER, "USER" },
359 { LOG_LOCAL0, "LOCAL0" },
360 { LOG_LOCAL1, "LOCAL1" },
361 { LOG_LOCAL2, "LOCAL2" },
362 { LOG_LOCAL3, "LOCAL3" },
363 { LOG_LOCAL4, "LOCAL4" },
364 { LOG_LOCAL5, "LOCAL5" },
365 { LOG_LOCAL6, "LOCAL6" },
366 { LOG_LOCAL7, "LOCAL7" },
372 facility = lp_parm_enum(SNUM(handle->conn), "full_audit", "facility", enum_log_facilities, LOG_USER);
377 static int audit_syslog_priority(vfs_handle_struct *handle)
379 static const struct enum_list enum_log_priorities[] = {
380 { LOG_EMERG, "EMERG" },
381 { LOG_ALERT, "ALERT" },
382 { LOG_CRIT, "CRIT" },
384 { LOG_WARNING, "WARNING" },
385 { LOG_NOTICE, "NOTICE" },
386 { LOG_INFO, "INFO" },
387 { LOG_DEBUG, "DEBUG" },
393 priority = lp_parm_enum(SNUM(handle->conn), "full_audit", "priority",
394 enum_log_priorities, LOG_NOTICE);
395 if (priority == -1) {
396 priority = LOG_WARNING;
402 static char *audit_prefix(TALLOC_CTX *ctx, connection_struct *conn)
407 prefix = talloc_strdup(ctx,
408 lp_parm_const_string(SNUM(conn), "full_audit",
413 result = talloc_sub_advanced(ctx,
414 lp_servicename(talloc_tos(), SNUM(conn)),
415 conn->session_info->unix_info->unix_name,
417 conn->session_info->unix_token->gid,
418 conn->session_info->unix_info->sanitized_username,
419 conn->session_info->info->domain_name,
425 static bool log_success(struct vfs_full_audit_private_data *pd, vfs_op_type op)
427 if (pd->success_ops == NULL) {
431 return bitmap_query(pd->success_ops, op);
434 static bool log_failure(struct vfs_full_audit_private_data *pd, vfs_op_type op)
436 if (pd->failure_ops == NULL)
439 return bitmap_query(pd->failure_ops, op);
442 static struct bitmap *init_bitmap(TALLOC_CTX *mem_ctx, const char **ops)
450 bm = bitmap_talloc(mem_ctx, SMB_VFS_OP_LAST);
452 DEBUG(0, ("Could not alloc bitmap -- "
453 "defaulting to logging everything\n"));
457 for (; *ops != NULL; ops += 1) {
462 if (strequal(*ops, "all")) {
463 for (i=0; i<SMB_VFS_OP_LAST; i++) {
469 if (strequal(*ops, "none")) {
479 for (i=0; i<SMB_VFS_OP_LAST; i++) {
480 if ((vfs_op_names[i].name == NULL)
481 || (vfs_op_names[i].type != i)) {
482 smb_panic("vfs_full_audit.c: name table not "
483 "in sync with vfs_op_type enums\n");
485 if (strequal(op, vfs_op_names[i].name)) {
494 if (i == SMB_VFS_OP_LAST) {
495 DEBUG(0, ("Could not find opname %s, logging all\n",
504 static const char *audit_opname(vfs_op_type op)
506 if (op >= SMB_VFS_OP_LAST)
507 return "INVALID VFS OP";
508 return vfs_op_names[op].name;
511 static TALLOC_CTX *tmp_do_log_ctx;
513 * Get us a temporary talloc context usable just for DEBUG arguments
515 static TALLOC_CTX *do_log_ctx(void)
517 if (tmp_do_log_ctx == NULL) {
518 tmp_do_log_ctx = talloc_named_const(NULL, 0, "do_log_ctx");
520 return tmp_do_log_ctx;
523 static void do_log(vfs_op_type op, bool success, vfs_handle_struct *handle,
524 const char *format, ...)
526 struct vfs_full_audit_private_data *pd;
528 char *audit_pre = NULL;
532 SMB_VFS_HANDLE_GET_DATA(handle, pd,
533 struct vfs_full_audit_private_data,
536 if (success && (!log_success(pd, op)))
539 if (!success && (!log_failure(pd, op)))
543 fstrcpy(err_msg, "ok");
545 fstr_sprintf(err_msg, "fail (%s)", strerror(errno));
547 va_start(ap, format);
548 op_msg = talloc_vasprintf(talloc_tos(), format, ap);
555 audit_pre = audit_prefix(talloc_tos(), handle->conn);
561 * Specify the facility to interoperate with other syslog
562 * callers (smbd for example).
564 priority = pd->syslog_priority | pd->syslog_facility;
566 syslog(priority, "%s|%s|%s|%s\n",
567 audit_pre ? audit_pre : "",
568 audit_opname(op), err_msg, op_msg);
570 DEBUG(1, ("%s|%s|%s|%s\n",
571 audit_pre ? audit_pre : "",
572 audit_opname(op), err_msg, op_msg));
575 TALLOC_FREE(audit_pre);
577 TALLOC_FREE(tmp_do_log_ctx);
581 * Return a string using the do_log_ctx()
583 static const char *smb_fname_str_do_log(const struct smb_filename *smb_fname)
588 if (smb_fname == NULL) {
591 status = get_full_smb_filename(do_log_ctx(), smb_fname, &fname);
592 if (!NT_STATUS_IS_OK(status)) {
599 * Return an fsp debug string using the do_log_ctx()
601 static const char *fsp_str_do_log(const struct files_struct *fsp)
603 return smb_fname_str_do_log(fsp->fsp_name);
606 /* Implementation of vfs_ops. Pass everything on to the default
607 operation but log event first. */
609 static int smb_full_audit_connect(vfs_handle_struct *handle,
610 const char *svc, const char *user)
613 struct vfs_full_audit_private_data *pd = NULL;
615 result = SMB_VFS_NEXT_CONNECT(handle, svc, user);
620 pd = talloc_zero(handle, struct vfs_full_audit_private_data);
622 SMB_VFS_NEXT_DISCONNECT(handle);
626 pd->syslog_facility = audit_syslog_facility(handle);
627 if (pd->syslog_facility == -1) {
628 DEBUG(1, ("%s: Unknown facility %s\n", __func__,
629 lp_parm_const_string(SNUM(handle->conn),
630 "full_audit", "facility",
632 SMB_VFS_NEXT_DISCONNECT(handle);
636 pd->syslog_priority = audit_syslog_priority(handle);
638 pd->log_secdesc = lp_parm_bool(SNUM(handle->conn),
639 "full_audit", "log_secdesc", false);
641 pd->do_syslog = lp_parm_bool(SNUM(handle->conn),
642 "full_audit", "syslog", true);
646 openlog("smbd_audit", 0, pd->syslog_facility);
650 pd->success_ops = init_bitmap(
651 pd, lp_parm_string_list(SNUM(handle->conn), "full_audit",
653 pd->failure_ops = init_bitmap(
654 pd, lp_parm_string_list(SNUM(handle->conn), "full_audit",
657 /* Store the private data. */
658 SMB_VFS_HANDLE_SET_DATA(handle, pd, NULL,
659 struct vfs_full_audit_private_data, return -1);
661 do_log(SMB_VFS_OP_CONNECT, True, handle,
667 static void smb_full_audit_disconnect(vfs_handle_struct *handle)
669 SMB_VFS_NEXT_DISCONNECT(handle);
671 do_log(SMB_VFS_OP_DISCONNECT, True, handle,
672 "%s", lp_servicename(talloc_tos(), SNUM(handle->conn)));
674 /* The bitmaps will be disconnected when the private
678 static uint64_t smb_full_audit_disk_free(vfs_handle_struct *handle,
679 const struct smb_filename *smb_fname,
686 result = SMB_VFS_NEXT_DISK_FREE(handle, smb_fname, bsize, dfree, dsize);
688 /* Don't have a reasonable notion of failure here */
690 do_log(SMB_VFS_OP_DISK_FREE, True, handle, "%s", smb_fname->base_name);
695 static int smb_full_audit_get_quota(struct vfs_handle_struct *handle,
696 const struct smb_filename *smb_fname,
697 enum SMB_QUOTA_TYPE qtype,
703 result = SMB_VFS_NEXT_GET_QUOTA(handle, smb_fname, qtype, id, qt);
705 do_log(SMB_VFS_OP_GET_QUOTA, (result >= 0), handle, "%s",
706 smb_fname->base_name);
711 static int smb_full_audit_set_quota(struct vfs_handle_struct *handle,
712 enum SMB_QUOTA_TYPE qtype, unid_t id,
717 result = SMB_VFS_NEXT_SET_QUOTA(handle, qtype, id, qt);
719 do_log(SMB_VFS_OP_SET_QUOTA, (result >= 0), handle, "");
724 static int smb_full_audit_get_shadow_copy_data(struct vfs_handle_struct *handle,
725 struct files_struct *fsp,
726 struct shadow_copy_data *shadow_copy_data,
731 result = SMB_VFS_NEXT_GET_SHADOW_COPY_DATA(handle, fsp, shadow_copy_data, labels);
733 do_log(SMB_VFS_OP_GET_SHADOW_COPY_DATA, (result >= 0), handle, "");
738 static int smb_full_audit_statvfs(struct vfs_handle_struct *handle,
739 const struct smb_filename *smb_fname,
740 struct vfs_statvfs_struct *statbuf)
744 result = SMB_VFS_NEXT_STATVFS(handle, smb_fname, statbuf);
746 do_log(SMB_VFS_OP_STATVFS, (result >= 0), handle, "");
751 static uint32_t smb_full_audit_fs_capabilities(struct vfs_handle_struct *handle, enum timestamp_set_resolution *p_ts_res)
755 result = SMB_VFS_NEXT_FS_CAPABILITIES(handle, p_ts_res);
757 do_log(SMB_VFS_OP_FS_CAPABILITIES, true, handle, "");
762 static NTSTATUS smb_full_audit_get_dfs_referrals(
763 struct vfs_handle_struct *handle,
764 struct dfs_GetDFSReferral *r)
768 status = SMB_VFS_NEXT_GET_DFS_REFERRALS(handle, r);
770 do_log(SMB_VFS_OP_GET_DFS_REFERRALS, NT_STATUS_IS_OK(status),
776 static NTSTATUS smb_full_audit_snap_check_path(struct vfs_handle_struct *handle,
778 const char *service_path,
783 status = SMB_VFS_NEXT_SNAP_CHECK_PATH(handle, mem_ctx, service_path,
785 do_log(SMB_VFS_OP_SNAP_CHECK_PATH, NT_STATUS_IS_OK(status),
791 static NTSTATUS smb_full_audit_snap_create(struct vfs_handle_struct *handle,
793 const char *base_volume,
801 status = SMB_VFS_NEXT_SNAP_CREATE(handle, mem_ctx, base_volume, tstamp,
802 rw, base_path, snap_path);
803 do_log(SMB_VFS_OP_SNAP_CREATE, NT_STATUS_IS_OK(status), handle, "");
808 static NTSTATUS smb_full_audit_snap_delete(struct vfs_handle_struct *handle,
815 status = SMB_VFS_NEXT_SNAP_DELETE(handle, mem_ctx, base_path,
817 do_log(SMB_VFS_OP_SNAP_DELETE, NT_STATUS_IS_OK(status), handle, "");
822 static DIR *smb_full_audit_opendir(vfs_handle_struct *handle,
823 const struct smb_filename *smb_fname,
829 result = SMB_VFS_NEXT_OPENDIR(handle, smb_fname, mask, attr);
831 do_log(SMB_VFS_OP_OPENDIR, (result != NULL), handle, "%s",
832 smb_fname->base_name);
837 static DIR *smb_full_audit_fdopendir(vfs_handle_struct *handle,
838 files_struct *fsp, const char *mask, uint32_t attr)
842 result = SMB_VFS_NEXT_FDOPENDIR(handle, fsp, mask, attr);
844 do_log(SMB_VFS_OP_FDOPENDIR, (result != NULL), handle, "%s",
845 fsp_str_do_log(fsp));
850 static struct dirent *smb_full_audit_readdir(vfs_handle_struct *handle,
851 DIR *dirp, SMB_STRUCT_STAT *sbuf)
853 struct dirent *result;
855 result = SMB_VFS_NEXT_READDIR(handle, dirp, sbuf);
857 /* This operation has no reasonable error condition
858 * (End of dir is also failure), so always succeed.
860 do_log(SMB_VFS_OP_READDIR, True, handle, "");
865 static void smb_full_audit_seekdir(vfs_handle_struct *handle,
866 DIR *dirp, long offset)
868 SMB_VFS_NEXT_SEEKDIR(handle, dirp, offset);
870 do_log(SMB_VFS_OP_SEEKDIR, True, handle, "");
873 static long smb_full_audit_telldir(vfs_handle_struct *handle,
878 result = SMB_VFS_NEXT_TELLDIR(handle, dirp);
880 do_log(SMB_VFS_OP_TELLDIR, True, handle, "");
885 static void smb_full_audit_rewinddir(vfs_handle_struct *handle,
888 SMB_VFS_NEXT_REWINDDIR(handle, dirp);
890 do_log(SMB_VFS_OP_REWINDDIR, True, handle, "");
893 static int smb_full_audit_mkdir(vfs_handle_struct *handle,
894 const struct smb_filename *smb_fname, mode_t mode)
898 result = SMB_VFS_NEXT_MKDIR(handle, smb_fname, mode);
900 do_log(SMB_VFS_OP_MKDIR, (result >= 0), handle, "%s",
901 smb_fname->base_name);
906 static int smb_full_audit_rmdir(vfs_handle_struct *handle,
907 const struct smb_filename *smb_fname)
911 result = SMB_VFS_NEXT_RMDIR(handle, smb_fname);
913 do_log(SMB_VFS_OP_RMDIR, (result >= 0), handle, "%s",
914 smb_fname->base_name);
919 static int smb_full_audit_closedir(vfs_handle_struct *handle,
924 result = SMB_VFS_NEXT_CLOSEDIR(handle, dirp);
926 do_log(SMB_VFS_OP_CLOSEDIR, (result >= 0), handle, "");
931 static void smb_full_audit_init_search_op(vfs_handle_struct *handle,
934 SMB_VFS_NEXT_INIT_SEARCH_OP(handle, dirp);
936 do_log(SMB_VFS_OP_INIT_SEARCH_OP, True, handle, "");
939 static int smb_full_audit_open(vfs_handle_struct *handle,
940 struct smb_filename *smb_fname,
941 files_struct *fsp, int flags, mode_t mode)
945 result = SMB_VFS_NEXT_OPEN(handle, smb_fname, fsp, flags, mode);
947 do_log(SMB_VFS_OP_OPEN, (result >= 0), handle, "%s|%s",
948 ((flags & O_WRONLY) || (flags & O_RDWR))?"w":"r",
949 smb_fname_str_do_log(smb_fname));
954 static NTSTATUS smb_full_audit_create_file(vfs_handle_struct *handle,
955 struct smb_request *req,
956 uint16_t root_dir_fid,
957 struct smb_filename *smb_fname,
958 uint32_t access_mask,
959 uint32_t share_access,
960 uint32_t create_disposition,
961 uint32_t create_options,
962 uint32_t file_attributes,
963 uint32_t oplock_request,
964 struct smb2_lease *lease,
965 uint64_t allocation_size,
966 uint32_t private_flags,
967 struct security_descriptor *sd,
968 struct ea_list *ea_list,
969 files_struct **result_fsp,
971 const struct smb2_create_blobs *in_context_blobs,
972 struct smb2_create_blobs *out_context_blobs)
975 const char* str_create_disposition;
977 switch (create_disposition) {
979 str_create_disposition = "supersede";
981 case FILE_OVERWRITE_IF:
982 str_create_disposition = "overwrite_if";
985 str_create_disposition = "open";
988 str_create_disposition = "overwrite";
991 str_create_disposition = "create";
994 str_create_disposition = "open_if";
997 str_create_disposition = "unknown";
1000 result = SMB_VFS_NEXT_CREATE_FILE(
1001 handle, /* handle */
1003 root_dir_fid, /* root_dir_fid */
1004 smb_fname, /* fname */
1005 access_mask, /* access_mask */
1006 share_access, /* share_access */
1007 create_disposition, /* create_disposition*/
1008 create_options, /* create_options */
1009 file_attributes, /* file_attributes */
1010 oplock_request, /* oplock_request */
1012 allocation_size, /* allocation_size */
1015 ea_list, /* ea_list */
1016 result_fsp, /* result */
1018 in_context_blobs, out_context_blobs); /* create context */
1020 do_log(SMB_VFS_OP_CREATE_FILE, (NT_STATUS_IS_OK(result)), handle,
1021 "0x%x|%s|%s|%s", access_mask,
1022 create_options & FILE_DIRECTORY_FILE ? "dir" : "file",
1023 str_create_disposition, smb_fname_str_do_log(smb_fname));
1028 static int smb_full_audit_close(vfs_handle_struct *handle, files_struct *fsp)
1032 result = SMB_VFS_NEXT_CLOSE(handle, fsp);
1034 do_log(SMB_VFS_OP_CLOSE, (result >= 0), handle, "%s",
1035 fsp_str_do_log(fsp));
1040 static ssize_t smb_full_audit_read(vfs_handle_struct *handle, files_struct *fsp,
1041 void *data, size_t n)
1045 result = SMB_VFS_NEXT_READ(handle, fsp, data, n);
1047 do_log(SMB_VFS_OP_READ, (result >= 0), handle, "%s",
1048 fsp_str_do_log(fsp));
1053 static ssize_t smb_full_audit_pread(vfs_handle_struct *handle, files_struct *fsp,
1054 void *data, size_t n, off_t offset)
1058 result = SMB_VFS_NEXT_PREAD(handle, fsp, data, n, offset);
1060 do_log(SMB_VFS_OP_PREAD, (result >= 0), handle, "%s",
1061 fsp_str_do_log(fsp));
1066 struct smb_full_audit_pread_state {
1067 vfs_handle_struct *handle;
1070 struct vfs_aio_state vfs_aio_state;
1073 static void smb_full_audit_pread_done(struct tevent_req *subreq);
1075 static struct tevent_req *smb_full_audit_pread_send(
1076 struct vfs_handle_struct *handle, TALLOC_CTX *mem_ctx,
1077 struct tevent_context *ev, struct files_struct *fsp,
1078 void *data, size_t n, off_t offset)
1080 struct tevent_req *req, *subreq;
1081 struct smb_full_audit_pread_state *state;
1083 req = tevent_req_create(mem_ctx, &state,
1084 struct smb_full_audit_pread_state);
1086 do_log(SMB_VFS_OP_PREAD_SEND, false, handle, "%s",
1087 fsp_str_do_log(fsp));
1090 state->handle = handle;
1093 subreq = SMB_VFS_NEXT_PREAD_SEND(state, ev, handle, fsp, data,
1095 if (tevent_req_nomem(subreq, req)) {
1096 do_log(SMB_VFS_OP_PREAD_SEND, false, handle, "%s",
1097 fsp_str_do_log(fsp));
1098 return tevent_req_post(req, ev);
1100 tevent_req_set_callback(subreq, smb_full_audit_pread_done, req);
1102 do_log(SMB_VFS_OP_PREAD_SEND, true, handle, "%s", fsp_str_do_log(fsp));
1106 static void smb_full_audit_pread_done(struct tevent_req *subreq)
1108 struct tevent_req *req = tevent_req_callback_data(
1109 subreq, struct tevent_req);
1110 struct smb_full_audit_pread_state *state = tevent_req_data(
1111 req, struct smb_full_audit_pread_state);
1113 state->ret = SMB_VFS_PREAD_RECV(subreq, &state->vfs_aio_state);
1114 TALLOC_FREE(subreq);
1115 tevent_req_done(req);
1118 static ssize_t smb_full_audit_pread_recv(struct tevent_req *req,
1119 struct vfs_aio_state *vfs_aio_state)
1121 struct smb_full_audit_pread_state *state = tevent_req_data(
1122 req, struct smb_full_audit_pread_state);
1124 if (tevent_req_is_unix_error(req, &vfs_aio_state->error)) {
1125 do_log(SMB_VFS_OP_PREAD_RECV, false, state->handle, "%s",
1126 fsp_str_do_log(state->fsp));
1130 do_log(SMB_VFS_OP_PREAD_RECV, (state->ret >= 0), state->handle, "%s",
1131 fsp_str_do_log(state->fsp));
1133 *vfs_aio_state = state->vfs_aio_state;
1137 static ssize_t smb_full_audit_write(vfs_handle_struct *handle, files_struct *fsp,
1138 const void *data, size_t n)
1142 result = SMB_VFS_NEXT_WRITE(handle, fsp, data, n);
1144 do_log(SMB_VFS_OP_WRITE, (result >= 0), handle, "%s",
1145 fsp_str_do_log(fsp));
1150 static ssize_t smb_full_audit_pwrite(vfs_handle_struct *handle, files_struct *fsp,
1151 const void *data, size_t n,
1156 result = SMB_VFS_NEXT_PWRITE(handle, fsp, data, n, offset);
1158 do_log(SMB_VFS_OP_PWRITE, (result >= 0), handle, "%s",
1159 fsp_str_do_log(fsp));
1164 struct smb_full_audit_pwrite_state {
1165 vfs_handle_struct *handle;
1168 struct vfs_aio_state vfs_aio_state;
1171 static void smb_full_audit_pwrite_done(struct tevent_req *subreq);
1173 static struct tevent_req *smb_full_audit_pwrite_send(
1174 struct vfs_handle_struct *handle, TALLOC_CTX *mem_ctx,
1175 struct tevent_context *ev, struct files_struct *fsp,
1176 const void *data, size_t n, off_t offset)
1178 struct tevent_req *req, *subreq;
1179 struct smb_full_audit_pwrite_state *state;
1181 req = tevent_req_create(mem_ctx, &state,
1182 struct smb_full_audit_pwrite_state);
1184 do_log(SMB_VFS_OP_PWRITE_SEND, false, handle, "%s",
1185 fsp_str_do_log(fsp));
1188 state->handle = handle;
1191 subreq = SMB_VFS_NEXT_PWRITE_SEND(state, ev, handle, fsp, data,
1193 if (tevent_req_nomem(subreq, req)) {
1194 do_log(SMB_VFS_OP_PWRITE_SEND, false, handle, "%s",
1195 fsp_str_do_log(fsp));
1196 return tevent_req_post(req, ev);
1198 tevent_req_set_callback(subreq, smb_full_audit_pwrite_done, req);
1200 do_log(SMB_VFS_OP_PWRITE_SEND, true, handle, "%s",
1201 fsp_str_do_log(fsp));
1205 static void smb_full_audit_pwrite_done(struct tevent_req *subreq)
1207 struct tevent_req *req = tevent_req_callback_data(
1208 subreq, struct tevent_req);
1209 struct smb_full_audit_pwrite_state *state = tevent_req_data(
1210 req, struct smb_full_audit_pwrite_state);
1212 state->ret = SMB_VFS_PWRITE_RECV(subreq, &state->vfs_aio_state);
1213 TALLOC_FREE(subreq);
1214 tevent_req_done(req);
1217 static ssize_t smb_full_audit_pwrite_recv(struct tevent_req *req,
1218 struct vfs_aio_state *vfs_aio_state)
1220 struct smb_full_audit_pwrite_state *state = tevent_req_data(
1221 req, struct smb_full_audit_pwrite_state);
1223 if (tevent_req_is_unix_error(req, &vfs_aio_state->error)) {
1224 do_log(SMB_VFS_OP_PWRITE_RECV, false, state->handle, "%s",
1225 fsp_str_do_log(state->fsp));
1229 do_log(SMB_VFS_OP_PWRITE_RECV, (state->ret >= 0), state->handle, "%s",
1230 fsp_str_do_log(state->fsp));
1232 *vfs_aio_state = state->vfs_aio_state;
1236 static off_t smb_full_audit_lseek(vfs_handle_struct *handle, files_struct *fsp,
1237 off_t offset, int whence)
1241 result = SMB_VFS_NEXT_LSEEK(handle, fsp, offset, whence);
1243 do_log(SMB_VFS_OP_LSEEK, (result != (ssize_t)-1), handle,
1244 "%s", fsp_str_do_log(fsp));
1249 static ssize_t smb_full_audit_sendfile(vfs_handle_struct *handle, int tofd,
1250 files_struct *fromfsp,
1251 const DATA_BLOB *hdr, off_t offset,
1256 result = SMB_VFS_NEXT_SENDFILE(handle, tofd, fromfsp, hdr, offset, n);
1258 do_log(SMB_VFS_OP_SENDFILE, (result >= 0), handle,
1259 "%s", fsp_str_do_log(fromfsp));
1264 static ssize_t smb_full_audit_recvfile(vfs_handle_struct *handle, int fromfd,
1265 files_struct *tofsp,
1271 result = SMB_VFS_NEXT_RECVFILE(handle, fromfd, tofsp, offset, n);
1273 do_log(SMB_VFS_OP_RECVFILE, (result >= 0), handle,
1274 "%s", fsp_str_do_log(tofsp));
1279 static int smb_full_audit_rename(vfs_handle_struct *handle,
1280 const struct smb_filename *smb_fname_src,
1281 const struct smb_filename *smb_fname_dst)
1285 result = SMB_VFS_NEXT_RENAME(handle, smb_fname_src, smb_fname_dst);
1287 do_log(SMB_VFS_OP_RENAME, (result >= 0), handle, "%s|%s",
1288 smb_fname_str_do_log(smb_fname_src),
1289 smb_fname_str_do_log(smb_fname_dst));
1294 static int smb_full_audit_fsync(vfs_handle_struct *handle, files_struct *fsp)
1298 result = SMB_VFS_NEXT_FSYNC(handle, fsp);
1300 do_log(SMB_VFS_OP_FSYNC, (result >= 0), handle, "%s",
1301 fsp_str_do_log(fsp));
1306 struct smb_full_audit_fsync_state {
1307 vfs_handle_struct *handle;
1310 struct vfs_aio_state vfs_aio_state;
1313 static void smb_full_audit_fsync_done(struct tevent_req *subreq);
1315 static struct tevent_req *smb_full_audit_fsync_send(
1316 struct vfs_handle_struct *handle, TALLOC_CTX *mem_ctx,
1317 struct tevent_context *ev, struct files_struct *fsp)
1319 struct tevent_req *req, *subreq;
1320 struct smb_full_audit_fsync_state *state;
1322 req = tevent_req_create(mem_ctx, &state,
1323 struct smb_full_audit_fsync_state);
1325 do_log(SMB_VFS_OP_FSYNC_SEND, false, handle, "%s",
1326 fsp_str_do_log(fsp));
1329 state->handle = handle;
1332 subreq = SMB_VFS_NEXT_FSYNC_SEND(state, ev, handle, fsp);
1333 if (tevent_req_nomem(subreq, req)) {
1334 do_log(SMB_VFS_OP_FSYNC_SEND, false, handle, "%s",
1335 fsp_str_do_log(fsp));
1336 return tevent_req_post(req, ev);
1338 tevent_req_set_callback(subreq, smb_full_audit_fsync_done, req);
1340 do_log(SMB_VFS_OP_FSYNC_SEND, true, handle, "%s", fsp_str_do_log(fsp));
1344 static void smb_full_audit_fsync_done(struct tevent_req *subreq)
1346 struct tevent_req *req = tevent_req_callback_data(
1347 subreq, struct tevent_req);
1348 struct smb_full_audit_fsync_state *state = tevent_req_data(
1349 req, struct smb_full_audit_fsync_state);
1351 state->ret = SMB_VFS_FSYNC_RECV(subreq, &state->vfs_aio_state);
1352 TALLOC_FREE(subreq);
1353 tevent_req_done(req);
1356 static int smb_full_audit_fsync_recv(struct tevent_req *req,
1357 struct vfs_aio_state *vfs_aio_state)
1359 struct smb_full_audit_fsync_state *state = tevent_req_data(
1360 req, struct smb_full_audit_fsync_state);
1362 if (tevent_req_is_unix_error(req, &vfs_aio_state->error)) {
1363 do_log(SMB_VFS_OP_FSYNC_RECV, false, state->handle, "%s",
1364 fsp_str_do_log(state->fsp));
1368 do_log(SMB_VFS_OP_FSYNC_RECV, (state->ret >= 0), state->handle, "%s",
1369 fsp_str_do_log(state->fsp));
1371 *vfs_aio_state = state->vfs_aio_state;
1375 static int smb_full_audit_stat(vfs_handle_struct *handle,
1376 struct smb_filename *smb_fname)
1380 result = SMB_VFS_NEXT_STAT(handle, smb_fname);
1382 do_log(SMB_VFS_OP_STAT, (result >= 0), handle, "%s",
1383 smb_fname_str_do_log(smb_fname));
1388 static int smb_full_audit_fstat(vfs_handle_struct *handle, files_struct *fsp,
1389 SMB_STRUCT_STAT *sbuf)
1393 result = SMB_VFS_NEXT_FSTAT(handle, fsp, sbuf);
1395 do_log(SMB_VFS_OP_FSTAT, (result >= 0), handle, "%s",
1396 fsp_str_do_log(fsp));
1401 static int smb_full_audit_lstat(vfs_handle_struct *handle,
1402 struct smb_filename *smb_fname)
1406 result = SMB_VFS_NEXT_LSTAT(handle, smb_fname);
1408 do_log(SMB_VFS_OP_LSTAT, (result >= 0), handle, "%s",
1409 smb_fname_str_do_log(smb_fname));
1414 static uint64_t smb_full_audit_get_alloc_size(vfs_handle_struct *handle,
1415 files_struct *fsp, const SMB_STRUCT_STAT *sbuf)
1419 result = SMB_VFS_NEXT_GET_ALLOC_SIZE(handle, fsp, sbuf);
1421 do_log(SMB_VFS_OP_GET_ALLOC_SIZE, (result != (uint64_t)-1), handle,
1427 static int smb_full_audit_unlink(vfs_handle_struct *handle,
1428 const struct smb_filename *smb_fname)
1432 result = SMB_VFS_NEXT_UNLINK(handle, smb_fname);
1434 do_log(SMB_VFS_OP_UNLINK, (result >= 0), handle, "%s",
1435 smb_fname_str_do_log(smb_fname));
1440 static int smb_full_audit_chmod(vfs_handle_struct *handle,
1441 const struct smb_filename *smb_fname,
1446 result = SMB_VFS_NEXT_CHMOD(handle, smb_fname, mode);
1448 do_log(SMB_VFS_OP_CHMOD, (result >= 0), handle, "%s|%o",
1449 smb_fname->base_name,
1455 static int smb_full_audit_fchmod(vfs_handle_struct *handle, files_struct *fsp,
1460 result = SMB_VFS_NEXT_FCHMOD(handle, fsp, mode);
1462 do_log(SMB_VFS_OP_FCHMOD, (result >= 0), handle,
1463 "%s|%o", fsp_str_do_log(fsp), mode);
1468 static int smb_full_audit_chown(vfs_handle_struct *handle,
1469 const struct smb_filename *smb_fname,
1475 result = SMB_VFS_NEXT_CHOWN(handle, smb_fname, uid, gid);
1477 do_log(SMB_VFS_OP_CHOWN, (result >= 0), handle, "%s|%ld|%ld",
1478 smb_fname->base_name, (long int)uid, (long int)gid);
1483 static int smb_full_audit_fchown(vfs_handle_struct *handle, files_struct *fsp,
1484 uid_t uid, gid_t gid)
1488 result = SMB_VFS_NEXT_FCHOWN(handle, fsp, uid, gid);
1490 do_log(SMB_VFS_OP_FCHOWN, (result >= 0), handle, "%s|%ld|%ld",
1491 fsp_str_do_log(fsp), (long int)uid, (long int)gid);
1496 static int smb_full_audit_lchown(vfs_handle_struct *handle,
1497 const struct smb_filename *smb_fname,
1503 result = SMB_VFS_NEXT_LCHOWN(handle, smb_fname, uid, gid);
1505 do_log(SMB_VFS_OP_LCHOWN, (result >= 0), handle, "%s|%ld|%ld",
1506 smb_fname->base_name, (long int)uid, (long int)gid);
1511 static int smb_full_audit_chdir(vfs_handle_struct *handle,
1512 const struct smb_filename *smb_fname)
1516 result = SMB_VFS_NEXT_CHDIR(handle, smb_fname);
1518 do_log(SMB_VFS_OP_CHDIR, (result >= 0), handle, "chdir|%s",
1519 smb_fname->base_name);
1524 static struct smb_filename *smb_full_audit_getwd(vfs_handle_struct *handle,
1527 struct smb_filename *result;
1529 result = SMB_VFS_NEXT_GETWD(handle, ctx);
1531 do_log(SMB_VFS_OP_GETWD, (result != NULL), handle, "%s",
1532 result == NULL? "" : result->base_name);
1537 static int smb_full_audit_ntimes(vfs_handle_struct *handle,
1538 const struct smb_filename *smb_fname,
1539 struct smb_file_time *ft)
1543 result = SMB_VFS_NEXT_NTIMES(handle, smb_fname, ft);
1545 do_log(SMB_VFS_OP_NTIMES, (result >= 0), handle, "%s",
1546 smb_fname_str_do_log(smb_fname));
1551 static int smb_full_audit_ftruncate(vfs_handle_struct *handle, files_struct *fsp,
1556 result = SMB_VFS_NEXT_FTRUNCATE(handle, fsp, len);
1558 do_log(SMB_VFS_OP_FTRUNCATE, (result >= 0), handle,
1559 "%s", fsp_str_do_log(fsp));
1564 static int smb_full_audit_fallocate(vfs_handle_struct *handle, files_struct *fsp,
1571 result = SMB_VFS_NEXT_FALLOCATE(handle, fsp, mode, offset, len);
1573 do_log(SMB_VFS_OP_FALLOCATE, (result >= 0), handle,
1574 "%s", fsp_str_do_log(fsp));
1579 static bool smb_full_audit_lock(vfs_handle_struct *handle, files_struct *fsp,
1580 int op, off_t offset, off_t count, int type)
1584 result = SMB_VFS_NEXT_LOCK(handle, fsp, op, offset, count, type);
1586 do_log(SMB_VFS_OP_LOCK, result, handle, "%s", fsp_str_do_log(fsp));
1591 static int smb_full_audit_kernel_flock(struct vfs_handle_struct *handle,
1592 struct files_struct *fsp,
1593 uint32_t share_mode, uint32_t access_mask)
1597 result = SMB_VFS_NEXT_KERNEL_FLOCK(handle, fsp, share_mode, access_mask);
1599 do_log(SMB_VFS_OP_KERNEL_FLOCK, (result >= 0), handle, "%s",
1600 fsp_str_do_log(fsp));
1605 static int smb_full_audit_linux_setlease(vfs_handle_struct *handle, files_struct *fsp,
1610 result = SMB_VFS_NEXT_LINUX_SETLEASE(handle, fsp, leasetype);
1612 do_log(SMB_VFS_OP_LINUX_SETLEASE, (result >= 0), handle, "%s",
1613 fsp_str_do_log(fsp));
1618 static bool smb_full_audit_getlock(vfs_handle_struct *handle, files_struct *fsp,
1619 off_t *poffset, off_t *pcount, int *ptype, pid_t *ppid)
1623 result = SMB_VFS_NEXT_GETLOCK(handle, fsp, poffset, pcount, ptype, ppid);
1625 do_log(SMB_VFS_OP_GETLOCK, result, handle, "%s", fsp_str_do_log(fsp));
1630 static int smb_full_audit_symlink(vfs_handle_struct *handle,
1631 const char *link_contents,
1632 const struct smb_filename *new_smb_fname)
1636 result = SMB_VFS_NEXT_SYMLINK(handle, link_contents, new_smb_fname);
1638 do_log(SMB_VFS_OP_SYMLINK, (result >= 0), handle,
1639 "%s|%s", link_contents, new_smb_fname->base_name);
1644 static int smb_full_audit_readlink(vfs_handle_struct *handle,
1645 const struct smb_filename *smb_fname,
1651 result = SMB_VFS_NEXT_READLINK(handle, smb_fname, buf, bufsiz);
1653 do_log(SMB_VFS_OP_READLINK, (result >= 0), handle, "%s",
1654 smb_fname->base_name);
1659 static int smb_full_audit_link(vfs_handle_struct *handle,
1660 const struct smb_filename *old_smb_fname,
1661 const struct smb_filename *new_smb_fname)
1665 result = SMB_VFS_NEXT_LINK(handle, old_smb_fname, new_smb_fname);
1667 do_log(SMB_VFS_OP_LINK, (result >= 0), handle,
1668 "%s|%s", old_smb_fname->base_name, new_smb_fname->base_name);
1673 static int smb_full_audit_mknod(vfs_handle_struct *handle,
1674 const struct smb_filename *smb_fname,
1680 result = SMB_VFS_NEXT_MKNOD(handle, smb_fname, mode, dev);
1682 do_log(SMB_VFS_OP_MKNOD, (result >= 0), handle, "%s",
1683 smb_fname->base_name);
1688 static struct smb_filename *smb_full_audit_realpath(vfs_handle_struct *handle,
1690 const struct smb_filename *smb_fname)
1692 struct smb_filename *result_fname = NULL;
1694 result_fname = SMB_VFS_NEXT_REALPATH(handle, ctx, smb_fname);
1696 do_log(SMB_VFS_OP_REALPATH, (result_fname != NULL), handle, "%s",
1697 smb_fname->base_name);
1699 return result_fname;
1702 static int smb_full_audit_chflags(vfs_handle_struct *handle,
1703 const struct smb_filename *smb_fname,
1708 result = SMB_VFS_NEXT_CHFLAGS(handle, smb_fname, flags);
1710 do_log(SMB_VFS_OP_CHFLAGS, (result != 0), handle, "%s",
1711 smb_fname->base_name);
1716 static struct file_id smb_full_audit_file_id_create(struct vfs_handle_struct *handle,
1717 const SMB_STRUCT_STAT *sbuf)
1719 struct file_id id_zero;
1720 struct file_id result;
1722 ZERO_STRUCT(id_zero);
1724 result = SMB_VFS_NEXT_FILE_ID_CREATE(handle, sbuf);
1726 do_log(SMB_VFS_OP_FILE_ID_CREATE,
1727 !file_id_equal(&id_zero, &result),
1728 handle, "%s", file_id_string_tos(&result));
1733 static NTSTATUS smb_full_audit_streaminfo(vfs_handle_struct *handle,
1734 struct files_struct *fsp,
1735 const struct smb_filename *smb_fname,
1736 TALLOC_CTX *mem_ctx,
1737 unsigned int *pnum_streams,
1738 struct stream_struct **pstreams)
1742 result = SMB_VFS_NEXT_STREAMINFO(handle, fsp, smb_fname, mem_ctx,
1743 pnum_streams, pstreams);
1745 do_log(SMB_VFS_OP_STREAMINFO, NT_STATUS_IS_OK(result), handle,
1746 "%s", smb_fname->base_name);
1751 static int smb_full_audit_get_real_filename(struct vfs_handle_struct *handle,
1754 TALLOC_CTX *mem_ctx,
1759 result = SMB_VFS_NEXT_GET_REAL_FILENAME(handle, path, name, mem_ctx,
1762 do_log(SMB_VFS_OP_GET_REAL_FILENAME, (result == 0), handle,
1763 "%s/%s->%s", path, name, (result == 0) ? "" : *found_name);
1768 static const char *smb_full_audit_connectpath(vfs_handle_struct *handle,
1773 result = SMB_VFS_NEXT_CONNECTPATH(handle, fname);
1775 do_log(SMB_VFS_OP_CONNECTPATH, result != NULL, handle,
1781 static NTSTATUS smb_full_audit_brl_lock_windows(struct vfs_handle_struct *handle,
1782 struct byte_range_lock *br_lck,
1783 struct lock_struct *plock,
1788 result = SMB_VFS_NEXT_BRL_LOCK_WINDOWS(handle, br_lck, plock,
1791 do_log(SMB_VFS_OP_BRL_LOCK_WINDOWS, NT_STATUS_IS_OK(result), handle,
1792 "%s:%llu-%llu. type=%d. blocking=%d",
1793 fsp_str_do_log(brl_fsp(br_lck)),
1794 plock->start, plock->size, plock->lock_type, blocking_lock);
1799 static bool smb_full_audit_brl_unlock_windows(struct vfs_handle_struct *handle,
1800 struct messaging_context *msg_ctx,
1801 struct byte_range_lock *br_lck,
1802 const struct lock_struct *plock)
1806 result = SMB_VFS_NEXT_BRL_UNLOCK_WINDOWS(handle, msg_ctx, br_lck,
1809 do_log(SMB_VFS_OP_BRL_UNLOCK_WINDOWS, (result == 0), handle,
1810 "%s:%llu-%llu:%d", fsp_str_do_log(brl_fsp(br_lck)),
1812 plock->size, plock->lock_type);
1817 static bool smb_full_audit_brl_cancel_windows(struct vfs_handle_struct *handle,
1818 struct byte_range_lock *br_lck,
1819 struct lock_struct *plock)
1823 result = SMB_VFS_NEXT_BRL_CANCEL_WINDOWS(handle, br_lck, plock);
1825 do_log(SMB_VFS_OP_BRL_CANCEL_WINDOWS, (result == 0), handle,
1826 "%s:%llu-%llu:%d", fsp_str_do_log(brl_fsp(br_lck)),
1828 plock->size, plock->lock_type);
1833 static bool smb_full_audit_strict_lock(struct vfs_handle_struct *handle,
1834 struct files_struct *fsp,
1835 struct lock_struct *plock)
1839 result = SMB_VFS_NEXT_STRICT_LOCK(handle, fsp, plock);
1841 do_log(SMB_VFS_OP_STRICT_LOCK, result, handle,
1842 "%s:%llu-%llu:%d", fsp_str_do_log(fsp), plock->start,
1843 plock->size, plock->lock_type);
1848 static void smb_full_audit_strict_unlock(struct vfs_handle_struct *handle,
1849 struct files_struct *fsp,
1850 struct lock_struct *plock)
1852 SMB_VFS_NEXT_STRICT_UNLOCK(handle, fsp, plock);
1854 do_log(SMB_VFS_OP_STRICT_UNLOCK, true, handle,
1855 "%s:%llu-%llu:%d", fsp_str_do_log(fsp), plock->start,
1856 plock->size, plock->lock_type);
1859 static NTSTATUS smb_full_audit_translate_name(struct vfs_handle_struct *handle,
1861 enum vfs_translate_direction direction,
1862 TALLOC_CTX *mem_ctx,
1867 result = SMB_VFS_NEXT_TRANSLATE_NAME(handle, name, direction, mem_ctx,
1870 do_log(SMB_VFS_OP_TRANSLATE_NAME, NT_STATUS_IS_OK(result), handle, "");
1875 static NTSTATUS smb_full_audit_fsctl(struct vfs_handle_struct *handle,
1876 struct files_struct *fsp,
1880 const uint8_t *_in_data,
1882 uint8_t **_out_data,
1883 uint32_t max_out_len,
1888 result = SMB_VFS_NEXT_FSCTL(handle,
1899 do_log(SMB_VFS_OP_FSCTL, NT_STATUS_IS_OK(result), handle, "");
1904 static struct tevent_req *smb_full_audit_copy_chunk_send(struct vfs_handle_struct *handle,
1905 TALLOC_CTX *mem_ctx,
1906 struct tevent_context *ev,
1907 struct files_struct *src_fsp,
1909 struct files_struct *dest_fsp,
1914 struct tevent_req *req;
1916 req = SMB_VFS_NEXT_COPY_CHUNK_SEND(handle, mem_ctx, ev, src_fsp,
1917 src_off, dest_fsp, dest_off, num,
1920 do_log(SMB_VFS_OP_COPY_CHUNK_SEND, req, handle, "");
1925 static NTSTATUS smb_full_audit_copy_chunk_recv(struct vfs_handle_struct *handle,
1926 struct tevent_req *req,
1931 result = SMB_VFS_NEXT_COPY_CHUNK_RECV(handle, req, copied);
1933 do_log(SMB_VFS_OP_COPY_CHUNK_RECV, NT_STATUS_IS_OK(result), handle, "");
1938 static NTSTATUS smb_full_audit_get_compression(vfs_handle_struct *handle,
1939 TALLOC_CTX *mem_ctx,
1940 struct files_struct *fsp,
1941 struct smb_filename *smb_fname,
1942 uint16_t *_compression_fmt)
1946 result = SMB_VFS_NEXT_GET_COMPRESSION(handle, mem_ctx, fsp, smb_fname,
1949 do_log(SMB_VFS_OP_GET_COMPRESSION, NT_STATUS_IS_OK(result), handle,
1951 (fsp ? fsp_str_do_log(fsp) : smb_fname_str_do_log(smb_fname)));
1956 static NTSTATUS smb_full_audit_set_compression(vfs_handle_struct *handle,
1957 TALLOC_CTX *mem_ctx,
1958 struct files_struct *fsp,
1959 uint16_t compression_fmt)
1963 result = SMB_VFS_NEXT_SET_COMPRESSION(handle, mem_ctx, fsp,
1966 do_log(SMB_VFS_OP_SET_COMPRESSION, NT_STATUS_IS_OK(result), handle,
1967 "%s", fsp_str_do_log(fsp));
1972 static NTSTATUS smb_full_audit_readdir_attr(struct vfs_handle_struct *handle,
1973 const struct smb_filename *fname,
1974 TALLOC_CTX *mem_ctx,
1975 struct readdir_attr_data **pattr_data)
1979 status = SMB_VFS_NEXT_READDIR_ATTR(handle, fname, mem_ctx, pattr_data);
1981 do_log(SMB_VFS_OP_READDIR_ATTR, NT_STATUS_IS_OK(status), handle, "%s",
1982 smb_fname_str_do_log(fname));
1987 static NTSTATUS smb_full_audit_get_dos_attributes(
1988 struct vfs_handle_struct *handle,
1989 struct smb_filename *smb_fname,
1994 status = SMB_VFS_NEXT_GET_DOS_ATTRIBUTES(handle,
1998 do_log(SMB_VFS_OP_GET_DOS_ATTRIBUTES,
1999 NT_STATUS_IS_OK(status),
2002 smb_fname_str_do_log(smb_fname));
2007 static NTSTATUS smb_full_audit_fget_dos_attributes(
2008 struct vfs_handle_struct *handle,
2009 struct files_struct *fsp,
2014 status = SMB_VFS_NEXT_FGET_DOS_ATTRIBUTES(handle,
2018 do_log(SMB_VFS_OP_FGET_DOS_ATTRIBUTES,
2019 NT_STATUS_IS_OK(status),
2022 fsp_str_do_log(fsp));
2027 static NTSTATUS smb_full_audit_set_dos_attributes(
2028 struct vfs_handle_struct *handle,
2029 const struct smb_filename *smb_fname,
2034 status = SMB_VFS_NEXT_SET_DOS_ATTRIBUTES(handle,
2038 do_log(SMB_VFS_OP_SET_DOS_ATTRIBUTES,
2039 NT_STATUS_IS_OK(status),
2042 smb_fname_str_do_log(smb_fname));
2047 static NTSTATUS smb_full_audit_fset_dos_attributes(
2048 struct vfs_handle_struct *handle,
2049 struct files_struct *fsp,
2054 status = SMB_VFS_NEXT_FSET_DOS_ATTRIBUTES(handle,
2058 do_log(SMB_VFS_OP_FSET_DOS_ATTRIBUTES,
2059 NT_STATUS_IS_OK(status),
2062 fsp_str_do_log(fsp));
2067 static NTSTATUS smb_full_audit_fget_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
2068 uint32_t security_info,
2069 TALLOC_CTX *mem_ctx,
2070 struct security_descriptor **ppdesc)
2074 result = SMB_VFS_NEXT_FGET_NT_ACL(handle, fsp, security_info,
2077 do_log(SMB_VFS_OP_FGET_NT_ACL, NT_STATUS_IS_OK(result), handle,
2078 "%s", fsp_str_do_log(fsp));
2083 static NTSTATUS smb_full_audit_get_nt_acl(vfs_handle_struct *handle,
2084 const struct smb_filename *smb_fname,
2085 uint32_t security_info,
2086 TALLOC_CTX *mem_ctx,
2087 struct security_descriptor **ppdesc)
2091 result = SMB_VFS_NEXT_GET_NT_ACL(handle, smb_fname, security_info,
2094 do_log(SMB_VFS_OP_GET_NT_ACL, NT_STATUS_IS_OK(result), handle,
2095 "%s", smb_fname_str_do_log(smb_fname));
2100 static NTSTATUS smb_full_audit_fset_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
2101 uint32_t security_info_sent,
2102 const struct security_descriptor *psd)
2104 struct vfs_full_audit_private_data *pd;
2108 SMB_VFS_HANDLE_GET_DATA(handle, pd,
2109 struct vfs_full_audit_private_data,
2110 return NT_STATUS_INTERNAL_ERROR);
2112 if (pd->log_secdesc) {
2113 sd = sddl_encode(talloc_tos(), psd, get_global_sam_sid());
2116 result = SMB_VFS_NEXT_FSET_NT_ACL(handle, fsp, security_info_sent, psd);
2118 do_log(SMB_VFS_OP_FSET_NT_ACL, NT_STATUS_IS_OK(result), handle,
2119 "%s [%s]", fsp_str_do_log(fsp), sd ? sd : "");
2126 static NTSTATUS smb_full_audit_audit_file(struct vfs_handle_struct *handle,
2127 struct smb_filename *file,
2128 struct security_acl *sacl,
2129 uint32_t access_requested,
2130 uint32_t access_denied)
2134 result = SMB_VFS_NEXT_AUDIT_FILE(handle,
2140 do_log(SMB_VFS_OP_AUDIT_FILE, NT_STATUS_IS_OK(result), handle,
2141 "%s", smb_fname_str_do_log(file));
2146 static int smb_full_audit_chmod_acl(vfs_handle_struct *handle,
2147 const struct smb_filename *smb_fname,
2152 result = SMB_VFS_NEXT_CHMOD_ACL(handle, smb_fname, mode);
2154 do_log(SMB_VFS_OP_CHMOD_ACL, (result >= 0), handle,
2155 "%s|%o", smb_fname->base_name, mode);
2160 static int smb_full_audit_fchmod_acl(vfs_handle_struct *handle, files_struct *fsp,
2165 result = SMB_VFS_NEXT_FCHMOD_ACL(handle, fsp, mode);
2167 do_log(SMB_VFS_OP_FCHMOD_ACL, (result >= 0), handle,
2168 "%s|%o", fsp_str_do_log(fsp), mode);
2173 static SMB_ACL_T smb_full_audit_sys_acl_get_file(vfs_handle_struct *handle,
2174 const struct smb_filename *smb_fname,
2175 SMB_ACL_TYPE_T type,
2176 TALLOC_CTX *mem_ctx)
2180 result = SMB_VFS_NEXT_SYS_ACL_GET_FILE(handle, smb_fname,
2183 do_log(SMB_VFS_OP_SYS_ACL_GET_FILE, (result != NULL), handle,
2184 "%s", smb_fname->base_name);
2189 static SMB_ACL_T smb_full_audit_sys_acl_get_fd(vfs_handle_struct *handle,
2190 files_struct *fsp, TALLOC_CTX *mem_ctx)
2194 result = SMB_VFS_NEXT_SYS_ACL_GET_FD(handle, fsp, mem_ctx);
2196 do_log(SMB_VFS_OP_SYS_ACL_GET_FD, (result != NULL), handle,
2197 "%s", fsp_str_do_log(fsp));
2202 static int smb_full_audit_sys_acl_blob_get_file(vfs_handle_struct *handle,
2203 const struct smb_filename *smb_fname,
2204 TALLOC_CTX *mem_ctx,
2205 char **blob_description,
2210 result = SMB_VFS_NEXT_SYS_ACL_BLOB_GET_FILE(handle, smb_fname,
2211 mem_ctx, blob_description, blob);
2213 do_log(SMB_VFS_OP_SYS_ACL_BLOB_GET_FILE, (result >= 0), handle,
2214 "%s", smb_fname->base_name);
2219 static int smb_full_audit_sys_acl_blob_get_fd(vfs_handle_struct *handle,
2221 TALLOC_CTX *mem_ctx,
2222 char **blob_description,
2227 result = SMB_VFS_NEXT_SYS_ACL_BLOB_GET_FD(handle, fsp, mem_ctx, blob_description, blob);
2229 do_log(SMB_VFS_OP_SYS_ACL_BLOB_GET_FD, (result >= 0), handle,
2230 "%s", fsp_str_do_log(fsp));
2235 static int smb_full_audit_sys_acl_set_file(vfs_handle_struct *handle,
2236 const struct smb_filename *smb_fname,
2237 SMB_ACL_TYPE_T acltype,
2242 result = SMB_VFS_NEXT_SYS_ACL_SET_FILE(handle, smb_fname, acltype,
2245 do_log(SMB_VFS_OP_SYS_ACL_SET_FILE, (result >= 0), handle,
2246 "%s", smb_fname->base_name);
2251 static int smb_full_audit_sys_acl_set_fd(vfs_handle_struct *handle, files_struct *fsp,
2256 result = SMB_VFS_NEXT_SYS_ACL_SET_FD(handle, fsp, theacl);
2258 do_log(SMB_VFS_OP_SYS_ACL_SET_FD, (result >= 0), handle,
2259 "%s", fsp_str_do_log(fsp));
2264 static int smb_full_audit_sys_acl_delete_def_file(vfs_handle_struct *handle,
2265 const struct smb_filename *smb_fname)
2269 result = SMB_VFS_NEXT_SYS_ACL_DELETE_DEF_FILE(handle, smb_fname);
2271 do_log(SMB_VFS_OP_SYS_ACL_DELETE_DEF_FILE, (result >= 0), handle,
2272 "%s", smb_fname->base_name);
2277 static ssize_t smb_full_audit_getxattr(struct vfs_handle_struct *handle,
2278 const struct smb_filename *smb_fname,
2279 const char *name, void *value, size_t size)
2283 result = SMB_VFS_NEXT_GETXATTR(handle, smb_fname, name, value, size);
2285 do_log(SMB_VFS_OP_GETXATTR, (result >= 0), handle,
2286 "%s|%s", smb_fname->base_name, name);
2291 static ssize_t smb_full_audit_fgetxattr(struct vfs_handle_struct *handle,
2292 struct files_struct *fsp,
2293 const char *name, void *value, size_t size)
2297 result = SMB_VFS_NEXT_FGETXATTR(handle, fsp, name, value, size);
2299 do_log(SMB_VFS_OP_FGETXATTR, (result >= 0), handle,
2300 "%s|%s", fsp_str_do_log(fsp), name);
2305 static ssize_t smb_full_audit_listxattr(struct vfs_handle_struct *handle,
2306 const struct smb_filename *smb_fname,
2312 result = SMB_VFS_NEXT_LISTXATTR(handle, smb_fname, list, size);
2314 do_log(SMB_VFS_OP_LISTXATTR, (result >= 0), handle, "%s",
2315 smb_fname->base_name);
2320 static ssize_t smb_full_audit_flistxattr(struct vfs_handle_struct *handle,
2321 struct files_struct *fsp, char *list,
2326 result = SMB_VFS_NEXT_FLISTXATTR(handle, fsp, list, size);
2328 do_log(SMB_VFS_OP_FLISTXATTR, (result >= 0), handle,
2329 "%s", fsp_str_do_log(fsp));
2334 static int smb_full_audit_removexattr(struct vfs_handle_struct *handle,
2335 const struct smb_filename *smb_fname,
2340 result = SMB_VFS_NEXT_REMOVEXATTR(handle, smb_fname, name);
2342 do_log(SMB_VFS_OP_REMOVEXATTR, (result >= 0), handle,
2343 "%s|%s", smb_fname->base_name, name);
2348 static int smb_full_audit_fremovexattr(struct vfs_handle_struct *handle,
2349 struct files_struct *fsp,
2354 result = SMB_VFS_NEXT_FREMOVEXATTR(handle, fsp, name);
2356 do_log(SMB_VFS_OP_FREMOVEXATTR, (result >= 0), handle,
2357 "%s|%s", fsp_str_do_log(fsp), name);
2362 static int smb_full_audit_setxattr(struct vfs_handle_struct *handle,
2363 const struct smb_filename *smb_fname,
2364 const char *name, const void *value, size_t size,
2369 result = SMB_VFS_NEXT_SETXATTR(handle, smb_fname, name, value, size,
2372 do_log(SMB_VFS_OP_SETXATTR, (result >= 0), handle,
2373 "%s|%s", smb_fname->base_name, name);
2378 static int smb_full_audit_fsetxattr(struct vfs_handle_struct *handle,
2379 struct files_struct *fsp, const char *name,
2380 const void *value, size_t size, int flags)
2384 result = SMB_VFS_NEXT_FSETXATTR(handle, fsp, name, value, size, flags);
2386 do_log(SMB_VFS_OP_FSETXATTR, (result >= 0), handle,
2387 "%s|%s", fsp_str_do_log(fsp), name);
2392 static bool smb_full_audit_aio_force(struct vfs_handle_struct *handle,
2393 struct files_struct *fsp)
2397 result = SMB_VFS_NEXT_AIO_FORCE(handle, fsp);
2398 do_log(SMB_VFS_OP_AIO_FORCE, result, handle,
2399 "%s", fsp_str_do_log(fsp));
2404 static NTSTATUS smb_full_audit_durable_cookie(struct vfs_handle_struct *handle,
2405 struct files_struct *fsp,
2406 TALLOC_CTX *mem_ctx,
2411 result = SMB_VFS_NEXT_DURABLE_COOKIE(handle,
2416 do_log(SMB_VFS_OP_DURABLE_COOKIE, NT_STATUS_IS_OK(result), handle,
2417 "%s", fsp_str_do_log(fsp));
2422 static NTSTATUS smb_full_audit_durable_disconnect(
2423 struct vfs_handle_struct *handle,
2424 struct files_struct *fsp,
2425 const DATA_BLOB old_cookie,
2426 TALLOC_CTX *mem_ctx,
2427 DATA_BLOB *new_cookie)
2431 result = SMB_VFS_NEXT_DURABLE_DISCONNECT(handle,
2437 do_log(SMB_VFS_OP_DURABLE_DISCONNECT, NT_STATUS_IS_OK(result), handle,
2438 "%s", fsp_str_do_log(fsp));
2443 static NTSTATUS smb_full_audit_durable_reconnect(
2444 struct vfs_handle_struct *handle,
2445 struct smb_request *smb1req,
2446 struct smbXsrv_open *op,
2447 const DATA_BLOB old_cookie,
2448 TALLOC_CTX *mem_ctx,
2449 struct files_struct **fsp,
2450 DATA_BLOB *new_cookie)
2454 result = SMB_VFS_NEXT_DURABLE_RECONNECT(handle,
2462 do_log(SMB_VFS_OP_DURABLE_RECONNECT,
2463 NT_STATUS_IS_OK(result),
2470 static struct vfs_fn_pointers vfs_full_audit_fns = {
2472 /* Disk operations */
2474 .connect_fn = smb_full_audit_connect,
2475 .disconnect_fn = smb_full_audit_disconnect,
2476 .disk_free_fn = smb_full_audit_disk_free,
2477 .get_quota_fn = smb_full_audit_get_quota,
2478 .set_quota_fn = smb_full_audit_set_quota,
2479 .get_shadow_copy_data_fn = smb_full_audit_get_shadow_copy_data,
2480 .statvfs_fn = smb_full_audit_statvfs,
2481 .fs_capabilities_fn = smb_full_audit_fs_capabilities,
2482 .get_dfs_referrals_fn = smb_full_audit_get_dfs_referrals,
2483 .opendir_fn = smb_full_audit_opendir,
2484 .fdopendir_fn = smb_full_audit_fdopendir,
2485 .readdir_fn = smb_full_audit_readdir,
2486 .seekdir_fn = smb_full_audit_seekdir,
2487 .telldir_fn = smb_full_audit_telldir,
2488 .rewind_dir_fn = smb_full_audit_rewinddir,
2489 .mkdir_fn = smb_full_audit_mkdir,
2490 .rmdir_fn = smb_full_audit_rmdir,
2491 .closedir_fn = smb_full_audit_closedir,
2492 .init_search_op_fn = smb_full_audit_init_search_op,
2493 .open_fn = smb_full_audit_open,
2494 .create_file_fn = smb_full_audit_create_file,
2495 .close_fn = smb_full_audit_close,
2496 .read_fn = smb_full_audit_read,
2497 .pread_fn = smb_full_audit_pread,
2498 .pread_send_fn = smb_full_audit_pread_send,
2499 .pread_recv_fn = smb_full_audit_pread_recv,
2500 .write_fn = smb_full_audit_write,
2501 .pwrite_fn = smb_full_audit_pwrite,
2502 .pwrite_send_fn = smb_full_audit_pwrite_send,
2503 .pwrite_recv_fn = smb_full_audit_pwrite_recv,
2504 .lseek_fn = smb_full_audit_lseek,
2505 .sendfile_fn = smb_full_audit_sendfile,
2506 .recvfile_fn = smb_full_audit_recvfile,
2507 .rename_fn = smb_full_audit_rename,
2508 .fsync_fn = smb_full_audit_fsync,
2509 .fsync_send_fn = smb_full_audit_fsync_send,
2510 .fsync_recv_fn = smb_full_audit_fsync_recv,
2511 .stat_fn = smb_full_audit_stat,
2512 .fstat_fn = smb_full_audit_fstat,
2513 .lstat_fn = smb_full_audit_lstat,
2514 .get_alloc_size_fn = smb_full_audit_get_alloc_size,
2515 .unlink_fn = smb_full_audit_unlink,
2516 .chmod_fn = smb_full_audit_chmod,
2517 .fchmod_fn = smb_full_audit_fchmod,
2518 .chown_fn = smb_full_audit_chown,
2519 .fchown_fn = smb_full_audit_fchown,
2520 .lchown_fn = smb_full_audit_lchown,
2521 .chdir_fn = smb_full_audit_chdir,
2522 .getwd_fn = smb_full_audit_getwd,
2523 .ntimes_fn = smb_full_audit_ntimes,
2524 .ftruncate_fn = smb_full_audit_ftruncate,
2525 .fallocate_fn = smb_full_audit_fallocate,
2526 .lock_fn = smb_full_audit_lock,
2527 .kernel_flock_fn = smb_full_audit_kernel_flock,
2528 .linux_setlease_fn = smb_full_audit_linux_setlease,
2529 .getlock_fn = smb_full_audit_getlock,
2530 .symlink_fn = smb_full_audit_symlink,
2531 .readlink_fn = smb_full_audit_readlink,
2532 .link_fn = smb_full_audit_link,
2533 .mknod_fn = smb_full_audit_mknod,
2534 .realpath_fn = smb_full_audit_realpath,
2535 .chflags_fn = smb_full_audit_chflags,
2536 .file_id_create_fn = smb_full_audit_file_id_create,
2537 .copy_chunk_send_fn = smb_full_audit_copy_chunk_send,
2538 .copy_chunk_recv_fn = smb_full_audit_copy_chunk_recv,
2539 .get_compression_fn = smb_full_audit_get_compression,
2540 .set_compression_fn = smb_full_audit_set_compression,
2541 .snap_check_path_fn = smb_full_audit_snap_check_path,
2542 .snap_create_fn = smb_full_audit_snap_create,
2543 .snap_delete_fn = smb_full_audit_snap_delete,
2544 .streaminfo_fn = smb_full_audit_streaminfo,
2545 .get_real_filename_fn = smb_full_audit_get_real_filename,
2546 .connectpath_fn = smb_full_audit_connectpath,
2547 .brl_lock_windows_fn = smb_full_audit_brl_lock_windows,
2548 .brl_unlock_windows_fn = smb_full_audit_brl_unlock_windows,
2549 .brl_cancel_windows_fn = smb_full_audit_brl_cancel_windows,
2550 .strict_lock_fn = smb_full_audit_strict_lock,
2551 .strict_unlock_fn = smb_full_audit_strict_unlock,
2552 .translate_name_fn = smb_full_audit_translate_name,
2553 .fsctl_fn = smb_full_audit_fsctl,
2554 .get_dos_attributes_fn = smb_full_audit_get_dos_attributes,
2555 .fget_dos_attributes_fn = smb_full_audit_fget_dos_attributes,
2556 .set_dos_attributes_fn = smb_full_audit_set_dos_attributes,
2557 .fset_dos_attributes_fn = smb_full_audit_fset_dos_attributes,
2558 .fget_nt_acl_fn = smb_full_audit_fget_nt_acl,
2559 .get_nt_acl_fn = smb_full_audit_get_nt_acl,
2560 .fset_nt_acl_fn = smb_full_audit_fset_nt_acl,
2561 .audit_file_fn = smb_full_audit_audit_file,
2562 .chmod_acl_fn = smb_full_audit_chmod_acl,
2563 .fchmod_acl_fn = smb_full_audit_fchmod_acl,
2564 .sys_acl_get_file_fn = smb_full_audit_sys_acl_get_file,
2565 .sys_acl_get_fd_fn = smb_full_audit_sys_acl_get_fd,
2566 .sys_acl_blob_get_file_fn = smb_full_audit_sys_acl_blob_get_file,
2567 .sys_acl_blob_get_fd_fn = smb_full_audit_sys_acl_blob_get_fd,
2568 .sys_acl_set_file_fn = smb_full_audit_sys_acl_set_file,
2569 .sys_acl_set_fd_fn = smb_full_audit_sys_acl_set_fd,
2570 .sys_acl_delete_def_file_fn = smb_full_audit_sys_acl_delete_def_file,
2571 .getxattr_fn = smb_full_audit_getxattr,
2572 .fgetxattr_fn = smb_full_audit_fgetxattr,
2573 .listxattr_fn = smb_full_audit_listxattr,
2574 .flistxattr_fn = smb_full_audit_flistxattr,
2575 .removexattr_fn = smb_full_audit_removexattr,
2576 .fremovexattr_fn = smb_full_audit_fremovexattr,
2577 .setxattr_fn = smb_full_audit_setxattr,
2578 .fsetxattr_fn = smb_full_audit_fsetxattr,
2579 .aio_force_fn = smb_full_audit_aio_force,
2580 .durable_cookie_fn = smb_full_audit_durable_cookie,
2581 .durable_disconnect_fn = smb_full_audit_durable_disconnect,
2582 .durable_reconnect_fn = smb_full_audit_durable_reconnect,
2583 .readdir_attr_fn = smb_full_audit_readdir_attr
2588 NTSTATUS vfs_full_audit_init(TALLOC_CTX *ctx)
2592 smb_vfs_assert_all_fns(&vfs_full_audit_fns, "full_audit");
2594 ret = smb_register_vfs(SMB_VFS_INTERFACE_VERSION, "full_audit",
2595 &vfs_full_audit_fns);
2597 if (!NT_STATUS_IS_OK(ret))
2600 vfs_full_audit_debug_level = debug_add_class("full_audit");
2601 if (vfs_full_audit_debug_level == -1) {
2602 vfs_full_audit_debug_level = DBGC_VFS;
2603 DEBUG(0, ("vfs_full_audit: Couldn't register custom debugging "
2606 DEBUG(10, ("vfs_full_audit: Debug class number of "
2607 "'full_audit': %d\n", vfs_full_audit_debug_level));