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 char *path
, uint64_t *bsize
,
680 uint64_t *dfree
, uint64_t *dsize
)
684 result
= SMB_VFS_NEXT_DISK_FREE(handle
, path
, bsize
, dfree
, dsize
);
686 /* Don't have a reasonable notion of failure here */
688 do_log(SMB_VFS_OP_DISK_FREE
, True
, handle
, "%s", path
);
693 static int smb_full_audit_get_quota(struct vfs_handle_struct
*handle
,
694 const char *path
, enum SMB_QUOTA_TYPE qtype
,
695 unid_t id
, SMB_DISK_QUOTA
*qt
)
699 result
= SMB_VFS_NEXT_GET_QUOTA(handle
, path
, qtype
, id
, qt
);
701 do_log(SMB_VFS_OP_GET_QUOTA
, (result
>= 0), handle
, "%s", path
);
706 static int smb_full_audit_set_quota(struct vfs_handle_struct
*handle
,
707 enum SMB_QUOTA_TYPE qtype
, unid_t id
,
712 result
= SMB_VFS_NEXT_SET_QUOTA(handle
, qtype
, id
, qt
);
714 do_log(SMB_VFS_OP_SET_QUOTA
, (result
>= 0), handle
, "");
719 static int smb_full_audit_get_shadow_copy_data(struct vfs_handle_struct
*handle
,
720 struct files_struct
*fsp
,
721 struct shadow_copy_data
*shadow_copy_data
,
726 result
= SMB_VFS_NEXT_GET_SHADOW_COPY_DATA(handle
, fsp
, shadow_copy_data
, labels
);
728 do_log(SMB_VFS_OP_GET_SHADOW_COPY_DATA
, (result
>= 0), handle
, "");
733 static int smb_full_audit_statvfs(struct vfs_handle_struct
*handle
,
735 struct vfs_statvfs_struct
*statbuf
)
739 result
= SMB_VFS_NEXT_STATVFS(handle
, path
, statbuf
);
741 do_log(SMB_VFS_OP_STATVFS
, (result
>= 0), handle
, "");
746 static uint32_t smb_full_audit_fs_capabilities(struct vfs_handle_struct
*handle
, enum timestamp_set_resolution
*p_ts_res
)
750 result
= SMB_VFS_NEXT_FS_CAPABILITIES(handle
, p_ts_res
);
752 do_log(SMB_VFS_OP_FS_CAPABILITIES
, true, handle
, "");
757 static NTSTATUS
smb_full_audit_get_dfs_referrals(
758 struct vfs_handle_struct
*handle
,
759 struct dfs_GetDFSReferral
*r
)
763 status
= SMB_VFS_NEXT_GET_DFS_REFERRALS(handle
, r
);
765 do_log(SMB_VFS_OP_GET_DFS_REFERRALS
, NT_STATUS_IS_OK(status
),
771 static NTSTATUS
smb_full_audit_snap_check_path(struct vfs_handle_struct
*handle
,
773 const char *service_path
,
778 status
= SMB_VFS_NEXT_SNAP_CHECK_PATH(handle
, mem_ctx
, service_path
,
780 do_log(SMB_VFS_OP_SNAP_CHECK_PATH
, NT_STATUS_IS_OK(status
),
786 static NTSTATUS
smb_full_audit_snap_create(struct vfs_handle_struct
*handle
,
788 const char *base_volume
,
796 status
= SMB_VFS_NEXT_SNAP_CREATE(handle
, mem_ctx
, base_volume
, tstamp
,
797 rw
, base_path
, snap_path
);
798 do_log(SMB_VFS_OP_SNAP_CREATE
, NT_STATUS_IS_OK(status
), handle
, "");
803 static NTSTATUS
smb_full_audit_snap_delete(struct vfs_handle_struct
*handle
,
810 status
= SMB_VFS_NEXT_SNAP_DELETE(handle
, mem_ctx
, base_path
,
812 do_log(SMB_VFS_OP_SNAP_DELETE
, NT_STATUS_IS_OK(status
), handle
, "");
817 static DIR *smb_full_audit_opendir(vfs_handle_struct
*handle
,
818 const struct smb_filename
*smb_fname
,
824 result
= SMB_VFS_NEXT_OPENDIR(handle
, smb_fname
, mask
, attr
);
826 do_log(SMB_VFS_OP_OPENDIR
, (result
!= NULL
), handle
, "%s",
827 smb_fname
->base_name
);
832 static DIR *smb_full_audit_fdopendir(vfs_handle_struct
*handle
,
833 files_struct
*fsp
, const char *mask
, uint32_t attr
)
837 result
= SMB_VFS_NEXT_FDOPENDIR(handle
, fsp
, mask
, attr
);
839 do_log(SMB_VFS_OP_FDOPENDIR
, (result
!= NULL
), handle
, "%s",
840 fsp_str_do_log(fsp
));
845 static struct dirent
*smb_full_audit_readdir(vfs_handle_struct
*handle
,
846 DIR *dirp
, SMB_STRUCT_STAT
*sbuf
)
848 struct dirent
*result
;
850 result
= SMB_VFS_NEXT_READDIR(handle
, dirp
, sbuf
);
852 /* This operation has no reasonable error condition
853 * (End of dir is also failure), so always succeed.
855 do_log(SMB_VFS_OP_READDIR
, True
, handle
, "");
860 static void smb_full_audit_seekdir(vfs_handle_struct
*handle
,
861 DIR *dirp
, long offset
)
863 SMB_VFS_NEXT_SEEKDIR(handle
, dirp
, offset
);
865 do_log(SMB_VFS_OP_SEEKDIR
, True
, handle
, "");
868 static long smb_full_audit_telldir(vfs_handle_struct
*handle
,
873 result
= SMB_VFS_NEXT_TELLDIR(handle
, dirp
);
875 do_log(SMB_VFS_OP_TELLDIR
, True
, handle
, "");
880 static void smb_full_audit_rewinddir(vfs_handle_struct
*handle
,
883 SMB_VFS_NEXT_REWINDDIR(handle
, dirp
);
885 do_log(SMB_VFS_OP_REWINDDIR
, True
, handle
, "");
888 static int smb_full_audit_mkdir(vfs_handle_struct
*handle
,
889 const struct smb_filename
*smb_fname
, mode_t mode
)
893 result
= SMB_VFS_NEXT_MKDIR(handle
, smb_fname
, mode
);
895 do_log(SMB_VFS_OP_MKDIR
, (result
>= 0), handle
, "%s",
896 smb_fname
->base_name
);
901 static int smb_full_audit_rmdir(vfs_handle_struct
*handle
,
902 const struct smb_filename
*smb_fname
)
906 result
= SMB_VFS_NEXT_RMDIR(handle
, smb_fname
);
908 do_log(SMB_VFS_OP_RMDIR
, (result
>= 0), handle
, "%s",
909 smb_fname
->base_name
);
914 static int smb_full_audit_closedir(vfs_handle_struct
*handle
,
919 result
= SMB_VFS_NEXT_CLOSEDIR(handle
, dirp
);
921 do_log(SMB_VFS_OP_CLOSEDIR
, (result
>= 0), handle
, "");
926 static void smb_full_audit_init_search_op(vfs_handle_struct
*handle
,
929 SMB_VFS_NEXT_INIT_SEARCH_OP(handle
, dirp
);
931 do_log(SMB_VFS_OP_INIT_SEARCH_OP
, True
, handle
, "");
934 static int smb_full_audit_open(vfs_handle_struct
*handle
,
935 struct smb_filename
*smb_fname
,
936 files_struct
*fsp
, int flags
, mode_t mode
)
940 result
= SMB_VFS_NEXT_OPEN(handle
, smb_fname
, fsp
, flags
, mode
);
942 do_log(SMB_VFS_OP_OPEN
, (result
>= 0), handle
, "%s|%s",
943 ((flags
& O_WRONLY
) || (flags
& O_RDWR
))?"w":"r",
944 smb_fname_str_do_log(smb_fname
));
949 static NTSTATUS
smb_full_audit_create_file(vfs_handle_struct
*handle
,
950 struct smb_request
*req
,
951 uint16_t root_dir_fid
,
952 struct smb_filename
*smb_fname
,
953 uint32_t access_mask
,
954 uint32_t share_access
,
955 uint32_t create_disposition
,
956 uint32_t create_options
,
957 uint32_t file_attributes
,
958 uint32_t oplock_request
,
959 struct smb2_lease
*lease
,
960 uint64_t allocation_size
,
961 uint32_t private_flags
,
962 struct security_descriptor
*sd
,
963 struct ea_list
*ea_list
,
964 files_struct
**result_fsp
,
966 const struct smb2_create_blobs
*in_context_blobs
,
967 struct smb2_create_blobs
*out_context_blobs
)
970 const char* str_create_disposition
;
972 switch (create_disposition
) {
974 str_create_disposition
= "supersede";
976 case FILE_OVERWRITE_IF
:
977 str_create_disposition
= "overwrite_if";
980 str_create_disposition
= "open";
983 str_create_disposition
= "overwrite";
986 str_create_disposition
= "create";
989 str_create_disposition
= "open_if";
992 str_create_disposition
= "unknown";
995 result
= SMB_VFS_NEXT_CREATE_FILE(
998 root_dir_fid
, /* root_dir_fid */
999 smb_fname
, /* fname */
1000 access_mask
, /* access_mask */
1001 share_access
, /* share_access */
1002 create_disposition
, /* create_disposition*/
1003 create_options
, /* create_options */
1004 file_attributes
, /* file_attributes */
1005 oplock_request
, /* oplock_request */
1007 allocation_size
, /* allocation_size */
1010 ea_list
, /* ea_list */
1011 result_fsp
, /* result */
1013 in_context_blobs
, out_context_blobs
); /* create context */
1015 do_log(SMB_VFS_OP_CREATE_FILE
, (NT_STATUS_IS_OK(result
)), handle
,
1016 "0x%x|%s|%s|%s", access_mask
,
1017 create_options
& FILE_DIRECTORY_FILE
? "dir" : "file",
1018 str_create_disposition
, smb_fname_str_do_log(smb_fname
));
1023 static int smb_full_audit_close(vfs_handle_struct
*handle
, files_struct
*fsp
)
1027 result
= SMB_VFS_NEXT_CLOSE(handle
, fsp
);
1029 do_log(SMB_VFS_OP_CLOSE
, (result
>= 0), handle
, "%s",
1030 fsp_str_do_log(fsp
));
1035 static ssize_t
smb_full_audit_read(vfs_handle_struct
*handle
, files_struct
*fsp
,
1036 void *data
, size_t n
)
1040 result
= SMB_VFS_NEXT_READ(handle
, fsp
, data
, n
);
1042 do_log(SMB_VFS_OP_READ
, (result
>= 0), handle
, "%s",
1043 fsp_str_do_log(fsp
));
1048 static ssize_t
smb_full_audit_pread(vfs_handle_struct
*handle
, files_struct
*fsp
,
1049 void *data
, size_t n
, off_t offset
)
1053 result
= SMB_VFS_NEXT_PREAD(handle
, fsp
, data
, n
, offset
);
1055 do_log(SMB_VFS_OP_PREAD
, (result
>= 0), handle
, "%s",
1056 fsp_str_do_log(fsp
));
1061 struct smb_full_audit_pread_state
{
1062 vfs_handle_struct
*handle
;
1065 struct vfs_aio_state vfs_aio_state
;
1068 static void smb_full_audit_pread_done(struct tevent_req
*subreq
);
1070 static struct tevent_req
*smb_full_audit_pread_send(
1071 struct vfs_handle_struct
*handle
, TALLOC_CTX
*mem_ctx
,
1072 struct tevent_context
*ev
, struct files_struct
*fsp
,
1073 void *data
, size_t n
, off_t offset
)
1075 struct tevent_req
*req
, *subreq
;
1076 struct smb_full_audit_pread_state
*state
;
1078 req
= tevent_req_create(mem_ctx
, &state
,
1079 struct smb_full_audit_pread_state
);
1081 do_log(SMB_VFS_OP_PREAD_SEND
, false, handle
, "%s",
1082 fsp_str_do_log(fsp
));
1085 state
->handle
= handle
;
1088 subreq
= SMB_VFS_NEXT_PREAD_SEND(state
, ev
, handle
, fsp
, data
,
1090 if (tevent_req_nomem(subreq
, req
)) {
1091 do_log(SMB_VFS_OP_PREAD_SEND
, false, handle
, "%s",
1092 fsp_str_do_log(fsp
));
1093 return tevent_req_post(req
, ev
);
1095 tevent_req_set_callback(subreq
, smb_full_audit_pread_done
, req
);
1097 do_log(SMB_VFS_OP_PREAD_SEND
, true, handle
, "%s", fsp_str_do_log(fsp
));
1101 static void smb_full_audit_pread_done(struct tevent_req
*subreq
)
1103 struct tevent_req
*req
= tevent_req_callback_data(
1104 subreq
, struct tevent_req
);
1105 struct smb_full_audit_pread_state
*state
= tevent_req_data(
1106 req
, struct smb_full_audit_pread_state
);
1108 state
->ret
= SMB_VFS_PREAD_RECV(subreq
, &state
->vfs_aio_state
);
1109 TALLOC_FREE(subreq
);
1110 tevent_req_done(req
);
1113 static ssize_t
smb_full_audit_pread_recv(struct tevent_req
*req
,
1114 struct vfs_aio_state
*vfs_aio_state
)
1116 struct smb_full_audit_pread_state
*state
= tevent_req_data(
1117 req
, struct smb_full_audit_pread_state
);
1119 if (tevent_req_is_unix_error(req
, &vfs_aio_state
->error
)) {
1120 do_log(SMB_VFS_OP_PREAD_RECV
, false, state
->handle
, "%s",
1121 fsp_str_do_log(state
->fsp
));
1125 do_log(SMB_VFS_OP_PREAD_RECV
, (state
->ret
>= 0), state
->handle
, "%s",
1126 fsp_str_do_log(state
->fsp
));
1128 *vfs_aio_state
= state
->vfs_aio_state
;
1132 static ssize_t
smb_full_audit_write(vfs_handle_struct
*handle
, files_struct
*fsp
,
1133 const void *data
, size_t n
)
1137 result
= SMB_VFS_NEXT_WRITE(handle
, fsp
, data
, n
);
1139 do_log(SMB_VFS_OP_WRITE
, (result
>= 0), handle
, "%s",
1140 fsp_str_do_log(fsp
));
1145 static ssize_t
smb_full_audit_pwrite(vfs_handle_struct
*handle
, files_struct
*fsp
,
1146 const void *data
, size_t n
,
1151 result
= SMB_VFS_NEXT_PWRITE(handle
, fsp
, data
, n
, offset
);
1153 do_log(SMB_VFS_OP_PWRITE
, (result
>= 0), handle
, "%s",
1154 fsp_str_do_log(fsp
));
1159 struct smb_full_audit_pwrite_state
{
1160 vfs_handle_struct
*handle
;
1163 struct vfs_aio_state vfs_aio_state
;
1166 static void smb_full_audit_pwrite_done(struct tevent_req
*subreq
);
1168 static struct tevent_req
*smb_full_audit_pwrite_send(
1169 struct vfs_handle_struct
*handle
, TALLOC_CTX
*mem_ctx
,
1170 struct tevent_context
*ev
, struct files_struct
*fsp
,
1171 const void *data
, size_t n
, off_t offset
)
1173 struct tevent_req
*req
, *subreq
;
1174 struct smb_full_audit_pwrite_state
*state
;
1176 req
= tevent_req_create(mem_ctx
, &state
,
1177 struct smb_full_audit_pwrite_state
);
1179 do_log(SMB_VFS_OP_PWRITE_SEND
, false, handle
, "%s",
1180 fsp_str_do_log(fsp
));
1183 state
->handle
= handle
;
1186 subreq
= SMB_VFS_NEXT_PWRITE_SEND(state
, ev
, handle
, fsp
, data
,
1188 if (tevent_req_nomem(subreq
, req
)) {
1189 do_log(SMB_VFS_OP_PWRITE_SEND
, false, handle
, "%s",
1190 fsp_str_do_log(fsp
));
1191 return tevent_req_post(req
, ev
);
1193 tevent_req_set_callback(subreq
, smb_full_audit_pwrite_done
, req
);
1195 do_log(SMB_VFS_OP_PWRITE_SEND
, true, handle
, "%s",
1196 fsp_str_do_log(fsp
));
1200 static void smb_full_audit_pwrite_done(struct tevent_req
*subreq
)
1202 struct tevent_req
*req
= tevent_req_callback_data(
1203 subreq
, struct tevent_req
);
1204 struct smb_full_audit_pwrite_state
*state
= tevent_req_data(
1205 req
, struct smb_full_audit_pwrite_state
);
1207 state
->ret
= SMB_VFS_PWRITE_RECV(subreq
, &state
->vfs_aio_state
);
1208 TALLOC_FREE(subreq
);
1209 tevent_req_done(req
);
1212 static ssize_t
smb_full_audit_pwrite_recv(struct tevent_req
*req
,
1213 struct vfs_aio_state
*vfs_aio_state
)
1215 struct smb_full_audit_pwrite_state
*state
= tevent_req_data(
1216 req
, struct smb_full_audit_pwrite_state
);
1218 if (tevent_req_is_unix_error(req
, &vfs_aio_state
->error
)) {
1219 do_log(SMB_VFS_OP_PWRITE_RECV
, false, state
->handle
, "%s",
1220 fsp_str_do_log(state
->fsp
));
1224 do_log(SMB_VFS_OP_PWRITE_RECV
, (state
->ret
>= 0), state
->handle
, "%s",
1225 fsp_str_do_log(state
->fsp
));
1227 *vfs_aio_state
= state
->vfs_aio_state
;
1231 static off_t
smb_full_audit_lseek(vfs_handle_struct
*handle
, files_struct
*fsp
,
1232 off_t offset
, int whence
)
1236 result
= SMB_VFS_NEXT_LSEEK(handle
, fsp
, offset
, whence
);
1238 do_log(SMB_VFS_OP_LSEEK
, (result
!= (ssize_t
)-1), handle
,
1239 "%s", fsp_str_do_log(fsp
));
1244 static ssize_t
smb_full_audit_sendfile(vfs_handle_struct
*handle
, int tofd
,
1245 files_struct
*fromfsp
,
1246 const DATA_BLOB
*hdr
, off_t offset
,
1251 result
= SMB_VFS_NEXT_SENDFILE(handle
, tofd
, fromfsp
, hdr
, offset
, n
);
1253 do_log(SMB_VFS_OP_SENDFILE
, (result
>= 0), handle
,
1254 "%s", fsp_str_do_log(fromfsp
));
1259 static ssize_t
smb_full_audit_recvfile(vfs_handle_struct
*handle
, int fromfd
,
1260 files_struct
*tofsp
,
1266 result
= SMB_VFS_NEXT_RECVFILE(handle
, fromfd
, tofsp
, offset
, n
);
1268 do_log(SMB_VFS_OP_RECVFILE
, (result
>= 0), handle
,
1269 "%s", fsp_str_do_log(tofsp
));
1274 static int smb_full_audit_rename(vfs_handle_struct
*handle
,
1275 const struct smb_filename
*smb_fname_src
,
1276 const struct smb_filename
*smb_fname_dst
)
1280 result
= SMB_VFS_NEXT_RENAME(handle
, smb_fname_src
, smb_fname_dst
);
1282 do_log(SMB_VFS_OP_RENAME
, (result
>= 0), handle
, "%s|%s",
1283 smb_fname_str_do_log(smb_fname_src
),
1284 smb_fname_str_do_log(smb_fname_dst
));
1289 static int smb_full_audit_fsync(vfs_handle_struct
*handle
, files_struct
*fsp
)
1293 result
= SMB_VFS_NEXT_FSYNC(handle
, fsp
);
1295 do_log(SMB_VFS_OP_FSYNC
, (result
>= 0), handle
, "%s",
1296 fsp_str_do_log(fsp
));
1301 struct smb_full_audit_fsync_state
{
1302 vfs_handle_struct
*handle
;
1305 struct vfs_aio_state vfs_aio_state
;
1308 static void smb_full_audit_fsync_done(struct tevent_req
*subreq
);
1310 static struct tevent_req
*smb_full_audit_fsync_send(
1311 struct vfs_handle_struct
*handle
, TALLOC_CTX
*mem_ctx
,
1312 struct tevent_context
*ev
, struct files_struct
*fsp
)
1314 struct tevent_req
*req
, *subreq
;
1315 struct smb_full_audit_fsync_state
*state
;
1317 req
= tevent_req_create(mem_ctx
, &state
,
1318 struct smb_full_audit_fsync_state
);
1320 do_log(SMB_VFS_OP_FSYNC_SEND
, false, handle
, "%s",
1321 fsp_str_do_log(fsp
));
1324 state
->handle
= handle
;
1327 subreq
= SMB_VFS_NEXT_FSYNC_SEND(state
, ev
, handle
, fsp
);
1328 if (tevent_req_nomem(subreq
, req
)) {
1329 do_log(SMB_VFS_OP_FSYNC_SEND
, false, handle
, "%s",
1330 fsp_str_do_log(fsp
));
1331 return tevent_req_post(req
, ev
);
1333 tevent_req_set_callback(subreq
, smb_full_audit_fsync_done
, req
);
1335 do_log(SMB_VFS_OP_FSYNC_SEND
, true, handle
, "%s", fsp_str_do_log(fsp
));
1339 static void smb_full_audit_fsync_done(struct tevent_req
*subreq
)
1341 struct tevent_req
*req
= tevent_req_callback_data(
1342 subreq
, struct tevent_req
);
1343 struct smb_full_audit_fsync_state
*state
= tevent_req_data(
1344 req
, struct smb_full_audit_fsync_state
);
1346 state
->ret
= SMB_VFS_FSYNC_RECV(subreq
, &state
->vfs_aio_state
);
1347 TALLOC_FREE(subreq
);
1348 tevent_req_done(req
);
1351 static int smb_full_audit_fsync_recv(struct tevent_req
*req
,
1352 struct vfs_aio_state
*vfs_aio_state
)
1354 struct smb_full_audit_fsync_state
*state
= tevent_req_data(
1355 req
, struct smb_full_audit_fsync_state
);
1357 if (tevent_req_is_unix_error(req
, &vfs_aio_state
->error
)) {
1358 do_log(SMB_VFS_OP_FSYNC_RECV
, false, state
->handle
, "%s",
1359 fsp_str_do_log(state
->fsp
));
1363 do_log(SMB_VFS_OP_FSYNC_RECV
, (state
->ret
>= 0), state
->handle
, "%s",
1364 fsp_str_do_log(state
->fsp
));
1366 *vfs_aio_state
= state
->vfs_aio_state
;
1370 static int smb_full_audit_stat(vfs_handle_struct
*handle
,
1371 struct smb_filename
*smb_fname
)
1375 result
= SMB_VFS_NEXT_STAT(handle
, smb_fname
);
1377 do_log(SMB_VFS_OP_STAT
, (result
>= 0), handle
, "%s",
1378 smb_fname_str_do_log(smb_fname
));
1383 static int smb_full_audit_fstat(vfs_handle_struct
*handle
, files_struct
*fsp
,
1384 SMB_STRUCT_STAT
*sbuf
)
1388 result
= SMB_VFS_NEXT_FSTAT(handle
, fsp
, sbuf
);
1390 do_log(SMB_VFS_OP_FSTAT
, (result
>= 0), handle
, "%s",
1391 fsp_str_do_log(fsp
));
1396 static int smb_full_audit_lstat(vfs_handle_struct
*handle
,
1397 struct smb_filename
*smb_fname
)
1401 result
= SMB_VFS_NEXT_LSTAT(handle
, smb_fname
);
1403 do_log(SMB_VFS_OP_LSTAT
, (result
>= 0), handle
, "%s",
1404 smb_fname_str_do_log(smb_fname
));
1409 static uint64_t smb_full_audit_get_alloc_size(vfs_handle_struct
*handle
,
1410 files_struct
*fsp
, const SMB_STRUCT_STAT
*sbuf
)
1414 result
= SMB_VFS_NEXT_GET_ALLOC_SIZE(handle
, fsp
, sbuf
);
1416 do_log(SMB_VFS_OP_GET_ALLOC_SIZE
, (result
!= (uint64_t)-1), handle
,
1422 static int smb_full_audit_unlink(vfs_handle_struct
*handle
,
1423 const struct smb_filename
*smb_fname
)
1427 result
= SMB_VFS_NEXT_UNLINK(handle
, smb_fname
);
1429 do_log(SMB_VFS_OP_UNLINK
, (result
>= 0), handle
, "%s",
1430 smb_fname_str_do_log(smb_fname
));
1435 static int smb_full_audit_chmod(vfs_handle_struct
*handle
,
1436 const struct smb_filename
*smb_fname
,
1441 result
= SMB_VFS_NEXT_CHMOD(handle
, smb_fname
, mode
);
1443 do_log(SMB_VFS_OP_CHMOD
, (result
>= 0), handle
, "%s|%o",
1444 smb_fname
->base_name
,
1450 static int smb_full_audit_fchmod(vfs_handle_struct
*handle
, files_struct
*fsp
,
1455 result
= SMB_VFS_NEXT_FCHMOD(handle
, fsp
, mode
);
1457 do_log(SMB_VFS_OP_FCHMOD
, (result
>= 0), handle
,
1458 "%s|%o", fsp_str_do_log(fsp
), mode
);
1463 static int smb_full_audit_chown(vfs_handle_struct
*handle
,
1464 const struct smb_filename
*smb_fname
,
1470 result
= SMB_VFS_NEXT_CHOWN(handle
, smb_fname
, uid
, gid
);
1472 do_log(SMB_VFS_OP_CHOWN
, (result
>= 0), handle
, "%s|%ld|%ld",
1473 smb_fname
->base_name
, (long int)uid
, (long int)gid
);
1478 static int smb_full_audit_fchown(vfs_handle_struct
*handle
, files_struct
*fsp
,
1479 uid_t uid
, gid_t gid
)
1483 result
= SMB_VFS_NEXT_FCHOWN(handle
, fsp
, uid
, gid
);
1485 do_log(SMB_VFS_OP_FCHOWN
, (result
>= 0), handle
, "%s|%ld|%ld",
1486 fsp_str_do_log(fsp
), (long int)uid
, (long int)gid
);
1491 static int smb_full_audit_lchown(vfs_handle_struct
*handle
,
1492 const struct smb_filename
*smb_fname
,
1498 result
= SMB_VFS_NEXT_LCHOWN(handle
, smb_fname
, uid
, gid
);
1500 do_log(SMB_VFS_OP_LCHOWN
, (result
>= 0), handle
, "%s|%ld|%ld",
1501 smb_fname
->base_name
, (long int)uid
, (long int)gid
);
1506 static int smb_full_audit_chdir(vfs_handle_struct
*handle
,
1511 result
= SMB_VFS_NEXT_CHDIR(handle
, path
);
1513 do_log(SMB_VFS_OP_CHDIR
, (result
>= 0), handle
, "chdir|%s", path
);
1518 static char *smb_full_audit_getwd(vfs_handle_struct
*handle
)
1522 result
= SMB_VFS_NEXT_GETWD(handle
);
1524 do_log(SMB_VFS_OP_GETWD
, (result
!= NULL
), handle
, "%s",
1525 result
== NULL
? "" : result
);
1530 static int smb_full_audit_ntimes(vfs_handle_struct
*handle
,
1531 const struct smb_filename
*smb_fname
,
1532 struct smb_file_time
*ft
)
1536 result
= SMB_VFS_NEXT_NTIMES(handle
, smb_fname
, ft
);
1538 do_log(SMB_VFS_OP_NTIMES
, (result
>= 0), handle
, "%s",
1539 smb_fname_str_do_log(smb_fname
));
1544 static int smb_full_audit_ftruncate(vfs_handle_struct
*handle
, files_struct
*fsp
,
1549 result
= SMB_VFS_NEXT_FTRUNCATE(handle
, fsp
, len
);
1551 do_log(SMB_VFS_OP_FTRUNCATE
, (result
>= 0), handle
,
1552 "%s", fsp_str_do_log(fsp
));
1557 static int smb_full_audit_fallocate(vfs_handle_struct
*handle
, files_struct
*fsp
,
1564 result
= SMB_VFS_NEXT_FALLOCATE(handle
, fsp
, mode
, offset
, len
);
1566 do_log(SMB_VFS_OP_FALLOCATE
, (result
>= 0), handle
,
1567 "%s", fsp_str_do_log(fsp
));
1572 static bool smb_full_audit_lock(vfs_handle_struct
*handle
, files_struct
*fsp
,
1573 int op
, off_t offset
, off_t count
, int type
)
1577 result
= SMB_VFS_NEXT_LOCK(handle
, fsp
, op
, offset
, count
, type
);
1579 do_log(SMB_VFS_OP_LOCK
, result
, handle
, "%s", fsp_str_do_log(fsp
));
1584 static int smb_full_audit_kernel_flock(struct vfs_handle_struct
*handle
,
1585 struct files_struct
*fsp
,
1586 uint32_t share_mode
, uint32_t access_mask
)
1590 result
= SMB_VFS_NEXT_KERNEL_FLOCK(handle
, fsp
, share_mode
, access_mask
);
1592 do_log(SMB_VFS_OP_KERNEL_FLOCK
, (result
>= 0), handle
, "%s",
1593 fsp_str_do_log(fsp
));
1598 static int smb_full_audit_linux_setlease(vfs_handle_struct
*handle
, files_struct
*fsp
,
1603 result
= SMB_VFS_NEXT_LINUX_SETLEASE(handle
, fsp
, leasetype
);
1605 do_log(SMB_VFS_OP_LINUX_SETLEASE
, (result
>= 0), handle
, "%s",
1606 fsp_str_do_log(fsp
));
1611 static bool smb_full_audit_getlock(vfs_handle_struct
*handle
, files_struct
*fsp
,
1612 off_t
*poffset
, off_t
*pcount
, int *ptype
, pid_t
*ppid
)
1616 result
= SMB_VFS_NEXT_GETLOCK(handle
, fsp
, poffset
, pcount
, ptype
, ppid
);
1618 do_log(SMB_VFS_OP_GETLOCK
, result
, handle
, "%s", fsp_str_do_log(fsp
));
1623 static int smb_full_audit_symlink(vfs_handle_struct
*handle
,
1624 const char *oldpath
, const char *newpath
)
1628 result
= SMB_VFS_NEXT_SYMLINK(handle
, oldpath
, newpath
);
1630 do_log(SMB_VFS_OP_SYMLINK
, (result
>= 0), handle
,
1631 "%s|%s", oldpath
, newpath
);
1636 static int smb_full_audit_readlink(vfs_handle_struct
*handle
,
1637 const char *path
, char *buf
, size_t bufsiz
)
1641 result
= SMB_VFS_NEXT_READLINK(handle
, path
, buf
, bufsiz
);
1643 do_log(SMB_VFS_OP_READLINK
, (result
>= 0), handle
, "%s", path
);
1648 static int smb_full_audit_link(vfs_handle_struct
*handle
,
1649 const char *oldpath
, const char *newpath
)
1653 result
= SMB_VFS_NEXT_LINK(handle
, oldpath
, newpath
);
1655 do_log(SMB_VFS_OP_LINK
, (result
>= 0), handle
,
1656 "%s|%s", oldpath
, newpath
);
1661 static int smb_full_audit_mknod(vfs_handle_struct
*handle
,
1662 const struct smb_filename
*smb_fname
,
1668 result
= SMB_VFS_NEXT_MKNOD(handle
, smb_fname
, mode
, dev
);
1670 do_log(SMB_VFS_OP_MKNOD
, (result
>= 0), handle
, "%s",
1671 smb_fname
->base_name
);
1676 static char *smb_full_audit_realpath(vfs_handle_struct
*handle
,
1681 result
= SMB_VFS_NEXT_REALPATH(handle
, path
);
1683 do_log(SMB_VFS_OP_REALPATH
, (result
!= NULL
), handle
, "%s", path
);
1688 static int smb_full_audit_chflags(vfs_handle_struct
*handle
,
1689 const char *path
, unsigned int flags
)
1693 result
= SMB_VFS_NEXT_CHFLAGS(handle
, path
, flags
);
1695 do_log(SMB_VFS_OP_CHFLAGS
, (result
!= 0), handle
, "%s", path
);
1700 static struct file_id
smb_full_audit_file_id_create(struct vfs_handle_struct
*handle
,
1701 const SMB_STRUCT_STAT
*sbuf
)
1703 struct file_id id_zero
;
1704 struct file_id result
;
1706 ZERO_STRUCT(id_zero
);
1708 result
= SMB_VFS_NEXT_FILE_ID_CREATE(handle
, sbuf
);
1710 do_log(SMB_VFS_OP_FILE_ID_CREATE
,
1711 !file_id_equal(&id_zero
, &result
),
1712 handle
, "%s", file_id_string_tos(&result
));
1717 static NTSTATUS
smb_full_audit_streaminfo(vfs_handle_struct
*handle
,
1718 struct files_struct
*fsp
,
1719 const struct smb_filename
*smb_fname
,
1720 TALLOC_CTX
*mem_ctx
,
1721 unsigned int *pnum_streams
,
1722 struct stream_struct
**pstreams
)
1726 result
= SMB_VFS_NEXT_STREAMINFO(handle
, fsp
, smb_fname
, mem_ctx
,
1727 pnum_streams
, pstreams
);
1729 do_log(SMB_VFS_OP_STREAMINFO
, NT_STATUS_IS_OK(result
), handle
,
1730 "%s", smb_fname
->base_name
);
1735 static int smb_full_audit_get_real_filename(struct vfs_handle_struct
*handle
,
1738 TALLOC_CTX
*mem_ctx
,
1743 result
= SMB_VFS_NEXT_GET_REAL_FILENAME(handle
, path
, name
, mem_ctx
,
1746 do_log(SMB_VFS_OP_GET_REAL_FILENAME
, (result
== 0), handle
,
1747 "%s/%s->%s", path
, name
, (result
== 0) ? "" : *found_name
);
1752 static const char *smb_full_audit_connectpath(vfs_handle_struct
*handle
,
1757 result
= SMB_VFS_NEXT_CONNECTPATH(handle
, fname
);
1759 do_log(SMB_VFS_OP_CONNECTPATH
, result
!= NULL
, handle
,
1765 static NTSTATUS
smb_full_audit_brl_lock_windows(struct vfs_handle_struct
*handle
,
1766 struct byte_range_lock
*br_lck
,
1767 struct lock_struct
*plock
,
1772 result
= SMB_VFS_NEXT_BRL_LOCK_WINDOWS(handle
, br_lck
, plock
,
1775 do_log(SMB_VFS_OP_BRL_LOCK_WINDOWS
, NT_STATUS_IS_OK(result
), handle
,
1776 "%s:%llu-%llu. type=%d. blocking=%d",
1777 fsp_str_do_log(brl_fsp(br_lck
)),
1778 plock
->start
, plock
->size
, plock
->lock_type
, blocking_lock
);
1783 static bool smb_full_audit_brl_unlock_windows(struct vfs_handle_struct
*handle
,
1784 struct messaging_context
*msg_ctx
,
1785 struct byte_range_lock
*br_lck
,
1786 const struct lock_struct
*plock
)
1790 result
= SMB_VFS_NEXT_BRL_UNLOCK_WINDOWS(handle
, msg_ctx
, br_lck
,
1793 do_log(SMB_VFS_OP_BRL_UNLOCK_WINDOWS
, (result
== 0), handle
,
1794 "%s:%llu-%llu:%d", fsp_str_do_log(brl_fsp(br_lck
)),
1796 plock
->size
, plock
->lock_type
);
1801 static bool smb_full_audit_brl_cancel_windows(struct vfs_handle_struct
*handle
,
1802 struct byte_range_lock
*br_lck
,
1803 struct lock_struct
*plock
)
1807 result
= SMB_VFS_NEXT_BRL_CANCEL_WINDOWS(handle
, br_lck
, plock
);
1809 do_log(SMB_VFS_OP_BRL_CANCEL_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_strict_lock(struct vfs_handle_struct
*handle
,
1818 struct files_struct
*fsp
,
1819 struct lock_struct
*plock
)
1823 result
= SMB_VFS_NEXT_STRICT_LOCK(handle
, fsp
, plock
);
1825 do_log(SMB_VFS_OP_STRICT_LOCK
, result
, handle
,
1826 "%s:%llu-%llu:%d", fsp_str_do_log(fsp
), plock
->start
,
1827 plock
->size
, plock
->lock_type
);
1832 static void smb_full_audit_strict_unlock(struct vfs_handle_struct
*handle
,
1833 struct files_struct
*fsp
,
1834 struct lock_struct
*plock
)
1836 SMB_VFS_NEXT_STRICT_UNLOCK(handle
, fsp
, plock
);
1838 do_log(SMB_VFS_OP_STRICT_UNLOCK
, true, handle
,
1839 "%s:%llu-%llu:%d", fsp_str_do_log(fsp
), plock
->start
,
1840 plock
->size
, plock
->lock_type
);
1843 static NTSTATUS
smb_full_audit_translate_name(struct vfs_handle_struct
*handle
,
1845 enum vfs_translate_direction direction
,
1846 TALLOC_CTX
*mem_ctx
,
1851 result
= SMB_VFS_NEXT_TRANSLATE_NAME(handle
, name
, direction
, mem_ctx
,
1854 do_log(SMB_VFS_OP_TRANSLATE_NAME
, NT_STATUS_IS_OK(result
), handle
, "");
1859 static NTSTATUS
smb_full_audit_fsctl(struct vfs_handle_struct
*handle
,
1860 struct files_struct
*fsp
,
1864 const uint8_t *_in_data
,
1866 uint8_t **_out_data
,
1867 uint32_t max_out_len
,
1872 result
= SMB_VFS_NEXT_FSCTL(handle
,
1883 do_log(SMB_VFS_OP_FSCTL
, NT_STATUS_IS_OK(result
), handle
, "");
1888 static struct tevent_req
*smb_full_audit_copy_chunk_send(struct vfs_handle_struct
*handle
,
1889 TALLOC_CTX
*mem_ctx
,
1890 struct tevent_context
*ev
,
1891 struct files_struct
*src_fsp
,
1893 struct files_struct
*dest_fsp
,
1898 struct tevent_req
*req
;
1900 req
= SMB_VFS_NEXT_COPY_CHUNK_SEND(handle
, mem_ctx
, ev
, src_fsp
,
1901 src_off
, dest_fsp
, dest_off
, num
,
1904 do_log(SMB_VFS_OP_COPY_CHUNK_SEND
, req
, handle
, "");
1909 static NTSTATUS
smb_full_audit_copy_chunk_recv(struct vfs_handle_struct
*handle
,
1910 struct tevent_req
*req
,
1915 result
= SMB_VFS_NEXT_COPY_CHUNK_RECV(handle
, req
, copied
);
1917 do_log(SMB_VFS_OP_COPY_CHUNK_RECV
, NT_STATUS_IS_OK(result
), handle
, "");
1922 static NTSTATUS
smb_full_audit_get_compression(vfs_handle_struct
*handle
,
1923 TALLOC_CTX
*mem_ctx
,
1924 struct files_struct
*fsp
,
1925 struct smb_filename
*smb_fname
,
1926 uint16_t *_compression_fmt
)
1930 result
= SMB_VFS_NEXT_GET_COMPRESSION(handle
, mem_ctx
, fsp
, smb_fname
,
1933 do_log(SMB_VFS_OP_GET_COMPRESSION
, NT_STATUS_IS_OK(result
), handle
,
1935 (fsp
? fsp_str_do_log(fsp
) : smb_fname_str_do_log(smb_fname
)));
1940 static NTSTATUS
smb_full_audit_set_compression(vfs_handle_struct
*handle
,
1941 TALLOC_CTX
*mem_ctx
,
1942 struct files_struct
*fsp
,
1943 uint16_t compression_fmt
)
1947 result
= SMB_VFS_NEXT_SET_COMPRESSION(handle
, mem_ctx
, fsp
,
1950 do_log(SMB_VFS_OP_SET_COMPRESSION
, NT_STATUS_IS_OK(result
), handle
,
1951 "%s", fsp_str_do_log(fsp
));
1956 static NTSTATUS
smb_full_audit_readdir_attr(struct vfs_handle_struct
*handle
,
1957 const struct smb_filename
*fname
,
1958 TALLOC_CTX
*mem_ctx
,
1959 struct readdir_attr_data
**pattr_data
)
1963 status
= SMB_VFS_NEXT_READDIR_ATTR(handle
, fname
, mem_ctx
, pattr_data
);
1965 do_log(SMB_VFS_OP_READDIR_ATTR
, NT_STATUS_IS_OK(status
), handle
, "%s",
1966 smb_fname_str_do_log(fname
));
1971 static NTSTATUS
smb_full_audit_get_dos_attributes(
1972 struct vfs_handle_struct
*handle
,
1973 struct smb_filename
*smb_fname
,
1978 status
= SMB_VFS_NEXT_GET_DOS_ATTRIBUTES(handle
,
1982 do_log(SMB_VFS_OP_GET_DOS_ATTRIBUTES
,
1983 NT_STATUS_IS_OK(status
),
1986 smb_fname_str_do_log(smb_fname
));
1991 static NTSTATUS
smb_full_audit_fget_dos_attributes(
1992 struct vfs_handle_struct
*handle
,
1993 struct files_struct
*fsp
,
1998 status
= SMB_VFS_NEXT_FGET_DOS_ATTRIBUTES(handle
,
2002 do_log(SMB_VFS_OP_FGET_DOS_ATTRIBUTES
,
2003 NT_STATUS_IS_OK(status
),
2006 fsp_str_do_log(fsp
));
2011 static NTSTATUS
smb_full_audit_set_dos_attributes(
2012 struct vfs_handle_struct
*handle
,
2013 const struct smb_filename
*smb_fname
,
2018 status
= SMB_VFS_NEXT_SET_DOS_ATTRIBUTES(handle
,
2022 do_log(SMB_VFS_OP_SET_DOS_ATTRIBUTES
,
2023 NT_STATUS_IS_OK(status
),
2026 smb_fname_str_do_log(smb_fname
));
2031 static NTSTATUS
smb_full_audit_fset_dos_attributes(
2032 struct vfs_handle_struct
*handle
,
2033 struct files_struct
*fsp
,
2038 status
= SMB_VFS_NEXT_FSET_DOS_ATTRIBUTES(handle
,
2042 do_log(SMB_VFS_OP_FSET_DOS_ATTRIBUTES
,
2043 NT_STATUS_IS_OK(status
),
2046 fsp_str_do_log(fsp
));
2051 static NTSTATUS
smb_full_audit_fget_nt_acl(vfs_handle_struct
*handle
, files_struct
*fsp
,
2052 uint32_t security_info
,
2053 TALLOC_CTX
*mem_ctx
,
2054 struct security_descriptor
**ppdesc
)
2058 result
= SMB_VFS_NEXT_FGET_NT_ACL(handle
, fsp
, security_info
,
2061 do_log(SMB_VFS_OP_FGET_NT_ACL
, NT_STATUS_IS_OK(result
), handle
,
2062 "%s", fsp_str_do_log(fsp
));
2067 static NTSTATUS
smb_full_audit_get_nt_acl(vfs_handle_struct
*handle
,
2068 const struct smb_filename
*smb_fname
,
2069 uint32_t security_info
,
2070 TALLOC_CTX
*mem_ctx
,
2071 struct security_descriptor
**ppdesc
)
2075 result
= SMB_VFS_NEXT_GET_NT_ACL(handle
, smb_fname
, security_info
,
2078 do_log(SMB_VFS_OP_GET_NT_ACL
, NT_STATUS_IS_OK(result
), handle
,
2079 "%s", smb_fname_str_do_log(smb_fname
));
2084 static NTSTATUS
smb_full_audit_fset_nt_acl(vfs_handle_struct
*handle
, files_struct
*fsp
,
2085 uint32_t security_info_sent
,
2086 const struct security_descriptor
*psd
)
2088 struct vfs_full_audit_private_data
*pd
;
2092 SMB_VFS_HANDLE_GET_DATA(handle
, pd
,
2093 struct vfs_full_audit_private_data
,
2094 return NT_STATUS_INTERNAL_ERROR
);
2096 if (pd
->log_secdesc
) {
2097 sd
= sddl_encode(talloc_tos(), psd
, get_global_sam_sid());
2100 result
= SMB_VFS_NEXT_FSET_NT_ACL(handle
, fsp
, security_info_sent
, psd
);
2102 do_log(SMB_VFS_OP_FSET_NT_ACL
, NT_STATUS_IS_OK(result
), handle
,
2103 "%s [%s]", fsp_str_do_log(fsp
), sd
? sd
: "");
2110 static NTSTATUS
smb_full_audit_audit_file(struct vfs_handle_struct
*handle
,
2111 struct smb_filename
*file
,
2112 struct security_acl
*sacl
,
2113 uint32_t access_requested
,
2114 uint32_t access_denied
)
2118 result
= SMB_VFS_NEXT_AUDIT_FILE(handle
,
2124 do_log(SMB_VFS_OP_AUDIT_FILE
, NT_STATUS_IS_OK(result
), handle
,
2125 "%s", smb_fname_str_do_log(file
));
2130 static int smb_full_audit_chmod_acl(vfs_handle_struct
*handle
,
2131 const struct smb_filename
*smb_fname
,
2136 result
= SMB_VFS_NEXT_CHMOD_ACL(handle
, smb_fname
, mode
);
2138 do_log(SMB_VFS_OP_CHMOD_ACL
, (result
>= 0), handle
,
2139 "%s|%o", smb_fname
->base_name
, mode
);
2144 static int smb_full_audit_fchmod_acl(vfs_handle_struct
*handle
, files_struct
*fsp
,
2149 result
= SMB_VFS_NEXT_FCHMOD_ACL(handle
, fsp
, mode
);
2151 do_log(SMB_VFS_OP_FCHMOD_ACL
, (result
>= 0), handle
,
2152 "%s|%o", fsp_str_do_log(fsp
), mode
);
2157 static SMB_ACL_T
smb_full_audit_sys_acl_get_file(vfs_handle_struct
*handle
,
2158 const struct smb_filename
*smb_fname
,
2159 SMB_ACL_TYPE_T type
,
2160 TALLOC_CTX
*mem_ctx
)
2164 result
= SMB_VFS_NEXT_SYS_ACL_GET_FILE(handle
, smb_fname
,
2167 do_log(SMB_VFS_OP_SYS_ACL_GET_FILE
, (result
!= NULL
), handle
,
2168 "%s", smb_fname
->base_name
);
2173 static SMB_ACL_T
smb_full_audit_sys_acl_get_fd(vfs_handle_struct
*handle
,
2174 files_struct
*fsp
, TALLOC_CTX
*mem_ctx
)
2178 result
= SMB_VFS_NEXT_SYS_ACL_GET_FD(handle
, fsp
, mem_ctx
);
2180 do_log(SMB_VFS_OP_SYS_ACL_GET_FD
, (result
!= NULL
), handle
,
2181 "%s", fsp_str_do_log(fsp
));
2186 static int smb_full_audit_sys_acl_blob_get_file(vfs_handle_struct
*handle
,
2187 const struct smb_filename
*smb_fname
,
2188 TALLOC_CTX
*mem_ctx
,
2189 char **blob_description
,
2194 result
= SMB_VFS_NEXT_SYS_ACL_BLOB_GET_FILE(handle
, smb_fname
,
2195 mem_ctx
, blob_description
, blob
);
2197 do_log(SMB_VFS_OP_SYS_ACL_BLOB_GET_FILE
, (result
>= 0), handle
,
2198 "%s", smb_fname
->base_name
);
2203 static int smb_full_audit_sys_acl_blob_get_fd(vfs_handle_struct
*handle
,
2205 TALLOC_CTX
*mem_ctx
,
2206 char **blob_description
,
2211 result
= SMB_VFS_NEXT_SYS_ACL_BLOB_GET_FD(handle
, fsp
, mem_ctx
, blob_description
, blob
);
2213 do_log(SMB_VFS_OP_SYS_ACL_BLOB_GET_FD
, (result
>= 0), handle
,
2214 "%s", fsp_str_do_log(fsp
));
2219 static int smb_full_audit_sys_acl_set_file(vfs_handle_struct
*handle
,
2220 const struct smb_filename
*smb_fname
,
2221 SMB_ACL_TYPE_T acltype
,
2226 result
= SMB_VFS_NEXT_SYS_ACL_SET_FILE(handle
, smb_fname
, acltype
,
2229 do_log(SMB_VFS_OP_SYS_ACL_SET_FILE
, (result
>= 0), handle
,
2230 "%s", smb_fname
->base_name
);
2235 static int smb_full_audit_sys_acl_set_fd(vfs_handle_struct
*handle
, files_struct
*fsp
,
2240 result
= SMB_VFS_NEXT_SYS_ACL_SET_FD(handle
, fsp
, theacl
);
2242 do_log(SMB_VFS_OP_SYS_ACL_SET_FD
, (result
>= 0), handle
,
2243 "%s", fsp_str_do_log(fsp
));
2248 static int smb_full_audit_sys_acl_delete_def_file(vfs_handle_struct
*handle
,
2249 const struct smb_filename
*smb_fname
)
2253 result
= SMB_VFS_NEXT_SYS_ACL_DELETE_DEF_FILE(handle
, smb_fname
);
2255 do_log(SMB_VFS_OP_SYS_ACL_DELETE_DEF_FILE
, (result
>= 0), handle
,
2256 "%s", smb_fname
->base_name
);
2261 static ssize_t
smb_full_audit_getxattr(struct vfs_handle_struct
*handle
,
2262 const struct smb_filename
*smb_fname
,
2263 const char *name
, void *value
, size_t size
)
2267 result
= SMB_VFS_NEXT_GETXATTR(handle
, smb_fname
, name
, value
, size
);
2269 do_log(SMB_VFS_OP_GETXATTR
, (result
>= 0), handle
,
2270 "%s|%s", smb_fname
->base_name
, name
);
2275 static ssize_t
smb_full_audit_fgetxattr(struct vfs_handle_struct
*handle
,
2276 struct files_struct
*fsp
,
2277 const char *name
, void *value
, size_t size
)
2281 result
= SMB_VFS_NEXT_FGETXATTR(handle
, fsp
, name
, value
, size
);
2283 do_log(SMB_VFS_OP_FGETXATTR
, (result
>= 0), handle
,
2284 "%s|%s", fsp_str_do_log(fsp
), name
);
2289 static ssize_t
smb_full_audit_listxattr(struct vfs_handle_struct
*handle
,
2290 const struct smb_filename
*smb_fname
,
2296 result
= SMB_VFS_NEXT_LISTXATTR(handle
, smb_fname
, list
, size
);
2298 do_log(SMB_VFS_OP_LISTXATTR
, (result
>= 0), handle
, "%s",
2299 smb_fname
->base_name
);
2304 static ssize_t
smb_full_audit_flistxattr(struct vfs_handle_struct
*handle
,
2305 struct files_struct
*fsp
, char *list
,
2310 result
= SMB_VFS_NEXT_FLISTXATTR(handle
, fsp
, list
, size
);
2312 do_log(SMB_VFS_OP_FLISTXATTR
, (result
>= 0), handle
,
2313 "%s", fsp_str_do_log(fsp
));
2318 static int smb_full_audit_removexattr(struct vfs_handle_struct
*handle
,
2319 const struct smb_filename
*smb_fname
,
2324 result
= SMB_VFS_NEXT_REMOVEXATTR(handle
, smb_fname
, name
);
2326 do_log(SMB_VFS_OP_REMOVEXATTR
, (result
>= 0), handle
,
2327 "%s|%s", smb_fname
->base_name
, name
);
2332 static int smb_full_audit_fremovexattr(struct vfs_handle_struct
*handle
,
2333 struct files_struct
*fsp
,
2338 result
= SMB_VFS_NEXT_FREMOVEXATTR(handle
, fsp
, name
);
2340 do_log(SMB_VFS_OP_FREMOVEXATTR
, (result
>= 0), handle
,
2341 "%s|%s", fsp_str_do_log(fsp
), name
);
2346 static int smb_full_audit_setxattr(struct vfs_handle_struct
*handle
,
2347 const struct smb_filename
*smb_fname
,
2348 const char *name
, const void *value
, size_t size
,
2353 result
= SMB_VFS_NEXT_SETXATTR(handle
, smb_fname
, name
, value
, size
,
2356 do_log(SMB_VFS_OP_SETXATTR
, (result
>= 0), handle
,
2357 "%s|%s", smb_fname
->base_name
, name
);
2362 static int smb_full_audit_fsetxattr(struct vfs_handle_struct
*handle
,
2363 struct files_struct
*fsp
, const char *name
,
2364 const void *value
, size_t size
, int flags
)
2368 result
= SMB_VFS_NEXT_FSETXATTR(handle
, fsp
, name
, value
, size
, flags
);
2370 do_log(SMB_VFS_OP_FSETXATTR
, (result
>= 0), handle
,
2371 "%s|%s", fsp_str_do_log(fsp
), name
);
2376 static bool smb_full_audit_aio_force(struct vfs_handle_struct
*handle
,
2377 struct files_struct
*fsp
)
2381 result
= SMB_VFS_NEXT_AIO_FORCE(handle
, fsp
);
2382 do_log(SMB_VFS_OP_AIO_FORCE
, result
, handle
,
2383 "%s", fsp_str_do_log(fsp
));
2388 static NTSTATUS
smb_full_audit_durable_cookie(struct vfs_handle_struct
*handle
,
2389 struct files_struct
*fsp
,
2390 TALLOC_CTX
*mem_ctx
,
2395 result
= SMB_VFS_NEXT_DURABLE_COOKIE(handle
,
2400 do_log(SMB_VFS_OP_DURABLE_COOKIE
, NT_STATUS_IS_OK(result
), handle
,
2401 "%s", fsp_str_do_log(fsp
));
2406 static NTSTATUS
smb_full_audit_durable_disconnect(
2407 struct vfs_handle_struct
*handle
,
2408 struct files_struct
*fsp
,
2409 const DATA_BLOB old_cookie
,
2410 TALLOC_CTX
*mem_ctx
,
2411 DATA_BLOB
*new_cookie
)
2415 result
= SMB_VFS_NEXT_DURABLE_DISCONNECT(handle
,
2421 do_log(SMB_VFS_OP_DURABLE_DISCONNECT
, NT_STATUS_IS_OK(result
), handle
,
2422 "%s", fsp_str_do_log(fsp
));
2427 static NTSTATUS
smb_full_audit_durable_reconnect(
2428 struct vfs_handle_struct
*handle
,
2429 struct smb_request
*smb1req
,
2430 struct smbXsrv_open
*op
,
2431 const DATA_BLOB old_cookie
,
2432 TALLOC_CTX
*mem_ctx
,
2433 struct files_struct
**fsp
,
2434 DATA_BLOB
*new_cookie
)
2438 result
= SMB_VFS_NEXT_DURABLE_RECONNECT(handle
,
2446 do_log(SMB_VFS_OP_DURABLE_RECONNECT
,
2447 NT_STATUS_IS_OK(result
),
2454 static struct vfs_fn_pointers vfs_full_audit_fns
= {
2456 /* Disk operations */
2458 .connect_fn
= smb_full_audit_connect
,
2459 .disconnect_fn
= smb_full_audit_disconnect
,
2460 .disk_free_fn
= smb_full_audit_disk_free
,
2461 .get_quota_fn
= smb_full_audit_get_quota
,
2462 .set_quota_fn
= smb_full_audit_set_quota
,
2463 .get_shadow_copy_data_fn
= smb_full_audit_get_shadow_copy_data
,
2464 .statvfs_fn
= smb_full_audit_statvfs
,
2465 .fs_capabilities_fn
= smb_full_audit_fs_capabilities
,
2466 .get_dfs_referrals_fn
= smb_full_audit_get_dfs_referrals
,
2467 .opendir_fn
= smb_full_audit_opendir
,
2468 .fdopendir_fn
= smb_full_audit_fdopendir
,
2469 .readdir_fn
= smb_full_audit_readdir
,
2470 .seekdir_fn
= smb_full_audit_seekdir
,
2471 .telldir_fn
= smb_full_audit_telldir
,
2472 .rewind_dir_fn
= smb_full_audit_rewinddir
,
2473 .mkdir_fn
= smb_full_audit_mkdir
,
2474 .rmdir_fn
= smb_full_audit_rmdir
,
2475 .closedir_fn
= smb_full_audit_closedir
,
2476 .init_search_op_fn
= smb_full_audit_init_search_op
,
2477 .open_fn
= smb_full_audit_open
,
2478 .create_file_fn
= smb_full_audit_create_file
,
2479 .close_fn
= smb_full_audit_close
,
2480 .read_fn
= smb_full_audit_read
,
2481 .pread_fn
= smb_full_audit_pread
,
2482 .pread_send_fn
= smb_full_audit_pread_send
,
2483 .pread_recv_fn
= smb_full_audit_pread_recv
,
2484 .write_fn
= smb_full_audit_write
,
2485 .pwrite_fn
= smb_full_audit_pwrite
,
2486 .pwrite_send_fn
= smb_full_audit_pwrite_send
,
2487 .pwrite_recv_fn
= smb_full_audit_pwrite_recv
,
2488 .lseek_fn
= smb_full_audit_lseek
,
2489 .sendfile_fn
= smb_full_audit_sendfile
,
2490 .recvfile_fn
= smb_full_audit_recvfile
,
2491 .rename_fn
= smb_full_audit_rename
,
2492 .fsync_fn
= smb_full_audit_fsync
,
2493 .fsync_send_fn
= smb_full_audit_fsync_send
,
2494 .fsync_recv_fn
= smb_full_audit_fsync_recv
,
2495 .stat_fn
= smb_full_audit_stat
,
2496 .fstat_fn
= smb_full_audit_fstat
,
2497 .lstat_fn
= smb_full_audit_lstat
,
2498 .get_alloc_size_fn
= smb_full_audit_get_alloc_size
,
2499 .unlink_fn
= smb_full_audit_unlink
,
2500 .chmod_fn
= smb_full_audit_chmod
,
2501 .fchmod_fn
= smb_full_audit_fchmod
,
2502 .chown_fn
= smb_full_audit_chown
,
2503 .fchown_fn
= smb_full_audit_fchown
,
2504 .lchown_fn
= smb_full_audit_lchown
,
2505 .chdir_fn
= smb_full_audit_chdir
,
2506 .getwd_fn
= smb_full_audit_getwd
,
2507 .ntimes_fn
= smb_full_audit_ntimes
,
2508 .ftruncate_fn
= smb_full_audit_ftruncate
,
2509 .fallocate_fn
= smb_full_audit_fallocate
,
2510 .lock_fn
= smb_full_audit_lock
,
2511 .kernel_flock_fn
= smb_full_audit_kernel_flock
,
2512 .linux_setlease_fn
= smb_full_audit_linux_setlease
,
2513 .getlock_fn
= smb_full_audit_getlock
,
2514 .symlink_fn
= smb_full_audit_symlink
,
2515 .readlink_fn
= smb_full_audit_readlink
,
2516 .link_fn
= smb_full_audit_link
,
2517 .mknod_fn
= smb_full_audit_mknod
,
2518 .realpath_fn
= smb_full_audit_realpath
,
2519 .chflags_fn
= smb_full_audit_chflags
,
2520 .file_id_create_fn
= smb_full_audit_file_id_create
,
2521 .copy_chunk_send_fn
= smb_full_audit_copy_chunk_send
,
2522 .copy_chunk_recv_fn
= smb_full_audit_copy_chunk_recv
,
2523 .get_compression_fn
= smb_full_audit_get_compression
,
2524 .set_compression_fn
= smb_full_audit_set_compression
,
2525 .snap_check_path_fn
= smb_full_audit_snap_check_path
,
2526 .snap_create_fn
= smb_full_audit_snap_create
,
2527 .snap_delete_fn
= smb_full_audit_snap_delete
,
2528 .streaminfo_fn
= smb_full_audit_streaminfo
,
2529 .get_real_filename_fn
= smb_full_audit_get_real_filename
,
2530 .connectpath_fn
= smb_full_audit_connectpath
,
2531 .brl_lock_windows_fn
= smb_full_audit_brl_lock_windows
,
2532 .brl_unlock_windows_fn
= smb_full_audit_brl_unlock_windows
,
2533 .brl_cancel_windows_fn
= smb_full_audit_brl_cancel_windows
,
2534 .strict_lock_fn
= smb_full_audit_strict_lock
,
2535 .strict_unlock_fn
= smb_full_audit_strict_unlock
,
2536 .translate_name_fn
= smb_full_audit_translate_name
,
2537 .fsctl_fn
= smb_full_audit_fsctl
,
2538 .get_dos_attributes_fn
= smb_full_audit_get_dos_attributes
,
2539 .fget_dos_attributes_fn
= smb_full_audit_fget_dos_attributes
,
2540 .set_dos_attributes_fn
= smb_full_audit_set_dos_attributes
,
2541 .fset_dos_attributes_fn
= smb_full_audit_fset_dos_attributes
,
2542 .fget_nt_acl_fn
= smb_full_audit_fget_nt_acl
,
2543 .get_nt_acl_fn
= smb_full_audit_get_nt_acl
,
2544 .fset_nt_acl_fn
= smb_full_audit_fset_nt_acl
,
2545 .audit_file_fn
= smb_full_audit_audit_file
,
2546 .chmod_acl_fn
= smb_full_audit_chmod_acl
,
2547 .fchmod_acl_fn
= smb_full_audit_fchmod_acl
,
2548 .sys_acl_get_file_fn
= smb_full_audit_sys_acl_get_file
,
2549 .sys_acl_get_fd_fn
= smb_full_audit_sys_acl_get_fd
,
2550 .sys_acl_blob_get_file_fn
= smb_full_audit_sys_acl_blob_get_file
,
2551 .sys_acl_blob_get_fd_fn
= smb_full_audit_sys_acl_blob_get_fd
,
2552 .sys_acl_set_file_fn
= smb_full_audit_sys_acl_set_file
,
2553 .sys_acl_set_fd_fn
= smb_full_audit_sys_acl_set_fd
,
2554 .sys_acl_delete_def_file_fn
= smb_full_audit_sys_acl_delete_def_file
,
2555 .getxattr_fn
= smb_full_audit_getxattr
,
2556 .fgetxattr_fn
= smb_full_audit_fgetxattr
,
2557 .listxattr_fn
= smb_full_audit_listxattr
,
2558 .flistxattr_fn
= smb_full_audit_flistxattr
,
2559 .removexattr_fn
= smb_full_audit_removexattr
,
2560 .fremovexattr_fn
= smb_full_audit_fremovexattr
,
2561 .setxattr_fn
= smb_full_audit_setxattr
,
2562 .fsetxattr_fn
= smb_full_audit_fsetxattr
,
2563 .aio_force_fn
= smb_full_audit_aio_force
,
2564 .durable_cookie_fn
= smb_full_audit_durable_cookie
,
2565 .durable_disconnect_fn
= smb_full_audit_durable_disconnect
,
2566 .durable_reconnect_fn
= smb_full_audit_durable_reconnect
,
2567 .readdir_attr_fn
= smb_full_audit_readdir_attr
2572 NTSTATUS
vfs_full_audit_init(TALLOC_CTX
*ctx
)
2576 smb_vfs_assert_all_fns(&vfs_full_audit_fns
, "full_audit");
2578 ret
= smb_register_vfs(SMB_VFS_INTERFACE_VERSION
, "full_audit",
2579 &vfs_full_audit_fns
);
2581 if (!NT_STATUS_IS_OK(ret
))
2584 vfs_full_audit_debug_level
= debug_add_class("full_audit");
2585 if (vfs_full_audit_debug_level
== -1) {
2586 vfs_full_audit_debug_level
= DBGC_VFS
;
2587 DEBUG(0, ("vfs_full_audit: Couldn't register custom debugging "
2590 DEBUG(10, ("vfs_full_audit: Debug class number of "
2591 "'full_audit': %d\n", vfs_full_audit_debug_level
));