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"
71 static int vfs_full_audit_debug_level
= DBGC_VFS
;
73 struct vfs_full_audit_private_data
{
74 struct bitmap
*success_ops
;
75 struct bitmap
*failure_ops
;
79 #define DBGC_CLASS vfs_full_audit_debug_level
81 typedef enum _vfs_op_type
{
86 SMB_VFS_OP_CONNECT
= 0,
87 SMB_VFS_OP_DISCONNECT
,
91 SMB_VFS_OP_GET_SHADOW_COPY_DATA
,
93 SMB_VFS_OP_FS_CAPABILITIES
,
95 /* Directory operations */
102 SMB_VFS_OP_REWINDDIR
,
106 SMB_VFS_OP_INIT_SEARCH_OP
,
108 /* File operations */
111 SMB_VFS_OP_CREATE_FILE
,
115 SMB_VFS_OP_PREAD_SEND
,
116 SMB_VFS_OP_PREAD_RECV
,
119 SMB_VFS_OP_PWRITE_SEND
,
120 SMB_VFS_OP_PWRITE_RECV
,
126 SMB_VFS_OP_FSYNC_SEND
,
127 SMB_VFS_OP_FSYNC_RECV
,
131 SMB_VFS_OP_GET_ALLOC_SIZE
,
141 SMB_VFS_OP_FTRUNCATE
,
142 SMB_VFS_OP_FALLOCATE
,
144 SMB_VFS_OP_KERNEL_FLOCK
,
145 SMB_VFS_OP_LINUX_SETLEASE
,
152 SMB_VFS_OP_NOTIFY_WATCH
,
154 SMB_VFS_OP_FILE_ID_CREATE
,
155 SMB_VFS_OP_STREAMINFO
,
156 SMB_VFS_OP_GET_REAL_FILENAME
,
157 SMB_VFS_OP_CONNECTPATH
,
158 SMB_VFS_OP_BRL_LOCK_WINDOWS
,
159 SMB_VFS_OP_BRL_UNLOCK_WINDOWS
,
160 SMB_VFS_OP_BRL_CANCEL_WINDOWS
,
161 SMB_VFS_OP_STRICT_LOCK
,
162 SMB_VFS_OP_STRICT_UNLOCK
,
163 SMB_VFS_OP_TRANSLATE_NAME
,
165 /* NT ACL operations. */
167 SMB_VFS_OP_FGET_NT_ACL
,
168 SMB_VFS_OP_GET_NT_ACL
,
169 SMB_VFS_OP_FSET_NT_ACL
,
171 /* POSIX ACL operations. */
173 SMB_VFS_OP_CHMOD_ACL
,
174 SMB_VFS_OP_FCHMOD_ACL
,
176 SMB_VFS_OP_SYS_ACL_GET_ENTRY
,
177 SMB_VFS_OP_SYS_ACL_GET_TAG_TYPE
,
178 SMB_VFS_OP_SYS_ACL_GET_PERMSET
,
179 SMB_VFS_OP_SYS_ACL_GET_QUALIFIER
,
180 SMB_VFS_OP_SYS_ACL_GET_FILE
,
181 SMB_VFS_OP_SYS_ACL_GET_FD
,
182 SMB_VFS_OP_SYS_ACL_CLEAR_PERMS
,
183 SMB_VFS_OP_SYS_ACL_ADD_PERM
,
184 SMB_VFS_OP_SYS_ACL_TO_TEXT
,
185 SMB_VFS_OP_SYS_ACL_INIT
,
186 SMB_VFS_OP_SYS_ACL_CREATE_ENTRY
,
187 SMB_VFS_OP_SYS_ACL_SET_TAG_TYPE
,
188 SMB_VFS_OP_SYS_ACL_SET_QUALIFIER
,
189 SMB_VFS_OP_SYS_ACL_SET_PERMSET
,
190 SMB_VFS_OP_SYS_ACL_VALID
,
191 SMB_VFS_OP_SYS_ACL_SET_FILE
,
192 SMB_VFS_OP_SYS_ACL_SET_FD
,
193 SMB_VFS_OP_SYS_ACL_DELETE_DEF_FILE
,
194 SMB_VFS_OP_SYS_ACL_GET_PERM
,
195 SMB_VFS_OP_SYS_ACL_FREE_TEXT
,
196 SMB_VFS_OP_SYS_ACL_FREE_ACL
,
197 SMB_VFS_OP_SYS_ACL_FREE_QUALIFIER
,
201 SMB_VFS_OP_FGETXATTR
,
202 SMB_VFS_OP_LISTXATTR
,
203 SMB_VFS_OP_FLISTXATTR
,
204 SMB_VFS_OP_REMOVEXATTR
,
205 SMB_VFS_OP_FREMOVEXATTR
,
207 SMB_VFS_OP_FSETXATTR
,
210 SMB_VFS_OP_AIO_FORCE
,
212 /* offline operations */
213 SMB_VFS_OP_IS_OFFLINE
,
214 SMB_VFS_OP_SET_OFFLINE
,
216 /* This should always be last enum value */
221 /* The following array *must* be in the same order as defined in vfs.h */
227 { SMB_VFS_OP_CONNECT
, "connect" },
228 { SMB_VFS_OP_DISCONNECT
, "disconnect" },
229 { SMB_VFS_OP_DISK_FREE
, "disk_free" },
230 { SMB_VFS_OP_GET_QUOTA
, "get_quota" },
231 { SMB_VFS_OP_SET_QUOTA
, "set_quota" },
232 { SMB_VFS_OP_GET_SHADOW_COPY_DATA
, "get_shadow_copy_data" },
233 { SMB_VFS_OP_STATVFS
, "statvfs" },
234 { SMB_VFS_OP_FS_CAPABILITIES
, "fs_capabilities" },
235 { SMB_VFS_OP_OPENDIR
, "opendir" },
236 { SMB_VFS_OP_FDOPENDIR
, "fdopendir" },
237 { SMB_VFS_OP_READDIR
, "readdir" },
238 { SMB_VFS_OP_SEEKDIR
, "seekdir" },
239 { SMB_VFS_OP_TELLDIR
, "telldir" },
240 { SMB_VFS_OP_REWINDDIR
, "rewinddir" },
241 { SMB_VFS_OP_MKDIR
, "mkdir" },
242 { SMB_VFS_OP_RMDIR
, "rmdir" },
243 { SMB_VFS_OP_CLOSEDIR
, "closedir" },
244 { SMB_VFS_OP_INIT_SEARCH_OP
, "init_search_op" },
245 { SMB_VFS_OP_OPEN
, "open" },
246 { SMB_VFS_OP_CREATE_FILE
, "create_file" },
247 { SMB_VFS_OP_CLOSE
, "close" },
248 { SMB_VFS_OP_READ
, "read" },
249 { SMB_VFS_OP_PREAD
, "pread" },
250 { SMB_VFS_OP_PREAD_SEND
, "pread_send" },
251 { SMB_VFS_OP_PREAD_RECV
, "pread_recv" },
252 { SMB_VFS_OP_WRITE
, "write" },
253 { SMB_VFS_OP_PWRITE
, "pwrite" },
254 { SMB_VFS_OP_LSEEK
, "lseek" },
255 { SMB_VFS_OP_SENDFILE
, "sendfile" },
256 { SMB_VFS_OP_RECVFILE
, "recvfile" },
257 { SMB_VFS_OP_RENAME
, "rename" },
258 { SMB_VFS_OP_FSYNC
, "fsync" },
259 { SMB_VFS_OP_FSYNC_SEND
, "fsync_send" },
260 { SMB_VFS_OP_FSYNC_RECV
, "fsync_recv" },
261 { SMB_VFS_OP_STAT
, "stat" },
262 { SMB_VFS_OP_FSTAT
, "fstat" },
263 { SMB_VFS_OP_LSTAT
, "lstat" },
264 { SMB_VFS_OP_GET_ALLOC_SIZE
, "get_alloc_size" },
265 { SMB_VFS_OP_UNLINK
, "unlink" },
266 { SMB_VFS_OP_CHMOD
, "chmod" },
267 { SMB_VFS_OP_FCHMOD
, "fchmod" },
268 { SMB_VFS_OP_CHOWN
, "chown" },
269 { SMB_VFS_OP_FCHOWN
, "fchown" },
270 { SMB_VFS_OP_LCHOWN
, "lchown" },
271 { SMB_VFS_OP_CHDIR
, "chdir" },
272 { SMB_VFS_OP_GETWD
, "getwd" },
273 { SMB_VFS_OP_NTIMES
, "ntimes" },
274 { SMB_VFS_OP_FTRUNCATE
, "ftruncate" },
275 { SMB_VFS_OP_FALLOCATE
,"fallocate" },
276 { SMB_VFS_OP_LOCK
, "lock" },
277 { SMB_VFS_OP_KERNEL_FLOCK
, "kernel_flock" },
278 { SMB_VFS_OP_LINUX_SETLEASE
, "linux_setlease" },
279 { SMB_VFS_OP_GETLOCK
, "getlock" },
280 { SMB_VFS_OP_SYMLINK
, "symlink" },
281 { SMB_VFS_OP_READLINK
, "readlink" },
282 { SMB_VFS_OP_LINK
, "link" },
283 { SMB_VFS_OP_MKNOD
, "mknod" },
284 { SMB_VFS_OP_REALPATH
, "realpath" },
285 { SMB_VFS_OP_NOTIFY_WATCH
, "notify_watch" },
286 { SMB_VFS_OP_CHFLAGS
, "chflags" },
287 { SMB_VFS_OP_FILE_ID_CREATE
, "file_id_create" },
288 { SMB_VFS_OP_STREAMINFO
, "streaminfo" },
289 { SMB_VFS_OP_GET_REAL_FILENAME
, "get_real_filename" },
290 { SMB_VFS_OP_CONNECTPATH
, "connectpath" },
291 { SMB_VFS_OP_BRL_LOCK_WINDOWS
, "brl_lock_windows" },
292 { SMB_VFS_OP_BRL_UNLOCK_WINDOWS
, "brl_unlock_windows" },
293 { SMB_VFS_OP_BRL_CANCEL_WINDOWS
, "brl_cancel_windows" },
294 { SMB_VFS_OP_STRICT_LOCK
, "strict_lock" },
295 { SMB_VFS_OP_STRICT_UNLOCK
, "strict_unlock" },
296 { SMB_VFS_OP_TRANSLATE_NAME
, "translate_name" },
297 { SMB_VFS_OP_FGET_NT_ACL
, "fget_nt_acl" },
298 { SMB_VFS_OP_GET_NT_ACL
, "get_nt_acl" },
299 { SMB_VFS_OP_FSET_NT_ACL
, "fset_nt_acl" },
300 { SMB_VFS_OP_CHMOD_ACL
, "chmod_acl" },
301 { SMB_VFS_OP_FCHMOD_ACL
, "fchmod_acl" },
302 { SMB_VFS_OP_SYS_ACL_GET_ENTRY
, "sys_acl_get_entry" },
303 { SMB_VFS_OP_SYS_ACL_GET_TAG_TYPE
, "sys_acl_get_tag_type" },
304 { SMB_VFS_OP_SYS_ACL_GET_PERMSET
, "sys_acl_get_permset" },
305 { SMB_VFS_OP_SYS_ACL_GET_QUALIFIER
, "sys_acl_get_qualifier" },
306 { SMB_VFS_OP_SYS_ACL_GET_FILE
, "sys_acl_get_file" },
307 { SMB_VFS_OP_SYS_ACL_GET_FD
, "sys_acl_get_fd" },
308 { SMB_VFS_OP_SYS_ACL_CLEAR_PERMS
, "sys_acl_clear_perms" },
309 { SMB_VFS_OP_SYS_ACL_ADD_PERM
, "sys_acl_add_perm" },
310 { SMB_VFS_OP_SYS_ACL_TO_TEXT
, "sys_acl_to_text" },
311 { SMB_VFS_OP_SYS_ACL_INIT
, "sys_acl_init" },
312 { SMB_VFS_OP_SYS_ACL_CREATE_ENTRY
, "sys_acl_create_entry" },
313 { SMB_VFS_OP_SYS_ACL_SET_TAG_TYPE
, "sys_acl_set_tag_type" },
314 { SMB_VFS_OP_SYS_ACL_SET_QUALIFIER
, "sys_acl_set_qualifier" },
315 { SMB_VFS_OP_SYS_ACL_SET_PERMSET
, "sys_acl_set_permset" },
316 { SMB_VFS_OP_SYS_ACL_VALID
, "sys_acl_valid" },
317 { SMB_VFS_OP_SYS_ACL_SET_FILE
, "sys_acl_set_file" },
318 { SMB_VFS_OP_SYS_ACL_SET_FD
, "sys_acl_set_fd" },
319 { SMB_VFS_OP_SYS_ACL_DELETE_DEF_FILE
, "sys_acl_delete_def_file" },
320 { SMB_VFS_OP_SYS_ACL_GET_PERM
, "sys_acl_get_perm" },
321 { SMB_VFS_OP_SYS_ACL_FREE_TEXT
, "sys_acl_free_text" },
322 { SMB_VFS_OP_SYS_ACL_FREE_ACL
, "sys_acl_free_acl" },
323 { SMB_VFS_OP_SYS_ACL_FREE_QUALIFIER
, "sys_acl_free_qualifier" },
324 { SMB_VFS_OP_GETXATTR
, "getxattr" },
325 { SMB_VFS_OP_FGETXATTR
, "fgetxattr" },
326 { SMB_VFS_OP_LISTXATTR
, "listxattr" },
327 { SMB_VFS_OP_FLISTXATTR
, "flistxattr" },
328 { SMB_VFS_OP_REMOVEXATTR
, "removexattr" },
329 { SMB_VFS_OP_FREMOVEXATTR
, "fremovexattr" },
330 { SMB_VFS_OP_SETXATTR
, "setxattr" },
331 { SMB_VFS_OP_FSETXATTR
, "fsetxattr" },
332 { SMB_VFS_OP_AIO_FORCE
, "aio_force" },
333 { SMB_VFS_OP_IS_OFFLINE
, "is_offline" },
334 { SMB_VFS_OP_SET_OFFLINE
, "set_offline" },
335 { SMB_VFS_OP_LAST
, NULL
}
338 static int audit_syslog_facility(vfs_handle_struct
*handle
)
340 static const struct enum_list enum_log_facilities
[] = {
341 { LOG_USER
, "USER" },
342 { LOG_LOCAL0
, "LOCAL0" },
343 { LOG_LOCAL1
, "LOCAL1" },
344 { LOG_LOCAL2
, "LOCAL2" },
345 { LOG_LOCAL3
, "LOCAL3" },
346 { LOG_LOCAL4
, "LOCAL4" },
347 { LOG_LOCAL5
, "LOCAL5" },
348 { LOG_LOCAL6
, "LOCAL6" },
349 { LOG_LOCAL7
, "LOCAL7" },
355 facility
= lp_parm_enum(SNUM(handle
->conn
), "full_audit", "facility", enum_log_facilities
, LOG_USER
);
360 static int audit_syslog_priority(vfs_handle_struct
*handle
)
362 static const struct enum_list enum_log_priorities
[] = {
363 { LOG_EMERG
, "EMERG" },
364 { LOG_ALERT
, "ALERT" },
365 { LOG_CRIT
, "CRIT" },
367 { LOG_WARNING
, "WARNING" },
368 { LOG_NOTICE
, "NOTICE" },
369 { LOG_INFO
, "INFO" },
370 { LOG_DEBUG
, "DEBUG" },
376 priority
= lp_parm_enum(SNUM(handle
->conn
), "full_audit", "priority",
377 enum_log_priorities
, LOG_NOTICE
);
378 if (priority
== -1) {
379 priority
= LOG_WARNING
;
385 static char *audit_prefix(TALLOC_CTX
*ctx
, connection_struct
*conn
)
390 prefix
= talloc_strdup(ctx
,
391 lp_parm_const_string(SNUM(conn
), "full_audit",
396 result
= talloc_sub_advanced(ctx
,
397 lp_servicename(talloc_tos(), SNUM(conn
)),
398 conn
->session_info
->unix_info
->unix_name
,
400 conn
->session_info
->unix_token
->gid
,
401 conn
->session_info
->unix_info
->sanitized_username
,
402 conn
->session_info
->info
->domain_name
,
408 static bool log_success(vfs_handle_struct
*handle
, vfs_op_type op
)
410 struct vfs_full_audit_private_data
*pd
= NULL
;
412 SMB_VFS_HANDLE_GET_DATA(handle
, pd
,
413 struct vfs_full_audit_private_data
,
416 if (pd
->success_ops
== NULL
) {
420 return bitmap_query(pd
->success_ops
, op
);
423 static bool log_failure(vfs_handle_struct
*handle
, vfs_op_type op
)
425 struct vfs_full_audit_private_data
*pd
= NULL
;
427 SMB_VFS_HANDLE_GET_DATA(handle
, pd
,
428 struct vfs_full_audit_private_data
,
431 if (pd
->failure_ops
== NULL
)
434 return bitmap_query(pd
->failure_ops
, op
);
437 static struct bitmap
*init_bitmap(TALLOC_CTX
*mem_ctx
, const char **ops
)
445 bm
= bitmap_talloc(mem_ctx
, SMB_VFS_OP_LAST
);
447 DEBUG(0, ("Could not alloc bitmap -- "
448 "defaulting to logging everything\n"));
452 for (; *ops
!= NULL
; ops
+= 1) {
457 if (strequal(*ops
, "all")) {
458 for (i
=0; i
<SMB_VFS_OP_LAST
; i
++) {
464 if (strequal(*ops
, "none")) {
474 for (i
=0; i
<SMB_VFS_OP_LAST
; i
++) {
475 if (vfs_op_names
[i
].name
== NULL
) {
476 smb_panic("vfs_full_audit.c: name table not "
477 "in sync with vfs.h\n");
479 if (strequal(op
, vfs_op_names
[i
].name
)) {
488 if (i
== SMB_VFS_OP_LAST
) {
489 DEBUG(0, ("Could not find opname %s, logging all\n",
498 static const char *audit_opname(vfs_op_type op
)
500 if (op
>= SMB_VFS_OP_LAST
)
501 return "INVALID VFS OP";
502 return vfs_op_names
[op
].name
;
505 static TALLOC_CTX
*tmp_do_log_ctx
;
507 * Get us a temporary talloc context usable just for DEBUG arguments
509 static TALLOC_CTX
*do_log_ctx(void)
511 if (tmp_do_log_ctx
== NULL
) {
512 tmp_do_log_ctx
= talloc_named_const(NULL
, 0, "do_log_ctx");
514 return tmp_do_log_ctx
;
517 static void do_log(vfs_op_type op
, bool success
, vfs_handle_struct
*handle
,
518 const char *format
, ...)
521 char *audit_pre
= NULL
;
526 if (success
&& (!log_success(handle
, op
)))
529 if (!success
&& (!log_failure(handle
, op
)))
533 fstrcpy(err_msg
, "ok");
535 fstr_sprintf(err_msg
, "fail (%s)", strerror(errno
));
537 va_start(ap
, format
);
538 op_msg
= talloc_vasprintf(talloc_tos(), format
, ap
);
546 * Specify the facility to interoperate with other syslog callers
547 * (smbd for example).
549 priority
= audit_syslog_priority(handle
) |
550 audit_syslog_facility(handle
);
552 audit_pre
= audit_prefix(talloc_tos(), handle
->conn
);
553 syslog(priority
, "%s|%s|%s|%s\n",
554 audit_pre
? audit_pre
: "",
555 audit_opname(op
), err_msg
, op_msg
);
558 TALLOC_FREE(audit_pre
);
560 TALLOC_FREE(tmp_do_log_ctx
);
564 * Return a string using the do_log_ctx()
566 static const char *smb_fname_str_do_log(const struct smb_filename
*smb_fname
)
571 if (smb_fname
== NULL
) {
574 status
= get_full_smb_filename(do_log_ctx(), smb_fname
, &fname
);
575 if (!NT_STATUS_IS_OK(status
)) {
582 * Return an fsp debug string using the do_log_ctx()
584 static const char *fsp_str_do_log(const struct files_struct
*fsp
)
586 return smb_fname_str_do_log(fsp
->fsp_name
);
589 /* Implementation of vfs_ops. Pass everything on to the default
590 operation but log event first. */
592 static int smb_full_audit_connect(vfs_handle_struct
*handle
,
593 const char *svc
, const char *user
)
596 struct vfs_full_audit_private_data
*pd
= NULL
;
598 result
= SMB_VFS_NEXT_CONNECT(handle
, svc
, user
);
603 pd
= talloc_zero(handle
, struct vfs_full_audit_private_data
);
605 SMB_VFS_NEXT_DISCONNECT(handle
);
610 openlog("smbd_audit", 0, audit_syslog_facility(handle
));
613 pd
->success_ops
= init_bitmap(
614 pd
, lp_parm_string_list(SNUM(handle
->conn
), "full_audit",
616 pd
->failure_ops
= init_bitmap(
617 pd
, lp_parm_string_list(SNUM(handle
->conn
), "full_audit",
620 /* Store the private data. */
621 SMB_VFS_HANDLE_SET_DATA(handle
, pd
, NULL
,
622 struct vfs_full_audit_private_data
, return -1);
624 do_log(SMB_VFS_OP_CONNECT
, True
, handle
,
630 static void smb_full_audit_disconnect(vfs_handle_struct
*handle
)
632 SMB_VFS_NEXT_DISCONNECT(handle
);
634 do_log(SMB_VFS_OP_DISCONNECT
, True
, handle
,
635 "%s", lp_servicename(talloc_tos(), SNUM(handle
->conn
)));
637 /* The bitmaps will be disconnected when the private
641 static uint64_t smb_full_audit_disk_free(vfs_handle_struct
*handle
,
643 bool small_query
, uint64_t *bsize
,
644 uint64_t *dfree
, uint64_t *dsize
)
648 result
= SMB_VFS_NEXT_DISK_FREE(handle
, path
, small_query
, bsize
,
651 /* Don't have a reasonable notion of failure here */
653 do_log(SMB_VFS_OP_DISK_FREE
, True
, handle
, "%s", path
);
658 static int smb_full_audit_get_quota(struct vfs_handle_struct
*handle
,
659 enum SMB_QUOTA_TYPE qtype
, unid_t id
,
664 result
= SMB_VFS_NEXT_GET_QUOTA(handle
, qtype
, id
, qt
);
666 do_log(SMB_VFS_OP_GET_QUOTA
, (result
>= 0), handle
, "");
672 static int smb_full_audit_set_quota(struct vfs_handle_struct
*handle
,
673 enum SMB_QUOTA_TYPE qtype
, unid_t id
,
678 result
= SMB_VFS_NEXT_SET_QUOTA(handle
, qtype
, id
, qt
);
680 do_log(SMB_VFS_OP_SET_QUOTA
, (result
>= 0), handle
, "");
685 static int smb_full_audit_get_shadow_copy_data(struct vfs_handle_struct
*handle
,
686 struct files_struct
*fsp
,
687 struct shadow_copy_data
*shadow_copy_data
,
692 result
= SMB_VFS_NEXT_GET_SHADOW_COPY_DATA(handle
, fsp
, shadow_copy_data
, labels
);
694 do_log(SMB_VFS_OP_GET_SHADOW_COPY_DATA
, (result
>= 0), handle
, "");
699 static int smb_full_audit_statvfs(struct vfs_handle_struct
*handle
,
701 struct vfs_statvfs_struct
*statbuf
)
705 result
= SMB_VFS_NEXT_STATVFS(handle
, path
, statbuf
);
707 do_log(SMB_VFS_OP_STATVFS
, (result
>= 0), handle
, "");
712 static uint32_t smb_full_audit_fs_capabilities(struct vfs_handle_struct
*handle
, enum timestamp_set_resolution
*p_ts_res
)
716 result
= SMB_VFS_NEXT_FS_CAPABILITIES(handle
, p_ts_res
);
718 do_log(SMB_VFS_OP_FS_CAPABILITIES
, true, handle
, "");
723 static DIR *smb_full_audit_opendir(vfs_handle_struct
*handle
,
724 const char *fname
, const char *mask
, uint32 attr
)
728 result
= SMB_VFS_NEXT_OPENDIR(handle
, fname
, mask
, attr
);
730 do_log(SMB_VFS_OP_OPENDIR
, (result
!= NULL
), handle
, "%s", fname
);
735 static DIR *smb_full_audit_fdopendir(vfs_handle_struct
*handle
,
736 files_struct
*fsp
, const char *mask
, uint32 attr
)
740 result
= SMB_VFS_NEXT_FDOPENDIR(handle
, fsp
, mask
, attr
);
742 do_log(SMB_VFS_OP_FDOPENDIR
, (result
!= NULL
), handle
, "%s",
743 fsp_str_do_log(fsp
));
748 static struct dirent
*smb_full_audit_readdir(vfs_handle_struct
*handle
,
749 DIR *dirp
, SMB_STRUCT_STAT
*sbuf
)
751 struct dirent
*result
;
753 result
= SMB_VFS_NEXT_READDIR(handle
, dirp
, sbuf
);
755 /* This operation has no reasonable error condition
756 * (End of dir is also failure), so always succeed.
758 do_log(SMB_VFS_OP_READDIR
, True
, handle
, "");
763 static void smb_full_audit_seekdir(vfs_handle_struct
*handle
,
764 DIR *dirp
, long offset
)
766 SMB_VFS_NEXT_SEEKDIR(handle
, dirp
, offset
);
768 do_log(SMB_VFS_OP_SEEKDIR
, True
, handle
, "");
771 static long smb_full_audit_telldir(vfs_handle_struct
*handle
,
776 result
= SMB_VFS_NEXT_TELLDIR(handle
, dirp
);
778 do_log(SMB_VFS_OP_TELLDIR
, True
, handle
, "");
783 static void smb_full_audit_rewinddir(vfs_handle_struct
*handle
,
786 SMB_VFS_NEXT_REWINDDIR(handle
, dirp
);
788 do_log(SMB_VFS_OP_REWINDDIR
, True
, handle
, "");
791 static int smb_full_audit_mkdir(vfs_handle_struct
*handle
,
792 const char *path
, mode_t mode
)
796 result
= SMB_VFS_NEXT_MKDIR(handle
, path
, mode
);
798 do_log(SMB_VFS_OP_MKDIR
, (result
>= 0), handle
, "%s", path
);
803 static int smb_full_audit_rmdir(vfs_handle_struct
*handle
,
808 result
= SMB_VFS_NEXT_RMDIR(handle
, path
);
810 do_log(SMB_VFS_OP_RMDIR
, (result
>= 0), handle
, "%s", path
);
815 static int smb_full_audit_closedir(vfs_handle_struct
*handle
,
820 result
= SMB_VFS_NEXT_CLOSEDIR(handle
, dirp
);
822 do_log(SMB_VFS_OP_CLOSEDIR
, (result
>= 0), handle
, "");
827 static void smb_full_audit_init_search_op(vfs_handle_struct
*handle
,
830 SMB_VFS_NEXT_INIT_SEARCH_OP(handle
, dirp
);
832 do_log(SMB_VFS_OP_INIT_SEARCH_OP
, True
, handle
, "");
835 static int smb_full_audit_open(vfs_handle_struct
*handle
,
836 struct smb_filename
*smb_fname
,
837 files_struct
*fsp
, int flags
, mode_t mode
)
841 result
= SMB_VFS_NEXT_OPEN(handle
, smb_fname
, fsp
, flags
, mode
);
843 do_log(SMB_VFS_OP_OPEN
, (result
>= 0), handle
, "%s|%s",
844 ((flags
& O_WRONLY
) || (flags
& O_RDWR
))?"w":"r",
845 smb_fname_str_do_log(smb_fname
));
850 static NTSTATUS
smb_full_audit_create_file(vfs_handle_struct
*handle
,
851 struct smb_request
*req
,
852 uint16_t root_dir_fid
,
853 struct smb_filename
*smb_fname
,
854 uint32_t access_mask
,
855 uint32_t share_access
,
856 uint32_t create_disposition
,
857 uint32_t create_options
,
858 uint32_t file_attributes
,
859 uint32_t oplock_request
,
860 uint64_t allocation_size
,
861 uint32_t private_flags
,
862 struct security_descriptor
*sd
,
863 struct ea_list
*ea_list
,
864 files_struct
**result_fsp
,
868 const char* str_create_disposition
;
870 switch (create_disposition
) {
872 str_create_disposition
= "supersede";
874 case FILE_OVERWRITE_IF
:
875 str_create_disposition
= "overwrite_if";
878 str_create_disposition
= "open";
881 str_create_disposition
= "overwrite";
884 str_create_disposition
= "create";
887 str_create_disposition
= "open_if";
890 str_create_disposition
= "unknown";
893 result
= SMB_VFS_NEXT_CREATE_FILE(
896 root_dir_fid
, /* root_dir_fid */
897 smb_fname
, /* fname */
898 access_mask
, /* access_mask */
899 share_access
, /* share_access */
900 create_disposition
, /* create_disposition*/
901 create_options
, /* create_options */
902 file_attributes
, /* file_attributes */
903 oplock_request
, /* oplock_request */
904 allocation_size
, /* allocation_size */
907 ea_list
, /* ea_list */
908 result_fsp
, /* result */
911 do_log(SMB_VFS_OP_CREATE_FILE
, (NT_STATUS_IS_OK(result
)), handle
,
912 "0x%x|%s|%s|%s", access_mask
,
913 create_options
& FILE_DIRECTORY_FILE
? "dir" : "file",
914 str_create_disposition
, smb_fname_str_do_log(smb_fname
));
919 static int smb_full_audit_close(vfs_handle_struct
*handle
, files_struct
*fsp
)
923 result
= SMB_VFS_NEXT_CLOSE(handle
, fsp
);
925 do_log(SMB_VFS_OP_CLOSE
, (result
>= 0), handle
, "%s",
926 fsp_str_do_log(fsp
));
931 static ssize_t
smb_full_audit_read(vfs_handle_struct
*handle
, files_struct
*fsp
,
932 void *data
, size_t n
)
936 result
= SMB_VFS_NEXT_READ(handle
, fsp
, data
, n
);
938 do_log(SMB_VFS_OP_READ
, (result
>= 0), handle
, "%s",
939 fsp_str_do_log(fsp
));
944 static ssize_t
smb_full_audit_pread(vfs_handle_struct
*handle
, files_struct
*fsp
,
945 void *data
, size_t n
, off_t offset
)
949 result
= SMB_VFS_NEXT_PREAD(handle
, fsp
, data
, n
, offset
);
951 do_log(SMB_VFS_OP_PREAD
, (result
>= 0), handle
, "%s",
952 fsp_str_do_log(fsp
));
957 struct smb_full_audit_pread_state
{
958 vfs_handle_struct
*handle
;
964 static void smb_full_audit_pread_done(struct tevent_req
*subreq
);
966 static struct tevent_req
*smb_full_audit_pread_send(
967 struct vfs_handle_struct
*handle
, TALLOC_CTX
*mem_ctx
,
968 struct tevent_context
*ev
, struct files_struct
*fsp
,
969 void *data
, size_t n
, off_t offset
)
971 struct tevent_req
*req
, *subreq
;
972 struct smb_full_audit_pread_state
*state
;
974 req
= tevent_req_create(mem_ctx
, &state
,
975 struct smb_full_audit_pread_state
);
977 do_log(SMB_VFS_OP_PREAD_SEND
, false, handle
, "%s",
978 fsp_str_do_log(fsp
));
981 state
->handle
= handle
;
984 subreq
= SMB_VFS_NEXT_PREAD_SEND(state
, ev
, handle
, fsp
, data
,
986 if (tevent_req_nomem(subreq
, req
)) {
987 do_log(SMB_VFS_OP_PREAD_SEND
, false, handle
, "%s",
988 fsp_str_do_log(fsp
));
989 return tevent_req_post(req
, ev
);
991 tevent_req_set_callback(subreq
, smb_full_audit_pread_done
, req
);
993 do_log(SMB_VFS_OP_PREAD_SEND
, true, handle
, "%s", fsp_str_do_log(fsp
));
997 static void smb_full_audit_pread_done(struct tevent_req
*subreq
)
999 struct tevent_req
*req
= tevent_req_callback_data(
1000 subreq
, struct tevent_req
);
1001 struct smb_full_audit_pread_state
*state
= tevent_req_data(
1002 req
, struct smb_full_audit_pread_state
);
1004 state
->ret
= SMB_VFS_PREAD_RECV(subreq
, &state
->err
);
1005 TALLOC_FREE(subreq
);
1006 tevent_req_done(req
);
1009 static ssize_t
smb_full_audit_pread_recv(struct tevent_req
*req
, int *err
)
1011 struct smb_full_audit_pread_state
*state
= tevent_req_data(
1012 req
, struct smb_full_audit_pread_state
);
1014 if (tevent_req_is_unix_error(req
, err
)) {
1015 do_log(SMB_VFS_OP_PREAD_RECV
, false, state
->handle
, "%s",
1016 fsp_str_do_log(state
->fsp
));
1020 do_log(SMB_VFS_OP_PREAD_RECV
, (state
->ret
>= 0), state
->handle
, "%s",
1021 fsp_str_do_log(state
->fsp
));
1027 static ssize_t
smb_full_audit_write(vfs_handle_struct
*handle
, files_struct
*fsp
,
1028 const void *data
, size_t n
)
1032 result
= SMB_VFS_NEXT_WRITE(handle
, fsp
, data
, n
);
1034 do_log(SMB_VFS_OP_WRITE
, (result
>= 0), handle
, "%s",
1035 fsp_str_do_log(fsp
));
1040 static ssize_t
smb_full_audit_pwrite(vfs_handle_struct
*handle
, files_struct
*fsp
,
1041 const void *data
, size_t n
,
1046 result
= SMB_VFS_NEXT_PWRITE(handle
, fsp
, data
, n
, offset
);
1048 do_log(SMB_VFS_OP_PWRITE
, (result
>= 0), handle
, "%s",
1049 fsp_str_do_log(fsp
));
1054 struct smb_full_audit_pwrite_state
{
1055 vfs_handle_struct
*handle
;
1061 static void smb_full_audit_pwrite_done(struct tevent_req
*subreq
);
1063 static struct tevent_req
*smb_full_audit_pwrite_send(
1064 struct vfs_handle_struct
*handle
, TALLOC_CTX
*mem_ctx
,
1065 struct tevent_context
*ev
, struct files_struct
*fsp
,
1066 const void *data
, size_t n
, off_t offset
)
1068 struct tevent_req
*req
, *subreq
;
1069 struct smb_full_audit_pwrite_state
*state
;
1071 req
= tevent_req_create(mem_ctx
, &state
,
1072 struct smb_full_audit_pwrite_state
);
1074 do_log(SMB_VFS_OP_PWRITE_SEND
, false, handle
, "%s",
1075 fsp_str_do_log(fsp
));
1078 state
->handle
= handle
;
1081 subreq
= SMB_VFS_NEXT_PWRITE_SEND(state
, ev
, handle
, fsp
, data
,
1083 if (tevent_req_nomem(subreq
, req
)) {
1084 do_log(SMB_VFS_OP_PWRITE_SEND
, false, handle
, "%s",
1085 fsp_str_do_log(fsp
));
1086 return tevent_req_post(req
, ev
);
1088 tevent_req_set_callback(subreq
, smb_full_audit_pwrite_done
, req
);
1090 do_log(SMB_VFS_OP_PWRITE_SEND
, true, handle
, "%s",
1091 fsp_str_do_log(fsp
));
1095 static void smb_full_audit_pwrite_done(struct tevent_req
*subreq
)
1097 struct tevent_req
*req
= tevent_req_callback_data(
1098 subreq
, struct tevent_req
);
1099 struct smb_full_audit_pwrite_state
*state
= tevent_req_data(
1100 req
, struct smb_full_audit_pwrite_state
);
1102 state
->ret
= SMB_VFS_PWRITE_RECV(subreq
, &state
->err
);
1103 TALLOC_FREE(subreq
);
1104 tevent_req_done(req
);
1107 static ssize_t
smb_full_audit_pwrite_recv(struct tevent_req
*req
, int *err
)
1109 struct smb_full_audit_pwrite_state
*state
= tevent_req_data(
1110 req
, struct smb_full_audit_pwrite_state
);
1112 if (tevent_req_is_unix_error(req
, err
)) {
1113 do_log(SMB_VFS_OP_PWRITE_RECV
, false, state
->handle
, "%s",
1114 fsp_str_do_log(state
->fsp
));
1118 do_log(SMB_VFS_OP_PWRITE_RECV
, (state
->ret
>= 0), state
->handle
, "%s",
1119 fsp_str_do_log(state
->fsp
));
1125 static off_t
smb_full_audit_lseek(vfs_handle_struct
*handle
, files_struct
*fsp
,
1126 off_t offset
, int whence
)
1130 result
= SMB_VFS_NEXT_LSEEK(handle
, fsp
, offset
, whence
);
1132 do_log(SMB_VFS_OP_LSEEK
, (result
!= (ssize_t
)-1), handle
,
1133 "%s", fsp_str_do_log(fsp
));
1138 static ssize_t
smb_full_audit_sendfile(vfs_handle_struct
*handle
, int tofd
,
1139 files_struct
*fromfsp
,
1140 const DATA_BLOB
*hdr
, off_t offset
,
1145 result
= SMB_VFS_NEXT_SENDFILE(handle
, tofd
, fromfsp
, hdr
, offset
, n
);
1147 do_log(SMB_VFS_OP_SENDFILE
, (result
>= 0), handle
,
1148 "%s", fsp_str_do_log(fromfsp
));
1153 static ssize_t
smb_full_audit_recvfile(vfs_handle_struct
*handle
, int fromfd
,
1154 files_struct
*tofsp
,
1160 result
= SMB_VFS_NEXT_RECVFILE(handle
, fromfd
, tofsp
, offset
, n
);
1162 do_log(SMB_VFS_OP_RECVFILE
, (result
>= 0), handle
,
1163 "%s", fsp_str_do_log(tofsp
));
1168 static int smb_full_audit_rename(vfs_handle_struct
*handle
,
1169 const struct smb_filename
*smb_fname_src
,
1170 const struct smb_filename
*smb_fname_dst
)
1174 result
= SMB_VFS_NEXT_RENAME(handle
, smb_fname_src
, smb_fname_dst
);
1176 do_log(SMB_VFS_OP_RENAME
, (result
>= 0), handle
, "%s|%s",
1177 smb_fname_str_do_log(smb_fname_src
),
1178 smb_fname_str_do_log(smb_fname_dst
));
1183 static int smb_full_audit_fsync(vfs_handle_struct
*handle
, files_struct
*fsp
)
1187 result
= SMB_VFS_NEXT_FSYNC(handle
, fsp
);
1189 do_log(SMB_VFS_OP_FSYNC
, (result
>= 0), handle
, "%s",
1190 fsp_str_do_log(fsp
));
1195 struct smb_full_audit_fsync_state
{
1196 vfs_handle_struct
*handle
;
1202 static void smb_full_audit_fsync_done(struct tevent_req
*subreq
);
1204 static struct tevent_req
*smb_full_audit_fsync_send(
1205 struct vfs_handle_struct
*handle
, TALLOC_CTX
*mem_ctx
,
1206 struct tevent_context
*ev
, struct files_struct
*fsp
)
1208 struct tevent_req
*req
, *subreq
;
1209 struct smb_full_audit_fsync_state
*state
;
1211 req
= tevent_req_create(mem_ctx
, &state
,
1212 struct smb_full_audit_fsync_state
);
1214 do_log(SMB_VFS_OP_FSYNC_SEND
, false, handle
, "%s",
1215 fsp_str_do_log(fsp
));
1218 state
->handle
= handle
;
1221 subreq
= SMB_VFS_NEXT_FSYNC_SEND(state
, ev
, handle
, fsp
);
1222 if (tevent_req_nomem(subreq
, req
)) {
1223 do_log(SMB_VFS_OP_FSYNC_SEND
, false, handle
, "%s",
1224 fsp_str_do_log(fsp
));
1225 return tevent_req_post(req
, ev
);
1227 tevent_req_set_callback(subreq
, smb_full_audit_fsync_done
, req
);
1229 do_log(SMB_VFS_OP_FSYNC_SEND
, true, handle
, "%s", fsp_str_do_log(fsp
));
1233 static void smb_full_audit_fsync_done(struct tevent_req
*subreq
)
1235 struct tevent_req
*req
= tevent_req_callback_data(
1236 subreq
, struct tevent_req
);
1237 struct smb_full_audit_fsync_state
*state
= tevent_req_data(
1238 req
, struct smb_full_audit_fsync_state
);
1240 state
->ret
= SMB_VFS_FSYNC_RECV(subreq
, &state
->err
);
1241 TALLOC_FREE(subreq
);
1242 tevent_req_done(req
);
1245 static int smb_full_audit_fsync_recv(struct tevent_req
*req
, int *err
)
1247 struct smb_full_audit_fsync_state
*state
= tevent_req_data(
1248 req
, struct smb_full_audit_fsync_state
);
1250 if (tevent_req_is_unix_error(req
, err
)) {
1251 do_log(SMB_VFS_OP_FSYNC_RECV
, false, state
->handle
, "%s",
1252 fsp_str_do_log(state
->fsp
));
1256 do_log(SMB_VFS_OP_FSYNC_RECV
, (state
->ret
>= 0), state
->handle
, "%s",
1257 fsp_str_do_log(state
->fsp
));
1263 static int smb_full_audit_stat(vfs_handle_struct
*handle
,
1264 struct smb_filename
*smb_fname
)
1268 result
= SMB_VFS_NEXT_STAT(handle
, smb_fname
);
1270 do_log(SMB_VFS_OP_STAT
, (result
>= 0), handle
, "%s",
1271 smb_fname_str_do_log(smb_fname
));
1276 static int smb_full_audit_fstat(vfs_handle_struct
*handle
, files_struct
*fsp
,
1277 SMB_STRUCT_STAT
*sbuf
)
1281 result
= SMB_VFS_NEXT_FSTAT(handle
, fsp
, sbuf
);
1283 do_log(SMB_VFS_OP_FSTAT
, (result
>= 0), handle
, "%s",
1284 fsp_str_do_log(fsp
));
1289 static int smb_full_audit_lstat(vfs_handle_struct
*handle
,
1290 struct smb_filename
*smb_fname
)
1294 result
= SMB_VFS_NEXT_LSTAT(handle
, smb_fname
);
1296 do_log(SMB_VFS_OP_LSTAT
, (result
>= 0), handle
, "%s",
1297 smb_fname_str_do_log(smb_fname
));
1302 static uint64_t smb_full_audit_get_alloc_size(vfs_handle_struct
*handle
,
1303 files_struct
*fsp
, const SMB_STRUCT_STAT
*sbuf
)
1307 result
= SMB_VFS_NEXT_GET_ALLOC_SIZE(handle
, fsp
, sbuf
);
1309 do_log(SMB_VFS_OP_GET_ALLOC_SIZE
, (result
!= (uint64_t)-1), handle
,
1315 static int smb_full_audit_unlink(vfs_handle_struct
*handle
,
1316 const struct smb_filename
*smb_fname
)
1320 result
= SMB_VFS_NEXT_UNLINK(handle
, smb_fname
);
1322 do_log(SMB_VFS_OP_UNLINK
, (result
>= 0), handle
, "%s",
1323 smb_fname_str_do_log(smb_fname
));
1328 static int smb_full_audit_chmod(vfs_handle_struct
*handle
,
1329 const char *path
, mode_t mode
)
1333 result
= SMB_VFS_NEXT_CHMOD(handle
, path
, mode
);
1335 do_log(SMB_VFS_OP_CHMOD
, (result
>= 0), handle
, "%s|%o", path
, mode
);
1340 static int smb_full_audit_fchmod(vfs_handle_struct
*handle
, files_struct
*fsp
,
1345 result
= SMB_VFS_NEXT_FCHMOD(handle
, fsp
, mode
);
1347 do_log(SMB_VFS_OP_FCHMOD
, (result
>= 0), handle
,
1348 "%s|%o", fsp_str_do_log(fsp
), mode
);
1353 static int smb_full_audit_chown(vfs_handle_struct
*handle
,
1354 const char *path
, uid_t uid
, gid_t gid
)
1358 result
= SMB_VFS_NEXT_CHOWN(handle
, path
, uid
, gid
);
1360 do_log(SMB_VFS_OP_CHOWN
, (result
>= 0), handle
, "%s|%ld|%ld",
1361 path
, (long int)uid
, (long int)gid
);
1366 static int smb_full_audit_fchown(vfs_handle_struct
*handle
, files_struct
*fsp
,
1367 uid_t uid
, gid_t gid
)
1371 result
= SMB_VFS_NEXT_FCHOWN(handle
, fsp
, uid
, gid
);
1373 do_log(SMB_VFS_OP_FCHOWN
, (result
>= 0), handle
, "%s|%ld|%ld",
1374 fsp_str_do_log(fsp
), (long int)uid
, (long int)gid
);
1379 static int smb_full_audit_lchown(vfs_handle_struct
*handle
,
1380 const char *path
, uid_t uid
, gid_t gid
)
1384 result
= SMB_VFS_NEXT_LCHOWN(handle
, path
, uid
, gid
);
1386 do_log(SMB_VFS_OP_LCHOWN
, (result
>= 0), handle
, "%s|%ld|%ld",
1387 path
, (long int)uid
, (long int)gid
);
1392 static int smb_full_audit_chdir(vfs_handle_struct
*handle
,
1397 result
= SMB_VFS_NEXT_CHDIR(handle
, path
);
1399 do_log(SMB_VFS_OP_CHDIR
, (result
>= 0), handle
, "chdir|%s", path
);
1404 static char *smb_full_audit_getwd(vfs_handle_struct
*handle
)
1408 result
= SMB_VFS_NEXT_GETWD(handle
);
1410 do_log(SMB_VFS_OP_GETWD
, (result
!= NULL
), handle
, "%s",
1411 result
== NULL
? "" : result
);
1416 static int smb_full_audit_ntimes(vfs_handle_struct
*handle
,
1417 const struct smb_filename
*smb_fname
,
1418 struct smb_file_time
*ft
)
1422 result
= SMB_VFS_NEXT_NTIMES(handle
, smb_fname
, ft
);
1424 do_log(SMB_VFS_OP_NTIMES
, (result
>= 0), handle
, "%s",
1425 smb_fname_str_do_log(smb_fname
));
1430 static int smb_full_audit_ftruncate(vfs_handle_struct
*handle
, files_struct
*fsp
,
1435 result
= SMB_VFS_NEXT_FTRUNCATE(handle
, fsp
, len
);
1437 do_log(SMB_VFS_OP_FTRUNCATE
, (result
>= 0), handle
,
1438 "%s", fsp_str_do_log(fsp
));
1443 static int smb_full_audit_fallocate(vfs_handle_struct
*handle
, files_struct
*fsp
,
1444 enum vfs_fallocate_mode mode
,
1450 result
= SMB_VFS_NEXT_FALLOCATE(handle
, fsp
, mode
, offset
, len
);
1452 do_log(SMB_VFS_OP_FALLOCATE
, (result
>= 0), handle
,
1453 "%s", fsp_str_do_log(fsp
));
1458 static bool smb_full_audit_lock(vfs_handle_struct
*handle
, files_struct
*fsp
,
1459 int op
, off_t offset
, off_t count
, int type
)
1463 result
= SMB_VFS_NEXT_LOCK(handle
, fsp
, op
, offset
, count
, type
);
1465 do_log(SMB_VFS_OP_LOCK
, result
, handle
, "%s", fsp_str_do_log(fsp
));
1470 static int smb_full_audit_kernel_flock(struct vfs_handle_struct
*handle
,
1471 struct files_struct
*fsp
,
1472 uint32 share_mode
, uint32 access_mask
)
1476 result
= SMB_VFS_NEXT_KERNEL_FLOCK(handle
, fsp
, share_mode
, access_mask
);
1478 do_log(SMB_VFS_OP_KERNEL_FLOCK
, (result
>= 0), handle
, "%s",
1479 fsp_str_do_log(fsp
));
1484 static int smb_full_audit_linux_setlease(vfs_handle_struct
*handle
, files_struct
*fsp
,
1489 result
= SMB_VFS_NEXT_LINUX_SETLEASE(handle
, fsp
, leasetype
);
1491 do_log(SMB_VFS_OP_LINUX_SETLEASE
, (result
>= 0), handle
, "%s",
1492 fsp_str_do_log(fsp
));
1497 static bool smb_full_audit_getlock(vfs_handle_struct
*handle
, files_struct
*fsp
,
1498 off_t
*poffset
, off_t
*pcount
, int *ptype
, pid_t
*ppid
)
1502 result
= SMB_VFS_NEXT_GETLOCK(handle
, fsp
, poffset
, pcount
, ptype
, ppid
);
1504 do_log(SMB_VFS_OP_GETLOCK
, result
, handle
, "%s", fsp_str_do_log(fsp
));
1509 static int smb_full_audit_symlink(vfs_handle_struct
*handle
,
1510 const char *oldpath
, const char *newpath
)
1514 result
= SMB_VFS_NEXT_SYMLINK(handle
, oldpath
, newpath
);
1516 do_log(SMB_VFS_OP_SYMLINK
, (result
>= 0), handle
,
1517 "%s|%s", oldpath
, newpath
);
1522 static int smb_full_audit_readlink(vfs_handle_struct
*handle
,
1523 const char *path
, char *buf
, size_t bufsiz
)
1527 result
= SMB_VFS_NEXT_READLINK(handle
, path
, buf
, bufsiz
);
1529 do_log(SMB_VFS_OP_READLINK
, (result
>= 0), handle
, "%s", path
);
1534 static int smb_full_audit_link(vfs_handle_struct
*handle
,
1535 const char *oldpath
, const char *newpath
)
1539 result
= SMB_VFS_NEXT_LINK(handle
, oldpath
, newpath
);
1541 do_log(SMB_VFS_OP_LINK
, (result
>= 0), handle
,
1542 "%s|%s", oldpath
, newpath
);
1547 static int smb_full_audit_mknod(vfs_handle_struct
*handle
,
1548 const char *pathname
, mode_t mode
, SMB_DEV_T dev
)
1552 result
= SMB_VFS_NEXT_MKNOD(handle
, pathname
, mode
, dev
);
1554 do_log(SMB_VFS_OP_MKNOD
, (result
>= 0), handle
, "%s", pathname
);
1559 static char *smb_full_audit_realpath(vfs_handle_struct
*handle
,
1564 result
= SMB_VFS_NEXT_REALPATH(handle
, path
);
1566 do_log(SMB_VFS_OP_REALPATH
, (result
!= NULL
), handle
, "%s", path
);
1571 static NTSTATUS
smb_full_audit_notify_watch(struct vfs_handle_struct
*handle
,
1572 struct sys_notify_context
*ctx
,
1575 uint32_t *subdir_filter
,
1576 void (*callback
)(struct sys_notify_context
*ctx
,
1578 struct notify_event
*ev
),
1579 void *private_data
, void *handle_p
)
1583 result
= SMB_VFS_NEXT_NOTIFY_WATCH(handle
, ctx
, path
,
1584 filter
, subdir_filter
, callback
,
1585 private_data
, handle_p
);
1587 do_log(SMB_VFS_OP_NOTIFY_WATCH
, NT_STATUS_IS_OK(result
), handle
, "");
1592 static int smb_full_audit_chflags(vfs_handle_struct
*handle
,
1593 const char *path
, unsigned int flags
)
1597 result
= SMB_VFS_NEXT_CHFLAGS(handle
, path
, flags
);
1599 do_log(SMB_VFS_OP_CHFLAGS
, (result
!= 0), handle
, "%s", path
);
1604 static struct file_id
smb_full_audit_file_id_create(struct vfs_handle_struct
*handle
,
1605 const SMB_STRUCT_STAT
*sbuf
)
1607 struct file_id id_zero
;
1608 struct file_id result
;
1610 ZERO_STRUCT(id_zero
);
1612 result
= SMB_VFS_NEXT_FILE_ID_CREATE(handle
, sbuf
);
1614 do_log(SMB_VFS_OP_FILE_ID_CREATE
,
1615 !file_id_equal(&id_zero
, &result
),
1616 handle
, "%s", file_id_string_tos(&result
));
1621 static NTSTATUS
smb_full_audit_streaminfo(vfs_handle_struct
*handle
,
1622 struct files_struct
*fsp
,
1624 TALLOC_CTX
*mem_ctx
,
1625 unsigned int *pnum_streams
,
1626 struct stream_struct
**pstreams
)
1630 result
= SMB_VFS_NEXT_STREAMINFO(handle
, fsp
, fname
, mem_ctx
,
1631 pnum_streams
, pstreams
);
1633 do_log(SMB_VFS_OP_STREAMINFO
, NT_STATUS_IS_OK(result
), handle
,
1639 static int smb_full_audit_get_real_filename(struct vfs_handle_struct
*handle
,
1642 TALLOC_CTX
*mem_ctx
,
1647 result
= SMB_VFS_NEXT_GET_REAL_FILENAME(handle
, path
, name
, mem_ctx
,
1650 do_log(SMB_VFS_OP_GET_REAL_FILENAME
, (result
== 0), handle
,
1651 "%s/%s->%s", path
, name
, (result
== 0) ? "" : *found_name
);
1656 static const char *smb_full_audit_connectpath(vfs_handle_struct
*handle
,
1661 result
= SMB_VFS_NEXT_CONNECTPATH(handle
, fname
);
1663 do_log(SMB_VFS_OP_CONNECTPATH
, result
!= NULL
, handle
,
1669 static NTSTATUS
smb_full_audit_brl_lock_windows(struct vfs_handle_struct
*handle
,
1670 struct byte_range_lock
*br_lck
,
1671 struct lock_struct
*plock
,
1673 struct blocking_lock_record
*blr
)
1677 result
= SMB_VFS_NEXT_BRL_LOCK_WINDOWS(handle
, br_lck
, plock
,
1678 blocking_lock
, blr
);
1680 do_log(SMB_VFS_OP_BRL_LOCK_WINDOWS
, NT_STATUS_IS_OK(result
), handle
,
1681 "%s:%llu-%llu. type=%d. blocking=%d", fsp_str_do_log(br_lck
->fsp
),
1682 plock
->start
, plock
->size
, plock
->lock_type
, blocking_lock
);
1687 static bool smb_full_audit_brl_unlock_windows(struct vfs_handle_struct
*handle
,
1688 struct messaging_context
*msg_ctx
,
1689 struct byte_range_lock
*br_lck
,
1690 const struct lock_struct
*plock
)
1694 result
= SMB_VFS_NEXT_BRL_UNLOCK_WINDOWS(handle
, msg_ctx
, br_lck
,
1697 do_log(SMB_VFS_OP_BRL_UNLOCK_WINDOWS
, (result
== 0), handle
,
1698 "%s:%llu-%llu:%d", fsp_str_do_log(br_lck
->fsp
), plock
->start
,
1699 plock
->size
, plock
->lock_type
);
1704 static bool smb_full_audit_brl_cancel_windows(struct vfs_handle_struct
*handle
,
1705 struct byte_range_lock
*br_lck
,
1706 struct lock_struct
*plock
,
1707 struct blocking_lock_record
*blr
)
1711 result
= SMB_VFS_NEXT_BRL_CANCEL_WINDOWS(handle
, br_lck
, plock
, blr
);
1713 do_log(SMB_VFS_OP_BRL_CANCEL_WINDOWS
, (result
== 0), handle
,
1714 "%s:%llu-%llu:%d", fsp_str_do_log(br_lck
->fsp
), plock
->start
,
1720 static bool smb_full_audit_strict_lock(struct vfs_handle_struct
*handle
,
1721 struct files_struct
*fsp
,
1722 struct lock_struct
*plock
)
1726 result
= SMB_VFS_NEXT_STRICT_LOCK(handle
, fsp
, plock
);
1728 do_log(SMB_VFS_OP_STRICT_LOCK
, result
, handle
,
1729 "%s:%llu-%llu:%d", fsp_str_do_log(fsp
), plock
->start
,
1735 static void smb_full_audit_strict_unlock(struct vfs_handle_struct
*handle
,
1736 struct files_struct
*fsp
,
1737 struct lock_struct
*plock
)
1739 SMB_VFS_NEXT_STRICT_UNLOCK(handle
, fsp
, plock
);
1741 do_log(SMB_VFS_OP_STRICT_UNLOCK
, true, handle
,
1742 "%s:%llu-%llu:%d", fsp_str_do_log(fsp
), plock
->start
,
1746 static NTSTATUS
smb_full_audit_translate_name(struct vfs_handle_struct
*handle
,
1748 enum vfs_translate_direction direction
,
1749 TALLOC_CTX
*mem_ctx
,
1754 result
= SMB_VFS_NEXT_TRANSLATE_NAME(handle
, name
, direction
, mem_ctx
,
1757 do_log(SMB_VFS_OP_TRANSLATE_NAME
, NT_STATUS_IS_OK(result
), handle
, "");
1762 static NTSTATUS
smb_full_audit_fget_nt_acl(vfs_handle_struct
*handle
, files_struct
*fsp
,
1763 uint32 security_info
,
1764 struct security_descriptor
**ppdesc
)
1768 result
= SMB_VFS_NEXT_FGET_NT_ACL(handle
, fsp
, security_info
, ppdesc
);
1770 do_log(SMB_VFS_OP_FGET_NT_ACL
, NT_STATUS_IS_OK(result
), handle
,
1771 "%s", fsp_str_do_log(fsp
));
1776 static NTSTATUS
smb_full_audit_get_nt_acl(vfs_handle_struct
*handle
,
1778 uint32 security_info
,
1779 struct security_descriptor
**ppdesc
)
1783 result
= SMB_VFS_NEXT_GET_NT_ACL(handle
, name
, security_info
, ppdesc
);
1785 do_log(SMB_VFS_OP_GET_NT_ACL
, NT_STATUS_IS_OK(result
), handle
,
1791 static NTSTATUS
smb_full_audit_fset_nt_acl(vfs_handle_struct
*handle
, files_struct
*fsp
,
1792 uint32 security_info_sent
,
1793 const struct security_descriptor
*psd
)
1797 result
= SMB_VFS_NEXT_FSET_NT_ACL(handle
, fsp
, security_info_sent
, psd
);
1799 do_log(SMB_VFS_OP_FSET_NT_ACL
, NT_STATUS_IS_OK(result
), handle
, "%s",
1800 fsp_str_do_log(fsp
));
1805 static int smb_full_audit_chmod_acl(vfs_handle_struct
*handle
,
1806 const char *path
, mode_t mode
)
1810 result
= SMB_VFS_NEXT_CHMOD_ACL(handle
, path
, mode
);
1812 do_log(SMB_VFS_OP_CHMOD_ACL
, (result
>= 0), handle
,
1813 "%s|%o", path
, mode
);
1818 static int smb_full_audit_fchmod_acl(vfs_handle_struct
*handle
, files_struct
*fsp
,
1823 result
= SMB_VFS_NEXT_FCHMOD_ACL(handle
, fsp
, mode
);
1825 do_log(SMB_VFS_OP_FCHMOD_ACL
, (result
>= 0), handle
,
1826 "%s|%o", fsp_str_do_log(fsp
), mode
);
1831 static int smb_full_audit_sys_acl_get_entry(vfs_handle_struct
*handle
,
1833 SMB_ACL_T theacl
, int entry_id
,
1834 SMB_ACL_ENTRY_T
*entry_p
)
1838 result
= SMB_VFS_NEXT_SYS_ACL_GET_ENTRY(handle
, theacl
, entry_id
,
1841 do_log(SMB_VFS_OP_SYS_ACL_GET_ENTRY
, (result
>= 0), handle
,
1847 static int smb_full_audit_sys_acl_get_tag_type(vfs_handle_struct
*handle
,
1849 SMB_ACL_ENTRY_T entry_d
,
1850 SMB_ACL_TAG_T
*tag_type_p
)
1854 result
= SMB_VFS_NEXT_SYS_ACL_GET_TAG_TYPE(handle
, entry_d
,
1857 do_log(SMB_VFS_OP_SYS_ACL_GET_TAG_TYPE
, (result
>= 0), handle
,
1863 static int smb_full_audit_sys_acl_get_permset(vfs_handle_struct
*handle
,
1865 SMB_ACL_ENTRY_T entry_d
,
1866 SMB_ACL_PERMSET_T
*permset_p
)
1870 result
= SMB_VFS_NEXT_SYS_ACL_GET_PERMSET(handle
, entry_d
,
1873 do_log(SMB_VFS_OP_SYS_ACL_GET_PERMSET
, (result
>= 0), handle
,
1879 static void * smb_full_audit_sys_acl_get_qualifier(vfs_handle_struct
*handle
,
1881 SMB_ACL_ENTRY_T entry_d
)
1885 result
= SMB_VFS_NEXT_SYS_ACL_GET_QUALIFIER(handle
, entry_d
);
1887 do_log(SMB_VFS_OP_SYS_ACL_GET_QUALIFIER
, (result
!= NULL
), handle
,
1893 static SMB_ACL_T
smb_full_audit_sys_acl_get_file(vfs_handle_struct
*handle
,
1895 SMB_ACL_TYPE_T type
)
1899 result
= SMB_VFS_NEXT_SYS_ACL_GET_FILE(handle
, path_p
, type
);
1901 do_log(SMB_VFS_OP_SYS_ACL_GET_FILE
, (result
!= NULL
), handle
,
1907 static SMB_ACL_T
smb_full_audit_sys_acl_get_fd(vfs_handle_struct
*handle
,
1912 result
= SMB_VFS_NEXT_SYS_ACL_GET_FD(handle
, fsp
);
1914 do_log(SMB_VFS_OP_SYS_ACL_GET_FD
, (result
!= NULL
), handle
,
1915 "%s", fsp_str_do_log(fsp
));
1920 static int smb_full_audit_sys_acl_clear_perms(vfs_handle_struct
*handle
,
1922 SMB_ACL_PERMSET_T permset
)
1926 result
= SMB_VFS_NEXT_SYS_ACL_CLEAR_PERMS(handle
, permset
);
1928 do_log(SMB_VFS_OP_SYS_ACL_CLEAR_PERMS
, (result
>= 0), handle
,
1934 static int smb_full_audit_sys_acl_add_perm(vfs_handle_struct
*handle
,
1936 SMB_ACL_PERMSET_T permset
,
1937 SMB_ACL_PERM_T perm
)
1941 result
= SMB_VFS_NEXT_SYS_ACL_ADD_PERM(handle
, permset
, perm
);
1943 do_log(SMB_VFS_OP_SYS_ACL_ADD_PERM
, (result
>= 0), handle
,
1949 static char * smb_full_audit_sys_acl_to_text(vfs_handle_struct
*handle
,
1955 result
= SMB_VFS_NEXT_SYS_ACL_TO_TEXT(handle
, theacl
, plen
);
1957 do_log(SMB_VFS_OP_SYS_ACL_TO_TEXT
, (result
!= NULL
), handle
,
1963 static SMB_ACL_T
smb_full_audit_sys_acl_init(vfs_handle_struct
*handle
,
1969 result
= SMB_VFS_NEXT_SYS_ACL_INIT(handle
, count
);
1971 do_log(SMB_VFS_OP_SYS_ACL_INIT
, (result
!= NULL
), handle
,
1977 static int smb_full_audit_sys_acl_create_entry(vfs_handle_struct
*handle
,
1979 SMB_ACL_ENTRY_T
*pentry
)
1983 result
= SMB_VFS_NEXT_SYS_ACL_CREATE_ENTRY(handle
, pacl
, pentry
);
1985 do_log(SMB_VFS_OP_SYS_ACL_CREATE_ENTRY
, (result
>= 0), handle
,
1991 static int smb_full_audit_sys_acl_set_tag_type(vfs_handle_struct
*handle
,
1993 SMB_ACL_ENTRY_T entry
,
1994 SMB_ACL_TAG_T tagtype
)
1998 result
= SMB_VFS_NEXT_SYS_ACL_SET_TAG_TYPE(handle
, entry
,
2001 do_log(SMB_VFS_OP_SYS_ACL_SET_TAG_TYPE
, (result
>= 0), handle
,
2007 static int smb_full_audit_sys_acl_set_qualifier(vfs_handle_struct
*handle
,
2009 SMB_ACL_ENTRY_T entry
,
2014 result
= SMB_VFS_NEXT_SYS_ACL_SET_QUALIFIER(handle
, entry
, qual
);
2016 do_log(SMB_VFS_OP_SYS_ACL_SET_QUALIFIER
, (result
>= 0), handle
,
2022 static int smb_full_audit_sys_acl_set_permset(vfs_handle_struct
*handle
,
2024 SMB_ACL_ENTRY_T entry
,
2025 SMB_ACL_PERMSET_T permset
)
2029 result
= SMB_VFS_NEXT_SYS_ACL_SET_PERMSET(handle
, entry
, permset
);
2031 do_log(SMB_VFS_OP_SYS_ACL_SET_PERMSET
, (result
>= 0), handle
,
2037 static int smb_full_audit_sys_acl_valid(vfs_handle_struct
*handle
,
2043 result
= SMB_VFS_NEXT_SYS_ACL_VALID(handle
, theacl
);
2045 do_log(SMB_VFS_OP_SYS_ACL_VALID
, (result
>= 0), handle
,
2051 static int smb_full_audit_sys_acl_set_file(vfs_handle_struct
*handle
,
2053 const char *name
, SMB_ACL_TYPE_T acltype
,
2058 result
= SMB_VFS_NEXT_SYS_ACL_SET_FILE(handle
, name
, acltype
,
2061 do_log(SMB_VFS_OP_SYS_ACL_SET_FILE
, (result
>= 0), handle
,
2067 static int smb_full_audit_sys_acl_set_fd(vfs_handle_struct
*handle
, files_struct
*fsp
,
2072 result
= SMB_VFS_NEXT_SYS_ACL_SET_FD(handle
, fsp
, theacl
);
2074 do_log(SMB_VFS_OP_SYS_ACL_SET_FD
, (result
>= 0), handle
,
2075 "%s", fsp_str_do_log(fsp
));
2080 static int smb_full_audit_sys_acl_delete_def_file(vfs_handle_struct
*handle
,
2086 result
= SMB_VFS_NEXT_SYS_ACL_DELETE_DEF_FILE(handle
, path
);
2088 do_log(SMB_VFS_OP_SYS_ACL_DELETE_DEF_FILE
, (result
>= 0), handle
,
2094 static int smb_full_audit_sys_acl_get_perm(vfs_handle_struct
*handle
,
2096 SMB_ACL_PERMSET_T permset
,
2097 SMB_ACL_PERM_T perm
)
2101 result
= SMB_VFS_NEXT_SYS_ACL_GET_PERM(handle
, permset
, perm
);
2103 do_log(SMB_VFS_OP_SYS_ACL_GET_PERM
, (result
>= 0), handle
,
2109 static int smb_full_audit_sys_acl_free_text(vfs_handle_struct
*handle
,
2115 result
= SMB_VFS_NEXT_SYS_ACL_FREE_TEXT(handle
, text
);
2117 do_log(SMB_VFS_OP_SYS_ACL_FREE_TEXT
, (result
>= 0), handle
,
2123 static int smb_full_audit_sys_acl_free_acl(vfs_handle_struct
*handle
,
2125 SMB_ACL_T posix_acl
)
2129 result
= SMB_VFS_NEXT_SYS_ACL_FREE_ACL(handle
, posix_acl
);
2131 do_log(SMB_VFS_OP_SYS_ACL_FREE_ACL
, (result
>= 0), handle
,
2137 static int smb_full_audit_sys_acl_free_qualifier(vfs_handle_struct
*handle
,
2139 SMB_ACL_TAG_T tagtype
)
2143 result
= SMB_VFS_NEXT_SYS_ACL_FREE_QUALIFIER(handle
, qualifier
,
2146 do_log(SMB_VFS_OP_SYS_ACL_FREE_QUALIFIER
, (result
>= 0), handle
,
2152 static ssize_t
smb_full_audit_getxattr(struct vfs_handle_struct
*handle
,
2154 const char *name
, void *value
, size_t size
)
2158 result
= SMB_VFS_NEXT_GETXATTR(handle
, path
, name
, value
, size
);
2160 do_log(SMB_VFS_OP_GETXATTR
, (result
>= 0), handle
,
2161 "%s|%s", path
, name
);
2166 static ssize_t
smb_full_audit_fgetxattr(struct vfs_handle_struct
*handle
,
2167 struct files_struct
*fsp
,
2168 const char *name
, void *value
, size_t size
)
2172 result
= SMB_VFS_NEXT_FGETXATTR(handle
, fsp
, name
, value
, size
);
2174 do_log(SMB_VFS_OP_FGETXATTR
, (result
>= 0), handle
,
2175 "%s|%s", fsp_str_do_log(fsp
), name
);
2180 static ssize_t
smb_full_audit_listxattr(struct vfs_handle_struct
*handle
,
2181 const char *path
, char *list
, size_t size
)
2185 result
= SMB_VFS_NEXT_LISTXATTR(handle
, path
, list
, size
);
2187 do_log(SMB_VFS_OP_LISTXATTR
, (result
>= 0), handle
, "%s", path
);
2192 static ssize_t
smb_full_audit_flistxattr(struct vfs_handle_struct
*handle
,
2193 struct files_struct
*fsp
, char *list
,
2198 result
= SMB_VFS_NEXT_FLISTXATTR(handle
, fsp
, list
, size
);
2200 do_log(SMB_VFS_OP_FLISTXATTR
, (result
>= 0), handle
,
2201 "%s", fsp_str_do_log(fsp
));
2206 static int smb_full_audit_removexattr(struct vfs_handle_struct
*handle
,
2212 result
= SMB_VFS_NEXT_REMOVEXATTR(handle
, path
, name
);
2214 do_log(SMB_VFS_OP_REMOVEXATTR
, (result
>= 0), handle
,
2215 "%s|%s", path
, name
);
2220 static int smb_full_audit_fremovexattr(struct vfs_handle_struct
*handle
,
2221 struct files_struct
*fsp
,
2226 result
= SMB_VFS_NEXT_FREMOVEXATTR(handle
, fsp
, name
);
2228 do_log(SMB_VFS_OP_FREMOVEXATTR
, (result
>= 0), handle
,
2229 "%s|%s", fsp_str_do_log(fsp
), name
);
2234 static int smb_full_audit_setxattr(struct vfs_handle_struct
*handle
,
2236 const char *name
, const void *value
, size_t size
,
2241 result
= SMB_VFS_NEXT_SETXATTR(handle
, path
, name
, value
, size
,
2244 do_log(SMB_VFS_OP_SETXATTR
, (result
>= 0), handle
,
2245 "%s|%s", path
, name
);
2250 static int smb_full_audit_fsetxattr(struct vfs_handle_struct
*handle
,
2251 struct files_struct
*fsp
, const char *name
,
2252 const void *value
, size_t size
, int flags
)
2256 result
= SMB_VFS_NEXT_FSETXATTR(handle
, fsp
, name
, value
, size
, flags
);
2258 do_log(SMB_VFS_OP_FSETXATTR
, (result
>= 0), handle
,
2259 "%s|%s", fsp_str_do_log(fsp
), name
);
2264 static bool smb_full_audit_aio_force(struct vfs_handle_struct
*handle
,
2265 struct files_struct
*fsp
)
2269 result
= SMB_VFS_NEXT_AIO_FORCE(handle
, fsp
);
2270 do_log(SMB_VFS_OP_AIO_FORCE
, result
, handle
,
2271 "%s", fsp_str_do_log(fsp
));
2276 static bool smb_full_audit_is_offline(struct vfs_handle_struct
*handle
,
2277 const struct smb_filename
*fname
,
2278 SMB_STRUCT_STAT
*sbuf
)
2282 result
= SMB_VFS_NEXT_IS_OFFLINE(handle
, fname
, sbuf
);
2283 do_log(SMB_VFS_OP_IS_OFFLINE
, result
, handle
, "%s",
2284 smb_fname_str_do_log(fname
));
2288 static int smb_full_audit_set_offline(struct vfs_handle_struct
*handle
,
2289 const struct smb_filename
*fname
)
2293 result
= SMB_VFS_NEXT_SET_OFFLINE(handle
, fname
);
2294 do_log(SMB_VFS_OP_SET_OFFLINE
, result
>= 0, handle
, "%s",
2295 smb_fname_str_do_log(fname
));
2299 static struct vfs_fn_pointers vfs_full_audit_fns
= {
2301 /* Disk operations */
2303 .connect_fn
= smb_full_audit_connect
,
2304 .disconnect_fn
= smb_full_audit_disconnect
,
2305 .disk_free_fn
= smb_full_audit_disk_free
,
2306 .get_quota_fn
= smb_full_audit_get_quota
,
2307 .set_quota_fn
= smb_full_audit_set_quota
,
2308 .get_shadow_copy_data_fn
= smb_full_audit_get_shadow_copy_data
,
2309 .statvfs_fn
= smb_full_audit_statvfs
,
2310 .fs_capabilities_fn
= smb_full_audit_fs_capabilities
,
2311 .opendir_fn
= smb_full_audit_opendir
,
2312 .fdopendir_fn
= smb_full_audit_fdopendir
,
2313 .readdir_fn
= smb_full_audit_readdir
,
2314 .seekdir_fn
= smb_full_audit_seekdir
,
2315 .telldir_fn
= smb_full_audit_telldir
,
2316 .rewind_dir_fn
= smb_full_audit_rewinddir
,
2317 .mkdir_fn
= smb_full_audit_mkdir
,
2318 .rmdir_fn
= smb_full_audit_rmdir
,
2319 .closedir_fn
= smb_full_audit_closedir
,
2320 .init_search_op_fn
= smb_full_audit_init_search_op
,
2321 .open_fn
= smb_full_audit_open
,
2322 .create_file_fn
= smb_full_audit_create_file
,
2323 .close_fn
= smb_full_audit_close
,
2324 .read_fn
= smb_full_audit_read
,
2325 .pread_fn
= smb_full_audit_pread
,
2326 .pread_send_fn
= smb_full_audit_pread_send
,
2327 .pread_recv_fn
= smb_full_audit_pread_recv
,
2328 .write_fn
= smb_full_audit_write
,
2329 .pwrite_fn
= smb_full_audit_pwrite
,
2330 .pwrite_send_fn
= smb_full_audit_pwrite_send
,
2331 .pwrite_recv_fn
= smb_full_audit_pwrite_recv
,
2332 .lseek_fn
= smb_full_audit_lseek
,
2333 .sendfile_fn
= smb_full_audit_sendfile
,
2334 .recvfile_fn
= smb_full_audit_recvfile
,
2335 .rename_fn
= smb_full_audit_rename
,
2336 .fsync_fn
= smb_full_audit_fsync
,
2337 .fsync_send_fn
= smb_full_audit_fsync_send
,
2338 .fsync_recv_fn
= smb_full_audit_fsync_recv
,
2339 .stat_fn
= smb_full_audit_stat
,
2340 .fstat_fn
= smb_full_audit_fstat
,
2341 .lstat_fn
= smb_full_audit_lstat
,
2342 .get_alloc_size_fn
= smb_full_audit_get_alloc_size
,
2343 .unlink_fn
= smb_full_audit_unlink
,
2344 .chmod_fn
= smb_full_audit_chmod
,
2345 .fchmod_fn
= smb_full_audit_fchmod
,
2346 .chown_fn
= smb_full_audit_chown
,
2347 .fchown_fn
= smb_full_audit_fchown
,
2348 .lchown_fn
= smb_full_audit_lchown
,
2349 .chdir_fn
= smb_full_audit_chdir
,
2350 .getwd_fn
= smb_full_audit_getwd
,
2351 .ntimes_fn
= smb_full_audit_ntimes
,
2352 .ftruncate_fn
= smb_full_audit_ftruncate
,
2353 .fallocate_fn
= smb_full_audit_fallocate
,
2354 .lock_fn
= smb_full_audit_lock
,
2355 .kernel_flock_fn
= smb_full_audit_kernel_flock
,
2356 .linux_setlease_fn
= smb_full_audit_linux_setlease
,
2357 .getlock_fn
= smb_full_audit_getlock
,
2358 .symlink_fn
= smb_full_audit_symlink
,
2359 .readlink_fn
= smb_full_audit_readlink
,
2360 .link_fn
= smb_full_audit_link
,
2361 .mknod_fn
= smb_full_audit_mknod
,
2362 .realpath_fn
= smb_full_audit_realpath
,
2363 .notify_watch_fn
= smb_full_audit_notify_watch
,
2364 .chflags_fn
= smb_full_audit_chflags
,
2365 .file_id_create_fn
= smb_full_audit_file_id_create
,
2366 .streaminfo_fn
= smb_full_audit_streaminfo
,
2367 .get_real_filename_fn
= smb_full_audit_get_real_filename
,
2368 .connectpath_fn
= smb_full_audit_connectpath
,
2369 .brl_lock_windows_fn
= smb_full_audit_brl_lock_windows
,
2370 .brl_unlock_windows_fn
= smb_full_audit_brl_unlock_windows
,
2371 .brl_cancel_windows_fn
= smb_full_audit_brl_cancel_windows
,
2372 .strict_lock_fn
= smb_full_audit_strict_lock
,
2373 .strict_unlock_fn
= smb_full_audit_strict_unlock
,
2374 .translate_name_fn
= smb_full_audit_translate_name
,
2375 .fget_nt_acl_fn
= smb_full_audit_fget_nt_acl
,
2376 .get_nt_acl_fn
= smb_full_audit_get_nt_acl
,
2377 .fset_nt_acl_fn
= smb_full_audit_fset_nt_acl
,
2378 .chmod_acl_fn
= smb_full_audit_chmod_acl
,
2379 .fchmod_acl_fn
= smb_full_audit_fchmod_acl
,
2380 .sys_acl_get_entry_fn
= smb_full_audit_sys_acl_get_entry
,
2381 .sys_acl_get_tag_type_fn
= smb_full_audit_sys_acl_get_tag_type
,
2382 .sys_acl_get_permset_fn
= smb_full_audit_sys_acl_get_permset
,
2383 .sys_acl_get_qualifier_fn
= smb_full_audit_sys_acl_get_qualifier
,
2384 .sys_acl_get_file_fn
= smb_full_audit_sys_acl_get_file
,
2385 .sys_acl_get_fd_fn
= smb_full_audit_sys_acl_get_fd
,
2386 .sys_acl_clear_perms_fn
= smb_full_audit_sys_acl_clear_perms
,
2387 .sys_acl_add_perm_fn
= smb_full_audit_sys_acl_add_perm
,
2388 .sys_acl_to_text_fn
= smb_full_audit_sys_acl_to_text
,
2389 .sys_acl_init_fn
= smb_full_audit_sys_acl_init
,
2390 .sys_acl_create_entry_fn
= smb_full_audit_sys_acl_create_entry
,
2391 .sys_acl_set_tag_type_fn
= smb_full_audit_sys_acl_set_tag_type
,
2392 .sys_acl_set_qualifier_fn
= smb_full_audit_sys_acl_set_qualifier
,
2393 .sys_acl_set_permset_fn
= smb_full_audit_sys_acl_set_permset
,
2394 .sys_acl_valid_fn
= smb_full_audit_sys_acl_valid
,
2395 .sys_acl_set_file_fn
= smb_full_audit_sys_acl_set_file
,
2396 .sys_acl_set_fd_fn
= smb_full_audit_sys_acl_set_fd
,
2397 .sys_acl_delete_def_file_fn
= smb_full_audit_sys_acl_delete_def_file
,
2398 .sys_acl_get_perm_fn
= smb_full_audit_sys_acl_get_perm
,
2399 .sys_acl_free_text_fn
= smb_full_audit_sys_acl_free_text
,
2400 .sys_acl_free_acl_fn
= smb_full_audit_sys_acl_free_acl
,
2401 .sys_acl_free_qualifier_fn
= smb_full_audit_sys_acl_free_qualifier
,
2402 .getxattr_fn
= smb_full_audit_getxattr
,
2403 .fgetxattr_fn
= smb_full_audit_fgetxattr
,
2404 .listxattr_fn
= smb_full_audit_listxattr
,
2405 .flistxattr_fn
= smb_full_audit_flistxattr
,
2406 .removexattr_fn
= smb_full_audit_removexattr
,
2407 .fremovexattr_fn
= smb_full_audit_fremovexattr
,
2408 .setxattr_fn
= smb_full_audit_setxattr
,
2409 .fsetxattr_fn
= smb_full_audit_fsetxattr
,
2410 .aio_force_fn
= smb_full_audit_aio_force
,
2411 .is_offline_fn
= smb_full_audit_is_offline
,
2412 .set_offline_fn
= smb_full_audit_set_offline
,
2415 NTSTATUS
vfs_full_audit_init(void)
2417 NTSTATUS ret
= smb_register_vfs(SMB_VFS_INTERFACE_VERSION
,
2418 "full_audit", &vfs_full_audit_fns
);
2420 if (!NT_STATUS_IS_OK(ret
))
2423 vfs_full_audit_debug_level
= debug_add_class("full_audit");
2424 if (vfs_full_audit_debug_level
== -1) {
2425 vfs_full_audit_debug_level
= DBGC_VFS
;
2426 DEBUG(0, ("vfs_full_audit: Couldn't register custom debugging "
2429 DEBUG(10, ("vfs_full_audit: Debug class number of "
2430 "'full_audit': %d\n", vfs_full_audit_debug_level
));