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 create_file
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|/tmp
42 * smbd_audit: nobody|192.168.234.1|create_file|fail (No such file or directory)|0x1|file|open|/ts/doesNotExist
43 * smbd_audit: nobody|192.168.234.1|open|ok|w|/tmp/file.txt
44 * smbd_audit: nobody|192.168.234.1|create_file|ok|0x3|file|open|/tmp/file.txt
46 * where "nobody" is the connected username and "192.168.234.1" is the
47 * client's IP address.
51 * prefix: A macro expansion template prepended to the syslog entry.
53 * success: A list of VFS operations for which a successful completion should
54 * be logged. Defaults to no logging at all. The special operation "all" logs
55 * - you guessed it - everything.
57 * failure: A list of VFS operations for which failure to complete should be
58 * logged. Defaults to logging everything.
63 #include "system/filesys.h"
64 #include "system/syslog.h"
65 #include "smbd/smbd.h"
66 #include "../librpc/gen_ndr/ndr_netlogon.h"
69 #include "lib/param/loadparm.h"
70 #include "lib/util/bitmap.h"
71 #include "lib/util/tevent_unix.h"
72 #include "libcli/security/sddl.h"
73 #include "passdb/machine_sid.h"
74 #include "lib/util/tevent_ntstatus.h"
76 static int vfs_full_audit_debug_level
= DBGC_VFS
;
78 struct vfs_full_audit_private_data
{
79 struct bitmap
*success_ops
;
80 struct bitmap
*failure_ops
;
88 #define DBGC_CLASS vfs_full_audit_debug_level
90 typedef enum _vfs_op_type
{
95 SMB_VFS_OP_CONNECT
= 0,
96 SMB_VFS_OP_DISCONNECT
,
100 SMB_VFS_OP_GET_SHADOW_COPY_DATA
,
102 SMB_VFS_OP_FS_CAPABILITIES
,
103 SMB_VFS_OP_GET_DFS_REFERRALS
,
104 SMB_VFS_OP_CREATE_DFS_PATHAT
,
105 SMB_VFS_OP_READ_DFS_PATHAT
,
107 /* Directory operations */
110 SMB_VFS_OP_FDOPENDIR
,
114 SMB_VFS_OP_REWINDDIR
,
118 /* File operations */
121 SMB_VFS_OP_CREATE_FILE
,
125 SMB_VFS_OP_PREAD_SEND
,
126 SMB_VFS_OP_PREAD_RECV
,
129 SMB_VFS_OP_PWRITE_SEND
,
130 SMB_VFS_OP_PWRITE_RECV
,
136 SMB_VFS_OP_FSYNC_SEND
,
137 SMB_VFS_OP_FSYNC_RECV
,
141 SMB_VFS_OP_GET_ALLOC_SIZE
,
150 SMB_VFS_OP_FTRUNCATE
,
151 SMB_VFS_OP_FALLOCATE
,
153 SMB_VFS_OP_KERNEL_FLOCK
,
155 SMB_VFS_OP_LINUX_SETLEASE
,
157 SMB_VFS_OP_SYMLINKAT
,
158 SMB_VFS_OP_READLINKAT
,
163 SMB_VFS_OP_FILE_ID_CREATE
,
164 SMB_VFS_OP_FS_FILE_ID
,
165 SMB_VFS_OP_STREAMINFO
,
166 SMB_VFS_OP_GET_REAL_FILENAME
,
167 SMB_VFS_OP_CONNECTPATH
,
168 SMB_VFS_OP_BRL_LOCK_WINDOWS
,
169 SMB_VFS_OP_BRL_UNLOCK_WINDOWS
,
170 SMB_VFS_OP_STRICT_LOCK_CHECK
,
171 SMB_VFS_OP_TRANSLATE_NAME
,
173 SMB_VFS_OP_OFFLOAD_READ_SEND
,
174 SMB_VFS_OP_OFFLOAD_READ_RECV
,
175 SMB_VFS_OP_OFFLOAD_WRITE_SEND
,
176 SMB_VFS_OP_OFFLOAD_WRITE_RECV
,
177 SMB_VFS_OP_GET_COMPRESSION
,
178 SMB_VFS_OP_SET_COMPRESSION
,
179 SMB_VFS_OP_SNAP_CHECK_PATH
,
180 SMB_VFS_OP_SNAP_CREATE
,
181 SMB_VFS_OP_SNAP_DELETE
,
183 /* DOS attribute operations. */
184 SMB_VFS_OP_GET_DOS_ATTRIBUTES
,
185 SMB_VFS_OP_GET_DOS_ATTRIBUTES_SEND
,
186 SMB_VFS_OP_GET_DOS_ATTRIBUTES_RECV
,
187 SMB_VFS_OP_FGET_DOS_ATTRIBUTES
,
188 SMB_VFS_OP_SET_DOS_ATTRIBUTES
,
189 SMB_VFS_OP_FSET_DOS_ATTRIBUTES
,
191 /* NT ACL operations. */
193 SMB_VFS_OP_FGET_NT_ACL
,
194 SMB_VFS_OP_GET_NT_ACL
,
195 SMB_VFS_OP_FSET_NT_ACL
,
196 SMB_VFS_OP_AUDIT_FILE
,
198 /* POSIX ACL operations. */
200 SMB_VFS_OP_SYS_ACL_GET_FILE
,
201 SMB_VFS_OP_SYS_ACL_GET_FD
,
202 SMB_VFS_OP_SYS_ACL_BLOB_GET_FILE
,
203 SMB_VFS_OP_SYS_ACL_BLOB_GET_FD
,
204 SMB_VFS_OP_SYS_ACL_SET_FILE
,
205 SMB_VFS_OP_SYS_ACL_SET_FD
,
206 SMB_VFS_OP_SYS_ACL_DELETE_DEF_FILE
,
210 SMB_VFS_OP_GETXATTRAT_SEND
,
211 SMB_VFS_OP_GETXATTRAT_RECV
,
212 SMB_VFS_OP_FGETXATTR
,
213 SMB_VFS_OP_LISTXATTR
,
214 SMB_VFS_OP_FLISTXATTR
,
215 SMB_VFS_OP_REMOVEXATTR
,
216 SMB_VFS_OP_FREMOVEXATTR
,
218 SMB_VFS_OP_FSETXATTR
,
221 SMB_VFS_OP_AIO_FORCE
,
223 /* offline operations */
224 SMB_VFS_OP_IS_OFFLINE
,
225 SMB_VFS_OP_SET_OFFLINE
,
227 /* Durable handle operations. */
228 SMB_VFS_OP_DURABLE_COOKIE
,
229 SMB_VFS_OP_DURABLE_DISCONNECT
,
230 SMB_VFS_OP_DURABLE_RECONNECT
,
232 SMB_VFS_OP_READDIR_ATTR
,
234 /* This should always be last enum value */
239 /* The following array *must* be in the same order as defined in vfs_op_type */
245 { SMB_VFS_OP_CONNECT
, "connect" },
246 { SMB_VFS_OP_DISCONNECT
, "disconnect" },
247 { SMB_VFS_OP_DISK_FREE
, "disk_free" },
248 { SMB_VFS_OP_GET_QUOTA
, "get_quota" },
249 { SMB_VFS_OP_SET_QUOTA
, "set_quota" },
250 { SMB_VFS_OP_GET_SHADOW_COPY_DATA
, "get_shadow_copy_data" },
251 { SMB_VFS_OP_STATVFS
, "statvfs" },
252 { SMB_VFS_OP_FS_CAPABILITIES
, "fs_capabilities" },
253 { SMB_VFS_OP_GET_DFS_REFERRALS
, "get_dfs_referrals" },
254 { SMB_VFS_OP_CREATE_DFS_PATHAT
, "create_dfs_pathat" },
255 { SMB_VFS_OP_READ_DFS_PATHAT
, "read_dfs_pathat" },
256 { SMB_VFS_OP_OPENDIR
, "opendir" },
257 { SMB_VFS_OP_FDOPENDIR
, "fdopendir" },
258 { SMB_VFS_OP_READDIR
, "readdir" },
259 { SMB_VFS_OP_SEEKDIR
, "seekdir" },
260 { SMB_VFS_OP_TELLDIR
, "telldir" },
261 { SMB_VFS_OP_REWINDDIR
, "rewinddir" },
262 { SMB_VFS_OP_MKDIRAT
, "mkdirat" },
263 { SMB_VFS_OP_CLOSEDIR
, "closedir" },
264 { SMB_VFS_OP_OPEN
, "open" },
265 { SMB_VFS_OP_CREATE_FILE
, "create_file" },
266 { SMB_VFS_OP_CLOSE
, "close" },
267 { SMB_VFS_OP_READ
, "read" },
268 { SMB_VFS_OP_PREAD
, "pread" },
269 { SMB_VFS_OP_PREAD_SEND
, "pread_send" },
270 { SMB_VFS_OP_PREAD_RECV
, "pread_recv" },
271 { SMB_VFS_OP_WRITE
, "write" },
272 { SMB_VFS_OP_PWRITE
, "pwrite" },
273 { SMB_VFS_OP_PWRITE_SEND
, "pwrite_send" },
274 { SMB_VFS_OP_PWRITE_RECV
, "pwrite_recv" },
275 { SMB_VFS_OP_LSEEK
, "lseek" },
276 { SMB_VFS_OP_SENDFILE
, "sendfile" },
277 { SMB_VFS_OP_RECVFILE
, "recvfile" },
278 { SMB_VFS_OP_RENAMEAT
, "renameat" },
279 { SMB_VFS_OP_FSYNC
, "fsync" },
280 { SMB_VFS_OP_FSYNC_SEND
, "fsync_send" },
281 { SMB_VFS_OP_FSYNC_RECV
, "fsync_recv" },
282 { SMB_VFS_OP_STAT
, "stat" },
283 { SMB_VFS_OP_FSTAT
, "fstat" },
284 { SMB_VFS_OP_LSTAT
, "lstat" },
285 { SMB_VFS_OP_GET_ALLOC_SIZE
, "get_alloc_size" },
286 { SMB_VFS_OP_UNLINKAT
, "unlinkat" },
287 { SMB_VFS_OP_CHMOD
, "chmod" },
288 { SMB_VFS_OP_FCHMOD
, "fchmod" },
289 { SMB_VFS_OP_FCHOWN
, "fchown" },
290 { SMB_VFS_OP_LCHOWN
, "lchown" },
291 { SMB_VFS_OP_CHDIR
, "chdir" },
292 { SMB_VFS_OP_GETWD
, "getwd" },
293 { SMB_VFS_OP_NTIMES
, "ntimes" },
294 { SMB_VFS_OP_FTRUNCATE
, "ftruncate" },
295 { SMB_VFS_OP_FALLOCATE
,"fallocate" },
296 { SMB_VFS_OP_LOCK
, "lock" },
297 { SMB_VFS_OP_KERNEL_FLOCK
, "kernel_flock" },
298 { SMB_VFS_OP_FCNTL
, "fcntl" },
299 { SMB_VFS_OP_LINUX_SETLEASE
, "linux_setlease" },
300 { SMB_VFS_OP_GETLOCK
, "getlock" },
301 { SMB_VFS_OP_SYMLINKAT
, "symlinkat" },
302 { SMB_VFS_OP_READLINKAT
,"readlinkat" },
303 { SMB_VFS_OP_LINKAT
, "linkat" },
304 { SMB_VFS_OP_MKNODAT
, "mknodat" },
305 { SMB_VFS_OP_REALPATH
, "realpath" },
306 { SMB_VFS_OP_CHFLAGS
, "chflags" },
307 { SMB_VFS_OP_FILE_ID_CREATE
, "file_id_create" },
308 { SMB_VFS_OP_FS_FILE_ID
, "fs_file_id" },
309 { SMB_VFS_OP_STREAMINFO
, "streaminfo" },
310 { SMB_VFS_OP_GET_REAL_FILENAME
, "get_real_filename" },
311 { SMB_VFS_OP_CONNECTPATH
, "connectpath" },
312 { SMB_VFS_OP_BRL_LOCK_WINDOWS
, "brl_lock_windows" },
313 { SMB_VFS_OP_BRL_UNLOCK_WINDOWS
, "brl_unlock_windows" },
314 { SMB_VFS_OP_STRICT_LOCK_CHECK
, "strict_lock_check" },
315 { SMB_VFS_OP_TRANSLATE_NAME
, "translate_name" },
316 { SMB_VFS_OP_FSCTL
, "fsctl" },
317 { SMB_VFS_OP_OFFLOAD_READ_SEND
, "offload_read_send" },
318 { SMB_VFS_OP_OFFLOAD_READ_RECV
, "offload_read_recv" },
319 { SMB_VFS_OP_OFFLOAD_WRITE_SEND
, "offload_write_send" },
320 { SMB_VFS_OP_OFFLOAD_WRITE_RECV
, "offload_write_recv" },
321 { SMB_VFS_OP_GET_COMPRESSION
, "get_compression" },
322 { SMB_VFS_OP_SET_COMPRESSION
, "set_compression" },
323 { SMB_VFS_OP_SNAP_CHECK_PATH
, "snap_check_path" },
324 { SMB_VFS_OP_SNAP_CREATE
, "snap_create" },
325 { SMB_VFS_OP_SNAP_DELETE
, "snap_delete" },
326 { SMB_VFS_OP_GET_DOS_ATTRIBUTES
, "get_dos_attributes" },
327 { SMB_VFS_OP_GET_DOS_ATTRIBUTES_SEND
, "get_dos_attributes_send" },
328 { SMB_VFS_OP_GET_DOS_ATTRIBUTES_RECV
, "get_dos_attributes_recv" },
329 { SMB_VFS_OP_FGET_DOS_ATTRIBUTES
, "fget_dos_attributes" },
330 { SMB_VFS_OP_SET_DOS_ATTRIBUTES
, "set_dos_attributes" },
331 { SMB_VFS_OP_FSET_DOS_ATTRIBUTES
, "fset_dos_attributes" },
332 { SMB_VFS_OP_FGET_NT_ACL
, "fget_nt_acl" },
333 { SMB_VFS_OP_GET_NT_ACL
, "get_nt_acl" },
334 { SMB_VFS_OP_FSET_NT_ACL
, "fset_nt_acl" },
335 { SMB_VFS_OP_AUDIT_FILE
, "audit_file" },
336 { SMB_VFS_OP_SYS_ACL_GET_FILE
, "sys_acl_get_file" },
337 { SMB_VFS_OP_SYS_ACL_GET_FD
, "sys_acl_get_fd" },
338 { SMB_VFS_OP_SYS_ACL_BLOB_GET_FILE
, "sys_acl_blob_get_file" },
339 { SMB_VFS_OP_SYS_ACL_BLOB_GET_FD
, "sys_acl_blob_get_fd" },
340 { SMB_VFS_OP_SYS_ACL_SET_FILE
, "sys_acl_set_file" },
341 { SMB_VFS_OP_SYS_ACL_SET_FD
, "sys_acl_set_fd" },
342 { SMB_VFS_OP_SYS_ACL_DELETE_DEF_FILE
, "sys_acl_delete_def_file" },
343 { SMB_VFS_OP_GETXATTR
, "getxattr" },
344 { SMB_VFS_OP_GETXATTRAT_SEND
, "getxattrat_send" },
345 { SMB_VFS_OP_GETXATTRAT_RECV
, "getxattrat_recv" },
346 { SMB_VFS_OP_FGETXATTR
, "fgetxattr" },
347 { SMB_VFS_OP_LISTXATTR
, "listxattr" },
348 { SMB_VFS_OP_FLISTXATTR
, "flistxattr" },
349 { SMB_VFS_OP_REMOVEXATTR
, "removexattr" },
350 { SMB_VFS_OP_FREMOVEXATTR
, "fremovexattr" },
351 { SMB_VFS_OP_SETXATTR
, "setxattr" },
352 { SMB_VFS_OP_FSETXATTR
, "fsetxattr" },
353 { SMB_VFS_OP_AIO_FORCE
, "aio_force" },
354 { SMB_VFS_OP_IS_OFFLINE
, "is_offline" },
355 { SMB_VFS_OP_SET_OFFLINE
, "set_offline" },
356 { SMB_VFS_OP_DURABLE_COOKIE
, "durable_cookie" },
357 { SMB_VFS_OP_DURABLE_DISCONNECT
, "durable_disconnect" },
358 { SMB_VFS_OP_DURABLE_RECONNECT
, "durable_reconnect" },
359 { SMB_VFS_OP_READDIR_ATTR
, "readdir_attr" },
360 { SMB_VFS_OP_LAST
, NULL
}
363 static int audit_syslog_facility(vfs_handle_struct
*handle
)
365 static const struct enum_list enum_log_facilities
[] = {
367 { LOG_AUTH
, "AUTH" },
370 { LOG_AUTHPRIV
, "AUTHPRIV" },
373 { LOG_AUDIT
, "AUDIT" },
376 { LOG_CONSOLE
, "CONSOLE" },
379 { LOG_CRON
, "CRON" },
382 { LOG_DAEMON
, "DAEMON" },
388 { LOG_INSTALL
, "INSTALL" },
391 { LOG_KERN
, "KERN" },
394 { LOG_LAUNCHD
, "LAUNCHD" },
397 { LOG_LFMT
, "LFMT" },
403 { LOG_MAIL
, "MAIL" },
406 { LOG_MEGASAFE
, "MEGASAFE" },
409 { LOG_NETINFO
, "NETINFO" },
412 { LOG_NEWS
, "NEWS" },
414 #ifdef LOG_NFACILITIES
415 { LOG_NFACILITIES
, "NFACILITIES" },
423 #ifdef LOG_REMOTEAUTH
424 { LOG_REMOTEAUTH
, "REMOTEAUTH" },
427 { LOG_SECURITY
, "SECURITY" },
430 { LOG_SYSLOG
, "SYSLOG" },
433 { LOG_USER
, "USER" },
436 { LOG_UUCP
, "UUCP" },
438 { LOG_LOCAL0
, "LOCAL0" },
439 { LOG_LOCAL1
, "LOCAL1" },
440 { LOG_LOCAL2
, "LOCAL2" },
441 { LOG_LOCAL3
, "LOCAL3" },
442 { LOG_LOCAL4
, "LOCAL4" },
443 { LOG_LOCAL5
, "LOCAL5" },
444 { LOG_LOCAL6
, "LOCAL6" },
445 { LOG_LOCAL7
, "LOCAL7" },
451 facility
= lp_parm_enum(SNUM(handle
->conn
), "full_audit", "facility", enum_log_facilities
, LOG_USER
);
456 static int audit_syslog_priority(vfs_handle_struct
*handle
)
458 static const struct enum_list enum_log_priorities
[] = {
459 { LOG_EMERG
, "EMERG" },
460 { LOG_ALERT
, "ALERT" },
461 { LOG_CRIT
, "CRIT" },
463 { LOG_WARNING
, "WARNING" },
464 { LOG_NOTICE
, "NOTICE" },
465 { LOG_INFO
, "INFO" },
466 { LOG_DEBUG
, "DEBUG" },
472 priority
= lp_parm_enum(SNUM(handle
->conn
), "full_audit", "priority",
473 enum_log_priorities
, LOG_NOTICE
);
474 if (priority
== -1) {
475 priority
= LOG_WARNING
;
481 static char *audit_prefix(TALLOC_CTX
*ctx
, connection_struct
*conn
)
483 const struct loadparm_substitution
*lp_sub
=
484 loadparm_s3_global_substitution();
488 prefix
= talloc_strdup(ctx
,
489 lp_parm_const_string(SNUM(conn
), "full_audit",
494 result
= talloc_sub_full(ctx
,
495 lp_servicename(talloc_tos(), lp_sub
, SNUM(conn
)),
496 conn
->session_info
->unix_info
->unix_name
,
498 conn
->session_info
->unix_token
->gid
,
499 conn
->session_info
->unix_info
->sanitized_username
,
500 conn
->session_info
->info
->domain_name
,
506 static bool log_success(struct vfs_full_audit_private_data
*pd
, vfs_op_type op
)
508 if (pd
->success_ops
== NULL
) {
512 return bitmap_query(pd
->success_ops
, op
);
515 static bool log_failure(struct vfs_full_audit_private_data
*pd
, vfs_op_type op
)
517 if (pd
->failure_ops
== NULL
)
520 return bitmap_query(pd
->failure_ops
, op
);
523 static struct bitmap
*init_bitmap(TALLOC_CTX
*mem_ctx
, const char **ops
)
531 bm
= bitmap_talloc(mem_ctx
, SMB_VFS_OP_LAST
);
533 DEBUG(0, ("Could not alloc bitmap -- "
534 "defaulting to logging everything\n"));
538 for (; *ops
!= NULL
; ops
+= 1) {
543 if (strequal(*ops
, "all")) {
544 for (i
=0; i
<SMB_VFS_OP_LAST
; i
++) {
550 if (strequal(*ops
, "none")) {
560 for (i
=0; i
<SMB_VFS_OP_LAST
; i
++) {
561 if ((vfs_op_names
[i
].name
== NULL
)
562 || (vfs_op_names
[i
].type
!= i
)) {
563 smb_panic("vfs_full_audit.c: name table not "
564 "in sync with vfs_op_type enums\n");
566 if (strequal(op
, vfs_op_names
[i
].name
)) {
575 if (i
== SMB_VFS_OP_LAST
) {
576 DEBUG(0, ("Could not find opname %s, logging all\n",
585 static const char *audit_opname(vfs_op_type op
)
587 if (op
>= SMB_VFS_OP_LAST
)
588 return "INVALID VFS OP";
589 return vfs_op_names
[op
].name
;
592 static TALLOC_CTX
*tmp_do_log_ctx
;
594 * Get us a temporary talloc context usable just for DEBUG arguments
596 static TALLOC_CTX
*do_log_ctx(void)
598 if (tmp_do_log_ctx
== NULL
) {
599 tmp_do_log_ctx
= talloc_named_const(NULL
, 0, "do_log_ctx");
601 return tmp_do_log_ctx
;
604 static void do_log(vfs_op_type op
, bool success
, vfs_handle_struct
*handle
,
605 const char *format
, ...) PRINTF_ATTRIBUTE(4, 5);
607 static void do_log(vfs_op_type op
, bool success
, vfs_handle_struct
*handle
,
608 const char *format
, ...)
610 struct vfs_full_audit_private_data
*pd
;
612 char *audit_pre
= NULL
;
616 SMB_VFS_HANDLE_GET_DATA(handle
, pd
,
617 struct vfs_full_audit_private_data
,
620 if (success
&& (!log_success(pd
, op
)))
623 if (!success
&& (!log_failure(pd
, op
)))
627 fstrcpy(err_msg
, "ok");
629 fstr_sprintf(err_msg
, "fail (%s)", strerror(errno
));
631 va_start(ap
, format
);
632 op_msg
= talloc_vasprintf(talloc_tos(), format
, ap
);
639 audit_pre
= audit_prefix(talloc_tos(), handle
->conn
);
645 * Specify the facility to interoperate with other syslog
646 * callers (smbd for example).
648 priority
= pd
->syslog_priority
| pd
->syslog_facility
;
650 syslog(priority
, "%s|%s|%s|%s\n",
651 audit_pre
? audit_pre
: "",
652 audit_opname(op
), err_msg
, op_msg
);
654 DEBUG(1, ("%s|%s|%s|%s\n",
655 audit_pre
? audit_pre
: "",
656 audit_opname(op
), err_msg
, op_msg
));
659 TALLOC_FREE(audit_pre
);
661 TALLOC_FREE(tmp_do_log_ctx
);
665 * Return a string using the do_log_ctx()
667 static const char *smb_fname_str_do_log(struct connection_struct
*conn
,
668 const struct smb_filename
*smb_fname
)
673 if (smb_fname
== NULL
) {
677 if (smb_fname
->base_name
[0] != '/') {
678 char *abs_name
= NULL
;
679 struct smb_filename
*fname_copy
= cp_smb_filename(
682 if (fname_copy
== NULL
) {
686 if (!ISDOT(smb_fname
->base_name
)) {
687 abs_name
= talloc_asprintf(do_log_ctx(),
689 conn
->cwd_fsp
->fsp_name
->base_name
,
690 smb_fname
->base_name
);
692 abs_name
= talloc_strdup(do_log_ctx(),
693 conn
->cwd_fsp
->fsp_name
->base_name
);
695 if (abs_name
== NULL
) {
698 fname_copy
->base_name
= abs_name
;
699 smb_fname
= fname_copy
;
702 status
= get_full_smb_filename(do_log_ctx(), smb_fname
, &fname
);
703 if (!NT_STATUS_IS_OK(status
)) {
710 * Return an fsp debug string using the do_log_ctx()
712 static const char *fsp_str_do_log(const struct files_struct
*fsp
)
714 return smb_fname_str_do_log(fsp
->conn
, fsp
->fsp_name
);
717 /* Implementation of vfs_ops. Pass everything on to the default
718 operation but log event first. */
720 static int smb_full_audit_connect(vfs_handle_struct
*handle
,
721 const char *svc
, const char *user
)
724 const char *none
[] = { "none" };
725 struct vfs_full_audit_private_data
*pd
= NULL
;
727 result
= SMB_VFS_NEXT_CONNECT(handle
, svc
, user
);
732 pd
= talloc_zero(handle
, struct vfs_full_audit_private_data
);
734 SMB_VFS_NEXT_DISCONNECT(handle
);
738 pd
->syslog_facility
= audit_syslog_facility(handle
);
739 if (pd
->syslog_facility
== -1) {
740 DEBUG(1, ("%s: Unknown facility %s\n", __func__
,
741 lp_parm_const_string(SNUM(handle
->conn
),
742 "full_audit", "facility",
744 SMB_VFS_NEXT_DISCONNECT(handle
);
748 pd
->syslog_priority
= audit_syslog_priority(handle
);
750 pd
->log_secdesc
= lp_parm_bool(SNUM(handle
->conn
),
751 "full_audit", "log_secdesc", false);
753 pd
->do_syslog
= lp_parm_bool(SNUM(handle
->conn
),
754 "full_audit", "syslog", true);
758 openlog("smbd_audit", 0, pd
->syslog_facility
);
762 pd
->success_ops
= init_bitmap(
763 pd
, lp_parm_string_list(SNUM(handle
->conn
), "full_audit",
765 pd
->failure_ops
= init_bitmap(
766 pd
, lp_parm_string_list(SNUM(handle
->conn
), "full_audit",
769 /* Store the private data. */
770 SMB_VFS_HANDLE_SET_DATA(handle
, pd
, NULL
,
771 struct vfs_full_audit_private_data
, return -1);
773 do_log(SMB_VFS_OP_CONNECT
, True
, handle
,
779 static void smb_full_audit_disconnect(vfs_handle_struct
*handle
)
781 const struct loadparm_substitution
*lp_sub
=
782 loadparm_s3_global_substitution();
784 SMB_VFS_NEXT_DISCONNECT(handle
);
786 do_log(SMB_VFS_OP_DISCONNECT
, True
, handle
,
787 "%s", lp_servicename(talloc_tos(), lp_sub
, SNUM(handle
->conn
)));
789 /* The bitmaps will be disconnected when the private
793 static uint64_t smb_full_audit_disk_free(vfs_handle_struct
*handle
,
794 const struct smb_filename
*smb_fname
,
801 result
= SMB_VFS_NEXT_DISK_FREE(handle
, smb_fname
, bsize
, dfree
, dsize
);
803 /* Don't have a reasonable notion of failure here */
805 do_log(SMB_VFS_OP_DISK_FREE
,
809 smb_fname_str_do_log(handle
->conn
, smb_fname
));
814 static int smb_full_audit_get_quota(struct vfs_handle_struct
*handle
,
815 const struct smb_filename
*smb_fname
,
816 enum SMB_QUOTA_TYPE qtype
,
822 result
= SMB_VFS_NEXT_GET_QUOTA(handle
, smb_fname
, qtype
, id
, qt
);
824 do_log(SMB_VFS_OP_GET_QUOTA
,
828 smb_fname_str_do_log(handle
->conn
, smb_fname
));
833 static int smb_full_audit_set_quota(struct vfs_handle_struct
*handle
,
834 enum SMB_QUOTA_TYPE qtype
, unid_t id
,
839 result
= SMB_VFS_NEXT_SET_QUOTA(handle
, qtype
, id
, qt
);
841 do_log(SMB_VFS_OP_SET_QUOTA
, (result
>= 0), handle
, "");
846 static int smb_full_audit_get_shadow_copy_data(struct vfs_handle_struct
*handle
,
847 struct files_struct
*fsp
,
848 struct shadow_copy_data
*shadow_copy_data
,
853 result
= SMB_VFS_NEXT_GET_SHADOW_COPY_DATA(handle
, fsp
, shadow_copy_data
, labels
);
855 do_log(SMB_VFS_OP_GET_SHADOW_COPY_DATA
, (result
>= 0), handle
, "");
860 static int smb_full_audit_statvfs(struct vfs_handle_struct
*handle
,
861 const struct smb_filename
*smb_fname
,
862 struct vfs_statvfs_struct
*statbuf
)
866 result
= SMB_VFS_NEXT_STATVFS(handle
, smb_fname
, statbuf
);
868 do_log(SMB_VFS_OP_STATVFS
, (result
>= 0), handle
, "");
873 static uint32_t smb_full_audit_fs_capabilities(struct vfs_handle_struct
*handle
, enum timestamp_set_resolution
*p_ts_res
)
877 result
= SMB_VFS_NEXT_FS_CAPABILITIES(handle
, p_ts_res
);
879 do_log(SMB_VFS_OP_FS_CAPABILITIES
, true, handle
, "");
884 static NTSTATUS
smb_full_audit_get_dfs_referrals(
885 struct vfs_handle_struct
*handle
,
886 struct dfs_GetDFSReferral
*r
)
890 status
= SMB_VFS_NEXT_GET_DFS_REFERRALS(handle
, r
);
892 do_log(SMB_VFS_OP_GET_DFS_REFERRALS
, NT_STATUS_IS_OK(status
),
898 static NTSTATUS
smb_full_audit_create_dfs_pathat(struct vfs_handle_struct
*handle
,
899 struct files_struct
*dirfsp
,
900 const struct smb_filename
*smb_fname
,
901 const struct referral
*reflist
,
902 size_t referral_count
)
906 status
= SMB_VFS_NEXT_CREATE_DFS_PATHAT(handle
,
912 do_log(SMB_VFS_OP_CREATE_DFS_PATHAT
,
913 NT_STATUS_IS_OK(status
),
916 smb_fname_str_do_log(handle
->conn
, smb_fname
));
921 static NTSTATUS
smb_full_audit_read_dfs_pathat(struct vfs_handle_struct
*handle
,
923 struct files_struct
*dirfsp
,
924 const struct smb_filename
*smb_fname
,
925 struct referral
**ppreflist
,
926 size_t *preferral_count
)
930 status
= SMB_VFS_NEXT_READ_DFS_PATHAT(handle
,
937 do_log(SMB_VFS_OP_READ_DFS_PATHAT
,
938 NT_STATUS_IS_OK(status
),
941 smb_fname_str_do_log(handle
->conn
, smb_fname
));
946 static NTSTATUS
smb_full_audit_snap_check_path(struct vfs_handle_struct
*handle
,
948 const char *service_path
,
953 status
= SMB_VFS_NEXT_SNAP_CHECK_PATH(handle
, mem_ctx
, service_path
,
955 do_log(SMB_VFS_OP_SNAP_CHECK_PATH
, NT_STATUS_IS_OK(status
),
961 static NTSTATUS
smb_full_audit_snap_create(struct vfs_handle_struct
*handle
,
963 const char *base_volume
,
971 status
= SMB_VFS_NEXT_SNAP_CREATE(handle
, mem_ctx
, base_volume
, tstamp
,
972 rw
, base_path
, snap_path
);
973 do_log(SMB_VFS_OP_SNAP_CREATE
, NT_STATUS_IS_OK(status
), handle
, "");
978 static NTSTATUS
smb_full_audit_snap_delete(struct vfs_handle_struct
*handle
,
985 status
= SMB_VFS_NEXT_SNAP_DELETE(handle
, mem_ctx
, base_path
,
987 do_log(SMB_VFS_OP_SNAP_DELETE
, NT_STATUS_IS_OK(status
), handle
, "");
992 static DIR *smb_full_audit_opendir(vfs_handle_struct
*handle
,
993 const struct smb_filename
*smb_fname
,
999 result
= SMB_VFS_NEXT_OPENDIR(handle
, smb_fname
, mask
, attr
);
1001 do_log(SMB_VFS_OP_OPENDIR
,
1005 smb_fname_str_do_log(handle
->conn
, smb_fname
));
1010 static DIR *smb_full_audit_fdopendir(vfs_handle_struct
*handle
,
1011 files_struct
*fsp
, const char *mask
, uint32_t attr
)
1015 result
= SMB_VFS_NEXT_FDOPENDIR(handle
, fsp
, mask
, attr
);
1017 do_log(SMB_VFS_OP_FDOPENDIR
, (result
!= NULL
), handle
, "%s",
1018 fsp_str_do_log(fsp
));
1023 static struct dirent
*smb_full_audit_readdir(vfs_handle_struct
*handle
,
1024 DIR *dirp
, SMB_STRUCT_STAT
*sbuf
)
1026 struct dirent
*result
;
1028 result
= SMB_VFS_NEXT_READDIR(handle
, dirp
, sbuf
);
1030 /* This operation has no reasonable error condition
1031 * (End of dir is also failure), so always succeed.
1033 do_log(SMB_VFS_OP_READDIR
, True
, handle
, "");
1038 static void smb_full_audit_seekdir(vfs_handle_struct
*handle
,
1039 DIR *dirp
, long offset
)
1041 SMB_VFS_NEXT_SEEKDIR(handle
, dirp
, offset
);
1043 do_log(SMB_VFS_OP_SEEKDIR
, True
, handle
, "");
1046 static long smb_full_audit_telldir(vfs_handle_struct
*handle
,
1051 result
= SMB_VFS_NEXT_TELLDIR(handle
, dirp
);
1053 do_log(SMB_VFS_OP_TELLDIR
, True
, handle
, "");
1058 static void smb_full_audit_rewinddir(vfs_handle_struct
*handle
,
1061 SMB_VFS_NEXT_REWINDDIR(handle
, dirp
);
1063 do_log(SMB_VFS_OP_REWINDDIR
, True
, handle
, "");
1066 static int smb_full_audit_mkdirat(vfs_handle_struct
*handle
,
1067 struct files_struct
*dirfsp
,
1068 const struct smb_filename
*smb_fname
,
1073 result
= SMB_VFS_NEXT_MKDIRAT(handle
,
1078 do_log(SMB_VFS_OP_MKDIRAT
,
1082 smb_fname_str_do_log(handle
->conn
, smb_fname
));
1087 static int smb_full_audit_closedir(vfs_handle_struct
*handle
,
1092 result
= SMB_VFS_NEXT_CLOSEDIR(handle
, dirp
);
1094 do_log(SMB_VFS_OP_CLOSEDIR
, (result
>= 0), handle
, "");
1099 static int smb_full_audit_open(vfs_handle_struct
*handle
,
1100 struct smb_filename
*smb_fname
,
1101 files_struct
*fsp
, int flags
, mode_t mode
)
1105 result
= SMB_VFS_NEXT_OPEN(handle
, smb_fname
, fsp
, flags
, mode
);
1107 do_log(SMB_VFS_OP_OPEN
, (result
>= 0), handle
, "%s|%s",
1108 ((flags
& O_WRONLY
) || (flags
& O_RDWR
))?"w":"r",
1109 smb_fname_str_do_log(handle
->conn
, smb_fname
));
1114 static NTSTATUS
smb_full_audit_create_file(vfs_handle_struct
*handle
,
1115 struct smb_request
*req
,
1116 uint16_t root_dir_fid
,
1117 struct smb_filename
*smb_fname
,
1118 uint32_t access_mask
,
1119 uint32_t share_access
,
1120 uint32_t create_disposition
,
1121 uint32_t create_options
,
1122 uint32_t file_attributes
,
1123 uint32_t oplock_request
,
1124 const struct smb2_lease
*lease
,
1125 uint64_t allocation_size
,
1126 uint32_t private_flags
,
1127 struct security_descriptor
*sd
,
1128 struct ea_list
*ea_list
,
1129 files_struct
**result_fsp
,
1131 const struct smb2_create_blobs
*in_context_blobs
,
1132 struct smb2_create_blobs
*out_context_blobs
)
1135 const char* str_create_disposition
;
1137 switch (create_disposition
) {
1138 case FILE_SUPERSEDE
:
1139 str_create_disposition
= "supersede";
1141 case FILE_OVERWRITE_IF
:
1142 str_create_disposition
= "overwrite_if";
1145 str_create_disposition
= "open";
1147 case FILE_OVERWRITE
:
1148 str_create_disposition
= "overwrite";
1151 str_create_disposition
= "create";
1154 str_create_disposition
= "open_if";
1157 str_create_disposition
= "unknown";
1160 result
= SMB_VFS_NEXT_CREATE_FILE(
1161 handle
, /* handle */
1163 root_dir_fid
, /* root_dir_fid */
1164 smb_fname
, /* fname */
1165 access_mask
, /* access_mask */
1166 share_access
, /* share_access */
1167 create_disposition
, /* create_disposition*/
1168 create_options
, /* create_options */
1169 file_attributes
, /* file_attributes */
1170 oplock_request
, /* oplock_request */
1172 allocation_size
, /* allocation_size */
1175 ea_list
, /* ea_list */
1176 result_fsp
, /* result */
1178 in_context_blobs
, out_context_blobs
); /* create context */
1180 do_log(SMB_VFS_OP_CREATE_FILE
, (NT_STATUS_IS_OK(result
)), handle
,
1181 "0x%x|%s|%s|%s", access_mask
,
1182 create_options
& FILE_DIRECTORY_FILE
? "dir" : "file",
1183 str_create_disposition
,
1184 smb_fname_str_do_log(handle
->conn
, smb_fname
));
1189 static int smb_full_audit_close(vfs_handle_struct
*handle
, files_struct
*fsp
)
1193 result
= SMB_VFS_NEXT_CLOSE(handle
, fsp
);
1195 do_log(SMB_VFS_OP_CLOSE
, (result
>= 0), handle
, "%s",
1196 fsp_str_do_log(fsp
));
1201 static ssize_t
smb_full_audit_pread(vfs_handle_struct
*handle
, files_struct
*fsp
,
1202 void *data
, size_t n
, off_t offset
)
1206 result
= SMB_VFS_NEXT_PREAD(handle
, fsp
, data
, n
, offset
);
1208 do_log(SMB_VFS_OP_PREAD
, (result
>= 0), handle
, "%s",
1209 fsp_str_do_log(fsp
));
1214 struct smb_full_audit_pread_state
{
1215 vfs_handle_struct
*handle
;
1218 struct vfs_aio_state vfs_aio_state
;
1221 static void smb_full_audit_pread_done(struct tevent_req
*subreq
);
1223 static struct tevent_req
*smb_full_audit_pread_send(
1224 struct vfs_handle_struct
*handle
, TALLOC_CTX
*mem_ctx
,
1225 struct tevent_context
*ev
, struct files_struct
*fsp
,
1226 void *data
, size_t n
, off_t offset
)
1228 struct tevent_req
*req
, *subreq
;
1229 struct smb_full_audit_pread_state
*state
;
1231 req
= tevent_req_create(mem_ctx
, &state
,
1232 struct smb_full_audit_pread_state
);
1234 do_log(SMB_VFS_OP_PREAD_SEND
, false, handle
, "%s",
1235 fsp_str_do_log(fsp
));
1238 state
->handle
= handle
;
1241 subreq
= SMB_VFS_NEXT_PREAD_SEND(state
, ev
, handle
, fsp
, data
,
1243 if (tevent_req_nomem(subreq
, req
)) {
1244 do_log(SMB_VFS_OP_PREAD_SEND
, false, handle
, "%s",
1245 fsp_str_do_log(fsp
));
1246 return tevent_req_post(req
, ev
);
1248 tevent_req_set_callback(subreq
, smb_full_audit_pread_done
, req
);
1250 do_log(SMB_VFS_OP_PREAD_SEND
, true, handle
, "%s", fsp_str_do_log(fsp
));
1254 static void smb_full_audit_pread_done(struct tevent_req
*subreq
)
1256 struct tevent_req
*req
= tevent_req_callback_data(
1257 subreq
, struct tevent_req
);
1258 struct smb_full_audit_pread_state
*state
= tevent_req_data(
1259 req
, struct smb_full_audit_pread_state
);
1261 state
->ret
= SMB_VFS_PREAD_RECV(subreq
, &state
->vfs_aio_state
);
1262 TALLOC_FREE(subreq
);
1263 tevent_req_done(req
);
1266 static ssize_t
smb_full_audit_pread_recv(struct tevent_req
*req
,
1267 struct vfs_aio_state
*vfs_aio_state
)
1269 struct smb_full_audit_pread_state
*state
= tevent_req_data(
1270 req
, struct smb_full_audit_pread_state
);
1272 if (tevent_req_is_unix_error(req
, &vfs_aio_state
->error
)) {
1273 do_log(SMB_VFS_OP_PREAD_RECV
, false, state
->handle
, "%s",
1274 fsp_str_do_log(state
->fsp
));
1278 do_log(SMB_VFS_OP_PREAD_RECV
, (state
->ret
>= 0), state
->handle
, "%s",
1279 fsp_str_do_log(state
->fsp
));
1281 *vfs_aio_state
= state
->vfs_aio_state
;
1285 static ssize_t
smb_full_audit_pwrite(vfs_handle_struct
*handle
, files_struct
*fsp
,
1286 const void *data
, size_t n
,
1291 result
= SMB_VFS_NEXT_PWRITE(handle
, fsp
, data
, n
, offset
);
1293 do_log(SMB_VFS_OP_PWRITE
, (result
>= 0), handle
, "%s",
1294 fsp_str_do_log(fsp
));
1299 struct smb_full_audit_pwrite_state
{
1300 vfs_handle_struct
*handle
;
1303 struct vfs_aio_state vfs_aio_state
;
1306 static void smb_full_audit_pwrite_done(struct tevent_req
*subreq
);
1308 static struct tevent_req
*smb_full_audit_pwrite_send(
1309 struct vfs_handle_struct
*handle
, TALLOC_CTX
*mem_ctx
,
1310 struct tevent_context
*ev
, struct files_struct
*fsp
,
1311 const void *data
, size_t n
, off_t offset
)
1313 struct tevent_req
*req
, *subreq
;
1314 struct smb_full_audit_pwrite_state
*state
;
1316 req
= tevent_req_create(mem_ctx
, &state
,
1317 struct smb_full_audit_pwrite_state
);
1319 do_log(SMB_VFS_OP_PWRITE_SEND
, false, handle
, "%s",
1320 fsp_str_do_log(fsp
));
1323 state
->handle
= handle
;
1326 subreq
= SMB_VFS_NEXT_PWRITE_SEND(state
, ev
, handle
, fsp
, data
,
1328 if (tevent_req_nomem(subreq
, req
)) {
1329 do_log(SMB_VFS_OP_PWRITE_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_pwrite_done
, req
);
1335 do_log(SMB_VFS_OP_PWRITE_SEND
, true, handle
, "%s",
1336 fsp_str_do_log(fsp
));
1340 static void smb_full_audit_pwrite_done(struct tevent_req
*subreq
)
1342 struct tevent_req
*req
= tevent_req_callback_data(
1343 subreq
, struct tevent_req
);
1344 struct smb_full_audit_pwrite_state
*state
= tevent_req_data(
1345 req
, struct smb_full_audit_pwrite_state
);
1347 state
->ret
= SMB_VFS_PWRITE_RECV(subreq
, &state
->vfs_aio_state
);
1348 TALLOC_FREE(subreq
);
1349 tevent_req_done(req
);
1352 static ssize_t
smb_full_audit_pwrite_recv(struct tevent_req
*req
,
1353 struct vfs_aio_state
*vfs_aio_state
)
1355 struct smb_full_audit_pwrite_state
*state
= tevent_req_data(
1356 req
, struct smb_full_audit_pwrite_state
);
1358 if (tevent_req_is_unix_error(req
, &vfs_aio_state
->error
)) {
1359 do_log(SMB_VFS_OP_PWRITE_RECV
, false, state
->handle
, "%s",
1360 fsp_str_do_log(state
->fsp
));
1364 do_log(SMB_VFS_OP_PWRITE_RECV
, (state
->ret
>= 0), state
->handle
, "%s",
1365 fsp_str_do_log(state
->fsp
));
1367 *vfs_aio_state
= state
->vfs_aio_state
;
1371 static off_t
smb_full_audit_lseek(vfs_handle_struct
*handle
, files_struct
*fsp
,
1372 off_t offset
, int whence
)
1376 result
= SMB_VFS_NEXT_LSEEK(handle
, fsp
, offset
, whence
);
1378 do_log(SMB_VFS_OP_LSEEK
, (result
!= (ssize_t
)-1), handle
,
1379 "%s", fsp_str_do_log(fsp
));
1384 static ssize_t
smb_full_audit_sendfile(vfs_handle_struct
*handle
, int tofd
,
1385 files_struct
*fromfsp
,
1386 const DATA_BLOB
*hdr
, off_t offset
,
1391 result
= SMB_VFS_NEXT_SENDFILE(handle
, tofd
, fromfsp
, hdr
, offset
, n
);
1393 do_log(SMB_VFS_OP_SENDFILE
, (result
>= 0), handle
,
1394 "%s", fsp_str_do_log(fromfsp
));
1399 static ssize_t
smb_full_audit_recvfile(vfs_handle_struct
*handle
, int fromfd
,
1400 files_struct
*tofsp
,
1406 result
= SMB_VFS_NEXT_RECVFILE(handle
, fromfd
, tofsp
, offset
, n
);
1408 do_log(SMB_VFS_OP_RECVFILE
, (result
>= 0), handle
,
1409 "%s", fsp_str_do_log(tofsp
));
1414 static int smb_full_audit_renameat(vfs_handle_struct
*handle
,
1415 files_struct
*srcfsp
,
1416 const struct smb_filename
*smb_fname_src
,
1417 files_struct
*dstfsp
,
1418 const struct smb_filename
*smb_fname_dst
)
1422 result
= SMB_VFS_NEXT_RENAMEAT(handle
,
1428 do_log(SMB_VFS_OP_RENAMEAT
, (result
>= 0), handle
, "%s|%s",
1429 smb_fname_str_do_log(handle
->conn
, smb_fname_src
),
1430 smb_fname_str_do_log(handle
->conn
, smb_fname_dst
));
1435 struct smb_full_audit_fsync_state
{
1436 vfs_handle_struct
*handle
;
1439 struct vfs_aio_state vfs_aio_state
;
1442 static void smb_full_audit_fsync_done(struct tevent_req
*subreq
);
1444 static struct tevent_req
*smb_full_audit_fsync_send(
1445 struct vfs_handle_struct
*handle
, TALLOC_CTX
*mem_ctx
,
1446 struct tevent_context
*ev
, struct files_struct
*fsp
)
1448 struct tevent_req
*req
, *subreq
;
1449 struct smb_full_audit_fsync_state
*state
;
1451 req
= tevent_req_create(mem_ctx
, &state
,
1452 struct smb_full_audit_fsync_state
);
1454 do_log(SMB_VFS_OP_FSYNC_SEND
, false, handle
, "%s",
1455 fsp_str_do_log(fsp
));
1458 state
->handle
= handle
;
1461 subreq
= SMB_VFS_NEXT_FSYNC_SEND(state
, ev
, handle
, fsp
);
1462 if (tevent_req_nomem(subreq
, req
)) {
1463 do_log(SMB_VFS_OP_FSYNC_SEND
, false, handle
, "%s",
1464 fsp_str_do_log(fsp
));
1465 return tevent_req_post(req
, ev
);
1467 tevent_req_set_callback(subreq
, smb_full_audit_fsync_done
, req
);
1469 do_log(SMB_VFS_OP_FSYNC_SEND
, true, handle
, "%s", fsp_str_do_log(fsp
));
1473 static void smb_full_audit_fsync_done(struct tevent_req
*subreq
)
1475 struct tevent_req
*req
= tevent_req_callback_data(
1476 subreq
, struct tevent_req
);
1477 struct smb_full_audit_fsync_state
*state
= tevent_req_data(
1478 req
, struct smb_full_audit_fsync_state
);
1480 state
->ret
= SMB_VFS_FSYNC_RECV(subreq
, &state
->vfs_aio_state
);
1481 TALLOC_FREE(subreq
);
1482 tevent_req_done(req
);
1485 static int smb_full_audit_fsync_recv(struct tevent_req
*req
,
1486 struct vfs_aio_state
*vfs_aio_state
)
1488 struct smb_full_audit_fsync_state
*state
= tevent_req_data(
1489 req
, struct smb_full_audit_fsync_state
);
1491 if (tevent_req_is_unix_error(req
, &vfs_aio_state
->error
)) {
1492 do_log(SMB_VFS_OP_FSYNC_RECV
, false, state
->handle
, "%s",
1493 fsp_str_do_log(state
->fsp
));
1497 do_log(SMB_VFS_OP_FSYNC_RECV
, (state
->ret
>= 0), state
->handle
, "%s",
1498 fsp_str_do_log(state
->fsp
));
1500 *vfs_aio_state
= state
->vfs_aio_state
;
1504 static int smb_full_audit_stat(vfs_handle_struct
*handle
,
1505 struct smb_filename
*smb_fname
)
1509 result
= SMB_VFS_NEXT_STAT(handle
, smb_fname
);
1511 do_log(SMB_VFS_OP_STAT
, (result
>= 0), handle
, "%s",
1512 smb_fname_str_do_log(handle
->conn
, smb_fname
));
1517 static int smb_full_audit_fstat(vfs_handle_struct
*handle
, files_struct
*fsp
,
1518 SMB_STRUCT_STAT
*sbuf
)
1522 result
= SMB_VFS_NEXT_FSTAT(handle
, fsp
, sbuf
);
1524 do_log(SMB_VFS_OP_FSTAT
, (result
>= 0), handle
, "%s",
1525 fsp_str_do_log(fsp
));
1530 static int smb_full_audit_lstat(vfs_handle_struct
*handle
,
1531 struct smb_filename
*smb_fname
)
1535 result
= SMB_VFS_NEXT_LSTAT(handle
, smb_fname
);
1537 do_log(SMB_VFS_OP_LSTAT
, (result
>= 0), handle
, "%s",
1538 smb_fname_str_do_log(handle
->conn
, smb_fname
));
1543 static uint64_t smb_full_audit_get_alloc_size(vfs_handle_struct
*handle
,
1544 files_struct
*fsp
, const SMB_STRUCT_STAT
*sbuf
)
1548 result
= SMB_VFS_NEXT_GET_ALLOC_SIZE(handle
, fsp
, sbuf
);
1550 do_log(SMB_VFS_OP_GET_ALLOC_SIZE
, (result
!= (uint64_t)-1), handle
,
1551 "%llu", (unsigned long long)result
);
1556 static int smb_full_audit_unlinkat(vfs_handle_struct
*handle
,
1557 struct files_struct
*dirfsp
,
1558 const struct smb_filename
*smb_fname
,
1563 result
= SMB_VFS_NEXT_UNLINKAT(handle
,
1568 do_log(SMB_VFS_OP_UNLINKAT
, (result
>= 0), handle
, "%s",
1569 smb_fname_str_do_log(handle
->conn
, smb_fname
));
1574 static int smb_full_audit_chmod(vfs_handle_struct
*handle
,
1575 const struct smb_filename
*smb_fname
,
1580 result
= SMB_VFS_NEXT_CHMOD(handle
, smb_fname
, mode
);
1582 do_log(SMB_VFS_OP_CHMOD
,
1586 smb_fname_str_do_log(handle
->conn
, smb_fname
),
1592 static int smb_full_audit_fchmod(vfs_handle_struct
*handle
, files_struct
*fsp
,
1597 result
= SMB_VFS_NEXT_FCHMOD(handle
, fsp
, mode
);
1599 do_log(SMB_VFS_OP_FCHMOD
, (result
>= 0), handle
,
1600 "%s|%o", fsp_str_do_log(fsp
), mode
);
1605 static int smb_full_audit_fchown(vfs_handle_struct
*handle
, files_struct
*fsp
,
1606 uid_t uid
, gid_t gid
)
1610 result
= SMB_VFS_NEXT_FCHOWN(handle
, fsp
, uid
, gid
);
1612 do_log(SMB_VFS_OP_FCHOWN
, (result
>= 0), handle
, "%s|%ld|%ld",
1613 fsp_str_do_log(fsp
), (long int)uid
, (long int)gid
);
1618 static int smb_full_audit_lchown(vfs_handle_struct
*handle
,
1619 const struct smb_filename
*smb_fname
,
1625 result
= SMB_VFS_NEXT_LCHOWN(handle
, smb_fname
, uid
, gid
);
1627 do_log(SMB_VFS_OP_LCHOWN
, (result
>= 0), handle
, "%s|%ld|%ld",
1628 smb_fname
->base_name
, (long int)uid
, (long int)gid
);
1633 static int smb_full_audit_chdir(vfs_handle_struct
*handle
,
1634 const struct smb_filename
*smb_fname
)
1638 result
= SMB_VFS_NEXT_CHDIR(handle
, smb_fname
);
1640 do_log(SMB_VFS_OP_CHDIR
,
1644 smb_fname_str_do_log(handle
->conn
, smb_fname
));
1649 static struct smb_filename
*smb_full_audit_getwd(vfs_handle_struct
*handle
,
1652 struct smb_filename
*result
;
1654 result
= SMB_VFS_NEXT_GETWD(handle
, ctx
);
1656 do_log(SMB_VFS_OP_GETWD
, (result
!= NULL
), handle
, "%s",
1657 result
== NULL
? "" : result
->base_name
);
1662 static int smb_full_audit_ntimes(vfs_handle_struct
*handle
,
1663 const struct smb_filename
*smb_fname
,
1664 struct smb_file_time
*ft
)
1667 time_t create_time
= convert_timespec_to_time_t(ft
->create_time
);
1668 time_t atime
= convert_timespec_to_time_t(ft
->atime
);
1669 time_t mtime
= convert_timespec_to_time_t(ft
->mtime
);
1670 time_t ctime
= convert_timespec_to_time_t(ft
->ctime
);
1671 const char *create_time_str
= "";
1672 const char *atime_str
= "";
1673 const char *mtime_str
= "";
1674 const char *ctime_str
= "";
1675 TALLOC_CTX
*frame
= talloc_stackframe();
1677 result
= SMB_VFS_NEXT_NTIMES(handle
, smb_fname
, ft
);
1679 if (create_time
> 0) {
1680 create_time_str
= timestring(frame
, create_time
);
1683 atime_str
= timestring(frame
, atime
);
1686 mtime_str
= timestring(frame
, mtime
);
1689 ctime_str
= timestring(frame
, ctime
);
1692 do_log(SMB_VFS_OP_NTIMES
,
1696 smb_fname_str_do_log(handle
->conn
, smb_fname
),
1707 static int smb_full_audit_ftruncate(vfs_handle_struct
*handle
, files_struct
*fsp
,
1712 result
= SMB_VFS_NEXT_FTRUNCATE(handle
, fsp
, len
);
1714 do_log(SMB_VFS_OP_FTRUNCATE
, (result
>= 0), handle
,
1715 "%s", fsp_str_do_log(fsp
));
1720 static int smb_full_audit_fallocate(vfs_handle_struct
*handle
, files_struct
*fsp
,
1727 result
= SMB_VFS_NEXT_FALLOCATE(handle
, fsp
, mode
, offset
, len
);
1729 do_log(SMB_VFS_OP_FALLOCATE
, (result
>= 0), handle
,
1730 "%s", fsp_str_do_log(fsp
));
1735 static bool smb_full_audit_lock(vfs_handle_struct
*handle
, files_struct
*fsp
,
1736 int op
, off_t offset
, off_t count
, int type
)
1740 result
= SMB_VFS_NEXT_LOCK(handle
, fsp
, op
, offset
, count
, type
);
1742 do_log(SMB_VFS_OP_LOCK
, result
, handle
, "%s", fsp_str_do_log(fsp
));
1747 static int smb_full_audit_kernel_flock(struct vfs_handle_struct
*handle
,
1748 struct files_struct
*fsp
,
1749 uint32_t share_access
,
1750 uint32_t access_mask
)
1754 result
= SMB_VFS_NEXT_KERNEL_FLOCK(handle
,
1759 do_log(SMB_VFS_OP_KERNEL_FLOCK
, (result
>= 0), handle
, "%s",
1760 fsp_str_do_log(fsp
));
1765 static int smb_full_audit_fcntl(struct vfs_handle_struct
*handle
,
1766 struct files_struct
*fsp
,
1767 int cmd
, va_list cmd_arg
)
1770 va_list dup_cmd_arg
;
1773 va_copy(dup_cmd_arg
, cmd_arg
);
1774 arg
= va_arg(dup_cmd_arg
, void *);
1775 result
= SMB_VFS_NEXT_FCNTL(handle
, fsp
, cmd
, arg
);
1776 va_end(dup_cmd_arg
);
1778 do_log(SMB_VFS_OP_FCNTL
, (result
>= 0), handle
, "%s",
1779 fsp_str_do_log(fsp
));
1784 static int smb_full_audit_linux_setlease(vfs_handle_struct
*handle
, files_struct
*fsp
,
1789 result
= SMB_VFS_NEXT_LINUX_SETLEASE(handle
, fsp
, leasetype
);
1791 do_log(SMB_VFS_OP_LINUX_SETLEASE
, (result
>= 0), handle
, "%s",
1792 fsp_str_do_log(fsp
));
1797 static bool smb_full_audit_getlock(vfs_handle_struct
*handle
, files_struct
*fsp
,
1798 off_t
*poffset
, off_t
*pcount
, int *ptype
, pid_t
*ppid
)
1802 result
= SMB_VFS_NEXT_GETLOCK(handle
, fsp
, poffset
, pcount
, ptype
, ppid
);
1804 do_log(SMB_VFS_OP_GETLOCK
, result
, handle
, "%s", fsp_str_do_log(fsp
));
1809 static int smb_full_audit_symlinkat(vfs_handle_struct
*handle
,
1810 const char *link_contents
,
1811 struct files_struct
*dirfsp
,
1812 const struct smb_filename
*new_smb_fname
)
1816 result
= SMB_VFS_NEXT_SYMLINKAT(handle
,
1821 do_log(SMB_VFS_OP_SYMLINKAT
,
1826 smb_fname_str_do_log(handle
->conn
, new_smb_fname
));
1831 static int smb_full_audit_readlinkat(vfs_handle_struct
*handle
,
1832 files_struct
*dirfsp
,
1833 const struct smb_filename
*smb_fname
,
1839 result
= SMB_VFS_NEXT_READLINKAT(handle
,
1845 do_log(SMB_VFS_OP_READLINKAT
,
1849 smb_fname_str_do_log(handle
->conn
, smb_fname
));
1854 static int smb_full_audit_linkat(vfs_handle_struct
*handle
,
1855 files_struct
*srcfsp
,
1856 const struct smb_filename
*old_smb_fname
,
1857 files_struct
*dstfsp
,
1858 const struct smb_filename
*new_smb_fname
,
1863 result
= SMB_VFS_NEXT_LINKAT(handle
,
1870 do_log(SMB_VFS_OP_LINKAT
,
1874 smb_fname_str_do_log(handle
->conn
, old_smb_fname
),
1875 smb_fname_str_do_log(handle
->conn
, new_smb_fname
));
1880 static int smb_full_audit_mknodat(vfs_handle_struct
*handle
,
1881 files_struct
*dirfsp
,
1882 const struct smb_filename
*smb_fname
,
1888 result
= SMB_VFS_NEXT_MKNODAT(handle
,
1894 do_log(SMB_VFS_OP_MKNODAT
,
1898 smb_fname_str_do_log(handle
->conn
, smb_fname
));
1903 static struct smb_filename
*smb_full_audit_realpath(vfs_handle_struct
*handle
,
1905 const struct smb_filename
*smb_fname
)
1907 struct smb_filename
*result_fname
= NULL
;
1909 result_fname
= SMB_VFS_NEXT_REALPATH(handle
, ctx
, smb_fname
);
1911 do_log(SMB_VFS_OP_REALPATH
,
1912 (result_fname
!= NULL
),
1915 smb_fname_str_do_log(handle
->conn
, smb_fname
));
1917 return result_fname
;
1920 static int smb_full_audit_chflags(vfs_handle_struct
*handle
,
1921 const struct smb_filename
*smb_fname
,
1926 result
= SMB_VFS_NEXT_CHFLAGS(handle
, smb_fname
, flags
);
1928 do_log(SMB_VFS_OP_CHFLAGS
,
1932 smb_fname_str_do_log(handle
->conn
, smb_fname
));
1937 static struct file_id
smb_full_audit_file_id_create(struct vfs_handle_struct
*handle
,
1938 const SMB_STRUCT_STAT
*sbuf
)
1940 struct file_id id_zero
= { 0 };
1941 struct file_id result
;
1942 struct file_id_buf idbuf
;
1944 result
= SMB_VFS_NEXT_FILE_ID_CREATE(handle
, sbuf
);
1946 do_log(SMB_VFS_OP_FILE_ID_CREATE
,
1947 !file_id_equal(&id_zero
, &result
),
1950 file_id_str_buf(result
, &idbuf
));
1955 static uint64_t smb_full_audit_fs_file_id(struct vfs_handle_struct
*handle
,
1956 const SMB_STRUCT_STAT
*sbuf
)
1960 result
= SMB_VFS_NEXT_FS_FILE_ID(handle
, sbuf
);
1962 do_log(SMB_VFS_OP_FS_FILE_ID
,
1964 handle
, "%" PRIu64
, result
);
1969 static NTSTATUS
smb_full_audit_streaminfo(vfs_handle_struct
*handle
,
1970 struct files_struct
*fsp
,
1971 const struct smb_filename
*smb_fname
,
1972 TALLOC_CTX
*mem_ctx
,
1973 unsigned int *pnum_streams
,
1974 struct stream_struct
**pstreams
)
1978 result
= SMB_VFS_NEXT_STREAMINFO(handle
, fsp
, smb_fname
, mem_ctx
,
1979 pnum_streams
, pstreams
);
1981 do_log(SMB_VFS_OP_STREAMINFO
,
1982 NT_STATUS_IS_OK(result
),
1985 smb_fname_str_do_log(handle
->conn
, smb_fname
));
1990 static int smb_full_audit_get_real_filename(struct vfs_handle_struct
*handle
,
1993 TALLOC_CTX
*mem_ctx
,
1998 result
= SMB_VFS_NEXT_GET_REAL_FILENAME(handle
, path
, name
, mem_ctx
,
2001 do_log(SMB_VFS_OP_GET_REAL_FILENAME
, (result
== 0), handle
,
2002 "%s/%s->%s", path
, name
, (result
== 0) ? *found_name
: "");
2007 static const char *smb_full_audit_connectpath(vfs_handle_struct
*handle
,
2008 const struct smb_filename
*smb_fname
)
2012 result
= SMB_VFS_NEXT_CONNECTPATH(handle
, smb_fname
);
2014 do_log(SMB_VFS_OP_CONNECTPATH
,
2018 smb_fname_str_do_log(handle
->conn
, smb_fname
));
2023 static NTSTATUS
smb_full_audit_brl_lock_windows(struct vfs_handle_struct
*handle
,
2024 struct byte_range_lock
*br_lck
,
2025 struct lock_struct
*plock
)
2029 result
= SMB_VFS_NEXT_BRL_LOCK_WINDOWS(handle
, br_lck
, plock
);
2031 do_log(SMB_VFS_OP_BRL_LOCK_WINDOWS
, NT_STATUS_IS_OK(result
), handle
,
2032 "%s:%llu-%llu. type=%d.",
2033 fsp_str_do_log(brl_fsp(br_lck
)),
2034 (unsigned long long)plock
->start
,
2035 (unsigned long long)plock
->size
,
2041 static bool smb_full_audit_brl_unlock_windows(struct vfs_handle_struct
*handle
,
2042 struct byte_range_lock
*br_lck
,
2043 const struct lock_struct
*plock
)
2047 result
= SMB_VFS_NEXT_BRL_UNLOCK_WINDOWS(handle
, br_lck
, plock
);
2049 do_log(SMB_VFS_OP_BRL_UNLOCK_WINDOWS
, (result
== 0), handle
,
2050 "%s:%llu-%llu:%d", fsp_str_do_log(brl_fsp(br_lck
)),
2051 (unsigned long long)plock
->start
,
2052 (unsigned long long)plock
->size
,
2058 static bool smb_full_audit_strict_lock_check(struct vfs_handle_struct
*handle
,
2059 struct files_struct
*fsp
,
2060 struct lock_struct
*plock
)
2064 result
= SMB_VFS_NEXT_STRICT_LOCK_CHECK(handle
, fsp
, plock
);
2066 do_log(SMB_VFS_OP_STRICT_LOCK_CHECK
, result
, handle
,
2067 "%s:%llu-%llu:%d", fsp_str_do_log(fsp
),
2068 (unsigned long long)plock
->start
,
2069 (unsigned long long)plock
->size
,
2075 static NTSTATUS
smb_full_audit_translate_name(struct vfs_handle_struct
*handle
,
2077 enum vfs_translate_direction direction
,
2078 TALLOC_CTX
*mem_ctx
,
2083 result
= SMB_VFS_NEXT_TRANSLATE_NAME(handle
, name
, direction
, mem_ctx
,
2086 do_log(SMB_VFS_OP_TRANSLATE_NAME
, NT_STATUS_IS_OK(result
), handle
, "");
2091 static NTSTATUS
smb_full_audit_fsctl(struct vfs_handle_struct
*handle
,
2092 struct files_struct
*fsp
,
2096 const uint8_t *_in_data
,
2098 uint8_t **_out_data
,
2099 uint32_t max_out_len
,
2104 result
= SMB_VFS_NEXT_FSCTL(handle
,
2115 do_log(SMB_VFS_OP_FSCTL
, NT_STATUS_IS_OK(result
), handle
, "");
2120 static struct tevent_req
*smb_full_audit_offload_read_send(
2121 TALLOC_CTX
*mem_ctx
,
2122 struct tevent_context
*ev
,
2123 struct vfs_handle_struct
*handle
,
2124 struct files_struct
*fsp
,
2130 struct tevent_req
*req
= NULL
;
2132 req
= SMB_VFS_NEXT_OFFLOAD_READ_SEND(mem_ctx
, ev
, handle
, fsp
,
2133 fsctl
, ttl
, offset
, to_copy
);
2135 do_log(SMB_VFS_OP_OFFLOAD_READ_SEND
, req
, handle
, "");
2140 static NTSTATUS
smb_full_audit_offload_read_recv(
2141 struct tevent_req
*req
,
2142 struct vfs_handle_struct
*handle
,
2143 TALLOC_CTX
*mem_ctx
,
2144 DATA_BLOB
*_token_blob
)
2148 status
= SMB_VFS_NEXT_OFFLOAD_READ_RECV(req
, handle
, mem_ctx
,
2151 do_log(SMB_VFS_OP_OFFLOAD_READ_RECV
, NT_STATUS_IS_OK(status
), handle
, "");
2156 static struct tevent_req
*smb_full_audit_offload_write_send(struct vfs_handle_struct
*handle
,
2157 TALLOC_CTX
*mem_ctx
,
2158 struct tevent_context
*ev
,
2161 off_t transfer_offset
,
2162 struct files_struct
*dest_fsp
,
2166 struct tevent_req
*req
;
2168 req
= SMB_VFS_NEXT_OFFLOAD_WRITE_SEND(handle
, mem_ctx
, ev
,
2169 fsctl
, token
, transfer_offset
,
2170 dest_fsp
, dest_off
, num
);
2172 do_log(SMB_VFS_OP_OFFLOAD_WRITE_SEND
, req
, handle
, "");
2177 static NTSTATUS
smb_full_audit_offload_write_recv(struct vfs_handle_struct
*handle
,
2178 struct tevent_req
*req
,
2183 result
= SMB_VFS_NEXT_OFFLOAD_WRITE_RECV(handle
, req
, copied
);
2185 do_log(SMB_VFS_OP_OFFLOAD_WRITE_RECV
, NT_STATUS_IS_OK(result
), handle
, "");
2190 static NTSTATUS
smb_full_audit_get_compression(vfs_handle_struct
*handle
,
2191 TALLOC_CTX
*mem_ctx
,
2192 struct files_struct
*fsp
,
2193 struct smb_filename
*smb_fname
,
2194 uint16_t *_compression_fmt
)
2198 result
= SMB_VFS_NEXT_GET_COMPRESSION(handle
, mem_ctx
, fsp
, smb_fname
,
2201 do_log(SMB_VFS_OP_GET_COMPRESSION
, NT_STATUS_IS_OK(result
), handle
,
2203 (fsp
? fsp_str_do_log(fsp
) :
2204 smb_fname_str_do_log(handle
->conn
, smb_fname
)));
2209 static NTSTATUS
smb_full_audit_set_compression(vfs_handle_struct
*handle
,
2210 TALLOC_CTX
*mem_ctx
,
2211 struct files_struct
*fsp
,
2212 uint16_t compression_fmt
)
2216 result
= SMB_VFS_NEXT_SET_COMPRESSION(handle
, mem_ctx
, fsp
,
2219 do_log(SMB_VFS_OP_SET_COMPRESSION
, NT_STATUS_IS_OK(result
), handle
,
2220 "%s", fsp_str_do_log(fsp
));
2225 static NTSTATUS
smb_full_audit_readdir_attr(struct vfs_handle_struct
*handle
,
2226 const struct smb_filename
*fname
,
2227 TALLOC_CTX
*mem_ctx
,
2228 struct readdir_attr_data
**pattr_data
)
2232 status
= SMB_VFS_NEXT_READDIR_ATTR(handle
, fname
, mem_ctx
, pattr_data
);
2234 do_log(SMB_VFS_OP_READDIR_ATTR
, NT_STATUS_IS_OK(status
), handle
, "%s",
2235 smb_fname_str_do_log(handle
->conn
, fname
));
2240 static NTSTATUS
smb_full_audit_get_dos_attributes(
2241 struct vfs_handle_struct
*handle
,
2242 struct smb_filename
*smb_fname
,
2247 status
= SMB_VFS_NEXT_GET_DOS_ATTRIBUTES(handle
,
2251 do_log(SMB_VFS_OP_GET_DOS_ATTRIBUTES
,
2252 NT_STATUS_IS_OK(status
),
2255 smb_fname_str_do_log(handle
->conn
, smb_fname
));
2260 struct smb_full_audit_get_dos_attributes_state
{
2261 struct vfs_aio_state aio_state
;
2262 vfs_handle_struct
*handle
;
2263 files_struct
*dir_fsp
;
2264 const struct smb_filename
*smb_fname
;
2268 static void smb_full_audit_get_dos_attributes_done(struct tevent_req
*subreq
);
2270 static struct tevent_req
*smb_full_audit_get_dos_attributes_send(
2271 TALLOC_CTX
*mem_ctx
,
2272 struct tevent_context
*ev
,
2273 struct vfs_handle_struct
*handle
,
2274 files_struct
*dir_fsp
,
2275 struct smb_filename
*smb_fname
)
2277 struct tevent_req
*req
= NULL
;
2278 struct smb_full_audit_get_dos_attributes_state
*state
= NULL
;
2279 struct tevent_req
*subreq
= NULL
;
2281 req
= tevent_req_create(mem_ctx
, &state
,
2282 struct smb_full_audit_get_dos_attributes_state
);
2284 do_log(SMB_VFS_OP_GET_DOS_ATTRIBUTES_SEND
,
2288 fsp_str_do_log(dir_fsp
),
2289 smb_fname
->base_name
);
2292 *state
= (struct smb_full_audit_get_dos_attributes_state
) {
2295 .smb_fname
= smb_fname
,
2298 subreq
= SMB_VFS_NEXT_GET_DOS_ATTRIBUTES_SEND(mem_ctx
,
2303 if (tevent_req_nomem(subreq
, req
)) {
2304 do_log(SMB_VFS_OP_GET_DOS_ATTRIBUTES_SEND
,
2308 fsp_str_do_log(dir_fsp
),
2309 smb_fname
->base_name
);
2310 return tevent_req_post(req
, ev
);
2312 tevent_req_set_callback(subreq
,
2313 smb_full_audit_get_dos_attributes_done
,
2316 do_log(SMB_VFS_OP_GET_DOS_ATTRIBUTES_SEND
,
2320 fsp_str_do_log(dir_fsp
),
2321 smb_fname
->base_name
);
2326 static void smb_full_audit_get_dos_attributes_done(struct tevent_req
*subreq
)
2328 struct tevent_req
*req
=
2329 tevent_req_callback_data(subreq
,
2331 struct smb_full_audit_get_dos_attributes_state
*state
=
2332 tevent_req_data(req
,
2333 struct smb_full_audit_get_dos_attributes_state
);
2336 status
= SMB_VFS_NEXT_GET_DOS_ATTRIBUTES_RECV(subreq
,
2339 TALLOC_FREE(subreq
);
2340 if (tevent_req_nterror(req
, status
)) {
2344 tevent_req_done(req
);
2348 static NTSTATUS
smb_full_audit_get_dos_attributes_recv(struct tevent_req
*req
,
2349 struct vfs_aio_state
*aio_state
,
2352 struct smb_full_audit_get_dos_attributes_state
*state
=
2353 tevent_req_data(req
,
2354 struct smb_full_audit_get_dos_attributes_state
);
2357 if (tevent_req_is_nterror(req
, &status
)) {
2358 do_log(SMB_VFS_OP_GET_DOS_ATTRIBUTES_RECV
,
2362 fsp_str_do_log(state
->dir_fsp
),
2363 state
->smb_fname
->base_name
);
2364 tevent_req_received(req
);
2368 do_log(SMB_VFS_OP_GET_DOS_ATTRIBUTES_RECV
,
2372 fsp_str_do_log(state
->dir_fsp
),
2373 state
->smb_fname
->base_name
);
2375 *aio_state
= state
->aio_state
;
2376 *dosmode
= state
->dosmode
;
2377 tevent_req_received(req
);
2378 return NT_STATUS_OK
;
2381 static NTSTATUS
smb_full_audit_fget_dos_attributes(
2382 struct vfs_handle_struct
*handle
,
2383 struct files_struct
*fsp
,
2388 status
= SMB_VFS_NEXT_FGET_DOS_ATTRIBUTES(handle
,
2392 do_log(SMB_VFS_OP_FGET_DOS_ATTRIBUTES
,
2393 NT_STATUS_IS_OK(status
),
2396 fsp_str_do_log(fsp
));
2401 static NTSTATUS
smb_full_audit_set_dos_attributes(
2402 struct vfs_handle_struct
*handle
,
2403 const struct smb_filename
*smb_fname
,
2408 status
= SMB_VFS_NEXT_SET_DOS_ATTRIBUTES(handle
,
2412 do_log(SMB_VFS_OP_SET_DOS_ATTRIBUTES
,
2413 NT_STATUS_IS_OK(status
),
2416 smb_fname_str_do_log(handle
->conn
, smb_fname
));
2421 static NTSTATUS
smb_full_audit_fset_dos_attributes(
2422 struct vfs_handle_struct
*handle
,
2423 struct files_struct
*fsp
,
2428 status
= SMB_VFS_NEXT_FSET_DOS_ATTRIBUTES(handle
,
2432 do_log(SMB_VFS_OP_FSET_DOS_ATTRIBUTES
,
2433 NT_STATUS_IS_OK(status
),
2436 fsp_str_do_log(fsp
));
2441 static NTSTATUS
smb_full_audit_fget_nt_acl(vfs_handle_struct
*handle
, files_struct
*fsp
,
2442 uint32_t security_info
,
2443 TALLOC_CTX
*mem_ctx
,
2444 struct security_descriptor
**ppdesc
)
2448 result
= SMB_VFS_NEXT_FGET_NT_ACL(handle
, fsp
, security_info
,
2451 do_log(SMB_VFS_OP_FGET_NT_ACL
, NT_STATUS_IS_OK(result
), handle
,
2452 "%s", fsp_str_do_log(fsp
));
2457 static NTSTATUS
smb_full_audit_get_nt_acl(vfs_handle_struct
*handle
,
2458 const struct smb_filename
*smb_fname
,
2459 uint32_t security_info
,
2460 TALLOC_CTX
*mem_ctx
,
2461 struct security_descriptor
**ppdesc
)
2465 result
= SMB_VFS_NEXT_GET_NT_ACL(handle
, smb_fname
, security_info
,
2468 do_log(SMB_VFS_OP_GET_NT_ACL
, NT_STATUS_IS_OK(result
), handle
,
2469 "%s", smb_fname_str_do_log(handle
->conn
, smb_fname
));
2474 static NTSTATUS
smb_full_audit_fset_nt_acl(vfs_handle_struct
*handle
, files_struct
*fsp
,
2475 uint32_t security_info_sent
,
2476 const struct security_descriptor
*psd
)
2478 struct vfs_full_audit_private_data
*pd
;
2482 SMB_VFS_HANDLE_GET_DATA(handle
, pd
,
2483 struct vfs_full_audit_private_data
,
2484 return NT_STATUS_INTERNAL_ERROR
);
2486 if (pd
->log_secdesc
) {
2487 sd
= sddl_encode(talloc_tos(), psd
, get_global_sam_sid());
2490 result
= SMB_VFS_NEXT_FSET_NT_ACL(handle
, fsp
, security_info_sent
, psd
);
2492 do_log(SMB_VFS_OP_FSET_NT_ACL
, NT_STATUS_IS_OK(result
), handle
,
2493 "%s [%s]", fsp_str_do_log(fsp
), sd
? sd
: "");
2500 static NTSTATUS
smb_full_audit_audit_file(struct vfs_handle_struct
*handle
,
2501 struct smb_filename
*file
,
2502 struct security_acl
*sacl
,
2503 uint32_t access_requested
,
2504 uint32_t access_denied
)
2508 result
= SMB_VFS_NEXT_AUDIT_FILE(handle
,
2514 do_log(SMB_VFS_OP_AUDIT_FILE
, NT_STATUS_IS_OK(result
), handle
,
2516 smb_fname_str_do_log(handle
->conn
, file
));
2521 static SMB_ACL_T
smb_full_audit_sys_acl_get_file(vfs_handle_struct
*handle
,
2522 const struct smb_filename
*smb_fname
,
2523 SMB_ACL_TYPE_T type
,
2524 TALLOC_CTX
*mem_ctx
)
2528 result
= SMB_VFS_NEXT_SYS_ACL_GET_FILE(handle
, smb_fname
,
2531 do_log(SMB_VFS_OP_SYS_ACL_GET_FILE
,
2535 smb_fname_str_do_log(handle
->conn
, smb_fname
));
2540 static SMB_ACL_T
smb_full_audit_sys_acl_get_fd(vfs_handle_struct
*handle
,
2541 files_struct
*fsp
, TALLOC_CTX
*mem_ctx
)
2545 result
= SMB_VFS_NEXT_SYS_ACL_GET_FD(handle
, fsp
, mem_ctx
);
2547 do_log(SMB_VFS_OP_SYS_ACL_GET_FD
, (result
!= NULL
), handle
,
2548 "%s", fsp_str_do_log(fsp
));
2553 static int smb_full_audit_sys_acl_blob_get_file(vfs_handle_struct
*handle
,
2554 const struct smb_filename
*smb_fname
,
2555 TALLOC_CTX
*mem_ctx
,
2556 char **blob_description
,
2561 result
= SMB_VFS_NEXT_SYS_ACL_BLOB_GET_FILE(handle
, smb_fname
,
2562 mem_ctx
, blob_description
, blob
);
2564 do_log(SMB_VFS_OP_SYS_ACL_BLOB_GET_FILE
,
2568 smb_fname_str_do_log(handle
->conn
, smb_fname
));
2573 static int smb_full_audit_sys_acl_blob_get_fd(vfs_handle_struct
*handle
,
2575 TALLOC_CTX
*mem_ctx
,
2576 char **blob_description
,
2581 result
= SMB_VFS_NEXT_SYS_ACL_BLOB_GET_FD(handle
, fsp
, mem_ctx
, blob_description
, blob
);
2583 do_log(SMB_VFS_OP_SYS_ACL_BLOB_GET_FD
, (result
>= 0), handle
,
2584 "%s", fsp_str_do_log(fsp
));
2589 static int smb_full_audit_sys_acl_set_file(vfs_handle_struct
*handle
,
2590 const struct smb_filename
*smb_fname
,
2591 SMB_ACL_TYPE_T acltype
,
2596 result
= SMB_VFS_NEXT_SYS_ACL_SET_FILE(handle
, smb_fname
, acltype
,
2599 do_log(SMB_VFS_OP_SYS_ACL_SET_FILE
,
2603 smb_fname_str_do_log(handle
->conn
, smb_fname
));
2608 static int smb_full_audit_sys_acl_set_fd(vfs_handle_struct
*handle
, files_struct
*fsp
,
2613 result
= SMB_VFS_NEXT_SYS_ACL_SET_FD(handle
, fsp
, theacl
);
2615 do_log(SMB_VFS_OP_SYS_ACL_SET_FD
, (result
>= 0), handle
,
2616 "%s", fsp_str_do_log(fsp
));
2621 static int smb_full_audit_sys_acl_delete_def_file(vfs_handle_struct
*handle
,
2622 const struct smb_filename
*smb_fname
)
2626 result
= SMB_VFS_NEXT_SYS_ACL_DELETE_DEF_FILE(handle
, smb_fname
);
2628 do_log(SMB_VFS_OP_SYS_ACL_DELETE_DEF_FILE
,
2632 smb_fname_str_do_log(handle
->conn
, smb_fname
));
2637 static ssize_t
smb_full_audit_getxattr(struct vfs_handle_struct
*handle
,
2638 const struct smb_filename
*smb_fname
,
2639 const char *name
, void *value
, size_t size
)
2643 result
= SMB_VFS_NEXT_GETXATTR(handle
, smb_fname
, name
, value
, size
);
2645 do_log(SMB_VFS_OP_GETXATTR
,
2649 smb_fname_str_do_log(handle
->conn
, smb_fname
),
2655 struct smb_full_audit_getxattrat_state
{
2656 struct vfs_aio_state aio_state
;
2657 vfs_handle_struct
*handle
;
2658 files_struct
*dir_fsp
;
2659 const struct smb_filename
*smb_fname
;
2660 const char *xattr_name
;
2662 uint8_t *xattr_value
;
2665 static void smb_full_audit_getxattrat_done(struct tevent_req
*subreq
);
2667 static struct tevent_req
*smb_full_audit_getxattrat_send(
2668 TALLOC_CTX
*mem_ctx
,
2669 struct tevent_context
*ev
,
2670 struct vfs_handle_struct
*handle
,
2671 files_struct
*dir_fsp
,
2672 const struct smb_filename
*smb_fname
,
2673 const char *xattr_name
,
2676 struct tevent_req
*req
= NULL
;
2677 struct tevent_req
*subreq
= NULL
;
2678 struct smb_full_audit_getxattrat_state
*state
= NULL
;
2680 req
= tevent_req_create(mem_ctx
, &state
,
2681 struct smb_full_audit_getxattrat_state
);
2683 do_log(SMB_VFS_OP_GETXATTRAT_SEND
,
2687 fsp_str_do_log(dir_fsp
),
2688 smb_fname
->base_name
,
2692 *state
= (struct smb_full_audit_getxattrat_state
) {
2695 .smb_fname
= smb_fname
,
2696 .xattr_name
= xattr_name
,
2699 subreq
= SMB_VFS_NEXT_GETXATTRAT_SEND(state
,
2706 if (tevent_req_nomem(subreq
, req
)) {
2707 do_log(SMB_VFS_OP_GETXATTRAT_SEND
,
2711 fsp_str_do_log(dir_fsp
),
2712 smb_fname
->base_name
,
2714 return tevent_req_post(req
, ev
);
2716 tevent_req_set_callback(subreq
, smb_full_audit_getxattrat_done
, req
);
2718 do_log(SMB_VFS_OP_GETXATTRAT_SEND
,
2722 fsp_str_do_log(dir_fsp
),
2723 smb_fname
->base_name
,
2729 static void smb_full_audit_getxattrat_done(struct tevent_req
*subreq
)
2731 struct tevent_req
*req
= tevent_req_callback_data(
2732 subreq
, struct tevent_req
);
2733 struct smb_full_audit_getxattrat_state
*state
= tevent_req_data(
2734 req
, struct smb_full_audit_getxattrat_state
);
2736 state
->xattr_size
= SMB_VFS_NEXT_GETXATTRAT_RECV(subreq
,
2739 &state
->xattr_value
);
2740 TALLOC_FREE(subreq
);
2741 if (state
->xattr_size
== -1) {
2742 tevent_req_error(req
, state
->aio_state
.error
);
2746 tevent_req_done(req
);
2749 static ssize_t
smb_full_audit_getxattrat_recv(struct tevent_req
*req
,
2750 struct vfs_aio_state
*aio_state
,
2751 TALLOC_CTX
*mem_ctx
,
2752 uint8_t **xattr_value
)
2754 struct smb_full_audit_getxattrat_state
*state
= tevent_req_data(
2755 req
, struct smb_full_audit_getxattrat_state
);
2758 if (tevent_req_is_unix_error(req
, &aio_state
->error
)) {
2759 do_log(SMB_VFS_OP_GETXATTRAT_RECV
,
2763 fsp_str_do_log(state
->dir_fsp
),
2764 state
->smb_fname
->base_name
,
2766 tevent_req_received(req
);
2770 do_log(SMB_VFS_OP_GETXATTRAT_RECV
,
2774 fsp_str_do_log(state
->dir_fsp
),
2775 state
->smb_fname
->base_name
,
2778 *aio_state
= state
->aio_state
;
2779 xattr_size
= state
->xattr_size
;
2780 if (xattr_value
!= NULL
) {
2781 *xattr_value
= talloc_move(mem_ctx
, &state
->xattr_value
);
2784 tevent_req_received(req
);
2788 static ssize_t
smb_full_audit_fgetxattr(struct vfs_handle_struct
*handle
,
2789 struct files_struct
*fsp
,
2790 const char *name
, void *value
, size_t size
)
2794 result
= SMB_VFS_NEXT_FGETXATTR(handle
, fsp
, name
, value
, size
);
2796 do_log(SMB_VFS_OP_FGETXATTR
, (result
>= 0), handle
,
2797 "%s|%s", fsp_str_do_log(fsp
), name
);
2802 static ssize_t
smb_full_audit_listxattr(struct vfs_handle_struct
*handle
,
2803 const struct smb_filename
*smb_fname
,
2809 result
= SMB_VFS_NEXT_LISTXATTR(handle
, smb_fname
, list
, size
);
2811 do_log(SMB_VFS_OP_LISTXATTR
,
2815 smb_fname_str_do_log(handle
->conn
, smb_fname
));
2820 static ssize_t
smb_full_audit_flistxattr(struct vfs_handle_struct
*handle
,
2821 struct files_struct
*fsp
, char *list
,
2826 result
= SMB_VFS_NEXT_FLISTXATTR(handle
, fsp
, list
, size
);
2828 do_log(SMB_VFS_OP_FLISTXATTR
, (result
>= 0), handle
,
2829 "%s", fsp_str_do_log(fsp
));
2834 static int smb_full_audit_removexattr(struct vfs_handle_struct
*handle
,
2835 const struct smb_filename
*smb_fname
,
2840 result
= SMB_VFS_NEXT_REMOVEXATTR(handle
, smb_fname
, name
);
2842 do_log(SMB_VFS_OP_REMOVEXATTR
,
2846 smb_fname_str_do_log(handle
->conn
, smb_fname
),
2852 static int smb_full_audit_fremovexattr(struct vfs_handle_struct
*handle
,
2853 struct files_struct
*fsp
,
2858 result
= SMB_VFS_NEXT_FREMOVEXATTR(handle
, fsp
, name
);
2860 do_log(SMB_VFS_OP_FREMOVEXATTR
, (result
>= 0), handle
,
2861 "%s|%s", fsp_str_do_log(fsp
), name
);
2866 static int smb_full_audit_setxattr(struct vfs_handle_struct
*handle
,
2867 const struct smb_filename
*smb_fname
,
2868 const char *name
, const void *value
, size_t size
,
2873 result
= SMB_VFS_NEXT_SETXATTR(handle
, smb_fname
, name
, value
, size
,
2876 do_log(SMB_VFS_OP_SETXATTR
,
2880 smb_fname_str_do_log(handle
->conn
, smb_fname
),
2886 static int smb_full_audit_fsetxattr(struct vfs_handle_struct
*handle
,
2887 struct files_struct
*fsp
, const char *name
,
2888 const void *value
, size_t size
, int flags
)
2892 result
= SMB_VFS_NEXT_FSETXATTR(handle
, fsp
, name
, value
, size
, flags
);
2894 do_log(SMB_VFS_OP_FSETXATTR
, (result
>= 0), handle
,
2895 "%s|%s", fsp_str_do_log(fsp
), name
);
2900 static bool smb_full_audit_aio_force(struct vfs_handle_struct
*handle
,
2901 struct files_struct
*fsp
)
2905 result
= SMB_VFS_NEXT_AIO_FORCE(handle
, fsp
);
2906 do_log(SMB_VFS_OP_AIO_FORCE
, result
, handle
,
2907 "%s", fsp_str_do_log(fsp
));
2912 static NTSTATUS
smb_full_audit_durable_cookie(struct vfs_handle_struct
*handle
,
2913 struct files_struct
*fsp
,
2914 TALLOC_CTX
*mem_ctx
,
2919 result
= SMB_VFS_NEXT_DURABLE_COOKIE(handle
,
2924 do_log(SMB_VFS_OP_DURABLE_COOKIE
, NT_STATUS_IS_OK(result
), handle
,
2925 "%s", fsp_str_do_log(fsp
));
2930 static NTSTATUS
smb_full_audit_durable_disconnect(
2931 struct vfs_handle_struct
*handle
,
2932 struct files_struct
*fsp
,
2933 const DATA_BLOB old_cookie
,
2934 TALLOC_CTX
*mem_ctx
,
2935 DATA_BLOB
*new_cookie
)
2939 result
= SMB_VFS_NEXT_DURABLE_DISCONNECT(handle
,
2945 do_log(SMB_VFS_OP_DURABLE_DISCONNECT
, NT_STATUS_IS_OK(result
), handle
,
2946 "%s", fsp_str_do_log(fsp
));
2951 static NTSTATUS
smb_full_audit_durable_reconnect(
2952 struct vfs_handle_struct
*handle
,
2953 struct smb_request
*smb1req
,
2954 struct smbXsrv_open
*op
,
2955 const DATA_BLOB old_cookie
,
2956 TALLOC_CTX
*mem_ctx
,
2957 struct files_struct
**fsp
,
2958 DATA_BLOB
*new_cookie
)
2962 result
= SMB_VFS_NEXT_DURABLE_RECONNECT(handle
,
2970 do_log(SMB_VFS_OP_DURABLE_RECONNECT
,
2971 NT_STATUS_IS_OK(result
),
2978 static struct vfs_fn_pointers vfs_full_audit_fns
= {
2980 /* Disk operations */
2982 .connect_fn
= smb_full_audit_connect
,
2983 .disconnect_fn
= smb_full_audit_disconnect
,
2984 .disk_free_fn
= smb_full_audit_disk_free
,
2985 .get_quota_fn
= smb_full_audit_get_quota
,
2986 .set_quota_fn
= smb_full_audit_set_quota
,
2987 .get_shadow_copy_data_fn
= smb_full_audit_get_shadow_copy_data
,
2988 .statvfs_fn
= smb_full_audit_statvfs
,
2989 .fs_capabilities_fn
= smb_full_audit_fs_capabilities
,
2990 .get_dfs_referrals_fn
= smb_full_audit_get_dfs_referrals
,
2991 .create_dfs_pathat_fn
= smb_full_audit_create_dfs_pathat
,
2992 .read_dfs_pathat_fn
= smb_full_audit_read_dfs_pathat
,
2993 .opendir_fn
= smb_full_audit_opendir
,
2994 .fdopendir_fn
= smb_full_audit_fdopendir
,
2995 .readdir_fn
= smb_full_audit_readdir
,
2996 .seekdir_fn
= smb_full_audit_seekdir
,
2997 .telldir_fn
= smb_full_audit_telldir
,
2998 .rewind_dir_fn
= smb_full_audit_rewinddir
,
2999 .mkdirat_fn
= smb_full_audit_mkdirat
,
3000 .closedir_fn
= smb_full_audit_closedir
,
3001 .open_fn
= smb_full_audit_open
,
3002 .create_file_fn
= smb_full_audit_create_file
,
3003 .close_fn
= smb_full_audit_close
,
3004 .pread_fn
= smb_full_audit_pread
,
3005 .pread_send_fn
= smb_full_audit_pread_send
,
3006 .pread_recv_fn
= smb_full_audit_pread_recv
,
3007 .pwrite_fn
= smb_full_audit_pwrite
,
3008 .pwrite_send_fn
= smb_full_audit_pwrite_send
,
3009 .pwrite_recv_fn
= smb_full_audit_pwrite_recv
,
3010 .lseek_fn
= smb_full_audit_lseek
,
3011 .sendfile_fn
= smb_full_audit_sendfile
,
3012 .recvfile_fn
= smb_full_audit_recvfile
,
3013 .renameat_fn
= smb_full_audit_renameat
,
3014 .fsync_send_fn
= smb_full_audit_fsync_send
,
3015 .fsync_recv_fn
= smb_full_audit_fsync_recv
,
3016 .stat_fn
= smb_full_audit_stat
,
3017 .fstat_fn
= smb_full_audit_fstat
,
3018 .lstat_fn
= smb_full_audit_lstat
,
3019 .get_alloc_size_fn
= smb_full_audit_get_alloc_size
,
3020 .unlinkat_fn
= smb_full_audit_unlinkat
,
3021 .chmod_fn
= smb_full_audit_chmod
,
3022 .fchmod_fn
= smb_full_audit_fchmod
,
3023 .fchown_fn
= smb_full_audit_fchown
,
3024 .lchown_fn
= smb_full_audit_lchown
,
3025 .chdir_fn
= smb_full_audit_chdir
,
3026 .getwd_fn
= smb_full_audit_getwd
,
3027 .ntimes_fn
= smb_full_audit_ntimes
,
3028 .ftruncate_fn
= smb_full_audit_ftruncate
,
3029 .fallocate_fn
= smb_full_audit_fallocate
,
3030 .lock_fn
= smb_full_audit_lock
,
3031 .kernel_flock_fn
= smb_full_audit_kernel_flock
,
3032 .fcntl_fn
= smb_full_audit_fcntl
,
3033 .linux_setlease_fn
= smb_full_audit_linux_setlease
,
3034 .getlock_fn
= smb_full_audit_getlock
,
3035 .symlinkat_fn
= smb_full_audit_symlinkat
,
3036 .readlinkat_fn
= smb_full_audit_readlinkat
,
3037 .linkat_fn
= smb_full_audit_linkat
,
3038 .mknodat_fn
= smb_full_audit_mknodat
,
3039 .realpath_fn
= smb_full_audit_realpath
,
3040 .chflags_fn
= smb_full_audit_chflags
,
3041 .file_id_create_fn
= smb_full_audit_file_id_create
,
3042 .fs_file_id_fn
= smb_full_audit_fs_file_id
,
3043 .offload_read_send_fn
= smb_full_audit_offload_read_send
,
3044 .offload_read_recv_fn
= smb_full_audit_offload_read_recv
,
3045 .offload_write_send_fn
= smb_full_audit_offload_write_send
,
3046 .offload_write_recv_fn
= smb_full_audit_offload_write_recv
,
3047 .get_compression_fn
= smb_full_audit_get_compression
,
3048 .set_compression_fn
= smb_full_audit_set_compression
,
3049 .snap_check_path_fn
= smb_full_audit_snap_check_path
,
3050 .snap_create_fn
= smb_full_audit_snap_create
,
3051 .snap_delete_fn
= smb_full_audit_snap_delete
,
3052 .streaminfo_fn
= smb_full_audit_streaminfo
,
3053 .get_real_filename_fn
= smb_full_audit_get_real_filename
,
3054 .connectpath_fn
= smb_full_audit_connectpath
,
3055 .brl_lock_windows_fn
= smb_full_audit_brl_lock_windows
,
3056 .brl_unlock_windows_fn
= smb_full_audit_brl_unlock_windows
,
3057 .strict_lock_check_fn
= smb_full_audit_strict_lock_check
,
3058 .translate_name_fn
= smb_full_audit_translate_name
,
3059 .fsctl_fn
= smb_full_audit_fsctl
,
3060 .get_dos_attributes_fn
= smb_full_audit_get_dos_attributes
,
3061 .get_dos_attributes_send_fn
= smb_full_audit_get_dos_attributes_send
,
3062 .get_dos_attributes_recv_fn
= smb_full_audit_get_dos_attributes_recv
,
3063 .fget_dos_attributes_fn
= smb_full_audit_fget_dos_attributes
,
3064 .set_dos_attributes_fn
= smb_full_audit_set_dos_attributes
,
3065 .fset_dos_attributes_fn
= smb_full_audit_fset_dos_attributes
,
3066 .fget_nt_acl_fn
= smb_full_audit_fget_nt_acl
,
3067 .get_nt_acl_fn
= smb_full_audit_get_nt_acl
,
3068 .fset_nt_acl_fn
= smb_full_audit_fset_nt_acl
,
3069 .audit_file_fn
= smb_full_audit_audit_file
,
3070 .sys_acl_get_file_fn
= smb_full_audit_sys_acl_get_file
,
3071 .sys_acl_get_fd_fn
= smb_full_audit_sys_acl_get_fd
,
3072 .sys_acl_blob_get_file_fn
= smb_full_audit_sys_acl_blob_get_file
,
3073 .sys_acl_blob_get_fd_fn
= smb_full_audit_sys_acl_blob_get_fd
,
3074 .sys_acl_set_file_fn
= smb_full_audit_sys_acl_set_file
,
3075 .sys_acl_set_fd_fn
= smb_full_audit_sys_acl_set_fd
,
3076 .sys_acl_delete_def_file_fn
= smb_full_audit_sys_acl_delete_def_file
,
3077 .getxattr_fn
= smb_full_audit_getxattr
,
3078 .getxattrat_send_fn
= smb_full_audit_getxattrat_send
,
3079 .getxattrat_recv_fn
= smb_full_audit_getxattrat_recv
,
3080 .fgetxattr_fn
= smb_full_audit_fgetxattr
,
3081 .listxattr_fn
= smb_full_audit_listxattr
,
3082 .flistxattr_fn
= smb_full_audit_flistxattr
,
3083 .removexattr_fn
= smb_full_audit_removexattr
,
3084 .fremovexattr_fn
= smb_full_audit_fremovexattr
,
3085 .setxattr_fn
= smb_full_audit_setxattr
,
3086 .fsetxattr_fn
= smb_full_audit_fsetxattr
,
3087 .aio_force_fn
= smb_full_audit_aio_force
,
3088 .durable_cookie_fn
= smb_full_audit_durable_cookie
,
3089 .durable_disconnect_fn
= smb_full_audit_durable_disconnect
,
3090 .durable_reconnect_fn
= smb_full_audit_durable_reconnect
,
3091 .readdir_attr_fn
= smb_full_audit_readdir_attr
3096 NTSTATUS
vfs_full_audit_init(TALLOC_CTX
*ctx
)
3100 smb_vfs_assert_all_fns(&vfs_full_audit_fns
, "full_audit");
3102 ret
= smb_register_vfs(SMB_VFS_INTERFACE_VERSION
, "full_audit",
3103 &vfs_full_audit_fns
);
3105 if (!NT_STATUS_IS_OK(ret
))
3108 vfs_full_audit_debug_level
= debug_add_class("full_audit");
3109 if (vfs_full_audit_debug_level
== -1) {
3110 vfs_full_audit_debug_level
= DBGC_VFS
;
3111 DEBUG(0, ("vfs_full_audit: Couldn't register custom debugging "
3114 DEBUG(10, ("vfs_full_audit: Debug class number of "
3115 "'full_audit': %d\n", vfs_full_audit_debug_level
));