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 struct smb_filename *smb_time_audit_getwd(vfs_handle_struct *handle,
1261 TALLOC_CTX *mem_ctx)
1263 struct smb_filename *result;
1264 struct timespec ts1,ts2;
1267 clock_gettime_mono(&ts1);
1268 result = SMB_VFS_NEXT_GETWD(handle, mem_ctx);
1269 clock_gettime_mono(&ts2);
1270 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1272 if (timediff > audit_timeout) {
1273 smb_time_audit_log("getwd", timediff);
1279 static int smb_time_audit_ntimes(vfs_handle_struct *handle,
1280 const struct smb_filename *path,
1281 struct smb_file_time *ft)
1284 struct timespec ts1,ts2;
1287 clock_gettime_mono(&ts1);
1288 result = SMB_VFS_NEXT_NTIMES(handle, path, ft);
1289 clock_gettime_mono(&ts2);
1290 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1292 if (timediff > audit_timeout) {
1293 smb_time_audit_log_smb_fname("ntimes", timediff, path);
1299 static int smb_time_audit_ftruncate(vfs_handle_struct *handle,
1304 struct timespec ts1,ts2;
1307 clock_gettime_mono(&ts1);
1308 result = SMB_VFS_NEXT_FTRUNCATE(handle, fsp, len);
1309 clock_gettime_mono(&ts2);
1310 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1312 if (timediff > audit_timeout) {
1313 smb_time_audit_log_fsp("ftruncate", timediff, fsp);
1319 static int smb_time_audit_fallocate(vfs_handle_struct *handle,
1326 int saved_errno = 0;
1327 struct timespec ts1,ts2;
1330 clock_gettime_mono(&ts1);
1331 result = SMB_VFS_NEXT_FALLOCATE(handle, fsp, mode, offset, len);
1333 saved_errno = errno;
1335 clock_gettime_mono(&ts2);
1336 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1338 if (timediff > audit_timeout) {
1339 smb_time_audit_log_fsp("fallocate", timediff, fsp);
1342 errno = saved_errno;
1347 static bool smb_time_audit_lock(vfs_handle_struct *handle, files_struct *fsp,
1348 int op, off_t offset, off_t count,
1352 struct timespec ts1,ts2;
1355 clock_gettime_mono(&ts1);
1356 result = SMB_VFS_NEXT_LOCK(handle, fsp, op, offset, count, type);
1357 clock_gettime_mono(&ts2);
1358 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1360 if (timediff > audit_timeout) {
1361 smb_time_audit_log_fsp("lock", timediff, fsp);
1367 static int smb_time_audit_kernel_flock(struct vfs_handle_struct *handle,
1368 struct files_struct *fsp,
1369 uint32_t share_mode, uint32_t access_mask)
1372 struct timespec ts1,ts2;
1375 clock_gettime_mono(&ts1);
1376 result = SMB_VFS_NEXT_KERNEL_FLOCK(handle, fsp, share_mode,
1378 clock_gettime_mono(&ts2);
1379 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1381 if (timediff > audit_timeout) {
1382 smb_time_audit_log_fsp("kernel_flock", timediff, fsp);
1388 static int smb_time_audit_linux_setlease(vfs_handle_struct *handle,
1393 struct timespec ts1,ts2;
1396 clock_gettime_mono(&ts1);
1397 result = SMB_VFS_NEXT_LINUX_SETLEASE(handle, fsp, leasetype);
1398 clock_gettime_mono(&ts2);
1399 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1401 if (timediff > audit_timeout) {
1402 smb_time_audit_log_fsp("linux_setlease", timediff, fsp);
1408 static bool smb_time_audit_getlock(vfs_handle_struct *handle,
1410 off_t *poffset, off_t *pcount,
1411 int *ptype, pid_t *ppid)
1414 struct timespec ts1,ts2;
1417 clock_gettime_mono(&ts1);
1418 result = SMB_VFS_NEXT_GETLOCK(handle, fsp, poffset, pcount, ptype,
1420 clock_gettime_mono(&ts2);
1421 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1423 if (timediff > audit_timeout) {
1424 smb_time_audit_log_fsp("getlock", timediff, fsp);
1430 static int smb_time_audit_symlink(vfs_handle_struct *handle,
1431 const char *link_contents,
1432 const struct smb_filename *new_smb_fname)
1435 struct timespec ts1,ts2;
1438 clock_gettime_mono(&ts1);
1439 result = SMB_VFS_NEXT_SYMLINK(handle, link_contents, new_smb_fname);
1440 clock_gettime_mono(&ts2);
1441 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1443 if (timediff > audit_timeout) {
1444 smb_time_audit_log_fname("symlink", timediff,
1445 new_smb_fname->base_name);
1451 static int smb_time_audit_readlink(vfs_handle_struct *handle,
1452 const struct smb_filename *smb_fname,
1457 struct timespec ts1,ts2;
1460 clock_gettime_mono(&ts1);
1461 result = SMB_VFS_NEXT_READLINK(handle, smb_fname,
1463 clock_gettime_mono(&ts2);
1464 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1466 if (timediff > audit_timeout) {
1467 smb_time_audit_log_fname("readlink", timediff,
1468 smb_fname->base_name);
1474 static int smb_time_audit_link(vfs_handle_struct *handle,
1475 const struct smb_filename *old_smb_fname,
1476 const struct smb_filename *new_smb_fname)
1479 struct timespec ts1,ts2;
1482 clock_gettime_mono(&ts1);
1483 result = SMB_VFS_NEXT_LINK(handle, old_smb_fname, new_smb_fname);
1484 clock_gettime_mono(&ts2);
1485 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1487 if (timediff > audit_timeout) {
1488 smb_time_audit_log_fname("link", timediff,
1489 new_smb_fname->base_name);
1495 static int smb_time_audit_mknod(vfs_handle_struct *handle,
1496 const struct smb_filename *smb_fname,
1501 struct timespec ts1,ts2;
1504 clock_gettime_mono(&ts1);
1505 result = SMB_VFS_NEXT_MKNOD(handle, smb_fname, mode, dev);
1506 clock_gettime_mono(&ts2);
1507 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1509 if (timediff > audit_timeout) {
1510 smb_time_audit_log_smb_fname("mknod", timediff, smb_fname);
1516 static struct smb_filename *smb_time_audit_realpath(vfs_handle_struct *handle,
1518 const struct smb_filename *smb_fname)
1520 struct smb_filename *result_fname;
1521 struct timespec ts1,ts2;
1524 clock_gettime_mono(&ts1);
1525 result_fname = SMB_VFS_NEXT_REALPATH(handle, ctx, smb_fname);
1526 clock_gettime_mono(&ts2);
1527 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1529 if (timediff > audit_timeout) {
1530 smb_time_audit_log_fname("realpath", timediff,
1531 smb_fname->base_name);
1534 return result_fname;
1537 static int smb_time_audit_chflags(vfs_handle_struct *handle,
1538 const struct smb_filename *smb_fname,
1542 struct timespec ts1,ts2;
1545 clock_gettime_mono(&ts1);
1546 result = SMB_VFS_NEXT_CHFLAGS(handle, smb_fname, flags);
1547 clock_gettime_mono(&ts2);
1548 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1550 if (timediff > audit_timeout) {
1551 smb_time_audit_log_smb_fname("chflags", timediff, smb_fname);
1557 static struct file_id smb_time_audit_file_id_create(struct vfs_handle_struct *handle,
1558 const SMB_STRUCT_STAT *sbuf)
1560 struct file_id id_zero;
1561 struct file_id result;
1562 struct timespec ts1,ts2;
1565 ZERO_STRUCT(id_zero);
1567 clock_gettime_mono(&ts1);
1568 result = SMB_VFS_NEXT_FILE_ID_CREATE(handle, sbuf);
1569 clock_gettime_mono(&ts2);
1570 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1572 if (timediff > audit_timeout) {
1573 smb_time_audit_log("file_id_create", timediff);
1579 static NTSTATUS smb_time_audit_streaminfo(vfs_handle_struct *handle,
1580 struct files_struct *fsp,
1581 const struct smb_filename *smb_fname,
1582 TALLOC_CTX *mem_ctx,
1583 unsigned int *pnum_streams,
1584 struct stream_struct **pstreams)
1587 struct timespec ts1,ts2;
1590 clock_gettime_mono(&ts1);
1591 result = SMB_VFS_NEXT_STREAMINFO(handle, fsp, smb_fname, mem_ctx,
1592 pnum_streams, pstreams);
1593 clock_gettime_mono(&ts2);
1594 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1596 if (timediff > audit_timeout) {
1597 smb_time_audit_log_fsp("streaminfo", timediff, fsp);
1603 static int smb_time_audit_get_real_filename(struct vfs_handle_struct *handle,
1606 TALLOC_CTX *mem_ctx,
1610 struct timespec ts1,ts2;
1613 clock_gettime_mono(&ts1);
1614 result = SMB_VFS_NEXT_GET_REAL_FILENAME(handle, path, name, mem_ctx,
1616 clock_gettime_mono(&ts2);
1617 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1619 if (timediff > audit_timeout) {
1620 smb_time_audit_log_fname("get_real_filename", timediff, path);
1626 static const char *smb_time_audit_connectpath(vfs_handle_struct *handle,
1627 const struct smb_filename *smb_fname)
1630 struct timespec ts1,ts2;
1633 clock_gettime_mono(&ts1);
1634 result = SMB_VFS_NEXT_CONNECTPATH(handle, smb_fname);
1635 clock_gettime_mono(&ts2);
1636 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1638 if (timediff > audit_timeout) {
1639 smb_time_audit_log_fname("connectpath", timediff,
1640 smb_fname->base_name);
1646 static NTSTATUS smb_time_audit_brl_lock_windows(struct vfs_handle_struct *handle,
1647 struct byte_range_lock *br_lck,
1648 struct lock_struct *plock,
1652 struct timespec ts1,ts2;
1655 clock_gettime_mono(&ts1);
1656 result = SMB_VFS_NEXT_BRL_LOCK_WINDOWS(handle, br_lck, plock,
1658 clock_gettime_mono(&ts2);
1659 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1661 if (timediff > audit_timeout) {
1662 smb_time_audit_log_fsp("brl_lock_windows", timediff,
1669 static bool smb_time_audit_brl_unlock_windows(struct vfs_handle_struct *handle,
1670 struct messaging_context *msg_ctx,
1671 struct byte_range_lock *br_lck,
1672 const struct lock_struct *plock)
1675 struct timespec ts1,ts2;
1678 clock_gettime_mono(&ts1);
1679 result = SMB_VFS_NEXT_BRL_UNLOCK_WINDOWS(handle, msg_ctx, br_lck,
1681 clock_gettime_mono(&ts2);
1682 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1684 if (timediff > audit_timeout) {
1685 smb_time_audit_log_fsp("brl_unlock_windows", timediff,
1692 static bool smb_time_audit_brl_cancel_windows(struct vfs_handle_struct *handle,
1693 struct byte_range_lock *br_lck,
1694 struct lock_struct *plock)
1697 struct timespec ts1,ts2;
1700 clock_gettime_mono(&ts1);
1701 result = SMB_VFS_NEXT_BRL_CANCEL_WINDOWS(handle, br_lck, plock);
1702 clock_gettime_mono(&ts2);
1703 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1705 if (timediff > audit_timeout) {
1706 smb_time_audit_log_fsp("brl_cancel_windows", timediff,
1713 static bool smb_time_audit_strict_lock(struct vfs_handle_struct *handle,
1714 struct files_struct *fsp,
1715 struct lock_struct *plock)
1718 struct timespec ts1,ts2;
1721 clock_gettime_mono(&ts1);
1722 result = SMB_VFS_NEXT_STRICT_LOCK(handle, fsp, plock);
1723 clock_gettime_mono(&ts2);
1724 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1726 if (timediff > audit_timeout) {
1727 smb_time_audit_log_fsp("strict_lock", timediff, fsp);
1733 static void smb_time_audit_strict_unlock(struct vfs_handle_struct *handle,
1734 struct files_struct *fsp,
1735 struct lock_struct *plock)
1737 struct timespec ts1,ts2;
1740 clock_gettime_mono(&ts1);
1741 SMB_VFS_NEXT_STRICT_UNLOCK(handle, fsp, plock);
1742 clock_gettime_mono(&ts2);
1743 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1745 if (timediff > audit_timeout) {
1746 smb_time_audit_log_fsp("strict_unlock", timediff, fsp);
1750 static NTSTATUS smb_time_audit_translate_name(struct vfs_handle_struct *handle,
1752 enum vfs_translate_direction direction,
1753 TALLOC_CTX *mem_ctx,
1757 struct timespec ts1,ts2;
1760 clock_gettime_mono(&ts1);
1761 result = SMB_VFS_NEXT_TRANSLATE_NAME(handle, name, direction, mem_ctx,
1763 clock_gettime_mono(&ts2);
1764 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1766 if (timediff > audit_timeout) {
1767 smb_time_audit_log_fname("translate_name", timediff, name);
1773 static NTSTATUS smb_time_audit_fsctl(struct vfs_handle_struct *handle,
1774 struct files_struct *fsp,
1778 const uint8_t *_in_data,
1780 uint8_t **_out_data,
1781 uint32_t max_out_len,
1785 struct timespec ts1,ts2;
1788 clock_gettime_mono(&ts1);
1789 result = SMB_VFS_NEXT_FSCTL(handle,
1799 clock_gettime_mono(&ts2);
1800 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1802 if (timediff > audit_timeout) {
1803 smb_time_audit_log_fsp("fsctl", timediff, fsp);
1809 static NTSTATUS smb_time_get_dos_attributes(struct vfs_handle_struct *handle,
1810 struct smb_filename *smb_fname,
1814 struct timespec ts1,ts2;
1817 clock_gettime_mono(&ts1);
1818 result = SMB_VFS_NEXT_GET_DOS_ATTRIBUTES(handle,
1821 clock_gettime_mono(&ts2);
1822 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1824 if (timediff > audit_timeout) {
1825 smb_time_audit_log_fname("get_dos_attributes",
1827 smb_fname->base_name);
1833 static NTSTATUS smb_time_fget_dos_attributes(struct vfs_handle_struct *handle,
1834 struct files_struct *fsp,
1838 struct timespec ts1,ts2;
1841 clock_gettime_mono(&ts1);
1842 result = SMB_VFS_NEXT_FGET_DOS_ATTRIBUTES(handle,
1845 clock_gettime_mono(&ts2);
1846 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1848 if (timediff > audit_timeout) {
1849 smb_time_audit_log_fsp("fget_dos_attributes", timediff, fsp);
1855 static NTSTATUS smb_time_set_dos_attributes(struct vfs_handle_struct *handle,
1856 const struct smb_filename *smb_fname,
1860 struct timespec ts1,ts2;
1863 clock_gettime_mono(&ts1);
1864 result = SMB_VFS_NEXT_SET_DOS_ATTRIBUTES(handle,
1867 clock_gettime_mono(&ts2);
1868 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1870 if (timediff > audit_timeout) {
1871 smb_time_audit_log_fname("set_dos_attributes",
1873 smb_fname->base_name);
1879 static NTSTATUS smb_time_fset_dos_attributes(struct vfs_handle_struct *handle,
1880 struct files_struct *fsp,
1884 struct timespec ts1,ts2;
1887 clock_gettime_mono(&ts1);
1888 result = SMB_VFS_NEXT_FSET_DOS_ATTRIBUTES(handle,
1891 clock_gettime_mono(&ts2);
1892 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1894 if (timediff > audit_timeout) {
1895 smb_time_audit_log_fsp("fset_dos_attributes", timediff, fsp);
1901 struct time_audit_cc_state {
1902 struct timespec ts_send;
1903 struct vfs_handle_struct *handle;
1906 static void smb_time_audit_copy_chunk_done(struct tevent_req *subreq);
1908 static struct tevent_req *smb_time_audit_copy_chunk_send(struct vfs_handle_struct *handle,
1909 TALLOC_CTX *mem_ctx,
1910 struct tevent_context *ev,
1911 struct files_struct *src_fsp,
1913 struct files_struct *dest_fsp,
1918 struct tevent_req *req;
1919 struct tevent_req *subreq;
1920 struct time_audit_cc_state *cc_state;
1922 req = tevent_req_create(mem_ctx, &cc_state, struct time_audit_cc_state);
1927 cc_state->handle = handle;
1928 clock_gettime_mono(&cc_state->ts_send);
1929 subreq = SMB_VFS_NEXT_COPY_CHUNK_SEND(handle, cc_state, ev,
1931 dest_fsp, dest_off, num, flags);
1932 if (tevent_req_nomem(subreq, req)) {
1933 return tevent_req_post(req, ev);
1936 tevent_req_set_callback(subreq, smb_time_audit_copy_chunk_done, req);
1940 static void smb_time_audit_copy_chunk_done(struct tevent_req *subreq)
1942 struct tevent_req *req = tevent_req_callback_data(
1943 subreq, struct tevent_req);
1944 struct time_audit_cc_state *cc_state
1945 = tevent_req_data(req, struct time_audit_cc_state);
1948 status = SMB_VFS_NEXT_COPY_CHUNK_RECV(cc_state->handle,
1951 TALLOC_FREE(subreq);
1952 if (tevent_req_nterror(req, status)) {
1955 tevent_req_done(req);
1958 static NTSTATUS smb_time_audit_copy_chunk_recv(struct vfs_handle_struct *handle,
1959 struct tevent_req *req,
1962 struct time_audit_cc_state *cc_state
1963 = tevent_req_data(req, struct time_audit_cc_state);
1964 struct timespec ts_recv;
1968 clock_gettime_mono(&ts_recv);
1969 timediff = nsec_time_diff(&ts_recv, &cc_state->ts_send)*1.0e-9;
1970 if (timediff > audit_timeout) {
1971 smb_time_audit_log("copy_chunk", timediff);
1974 *copied = cc_state->copied;
1975 if (tevent_req_is_nterror(req, &status)) {
1976 tevent_req_received(req);
1980 tevent_req_received(req);
1981 return NT_STATUS_OK;
1984 static NTSTATUS smb_time_audit_get_compression(vfs_handle_struct *handle,
1985 TALLOC_CTX *mem_ctx,
1986 struct files_struct *fsp,
1987 struct smb_filename *smb_fname,
1988 uint16_t *_compression_fmt)
1991 struct timespec ts1,ts2;
1994 clock_gettime_mono(&ts1);
1995 result = SMB_VFS_NEXT_GET_COMPRESSION(handle, mem_ctx, fsp, smb_fname,
1997 clock_gettime_mono(&ts2);
1998 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2000 if (timediff > audit_timeout) {
2002 smb_time_audit_log_fsp("get_compression",
2005 smb_time_audit_log_smb_fname("get_compression",
2006 timediff, smb_fname);
2013 static NTSTATUS smb_time_audit_set_compression(vfs_handle_struct *handle,
2014 TALLOC_CTX *mem_ctx,
2015 struct files_struct *fsp,
2016 uint16_t compression_fmt)
2019 struct timespec ts1,ts2;
2022 clock_gettime_mono(&ts1);
2023 result = SMB_VFS_NEXT_SET_COMPRESSION(handle, mem_ctx, fsp,
2025 clock_gettime_mono(&ts2);
2026 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2028 if (timediff > audit_timeout) {
2029 smb_time_audit_log_fsp("set_compression", timediff, fsp);
2035 static NTSTATUS smb_time_audit_readdir_attr(struct vfs_handle_struct *handle,
2036 const struct smb_filename *fname,
2037 TALLOC_CTX *mem_ctx,
2038 struct readdir_attr_data **pattr_data)
2041 struct timespec ts1,ts2;
2044 clock_gettime_mono(&ts1);
2045 status = SMB_VFS_NEXT_READDIR_ATTR(handle, fname, mem_ctx, pattr_data);
2046 clock_gettime_mono(&ts2);
2047 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2049 if (timediff > audit_timeout) {
2050 smb_time_audit_log_smb_fname("readdir_attr", timediff, fname);
2056 static NTSTATUS smb_time_audit_fget_nt_acl(vfs_handle_struct *handle,
2058 uint32_t security_info,
2059 TALLOC_CTX *mem_ctx,
2060 struct security_descriptor **ppdesc)
2063 struct timespec ts1,ts2;
2066 clock_gettime_mono(&ts1);
2067 result = SMB_VFS_NEXT_FGET_NT_ACL(handle, fsp, security_info,
2069 clock_gettime_mono(&ts2);
2070 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2072 if (timediff > audit_timeout) {
2073 smb_time_audit_log_fsp("fget_nt_acl", timediff, fsp);
2079 static NTSTATUS smb_time_audit_get_nt_acl(vfs_handle_struct *handle,
2080 const struct smb_filename *smb_fname,
2081 uint32_t security_info,
2082 TALLOC_CTX *mem_ctx,
2083 struct security_descriptor **ppdesc)
2086 struct timespec ts1,ts2;
2089 clock_gettime_mono(&ts1);
2090 result = SMB_VFS_NEXT_GET_NT_ACL(handle, smb_fname, security_info,
2092 clock_gettime_mono(&ts2);
2093 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2095 if (timediff > audit_timeout) {
2096 smb_time_audit_log_fname("get_nt_acl",
2098 smb_fname->base_name);
2104 static NTSTATUS smb_time_audit_fset_nt_acl(vfs_handle_struct *handle,
2106 uint32_t security_info_sent,
2107 const struct security_descriptor *psd)
2110 struct timespec ts1,ts2;
2113 clock_gettime_mono(&ts1);
2114 result = SMB_VFS_NEXT_FSET_NT_ACL(handle, fsp, security_info_sent,
2116 clock_gettime_mono(&ts2);
2117 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2119 if (timediff > audit_timeout) {
2120 smb_time_audit_log_fsp("fset_nt_acl", timediff, fsp);
2126 static NTSTATUS smb_time_audit_audit_file(struct vfs_handle_struct *handle,
2127 struct smb_filename *smb_fname,
2128 struct security_acl *sacl,
2129 uint32_t access_requested,
2130 uint32_t access_denied)
2133 struct timespec ts1,ts2;
2136 clock_gettime_mono(&ts1);
2137 result = SMB_VFS_NEXT_AUDIT_FILE(handle,
2142 clock_gettime_mono(&ts2);
2143 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2145 if (timediff > audit_timeout) {
2146 smb_time_audit_log_fname("audit_file",
2148 smb_fname->base_name);
2156 static int smb_time_audit_chmod_acl(vfs_handle_struct *handle,
2157 const struct smb_filename *smb_fname,
2161 struct timespec ts1,ts2;
2164 clock_gettime_mono(&ts1);
2165 result = SMB_VFS_NEXT_CHMOD_ACL(handle, smb_fname, mode);
2166 clock_gettime_mono(&ts2);
2167 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2169 if (timediff > audit_timeout) {
2170 smb_time_audit_log_fname("chmod_acl",
2172 smb_fname->base_name);
2178 static int smb_time_audit_fchmod_acl(vfs_handle_struct *handle,
2179 files_struct *fsp, mode_t mode)
2182 struct timespec ts1,ts2;
2185 clock_gettime_mono(&ts1);
2186 result = SMB_VFS_NEXT_FCHMOD_ACL(handle, fsp, mode);
2187 clock_gettime_mono(&ts2);
2188 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2190 if (timediff > audit_timeout) {
2191 smb_time_audit_log_fsp("fchmod_acl", timediff, fsp);
2197 static SMB_ACL_T smb_time_audit_sys_acl_get_file(vfs_handle_struct *handle,
2198 const struct smb_filename *smb_fname,
2199 SMB_ACL_TYPE_T type,
2200 TALLOC_CTX *mem_ctx)
2203 struct timespec ts1,ts2;
2206 clock_gettime_mono(&ts1);
2207 result = SMB_VFS_NEXT_SYS_ACL_GET_FILE(handle, smb_fname,
2209 clock_gettime_mono(&ts2);
2210 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2212 if (timediff > audit_timeout) {
2213 smb_time_audit_log_fname("sys_acl_get_file", timediff,
2214 smb_fname->base_name);
2220 static SMB_ACL_T smb_time_audit_sys_acl_get_fd(vfs_handle_struct *handle,
2222 TALLOC_CTX *mem_ctx)
2225 struct timespec ts1,ts2;
2228 clock_gettime_mono(&ts1);
2229 result = SMB_VFS_NEXT_SYS_ACL_GET_FD(handle, fsp, mem_ctx);
2230 clock_gettime_mono(&ts2);
2231 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2233 if (timediff > audit_timeout) {
2234 smb_time_audit_log_fsp("sys_acl_get_fd", timediff, fsp);
2241 static int smb_time_audit_sys_acl_blob_get_file(vfs_handle_struct *handle,
2242 const struct smb_filename *smb_fname,
2243 TALLOC_CTX *mem_ctx,
2244 char **blob_description,
2248 struct timespec ts1,ts2;
2251 clock_gettime_mono(&ts1);
2252 result = SMB_VFS_NEXT_SYS_ACL_BLOB_GET_FILE(handle, smb_fname,
2253 mem_ctx, blob_description, blob);
2254 clock_gettime_mono(&ts2);
2255 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2257 if (timediff > audit_timeout) {
2258 smb_time_audit_log("sys_acl_blob_get_file", timediff);
2264 static int smb_time_audit_sys_acl_blob_get_fd(vfs_handle_struct *handle,
2266 TALLOC_CTX *mem_ctx,
2267 char **blob_description,
2271 struct timespec ts1,ts2;
2274 clock_gettime_mono(&ts1);
2275 result = SMB_VFS_NEXT_SYS_ACL_BLOB_GET_FD(handle, fsp, mem_ctx, blob_description, blob);
2276 clock_gettime_mono(&ts2);
2277 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2279 if (timediff > audit_timeout) {
2280 smb_time_audit_log("sys_acl_blob_get_fd", timediff);
2286 static int smb_time_audit_sys_acl_set_file(vfs_handle_struct *handle,
2287 const struct smb_filename *smb_fname,
2288 SMB_ACL_TYPE_T acltype,
2292 struct timespec ts1,ts2;
2295 clock_gettime_mono(&ts1);
2296 result = SMB_VFS_NEXT_SYS_ACL_SET_FILE(handle, smb_fname, acltype,
2298 clock_gettime_mono(&ts2);
2299 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2301 if (timediff > audit_timeout) {
2302 smb_time_audit_log_fname("sys_acl_set_file", timediff,
2303 smb_fname->base_name);
2309 static int smb_time_audit_sys_acl_set_fd(vfs_handle_struct *handle,
2314 struct timespec ts1,ts2;
2317 clock_gettime_mono(&ts1);
2318 result = SMB_VFS_NEXT_SYS_ACL_SET_FD(handle, fsp, theacl);
2319 clock_gettime_mono(&ts2);
2320 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2322 if (timediff > audit_timeout) {
2323 smb_time_audit_log_fsp("sys_acl_set_fd", timediff, fsp);
2329 static int smb_time_audit_sys_acl_delete_def_file(vfs_handle_struct *handle,
2330 const struct smb_filename *smb_fname)
2333 struct timespec ts1,ts2;
2336 clock_gettime_mono(&ts1);
2337 result = SMB_VFS_NEXT_SYS_ACL_DELETE_DEF_FILE(handle, smb_fname);
2338 clock_gettime_mono(&ts2);
2339 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2341 if (timediff > audit_timeout) {
2342 smb_time_audit_log_fname("sys_acl_delete_def_file", timediff,
2343 smb_fname->base_name);
2349 static ssize_t smb_time_audit_getxattr(struct vfs_handle_struct *handle,
2350 const struct smb_filename *smb_fname,
2356 struct timespec ts1,ts2;
2359 clock_gettime_mono(&ts1);
2360 result = SMB_VFS_NEXT_GETXATTR(handle, smb_fname, name, value, size);
2361 clock_gettime_mono(&ts2);
2362 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2364 if (timediff > audit_timeout) {
2365 smb_time_audit_log_fname("getxattr", timediff,
2366 smb_fname->base_name);
2372 static ssize_t smb_time_audit_fgetxattr(struct vfs_handle_struct *handle,
2373 struct files_struct *fsp,
2374 const char *name, void *value,
2378 struct timespec ts1,ts2;
2381 clock_gettime_mono(&ts1);
2382 result = SMB_VFS_NEXT_FGETXATTR(handle, fsp, name, value, size);
2383 clock_gettime_mono(&ts2);
2384 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2386 if (timediff > audit_timeout) {
2387 smb_time_audit_log_fsp("fgetxattr", timediff, fsp);
2393 static ssize_t smb_time_audit_listxattr(struct vfs_handle_struct *handle,
2394 const struct smb_filename *smb_fname,
2399 struct timespec ts1,ts2;
2402 clock_gettime_mono(&ts1);
2403 result = SMB_VFS_NEXT_LISTXATTR(handle, smb_fname, list, size);
2404 clock_gettime_mono(&ts2);
2405 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2407 if (timediff > audit_timeout) {
2408 smb_time_audit_log_fname("listxattr", timediff,
2409 smb_fname->base_name);
2415 static ssize_t smb_time_audit_flistxattr(struct vfs_handle_struct *handle,
2416 struct files_struct *fsp, char *list,
2420 struct timespec ts1,ts2;
2423 clock_gettime_mono(&ts1);
2424 result = SMB_VFS_NEXT_FLISTXATTR(handle, fsp, list, size);
2425 clock_gettime_mono(&ts2);
2426 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2428 if (timediff > audit_timeout) {
2429 smb_time_audit_log_fsp("flistxattr", timediff, fsp);
2435 static int smb_time_audit_removexattr(struct vfs_handle_struct *handle,
2436 const struct smb_filename *smb_fname,
2440 struct timespec ts1,ts2;
2443 clock_gettime_mono(&ts1);
2444 result = SMB_VFS_NEXT_REMOVEXATTR(handle, smb_fname, name);
2445 clock_gettime_mono(&ts2);
2446 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2448 if (timediff > audit_timeout) {
2449 smb_time_audit_log_fname("removexattr", timediff,
2450 smb_fname->base_name);
2456 static int smb_time_audit_fremovexattr(struct vfs_handle_struct *handle,
2457 struct files_struct *fsp,
2461 struct timespec ts1,ts2;
2464 clock_gettime_mono(&ts1);
2465 result = SMB_VFS_NEXT_FREMOVEXATTR(handle, fsp, name);
2466 clock_gettime_mono(&ts2);
2467 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2469 if (timediff > audit_timeout) {
2470 smb_time_audit_log_fsp("fremovexattr", timediff, fsp);
2476 static int smb_time_audit_setxattr(struct vfs_handle_struct *handle,
2477 const struct smb_filename *smb_fname,
2484 struct timespec ts1,ts2;
2487 clock_gettime_mono(&ts1);
2488 result = SMB_VFS_NEXT_SETXATTR(handle, smb_fname, name, value, size,
2490 clock_gettime_mono(&ts2);
2491 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2493 if (timediff > audit_timeout) {
2494 smb_time_audit_log_fname("setxattr", timediff,
2495 smb_fname->base_name);
2501 static int smb_time_audit_fsetxattr(struct vfs_handle_struct *handle,
2502 struct files_struct *fsp, const char *name,
2503 const void *value, size_t size, int flags)
2506 struct timespec ts1,ts2;
2509 clock_gettime_mono(&ts1);
2510 result = SMB_VFS_NEXT_FSETXATTR(handle, fsp, name, value, size, flags);
2511 clock_gettime_mono(&ts2);
2512 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2514 if (timediff > audit_timeout) {
2515 smb_time_audit_log_fsp("fsetxattr", timediff, fsp);
2521 static bool smb_time_audit_aio_force(struct vfs_handle_struct *handle,
2522 struct files_struct *fsp)
2525 struct timespec ts1,ts2;
2528 clock_gettime_mono(&ts1);
2529 result = SMB_VFS_NEXT_AIO_FORCE(handle, fsp);
2530 clock_gettime_mono(&ts2);
2531 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2533 if (timediff > audit_timeout) {
2534 smb_time_audit_log_fsp("aio_force", timediff, fsp);
2540 static NTSTATUS smb_time_audit_durable_cookie(struct vfs_handle_struct *handle,
2541 struct files_struct *fsp,
2542 TALLOC_CTX *mem_ctx,
2546 struct timespec ts1,ts2;
2549 clock_gettime_mono(&ts1);
2550 result = SMB_VFS_NEXT_DURABLE_COOKIE(handle, fsp, mem_ctx, cookie);
2551 clock_gettime_mono(&ts2);
2552 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2554 if (timediff > audit_timeout) {
2555 smb_time_audit_log_fsp("durable_cookie", timediff, fsp);
2561 static NTSTATUS smb_time_audit_durable_disconnect(struct vfs_handle_struct *handle,
2562 struct files_struct *fsp,
2563 const DATA_BLOB old_cookie,
2564 TALLOC_CTX *mem_ctx,
2565 DATA_BLOB *new_cookie)
2568 struct timespec ts1,ts2;
2571 clock_gettime_mono(&ts1);
2572 result = SMB_VFS_NEXT_DURABLE_DISCONNECT(handle, fsp, old_cookie,
2573 mem_ctx, new_cookie);
2574 clock_gettime_mono(&ts2);
2575 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2577 if (timediff > audit_timeout) {
2578 smb_time_audit_log_fsp("durable_disconnect", timediff, fsp);
2584 static NTSTATUS smb_time_audit_durable_reconnect(struct vfs_handle_struct *handle,
2585 struct smb_request *smb1req,
2586 struct smbXsrv_open *op,
2587 const DATA_BLOB old_cookie,
2588 TALLOC_CTX *mem_ctx,
2589 struct files_struct **fsp,
2590 DATA_BLOB *new_cookie)
2593 struct timespec ts1,ts2;
2596 clock_gettime_mono(&ts1);
2597 result = SMB_VFS_NEXT_DURABLE_RECONNECT(handle, smb1req, op, old_cookie,
2598 mem_ctx, fsp, new_cookie);
2599 clock_gettime_mono(&ts2);
2600 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2602 if (timediff > audit_timeout) {
2603 smb_time_audit_log("durable_reconnect", timediff);
2609 /* VFS operations */
2611 static struct vfs_fn_pointers vfs_time_audit_fns = {
2612 .connect_fn = smb_time_audit_connect,
2613 .disconnect_fn = smb_time_audit_disconnect,
2614 .disk_free_fn = smb_time_audit_disk_free,
2615 .get_quota_fn = smb_time_audit_get_quota,
2616 .set_quota_fn = smb_time_audit_set_quota,
2617 .get_shadow_copy_data_fn = smb_time_audit_get_shadow_copy_data,
2618 .statvfs_fn = smb_time_audit_statvfs,
2619 .fs_capabilities_fn = smb_time_audit_fs_capabilities,
2620 .get_dfs_referrals_fn = smb_time_audit_get_dfs_referrals,
2621 .opendir_fn = smb_time_audit_opendir,
2622 .fdopendir_fn = smb_time_audit_fdopendir,
2623 .readdir_fn = smb_time_audit_readdir,
2624 .seekdir_fn = smb_time_audit_seekdir,
2625 .telldir_fn = smb_time_audit_telldir,
2626 .rewind_dir_fn = smb_time_audit_rewinddir,
2627 .mkdir_fn = smb_time_audit_mkdir,
2628 .rmdir_fn = smb_time_audit_rmdir,
2629 .closedir_fn = smb_time_audit_closedir,
2630 .init_search_op_fn = smb_time_audit_init_search_op,
2631 .open_fn = smb_time_audit_open,
2632 .create_file_fn = smb_time_audit_create_file,
2633 .close_fn = smb_time_audit_close,
2634 .read_fn = smb_time_audit_read,
2635 .pread_fn = smb_time_audit_pread,
2636 .pread_send_fn = smb_time_audit_pread_send,
2637 .pread_recv_fn = smb_time_audit_pread_recv,
2638 .write_fn = smb_time_audit_write,
2639 .pwrite_fn = smb_time_audit_pwrite,
2640 .pwrite_send_fn = smb_time_audit_pwrite_send,
2641 .pwrite_recv_fn = smb_time_audit_pwrite_recv,
2642 .lseek_fn = smb_time_audit_lseek,
2643 .sendfile_fn = smb_time_audit_sendfile,
2644 .recvfile_fn = smb_time_audit_recvfile,
2645 .rename_fn = smb_time_audit_rename,
2646 .fsync_fn = smb_time_audit_fsync,
2647 .fsync_send_fn = smb_time_audit_fsync_send,
2648 .fsync_recv_fn = smb_time_audit_fsync_recv,
2649 .stat_fn = smb_time_audit_stat,
2650 .fstat_fn = smb_time_audit_fstat,
2651 .lstat_fn = smb_time_audit_lstat,
2652 .get_alloc_size_fn = smb_time_audit_get_alloc_size,
2653 .unlink_fn = smb_time_audit_unlink,
2654 .chmod_fn = smb_time_audit_chmod,
2655 .fchmod_fn = smb_time_audit_fchmod,
2656 .chown_fn = smb_time_audit_chown,
2657 .fchown_fn = smb_time_audit_fchown,
2658 .lchown_fn = smb_time_audit_lchown,
2659 .chdir_fn = smb_time_audit_chdir,
2660 .getwd_fn = smb_time_audit_getwd,
2661 .ntimes_fn = smb_time_audit_ntimes,
2662 .ftruncate_fn = smb_time_audit_ftruncate,
2663 .fallocate_fn = smb_time_audit_fallocate,
2664 .lock_fn = smb_time_audit_lock,
2665 .kernel_flock_fn = smb_time_audit_kernel_flock,
2666 .linux_setlease_fn = smb_time_audit_linux_setlease,
2667 .getlock_fn = smb_time_audit_getlock,
2668 .symlink_fn = smb_time_audit_symlink,
2669 .readlink_fn = smb_time_audit_readlink,
2670 .link_fn = smb_time_audit_link,
2671 .mknod_fn = smb_time_audit_mknod,
2672 .realpath_fn = smb_time_audit_realpath,
2673 .chflags_fn = smb_time_audit_chflags,
2674 .file_id_create_fn = smb_time_audit_file_id_create,
2675 .copy_chunk_send_fn = smb_time_audit_copy_chunk_send,
2676 .copy_chunk_recv_fn = smb_time_audit_copy_chunk_recv,
2677 .get_compression_fn = smb_time_audit_get_compression,
2678 .set_compression_fn = smb_time_audit_set_compression,
2679 .snap_check_path_fn = smb_time_audit_snap_check_path,
2680 .snap_create_fn = smb_time_audit_snap_create,
2681 .snap_delete_fn = smb_time_audit_snap_delete,
2682 .streaminfo_fn = smb_time_audit_streaminfo,
2683 .get_real_filename_fn = smb_time_audit_get_real_filename,
2684 .connectpath_fn = smb_time_audit_connectpath,
2685 .brl_lock_windows_fn = smb_time_audit_brl_lock_windows,
2686 .brl_unlock_windows_fn = smb_time_audit_brl_unlock_windows,
2687 .brl_cancel_windows_fn = smb_time_audit_brl_cancel_windows,
2688 .strict_lock_fn = smb_time_audit_strict_lock,
2689 .strict_unlock_fn = smb_time_audit_strict_unlock,
2690 .translate_name_fn = smb_time_audit_translate_name,
2691 .fsctl_fn = smb_time_audit_fsctl,
2692 .get_dos_attributes_fn = smb_time_get_dos_attributes,
2693 .fget_dos_attributes_fn = smb_time_fget_dos_attributes,
2694 .set_dos_attributes_fn = smb_time_set_dos_attributes,
2695 .fset_dos_attributes_fn = smb_time_fset_dos_attributes,
2696 .fget_nt_acl_fn = smb_time_audit_fget_nt_acl,
2697 .get_nt_acl_fn = smb_time_audit_get_nt_acl,
2698 .fset_nt_acl_fn = smb_time_audit_fset_nt_acl,
2699 .audit_file_fn = smb_time_audit_audit_file,
2700 .chmod_acl_fn = smb_time_audit_chmod_acl,
2701 .fchmod_acl_fn = smb_time_audit_fchmod_acl,
2702 .sys_acl_get_file_fn = smb_time_audit_sys_acl_get_file,
2703 .sys_acl_get_fd_fn = smb_time_audit_sys_acl_get_fd,
2704 .sys_acl_blob_get_file_fn = smb_time_audit_sys_acl_blob_get_file,
2705 .sys_acl_blob_get_fd_fn = smb_time_audit_sys_acl_blob_get_fd,
2706 .sys_acl_set_file_fn = smb_time_audit_sys_acl_set_file,
2707 .sys_acl_set_fd_fn = smb_time_audit_sys_acl_set_fd,
2708 .sys_acl_delete_def_file_fn = smb_time_audit_sys_acl_delete_def_file,
2709 .getxattr_fn = smb_time_audit_getxattr,
2710 .fgetxattr_fn = smb_time_audit_fgetxattr,
2711 .listxattr_fn = smb_time_audit_listxattr,
2712 .flistxattr_fn = smb_time_audit_flistxattr,
2713 .removexattr_fn = smb_time_audit_removexattr,
2714 .fremovexattr_fn = smb_time_audit_fremovexattr,
2715 .setxattr_fn = smb_time_audit_setxattr,
2716 .fsetxattr_fn = smb_time_audit_fsetxattr,
2717 .aio_force_fn = smb_time_audit_aio_force,
2718 .durable_cookie_fn = smb_time_audit_durable_cookie,
2719 .durable_disconnect_fn = smb_time_audit_durable_disconnect,
2720 .durable_reconnect_fn = smb_time_audit_durable_reconnect,
2721 .readdir_attr_fn = smb_time_audit_readdir_attr,
2725 NTSTATUS vfs_time_audit_init(TALLOC_CTX *);
2726 NTSTATUS vfs_time_audit_init(TALLOC_CTX *ctx)
2728 smb_vfs_assert_all_fns(&vfs_time_audit_fns, "time_audit");
2730 audit_timeout = (double)lp_parm_int(-1, "time_audit", "timeout",
2732 return smb_register_vfs(SMB_VFS_INTERFACE_VERSION, "time_audit",
2733 &vfs_time_audit_fns);