2 * Time auditing VFS module for samba. Log time taken for VFS call to syslog
5 * Copyright (C) Abhidnya Chirmule <achirmul@in.ibm.com> 2009
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, see <http://www.gnu.org/licenses/>.
22 * This module implements logging for time taken for all Samba VFS operations.
24 * vfs objects = time_audit
29 #include "smbd/smbd.h"
31 #include "lib/util/tevent_unix.h"
32 #include "lib/util/tevent_ntstatus.h"
35 #define DBGC_CLASS DBGC_VFS
37 static double audit_timeout
;
39 static void smb_time_audit_log_msg(const char *syscallname
, double elapsed
,
42 DEBUG(0, ("WARNING: VFS call \"%s\" took unexpectedly long "
43 "(%.2f seconds) %s%s-- Validate that file and storage "
44 "subsystems are operating normally\n", syscallname
,
45 elapsed
, (msg
!= NULL
) ? msg
: "",
46 (msg
!= NULL
) ? " " : ""));
49 static void smb_time_audit_log(const char *syscallname
, double elapsed
)
51 smb_time_audit_log_msg(syscallname
, elapsed
, NULL
);
54 static void smb_time_audit_log_fsp(const char *syscallname
, double elapsed
,
55 const struct files_struct
*fsp
)
57 char *base_name
= NULL
;
58 char *connectpath
= NULL
;
62 smb_time_audit_log(syscallname
, elapsed
);
66 connectpath
= fsp
->conn
->connectpath
;
68 base_name
= fsp
->fsp_name
->base_name
;
70 if (connectpath
!= NULL
&& base_name
!= NULL
) {
71 msg
= talloc_asprintf(talloc_tos(), "filename = \"%s/%s\"",
72 connectpath
, base_name
);
73 } else if (connectpath
!= NULL
&& base_name
== NULL
) {
74 msg
= talloc_asprintf(talloc_tos(), "connectpath = \"%s\", "
77 } else if (connectpath
== NULL
&& base_name
!= NULL
) {
78 msg
= talloc_asprintf(talloc_tos(), "connectpath = <NULL>, "
81 } else { /* connectpath == NULL && base_name == NULL */
82 msg
= talloc_asprintf(talloc_tos(), "connectpath = <NULL>, "
83 "base_name = <NULL>");
85 smb_time_audit_log_msg(syscallname
, elapsed
, msg
);
89 static void smb_time_audit_log_fname(const char *syscallname
, double elapsed
,
95 if (getcwd(cwd
, sizeof(cwd
)) == NULL
) {
96 snprintf(cwd
, sizeof(cwd
), "<getcwd() error %d>", errno
);
99 msg
= talloc_asprintf(talloc_tos(),
100 "cwd = \"%s\", filename = \"%s\"",
103 msg
= talloc_asprintf(talloc_tos(),
104 "cwd = \"%s\", filename = <NULL>",
107 smb_time_audit_log_msg(syscallname
, elapsed
, msg
);
111 static void smb_time_audit_log_smb_fname(const char *syscallname
, double elapsed
,
112 const struct smb_filename
*smb_fname
)
114 if (smb_fname
!= NULL
) {
115 smb_time_audit_log_fname(syscallname
, elapsed
,
116 smb_fname
->base_name
);
118 smb_time_audit_log_fname(syscallname
, elapsed
,
119 "smb_fname = <NULL>");
123 static int smb_time_audit_connect(vfs_handle_struct
*handle
,
124 const char *svc
, const char *user
)
127 struct timespec ts1
,ts2
;
134 clock_gettime_mono(&ts1
);
135 result
= SMB_VFS_NEXT_CONNECT(handle
, svc
, user
);
136 clock_gettime_mono(&ts2
);
137 timediff
= nsec_time_diff(&ts2
,&ts1
)*1.0e-9;
138 if (timediff
> audit_timeout
) {
139 smb_time_audit_log_msg("connect", timediff
, user
);
144 static void smb_time_audit_disconnect(vfs_handle_struct
*handle
)
146 struct timespec ts1
,ts2
;
149 clock_gettime_mono(&ts1
);
150 SMB_VFS_NEXT_DISCONNECT(handle
);
151 clock_gettime_mono(&ts2
);
152 timediff
= nsec_time_diff(&ts2
,&ts1
)*1.0e-9;
154 if (timediff
> audit_timeout
) {
155 smb_time_audit_log("disconnect", timediff
);
159 static uint64_t smb_time_audit_disk_free(vfs_handle_struct
*handle
,
160 const struct smb_filename
*smb_fname
,
166 struct timespec ts1
,ts2
;
169 clock_gettime_mono(&ts1
);
170 result
= SMB_VFS_NEXT_DISK_FREE(handle
, smb_fname
, bsize
, dfree
, dsize
);
171 clock_gettime_mono(&ts2
);
172 timediff
= nsec_time_diff(&ts2
,&ts1
)*1.0e-9;
174 /* Don't have a reasonable notion of failure here */
175 if (timediff
> audit_timeout
) {
176 smb_time_audit_log_fname("disk_free",
178 smb_fname
->base_name
);
184 static int smb_time_audit_get_quota(struct vfs_handle_struct
*handle
,
185 const struct smb_filename
*smb_fname
,
186 enum SMB_QUOTA_TYPE qtype
,
191 struct timespec ts1
,ts2
;
194 clock_gettime_mono(&ts1
);
195 result
= SMB_VFS_NEXT_GET_QUOTA(handle
, smb_fname
, qtype
, id
, qt
);
196 clock_gettime_mono(&ts2
);
197 timediff
= nsec_time_diff(&ts2
,&ts1
)*1.0e-9;
199 if (timediff
> audit_timeout
) {
200 smb_time_audit_log_fname("get_quota",
202 smb_fname
->base_name
);
207 static int smb_time_audit_set_quota(struct vfs_handle_struct
*handle
,
208 enum SMB_QUOTA_TYPE qtype
, unid_t id
,
212 struct timespec ts1
,ts2
;
215 clock_gettime_mono(&ts1
);
216 result
= SMB_VFS_NEXT_SET_QUOTA(handle
, qtype
, id
, qt
);
217 clock_gettime_mono(&ts2
);
218 timediff
= nsec_time_diff(&ts2
,&ts1
)*1.0e-9;
220 if (timediff
> audit_timeout
) {
221 smb_time_audit_log("set_quota", timediff
);
227 static int smb_time_audit_get_shadow_copy_data(struct vfs_handle_struct
*handle
,
228 struct files_struct
*fsp
,
229 struct shadow_copy_data
*shadow_copy_data
,
233 struct timespec ts1
,ts2
;
236 clock_gettime_mono(&ts1
);
237 result
= SMB_VFS_NEXT_GET_SHADOW_COPY_DATA(handle
, fsp
,
238 shadow_copy_data
, labels
);
239 clock_gettime_mono(&ts2
);
240 timediff
= nsec_time_diff(&ts2
,&ts1
)*1.0e-9;
242 if (timediff
> audit_timeout
) {
243 smb_time_audit_log_fsp("get_shadow_copy_data", timediff
, fsp
);
249 static int smb_time_audit_statvfs(struct vfs_handle_struct
*handle
,
250 const struct smb_filename
*smb_fname
,
251 struct vfs_statvfs_struct
*statbuf
)
254 struct timespec ts1
,ts2
;
257 clock_gettime_mono(&ts1
);
258 result
= SMB_VFS_NEXT_STATVFS(handle
, smb_fname
, statbuf
);
259 clock_gettime_mono(&ts2
);
260 timediff
= nsec_time_diff(&ts2
,&ts1
)*1.0e-9;
262 if (timediff
> audit_timeout
) {
263 smb_time_audit_log_fname("statvfs", timediff
,
264 smb_fname
->base_name
);
270 static uint32_t smb_time_audit_fs_capabilities(struct vfs_handle_struct
*handle
,
271 enum timestamp_set_resolution
*p_ts_res
)
274 struct timespec ts1
,ts2
;
277 clock_gettime_mono(&ts1
);
278 result
= SMB_VFS_NEXT_FS_CAPABILITIES(handle
, p_ts_res
);
279 clock_gettime_mono(&ts2
);
280 timediff
= nsec_time_diff(&ts2
,&ts1
)*1.0e-9;
282 if (timediff
> audit_timeout
) {
283 smb_time_audit_log("fs_capabilities", timediff
);
289 static NTSTATUS
smb_time_audit_get_dfs_referrals(
290 struct vfs_handle_struct
*handle
,
291 struct dfs_GetDFSReferral
*r
)
294 struct timespec ts1
,ts2
;
297 clock_gettime_mono(&ts1
);
298 result
= SMB_VFS_NEXT_GET_DFS_REFERRALS(handle
, r
);
299 clock_gettime_mono(&ts2
);
300 timediff
= nsec_time_diff(&ts2
,&ts1
)*1.0e-9;
302 if (timediff
> audit_timeout
) {
303 smb_time_audit_log("get_dfs_referrals(", timediff
);
309 static NTSTATUS
smb_time_audit_snap_check_path(struct vfs_handle_struct
*handle
,
311 const char *service_path
,
315 struct timespec ts1
,ts2
;
318 clock_gettime_mono(&ts1
);
319 status
= SMB_VFS_NEXT_SNAP_CHECK_PATH(handle
, mem_ctx
, service_path
,
321 clock_gettime_mono(&ts2
);
322 timediff
= nsec_time_diff(&ts2
, &ts1
) * 1.0e-9;
324 if (timediff
> audit_timeout
) {
325 smb_time_audit_log("snap_check_path", timediff
);
331 static NTSTATUS
smb_time_audit_snap_create(struct vfs_handle_struct
*handle
,
333 const char *base_volume
,
340 struct timespec ts1
,ts2
;
343 clock_gettime_mono(&ts1
);
344 status
= SMB_VFS_NEXT_SNAP_CREATE(handle
, mem_ctx
, base_volume
, tstamp
,
345 rw
, base_path
, snap_path
);
346 clock_gettime_mono(&ts2
);
347 timediff
= nsec_time_diff(&ts2
,&ts1
) * 1.0e-9;
349 if (timediff
> audit_timeout
) {
350 smb_time_audit_log("snap_create", timediff
);
356 static NTSTATUS
smb_time_audit_snap_delete(struct vfs_handle_struct
*handle
,
362 struct timespec ts1
,ts2
;
365 clock_gettime_mono(&ts1
);
366 status
= SMB_VFS_NEXT_SNAP_DELETE(handle
, mem_ctx
, base_path
,
368 clock_gettime_mono(&ts2
);
369 timediff
= nsec_time_diff(&ts2
, &ts1
) * 1.0e-9;
371 if (timediff
> audit_timeout
) {
372 smb_time_audit_log("snap_delete", timediff
);
378 static DIR *smb_time_audit_opendir(vfs_handle_struct
*handle
,
379 const struct smb_filename
*smb_fname
,
380 const char *mask
, uint32_t attr
)
383 struct timespec ts1
,ts2
;
386 clock_gettime_mono(&ts1
);
387 result
= SMB_VFS_NEXT_OPENDIR(handle
, smb_fname
, mask
, attr
);
388 clock_gettime_mono(&ts2
);
389 timediff
= nsec_time_diff(&ts2
,&ts1
)*1.0e-9;
391 if (timediff
> audit_timeout
) {
392 smb_time_audit_log_smb_fname("opendir", timediff
, smb_fname
);
398 static DIR *smb_time_audit_fdopendir(vfs_handle_struct
*handle
,
400 const char *mask
, uint32_t attr
)
403 struct timespec ts1
,ts2
;
406 clock_gettime_mono(&ts1
);
407 result
= SMB_VFS_NEXT_FDOPENDIR(handle
, fsp
, mask
, attr
);
408 clock_gettime_mono(&ts2
);
409 timediff
= nsec_time_diff(&ts2
,&ts1
)*1.0e-9;
411 if (timediff
> audit_timeout
) {
412 smb_time_audit_log_fsp("fdopendir", timediff
, fsp
);
418 static struct dirent
*smb_time_audit_readdir(vfs_handle_struct
*handle
,
420 SMB_STRUCT_STAT
*sbuf
)
422 struct dirent
*result
;
423 struct timespec ts1
,ts2
;
426 clock_gettime_mono(&ts1
);
427 result
= SMB_VFS_NEXT_READDIR(handle
, dirp
, sbuf
);
428 clock_gettime_mono(&ts2
);
429 timediff
= nsec_time_diff(&ts2
,&ts1
)*1.0e-9;
431 if (timediff
> audit_timeout
) {
432 smb_time_audit_log("readdir", timediff
);
438 static void smb_time_audit_seekdir(vfs_handle_struct
*handle
,
439 DIR *dirp
, long offset
)
441 struct timespec ts1
,ts2
;
444 clock_gettime_mono(&ts1
);
445 SMB_VFS_NEXT_SEEKDIR(handle
, dirp
, offset
);
446 clock_gettime_mono(&ts2
);
447 timediff
= nsec_time_diff(&ts2
,&ts1
)*1.0e-9;
449 if (timediff
> audit_timeout
) {
450 smb_time_audit_log("seekdir", timediff
);
455 static long smb_time_audit_telldir(vfs_handle_struct
*handle
,
459 struct timespec ts1
,ts2
;
462 clock_gettime_mono(&ts1
);
463 result
= SMB_VFS_NEXT_TELLDIR(handle
, dirp
);
464 clock_gettime_mono(&ts2
);
465 timediff
= nsec_time_diff(&ts2
,&ts1
)*1.0e-9;
467 if (timediff
> audit_timeout
) {
468 smb_time_audit_log("telldir", timediff
);
474 static void smb_time_audit_rewinddir(vfs_handle_struct
*handle
,
477 struct timespec ts1
,ts2
;
480 clock_gettime_mono(&ts1
);
481 SMB_VFS_NEXT_REWINDDIR(handle
, dirp
);
482 clock_gettime_mono(&ts2
);
483 timediff
= nsec_time_diff(&ts2
,&ts1
)*1.0e-9;
485 if (timediff
> audit_timeout
) {
486 smb_time_audit_log("rewinddir", timediff
);
491 static int smb_time_audit_mkdir(vfs_handle_struct
*handle
,
492 const struct smb_filename
*smb_fname
,
496 struct timespec ts1
,ts2
;
499 clock_gettime_mono(&ts1
);
500 result
= SMB_VFS_NEXT_MKDIR(handle
, smb_fname
, mode
);
501 clock_gettime_mono(&ts2
);
502 timediff
= nsec_time_diff(&ts2
,&ts1
)*1.0e-9;
504 if (timediff
> audit_timeout
) {
505 smb_time_audit_log_smb_fname("mkdir",
513 static int smb_time_audit_rmdir(vfs_handle_struct
*handle
,
514 const struct smb_filename
*smb_fname
)
517 struct timespec ts1
,ts2
;
520 clock_gettime_mono(&ts1
);
521 result
= SMB_VFS_NEXT_RMDIR(handle
, smb_fname
);
522 clock_gettime_mono(&ts2
);
523 timediff
= nsec_time_diff(&ts2
,&ts1
)*1.0e-9;
525 if (timediff
> audit_timeout
) {
526 smb_time_audit_log_smb_fname("rmdir",
534 static int smb_time_audit_closedir(vfs_handle_struct
*handle
,
538 struct timespec ts1
,ts2
;
541 clock_gettime_mono(&ts1
);
542 result
= SMB_VFS_NEXT_CLOSEDIR(handle
, dirp
);
543 clock_gettime_mono(&ts2
);
544 timediff
= nsec_time_diff(&ts2
,&ts1
)*1.0e-9;
546 if (timediff
> audit_timeout
) {
547 smb_time_audit_log("closedir", timediff
);
553 static void smb_time_audit_init_search_op(vfs_handle_struct
*handle
,
556 struct timespec ts1
,ts2
;
559 clock_gettime_mono(&ts1
);
560 SMB_VFS_NEXT_INIT_SEARCH_OP(handle
, dirp
);
561 clock_gettime_mono(&ts2
);
562 timediff
= nsec_time_diff(&ts2
,&ts1
)*1.0e-9;
564 if (timediff
> audit_timeout
) {
565 smb_time_audit_log("init_search_op", timediff
);
569 static int smb_time_audit_open(vfs_handle_struct
*handle
,
570 struct smb_filename
*fname
,
572 int flags
, mode_t mode
)
575 struct timespec ts1
,ts2
;
578 clock_gettime_mono(&ts1
);
579 result
= SMB_VFS_NEXT_OPEN(handle
, fname
, fsp
, flags
, mode
);
580 clock_gettime_mono(&ts2
);
581 timediff
= nsec_time_diff(&ts2
,&ts1
)*1.0e-9;
583 if (timediff
> audit_timeout
) {
584 smb_time_audit_log_fsp("open", timediff
, fsp
);
590 static NTSTATUS
smb_time_audit_create_file(vfs_handle_struct
*handle
,
591 struct smb_request
*req
,
592 uint16_t root_dir_fid
,
593 struct smb_filename
*fname
,
594 uint32_t access_mask
,
595 uint32_t share_access
,
596 uint32_t create_disposition
,
597 uint32_t create_options
,
598 uint32_t file_attributes
,
599 uint32_t oplock_request
,
600 struct smb2_lease
*lease
,
601 uint64_t allocation_size
,
602 uint32_t private_flags
,
603 struct security_descriptor
*sd
,
604 struct ea_list
*ea_list
,
605 files_struct
**result_fsp
,
607 const struct smb2_create_blobs
*in_context_blobs
,
608 struct smb2_create_blobs
*out_context_blobs
)
611 struct timespec ts1
,ts2
;
614 clock_gettime_mono(&ts1
);
615 result
= SMB_VFS_NEXT_CREATE_FILE(
618 root_dir_fid
, /* root_dir_fid */
620 access_mask
, /* access_mask */
621 share_access
, /* share_access */
622 create_disposition
, /* create_disposition*/
623 create_options
, /* create_options */
624 file_attributes
, /* file_attributes */
625 oplock_request
, /* oplock_request */
627 allocation_size
, /* allocation_size */
630 ea_list
, /* ea_list */
631 result_fsp
, /* result */
633 in_context_blobs
, out_context_blobs
); /* create context */
634 clock_gettime_mono(&ts2
);
635 timediff
= nsec_time_diff(&ts2
,&ts1
)*1.0e-9;
637 if (timediff
> audit_timeout
) {
639 * can't use result_fsp this time, may have
640 * invalid content causing smbd crash
642 smb_time_audit_log_smb_fname("create_file", timediff
,
649 static int smb_time_audit_close(vfs_handle_struct
*handle
, files_struct
*fsp
)
652 struct timespec ts1
,ts2
;
655 clock_gettime_mono(&ts1
);
656 result
= SMB_VFS_NEXT_CLOSE(handle
, fsp
);
657 clock_gettime_mono(&ts2
);
658 timediff
= nsec_time_diff(&ts2
,&ts1
)*1.0e-9;
660 if (timediff
> audit_timeout
) {
661 smb_time_audit_log_fsp("close", timediff
, fsp
);
667 static ssize_t
smb_time_audit_read(vfs_handle_struct
*handle
,
668 files_struct
*fsp
, void *data
, size_t n
)
671 struct timespec ts1
,ts2
;
674 clock_gettime_mono(&ts1
);
675 result
= SMB_VFS_NEXT_READ(handle
, fsp
, data
, n
);
676 clock_gettime_mono(&ts2
);
677 timediff
= nsec_time_diff(&ts2
,&ts1
)*1.0e-9;
679 if (timediff
> audit_timeout
) {
680 smb_time_audit_log_fsp("read", timediff
, fsp
);
686 static ssize_t
smb_time_audit_pread(vfs_handle_struct
*handle
,
688 void *data
, size_t n
, off_t offset
)
691 struct timespec ts1
,ts2
;
694 clock_gettime_mono(&ts1
);
695 result
= SMB_VFS_NEXT_PREAD(handle
, fsp
, data
, n
, offset
);
696 clock_gettime_mono(&ts2
);
697 timediff
= nsec_time_diff(&ts2
,&ts1
)*1.0e-9;
699 if (timediff
> audit_timeout
) {
700 smb_time_audit_log_fsp("pread", timediff
, fsp
);
706 struct smb_time_audit_pread_state
{
707 struct files_struct
*fsp
;
709 struct vfs_aio_state vfs_aio_state
;
712 static void smb_time_audit_pread_done(struct tevent_req
*subreq
);
714 static struct tevent_req
*smb_time_audit_pread_send(
715 struct vfs_handle_struct
*handle
, TALLOC_CTX
*mem_ctx
,
716 struct tevent_context
*ev
, struct files_struct
*fsp
,
717 void *data
, size_t n
, off_t offset
)
719 struct tevent_req
*req
, *subreq
;
720 struct smb_time_audit_pread_state
*state
;
722 req
= tevent_req_create(mem_ctx
, &state
,
723 struct smb_time_audit_pread_state
);
729 subreq
= SMB_VFS_NEXT_PREAD_SEND(state
, ev
, handle
, fsp
, data
,
731 if (tevent_req_nomem(subreq
, req
)) {
732 return tevent_req_post(req
, ev
);
734 tevent_req_set_callback(subreq
, smb_time_audit_pread_done
, req
);
738 static void smb_time_audit_pread_done(struct tevent_req
*subreq
)
740 struct tevent_req
*req
= tevent_req_callback_data(
741 subreq
, struct tevent_req
);
742 struct smb_time_audit_pread_state
*state
= tevent_req_data(
743 req
, struct smb_time_audit_pread_state
);
745 state
->ret
= SMB_VFS_PREAD_RECV(subreq
, &state
->vfs_aio_state
);
747 tevent_req_done(req
);
750 static ssize_t
smb_time_audit_pread_recv(struct tevent_req
*req
,
751 struct vfs_aio_state
*vfs_aio_state
)
753 struct smb_time_audit_pread_state
*state
= tevent_req_data(
754 req
, struct smb_time_audit_pread_state
);
757 timediff
= state
->vfs_aio_state
.duration
* 1.0e-9;
759 if (timediff
> audit_timeout
) {
760 smb_time_audit_log_fsp("async pread", timediff
, state
->fsp
);
763 if (tevent_req_is_unix_error(req
, &vfs_aio_state
->error
)) {
766 *vfs_aio_state
= state
->vfs_aio_state
;
770 static ssize_t
smb_time_audit_write(vfs_handle_struct
*handle
,
772 const void *data
, size_t n
)
775 struct timespec ts1
,ts2
;
778 clock_gettime_mono(&ts1
);
779 result
= SMB_VFS_NEXT_WRITE(handle
, fsp
, data
, n
);
780 clock_gettime_mono(&ts2
);
781 timediff
= nsec_time_diff(&ts2
,&ts1
)*1.0e-9;
783 if (timediff
> audit_timeout
) {
784 smb_time_audit_log_fsp("write", timediff
, fsp
);
790 static ssize_t
smb_time_audit_pwrite(vfs_handle_struct
*handle
,
792 const void *data
, size_t n
,
796 struct timespec ts1
,ts2
;
799 clock_gettime_mono(&ts1
);
800 result
= SMB_VFS_NEXT_PWRITE(handle
, fsp
, data
, n
, offset
);
801 clock_gettime_mono(&ts2
);
802 timediff
= nsec_time_diff(&ts2
,&ts1
)*1.0e-9;
804 if (timediff
> audit_timeout
) {
805 smb_time_audit_log_fsp("pwrite", timediff
, fsp
);
811 struct smb_time_audit_pwrite_state
{
812 struct files_struct
*fsp
;
814 struct vfs_aio_state vfs_aio_state
;
817 static void smb_time_audit_pwrite_done(struct tevent_req
*subreq
);
819 static struct tevent_req
*smb_time_audit_pwrite_send(
820 struct vfs_handle_struct
*handle
, TALLOC_CTX
*mem_ctx
,
821 struct tevent_context
*ev
, struct files_struct
*fsp
,
822 const void *data
, size_t n
, off_t offset
)
824 struct tevent_req
*req
, *subreq
;
825 struct smb_time_audit_pwrite_state
*state
;
827 req
= tevent_req_create(mem_ctx
, &state
,
828 struct smb_time_audit_pwrite_state
);
834 subreq
= SMB_VFS_NEXT_PWRITE_SEND(state
, ev
, handle
, fsp
, data
,
836 if (tevent_req_nomem(subreq
, req
)) {
837 return tevent_req_post(req
, ev
);
839 tevent_req_set_callback(subreq
, smb_time_audit_pwrite_done
, req
);
843 static void smb_time_audit_pwrite_done(struct tevent_req
*subreq
)
845 struct tevent_req
*req
= tevent_req_callback_data(
846 subreq
, struct tevent_req
);
847 struct smb_time_audit_pwrite_state
*state
= tevent_req_data(
848 req
, struct smb_time_audit_pwrite_state
);
850 state
->ret
= SMB_VFS_PWRITE_RECV(subreq
, &state
->vfs_aio_state
);
852 tevent_req_done(req
);
855 static ssize_t
smb_time_audit_pwrite_recv(struct tevent_req
*req
,
856 struct vfs_aio_state
*vfs_aio_state
)
858 struct smb_time_audit_pwrite_state
*state
= tevent_req_data(
859 req
, struct smb_time_audit_pwrite_state
);
862 timediff
= state
->vfs_aio_state
.duration
* 1.0e-9;
864 if (timediff
> audit_timeout
) {
865 smb_time_audit_log_fsp("async pwrite", timediff
, state
->fsp
);
868 if (tevent_req_is_unix_error(req
, &vfs_aio_state
->error
)) {
871 *vfs_aio_state
= state
->vfs_aio_state
;
875 static off_t
smb_time_audit_lseek(vfs_handle_struct
*handle
,
877 off_t offset
, int whence
)
880 struct timespec ts1
,ts2
;
883 clock_gettime_mono(&ts1
);
884 result
= SMB_VFS_NEXT_LSEEK(handle
, fsp
, offset
, whence
);
885 clock_gettime_mono(&ts2
);
886 timediff
= nsec_time_diff(&ts2
,&ts1
)*1.0e-9;
888 if (timediff
> audit_timeout
) {
889 smb_time_audit_log_fsp("lseek", timediff
, fsp
);
895 static ssize_t
smb_time_audit_sendfile(vfs_handle_struct
*handle
, int tofd
,
896 files_struct
*fromfsp
,
897 const DATA_BLOB
*hdr
, off_t offset
,
901 struct timespec ts1
,ts2
;
904 clock_gettime_mono(&ts1
);
905 result
= SMB_VFS_NEXT_SENDFILE(handle
, tofd
, fromfsp
, hdr
, offset
, n
);
906 clock_gettime_mono(&ts2
);
907 timediff
= nsec_time_diff(&ts2
,&ts1
)*1.0e-9;
909 if (timediff
> audit_timeout
) {
910 smb_time_audit_log_fsp("sendfile", timediff
, fromfsp
);
916 static ssize_t
smb_time_audit_recvfile(vfs_handle_struct
*handle
, int fromfd
,
922 struct timespec ts1
,ts2
;
925 clock_gettime_mono(&ts1
);
926 result
= SMB_VFS_NEXT_RECVFILE(handle
, fromfd
, tofsp
, offset
, n
);
927 clock_gettime_mono(&ts2
);
928 timediff
= nsec_time_diff(&ts2
,&ts1
)*1.0e-9;
930 if (timediff
> audit_timeout
) {
931 smb_time_audit_log_fsp("recvfile", timediff
, tofsp
);
937 static int smb_time_audit_rename(vfs_handle_struct
*handle
,
938 const struct smb_filename
*oldname
,
939 const struct smb_filename
*newname
)
942 struct timespec ts1
,ts2
;
945 clock_gettime_mono(&ts1
);
946 result
= SMB_VFS_NEXT_RENAME(handle
, oldname
, newname
);
947 clock_gettime_mono(&ts2
);
948 timediff
= nsec_time_diff(&ts2
,&ts1
)*1.0e-9;
950 if (timediff
> audit_timeout
) {
951 smb_time_audit_log_smb_fname("rename", timediff
, newname
);
957 static int smb_time_audit_fsync(vfs_handle_struct
*handle
, files_struct
*fsp
)
960 struct timespec ts1
,ts2
;
963 clock_gettime_mono(&ts1
);
964 result
= SMB_VFS_NEXT_FSYNC(handle
, fsp
);
965 clock_gettime_mono(&ts2
);
966 timediff
= nsec_time_diff(&ts2
,&ts1
)*1.0e-9;
968 if (timediff
> audit_timeout
) {
969 smb_time_audit_log_fsp("fsync", timediff
, fsp
);
975 struct smb_time_audit_fsync_state
{
976 struct files_struct
*fsp
;
978 struct vfs_aio_state vfs_aio_state
;
981 static void smb_time_audit_fsync_done(struct tevent_req
*subreq
);
983 static struct tevent_req
*smb_time_audit_fsync_send(
984 struct vfs_handle_struct
*handle
, TALLOC_CTX
*mem_ctx
,
985 struct tevent_context
*ev
, struct files_struct
*fsp
)
987 struct tevent_req
*req
, *subreq
;
988 struct smb_time_audit_fsync_state
*state
;
990 req
= tevent_req_create(mem_ctx
, &state
,
991 struct smb_time_audit_fsync_state
);
997 subreq
= SMB_VFS_NEXT_FSYNC_SEND(state
, ev
, handle
, fsp
);
998 if (tevent_req_nomem(subreq
, req
)) {
999 return tevent_req_post(req
, ev
);
1001 tevent_req_set_callback(subreq
, smb_time_audit_fsync_done
, req
);
1005 static void smb_time_audit_fsync_done(struct tevent_req
*subreq
)
1007 struct tevent_req
*req
= tevent_req_callback_data(
1008 subreq
, struct tevent_req
);
1009 struct smb_time_audit_fsync_state
*state
= tevent_req_data(
1010 req
, struct smb_time_audit_fsync_state
);
1012 state
->ret
= SMB_VFS_FSYNC_RECV(subreq
, &state
->vfs_aio_state
);
1013 TALLOC_FREE(subreq
);
1014 tevent_req_done(req
);
1017 static int smb_time_audit_fsync_recv(struct tevent_req
*req
,
1018 struct vfs_aio_state
*vfs_aio_state
)
1020 struct smb_time_audit_fsync_state
*state
= tevent_req_data(
1021 req
, struct smb_time_audit_fsync_state
);
1024 timediff
= state
->vfs_aio_state
.duration
* 1.0e-9;
1026 if (timediff
> audit_timeout
) {
1027 smb_time_audit_log_fsp("async fsync", timediff
, state
->fsp
);
1030 if (tevent_req_is_unix_error(req
, &vfs_aio_state
->error
)) {
1033 *vfs_aio_state
= state
->vfs_aio_state
;
1037 static int smb_time_audit_stat(vfs_handle_struct
*handle
,
1038 struct smb_filename
*fname
)
1041 struct timespec ts1
,ts2
;
1044 clock_gettime_mono(&ts1
);
1045 result
= SMB_VFS_NEXT_STAT(handle
, fname
);
1046 clock_gettime_mono(&ts2
);
1047 timediff
= nsec_time_diff(&ts2
,&ts1
)*1.0e-9;
1049 if (timediff
> audit_timeout
) {
1050 smb_time_audit_log_smb_fname("stat", timediff
, fname
);
1056 static int smb_time_audit_fstat(vfs_handle_struct
*handle
, files_struct
*fsp
,
1057 SMB_STRUCT_STAT
*sbuf
)
1060 struct timespec ts1
,ts2
;
1063 clock_gettime_mono(&ts1
);
1064 result
= SMB_VFS_NEXT_FSTAT(handle
, fsp
, sbuf
);
1065 clock_gettime_mono(&ts2
);
1066 timediff
= nsec_time_diff(&ts2
,&ts1
)*1.0e-9;
1068 if (timediff
> audit_timeout
) {
1069 smb_time_audit_log_fsp("fstat", timediff
, fsp
);
1075 static int smb_time_audit_lstat(vfs_handle_struct
*handle
,
1076 struct smb_filename
*path
)
1079 struct timespec ts1
,ts2
;
1082 clock_gettime_mono(&ts1
);
1083 result
= SMB_VFS_NEXT_LSTAT(handle
, path
);
1084 clock_gettime_mono(&ts2
);
1085 timediff
= nsec_time_diff(&ts2
,&ts1
)*1.0e-9;
1087 if (timediff
> audit_timeout
) {
1088 smb_time_audit_log_smb_fname("lstat", timediff
, path
);
1094 static uint64_t smb_time_audit_get_alloc_size(vfs_handle_struct
*handle
,
1096 const SMB_STRUCT_STAT
*sbuf
)
1099 struct timespec ts1
,ts2
;
1102 clock_gettime_mono(&ts1
);
1103 result
= SMB_VFS_NEXT_GET_ALLOC_SIZE(handle
, fsp
, sbuf
);
1104 clock_gettime_mono(&ts2
);
1105 timediff
= nsec_time_diff(&ts2
,&ts1
)*1.0e-9;
1107 if (timediff
> audit_timeout
) {
1108 smb_time_audit_log_fsp("get_alloc_size", timediff
, fsp
);
1114 static int smb_time_audit_unlink(vfs_handle_struct
*handle
,
1115 const struct smb_filename
*path
)
1118 struct timespec ts1
,ts2
;
1121 clock_gettime_mono(&ts1
);
1122 result
= SMB_VFS_NEXT_UNLINK(handle
, path
);
1123 clock_gettime_mono(&ts2
);
1124 timediff
= nsec_time_diff(&ts2
,&ts1
)*1.0e-9;
1126 if (timediff
> audit_timeout
) {
1127 smb_time_audit_log_smb_fname("unlink", timediff
, path
);
1133 static int smb_time_audit_chmod(vfs_handle_struct
*handle
,
1134 const struct smb_filename
*smb_fname
,
1138 struct timespec ts1
,ts2
;
1141 clock_gettime_mono(&ts1
);
1142 result
= SMB_VFS_NEXT_CHMOD(handle
, smb_fname
, mode
);
1143 clock_gettime_mono(&ts2
);
1144 timediff
= nsec_time_diff(&ts2
,&ts1
)*1.0e-9;
1146 if (timediff
> audit_timeout
) {
1147 smb_time_audit_log_fname("chmod",
1149 smb_fname
->base_name
);
1155 static int smb_time_audit_fchmod(vfs_handle_struct
*handle
, files_struct
*fsp
,
1159 struct timespec ts1
,ts2
;
1162 clock_gettime_mono(&ts1
);
1163 result
= SMB_VFS_NEXT_FCHMOD(handle
, fsp
, mode
);
1164 clock_gettime_mono(&ts2
);
1165 timediff
= nsec_time_diff(&ts2
,&ts1
)*1.0e-9;
1167 if (timediff
> audit_timeout
) {
1168 smb_time_audit_log_fsp("fchmod", timediff
, fsp
);
1174 static int smb_time_audit_chown(vfs_handle_struct
*handle
,
1175 const struct smb_filename
*smb_fname
,
1180 struct timespec ts1
,ts2
;
1183 clock_gettime_mono(&ts1
);
1184 result
= SMB_VFS_NEXT_CHOWN(handle
, smb_fname
, uid
, gid
);
1185 clock_gettime_mono(&ts2
);
1186 timediff
= nsec_time_diff(&ts2
,&ts1
)*1.0e-9;
1188 if (timediff
> audit_timeout
) {
1189 smb_time_audit_log_fname("chown",
1191 smb_fname
->base_name
);
1197 static int smb_time_audit_fchown(vfs_handle_struct
*handle
, files_struct
*fsp
,
1198 uid_t uid
, gid_t gid
)
1201 struct timespec ts1
,ts2
;
1204 clock_gettime_mono(&ts1
);
1205 result
= SMB_VFS_NEXT_FCHOWN(handle
, fsp
, uid
, gid
);
1206 clock_gettime_mono(&ts2
);
1207 timediff
= nsec_time_diff(&ts2
,&ts1
)*1.0e-9;
1209 if (timediff
> audit_timeout
) {
1210 smb_time_audit_log_fsp("fchown", timediff
, fsp
);
1216 static int smb_time_audit_lchown(vfs_handle_struct
*handle
,
1217 const struct smb_filename
*smb_fname
,
1222 struct timespec ts1
,ts2
;
1225 clock_gettime_mono(&ts1
);
1226 result
= SMB_VFS_NEXT_LCHOWN(handle
, smb_fname
, uid
, gid
);
1227 clock_gettime_mono(&ts2
);
1228 timediff
= nsec_time_diff(&ts2
,&ts1
)*1.0e-9;
1230 if (timediff
> audit_timeout
) {
1231 smb_time_audit_log_fname("lchown",
1233 smb_fname
->base_name
);
1239 static int smb_time_audit_chdir(vfs_handle_struct
*handle
,
1240 const struct smb_filename
*smb_fname
)
1243 struct timespec ts1
,ts2
;
1246 clock_gettime_mono(&ts1
);
1247 result
= SMB_VFS_NEXT_CHDIR(handle
, smb_fname
);
1248 clock_gettime_mono(&ts2
);
1249 timediff
= nsec_time_diff(&ts2
,&ts1
)*1.0e-9;
1251 if (timediff
> audit_timeout
) {
1252 smb_time_audit_log_fname("chdir",
1254 smb_fname
->base_name
);
1260 static char *smb_time_audit_getwd(vfs_handle_struct
*handle
)
1263 struct timespec ts1
,ts2
;
1266 clock_gettime_mono(&ts1
);
1267 result
= SMB_VFS_NEXT_GETWD(handle
);
1268 clock_gettime_mono(&ts2
);
1269 timediff
= nsec_time_diff(&ts2
,&ts1
)*1.0e-9;
1271 if (timediff
> audit_timeout
) {
1272 smb_time_audit_log("getwd", timediff
);
1278 static int smb_time_audit_ntimes(vfs_handle_struct
*handle
,
1279 const struct smb_filename
*path
,
1280 struct smb_file_time
*ft
)
1283 struct timespec ts1
,ts2
;
1286 clock_gettime_mono(&ts1
);
1287 result
= SMB_VFS_NEXT_NTIMES(handle
, path
, ft
);
1288 clock_gettime_mono(&ts2
);
1289 timediff
= nsec_time_diff(&ts2
,&ts1
)*1.0e-9;
1291 if (timediff
> audit_timeout
) {
1292 smb_time_audit_log_smb_fname("ntimes", timediff
, path
);
1298 static int smb_time_audit_ftruncate(vfs_handle_struct
*handle
,
1303 struct timespec ts1
,ts2
;
1306 clock_gettime_mono(&ts1
);
1307 result
= SMB_VFS_NEXT_FTRUNCATE(handle
, fsp
, len
);
1308 clock_gettime_mono(&ts2
);
1309 timediff
= nsec_time_diff(&ts2
,&ts1
)*1.0e-9;
1311 if (timediff
> audit_timeout
) {
1312 smb_time_audit_log_fsp("ftruncate", timediff
, fsp
);
1318 static int smb_time_audit_fallocate(vfs_handle_struct
*handle
,
1325 int saved_errno
= 0;
1326 struct timespec ts1
,ts2
;
1329 clock_gettime_mono(&ts1
);
1330 result
= SMB_VFS_NEXT_FALLOCATE(handle
, fsp
, mode
, offset
, len
);
1332 saved_errno
= errno
;
1334 clock_gettime_mono(&ts2
);
1335 timediff
= nsec_time_diff(&ts2
,&ts1
)*1.0e-9;
1337 if (timediff
> audit_timeout
) {
1338 smb_time_audit_log_fsp("fallocate", timediff
, fsp
);
1341 errno
= saved_errno
;
1346 static bool smb_time_audit_lock(vfs_handle_struct
*handle
, files_struct
*fsp
,
1347 int op
, off_t offset
, off_t count
,
1351 struct timespec ts1
,ts2
;
1354 clock_gettime_mono(&ts1
);
1355 result
= SMB_VFS_NEXT_LOCK(handle
, fsp
, op
, offset
, count
, type
);
1356 clock_gettime_mono(&ts2
);
1357 timediff
= nsec_time_diff(&ts2
,&ts1
)*1.0e-9;
1359 if (timediff
> audit_timeout
) {
1360 smb_time_audit_log_fsp("lock", timediff
, fsp
);
1366 static int smb_time_audit_kernel_flock(struct vfs_handle_struct
*handle
,
1367 struct files_struct
*fsp
,
1368 uint32_t share_mode
, uint32_t access_mask
)
1371 struct timespec ts1
,ts2
;
1374 clock_gettime_mono(&ts1
);
1375 result
= SMB_VFS_NEXT_KERNEL_FLOCK(handle
, fsp
, share_mode
,
1377 clock_gettime_mono(&ts2
);
1378 timediff
= nsec_time_diff(&ts2
,&ts1
)*1.0e-9;
1380 if (timediff
> audit_timeout
) {
1381 smb_time_audit_log_fsp("kernel_flock", timediff
, fsp
);
1387 static int smb_time_audit_linux_setlease(vfs_handle_struct
*handle
,
1392 struct timespec ts1
,ts2
;
1395 clock_gettime_mono(&ts1
);
1396 result
= SMB_VFS_NEXT_LINUX_SETLEASE(handle
, fsp
, leasetype
);
1397 clock_gettime_mono(&ts2
);
1398 timediff
= nsec_time_diff(&ts2
,&ts1
)*1.0e-9;
1400 if (timediff
> audit_timeout
) {
1401 smb_time_audit_log_fsp("linux_setlease", timediff
, fsp
);
1407 static bool smb_time_audit_getlock(vfs_handle_struct
*handle
,
1409 off_t
*poffset
, off_t
*pcount
,
1410 int *ptype
, pid_t
*ppid
)
1413 struct timespec ts1
,ts2
;
1416 clock_gettime_mono(&ts1
);
1417 result
= SMB_VFS_NEXT_GETLOCK(handle
, fsp
, poffset
, pcount
, ptype
,
1419 clock_gettime_mono(&ts2
);
1420 timediff
= nsec_time_diff(&ts2
,&ts1
)*1.0e-9;
1422 if (timediff
> audit_timeout
) {
1423 smb_time_audit_log_fsp("getlock", timediff
, fsp
);
1429 static int smb_time_audit_symlink(vfs_handle_struct
*handle
,
1430 const char *link_contents
,
1431 const struct smb_filename
*new_smb_fname
)
1434 struct timespec ts1
,ts2
;
1437 clock_gettime_mono(&ts1
);
1438 result
= SMB_VFS_NEXT_SYMLINK(handle
, link_contents
, new_smb_fname
);
1439 clock_gettime_mono(&ts2
);
1440 timediff
= nsec_time_diff(&ts2
,&ts1
)*1.0e-9;
1442 if (timediff
> audit_timeout
) {
1443 smb_time_audit_log_fname("symlink", timediff
,
1444 new_smb_fname
->base_name
);
1450 static int smb_time_audit_readlink(vfs_handle_struct
*handle
,
1451 const struct smb_filename
*smb_fname
,
1456 struct timespec ts1
,ts2
;
1459 clock_gettime_mono(&ts1
);
1460 result
= SMB_VFS_NEXT_READLINK(handle
, smb_fname
,
1462 clock_gettime_mono(&ts2
);
1463 timediff
= nsec_time_diff(&ts2
,&ts1
)*1.0e-9;
1465 if (timediff
> audit_timeout
) {
1466 smb_time_audit_log_fname("readlink", timediff
,
1467 smb_fname
->base_name
);
1473 static int smb_time_audit_link(vfs_handle_struct
*handle
,
1474 const struct smb_filename
*old_smb_fname
,
1475 const struct smb_filename
*new_smb_fname
)
1478 struct timespec ts1
,ts2
;
1481 clock_gettime_mono(&ts1
);
1482 result
= SMB_VFS_NEXT_LINK(handle
, old_smb_fname
, new_smb_fname
);
1483 clock_gettime_mono(&ts2
);
1484 timediff
= nsec_time_diff(&ts2
,&ts1
)*1.0e-9;
1486 if (timediff
> audit_timeout
) {
1487 smb_time_audit_log_fname("link", timediff
,
1488 new_smb_fname
->base_name
);
1494 static int smb_time_audit_mknod(vfs_handle_struct
*handle
,
1495 const struct smb_filename
*smb_fname
,
1500 struct timespec ts1
,ts2
;
1503 clock_gettime_mono(&ts1
);
1504 result
= SMB_VFS_NEXT_MKNOD(handle
, smb_fname
, mode
, dev
);
1505 clock_gettime_mono(&ts2
);
1506 timediff
= nsec_time_diff(&ts2
,&ts1
)*1.0e-9;
1508 if (timediff
> audit_timeout
) {
1509 smb_time_audit_log_smb_fname("mknod", timediff
, smb_fname
);
1515 static char *smb_time_audit_realpath(vfs_handle_struct
*handle
,
1519 struct timespec ts1
,ts2
;
1522 clock_gettime_mono(&ts1
);
1523 result
= SMB_VFS_NEXT_REALPATH(handle
, path
);
1524 clock_gettime_mono(&ts2
);
1525 timediff
= nsec_time_diff(&ts2
,&ts1
)*1.0e-9;
1527 if (timediff
> audit_timeout
) {
1528 smb_time_audit_log_fname("realpath", timediff
, path
);
1534 static int smb_time_audit_chflags(vfs_handle_struct
*handle
,
1535 const struct smb_filename
*smb_fname
,
1539 struct timespec ts1
,ts2
;
1542 clock_gettime_mono(&ts1
);
1543 result
= SMB_VFS_NEXT_CHFLAGS(handle
, smb_fname
, flags
);
1544 clock_gettime_mono(&ts2
);
1545 timediff
= nsec_time_diff(&ts2
,&ts1
)*1.0e-9;
1547 if (timediff
> audit_timeout
) {
1548 smb_time_audit_log_smb_fname("chflags", timediff
, smb_fname
);
1554 static struct file_id
smb_time_audit_file_id_create(struct vfs_handle_struct
*handle
,
1555 const SMB_STRUCT_STAT
*sbuf
)
1557 struct file_id id_zero
;
1558 struct file_id result
;
1559 struct timespec ts1
,ts2
;
1562 ZERO_STRUCT(id_zero
);
1564 clock_gettime_mono(&ts1
);
1565 result
= SMB_VFS_NEXT_FILE_ID_CREATE(handle
, sbuf
);
1566 clock_gettime_mono(&ts2
);
1567 timediff
= nsec_time_diff(&ts2
,&ts1
)*1.0e-9;
1569 if (timediff
> audit_timeout
) {
1570 smb_time_audit_log("file_id_create", timediff
);
1576 static NTSTATUS
smb_time_audit_streaminfo(vfs_handle_struct
*handle
,
1577 struct files_struct
*fsp
,
1578 const struct smb_filename
*smb_fname
,
1579 TALLOC_CTX
*mem_ctx
,
1580 unsigned int *pnum_streams
,
1581 struct stream_struct
**pstreams
)
1584 struct timespec ts1
,ts2
;
1587 clock_gettime_mono(&ts1
);
1588 result
= SMB_VFS_NEXT_STREAMINFO(handle
, fsp
, smb_fname
, mem_ctx
,
1589 pnum_streams
, pstreams
);
1590 clock_gettime_mono(&ts2
);
1591 timediff
= nsec_time_diff(&ts2
,&ts1
)*1.0e-9;
1593 if (timediff
> audit_timeout
) {
1594 smb_time_audit_log_fsp("streaminfo", timediff
, fsp
);
1600 static int smb_time_audit_get_real_filename(struct vfs_handle_struct
*handle
,
1603 TALLOC_CTX
*mem_ctx
,
1607 struct timespec ts1
,ts2
;
1610 clock_gettime_mono(&ts1
);
1611 result
= SMB_VFS_NEXT_GET_REAL_FILENAME(handle
, path
, name
, mem_ctx
,
1613 clock_gettime_mono(&ts2
);
1614 timediff
= nsec_time_diff(&ts2
,&ts1
)*1.0e-9;
1616 if (timediff
> audit_timeout
) {
1617 smb_time_audit_log_fname("get_real_filename", timediff
, path
);
1623 static const char *smb_time_audit_connectpath(vfs_handle_struct
*handle
,
1627 struct timespec ts1
,ts2
;
1630 clock_gettime_mono(&ts1
);
1631 result
= SMB_VFS_NEXT_CONNECTPATH(handle
, fname
);
1632 clock_gettime_mono(&ts2
);
1633 timediff
= nsec_time_diff(&ts2
,&ts1
)*1.0e-9;
1635 if (timediff
> audit_timeout
) {
1636 smb_time_audit_log_fname("connectpath", timediff
, fname
);
1642 static NTSTATUS
smb_time_audit_brl_lock_windows(struct vfs_handle_struct
*handle
,
1643 struct byte_range_lock
*br_lck
,
1644 struct lock_struct
*plock
,
1648 struct timespec ts1
,ts2
;
1651 clock_gettime_mono(&ts1
);
1652 result
= SMB_VFS_NEXT_BRL_LOCK_WINDOWS(handle
, br_lck
, plock
,
1654 clock_gettime_mono(&ts2
);
1655 timediff
= nsec_time_diff(&ts2
,&ts1
)*1.0e-9;
1657 if (timediff
> audit_timeout
) {
1658 smb_time_audit_log_fsp("brl_lock_windows", timediff
,
1665 static bool smb_time_audit_brl_unlock_windows(struct vfs_handle_struct
*handle
,
1666 struct messaging_context
*msg_ctx
,
1667 struct byte_range_lock
*br_lck
,
1668 const struct lock_struct
*plock
)
1671 struct timespec ts1
,ts2
;
1674 clock_gettime_mono(&ts1
);
1675 result
= SMB_VFS_NEXT_BRL_UNLOCK_WINDOWS(handle
, msg_ctx
, br_lck
,
1677 clock_gettime_mono(&ts2
);
1678 timediff
= nsec_time_diff(&ts2
,&ts1
)*1.0e-9;
1680 if (timediff
> audit_timeout
) {
1681 smb_time_audit_log_fsp("brl_unlock_windows", timediff
,
1688 static bool smb_time_audit_brl_cancel_windows(struct vfs_handle_struct
*handle
,
1689 struct byte_range_lock
*br_lck
,
1690 struct lock_struct
*plock
)
1693 struct timespec ts1
,ts2
;
1696 clock_gettime_mono(&ts1
);
1697 result
= SMB_VFS_NEXT_BRL_CANCEL_WINDOWS(handle
, br_lck
, plock
);
1698 clock_gettime_mono(&ts2
);
1699 timediff
= nsec_time_diff(&ts2
,&ts1
)*1.0e-9;
1701 if (timediff
> audit_timeout
) {
1702 smb_time_audit_log_fsp("brl_cancel_windows", timediff
,
1709 static bool smb_time_audit_strict_lock(struct vfs_handle_struct
*handle
,
1710 struct files_struct
*fsp
,
1711 struct lock_struct
*plock
)
1714 struct timespec ts1
,ts2
;
1717 clock_gettime_mono(&ts1
);
1718 result
= SMB_VFS_NEXT_STRICT_LOCK(handle
, fsp
, plock
);
1719 clock_gettime_mono(&ts2
);
1720 timediff
= nsec_time_diff(&ts2
,&ts1
)*1.0e-9;
1722 if (timediff
> audit_timeout
) {
1723 smb_time_audit_log_fsp("strict_lock", timediff
, fsp
);
1729 static void smb_time_audit_strict_unlock(struct vfs_handle_struct
*handle
,
1730 struct files_struct
*fsp
,
1731 struct lock_struct
*plock
)
1733 struct timespec ts1
,ts2
;
1736 clock_gettime_mono(&ts1
);
1737 SMB_VFS_NEXT_STRICT_UNLOCK(handle
, fsp
, plock
);
1738 clock_gettime_mono(&ts2
);
1739 timediff
= nsec_time_diff(&ts2
,&ts1
)*1.0e-9;
1741 if (timediff
> audit_timeout
) {
1742 smb_time_audit_log_fsp("strict_unlock", timediff
, fsp
);
1746 static NTSTATUS
smb_time_audit_translate_name(struct vfs_handle_struct
*handle
,
1748 enum vfs_translate_direction direction
,
1749 TALLOC_CTX
*mem_ctx
,
1753 struct timespec ts1
,ts2
;
1756 clock_gettime_mono(&ts1
);
1757 result
= SMB_VFS_NEXT_TRANSLATE_NAME(handle
, name
, direction
, mem_ctx
,
1759 clock_gettime_mono(&ts2
);
1760 timediff
= nsec_time_diff(&ts2
,&ts1
)*1.0e-9;
1762 if (timediff
> audit_timeout
) {
1763 smb_time_audit_log_fname("translate_name", timediff
, name
);
1769 static NTSTATUS
smb_time_audit_fsctl(struct vfs_handle_struct
*handle
,
1770 struct files_struct
*fsp
,
1774 const uint8_t *_in_data
,
1776 uint8_t **_out_data
,
1777 uint32_t max_out_len
,
1781 struct timespec ts1
,ts2
;
1784 clock_gettime_mono(&ts1
);
1785 result
= SMB_VFS_NEXT_FSCTL(handle
,
1795 clock_gettime_mono(&ts2
);
1796 timediff
= nsec_time_diff(&ts2
,&ts1
)*1.0e-9;
1798 if (timediff
> audit_timeout
) {
1799 smb_time_audit_log_fsp("fsctl", timediff
, fsp
);
1805 static NTSTATUS
smb_time_get_dos_attributes(struct vfs_handle_struct
*handle
,
1806 struct smb_filename
*smb_fname
,
1810 struct timespec ts1
,ts2
;
1813 clock_gettime_mono(&ts1
);
1814 result
= SMB_VFS_NEXT_GET_DOS_ATTRIBUTES(handle
,
1817 clock_gettime_mono(&ts2
);
1818 timediff
= nsec_time_diff(&ts2
,&ts1
)*1.0e-9;
1820 if (timediff
> audit_timeout
) {
1821 smb_time_audit_log_fname("get_dos_attributes",
1823 smb_fname
->base_name
);
1829 static NTSTATUS
smb_time_fget_dos_attributes(struct vfs_handle_struct
*handle
,
1830 struct files_struct
*fsp
,
1834 struct timespec ts1
,ts2
;
1837 clock_gettime_mono(&ts1
);
1838 result
= SMB_VFS_NEXT_FGET_DOS_ATTRIBUTES(handle
,
1841 clock_gettime_mono(&ts2
);
1842 timediff
= nsec_time_diff(&ts2
,&ts1
)*1.0e-9;
1844 if (timediff
> audit_timeout
) {
1845 smb_time_audit_log_fsp("fget_dos_attributes", timediff
, fsp
);
1851 static NTSTATUS
smb_time_set_dos_attributes(struct vfs_handle_struct
*handle
,
1852 const struct smb_filename
*smb_fname
,
1856 struct timespec ts1
,ts2
;
1859 clock_gettime_mono(&ts1
);
1860 result
= SMB_VFS_NEXT_SET_DOS_ATTRIBUTES(handle
,
1863 clock_gettime_mono(&ts2
);
1864 timediff
= nsec_time_diff(&ts2
,&ts1
)*1.0e-9;
1866 if (timediff
> audit_timeout
) {
1867 smb_time_audit_log_fname("set_dos_attributes",
1869 smb_fname
->base_name
);
1875 static NTSTATUS
smb_time_fset_dos_attributes(struct vfs_handle_struct
*handle
,
1876 struct files_struct
*fsp
,
1880 struct timespec ts1
,ts2
;
1883 clock_gettime_mono(&ts1
);
1884 result
= SMB_VFS_NEXT_FSET_DOS_ATTRIBUTES(handle
,
1887 clock_gettime_mono(&ts2
);
1888 timediff
= nsec_time_diff(&ts2
,&ts1
)*1.0e-9;
1890 if (timediff
> audit_timeout
) {
1891 smb_time_audit_log_fsp("fset_dos_attributes", timediff
, fsp
);
1897 struct time_audit_cc_state
{
1898 struct timespec ts_send
;
1899 struct vfs_handle_struct
*handle
;
1902 static void smb_time_audit_copy_chunk_done(struct tevent_req
*subreq
);
1904 static struct tevent_req
*smb_time_audit_copy_chunk_send(struct vfs_handle_struct
*handle
,
1905 TALLOC_CTX
*mem_ctx
,
1906 struct tevent_context
*ev
,
1907 struct files_struct
*src_fsp
,
1909 struct files_struct
*dest_fsp
,
1914 struct tevent_req
*req
;
1915 struct tevent_req
*subreq
;
1916 struct time_audit_cc_state
*cc_state
;
1918 req
= tevent_req_create(mem_ctx
, &cc_state
, struct time_audit_cc_state
);
1923 cc_state
->handle
= handle
;
1924 clock_gettime_mono(&cc_state
->ts_send
);
1925 subreq
= SMB_VFS_NEXT_COPY_CHUNK_SEND(handle
, cc_state
, ev
,
1927 dest_fsp
, dest_off
, num
, flags
);
1928 if (tevent_req_nomem(subreq
, req
)) {
1929 return tevent_req_post(req
, ev
);
1932 tevent_req_set_callback(subreq
, smb_time_audit_copy_chunk_done
, req
);
1936 static void smb_time_audit_copy_chunk_done(struct tevent_req
*subreq
)
1938 struct tevent_req
*req
= tevent_req_callback_data(
1939 subreq
, struct tevent_req
);
1940 struct time_audit_cc_state
*cc_state
1941 = tevent_req_data(req
, struct time_audit_cc_state
);
1944 status
= SMB_VFS_NEXT_COPY_CHUNK_RECV(cc_state
->handle
,
1947 TALLOC_FREE(subreq
);
1948 if (tevent_req_nterror(req
, status
)) {
1951 tevent_req_done(req
);
1954 static NTSTATUS
smb_time_audit_copy_chunk_recv(struct vfs_handle_struct
*handle
,
1955 struct tevent_req
*req
,
1958 struct time_audit_cc_state
*cc_state
1959 = tevent_req_data(req
, struct time_audit_cc_state
);
1960 struct timespec ts_recv
;
1964 clock_gettime_mono(&ts_recv
);
1965 timediff
= nsec_time_diff(&ts_recv
, &cc_state
->ts_send
)*1.0e-9;
1966 if (timediff
> audit_timeout
) {
1967 smb_time_audit_log("copy_chunk", timediff
);
1970 *copied
= cc_state
->copied
;
1971 if (tevent_req_is_nterror(req
, &status
)) {
1972 tevent_req_received(req
);
1976 tevent_req_received(req
);
1977 return NT_STATUS_OK
;
1980 static NTSTATUS
smb_time_audit_get_compression(vfs_handle_struct
*handle
,
1981 TALLOC_CTX
*mem_ctx
,
1982 struct files_struct
*fsp
,
1983 struct smb_filename
*smb_fname
,
1984 uint16_t *_compression_fmt
)
1987 struct timespec ts1
,ts2
;
1990 clock_gettime_mono(&ts1
);
1991 result
= SMB_VFS_NEXT_GET_COMPRESSION(handle
, mem_ctx
, fsp
, smb_fname
,
1993 clock_gettime_mono(&ts2
);
1994 timediff
= nsec_time_diff(&ts2
,&ts1
)*1.0e-9;
1996 if (timediff
> audit_timeout
) {
1998 smb_time_audit_log_fsp("get_compression",
2001 smb_time_audit_log_smb_fname("get_compression",
2002 timediff
, smb_fname
);
2009 static NTSTATUS
smb_time_audit_set_compression(vfs_handle_struct
*handle
,
2010 TALLOC_CTX
*mem_ctx
,
2011 struct files_struct
*fsp
,
2012 uint16_t compression_fmt
)
2015 struct timespec ts1
,ts2
;
2018 clock_gettime_mono(&ts1
);
2019 result
= SMB_VFS_NEXT_SET_COMPRESSION(handle
, mem_ctx
, fsp
,
2021 clock_gettime_mono(&ts2
);
2022 timediff
= nsec_time_diff(&ts2
,&ts1
)*1.0e-9;
2024 if (timediff
> audit_timeout
) {
2025 smb_time_audit_log_fsp("set_compression", timediff
, fsp
);
2031 static NTSTATUS
smb_time_audit_readdir_attr(struct vfs_handle_struct
*handle
,
2032 const struct smb_filename
*fname
,
2033 TALLOC_CTX
*mem_ctx
,
2034 struct readdir_attr_data
**pattr_data
)
2037 struct timespec ts1
,ts2
;
2040 clock_gettime_mono(&ts1
);
2041 status
= SMB_VFS_NEXT_READDIR_ATTR(handle
, fname
, mem_ctx
, pattr_data
);
2042 clock_gettime_mono(&ts2
);
2043 timediff
= nsec_time_diff(&ts2
,&ts1
)*1.0e-9;
2045 if (timediff
> audit_timeout
) {
2046 smb_time_audit_log_smb_fname("readdir_attr", timediff
, fname
);
2052 static NTSTATUS
smb_time_audit_fget_nt_acl(vfs_handle_struct
*handle
,
2054 uint32_t security_info
,
2055 TALLOC_CTX
*mem_ctx
,
2056 struct security_descriptor
**ppdesc
)
2059 struct timespec ts1
,ts2
;
2062 clock_gettime_mono(&ts1
);
2063 result
= SMB_VFS_NEXT_FGET_NT_ACL(handle
, fsp
, security_info
,
2065 clock_gettime_mono(&ts2
);
2066 timediff
= nsec_time_diff(&ts2
,&ts1
)*1.0e-9;
2068 if (timediff
> audit_timeout
) {
2069 smb_time_audit_log_fsp("fget_nt_acl", timediff
, fsp
);
2075 static NTSTATUS
smb_time_audit_get_nt_acl(vfs_handle_struct
*handle
,
2076 const struct smb_filename
*smb_fname
,
2077 uint32_t security_info
,
2078 TALLOC_CTX
*mem_ctx
,
2079 struct security_descriptor
**ppdesc
)
2082 struct timespec ts1
,ts2
;
2085 clock_gettime_mono(&ts1
);
2086 result
= SMB_VFS_NEXT_GET_NT_ACL(handle
, smb_fname
, security_info
,
2088 clock_gettime_mono(&ts2
);
2089 timediff
= nsec_time_diff(&ts2
,&ts1
)*1.0e-9;
2091 if (timediff
> audit_timeout
) {
2092 smb_time_audit_log_fname("get_nt_acl",
2094 smb_fname
->base_name
);
2100 static NTSTATUS
smb_time_audit_fset_nt_acl(vfs_handle_struct
*handle
,
2102 uint32_t security_info_sent
,
2103 const struct security_descriptor
*psd
)
2106 struct timespec ts1
,ts2
;
2109 clock_gettime_mono(&ts1
);
2110 result
= SMB_VFS_NEXT_FSET_NT_ACL(handle
, fsp
, security_info_sent
,
2112 clock_gettime_mono(&ts2
);
2113 timediff
= nsec_time_diff(&ts2
,&ts1
)*1.0e-9;
2115 if (timediff
> audit_timeout
) {
2116 smb_time_audit_log_fsp("fset_nt_acl", timediff
, fsp
);
2122 static NTSTATUS
smb_time_audit_audit_file(struct vfs_handle_struct
*handle
,
2123 struct smb_filename
*smb_fname
,
2124 struct security_acl
*sacl
,
2125 uint32_t access_requested
,
2126 uint32_t access_denied
)
2129 struct timespec ts1
,ts2
;
2132 clock_gettime_mono(&ts1
);
2133 result
= SMB_VFS_NEXT_AUDIT_FILE(handle
,
2138 clock_gettime_mono(&ts2
);
2139 timediff
= nsec_time_diff(&ts2
,&ts1
)*1.0e-9;
2141 if (timediff
> audit_timeout
) {
2142 smb_time_audit_log_fname("audit_file",
2144 smb_fname
->base_name
);
2152 static int smb_time_audit_chmod_acl(vfs_handle_struct
*handle
,
2153 const struct smb_filename
*smb_fname
,
2157 struct timespec ts1
,ts2
;
2160 clock_gettime_mono(&ts1
);
2161 result
= SMB_VFS_NEXT_CHMOD_ACL(handle
, smb_fname
, mode
);
2162 clock_gettime_mono(&ts2
);
2163 timediff
= nsec_time_diff(&ts2
,&ts1
)*1.0e-9;
2165 if (timediff
> audit_timeout
) {
2166 smb_time_audit_log_fname("chmod_acl",
2168 smb_fname
->base_name
);
2174 static int smb_time_audit_fchmod_acl(vfs_handle_struct
*handle
,
2175 files_struct
*fsp
, mode_t mode
)
2178 struct timespec ts1
,ts2
;
2181 clock_gettime_mono(&ts1
);
2182 result
= SMB_VFS_NEXT_FCHMOD_ACL(handle
, fsp
, mode
);
2183 clock_gettime_mono(&ts2
);
2184 timediff
= nsec_time_diff(&ts2
,&ts1
)*1.0e-9;
2186 if (timediff
> audit_timeout
) {
2187 smb_time_audit_log_fsp("fchmod_acl", timediff
, fsp
);
2193 static SMB_ACL_T
smb_time_audit_sys_acl_get_file(vfs_handle_struct
*handle
,
2194 const struct smb_filename
*smb_fname
,
2195 SMB_ACL_TYPE_T type
,
2196 TALLOC_CTX
*mem_ctx
)
2199 struct timespec ts1
,ts2
;
2202 clock_gettime_mono(&ts1
);
2203 result
= SMB_VFS_NEXT_SYS_ACL_GET_FILE(handle
, smb_fname
,
2205 clock_gettime_mono(&ts2
);
2206 timediff
= nsec_time_diff(&ts2
,&ts1
)*1.0e-9;
2208 if (timediff
> audit_timeout
) {
2209 smb_time_audit_log_fname("sys_acl_get_file", timediff
,
2210 smb_fname
->base_name
);
2216 static SMB_ACL_T
smb_time_audit_sys_acl_get_fd(vfs_handle_struct
*handle
,
2218 TALLOC_CTX
*mem_ctx
)
2221 struct timespec ts1
,ts2
;
2224 clock_gettime_mono(&ts1
);
2225 result
= SMB_VFS_NEXT_SYS_ACL_GET_FD(handle
, fsp
, mem_ctx
);
2226 clock_gettime_mono(&ts2
);
2227 timediff
= nsec_time_diff(&ts2
,&ts1
)*1.0e-9;
2229 if (timediff
> audit_timeout
) {
2230 smb_time_audit_log_fsp("sys_acl_get_fd", timediff
, fsp
);
2237 static int smb_time_audit_sys_acl_blob_get_file(vfs_handle_struct
*handle
,
2238 const struct smb_filename
*smb_fname
,
2239 TALLOC_CTX
*mem_ctx
,
2240 char **blob_description
,
2244 struct timespec ts1
,ts2
;
2247 clock_gettime_mono(&ts1
);
2248 result
= SMB_VFS_NEXT_SYS_ACL_BLOB_GET_FILE(handle
, smb_fname
,
2249 mem_ctx
, blob_description
, blob
);
2250 clock_gettime_mono(&ts2
);
2251 timediff
= nsec_time_diff(&ts2
,&ts1
)*1.0e-9;
2253 if (timediff
> audit_timeout
) {
2254 smb_time_audit_log("sys_acl_blob_get_file", timediff
);
2260 static int smb_time_audit_sys_acl_blob_get_fd(vfs_handle_struct
*handle
,
2262 TALLOC_CTX
*mem_ctx
,
2263 char **blob_description
,
2267 struct timespec ts1
,ts2
;
2270 clock_gettime_mono(&ts1
);
2271 result
= SMB_VFS_NEXT_SYS_ACL_BLOB_GET_FD(handle
, fsp
, mem_ctx
, blob_description
, blob
);
2272 clock_gettime_mono(&ts2
);
2273 timediff
= nsec_time_diff(&ts2
,&ts1
)*1.0e-9;
2275 if (timediff
> audit_timeout
) {
2276 smb_time_audit_log("sys_acl_blob_get_fd", timediff
);
2282 static int smb_time_audit_sys_acl_set_file(vfs_handle_struct
*handle
,
2283 const struct smb_filename
*smb_fname
,
2284 SMB_ACL_TYPE_T acltype
,
2288 struct timespec ts1
,ts2
;
2291 clock_gettime_mono(&ts1
);
2292 result
= SMB_VFS_NEXT_SYS_ACL_SET_FILE(handle
, smb_fname
, acltype
,
2294 clock_gettime_mono(&ts2
);
2295 timediff
= nsec_time_diff(&ts2
,&ts1
)*1.0e-9;
2297 if (timediff
> audit_timeout
) {
2298 smb_time_audit_log_fname("sys_acl_set_file", timediff
,
2299 smb_fname
->base_name
);
2305 static int smb_time_audit_sys_acl_set_fd(vfs_handle_struct
*handle
,
2310 struct timespec ts1
,ts2
;
2313 clock_gettime_mono(&ts1
);
2314 result
= SMB_VFS_NEXT_SYS_ACL_SET_FD(handle
, fsp
, theacl
);
2315 clock_gettime_mono(&ts2
);
2316 timediff
= nsec_time_diff(&ts2
,&ts1
)*1.0e-9;
2318 if (timediff
> audit_timeout
) {
2319 smb_time_audit_log_fsp("sys_acl_set_fd", timediff
, fsp
);
2325 static int smb_time_audit_sys_acl_delete_def_file(vfs_handle_struct
*handle
,
2326 const struct smb_filename
*smb_fname
)
2329 struct timespec ts1
,ts2
;
2332 clock_gettime_mono(&ts1
);
2333 result
= SMB_VFS_NEXT_SYS_ACL_DELETE_DEF_FILE(handle
, smb_fname
);
2334 clock_gettime_mono(&ts2
);
2335 timediff
= nsec_time_diff(&ts2
,&ts1
)*1.0e-9;
2337 if (timediff
> audit_timeout
) {
2338 smb_time_audit_log_fname("sys_acl_delete_def_file", timediff
,
2339 smb_fname
->base_name
);
2345 static ssize_t
smb_time_audit_getxattr(struct vfs_handle_struct
*handle
,
2346 const struct smb_filename
*smb_fname
,
2352 struct timespec ts1
,ts2
;
2355 clock_gettime_mono(&ts1
);
2356 result
= SMB_VFS_NEXT_GETXATTR(handle
, smb_fname
, name
, value
, size
);
2357 clock_gettime_mono(&ts2
);
2358 timediff
= nsec_time_diff(&ts2
,&ts1
)*1.0e-9;
2360 if (timediff
> audit_timeout
) {
2361 smb_time_audit_log_fname("getxattr", timediff
,
2362 smb_fname
->base_name
);
2368 static ssize_t
smb_time_audit_fgetxattr(struct vfs_handle_struct
*handle
,
2369 struct files_struct
*fsp
,
2370 const char *name
, void *value
,
2374 struct timespec ts1
,ts2
;
2377 clock_gettime_mono(&ts1
);
2378 result
= SMB_VFS_NEXT_FGETXATTR(handle
, fsp
, name
, value
, size
);
2379 clock_gettime_mono(&ts2
);
2380 timediff
= nsec_time_diff(&ts2
,&ts1
)*1.0e-9;
2382 if (timediff
> audit_timeout
) {
2383 smb_time_audit_log_fsp("fgetxattr", timediff
, fsp
);
2389 static ssize_t
smb_time_audit_listxattr(struct vfs_handle_struct
*handle
,
2390 const struct smb_filename
*smb_fname
,
2395 struct timespec ts1
,ts2
;
2398 clock_gettime_mono(&ts1
);
2399 result
= SMB_VFS_NEXT_LISTXATTR(handle
, smb_fname
, list
, size
);
2400 clock_gettime_mono(&ts2
);
2401 timediff
= nsec_time_diff(&ts2
,&ts1
)*1.0e-9;
2403 if (timediff
> audit_timeout
) {
2404 smb_time_audit_log_fname("listxattr", timediff
,
2405 smb_fname
->base_name
);
2411 static ssize_t
smb_time_audit_flistxattr(struct vfs_handle_struct
*handle
,
2412 struct files_struct
*fsp
, char *list
,
2416 struct timespec ts1
,ts2
;
2419 clock_gettime_mono(&ts1
);
2420 result
= SMB_VFS_NEXT_FLISTXATTR(handle
, fsp
, list
, size
);
2421 clock_gettime_mono(&ts2
);
2422 timediff
= nsec_time_diff(&ts2
,&ts1
)*1.0e-9;
2424 if (timediff
> audit_timeout
) {
2425 smb_time_audit_log_fsp("flistxattr", timediff
, fsp
);
2431 static int smb_time_audit_removexattr(struct vfs_handle_struct
*handle
,
2432 const struct smb_filename
*smb_fname
,
2436 struct timespec ts1
,ts2
;
2439 clock_gettime_mono(&ts1
);
2440 result
= SMB_VFS_NEXT_REMOVEXATTR(handle
, smb_fname
, name
);
2441 clock_gettime_mono(&ts2
);
2442 timediff
= nsec_time_diff(&ts2
,&ts1
)*1.0e-9;
2444 if (timediff
> audit_timeout
) {
2445 smb_time_audit_log_fname("removexattr", timediff
,
2446 smb_fname
->base_name
);
2452 static int smb_time_audit_fremovexattr(struct vfs_handle_struct
*handle
,
2453 struct files_struct
*fsp
,
2457 struct timespec ts1
,ts2
;
2460 clock_gettime_mono(&ts1
);
2461 result
= SMB_VFS_NEXT_FREMOVEXATTR(handle
, fsp
, name
);
2462 clock_gettime_mono(&ts2
);
2463 timediff
= nsec_time_diff(&ts2
,&ts1
)*1.0e-9;
2465 if (timediff
> audit_timeout
) {
2466 smb_time_audit_log_fsp("fremovexattr", timediff
, fsp
);
2472 static int smb_time_audit_setxattr(struct vfs_handle_struct
*handle
,
2473 const struct smb_filename
*smb_fname
,
2480 struct timespec ts1
,ts2
;
2483 clock_gettime_mono(&ts1
);
2484 result
= SMB_VFS_NEXT_SETXATTR(handle
, smb_fname
, name
, value
, size
,
2486 clock_gettime_mono(&ts2
);
2487 timediff
= nsec_time_diff(&ts2
,&ts1
)*1.0e-9;
2489 if (timediff
> audit_timeout
) {
2490 smb_time_audit_log_fname("setxattr", timediff
,
2491 smb_fname
->base_name
);
2497 static int smb_time_audit_fsetxattr(struct vfs_handle_struct
*handle
,
2498 struct files_struct
*fsp
, const char *name
,
2499 const void *value
, size_t size
, int flags
)
2502 struct timespec ts1
,ts2
;
2505 clock_gettime_mono(&ts1
);
2506 result
= SMB_VFS_NEXT_FSETXATTR(handle
, fsp
, name
, value
, size
, flags
);
2507 clock_gettime_mono(&ts2
);
2508 timediff
= nsec_time_diff(&ts2
,&ts1
)*1.0e-9;
2510 if (timediff
> audit_timeout
) {
2511 smb_time_audit_log_fsp("fsetxattr", timediff
, fsp
);
2517 static bool smb_time_audit_aio_force(struct vfs_handle_struct
*handle
,
2518 struct files_struct
*fsp
)
2521 struct timespec ts1
,ts2
;
2524 clock_gettime_mono(&ts1
);
2525 result
= SMB_VFS_NEXT_AIO_FORCE(handle
, fsp
);
2526 clock_gettime_mono(&ts2
);
2527 timediff
= nsec_time_diff(&ts2
,&ts1
)*1.0e-9;
2529 if (timediff
> audit_timeout
) {
2530 smb_time_audit_log_fsp("aio_force", timediff
, fsp
);
2536 static NTSTATUS
smb_time_audit_durable_cookie(struct vfs_handle_struct
*handle
,
2537 struct files_struct
*fsp
,
2538 TALLOC_CTX
*mem_ctx
,
2542 struct timespec ts1
,ts2
;
2545 clock_gettime_mono(&ts1
);
2546 result
= SMB_VFS_NEXT_DURABLE_COOKIE(handle
, fsp
, mem_ctx
, cookie
);
2547 clock_gettime_mono(&ts2
);
2548 timediff
= nsec_time_diff(&ts2
,&ts1
)*1.0e-9;
2550 if (timediff
> audit_timeout
) {
2551 smb_time_audit_log_fsp("durable_cookie", timediff
, fsp
);
2557 static NTSTATUS
smb_time_audit_durable_disconnect(struct vfs_handle_struct
*handle
,
2558 struct files_struct
*fsp
,
2559 const DATA_BLOB old_cookie
,
2560 TALLOC_CTX
*mem_ctx
,
2561 DATA_BLOB
*new_cookie
)
2564 struct timespec ts1
,ts2
;
2567 clock_gettime_mono(&ts1
);
2568 result
= SMB_VFS_NEXT_DURABLE_DISCONNECT(handle
, fsp
, old_cookie
,
2569 mem_ctx
, new_cookie
);
2570 clock_gettime_mono(&ts2
);
2571 timediff
= nsec_time_diff(&ts2
,&ts1
)*1.0e-9;
2573 if (timediff
> audit_timeout
) {
2574 smb_time_audit_log_fsp("durable_disconnect", timediff
, fsp
);
2580 static NTSTATUS
smb_time_audit_durable_reconnect(struct vfs_handle_struct
*handle
,
2581 struct smb_request
*smb1req
,
2582 struct smbXsrv_open
*op
,
2583 const DATA_BLOB old_cookie
,
2584 TALLOC_CTX
*mem_ctx
,
2585 struct files_struct
**fsp
,
2586 DATA_BLOB
*new_cookie
)
2589 struct timespec ts1
,ts2
;
2592 clock_gettime_mono(&ts1
);
2593 result
= SMB_VFS_NEXT_DURABLE_RECONNECT(handle
, smb1req
, op
, old_cookie
,
2594 mem_ctx
, fsp
, new_cookie
);
2595 clock_gettime_mono(&ts2
);
2596 timediff
= nsec_time_diff(&ts2
,&ts1
)*1.0e-9;
2598 if (timediff
> audit_timeout
) {
2599 smb_time_audit_log("durable_reconnect", timediff
);
2605 /* VFS operations */
2607 static struct vfs_fn_pointers vfs_time_audit_fns
= {
2608 .connect_fn
= smb_time_audit_connect
,
2609 .disconnect_fn
= smb_time_audit_disconnect
,
2610 .disk_free_fn
= smb_time_audit_disk_free
,
2611 .get_quota_fn
= smb_time_audit_get_quota
,
2612 .set_quota_fn
= smb_time_audit_set_quota
,
2613 .get_shadow_copy_data_fn
= smb_time_audit_get_shadow_copy_data
,
2614 .statvfs_fn
= smb_time_audit_statvfs
,
2615 .fs_capabilities_fn
= smb_time_audit_fs_capabilities
,
2616 .get_dfs_referrals_fn
= smb_time_audit_get_dfs_referrals
,
2617 .opendir_fn
= smb_time_audit_opendir
,
2618 .fdopendir_fn
= smb_time_audit_fdopendir
,
2619 .readdir_fn
= smb_time_audit_readdir
,
2620 .seekdir_fn
= smb_time_audit_seekdir
,
2621 .telldir_fn
= smb_time_audit_telldir
,
2622 .rewind_dir_fn
= smb_time_audit_rewinddir
,
2623 .mkdir_fn
= smb_time_audit_mkdir
,
2624 .rmdir_fn
= smb_time_audit_rmdir
,
2625 .closedir_fn
= smb_time_audit_closedir
,
2626 .init_search_op_fn
= smb_time_audit_init_search_op
,
2627 .open_fn
= smb_time_audit_open
,
2628 .create_file_fn
= smb_time_audit_create_file
,
2629 .close_fn
= smb_time_audit_close
,
2630 .read_fn
= smb_time_audit_read
,
2631 .pread_fn
= smb_time_audit_pread
,
2632 .pread_send_fn
= smb_time_audit_pread_send
,
2633 .pread_recv_fn
= smb_time_audit_pread_recv
,
2634 .write_fn
= smb_time_audit_write
,
2635 .pwrite_fn
= smb_time_audit_pwrite
,
2636 .pwrite_send_fn
= smb_time_audit_pwrite_send
,
2637 .pwrite_recv_fn
= smb_time_audit_pwrite_recv
,
2638 .lseek_fn
= smb_time_audit_lseek
,
2639 .sendfile_fn
= smb_time_audit_sendfile
,
2640 .recvfile_fn
= smb_time_audit_recvfile
,
2641 .rename_fn
= smb_time_audit_rename
,
2642 .fsync_fn
= smb_time_audit_fsync
,
2643 .fsync_send_fn
= smb_time_audit_fsync_send
,
2644 .fsync_recv_fn
= smb_time_audit_fsync_recv
,
2645 .stat_fn
= smb_time_audit_stat
,
2646 .fstat_fn
= smb_time_audit_fstat
,
2647 .lstat_fn
= smb_time_audit_lstat
,
2648 .get_alloc_size_fn
= smb_time_audit_get_alloc_size
,
2649 .unlink_fn
= smb_time_audit_unlink
,
2650 .chmod_fn
= smb_time_audit_chmod
,
2651 .fchmod_fn
= smb_time_audit_fchmod
,
2652 .chown_fn
= smb_time_audit_chown
,
2653 .fchown_fn
= smb_time_audit_fchown
,
2654 .lchown_fn
= smb_time_audit_lchown
,
2655 .chdir_fn
= smb_time_audit_chdir
,
2656 .getwd_fn
= smb_time_audit_getwd
,
2657 .ntimes_fn
= smb_time_audit_ntimes
,
2658 .ftruncate_fn
= smb_time_audit_ftruncate
,
2659 .fallocate_fn
= smb_time_audit_fallocate
,
2660 .lock_fn
= smb_time_audit_lock
,
2661 .kernel_flock_fn
= smb_time_audit_kernel_flock
,
2662 .linux_setlease_fn
= smb_time_audit_linux_setlease
,
2663 .getlock_fn
= smb_time_audit_getlock
,
2664 .symlink_fn
= smb_time_audit_symlink
,
2665 .readlink_fn
= smb_time_audit_readlink
,
2666 .link_fn
= smb_time_audit_link
,
2667 .mknod_fn
= smb_time_audit_mknod
,
2668 .realpath_fn
= smb_time_audit_realpath
,
2669 .chflags_fn
= smb_time_audit_chflags
,
2670 .file_id_create_fn
= smb_time_audit_file_id_create
,
2671 .copy_chunk_send_fn
= smb_time_audit_copy_chunk_send
,
2672 .copy_chunk_recv_fn
= smb_time_audit_copy_chunk_recv
,
2673 .get_compression_fn
= smb_time_audit_get_compression
,
2674 .set_compression_fn
= smb_time_audit_set_compression
,
2675 .snap_check_path_fn
= smb_time_audit_snap_check_path
,
2676 .snap_create_fn
= smb_time_audit_snap_create
,
2677 .snap_delete_fn
= smb_time_audit_snap_delete
,
2678 .streaminfo_fn
= smb_time_audit_streaminfo
,
2679 .get_real_filename_fn
= smb_time_audit_get_real_filename
,
2680 .connectpath_fn
= smb_time_audit_connectpath
,
2681 .brl_lock_windows_fn
= smb_time_audit_brl_lock_windows
,
2682 .brl_unlock_windows_fn
= smb_time_audit_brl_unlock_windows
,
2683 .brl_cancel_windows_fn
= smb_time_audit_brl_cancel_windows
,
2684 .strict_lock_fn
= smb_time_audit_strict_lock
,
2685 .strict_unlock_fn
= smb_time_audit_strict_unlock
,
2686 .translate_name_fn
= smb_time_audit_translate_name
,
2687 .fsctl_fn
= smb_time_audit_fsctl
,
2688 .get_dos_attributes_fn
= smb_time_get_dos_attributes
,
2689 .fget_dos_attributes_fn
= smb_time_fget_dos_attributes
,
2690 .set_dos_attributes_fn
= smb_time_set_dos_attributes
,
2691 .fset_dos_attributes_fn
= smb_time_fset_dos_attributes
,
2692 .fget_nt_acl_fn
= smb_time_audit_fget_nt_acl
,
2693 .get_nt_acl_fn
= smb_time_audit_get_nt_acl
,
2694 .fset_nt_acl_fn
= smb_time_audit_fset_nt_acl
,
2695 .audit_file_fn
= smb_time_audit_audit_file
,
2696 .chmod_acl_fn
= smb_time_audit_chmod_acl
,
2697 .fchmod_acl_fn
= smb_time_audit_fchmod_acl
,
2698 .sys_acl_get_file_fn
= smb_time_audit_sys_acl_get_file
,
2699 .sys_acl_get_fd_fn
= smb_time_audit_sys_acl_get_fd
,
2700 .sys_acl_blob_get_file_fn
= smb_time_audit_sys_acl_blob_get_file
,
2701 .sys_acl_blob_get_fd_fn
= smb_time_audit_sys_acl_blob_get_fd
,
2702 .sys_acl_set_file_fn
= smb_time_audit_sys_acl_set_file
,
2703 .sys_acl_set_fd_fn
= smb_time_audit_sys_acl_set_fd
,
2704 .sys_acl_delete_def_file_fn
= smb_time_audit_sys_acl_delete_def_file
,
2705 .getxattr_fn
= smb_time_audit_getxattr
,
2706 .fgetxattr_fn
= smb_time_audit_fgetxattr
,
2707 .listxattr_fn
= smb_time_audit_listxattr
,
2708 .flistxattr_fn
= smb_time_audit_flistxattr
,
2709 .removexattr_fn
= smb_time_audit_removexattr
,
2710 .fremovexattr_fn
= smb_time_audit_fremovexattr
,
2711 .setxattr_fn
= smb_time_audit_setxattr
,
2712 .fsetxattr_fn
= smb_time_audit_fsetxattr
,
2713 .aio_force_fn
= smb_time_audit_aio_force
,
2714 .durable_cookie_fn
= smb_time_audit_durable_cookie
,
2715 .durable_disconnect_fn
= smb_time_audit_durable_disconnect
,
2716 .durable_reconnect_fn
= smb_time_audit_durable_reconnect
,
2717 .readdir_attr_fn
= smb_time_audit_readdir_attr
,
2721 NTSTATUS
vfs_time_audit_init(TALLOC_CTX
*);
2722 NTSTATUS
vfs_time_audit_init(TALLOC_CTX
*ctx
)
2724 smb_vfs_assert_all_fns(&vfs_time_audit_fns
, "time_audit");
2726 audit_timeout
= (double)lp_parm_int(-1, "time_audit", "timeout",
2728 return smb_register_vfs(SMB_VFS_INTERFACE_VERSION
, "time_audit",
2729 &vfs_time_audit_fns
);