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_at(const char *syscallname,
91 const struct files_struct *dir_fsp,
92 const struct smb_filename *smb_fname)
96 msg = talloc_asprintf(talloc_tos(),
97 "filename = \"%s/%s/%s\"",
98 dir_fsp->conn->connectpath,
99 dir_fsp->fsp_name->base_name,
100 smb_fname->base_name);
102 smb_time_audit_log_msg(syscallname, elapsed, msg);
106 static void smb_time_audit_log_fname(const char *syscallname, double elapsed,
112 if (getcwd(cwd, sizeof(cwd)) == NULL) {
113 snprintf(cwd, sizeof(cwd), "<getcwd() error %d>", errno);
116 msg = talloc_asprintf(talloc_tos(),
117 "cwd = \"%s\", filename = \"%s\"",
120 msg = talloc_asprintf(talloc_tos(),
121 "cwd = \"%s\", filename = <NULL>",
124 smb_time_audit_log_msg(syscallname, elapsed, msg);
128 static void smb_time_audit_log_smb_fname(const char *syscallname, double elapsed,
129 const struct smb_filename *smb_fname)
131 if (smb_fname != NULL) {
132 smb_time_audit_log_fname(syscallname, elapsed,
133 smb_fname->base_name);
135 smb_time_audit_log_fname(syscallname, elapsed,
136 "smb_fname = <NULL>");
140 static int smb_time_audit_connect(vfs_handle_struct *handle,
141 const char *svc, const char *user)
144 struct timespec ts1,ts2;
151 clock_gettime_mono(&ts1);
152 result = SMB_VFS_NEXT_CONNECT(handle, svc, user);
153 clock_gettime_mono(&ts2);
154 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
155 if (timediff > audit_timeout) {
156 smb_time_audit_log_msg("connect", timediff, user);
161 static void smb_time_audit_disconnect(vfs_handle_struct *handle)
163 struct timespec ts1,ts2;
166 clock_gettime_mono(&ts1);
167 SMB_VFS_NEXT_DISCONNECT(handle);
168 clock_gettime_mono(&ts2);
169 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
171 if (timediff > audit_timeout) {
172 smb_time_audit_log("disconnect", timediff);
176 static uint64_t smb_time_audit_disk_free(vfs_handle_struct *handle,
177 const struct smb_filename *smb_fname,
183 struct timespec ts1,ts2;
186 clock_gettime_mono(&ts1);
187 result = SMB_VFS_NEXT_DISK_FREE(handle, smb_fname, bsize, dfree, dsize);
188 clock_gettime_mono(&ts2);
189 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
191 /* Don't have a reasonable notion of failure here */
192 if (timediff > audit_timeout) {
193 smb_time_audit_log_fname("disk_free",
195 smb_fname->base_name);
201 static int smb_time_audit_get_quota(struct vfs_handle_struct *handle,
202 const struct smb_filename *smb_fname,
203 enum SMB_QUOTA_TYPE qtype,
208 struct timespec ts1,ts2;
211 clock_gettime_mono(&ts1);
212 result = SMB_VFS_NEXT_GET_QUOTA(handle, smb_fname, qtype, id, qt);
213 clock_gettime_mono(&ts2);
214 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
216 if (timediff > audit_timeout) {
217 smb_time_audit_log_fname("get_quota",
219 smb_fname->base_name);
224 static int smb_time_audit_set_quota(struct vfs_handle_struct *handle,
225 enum SMB_QUOTA_TYPE qtype, unid_t id,
229 struct timespec ts1,ts2;
232 clock_gettime_mono(&ts1);
233 result = SMB_VFS_NEXT_SET_QUOTA(handle, qtype, id, qt);
234 clock_gettime_mono(&ts2);
235 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
237 if (timediff > audit_timeout) {
238 smb_time_audit_log("set_quota", timediff);
244 static int smb_time_audit_get_shadow_copy_data(struct vfs_handle_struct *handle,
245 struct files_struct *fsp,
246 struct shadow_copy_data *shadow_copy_data,
250 struct timespec ts1,ts2;
253 clock_gettime_mono(&ts1);
254 result = SMB_VFS_NEXT_GET_SHADOW_COPY_DATA(handle, fsp,
255 shadow_copy_data, labels);
256 clock_gettime_mono(&ts2);
257 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
259 if (timediff > audit_timeout) {
260 smb_time_audit_log_fsp("get_shadow_copy_data", timediff, fsp);
266 static int smb_time_audit_statvfs(struct vfs_handle_struct *handle,
267 const struct smb_filename *smb_fname,
268 struct vfs_statvfs_struct *statbuf)
271 struct timespec ts1,ts2;
274 clock_gettime_mono(&ts1);
275 result = SMB_VFS_NEXT_STATVFS(handle, smb_fname, statbuf);
276 clock_gettime_mono(&ts2);
277 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
279 if (timediff > audit_timeout) {
280 smb_time_audit_log_fname("statvfs", timediff,
281 smb_fname->base_name);
287 static uint32_t smb_time_audit_fs_capabilities(struct vfs_handle_struct *handle,
288 enum timestamp_set_resolution *p_ts_res)
291 struct timespec ts1,ts2;
294 clock_gettime_mono(&ts1);
295 result = SMB_VFS_NEXT_FS_CAPABILITIES(handle, p_ts_res);
296 clock_gettime_mono(&ts2);
297 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
299 if (timediff > audit_timeout) {
300 smb_time_audit_log("fs_capabilities", timediff);
306 static NTSTATUS smb_time_audit_get_dfs_referrals(
307 struct vfs_handle_struct *handle,
308 struct dfs_GetDFSReferral *r)
311 struct timespec ts1,ts2;
314 clock_gettime_mono(&ts1);
315 result = SMB_VFS_NEXT_GET_DFS_REFERRALS(handle, r);
316 clock_gettime_mono(&ts2);
317 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
319 if (timediff > audit_timeout) {
320 smb_time_audit_log("get_dfs_referrals", timediff);
326 static NTSTATUS smb_time_audit_create_dfs_pathat(struct vfs_handle_struct *handle,
327 struct files_struct *dirfsp,
328 const struct smb_filename *smb_fname,
329 const struct referral *reflist,
330 size_t referral_count)
333 struct timespec ts1,ts2;
335 struct smb_filename *full_fname = NULL;
337 full_fname = full_path_from_dirfsp_atname(talloc_tos(),
340 if (full_fname == NULL) {
341 return NT_STATUS_NO_MEMORY;
344 clock_gettime_mono(&ts1);
345 result = SMB_VFS_NEXT_CREATE_DFS_PATHAT(handle,
350 clock_gettime_mono(&ts2);
351 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
353 if (timediff > audit_timeout) {
354 smb_time_audit_log_smb_fname("create_dfs_pathat",
358 TALLOC_FREE(full_fname);
362 static NTSTATUS smb_time_audit_read_dfs_pathat(struct vfs_handle_struct *handle,
364 struct files_struct *dirfsp,
365 struct smb_filename *smb_fname,
366 struct referral **ppreflist,
367 size_t *preferral_count)
370 struct timespec ts1,ts2;
372 struct smb_filename *full_fname = NULL;
374 full_fname = full_path_from_dirfsp_atname(talloc_tos(),
377 if (full_fname == NULL) {
378 return NT_STATUS_NO_MEMORY;
381 clock_gettime_mono(&ts1);
382 result = SMB_VFS_NEXT_READ_DFS_PATHAT(handle,
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("read_dfs_pathat",
397 TALLOC_FREE(full_fname);
401 static NTSTATUS smb_time_audit_snap_check_path(struct vfs_handle_struct *handle,
403 const char *service_path,
407 struct timespec ts1,ts2;
410 clock_gettime_mono(&ts1);
411 status = SMB_VFS_NEXT_SNAP_CHECK_PATH(handle, mem_ctx, service_path,
413 clock_gettime_mono(&ts2);
414 timediff = nsec_time_diff(&ts2, &ts1) * 1.0e-9;
416 if (timediff > audit_timeout) {
417 smb_time_audit_log("snap_check_path", timediff);
423 static NTSTATUS smb_time_audit_snap_create(struct vfs_handle_struct *handle,
425 const char *base_volume,
432 struct timespec ts1,ts2;
435 clock_gettime_mono(&ts1);
436 status = SMB_VFS_NEXT_SNAP_CREATE(handle, mem_ctx, base_volume, tstamp,
437 rw, base_path, snap_path);
438 clock_gettime_mono(&ts2);
439 timediff = nsec_time_diff(&ts2 ,&ts1) * 1.0e-9;
441 if (timediff > audit_timeout) {
442 smb_time_audit_log("snap_create", timediff);
448 static NTSTATUS smb_time_audit_snap_delete(struct vfs_handle_struct *handle,
454 struct timespec ts1,ts2;
457 clock_gettime_mono(&ts1);
458 status = SMB_VFS_NEXT_SNAP_DELETE(handle, mem_ctx, base_path,
460 clock_gettime_mono(&ts2);
461 timediff = nsec_time_diff(&ts2, &ts1) * 1.0e-9;
463 if (timediff > audit_timeout) {
464 smb_time_audit_log("snap_delete", timediff);
470 static DIR *smb_time_audit_fdopendir(vfs_handle_struct *handle,
472 const char *mask, uint32_t attr)
475 struct timespec ts1,ts2;
478 clock_gettime_mono(&ts1);
479 result = SMB_VFS_NEXT_FDOPENDIR(handle, fsp, mask, attr);
480 clock_gettime_mono(&ts2);
481 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
483 if (timediff > audit_timeout) {
484 smb_time_audit_log_fsp("fdopendir", timediff, fsp);
490 static struct dirent *smb_time_audit_readdir(vfs_handle_struct *handle,
491 struct files_struct *dirfsp,
493 SMB_STRUCT_STAT *sbuf)
495 struct dirent *result;
496 struct timespec ts1,ts2;
499 clock_gettime_mono(&ts1);
500 result = SMB_VFS_NEXT_READDIR(handle, dirfsp, dirp, sbuf);
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("readdir", timediff);
511 static void smb_time_audit_seekdir(vfs_handle_struct *handle,
512 DIR *dirp, long offset)
514 struct timespec ts1,ts2;
517 clock_gettime_mono(&ts1);
518 SMB_VFS_NEXT_SEEKDIR(handle, dirp, offset);
519 clock_gettime_mono(&ts2);
520 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
522 if (timediff > audit_timeout) {
523 smb_time_audit_log("seekdir", timediff);
528 static long smb_time_audit_telldir(vfs_handle_struct *handle,
532 struct timespec ts1,ts2;
535 clock_gettime_mono(&ts1);
536 result = SMB_VFS_NEXT_TELLDIR(handle, dirp);
537 clock_gettime_mono(&ts2);
538 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
540 if (timediff > audit_timeout) {
541 smb_time_audit_log("telldir", timediff);
547 static void smb_time_audit_rewinddir(vfs_handle_struct *handle,
550 struct timespec ts1,ts2;
553 clock_gettime_mono(&ts1);
554 SMB_VFS_NEXT_REWINDDIR(handle, dirp);
555 clock_gettime_mono(&ts2);
556 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
558 if (timediff > audit_timeout) {
559 smb_time_audit_log("rewinddir", timediff);
564 static int smb_time_audit_mkdirat(vfs_handle_struct *handle,
565 struct files_struct *dirfsp,
566 const struct smb_filename *smb_fname,
569 struct smb_filename *full_fname = NULL;
571 struct timespec ts1,ts2;
574 full_fname = full_path_from_dirfsp_atname(talloc_tos(),
577 if (full_fname == NULL) {
582 clock_gettime_mono(&ts1);
583 result = SMB_VFS_NEXT_MKDIRAT(handle,
587 clock_gettime_mono(&ts2);
588 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
590 if (timediff > audit_timeout) {
591 smb_time_audit_log_smb_fname("mkdirat",
596 TALLOC_FREE(full_fname);
601 static int smb_time_audit_closedir(vfs_handle_struct *handle,
605 struct timespec ts1,ts2;
608 clock_gettime_mono(&ts1);
609 result = SMB_VFS_NEXT_CLOSEDIR(handle, dirp);
610 clock_gettime_mono(&ts2);
611 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
613 if (timediff > audit_timeout) {
614 smb_time_audit_log("closedir", timediff);
620 static int smb_time_audit_openat(vfs_handle_struct *handle,
621 const struct files_struct *dirfsp,
622 const struct smb_filename *smb_fname,
623 struct files_struct *fsp,
624 const struct vfs_open_how *how)
627 struct timespec ts1,ts2;
630 clock_gettime_mono(&ts1);
631 result = SMB_VFS_NEXT_OPENAT(handle,
636 clock_gettime_mono(&ts2);
637 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
639 if (timediff > audit_timeout) {
640 smb_time_audit_log_fsp("openat", timediff, fsp);
646 static NTSTATUS smb_time_audit_create_file(vfs_handle_struct *handle,
647 struct smb_request *req,
648 struct files_struct *dirfsp,
649 struct smb_filename *fname,
650 uint32_t access_mask,
651 uint32_t share_access,
652 uint32_t create_disposition,
653 uint32_t create_options,
654 uint32_t file_attributes,
655 uint32_t oplock_request,
656 const struct smb2_lease *lease,
657 uint64_t allocation_size,
658 uint32_t private_flags,
659 struct security_descriptor *sd,
660 struct ea_list *ea_list,
661 files_struct **result_fsp,
663 const struct smb2_create_blobs *in_context_blobs,
664 struct smb2_create_blobs *out_context_blobs)
667 struct timespec ts1,ts2;
670 clock_gettime_mono(&ts1);
671 result = SMB_VFS_NEXT_CREATE_FILE(
676 access_mask, /* access_mask */
677 share_access, /* share_access */
678 create_disposition, /* create_disposition*/
679 create_options, /* create_options */
680 file_attributes, /* file_attributes */
681 oplock_request, /* oplock_request */
683 allocation_size, /* allocation_size */
686 ea_list, /* ea_list */
687 result_fsp, /* result */
689 in_context_blobs, out_context_blobs); /* create context */
690 clock_gettime_mono(&ts2);
691 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
693 if (timediff > audit_timeout) {
695 * can't use result_fsp this time, may have
696 * invalid content causing smbd crash
698 smb_time_audit_log_smb_fname("create_file", timediff,
705 static int smb_time_audit_close(vfs_handle_struct *handle, files_struct *fsp)
708 struct timespec ts1,ts2;
711 clock_gettime_mono(&ts1);
712 result = SMB_VFS_NEXT_CLOSE(handle, fsp);
713 clock_gettime_mono(&ts2);
714 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
716 if (timediff > audit_timeout) {
717 smb_time_audit_log_fsp("close", timediff, fsp);
723 static ssize_t smb_time_audit_pread(vfs_handle_struct *handle,
725 void *data, size_t n, off_t offset)
728 struct timespec ts1,ts2;
731 clock_gettime_mono(&ts1);
732 result = SMB_VFS_NEXT_PREAD(handle, fsp, data, n, offset);
733 clock_gettime_mono(&ts2);
734 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
736 if (timediff > audit_timeout) {
737 smb_time_audit_log_fsp("pread", timediff, fsp);
743 struct smb_time_audit_pread_state {
744 struct files_struct *fsp;
746 struct vfs_aio_state vfs_aio_state;
749 static void smb_time_audit_pread_done(struct tevent_req *subreq);
751 static struct tevent_req *smb_time_audit_pread_send(
752 struct vfs_handle_struct *handle, TALLOC_CTX *mem_ctx,
753 struct tevent_context *ev, struct files_struct *fsp,
754 void *data, size_t n, off_t offset)
756 struct tevent_req *req, *subreq;
757 struct smb_time_audit_pread_state *state;
759 req = tevent_req_create(mem_ctx, &state,
760 struct smb_time_audit_pread_state);
766 subreq = SMB_VFS_NEXT_PREAD_SEND(state, ev, handle, fsp, data,
768 if (tevent_req_nomem(subreq, req)) {
769 return tevent_req_post(req, ev);
771 tevent_req_set_callback(subreq, smb_time_audit_pread_done, req);
775 static void smb_time_audit_pread_done(struct tevent_req *subreq)
777 struct tevent_req *req = tevent_req_callback_data(
778 subreq, struct tevent_req);
779 struct smb_time_audit_pread_state *state = tevent_req_data(
780 req, struct smb_time_audit_pread_state);
782 state->ret = SMB_VFS_PREAD_RECV(subreq, &state->vfs_aio_state);
784 tevent_req_done(req);
787 static ssize_t smb_time_audit_pread_recv(struct tevent_req *req,
788 struct vfs_aio_state *vfs_aio_state)
790 struct smb_time_audit_pread_state *state = tevent_req_data(
791 req, struct smb_time_audit_pread_state);
794 timediff = state->vfs_aio_state.duration * 1.0e-9;
796 if (timediff > audit_timeout) {
797 smb_time_audit_log_fsp("async pread", timediff, state->fsp);
800 if (tevent_req_is_unix_error(req, &vfs_aio_state->error)) {
803 *vfs_aio_state = state->vfs_aio_state;
807 static ssize_t smb_time_audit_pwrite(vfs_handle_struct *handle,
809 const void *data, size_t n,
813 struct timespec ts1,ts2;
816 clock_gettime_mono(&ts1);
817 result = SMB_VFS_NEXT_PWRITE(handle, fsp, data, n, offset);
818 clock_gettime_mono(&ts2);
819 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
821 if (timediff > audit_timeout) {
822 smb_time_audit_log_fsp("pwrite", timediff, fsp);
828 struct smb_time_audit_pwrite_state {
829 struct files_struct *fsp;
831 struct vfs_aio_state vfs_aio_state;
834 static void smb_time_audit_pwrite_done(struct tevent_req *subreq);
836 static struct tevent_req *smb_time_audit_pwrite_send(
837 struct vfs_handle_struct *handle, TALLOC_CTX *mem_ctx,
838 struct tevent_context *ev, struct files_struct *fsp,
839 const void *data, size_t n, off_t offset)
841 struct tevent_req *req, *subreq;
842 struct smb_time_audit_pwrite_state *state;
844 req = tevent_req_create(mem_ctx, &state,
845 struct smb_time_audit_pwrite_state);
851 subreq = SMB_VFS_NEXT_PWRITE_SEND(state, ev, handle, fsp, data,
853 if (tevent_req_nomem(subreq, req)) {
854 return tevent_req_post(req, ev);
856 tevent_req_set_callback(subreq, smb_time_audit_pwrite_done, req);
860 static void smb_time_audit_pwrite_done(struct tevent_req *subreq)
862 struct tevent_req *req = tevent_req_callback_data(
863 subreq, struct tevent_req);
864 struct smb_time_audit_pwrite_state *state = tevent_req_data(
865 req, struct smb_time_audit_pwrite_state);
867 state->ret = SMB_VFS_PWRITE_RECV(subreq, &state->vfs_aio_state);
869 tevent_req_done(req);
872 static ssize_t smb_time_audit_pwrite_recv(struct tevent_req *req,
873 struct vfs_aio_state *vfs_aio_state)
875 struct smb_time_audit_pwrite_state *state = tevent_req_data(
876 req, struct smb_time_audit_pwrite_state);
879 timediff = state->vfs_aio_state.duration * 1.0e-9;
881 if (timediff > audit_timeout) {
882 smb_time_audit_log_fsp("async pwrite", timediff, state->fsp);
885 if (tevent_req_is_unix_error(req, &vfs_aio_state->error)) {
888 *vfs_aio_state = state->vfs_aio_state;
892 static off_t smb_time_audit_lseek(vfs_handle_struct *handle,
894 off_t offset, int whence)
897 struct timespec ts1,ts2;
900 clock_gettime_mono(&ts1);
901 result = SMB_VFS_NEXT_LSEEK(handle, fsp, offset, whence);
902 clock_gettime_mono(&ts2);
903 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
905 if (timediff > audit_timeout) {
906 smb_time_audit_log_fsp("lseek", timediff, fsp);
912 static ssize_t smb_time_audit_sendfile(vfs_handle_struct *handle, int tofd,
913 files_struct *fromfsp,
914 const DATA_BLOB *hdr, off_t offset,
918 struct timespec ts1,ts2;
921 clock_gettime_mono(&ts1);
922 result = SMB_VFS_NEXT_SENDFILE(handle, tofd, fromfsp, hdr, offset, n);
923 clock_gettime_mono(&ts2);
924 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
926 if (timediff > audit_timeout) {
927 smb_time_audit_log_fsp("sendfile", timediff, fromfsp);
933 static ssize_t smb_time_audit_recvfile(vfs_handle_struct *handle, int fromfd,
939 struct timespec ts1,ts2;
942 clock_gettime_mono(&ts1);
943 result = SMB_VFS_NEXT_RECVFILE(handle, fromfd, tofsp, offset, n);
944 clock_gettime_mono(&ts2);
945 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
947 if (timediff > audit_timeout) {
948 smb_time_audit_log_fsp("recvfile", timediff, tofsp);
954 static int smb_time_audit_renameat(vfs_handle_struct *handle,
955 files_struct *srcfsp,
956 const struct smb_filename *oldname,
957 files_struct *dstfsp,
958 const struct smb_filename *newname)
961 struct timespec ts1,ts2;
963 struct smb_filename *new_full_fname = NULL;
965 new_full_fname = full_path_from_dirfsp_atname(talloc_tos(),
968 if (new_full_fname == NULL) {
972 clock_gettime_mono(&ts1);
973 result = SMB_VFS_NEXT_RENAMEAT(handle,
978 clock_gettime_mono(&ts2);
979 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
981 if (timediff > audit_timeout) {
982 smb_time_audit_log_smb_fname("renameat",
987 TALLOC_FREE(new_full_fname);
991 struct smb_time_audit_fsync_state {
992 struct files_struct *fsp;
994 struct vfs_aio_state vfs_aio_state;
997 static void smb_time_audit_fsync_done(struct tevent_req *subreq);
999 static struct tevent_req *smb_time_audit_fsync_send(
1000 struct vfs_handle_struct *handle, TALLOC_CTX *mem_ctx,
1001 struct tevent_context *ev, struct files_struct *fsp)
1003 struct tevent_req *req, *subreq;
1004 struct smb_time_audit_fsync_state *state;
1006 req = tevent_req_create(mem_ctx, &state,
1007 struct smb_time_audit_fsync_state);
1013 subreq = SMB_VFS_NEXT_FSYNC_SEND(state, ev, handle, fsp);
1014 if (tevent_req_nomem(subreq, req)) {
1015 return tevent_req_post(req, ev);
1017 tevent_req_set_callback(subreq, smb_time_audit_fsync_done, req);
1021 static void smb_time_audit_fsync_done(struct tevent_req *subreq)
1023 struct tevent_req *req = tevent_req_callback_data(
1024 subreq, struct tevent_req);
1025 struct smb_time_audit_fsync_state *state = tevent_req_data(
1026 req, struct smb_time_audit_fsync_state);
1028 state->ret = SMB_VFS_FSYNC_RECV(subreq, &state->vfs_aio_state);
1029 TALLOC_FREE(subreq);
1030 tevent_req_done(req);
1033 static int smb_time_audit_fsync_recv(struct tevent_req *req,
1034 struct vfs_aio_state *vfs_aio_state)
1036 struct smb_time_audit_fsync_state *state = tevent_req_data(
1037 req, struct smb_time_audit_fsync_state);
1040 timediff = state->vfs_aio_state.duration * 1.0e-9;
1042 if (timediff > audit_timeout) {
1043 smb_time_audit_log_fsp("async fsync", timediff, state->fsp);
1046 if (tevent_req_is_unix_error(req, &vfs_aio_state->error)) {
1049 *vfs_aio_state = state->vfs_aio_state;
1053 static int smb_time_audit_stat(vfs_handle_struct *handle,
1054 struct smb_filename *fname)
1057 struct timespec ts1,ts2;
1060 clock_gettime_mono(&ts1);
1061 result = SMB_VFS_NEXT_STAT(handle, fname);
1062 clock_gettime_mono(&ts2);
1063 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1065 if (timediff > audit_timeout) {
1066 smb_time_audit_log_smb_fname("stat", timediff, fname);
1072 static int smb_time_audit_fstat(vfs_handle_struct *handle, files_struct *fsp,
1073 SMB_STRUCT_STAT *sbuf)
1076 struct timespec ts1,ts2;
1079 clock_gettime_mono(&ts1);
1080 result = SMB_VFS_NEXT_FSTAT(handle, fsp, sbuf);
1081 clock_gettime_mono(&ts2);
1082 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1084 if (timediff > audit_timeout) {
1085 smb_time_audit_log_fsp("fstat", timediff, fsp);
1091 static int smb_time_audit_lstat(vfs_handle_struct *handle,
1092 struct smb_filename *path)
1095 struct timespec ts1,ts2;
1098 clock_gettime_mono(&ts1);
1099 result = SMB_VFS_NEXT_LSTAT(handle, path);
1100 clock_gettime_mono(&ts2);
1101 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1103 if (timediff > audit_timeout) {
1104 smb_time_audit_log_smb_fname("lstat", timediff, path);
1110 static int smb_time_audit_fstatat(
1111 struct vfs_handle_struct *handle,
1112 const struct files_struct *dirfsp,
1113 const struct smb_filename *smb_fname,
1114 SMB_STRUCT_STAT *sbuf,
1118 struct timespec ts1,ts2;
1121 clock_gettime_mono(&ts1);
1122 result = SMB_VFS_NEXT_FSTATAT(handle, dirfsp, smb_fname, sbuf, flags);
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("fstatat", timediff, smb_fname);
1133 static uint64_t smb_time_audit_get_alloc_size(vfs_handle_struct *handle,
1135 const SMB_STRUCT_STAT *sbuf)
1138 struct timespec ts1,ts2;
1141 clock_gettime_mono(&ts1);
1142 result = SMB_VFS_NEXT_GET_ALLOC_SIZE(handle, fsp, sbuf);
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_fsp("get_alloc_size", timediff, fsp);
1153 static int smb_time_audit_unlinkat(vfs_handle_struct *handle,
1154 struct files_struct *dirfsp,
1155 const struct smb_filename *path,
1158 struct smb_filename *full_fname = NULL;
1160 struct timespec ts1,ts2;
1163 full_fname = full_path_from_dirfsp_atname(talloc_tos(),
1166 if (full_fname == NULL) {
1170 clock_gettime_mono(&ts1);
1171 result = SMB_VFS_NEXT_UNLINKAT(handle,
1175 clock_gettime_mono(&ts2);
1176 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1178 if (timediff > audit_timeout) {
1179 smb_time_audit_log_smb_fname("unlinkat", timediff, full_fname);
1182 TALLOC_FREE(full_fname);
1186 static int smb_time_audit_fchmod(vfs_handle_struct *handle, files_struct *fsp,
1190 struct timespec ts1,ts2;
1193 clock_gettime_mono(&ts1);
1194 result = SMB_VFS_NEXT_FCHMOD(handle, fsp, mode);
1195 clock_gettime_mono(&ts2);
1196 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1198 if (timediff > audit_timeout) {
1199 smb_time_audit_log_fsp("fchmod", timediff, fsp);
1205 static int smb_time_audit_fchown(vfs_handle_struct *handle, files_struct *fsp,
1206 uid_t uid, gid_t gid)
1209 struct timespec ts1,ts2;
1212 clock_gettime_mono(&ts1);
1213 result = SMB_VFS_NEXT_FCHOWN(handle, fsp, uid, gid);
1214 clock_gettime_mono(&ts2);
1215 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1217 if (timediff > audit_timeout) {
1218 smb_time_audit_log_fsp("fchown", timediff, fsp);
1224 static int smb_time_audit_lchown(vfs_handle_struct *handle,
1225 const struct smb_filename *smb_fname,
1230 struct timespec ts1,ts2;
1233 clock_gettime_mono(&ts1);
1234 result = SMB_VFS_NEXT_LCHOWN(handle, smb_fname, uid, gid);
1235 clock_gettime_mono(&ts2);
1236 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1238 if (timediff > audit_timeout) {
1239 smb_time_audit_log_fname("lchown",
1241 smb_fname->base_name);
1247 static int smb_time_audit_chdir(vfs_handle_struct *handle,
1248 const struct smb_filename *smb_fname)
1251 struct timespec ts1,ts2;
1254 clock_gettime_mono(&ts1);
1255 result = SMB_VFS_NEXT_CHDIR(handle, smb_fname);
1256 clock_gettime_mono(&ts2);
1257 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1259 if (timediff > audit_timeout) {
1260 smb_time_audit_log_fname("chdir",
1262 smb_fname->base_name);
1268 static struct smb_filename *smb_time_audit_getwd(vfs_handle_struct *handle,
1269 TALLOC_CTX *mem_ctx)
1271 struct smb_filename *result;
1272 struct timespec ts1,ts2;
1275 clock_gettime_mono(&ts1);
1276 result = SMB_VFS_NEXT_GETWD(handle, mem_ctx);
1277 clock_gettime_mono(&ts2);
1278 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1280 if (timediff > audit_timeout) {
1281 smb_time_audit_log("getwd", timediff);
1287 static int smb_time_audit_fntimes(vfs_handle_struct *handle,
1289 struct smb_file_time *ft)
1292 struct timespec ts1,ts2;
1295 clock_gettime_mono(&ts1);
1296 result = SMB_VFS_NEXT_FNTIMES(handle, fsp, ft);
1297 clock_gettime_mono(&ts2);
1298 timediff = nsec_time_diff(&ts2, &ts1) * 1.0e-9;
1300 if (timediff > audit_timeout) {
1301 smb_time_audit_log_fsp("fntimes", timediff, fsp);
1307 static int smb_time_audit_ftruncate(vfs_handle_struct *handle,
1312 struct timespec ts1,ts2;
1315 clock_gettime_mono(&ts1);
1316 result = SMB_VFS_NEXT_FTRUNCATE(handle, fsp, len);
1317 clock_gettime_mono(&ts2);
1318 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1320 if (timediff > audit_timeout) {
1321 smb_time_audit_log_fsp("ftruncate", timediff, fsp);
1327 static int smb_time_audit_fallocate(vfs_handle_struct *handle,
1334 int saved_errno = 0;
1335 struct timespec ts1,ts2;
1338 clock_gettime_mono(&ts1);
1339 result = SMB_VFS_NEXT_FALLOCATE(handle, fsp, mode, offset, len);
1341 saved_errno = errno;
1343 clock_gettime_mono(&ts2);
1344 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1346 if (timediff > audit_timeout) {
1347 smb_time_audit_log_fsp("fallocate", timediff, fsp);
1350 errno = saved_errno;
1355 static bool smb_time_audit_lock(vfs_handle_struct *handle, files_struct *fsp,
1356 int op, off_t offset, off_t count,
1360 struct timespec ts1,ts2;
1363 clock_gettime_mono(&ts1);
1364 result = SMB_VFS_NEXT_LOCK(handle, fsp, op, offset, count, type);
1365 clock_gettime_mono(&ts2);
1366 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1368 if (timediff > audit_timeout) {
1369 smb_time_audit_log_fsp("lock", timediff, fsp);
1375 static int smb_time_audit_filesystem_sharemode(struct vfs_handle_struct *handle,
1376 struct files_struct *fsp,
1377 uint32_t share_access,
1378 uint32_t access_mask)
1381 struct timespec ts1,ts2;
1384 clock_gettime_mono(&ts1);
1385 result = SMB_VFS_NEXT_FILESYSTEM_SHAREMODE(handle,
1389 clock_gettime_mono(&ts2);
1390 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1392 if (timediff > audit_timeout) {
1393 smb_time_audit_log_fsp("filesystem_sharemode", timediff, fsp);
1399 static int smb_time_audit_fcntl(struct vfs_handle_struct *handle,
1400 struct files_struct *fsp,
1401 int cmd, va_list cmd_arg)
1404 va_list dup_cmd_arg;
1406 struct timespec ts1,ts2;
1409 va_copy(dup_cmd_arg, cmd_arg);
1410 arg = va_arg(dup_cmd_arg, void *);
1411 clock_gettime_mono(&ts1);
1412 result = SMB_VFS_NEXT_FCNTL(handle, fsp, cmd, arg);
1413 clock_gettime_mono(&ts2);
1414 va_end(dup_cmd_arg);
1416 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1417 if (timediff > audit_timeout) {
1418 smb_time_audit_log_fsp("fcntl", timediff, fsp);
1424 static int smb_time_audit_linux_setlease(vfs_handle_struct *handle,
1429 struct timespec ts1,ts2;
1432 clock_gettime_mono(&ts1);
1433 result = SMB_VFS_NEXT_LINUX_SETLEASE(handle, fsp, leasetype);
1434 clock_gettime_mono(&ts2);
1435 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1437 if (timediff > audit_timeout) {
1438 smb_time_audit_log_fsp("linux_setlease", timediff, fsp);
1444 static bool smb_time_audit_getlock(vfs_handle_struct *handle,
1446 off_t *poffset, off_t *pcount,
1447 int *ptype, pid_t *ppid)
1450 struct timespec ts1,ts2;
1453 clock_gettime_mono(&ts1);
1454 result = SMB_VFS_NEXT_GETLOCK(handle, fsp, poffset, pcount, ptype,
1456 clock_gettime_mono(&ts2);
1457 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1459 if (timediff > audit_timeout) {
1460 smb_time_audit_log_fsp("getlock", timediff, fsp);
1466 static int smb_time_audit_symlinkat(vfs_handle_struct *handle,
1467 const struct smb_filename *link_contents,
1468 struct files_struct *dirfsp,
1469 const struct smb_filename *new_smb_fname)
1471 struct smb_filename *full_fname = NULL;
1473 struct timespec ts1,ts2;
1476 full_fname = full_path_from_dirfsp_atname(talloc_tos(),
1479 if (full_fname == NULL) {
1484 clock_gettime_mono(&ts1);
1485 result = SMB_VFS_NEXT_SYMLINKAT(handle,
1489 clock_gettime_mono(&ts2);
1490 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1492 if (timediff > audit_timeout) {
1493 smb_time_audit_log_fname("symlinkat", timediff,
1494 full_fname->base_name);
1497 TALLOC_FREE(full_fname);
1501 static int smb_time_audit_readlinkat(vfs_handle_struct *handle,
1502 const struct files_struct *dirfsp,
1503 const struct smb_filename *smb_fname,
1507 struct smb_filename *full_fname = NULL;
1509 struct timespec ts1,ts2;
1512 full_fname = full_path_from_dirfsp_atname(talloc_tos(),
1515 if (full_fname == NULL) {
1520 clock_gettime_mono(&ts1);
1521 result = SMB_VFS_NEXT_READLINKAT(handle,
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("readlinkat", timediff,
1531 full_fname->base_name);
1534 TALLOC_FREE(full_fname);
1538 static int smb_time_audit_linkat(vfs_handle_struct *handle,
1539 files_struct *srcfsp,
1540 const struct smb_filename *old_smb_fname,
1541 files_struct *dstfsp,
1542 const struct smb_filename *new_smb_fname,
1545 struct smb_filename *new_full_fname = NULL;
1547 struct timespec ts1,ts2;
1550 new_full_fname = full_path_from_dirfsp_atname(talloc_tos(),
1553 if (new_full_fname == NULL) {
1558 clock_gettime_mono(&ts1);
1559 result = SMB_VFS_NEXT_LINKAT(handle,
1565 clock_gettime_mono(&ts2);
1566 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1568 if (timediff > audit_timeout) {
1569 smb_time_audit_log_fname("linkat", timediff,
1570 new_full_fname->base_name);
1573 TALLOC_FREE(new_full_fname);
1577 static int smb_time_audit_mknodat(vfs_handle_struct *handle,
1578 files_struct *dirfsp,
1579 const struct smb_filename *smb_fname,
1583 struct smb_filename *full_fname = NULL;
1585 struct timespec ts1,ts2;
1588 full_fname = full_path_from_dirfsp_atname(talloc_tos(),
1591 if (full_fname == NULL) {
1596 clock_gettime_mono(&ts1);
1597 result = SMB_VFS_NEXT_MKNODAT(handle,
1602 clock_gettime_mono(&ts2);
1603 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1605 if (timediff > audit_timeout) {
1606 smb_time_audit_log_smb_fname("mknodat", timediff, full_fname);
1609 TALLOC_FREE(full_fname);
1613 static struct smb_filename *smb_time_audit_realpath(vfs_handle_struct *handle,
1615 const struct smb_filename *smb_fname)
1617 struct smb_filename *result_fname;
1618 struct timespec ts1,ts2;
1621 clock_gettime_mono(&ts1);
1622 result_fname = SMB_VFS_NEXT_REALPATH(handle, ctx, smb_fname);
1623 clock_gettime_mono(&ts2);
1624 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1626 if (timediff > audit_timeout) {
1627 smb_time_audit_log_fname("realpath", timediff,
1628 smb_fname->base_name);
1631 return result_fname;
1634 static int smb_time_audit_fchflags(vfs_handle_struct *handle,
1635 struct files_struct *fsp,
1639 struct timespec ts1,ts2;
1642 clock_gettime_mono(&ts1);
1643 result = SMB_VFS_NEXT_FCHFLAGS(handle, fsp, flags);
1644 clock_gettime_mono(&ts2);
1645 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1647 if (timediff > audit_timeout) {
1648 smb_time_audit_log_smb_fname("chflags",
1656 static struct file_id smb_time_audit_file_id_create(struct vfs_handle_struct *handle,
1657 const SMB_STRUCT_STAT *sbuf)
1659 struct file_id id_zero;
1660 struct file_id result;
1661 struct timespec ts1,ts2;
1664 ZERO_STRUCT(id_zero);
1666 clock_gettime_mono(&ts1);
1667 result = SMB_VFS_NEXT_FILE_ID_CREATE(handle, sbuf);
1668 clock_gettime_mono(&ts2);
1669 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1671 if (timediff > audit_timeout) {
1672 smb_time_audit_log("file_id_create", timediff);
1678 static uint64_t smb_time_audit_fs_file_id(struct vfs_handle_struct *handle,
1679 const SMB_STRUCT_STAT *sbuf)
1682 struct timespec ts1,ts2;
1685 clock_gettime_mono(&ts1);
1686 result = SMB_VFS_NEXT_FS_FILE_ID(handle, sbuf);
1687 clock_gettime_mono(&ts2);
1688 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1690 if (timediff > audit_timeout) {
1691 smb_time_audit_log("fs_file_id", timediff);
1697 static NTSTATUS smb_time_audit_fstreaminfo(vfs_handle_struct *handle,
1698 struct files_struct *fsp,
1699 TALLOC_CTX *mem_ctx,
1700 unsigned int *pnum_streams,
1701 struct stream_struct **pstreams)
1704 struct timespec ts1,ts2;
1707 clock_gettime_mono(&ts1);
1708 result = SMB_VFS_NEXT_FSTREAMINFO(handle, fsp, mem_ctx,
1709 pnum_streams, pstreams);
1710 clock_gettime_mono(&ts2);
1711 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1713 if (timediff > audit_timeout) {
1714 smb_time_audit_log_fsp("fstreaminfo", timediff, fsp);
1720 static NTSTATUS smb_time_audit_get_real_filename_at(
1721 struct vfs_handle_struct *handle,
1722 struct files_struct *dirfsp,
1724 TALLOC_CTX *mem_ctx,
1728 struct timespec ts1,ts2;
1731 clock_gettime_mono(&ts1);
1732 result = SMB_VFS_NEXT_GET_REAL_FILENAME_AT(
1733 handle, dirfsp, name, mem_ctx, found_name);
1734 clock_gettime_mono(&ts2);
1735 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1737 if (timediff > audit_timeout) {
1738 smb_time_audit_log_fname("get_real_filename_at",
1740 fsp_str_dbg(dirfsp));
1746 static const char *smb_time_audit_connectpath(
1747 vfs_handle_struct *handle,
1748 const struct files_struct *dirfsp,
1749 const struct smb_filename *smb_fname)
1752 struct timespec ts1,ts2;
1755 clock_gettime_mono(&ts1);
1756 result = SMB_VFS_NEXT_CONNECTPATH(handle, dirfsp, smb_fname);
1757 clock_gettime_mono(&ts2);
1758 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1760 if (timediff > audit_timeout) {
1761 smb_time_audit_log_fname("connectpath", timediff,
1762 smb_fname->base_name);
1768 static NTSTATUS smb_time_audit_brl_lock_windows(struct vfs_handle_struct *handle,
1769 struct byte_range_lock *br_lck,
1770 struct lock_struct *plock)
1773 struct timespec ts1,ts2;
1776 clock_gettime_mono(&ts1);
1777 result = SMB_VFS_NEXT_BRL_LOCK_WINDOWS(handle, br_lck, plock);
1778 clock_gettime_mono(&ts2);
1779 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1781 if (timediff > audit_timeout) {
1782 smb_time_audit_log_fsp("brl_lock_windows", timediff,
1789 static bool smb_time_audit_brl_unlock_windows(struct vfs_handle_struct *handle,
1790 struct byte_range_lock *br_lck,
1791 const struct lock_struct *plock)
1794 struct timespec ts1,ts2;
1797 clock_gettime_mono(&ts1);
1798 result = SMB_VFS_NEXT_BRL_UNLOCK_WINDOWS(handle, br_lck, plock);
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("brl_unlock_windows", timediff,
1810 static bool smb_time_audit_strict_lock_check(struct vfs_handle_struct *handle,
1811 struct files_struct *fsp,
1812 struct lock_struct *plock)
1815 struct timespec ts1,ts2;
1818 clock_gettime_mono(&ts1);
1819 result = SMB_VFS_NEXT_STRICT_LOCK_CHECK(handle, fsp, plock);
1820 clock_gettime_mono(&ts2);
1821 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1823 if (timediff > audit_timeout) {
1824 smb_time_audit_log_fsp("strict_lock_check", timediff, fsp);
1830 static NTSTATUS smb_time_audit_translate_name(struct vfs_handle_struct *handle,
1832 enum vfs_translate_direction direction,
1833 TALLOC_CTX *mem_ctx,
1837 struct timespec ts1,ts2;
1840 clock_gettime_mono(&ts1);
1841 result = SMB_VFS_NEXT_TRANSLATE_NAME(handle, name, direction, mem_ctx,
1843 clock_gettime_mono(&ts2);
1844 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1846 if (timediff > audit_timeout) {
1847 smb_time_audit_log_fname("translate_name", timediff, name);
1853 static NTSTATUS smb_time_audit_parent_pathname(struct vfs_handle_struct *handle,
1854 TALLOC_CTX *mem_ctx,
1855 const struct smb_filename *smb_fname_in,
1856 struct smb_filename **parent_dir_out,
1857 struct smb_filename **atname_out)
1860 struct timespec ts1,ts2;
1863 clock_gettime_mono(&ts1);
1864 result = SMB_VFS_NEXT_PARENT_PATHNAME(handle,
1869 clock_gettime_mono(&ts2);
1870 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1872 if (timediff > audit_timeout) {
1873 smb_time_audit_log_fname("parent_pathname",
1875 smb_fname_in->base_name);
1881 static NTSTATUS smb_time_audit_fsctl(struct vfs_handle_struct *handle,
1882 struct files_struct *fsp,
1886 const uint8_t *_in_data,
1888 uint8_t **_out_data,
1889 uint32_t max_out_len,
1893 struct timespec ts1,ts2;
1896 clock_gettime_mono(&ts1);
1897 result = SMB_VFS_NEXT_FSCTL(handle,
1907 clock_gettime_mono(&ts2);
1908 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1910 if (timediff > audit_timeout) {
1911 smb_time_audit_log_fsp("fsctl", timediff, fsp);
1917 struct smb_time_audit_get_dos_attributes_state {
1918 struct vfs_aio_state aio_state;
1919 files_struct *dir_fsp;
1920 const struct smb_filename *smb_fname;
1924 static void smb_time_audit_get_dos_attributes_done(struct tevent_req *subreq);
1926 static struct tevent_req *smb_time_audit_get_dos_attributes_send(
1927 TALLOC_CTX *mem_ctx,
1928 struct tevent_context *ev,
1929 struct vfs_handle_struct *handle,
1930 files_struct *dir_fsp,
1931 struct smb_filename *smb_fname)
1933 struct tevent_req *req = NULL;
1934 struct smb_time_audit_get_dos_attributes_state *state = NULL;
1935 struct tevent_req *subreq = NULL;
1937 req = tevent_req_create(mem_ctx, &state,
1938 struct smb_time_audit_get_dos_attributes_state);
1942 *state = (struct smb_time_audit_get_dos_attributes_state) {
1944 .smb_fname = smb_fname,
1947 subreq = SMB_VFS_NEXT_GET_DOS_ATTRIBUTES_SEND(mem_ctx,
1952 if (tevent_req_nomem(subreq, req)) {
1953 return tevent_req_post(req, ev);
1955 tevent_req_set_callback(subreq,
1956 smb_time_audit_get_dos_attributes_done,
1962 static void smb_time_audit_get_dos_attributes_done(struct tevent_req *subreq)
1964 struct tevent_req *req =
1965 tevent_req_callback_data(subreq,
1967 struct smb_time_audit_get_dos_attributes_state *state =
1968 tevent_req_data(req,
1969 struct smb_time_audit_get_dos_attributes_state);
1972 status = SMB_VFS_NEXT_GET_DOS_ATTRIBUTES_RECV(subreq,
1975 TALLOC_FREE(subreq);
1976 if (tevent_req_nterror(req, status)) {
1980 tevent_req_done(req);
1984 static NTSTATUS smb_time_audit_get_dos_attributes_recv(struct tevent_req *req,
1985 struct vfs_aio_state *aio_state,
1988 struct smb_time_audit_get_dos_attributes_state *state =
1989 tevent_req_data(req,
1990 struct smb_time_audit_get_dos_attributes_state);
1994 timediff = state->aio_state.duration * 1.0e-9;
1996 if (timediff > audit_timeout) {
1997 smb_time_audit_log_at("async get_dos_attributes",
2003 if (tevent_req_is_nterror(req, &status)) {
2004 tevent_req_received(req);
2008 *aio_state = state->aio_state;
2009 *dosmode = state->dosmode;
2010 tevent_req_received(req);
2011 return NT_STATUS_OK;
2014 static NTSTATUS smb_time_fget_dos_attributes(struct vfs_handle_struct *handle,
2015 struct files_struct *fsp,
2019 struct timespec ts1,ts2;
2022 clock_gettime_mono(&ts1);
2023 result = SMB_VFS_NEXT_FGET_DOS_ATTRIBUTES(handle,
2026 clock_gettime_mono(&ts2);
2027 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2029 if (timediff > audit_timeout) {
2030 smb_time_audit_log_fsp("fget_dos_attributes", timediff, fsp);
2036 static NTSTATUS smb_time_fset_dos_attributes(struct vfs_handle_struct *handle,
2037 struct files_struct *fsp,
2041 struct timespec ts1,ts2;
2044 clock_gettime_mono(&ts1);
2045 result = SMB_VFS_NEXT_FSET_DOS_ATTRIBUTES(handle,
2048 clock_gettime_mono(&ts2);
2049 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2051 if (timediff > audit_timeout) {
2052 smb_time_audit_log_fsp("fset_dos_attributes", timediff, fsp);
2058 struct time_audit_offload_read_state {
2059 struct vfs_handle_struct *handle;
2060 struct timespec ts_send;
2063 DATA_BLOB token_blob;
2066 static void smb_time_audit_offload_read_done(struct tevent_req *subreq);
2068 static struct tevent_req *smb_time_audit_offload_read_send(
2069 TALLOC_CTX *mem_ctx,
2070 struct tevent_context *ev,
2071 struct vfs_handle_struct *handle,
2072 struct files_struct *fsp,
2078 struct tevent_req *req = NULL;
2079 struct tevent_req *subreq = NULL;
2080 struct time_audit_offload_read_state *state = NULL;
2082 req = tevent_req_create(mem_ctx, &state,
2083 struct time_audit_offload_read_state);
2087 state->handle = handle;
2088 clock_gettime_mono(&state->ts_send);
2090 subreq = SMB_VFS_NEXT_OFFLOAD_READ_SEND(mem_ctx, ev,
2094 if (tevent_req_nomem(subreq, req)) {
2095 return tevent_req_post(req, ev);
2098 tevent_req_set_callback(subreq, smb_time_audit_offload_read_done, req);
2102 static void smb_time_audit_offload_read_done(struct tevent_req *subreq)
2104 struct tevent_req *req = tevent_req_callback_data(
2105 subreq, struct tevent_req);
2106 struct time_audit_offload_read_state *state = tevent_req_data(
2107 req, struct time_audit_offload_read_state);
2110 status = SMB_VFS_NEXT_OFFLOAD_READ_RECV(subreq,
2115 &state->token_blob);
2116 TALLOC_FREE(subreq);
2117 if (tevent_req_nterror(req, status)) {
2120 tevent_req_done(req);
2123 static NTSTATUS smb_time_audit_offload_read_recv(
2124 struct tevent_req *req,
2125 struct vfs_handle_struct *handle,
2126 TALLOC_CTX *mem_ctx,
2129 DATA_BLOB *token_blob)
2131 struct time_audit_offload_read_state *state = tevent_req_data(
2132 req, struct time_audit_offload_read_state);
2133 struct timespec ts_recv;
2137 clock_gettime_mono(&ts_recv);
2138 timediff = nsec_time_diff(&ts_recv, &state->ts_send) * 1.0e-9;
2139 if (timediff > audit_timeout) {
2140 smb_time_audit_log("offload_read", timediff);
2143 if (tevent_req_is_nterror(req, &status)) {
2144 tevent_req_received(req);
2148 *flags = state->flags;
2149 *xferlen = state->xferlen;
2150 token_blob->length = state->token_blob.length;
2151 token_blob->data = talloc_move(mem_ctx, &state->token_blob.data);
2153 tevent_req_received(req);
2154 return NT_STATUS_OK;
2157 struct time_audit_offload_write_state {
2158 struct timespec ts_send;
2159 struct vfs_handle_struct *handle;
2162 static void smb_time_audit_offload_write_done(struct tevent_req *subreq);
2164 static struct tevent_req *smb_time_audit_offload_write_send(struct vfs_handle_struct *handle,
2165 TALLOC_CTX *mem_ctx,
2166 struct tevent_context *ev,
2169 off_t transfer_offset,
2170 struct files_struct *dest_fsp,
2174 struct tevent_req *req;
2175 struct tevent_req *subreq;
2176 struct time_audit_offload_write_state *state;
2178 req = tevent_req_create(mem_ctx, &state,
2179 struct time_audit_offload_write_state);
2184 state->handle = handle;
2185 clock_gettime_mono(&state->ts_send);
2186 subreq = SMB_VFS_NEXT_OFFLOAD_WRITE_SEND(handle, state, ev,
2187 fsctl, token, transfer_offset,
2188 dest_fsp, dest_off, num);
2189 if (tevent_req_nomem(subreq, req)) {
2190 return tevent_req_post(req, ev);
2193 tevent_req_set_callback(subreq, smb_time_audit_offload_write_done, req);
2197 static void smb_time_audit_offload_write_done(struct tevent_req *subreq)
2199 struct tevent_req *req = tevent_req_callback_data(
2200 subreq, struct tevent_req);
2201 struct time_audit_offload_write_state *state = tevent_req_data(
2202 req, struct time_audit_offload_write_state);
2205 status = SMB_VFS_NEXT_OFFLOAD_WRITE_RECV(state->handle,
2208 TALLOC_FREE(subreq);
2209 if (tevent_req_nterror(req, status)) {
2212 tevent_req_done(req);
2215 static NTSTATUS smb_time_audit_offload_write_recv(struct vfs_handle_struct *handle,
2216 struct tevent_req *req,
2219 struct time_audit_offload_write_state *state = tevent_req_data(
2220 req, struct time_audit_offload_write_state);
2221 struct timespec ts_recv;
2225 clock_gettime_mono(&ts_recv);
2226 timediff = nsec_time_diff(&ts_recv, &state->ts_send)*1.0e-9;
2227 if (timediff > audit_timeout) {
2228 smb_time_audit_log("offload_write", timediff);
2231 *copied = state->copied;
2232 if (tevent_req_is_nterror(req, &status)) {
2233 tevent_req_received(req);
2237 tevent_req_received(req);
2238 return NT_STATUS_OK;
2241 static NTSTATUS smb_time_audit_fget_compression(vfs_handle_struct *handle,
2242 TALLOC_CTX *mem_ctx,
2243 struct files_struct *fsp,
2244 uint16_t *_compression_fmt)
2247 struct timespec ts1,ts2;
2250 clock_gettime_mono(&ts1);
2251 result = SMB_VFS_NEXT_FGET_COMPRESSION(handle, mem_ctx, fsp,
2253 clock_gettime_mono(&ts2);
2254 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2256 if (timediff > audit_timeout) {
2257 smb_time_audit_log_fsp("get_compression",
2264 static NTSTATUS smb_time_audit_set_compression(vfs_handle_struct *handle,
2265 TALLOC_CTX *mem_ctx,
2266 struct files_struct *fsp,
2267 uint16_t compression_fmt)
2270 struct timespec ts1,ts2;
2273 clock_gettime_mono(&ts1);
2274 result = SMB_VFS_NEXT_SET_COMPRESSION(handle, mem_ctx, fsp,
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_fsp("set_compression", timediff, fsp);
2286 static NTSTATUS smb_time_audit_freaddir_attr(struct vfs_handle_struct *handle,
2287 struct files_struct *fsp,
2288 TALLOC_CTX *mem_ctx,
2289 struct readdir_attr_data **pattr_data)
2292 struct timespec ts1, ts2;
2295 clock_gettime_mono(&ts1);
2296 status = SMB_VFS_NEXT_FREADDIR_ATTR(handle, fsp, mem_ctx, pattr_data);
2297 clock_gettime_mono(&ts2);
2298 timediff = nsec_time_diff(&ts2, &ts1) * 1.0e-9;
2300 if (timediff > audit_timeout) {
2301 smb_time_audit_log_fsp("freaddir_attr", timediff, fsp);
2307 static NTSTATUS smb_time_audit_fget_nt_acl(vfs_handle_struct *handle,
2309 uint32_t security_info,
2310 TALLOC_CTX *mem_ctx,
2311 struct security_descriptor **ppdesc)
2314 struct timespec ts1,ts2;
2317 clock_gettime_mono(&ts1);
2318 result = SMB_VFS_NEXT_FGET_NT_ACL(handle, fsp, security_info,
2320 clock_gettime_mono(&ts2);
2321 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2323 if (timediff > audit_timeout) {
2324 smb_time_audit_log_fsp("fget_nt_acl", timediff, fsp);
2330 static NTSTATUS smb_time_audit_fset_nt_acl(vfs_handle_struct *handle,
2332 uint32_t security_info_sent,
2333 const struct security_descriptor *psd)
2336 struct timespec ts1,ts2;
2339 clock_gettime_mono(&ts1);
2340 result = SMB_VFS_NEXT_FSET_NT_ACL(handle, fsp, security_info_sent,
2342 clock_gettime_mono(&ts2);
2343 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2345 if (timediff > audit_timeout) {
2346 smb_time_audit_log_fsp("fset_nt_acl", timediff, fsp);
2352 static NTSTATUS smb_time_audit_audit_file(struct vfs_handle_struct *handle,
2353 struct smb_filename *smb_fname,
2354 struct security_acl *sacl,
2355 uint32_t access_requested,
2356 uint32_t access_denied)
2359 struct timespec ts1,ts2;
2362 clock_gettime_mono(&ts1);
2363 result = SMB_VFS_NEXT_AUDIT_FILE(handle,
2368 clock_gettime_mono(&ts2);
2369 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2371 if (timediff > audit_timeout) {
2372 smb_time_audit_log_fname("audit_file",
2374 smb_fname->base_name);
2380 static SMB_ACL_T smb_time_audit_sys_acl_get_fd(vfs_handle_struct *handle,
2382 SMB_ACL_TYPE_T type,
2383 TALLOC_CTX *mem_ctx)
2386 struct timespec ts1,ts2;
2389 clock_gettime_mono(&ts1);
2390 result = SMB_VFS_NEXT_SYS_ACL_GET_FD(handle, fsp, type, mem_ctx);
2391 clock_gettime_mono(&ts2);
2392 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2394 if (timediff > audit_timeout) {
2395 smb_time_audit_log_fsp("sys_acl_get_fd", timediff, fsp);
2401 static int smb_time_audit_sys_acl_blob_get_fd(vfs_handle_struct *handle,
2403 TALLOC_CTX *mem_ctx,
2404 char **blob_description,
2408 struct timespec ts1,ts2;
2411 clock_gettime_mono(&ts1);
2412 result = SMB_VFS_NEXT_SYS_ACL_BLOB_GET_FD(handle, fsp, mem_ctx, blob_description, blob);
2413 clock_gettime_mono(&ts2);
2414 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2416 if (timediff > audit_timeout) {
2417 smb_time_audit_log("sys_acl_blob_get_fd", timediff);
2423 static int smb_time_audit_sys_acl_set_fd(vfs_handle_struct *handle,
2425 SMB_ACL_TYPE_T type,
2429 struct timespec ts1,ts2;
2432 clock_gettime_mono(&ts1);
2433 result = SMB_VFS_NEXT_SYS_ACL_SET_FD(handle, fsp, type, theacl);
2434 clock_gettime_mono(&ts2);
2435 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2437 if (timediff > audit_timeout) {
2438 smb_time_audit_log_fsp("sys_acl_set_fd", timediff, fsp);
2444 static int smb_time_audit_sys_acl_delete_def_fd(vfs_handle_struct *handle,
2448 struct timespec ts1,ts2;
2451 clock_gettime_mono(&ts1);
2452 result = SMB_VFS_NEXT_SYS_ACL_DELETE_DEF_FD(handle, fsp);
2453 clock_gettime_mono(&ts2);
2454 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2456 if (timediff > audit_timeout) {
2457 smb_time_audit_log_fsp("sys_acl_delete_def_fd", timediff, fsp);
2463 struct smb_time_audit_getxattrat_state {
2464 struct vfs_aio_state aio_state;
2465 files_struct *dir_fsp;
2466 const struct smb_filename *smb_fname;
2467 const char *xattr_name;
2469 uint8_t *xattr_value;
2472 static void smb_time_audit_getxattrat_done(struct tevent_req *subreq);
2474 static struct tevent_req *smb_time_audit_getxattrat_send(
2475 TALLOC_CTX *mem_ctx,
2476 struct tevent_context *ev,
2477 struct vfs_handle_struct *handle,
2478 files_struct *dir_fsp,
2479 const struct smb_filename *smb_fname,
2480 const char *xattr_name,
2483 struct tevent_req *req = NULL;
2484 struct tevent_req *subreq = NULL;
2485 struct smb_time_audit_getxattrat_state *state = NULL;
2487 req = tevent_req_create(mem_ctx, &state,
2488 struct smb_time_audit_getxattrat_state);
2492 *state = (struct smb_time_audit_getxattrat_state) {
2494 .smb_fname = smb_fname,
2495 .xattr_name = xattr_name,
2498 subreq = SMB_VFS_NEXT_GETXATTRAT_SEND(state,
2505 if (tevent_req_nomem(subreq, req)) {
2506 return tevent_req_post(req, ev);
2508 tevent_req_set_callback(subreq, smb_time_audit_getxattrat_done, req);
2513 static void smb_time_audit_getxattrat_done(struct tevent_req *subreq)
2515 struct tevent_req *req = tevent_req_callback_data(
2516 subreq, struct tevent_req);
2517 struct smb_time_audit_getxattrat_state *state = tevent_req_data(
2518 req, struct smb_time_audit_getxattrat_state);
2520 state->xattr_size = SMB_VFS_NEXT_GETXATTRAT_RECV(subreq,
2523 &state->xattr_value);
2524 TALLOC_FREE(subreq);
2525 if (state->xattr_size == -1) {
2526 tevent_req_error(req, state->aio_state.error);
2530 tevent_req_done(req);
2533 static ssize_t smb_time_audit_getxattrat_recv(struct tevent_req *req,
2534 struct vfs_aio_state *aio_state,
2535 TALLOC_CTX *mem_ctx,
2536 uint8_t **xattr_value)
2538 struct smb_time_audit_getxattrat_state *state = tevent_req_data(
2539 req, struct smb_time_audit_getxattrat_state);
2543 timediff = state->aio_state.duration * 1.0e-9;
2545 if (timediff > audit_timeout) {
2546 smb_time_audit_log_at("async getxattrat",
2552 if (tevent_req_is_unix_error(req, &aio_state->error)) {
2553 tevent_req_received(req);
2557 *aio_state = state->aio_state;
2558 xattr_size = state->xattr_size;
2559 if (xattr_value != NULL) {
2560 *xattr_value = talloc_move(mem_ctx, &state->xattr_value);
2563 tevent_req_received(req);
2567 static ssize_t smb_time_audit_fgetxattr(struct vfs_handle_struct *handle,
2568 struct files_struct *fsp,
2569 const char *name, void *value,
2573 struct timespec ts1,ts2;
2576 clock_gettime_mono(&ts1);
2577 result = SMB_VFS_NEXT_FGETXATTR(handle, fsp, name, value, size);
2578 clock_gettime_mono(&ts2);
2579 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2581 if (timediff > audit_timeout) {
2582 smb_time_audit_log_fsp("fgetxattr", timediff, fsp);
2588 static ssize_t smb_time_audit_flistxattr(struct vfs_handle_struct *handle,
2589 struct files_struct *fsp, char *list,
2593 struct timespec ts1,ts2;
2596 clock_gettime_mono(&ts1);
2597 result = SMB_VFS_NEXT_FLISTXATTR(handle, fsp, list, size);
2598 clock_gettime_mono(&ts2);
2599 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2601 if (timediff > audit_timeout) {
2602 smb_time_audit_log_fsp("flistxattr", timediff, fsp);
2608 static int smb_time_audit_fremovexattr(struct vfs_handle_struct *handle,
2609 struct files_struct *fsp,
2613 struct timespec ts1,ts2;
2616 clock_gettime_mono(&ts1);
2617 result = SMB_VFS_NEXT_FREMOVEXATTR(handle, fsp, name);
2618 clock_gettime_mono(&ts2);
2619 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2621 if (timediff > audit_timeout) {
2622 smb_time_audit_log_fsp("fremovexattr", timediff, fsp);
2628 static int smb_time_audit_fsetxattr(struct vfs_handle_struct *handle,
2629 struct files_struct *fsp, const char *name,
2630 const void *value, size_t size, int flags)
2633 struct timespec ts1,ts2;
2636 clock_gettime_mono(&ts1);
2637 result = SMB_VFS_NEXT_FSETXATTR(handle, fsp, name, value, size, flags);
2638 clock_gettime_mono(&ts2);
2639 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2641 if (timediff > audit_timeout) {
2642 smb_time_audit_log_fsp("fsetxattr", timediff, fsp);
2648 static bool smb_time_audit_aio_force(struct vfs_handle_struct *handle,
2649 struct files_struct *fsp)
2652 struct timespec ts1,ts2;
2655 clock_gettime_mono(&ts1);
2656 result = SMB_VFS_NEXT_AIO_FORCE(handle, fsp);
2657 clock_gettime_mono(&ts2);
2658 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2660 if (timediff > audit_timeout) {
2661 smb_time_audit_log_fsp("aio_force", timediff, fsp);
2667 static NTSTATUS smb_time_audit_durable_cookie(struct vfs_handle_struct *handle,
2668 struct files_struct *fsp,
2669 TALLOC_CTX *mem_ctx,
2673 struct timespec ts1,ts2;
2676 clock_gettime_mono(&ts1);
2677 result = SMB_VFS_NEXT_DURABLE_COOKIE(handle, fsp, mem_ctx, cookie);
2678 clock_gettime_mono(&ts2);
2679 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2681 if (timediff > audit_timeout) {
2682 smb_time_audit_log_fsp("durable_cookie", timediff, fsp);
2688 static NTSTATUS smb_time_audit_durable_disconnect(struct vfs_handle_struct *handle,
2689 struct files_struct *fsp,
2690 const DATA_BLOB old_cookie,
2691 TALLOC_CTX *mem_ctx,
2692 DATA_BLOB *new_cookie)
2695 struct timespec ts1,ts2;
2698 clock_gettime_mono(&ts1);
2699 result = SMB_VFS_NEXT_DURABLE_DISCONNECT(handle, fsp, old_cookie,
2700 mem_ctx, new_cookie);
2701 clock_gettime_mono(&ts2);
2702 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2704 if (timediff > audit_timeout) {
2705 smb_time_audit_log_fsp("durable_disconnect", timediff, fsp);
2711 static NTSTATUS smb_time_audit_durable_reconnect(struct vfs_handle_struct *handle,
2712 struct smb_request *smb1req,
2713 struct smbXsrv_open *op,
2714 const DATA_BLOB old_cookie,
2715 TALLOC_CTX *mem_ctx,
2716 struct files_struct **fsp,
2717 DATA_BLOB *new_cookie)
2720 struct timespec ts1,ts2;
2723 clock_gettime_mono(&ts1);
2724 result = SMB_VFS_NEXT_DURABLE_RECONNECT(handle, smb1req, op, old_cookie,
2725 mem_ctx, fsp, new_cookie);
2726 clock_gettime_mono(&ts2);
2727 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2729 if (timediff > audit_timeout) {
2730 smb_time_audit_log("durable_reconnect", timediff);
2736 /* VFS operations */
2738 static struct vfs_fn_pointers vfs_time_audit_fns = {
2739 .connect_fn = smb_time_audit_connect,
2740 .disconnect_fn = smb_time_audit_disconnect,
2741 .disk_free_fn = smb_time_audit_disk_free,
2742 .get_quota_fn = smb_time_audit_get_quota,
2743 .set_quota_fn = smb_time_audit_set_quota,
2744 .get_shadow_copy_data_fn = smb_time_audit_get_shadow_copy_data,
2745 .statvfs_fn = smb_time_audit_statvfs,
2746 .fs_capabilities_fn = smb_time_audit_fs_capabilities,
2747 .get_dfs_referrals_fn = smb_time_audit_get_dfs_referrals,
2748 .create_dfs_pathat_fn = smb_time_audit_create_dfs_pathat,
2749 .read_dfs_pathat_fn = smb_time_audit_read_dfs_pathat,
2750 .fdopendir_fn = smb_time_audit_fdopendir,
2751 .readdir_fn = smb_time_audit_readdir,
2752 .seekdir_fn = smb_time_audit_seekdir,
2753 .telldir_fn = smb_time_audit_telldir,
2754 .rewind_dir_fn = smb_time_audit_rewinddir,
2755 .mkdirat_fn = smb_time_audit_mkdirat,
2756 .closedir_fn = smb_time_audit_closedir,
2757 .openat_fn = smb_time_audit_openat,
2758 .create_file_fn = smb_time_audit_create_file,
2759 .close_fn = smb_time_audit_close,
2760 .pread_fn = smb_time_audit_pread,
2761 .pread_send_fn = smb_time_audit_pread_send,
2762 .pread_recv_fn = smb_time_audit_pread_recv,
2763 .pwrite_fn = smb_time_audit_pwrite,
2764 .pwrite_send_fn = smb_time_audit_pwrite_send,
2765 .pwrite_recv_fn = smb_time_audit_pwrite_recv,
2766 .lseek_fn = smb_time_audit_lseek,
2767 .sendfile_fn = smb_time_audit_sendfile,
2768 .recvfile_fn = smb_time_audit_recvfile,
2769 .renameat_fn = smb_time_audit_renameat,
2770 .fsync_send_fn = smb_time_audit_fsync_send,
2771 .fsync_recv_fn = smb_time_audit_fsync_recv,
2772 .stat_fn = smb_time_audit_stat,
2773 .fstat_fn = smb_time_audit_fstat,
2774 .lstat_fn = smb_time_audit_lstat,
2775 .fstatat_fn = smb_time_audit_fstatat,
2776 .get_alloc_size_fn = smb_time_audit_get_alloc_size,
2777 .unlinkat_fn = smb_time_audit_unlinkat,
2778 .fchmod_fn = smb_time_audit_fchmod,
2779 .fchown_fn = smb_time_audit_fchown,
2780 .lchown_fn = smb_time_audit_lchown,
2781 .chdir_fn = smb_time_audit_chdir,
2782 .getwd_fn = smb_time_audit_getwd,
2783 .fntimes_fn = smb_time_audit_fntimes,
2784 .ftruncate_fn = smb_time_audit_ftruncate,
2785 .fallocate_fn = smb_time_audit_fallocate,
2786 .lock_fn = smb_time_audit_lock,
2787 .filesystem_sharemode_fn = smb_time_audit_filesystem_sharemode,
2788 .fcntl_fn = smb_time_audit_fcntl,
2789 .linux_setlease_fn = smb_time_audit_linux_setlease,
2790 .getlock_fn = smb_time_audit_getlock,
2791 .symlinkat_fn = smb_time_audit_symlinkat,
2792 .readlinkat_fn = smb_time_audit_readlinkat,
2793 .linkat_fn = smb_time_audit_linkat,
2794 .mknodat_fn = smb_time_audit_mknodat,
2795 .realpath_fn = smb_time_audit_realpath,
2796 .fchflags_fn = smb_time_audit_fchflags,
2797 .file_id_create_fn = smb_time_audit_file_id_create,
2798 .fs_file_id_fn = smb_time_audit_fs_file_id,
2799 .offload_read_send_fn = smb_time_audit_offload_read_send,
2800 .offload_read_recv_fn = smb_time_audit_offload_read_recv,
2801 .offload_write_send_fn = smb_time_audit_offload_write_send,
2802 .offload_write_recv_fn = smb_time_audit_offload_write_recv,
2803 .fget_compression_fn = smb_time_audit_fget_compression,
2804 .set_compression_fn = smb_time_audit_set_compression,
2805 .snap_check_path_fn = smb_time_audit_snap_check_path,
2806 .snap_create_fn = smb_time_audit_snap_create,
2807 .snap_delete_fn = smb_time_audit_snap_delete,
2808 .fstreaminfo_fn = smb_time_audit_fstreaminfo,
2809 .get_real_filename_at_fn = smb_time_audit_get_real_filename_at,
2810 .connectpath_fn = smb_time_audit_connectpath,
2811 .brl_lock_windows_fn = smb_time_audit_brl_lock_windows,
2812 .brl_unlock_windows_fn = smb_time_audit_brl_unlock_windows,
2813 .strict_lock_check_fn = smb_time_audit_strict_lock_check,
2814 .translate_name_fn = smb_time_audit_translate_name,
2815 .parent_pathname_fn = smb_time_audit_parent_pathname,
2816 .fsctl_fn = smb_time_audit_fsctl,
2817 .get_dos_attributes_send_fn = smb_time_audit_get_dos_attributes_send,
2818 .get_dos_attributes_recv_fn = smb_time_audit_get_dos_attributes_recv,
2819 .fget_dos_attributes_fn = smb_time_fget_dos_attributes,
2820 .fset_dos_attributes_fn = smb_time_fset_dos_attributes,
2821 .fget_nt_acl_fn = smb_time_audit_fget_nt_acl,
2822 .fset_nt_acl_fn = smb_time_audit_fset_nt_acl,
2823 .audit_file_fn = smb_time_audit_audit_file,
2824 .sys_acl_get_fd_fn = smb_time_audit_sys_acl_get_fd,
2825 .sys_acl_blob_get_fd_fn = smb_time_audit_sys_acl_blob_get_fd,
2826 .sys_acl_set_fd_fn = smb_time_audit_sys_acl_set_fd,
2827 .sys_acl_delete_def_fd_fn = smb_time_audit_sys_acl_delete_def_fd,
2828 .getxattrat_send_fn = smb_time_audit_getxattrat_send,
2829 .getxattrat_recv_fn = smb_time_audit_getxattrat_recv,
2830 .fgetxattr_fn = smb_time_audit_fgetxattr,
2831 .flistxattr_fn = smb_time_audit_flistxattr,
2832 .fremovexattr_fn = smb_time_audit_fremovexattr,
2833 .fsetxattr_fn = smb_time_audit_fsetxattr,
2834 .aio_force_fn = smb_time_audit_aio_force,
2835 .durable_cookie_fn = smb_time_audit_durable_cookie,
2836 .durable_disconnect_fn = smb_time_audit_durable_disconnect,
2837 .durable_reconnect_fn = smb_time_audit_durable_reconnect,
2838 .freaddir_attr_fn = smb_time_audit_freaddir_attr,
2843 NTSTATUS vfs_time_audit_init(TALLOC_CTX *ctx)
2845 smb_vfs_assert_all_fns(&vfs_time_audit_fns, "time_audit");
2847 audit_timeout = (double)lp_parm_int(-1, "time_audit", "timeout",
2849 return smb_register_vfs(SMB_VFS_INTERFACE_VERSION, "time_audit",
2850 &vfs_time_audit_fns);