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 char *path, uint64_t *bsize,
161 uint64_t *dfree, uint64_t *dsize)
164 struct timespec ts1,ts2;
167 clock_gettime_mono(&ts1);
168 result = SMB_VFS_NEXT_DISK_FREE(handle, path, bsize, dfree, dsize);
169 clock_gettime_mono(&ts2);
170 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
172 /* Don't have a reasonable notion of failure here */
173 if (timediff > audit_timeout) {
174 smb_time_audit_log_fname("disk_free", timediff, path);
180 static int smb_time_audit_get_quota(struct vfs_handle_struct *handle,
181 const char *path, enum SMB_QUOTA_TYPE qtype,
182 unid_t id, SMB_DISK_QUOTA *qt)
185 struct timespec ts1,ts2;
188 clock_gettime_mono(&ts1);
189 result = SMB_VFS_NEXT_GET_QUOTA(handle, path, qtype, id, qt);
190 clock_gettime_mono(&ts2);
191 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
193 if (timediff > audit_timeout) {
194 smb_time_audit_log("get_quota", timediff);
199 static int smb_time_audit_set_quota(struct vfs_handle_struct *handle,
200 enum SMB_QUOTA_TYPE qtype, unid_t id,
204 struct timespec ts1,ts2;
207 clock_gettime_mono(&ts1);
208 result = SMB_VFS_NEXT_SET_QUOTA(handle, qtype, id, qt);
209 clock_gettime_mono(&ts2);
210 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
212 if (timediff > audit_timeout) {
213 smb_time_audit_log("set_quota", timediff);
219 static int smb_time_audit_get_shadow_copy_data(struct vfs_handle_struct *handle,
220 struct files_struct *fsp,
221 struct shadow_copy_data *shadow_copy_data,
225 struct timespec ts1,ts2;
228 clock_gettime_mono(&ts1);
229 result = SMB_VFS_NEXT_GET_SHADOW_COPY_DATA(handle, fsp,
230 shadow_copy_data, labels);
231 clock_gettime_mono(&ts2);
232 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
234 if (timediff > audit_timeout) {
235 smb_time_audit_log_fsp("get_shadow_copy_data", timediff, fsp);
241 static int smb_time_audit_statvfs(struct vfs_handle_struct *handle,
243 struct vfs_statvfs_struct *statbuf)
246 struct timespec ts1,ts2;
249 clock_gettime_mono(&ts1);
250 result = SMB_VFS_NEXT_STATVFS(handle, path, statbuf);
251 clock_gettime_mono(&ts2);
252 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
254 if (timediff > audit_timeout) {
255 smb_time_audit_log_fname("statvfs", timediff, path);
261 static uint32_t smb_time_audit_fs_capabilities(struct vfs_handle_struct *handle,
262 enum timestamp_set_resolution *p_ts_res)
265 struct timespec ts1,ts2;
268 clock_gettime_mono(&ts1);
269 result = SMB_VFS_NEXT_FS_CAPABILITIES(handle, p_ts_res);
270 clock_gettime_mono(&ts2);
271 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
273 if (timediff > audit_timeout) {
274 smb_time_audit_log("fs_capabilities", timediff);
280 static NTSTATUS smb_time_audit_get_dfs_referrals(
281 struct vfs_handle_struct *handle,
282 struct dfs_GetDFSReferral *r)
285 struct timespec ts1,ts2;
288 clock_gettime_mono(&ts1);
289 result = SMB_VFS_NEXT_GET_DFS_REFERRALS(handle, r);
290 clock_gettime_mono(&ts2);
291 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
293 if (timediff > audit_timeout) {
294 smb_time_audit_log("get_dfs_referrals(", timediff);
300 static NTSTATUS smb_time_audit_snap_check_path(struct vfs_handle_struct *handle,
302 const char *service_path,
306 struct timespec ts1,ts2;
309 clock_gettime_mono(&ts1);
310 status = SMB_VFS_NEXT_SNAP_CHECK_PATH(handle, mem_ctx, service_path,
312 clock_gettime_mono(&ts2);
313 timediff = nsec_time_diff(&ts2, &ts1) * 1.0e-9;
315 if (timediff > audit_timeout) {
316 smb_time_audit_log("snap_check_path", timediff);
322 static NTSTATUS smb_time_audit_snap_create(struct vfs_handle_struct *handle,
324 const char *base_volume,
331 struct timespec ts1,ts2;
334 clock_gettime_mono(&ts1);
335 status = SMB_VFS_NEXT_SNAP_CREATE(handle, mem_ctx, base_volume, tstamp,
336 rw, base_path, snap_path);
337 clock_gettime_mono(&ts2);
338 timediff = nsec_time_diff(&ts2 ,&ts1) * 1.0e-9;
340 if (timediff > audit_timeout) {
341 smb_time_audit_log("snap_create", timediff);
347 static NTSTATUS smb_time_audit_snap_delete(struct vfs_handle_struct *handle,
353 struct timespec ts1,ts2;
356 clock_gettime_mono(&ts1);
357 status = SMB_VFS_NEXT_SNAP_DELETE(handle, mem_ctx, base_path,
359 clock_gettime_mono(&ts2);
360 timediff = nsec_time_diff(&ts2, &ts1) * 1.0e-9;
362 if (timediff > audit_timeout) {
363 smb_time_audit_log("snap_delete", timediff);
369 static DIR *smb_time_audit_opendir(vfs_handle_struct *handle,
370 const struct smb_filename *smb_fname,
371 const char *mask, uint32_t attr)
374 struct timespec ts1,ts2;
377 clock_gettime_mono(&ts1);
378 result = SMB_VFS_NEXT_OPENDIR(handle, smb_fname, mask, attr);
379 clock_gettime_mono(&ts2);
380 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
382 if (timediff > audit_timeout) {
383 smb_time_audit_log_smb_fname("opendir", timediff, smb_fname);
389 static DIR *smb_time_audit_fdopendir(vfs_handle_struct *handle,
391 const char *mask, uint32_t attr)
394 struct timespec ts1,ts2;
397 clock_gettime_mono(&ts1);
398 result = SMB_VFS_NEXT_FDOPENDIR(handle, fsp, mask, attr);
399 clock_gettime_mono(&ts2);
400 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
402 if (timediff > audit_timeout) {
403 smb_time_audit_log_fsp("fdopendir", timediff, fsp);
409 static struct dirent *smb_time_audit_readdir(vfs_handle_struct *handle,
411 SMB_STRUCT_STAT *sbuf)
413 struct dirent *result;
414 struct timespec ts1,ts2;
417 clock_gettime_mono(&ts1);
418 result = SMB_VFS_NEXT_READDIR(handle, dirp, sbuf);
419 clock_gettime_mono(&ts2);
420 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
422 if (timediff > audit_timeout) {
423 smb_time_audit_log("readdir", timediff);
429 static void smb_time_audit_seekdir(vfs_handle_struct *handle,
430 DIR *dirp, long offset)
432 struct timespec ts1,ts2;
435 clock_gettime_mono(&ts1);
436 SMB_VFS_NEXT_SEEKDIR(handle, dirp, offset);
437 clock_gettime_mono(&ts2);
438 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
440 if (timediff > audit_timeout) {
441 smb_time_audit_log("seekdir", timediff);
446 static long smb_time_audit_telldir(vfs_handle_struct *handle,
450 struct timespec ts1,ts2;
453 clock_gettime_mono(&ts1);
454 result = SMB_VFS_NEXT_TELLDIR(handle, dirp);
455 clock_gettime_mono(&ts2);
456 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
458 if (timediff > audit_timeout) {
459 smb_time_audit_log("telldir", timediff);
465 static void smb_time_audit_rewinddir(vfs_handle_struct *handle,
468 struct timespec ts1,ts2;
471 clock_gettime_mono(&ts1);
472 SMB_VFS_NEXT_REWINDDIR(handle, dirp);
473 clock_gettime_mono(&ts2);
474 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
476 if (timediff > audit_timeout) {
477 smb_time_audit_log("rewinddir", timediff);
482 static int smb_time_audit_mkdir(vfs_handle_struct *handle,
483 const struct smb_filename *smb_fname,
487 struct timespec ts1,ts2;
490 clock_gettime_mono(&ts1);
491 result = SMB_VFS_NEXT_MKDIR(handle, smb_fname, mode);
492 clock_gettime_mono(&ts2);
493 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
495 if (timediff > audit_timeout) {
496 smb_time_audit_log_smb_fname("mkdir",
504 static int smb_time_audit_rmdir(vfs_handle_struct *handle,
505 const struct smb_filename *smb_fname)
508 struct timespec ts1,ts2;
511 clock_gettime_mono(&ts1);
512 result = SMB_VFS_NEXT_RMDIR(handle, smb_fname);
513 clock_gettime_mono(&ts2);
514 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
516 if (timediff > audit_timeout) {
517 smb_time_audit_log_smb_fname("rmdir",
525 static int smb_time_audit_closedir(vfs_handle_struct *handle,
529 struct timespec ts1,ts2;
532 clock_gettime_mono(&ts1);
533 result = SMB_VFS_NEXT_CLOSEDIR(handle, dirp);
534 clock_gettime_mono(&ts2);
535 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
537 if (timediff > audit_timeout) {
538 smb_time_audit_log("closedir", timediff);
544 static void smb_time_audit_init_search_op(vfs_handle_struct *handle,
547 struct timespec ts1,ts2;
550 clock_gettime_mono(&ts1);
551 SMB_VFS_NEXT_INIT_SEARCH_OP(handle, dirp);
552 clock_gettime_mono(&ts2);
553 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
555 if (timediff > audit_timeout) {
556 smb_time_audit_log("init_search_op", timediff);
560 static int smb_time_audit_open(vfs_handle_struct *handle,
561 struct smb_filename *fname,
563 int flags, mode_t mode)
566 struct timespec ts1,ts2;
569 clock_gettime_mono(&ts1);
570 result = SMB_VFS_NEXT_OPEN(handle, fname, fsp, flags, mode);
571 clock_gettime_mono(&ts2);
572 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
574 if (timediff > audit_timeout) {
575 smb_time_audit_log_fsp("open", timediff, fsp);
581 static NTSTATUS smb_time_audit_create_file(vfs_handle_struct *handle,
582 struct smb_request *req,
583 uint16_t root_dir_fid,
584 struct smb_filename *fname,
585 uint32_t access_mask,
586 uint32_t share_access,
587 uint32_t create_disposition,
588 uint32_t create_options,
589 uint32_t file_attributes,
590 uint32_t oplock_request,
591 struct smb2_lease *lease,
592 uint64_t allocation_size,
593 uint32_t private_flags,
594 struct security_descriptor *sd,
595 struct ea_list *ea_list,
596 files_struct **result_fsp,
598 const struct smb2_create_blobs *in_context_blobs,
599 struct smb2_create_blobs *out_context_blobs)
602 struct timespec ts1,ts2;
605 clock_gettime_mono(&ts1);
606 result = SMB_VFS_NEXT_CREATE_FILE(
609 root_dir_fid, /* root_dir_fid */
611 access_mask, /* access_mask */
612 share_access, /* share_access */
613 create_disposition, /* create_disposition*/
614 create_options, /* create_options */
615 file_attributes, /* file_attributes */
616 oplock_request, /* oplock_request */
618 allocation_size, /* allocation_size */
621 ea_list, /* ea_list */
622 result_fsp, /* result */
624 in_context_blobs, out_context_blobs); /* create context */
625 clock_gettime_mono(&ts2);
626 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
628 if (timediff > audit_timeout) {
630 * can't use result_fsp this time, may have
631 * invalid content causing smbd crash
633 smb_time_audit_log_smb_fname("create_file", timediff,
640 static int smb_time_audit_close(vfs_handle_struct *handle, files_struct *fsp)
643 struct timespec ts1,ts2;
646 clock_gettime_mono(&ts1);
647 result = SMB_VFS_NEXT_CLOSE(handle, fsp);
648 clock_gettime_mono(&ts2);
649 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
651 if (timediff > audit_timeout) {
652 smb_time_audit_log_fsp("close", timediff, fsp);
658 static ssize_t smb_time_audit_read(vfs_handle_struct *handle,
659 files_struct *fsp, void *data, size_t n)
662 struct timespec ts1,ts2;
665 clock_gettime_mono(&ts1);
666 result = SMB_VFS_NEXT_READ(handle, fsp, data, n);
667 clock_gettime_mono(&ts2);
668 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
670 if (timediff > audit_timeout) {
671 smb_time_audit_log_fsp("read", timediff, fsp);
677 static ssize_t smb_time_audit_pread(vfs_handle_struct *handle,
679 void *data, size_t n, off_t offset)
682 struct timespec ts1,ts2;
685 clock_gettime_mono(&ts1);
686 result = SMB_VFS_NEXT_PREAD(handle, fsp, data, n, offset);
687 clock_gettime_mono(&ts2);
688 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
690 if (timediff > audit_timeout) {
691 smb_time_audit_log_fsp("pread", timediff, fsp);
697 struct smb_time_audit_pread_state {
698 struct files_struct *fsp;
700 struct vfs_aio_state vfs_aio_state;
703 static void smb_time_audit_pread_done(struct tevent_req *subreq);
705 static struct tevent_req *smb_time_audit_pread_send(
706 struct vfs_handle_struct *handle, TALLOC_CTX *mem_ctx,
707 struct tevent_context *ev, struct files_struct *fsp,
708 void *data, size_t n, off_t offset)
710 struct tevent_req *req, *subreq;
711 struct smb_time_audit_pread_state *state;
713 req = tevent_req_create(mem_ctx, &state,
714 struct smb_time_audit_pread_state);
720 subreq = SMB_VFS_NEXT_PREAD_SEND(state, ev, handle, fsp, data,
722 if (tevent_req_nomem(subreq, req)) {
723 return tevent_req_post(req, ev);
725 tevent_req_set_callback(subreq, smb_time_audit_pread_done, req);
729 static void smb_time_audit_pread_done(struct tevent_req *subreq)
731 struct tevent_req *req = tevent_req_callback_data(
732 subreq, struct tevent_req);
733 struct smb_time_audit_pread_state *state = tevent_req_data(
734 req, struct smb_time_audit_pread_state);
736 state->ret = SMB_VFS_PREAD_RECV(subreq, &state->vfs_aio_state);
738 tevent_req_done(req);
741 static ssize_t smb_time_audit_pread_recv(struct tevent_req *req,
742 struct vfs_aio_state *vfs_aio_state)
744 struct smb_time_audit_pread_state *state = tevent_req_data(
745 req, struct smb_time_audit_pread_state);
748 timediff = state->vfs_aio_state.duration * 1.0e-9;
750 if (timediff > audit_timeout) {
751 smb_time_audit_log_fsp("async pread", timediff, state->fsp);
754 if (tevent_req_is_unix_error(req, &vfs_aio_state->error)) {
757 *vfs_aio_state = state->vfs_aio_state;
761 static ssize_t smb_time_audit_write(vfs_handle_struct *handle,
763 const void *data, size_t n)
766 struct timespec ts1,ts2;
769 clock_gettime_mono(&ts1);
770 result = SMB_VFS_NEXT_WRITE(handle, fsp, data, n);
771 clock_gettime_mono(&ts2);
772 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
774 if (timediff > audit_timeout) {
775 smb_time_audit_log_fsp("write", timediff, fsp);
781 static ssize_t smb_time_audit_pwrite(vfs_handle_struct *handle,
783 const void *data, size_t n,
787 struct timespec ts1,ts2;
790 clock_gettime_mono(&ts1);
791 result = SMB_VFS_NEXT_PWRITE(handle, fsp, data, n, offset);
792 clock_gettime_mono(&ts2);
793 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
795 if (timediff > audit_timeout) {
796 smb_time_audit_log_fsp("pwrite", timediff, fsp);
802 struct smb_time_audit_pwrite_state {
803 struct files_struct *fsp;
805 struct vfs_aio_state vfs_aio_state;
808 static void smb_time_audit_pwrite_done(struct tevent_req *subreq);
810 static struct tevent_req *smb_time_audit_pwrite_send(
811 struct vfs_handle_struct *handle, TALLOC_CTX *mem_ctx,
812 struct tevent_context *ev, struct files_struct *fsp,
813 const void *data, size_t n, off_t offset)
815 struct tevent_req *req, *subreq;
816 struct smb_time_audit_pwrite_state *state;
818 req = tevent_req_create(mem_ctx, &state,
819 struct smb_time_audit_pwrite_state);
825 subreq = SMB_VFS_NEXT_PWRITE_SEND(state, ev, handle, fsp, data,
827 if (tevent_req_nomem(subreq, req)) {
828 return tevent_req_post(req, ev);
830 tevent_req_set_callback(subreq, smb_time_audit_pwrite_done, req);
834 static void smb_time_audit_pwrite_done(struct tevent_req *subreq)
836 struct tevent_req *req = tevent_req_callback_data(
837 subreq, struct tevent_req);
838 struct smb_time_audit_pwrite_state *state = tevent_req_data(
839 req, struct smb_time_audit_pwrite_state);
841 state->ret = SMB_VFS_PWRITE_RECV(subreq, &state->vfs_aio_state);
843 tevent_req_done(req);
846 static ssize_t smb_time_audit_pwrite_recv(struct tevent_req *req,
847 struct vfs_aio_state *vfs_aio_state)
849 struct smb_time_audit_pwrite_state *state = tevent_req_data(
850 req, struct smb_time_audit_pwrite_state);
853 timediff = state->vfs_aio_state.duration * 1.0e-9;
855 if (timediff > audit_timeout) {
856 smb_time_audit_log_fsp("async pwrite", timediff, state->fsp);
859 if (tevent_req_is_unix_error(req, &vfs_aio_state->error)) {
862 *vfs_aio_state = state->vfs_aio_state;
866 static off_t smb_time_audit_lseek(vfs_handle_struct *handle,
868 off_t offset, int whence)
871 struct timespec ts1,ts2;
874 clock_gettime_mono(&ts1);
875 result = SMB_VFS_NEXT_LSEEK(handle, fsp, offset, whence);
876 clock_gettime_mono(&ts2);
877 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
879 if (timediff > audit_timeout) {
880 smb_time_audit_log_fsp("lseek", timediff, fsp);
886 static ssize_t smb_time_audit_sendfile(vfs_handle_struct *handle, int tofd,
887 files_struct *fromfsp,
888 const DATA_BLOB *hdr, off_t offset,
892 struct timespec ts1,ts2;
895 clock_gettime_mono(&ts1);
896 result = SMB_VFS_NEXT_SENDFILE(handle, tofd, fromfsp, hdr, offset, n);
897 clock_gettime_mono(&ts2);
898 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
900 if (timediff > audit_timeout) {
901 smb_time_audit_log_fsp("sendfile", timediff, fromfsp);
907 static ssize_t smb_time_audit_recvfile(vfs_handle_struct *handle, int fromfd,
913 struct timespec ts1,ts2;
916 clock_gettime_mono(&ts1);
917 result = SMB_VFS_NEXT_RECVFILE(handle, fromfd, tofsp, offset, n);
918 clock_gettime_mono(&ts2);
919 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
921 if (timediff > audit_timeout) {
922 smb_time_audit_log_fsp("recvfile", timediff, tofsp);
928 static int smb_time_audit_rename(vfs_handle_struct *handle,
929 const struct smb_filename *oldname,
930 const struct smb_filename *newname)
933 struct timespec ts1,ts2;
936 clock_gettime_mono(&ts1);
937 result = SMB_VFS_NEXT_RENAME(handle, oldname, newname);
938 clock_gettime_mono(&ts2);
939 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
941 if (timediff > audit_timeout) {
942 smb_time_audit_log_smb_fname("rename", timediff, newname);
948 static int smb_time_audit_fsync(vfs_handle_struct *handle, files_struct *fsp)
951 struct timespec ts1,ts2;
954 clock_gettime_mono(&ts1);
955 result = SMB_VFS_NEXT_FSYNC(handle, fsp);
956 clock_gettime_mono(&ts2);
957 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
959 if (timediff > audit_timeout) {
960 smb_time_audit_log_fsp("fsync", timediff, fsp);
966 struct smb_time_audit_fsync_state {
967 struct files_struct *fsp;
969 struct vfs_aio_state vfs_aio_state;
972 static void smb_time_audit_fsync_done(struct tevent_req *subreq);
974 static struct tevent_req *smb_time_audit_fsync_send(
975 struct vfs_handle_struct *handle, TALLOC_CTX *mem_ctx,
976 struct tevent_context *ev, struct files_struct *fsp)
978 struct tevent_req *req, *subreq;
979 struct smb_time_audit_fsync_state *state;
981 req = tevent_req_create(mem_ctx, &state,
982 struct smb_time_audit_fsync_state);
988 subreq = SMB_VFS_NEXT_FSYNC_SEND(state, ev, handle, fsp);
989 if (tevent_req_nomem(subreq, req)) {
990 return tevent_req_post(req, ev);
992 tevent_req_set_callback(subreq, smb_time_audit_fsync_done, req);
996 static void smb_time_audit_fsync_done(struct tevent_req *subreq)
998 struct tevent_req *req = tevent_req_callback_data(
999 subreq, struct tevent_req);
1000 struct smb_time_audit_fsync_state *state = tevent_req_data(
1001 req, struct smb_time_audit_fsync_state);
1003 state->ret = SMB_VFS_FSYNC_RECV(subreq, &state->vfs_aio_state);
1004 TALLOC_FREE(subreq);
1005 tevent_req_done(req);
1008 static int smb_time_audit_fsync_recv(struct tevent_req *req,
1009 struct vfs_aio_state *vfs_aio_state)
1011 struct smb_time_audit_fsync_state *state = tevent_req_data(
1012 req, struct smb_time_audit_fsync_state);
1015 timediff = state->vfs_aio_state.duration * 1.0e-9;
1017 if (timediff > audit_timeout) {
1018 smb_time_audit_log_fsp("async fsync", timediff, state->fsp);
1021 if (tevent_req_is_unix_error(req, &vfs_aio_state->error)) {
1024 *vfs_aio_state = state->vfs_aio_state;
1028 static int smb_time_audit_stat(vfs_handle_struct *handle,
1029 struct smb_filename *fname)
1032 struct timespec ts1,ts2;
1035 clock_gettime_mono(&ts1);
1036 result = SMB_VFS_NEXT_STAT(handle, fname);
1037 clock_gettime_mono(&ts2);
1038 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1040 if (timediff > audit_timeout) {
1041 smb_time_audit_log_smb_fname("stat", timediff, fname);
1047 static int smb_time_audit_fstat(vfs_handle_struct *handle, files_struct *fsp,
1048 SMB_STRUCT_STAT *sbuf)
1051 struct timespec ts1,ts2;
1054 clock_gettime_mono(&ts1);
1055 result = SMB_VFS_NEXT_FSTAT(handle, fsp, sbuf);
1056 clock_gettime_mono(&ts2);
1057 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1059 if (timediff > audit_timeout) {
1060 smb_time_audit_log_fsp("fstat", timediff, fsp);
1066 static int smb_time_audit_lstat(vfs_handle_struct *handle,
1067 struct smb_filename *path)
1070 struct timespec ts1,ts2;
1073 clock_gettime_mono(&ts1);
1074 result = SMB_VFS_NEXT_LSTAT(handle, path);
1075 clock_gettime_mono(&ts2);
1076 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1078 if (timediff > audit_timeout) {
1079 smb_time_audit_log_smb_fname("lstat", timediff, path);
1085 static uint64_t smb_time_audit_get_alloc_size(vfs_handle_struct *handle,
1087 const SMB_STRUCT_STAT *sbuf)
1090 struct timespec ts1,ts2;
1093 clock_gettime_mono(&ts1);
1094 result = SMB_VFS_NEXT_GET_ALLOC_SIZE(handle, fsp, sbuf);
1095 clock_gettime_mono(&ts2);
1096 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1098 if (timediff > audit_timeout) {
1099 smb_time_audit_log_fsp("get_alloc_size", timediff, fsp);
1105 static int smb_time_audit_unlink(vfs_handle_struct *handle,
1106 const struct smb_filename *path)
1109 struct timespec ts1,ts2;
1112 clock_gettime_mono(&ts1);
1113 result = SMB_VFS_NEXT_UNLINK(handle, path);
1114 clock_gettime_mono(&ts2);
1115 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1117 if (timediff > audit_timeout) {
1118 smb_time_audit_log_smb_fname("unlink", timediff, path);
1124 static int smb_time_audit_chmod(vfs_handle_struct *handle,
1125 const struct smb_filename *smb_fname,
1129 struct timespec ts1,ts2;
1132 clock_gettime_mono(&ts1);
1133 result = SMB_VFS_NEXT_CHMOD(handle, smb_fname, mode);
1134 clock_gettime_mono(&ts2);
1135 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1137 if (timediff > audit_timeout) {
1138 smb_time_audit_log_fname("chmod",
1140 smb_fname->base_name);
1146 static int smb_time_audit_fchmod(vfs_handle_struct *handle, files_struct *fsp,
1150 struct timespec ts1,ts2;
1153 clock_gettime_mono(&ts1);
1154 result = SMB_VFS_NEXT_FCHMOD(handle, fsp, mode);
1155 clock_gettime_mono(&ts2);
1156 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1158 if (timediff > audit_timeout) {
1159 smb_time_audit_log_fsp("fchmod", timediff, fsp);
1165 static int smb_time_audit_chown(vfs_handle_struct *handle,
1166 const struct smb_filename *smb_fname,
1171 struct timespec ts1,ts2;
1174 clock_gettime_mono(&ts1);
1175 result = SMB_VFS_NEXT_CHOWN(handle, smb_fname, uid, gid);
1176 clock_gettime_mono(&ts2);
1177 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1179 if (timediff > audit_timeout) {
1180 smb_time_audit_log_fname("chown",
1182 smb_fname->base_name);
1188 static int smb_time_audit_fchown(vfs_handle_struct *handle, files_struct *fsp,
1189 uid_t uid, gid_t gid)
1192 struct timespec ts1,ts2;
1195 clock_gettime_mono(&ts1);
1196 result = SMB_VFS_NEXT_FCHOWN(handle, fsp, uid, gid);
1197 clock_gettime_mono(&ts2);
1198 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1200 if (timediff > audit_timeout) {
1201 smb_time_audit_log_fsp("fchown", timediff, fsp);
1207 static int smb_time_audit_lchown(vfs_handle_struct *handle,
1208 const struct smb_filename *smb_fname,
1213 struct timespec ts1,ts2;
1216 clock_gettime_mono(&ts1);
1217 result = SMB_VFS_NEXT_LCHOWN(handle, smb_fname, uid, gid);
1218 clock_gettime_mono(&ts2);
1219 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1221 if (timediff > audit_timeout) {
1222 smb_time_audit_log_fname("lchown",
1224 smb_fname->base_name);
1230 static int smb_time_audit_chdir(vfs_handle_struct *handle, const char *path)
1233 struct timespec ts1,ts2;
1236 clock_gettime_mono(&ts1);
1237 result = SMB_VFS_NEXT_CHDIR(handle, path);
1238 clock_gettime_mono(&ts2);
1239 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1241 if (timediff > audit_timeout) {
1242 smb_time_audit_log_fname("chdir", timediff, path);
1248 static char *smb_time_audit_getwd(vfs_handle_struct *handle)
1251 struct timespec ts1,ts2;
1254 clock_gettime_mono(&ts1);
1255 result = SMB_VFS_NEXT_GETWD(handle);
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("getwd", timediff);
1266 static int smb_time_audit_ntimes(vfs_handle_struct *handle,
1267 const struct smb_filename *path,
1268 struct smb_file_time *ft)
1271 struct timespec ts1,ts2;
1274 clock_gettime_mono(&ts1);
1275 result = SMB_VFS_NEXT_NTIMES(handle, path, ft);
1276 clock_gettime_mono(&ts2);
1277 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1279 if (timediff > audit_timeout) {
1280 smb_time_audit_log_smb_fname("ntimes", timediff, path);
1286 static int smb_time_audit_ftruncate(vfs_handle_struct *handle,
1291 struct timespec ts1,ts2;
1294 clock_gettime_mono(&ts1);
1295 result = SMB_VFS_NEXT_FTRUNCATE(handle, fsp, len);
1296 clock_gettime_mono(&ts2);
1297 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1299 if (timediff > audit_timeout) {
1300 smb_time_audit_log_fsp("ftruncate", timediff, fsp);
1306 static int smb_time_audit_fallocate(vfs_handle_struct *handle,
1313 int saved_errno = 0;
1314 struct timespec ts1,ts2;
1317 clock_gettime_mono(&ts1);
1318 result = SMB_VFS_NEXT_FALLOCATE(handle, fsp, mode, offset, len);
1320 saved_errno = errno;
1322 clock_gettime_mono(&ts2);
1323 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1325 if (timediff > audit_timeout) {
1326 smb_time_audit_log_fsp("fallocate", timediff, fsp);
1329 errno = saved_errno;
1334 static bool smb_time_audit_lock(vfs_handle_struct *handle, files_struct *fsp,
1335 int op, off_t offset, off_t count,
1339 struct timespec ts1,ts2;
1342 clock_gettime_mono(&ts1);
1343 result = SMB_VFS_NEXT_LOCK(handle, fsp, op, offset, count, type);
1344 clock_gettime_mono(&ts2);
1345 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1347 if (timediff > audit_timeout) {
1348 smb_time_audit_log_fsp("lock", timediff, fsp);
1354 static int smb_time_audit_kernel_flock(struct vfs_handle_struct *handle,
1355 struct files_struct *fsp,
1356 uint32_t share_mode, uint32_t access_mask)
1359 struct timespec ts1,ts2;
1362 clock_gettime_mono(&ts1);
1363 result = SMB_VFS_NEXT_KERNEL_FLOCK(handle, fsp, share_mode,
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("kernel_flock", timediff, fsp);
1375 static int smb_time_audit_linux_setlease(vfs_handle_struct *handle,
1380 struct timespec ts1,ts2;
1383 clock_gettime_mono(&ts1);
1384 result = SMB_VFS_NEXT_LINUX_SETLEASE(handle, fsp, leasetype);
1385 clock_gettime_mono(&ts2);
1386 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1388 if (timediff > audit_timeout) {
1389 smb_time_audit_log_fsp("linux_setlease", timediff, fsp);
1395 static bool smb_time_audit_getlock(vfs_handle_struct *handle,
1397 off_t *poffset, off_t *pcount,
1398 int *ptype, pid_t *ppid)
1401 struct timespec ts1,ts2;
1404 clock_gettime_mono(&ts1);
1405 result = SMB_VFS_NEXT_GETLOCK(handle, fsp, poffset, pcount, ptype,
1407 clock_gettime_mono(&ts2);
1408 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1410 if (timediff > audit_timeout) {
1411 smb_time_audit_log_fsp("getlock", timediff, fsp);
1417 static int smb_time_audit_symlink(vfs_handle_struct *handle,
1418 const char *oldpath, const char *newpath)
1421 struct timespec ts1,ts2;
1424 clock_gettime_mono(&ts1);
1425 result = SMB_VFS_NEXT_SYMLINK(handle, oldpath, newpath);
1426 clock_gettime_mono(&ts2);
1427 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1429 if (timediff > audit_timeout) {
1430 smb_time_audit_log_fname("symlink", timediff, newpath);
1436 static int smb_time_audit_readlink(vfs_handle_struct *handle,
1437 const char *path, char *buf, size_t bufsiz)
1440 struct timespec ts1,ts2;
1443 clock_gettime_mono(&ts1);
1444 result = SMB_VFS_NEXT_READLINK(handle, path, buf, bufsiz);
1445 clock_gettime_mono(&ts2);
1446 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1448 if (timediff > audit_timeout) {
1449 smb_time_audit_log_fname("readlink", timediff, path);
1455 static int smb_time_audit_link(vfs_handle_struct *handle,
1456 const char *oldpath, const char *newpath)
1459 struct timespec ts1,ts2;
1462 clock_gettime_mono(&ts1);
1463 result = SMB_VFS_NEXT_LINK(handle, oldpath, newpath);
1464 clock_gettime_mono(&ts2);
1465 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1467 if (timediff > audit_timeout) {
1468 smb_time_audit_log_fname("link", timediff, newpath);
1474 static int smb_time_audit_mknod(vfs_handle_struct *handle,
1475 const struct smb_filename *smb_fname,
1480 struct timespec ts1,ts2;
1483 clock_gettime_mono(&ts1);
1484 result = SMB_VFS_NEXT_MKNOD(handle, smb_fname, mode, dev);
1485 clock_gettime_mono(&ts2);
1486 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1488 if (timediff > audit_timeout) {
1489 smb_time_audit_log_smb_fname("mknod", timediff, smb_fname);
1495 static char *smb_time_audit_realpath(vfs_handle_struct *handle,
1499 struct timespec ts1,ts2;
1502 clock_gettime_mono(&ts1);
1503 result = SMB_VFS_NEXT_REALPATH(handle, path);
1504 clock_gettime_mono(&ts2);
1505 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1507 if (timediff > audit_timeout) {
1508 smb_time_audit_log_fname("realpath", timediff, path);
1514 static int smb_time_audit_chflags(vfs_handle_struct *handle,
1515 const struct smb_filename *smb_fname,
1519 struct timespec ts1,ts2;
1522 clock_gettime_mono(&ts1);
1523 result = SMB_VFS_NEXT_CHFLAGS(handle, smb_fname, flags);
1524 clock_gettime_mono(&ts2);
1525 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1527 if (timediff > audit_timeout) {
1528 smb_time_audit_log_smb_fname("chflags", timediff, smb_fname);
1534 static struct file_id smb_time_audit_file_id_create(struct vfs_handle_struct *handle,
1535 const SMB_STRUCT_STAT *sbuf)
1537 struct file_id id_zero;
1538 struct file_id result;
1539 struct timespec ts1,ts2;
1542 ZERO_STRUCT(id_zero);
1544 clock_gettime_mono(&ts1);
1545 result = SMB_VFS_NEXT_FILE_ID_CREATE(handle, sbuf);
1546 clock_gettime_mono(&ts2);
1547 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1549 if (timediff > audit_timeout) {
1550 smb_time_audit_log("file_id_create", timediff);
1556 static NTSTATUS smb_time_audit_streaminfo(vfs_handle_struct *handle,
1557 struct files_struct *fsp,
1558 const struct smb_filename *smb_fname,
1559 TALLOC_CTX *mem_ctx,
1560 unsigned int *pnum_streams,
1561 struct stream_struct **pstreams)
1564 struct timespec ts1,ts2;
1567 clock_gettime_mono(&ts1);
1568 result = SMB_VFS_NEXT_STREAMINFO(handle, fsp, smb_fname, mem_ctx,
1569 pnum_streams, pstreams);
1570 clock_gettime_mono(&ts2);
1571 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1573 if (timediff > audit_timeout) {
1574 smb_time_audit_log_fsp("streaminfo", timediff, fsp);
1580 static int smb_time_audit_get_real_filename(struct vfs_handle_struct *handle,
1583 TALLOC_CTX *mem_ctx,
1587 struct timespec ts1,ts2;
1590 clock_gettime_mono(&ts1);
1591 result = SMB_VFS_NEXT_GET_REAL_FILENAME(handle, path, name, mem_ctx,
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_fname("get_real_filename", timediff, path);
1603 static const char *smb_time_audit_connectpath(vfs_handle_struct *handle,
1607 struct timespec ts1,ts2;
1610 clock_gettime_mono(&ts1);
1611 result = SMB_VFS_NEXT_CONNECTPATH(handle, fname);
1612 clock_gettime_mono(&ts2);
1613 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1615 if (timediff > audit_timeout) {
1616 smb_time_audit_log_fname("connectpath", timediff, fname);
1622 static NTSTATUS smb_time_audit_brl_lock_windows(struct vfs_handle_struct *handle,
1623 struct byte_range_lock *br_lck,
1624 struct lock_struct *plock,
1628 struct timespec ts1,ts2;
1631 clock_gettime_mono(&ts1);
1632 result = SMB_VFS_NEXT_BRL_LOCK_WINDOWS(handle, br_lck, plock,
1634 clock_gettime_mono(&ts2);
1635 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1637 if (timediff > audit_timeout) {
1638 smb_time_audit_log_fsp("brl_lock_windows", timediff,
1645 static bool smb_time_audit_brl_unlock_windows(struct vfs_handle_struct *handle,
1646 struct messaging_context *msg_ctx,
1647 struct byte_range_lock *br_lck,
1648 const struct lock_struct *plock)
1651 struct timespec ts1,ts2;
1654 clock_gettime_mono(&ts1);
1655 result = SMB_VFS_NEXT_BRL_UNLOCK_WINDOWS(handle, msg_ctx, br_lck,
1657 clock_gettime_mono(&ts2);
1658 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1660 if (timediff > audit_timeout) {
1661 smb_time_audit_log_fsp("brl_unlock_windows", timediff,
1668 static bool smb_time_audit_brl_cancel_windows(struct vfs_handle_struct *handle,
1669 struct byte_range_lock *br_lck,
1670 struct lock_struct *plock)
1673 struct timespec ts1,ts2;
1676 clock_gettime_mono(&ts1);
1677 result = SMB_VFS_NEXT_BRL_CANCEL_WINDOWS(handle, br_lck, plock);
1678 clock_gettime_mono(&ts2);
1679 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1681 if (timediff > audit_timeout) {
1682 smb_time_audit_log_fsp("brl_cancel_windows", timediff,
1689 static bool smb_time_audit_strict_lock(struct vfs_handle_struct *handle,
1690 struct files_struct *fsp,
1691 struct lock_struct *plock)
1694 struct timespec ts1,ts2;
1697 clock_gettime_mono(&ts1);
1698 result = SMB_VFS_NEXT_STRICT_LOCK(handle, fsp, plock);
1699 clock_gettime_mono(&ts2);
1700 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1702 if (timediff > audit_timeout) {
1703 smb_time_audit_log_fsp("strict_lock", timediff, fsp);
1709 static void smb_time_audit_strict_unlock(struct vfs_handle_struct *handle,
1710 struct files_struct *fsp,
1711 struct lock_struct *plock)
1713 struct timespec ts1,ts2;
1716 clock_gettime_mono(&ts1);
1717 SMB_VFS_NEXT_STRICT_UNLOCK(handle, fsp, plock);
1718 clock_gettime_mono(&ts2);
1719 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1721 if (timediff > audit_timeout) {
1722 smb_time_audit_log_fsp("strict_unlock", timediff, fsp);
1726 static NTSTATUS smb_time_audit_translate_name(struct vfs_handle_struct *handle,
1728 enum vfs_translate_direction direction,
1729 TALLOC_CTX *mem_ctx,
1733 struct timespec ts1,ts2;
1736 clock_gettime_mono(&ts1);
1737 result = SMB_VFS_NEXT_TRANSLATE_NAME(handle, name, direction, mem_ctx,
1739 clock_gettime_mono(&ts2);
1740 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1742 if (timediff > audit_timeout) {
1743 smb_time_audit_log_fname("translate_name", timediff, name);
1749 static NTSTATUS smb_time_audit_fsctl(struct vfs_handle_struct *handle,
1750 struct files_struct *fsp,
1754 const uint8_t *_in_data,
1756 uint8_t **_out_data,
1757 uint32_t max_out_len,
1761 struct timespec ts1,ts2;
1764 clock_gettime_mono(&ts1);
1765 result = SMB_VFS_NEXT_FSCTL(handle,
1775 clock_gettime_mono(&ts2);
1776 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1778 if (timediff > audit_timeout) {
1779 smb_time_audit_log_fsp("fsctl", timediff, fsp);
1785 static NTSTATUS smb_time_get_dos_attributes(struct vfs_handle_struct *handle,
1786 struct smb_filename *smb_fname,
1790 struct timespec ts1,ts2;
1793 clock_gettime_mono(&ts1);
1794 result = SMB_VFS_NEXT_GET_DOS_ATTRIBUTES(handle,
1797 clock_gettime_mono(&ts2);
1798 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1800 if (timediff > audit_timeout) {
1801 smb_time_audit_log_fname("get_dos_attributes",
1803 smb_fname->base_name);
1809 static NTSTATUS smb_time_fget_dos_attributes(struct vfs_handle_struct *handle,
1810 struct files_struct *fsp,
1814 struct timespec ts1,ts2;
1817 clock_gettime_mono(&ts1);
1818 result = SMB_VFS_NEXT_FGET_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_fsp("fget_dos_attributes", timediff, fsp);
1831 static NTSTATUS smb_time_set_dos_attributes(struct vfs_handle_struct *handle,
1832 const struct smb_filename *smb_fname,
1836 struct timespec ts1,ts2;
1839 clock_gettime_mono(&ts1);
1840 result = SMB_VFS_NEXT_SET_DOS_ATTRIBUTES(handle,
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("set_dos_attributes",
1849 smb_fname->base_name);
1855 static NTSTATUS smb_time_fset_dos_attributes(struct vfs_handle_struct *handle,
1856 struct files_struct *fsp,
1860 struct timespec ts1,ts2;
1863 clock_gettime_mono(&ts1);
1864 result = SMB_VFS_NEXT_FSET_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_fsp("fset_dos_attributes", timediff, fsp);
1877 struct time_audit_cc_state {
1878 struct timespec ts_send;
1879 struct vfs_handle_struct *handle;
1882 static void smb_time_audit_copy_chunk_done(struct tevent_req *subreq);
1884 static struct tevent_req *smb_time_audit_copy_chunk_send(struct vfs_handle_struct *handle,
1885 TALLOC_CTX *mem_ctx,
1886 struct tevent_context *ev,
1887 struct files_struct *src_fsp,
1889 struct files_struct *dest_fsp,
1894 struct tevent_req *req;
1895 struct tevent_req *subreq;
1896 struct time_audit_cc_state *cc_state;
1898 req = tevent_req_create(mem_ctx, &cc_state, struct time_audit_cc_state);
1903 cc_state->handle = handle;
1904 clock_gettime_mono(&cc_state->ts_send);
1905 subreq = SMB_VFS_NEXT_COPY_CHUNK_SEND(handle, cc_state, ev,
1907 dest_fsp, dest_off, num, flags);
1908 if (tevent_req_nomem(subreq, req)) {
1909 return tevent_req_post(req, ev);
1912 tevent_req_set_callback(subreq, smb_time_audit_copy_chunk_done, req);
1916 static void smb_time_audit_copy_chunk_done(struct tevent_req *subreq)
1918 struct tevent_req *req = tevent_req_callback_data(
1919 subreq, struct tevent_req);
1920 struct time_audit_cc_state *cc_state
1921 = tevent_req_data(req, struct time_audit_cc_state);
1924 status = SMB_VFS_NEXT_COPY_CHUNK_RECV(cc_state->handle,
1927 TALLOC_FREE(subreq);
1928 if (tevent_req_nterror(req, status)) {
1931 tevent_req_done(req);
1934 static NTSTATUS smb_time_audit_copy_chunk_recv(struct vfs_handle_struct *handle,
1935 struct tevent_req *req,
1938 struct time_audit_cc_state *cc_state
1939 = tevent_req_data(req, struct time_audit_cc_state);
1940 struct timespec ts_recv;
1944 clock_gettime_mono(&ts_recv);
1945 timediff = nsec_time_diff(&ts_recv, &cc_state->ts_send)*1.0e-9;
1946 if (timediff > audit_timeout) {
1947 smb_time_audit_log("copy_chunk", timediff);
1950 *copied = cc_state->copied;
1951 if (tevent_req_is_nterror(req, &status)) {
1952 tevent_req_received(req);
1956 tevent_req_received(req);
1957 return NT_STATUS_OK;
1960 static NTSTATUS smb_time_audit_get_compression(vfs_handle_struct *handle,
1961 TALLOC_CTX *mem_ctx,
1962 struct files_struct *fsp,
1963 struct smb_filename *smb_fname,
1964 uint16_t *_compression_fmt)
1967 struct timespec ts1,ts2;
1970 clock_gettime_mono(&ts1);
1971 result = SMB_VFS_NEXT_GET_COMPRESSION(handle, mem_ctx, fsp, smb_fname,
1973 clock_gettime_mono(&ts2);
1974 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1976 if (timediff > audit_timeout) {
1978 smb_time_audit_log_fsp("get_compression",
1981 smb_time_audit_log_smb_fname("get_compression",
1982 timediff, smb_fname);
1989 static NTSTATUS smb_time_audit_set_compression(vfs_handle_struct *handle,
1990 TALLOC_CTX *mem_ctx,
1991 struct files_struct *fsp,
1992 uint16_t compression_fmt)
1995 struct timespec ts1,ts2;
1998 clock_gettime_mono(&ts1);
1999 result = SMB_VFS_NEXT_SET_COMPRESSION(handle, mem_ctx, fsp,
2001 clock_gettime_mono(&ts2);
2002 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2004 if (timediff > audit_timeout) {
2005 smb_time_audit_log_fsp("set_compression", timediff, fsp);
2011 static NTSTATUS smb_time_audit_readdir_attr(struct vfs_handle_struct *handle,
2012 const struct smb_filename *fname,
2013 TALLOC_CTX *mem_ctx,
2014 struct readdir_attr_data **pattr_data)
2017 struct timespec ts1,ts2;
2020 clock_gettime_mono(&ts1);
2021 status = SMB_VFS_NEXT_READDIR_ATTR(handle, fname, mem_ctx, pattr_data);
2022 clock_gettime_mono(&ts2);
2023 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2025 if (timediff > audit_timeout) {
2026 smb_time_audit_log_smb_fname("readdir_attr", timediff, fname);
2032 static NTSTATUS smb_time_audit_fget_nt_acl(vfs_handle_struct *handle,
2034 uint32_t security_info,
2035 TALLOC_CTX *mem_ctx,
2036 struct security_descriptor **ppdesc)
2039 struct timespec ts1,ts2;
2042 clock_gettime_mono(&ts1);
2043 result = SMB_VFS_NEXT_FGET_NT_ACL(handle, fsp, security_info,
2045 clock_gettime_mono(&ts2);
2046 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2048 if (timediff > audit_timeout) {
2049 smb_time_audit_log_fsp("fget_nt_acl", timediff, fsp);
2055 static NTSTATUS smb_time_audit_get_nt_acl(vfs_handle_struct *handle,
2056 const struct smb_filename *smb_fname,
2057 uint32_t security_info,
2058 TALLOC_CTX *mem_ctx,
2059 struct security_descriptor **ppdesc)
2062 struct timespec ts1,ts2;
2065 clock_gettime_mono(&ts1);
2066 result = SMB_VFS_NEXT_GET_NT_ACL(handle, smb_fname, security_info,
2068 clock_gettime_mono(&ts2);
2069 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2071 if (timediff > audit_timeout) {
2072 smb_time_audit_log_fname("get_nt_acl",
2074 smb_fname->base_name);
2080 static NTSTATUS smb_time_audit_fset_nt_acl(vfs_handle_struct *handle,
2082 uint32_t security_info_sent,
2083 const struct security_descriptor *psd)
2086 struct timespec ts1,ts2;
2089 clock_gettime_mono(&ts1);
2090 result = SMB_VFS_NEXT_FSET_NT_ACL(handle, fsp, security_info_sent,
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_fsp("fset_nt_acl", timediff, fsp);
2102 static NTSTATUS smb_time_audit_audit_file(struct vfs_handle_struct *handle,
2103 struct smb_filename *smb_fname,
2104 struct security_acl *sacl,
2105 uint32_t access_requested,
2106 uint32_t access_denied)
2109 struct timespec ts1,ts2;
2112 clock_gettime_mono(&ts1);
2113 result = SMB_VFS_NEXT_AUDIT_FILE(handle,
2118 clock_gettime_mono(&ts2);
2119 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2121 if (timediff > audit_timeout) {
2122 smb_time_audit_log_fname("audit_file",
2124 smb_fname->base_name);
2132 static int smb_time_audit_chmod_acl(vfs_handle_struct *handle,
2133 const struct smb_filename *smb_fname,
2137 struct timespec ts1,ts2;
2140 clock_gettime_mono(&ts1);
2141 result = SMB_VFS_NEXT_CHMOD_ACL(handle, smb_fname, mode);
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("chmod_acl",
2148 smb_fname->base_name);
2154 static int smb_time_audit_fchmod_acl(vfs_handle_struct *handle,
2155 files_struct *fsp, mode_t mode)
2158 struct timespec ts1,ts2;
2161 clock_gettime_mono(&ts1);
2162 result = SMB_VFS_NEXT_FCHMOD_ACL(handle, fsp, mode);
2163 clock_gettime_mono(&ts2);
2164 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2166 if (timediff > audit_timeout) {
2167 smb_time_audit_log_fsp("fchmod_acl", timediff, fsp);
2173 static SMB_ACL_T smb_time_audit_sys_acl_get_file(vfs_handle_struct *handle,
2174 const struct smb_filename *smb_fname,
2175 SMB_ACL_TYPE_T type,
2176 TALLOC_CTX *mem_ctx)
2179 struct timespec ts1,ts2;
2182 clock_gettime_mono(&ts1);
2183 result = SMB_VFS_NEXT_SYS_ACL_GET_FILE(handle, smb_fname,
2185 clock_gettime_mono(&ts2);
2186 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2188 if (timediff > audit_timeout) {
2189 smb_time_audit_log_fname("sys_acl_get_file", timediff,
2190 smb_fname->base_name);
2196 static SMB_ACL_T smb_time_audit_sys_acl_get_fd(vfs_handle_struct *handle,
2198 TALLOC_CTX *mem_ctx)
2201 struct timespec ts1,ts2;
2204 clock_gettime_mono(&ts1);
2205 result = SMB_VFS_NEXT_SYS_ACL_GET_FD(handle, fsp, mem_ctx);
2206 clock_gettime_mono(&ts2);
2207 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2209 if (timediff > audit_timeout) {
2210 smb_time_audit_log_fsp("sys_acl_get_fd", timediff, fsp);
2217 static int smb_time_audit_sys_acl_blob_get_file(vfs_handle_struct *handle,
2218 const struct smb_filename *smb_fname,
2219 TALLOC_CTX *mem_ctx,
2220 char **blob_description,
2224 struct timespec ts1,ts2;
2227 clock_gettime_mono(&ts1);
2228 result = SMB_VFS_NEXT_SYS_ACL_BLOB_GET_FILE(handle, smb_fname,
2229 mem_ctx, blob_description, blob);
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("sys_acl_blob_get_file", timediff);
2240 static int smb_time_audit_sys_acl_blob_get_fd(vfs_handle_struct *handle,
2242 TALLOC_CTX *mem_ctx,
2243 char **blob_description,
2247 struct timespec ts1,ts2;
2250 clock_gettime_mono(&ts1);
2251 result = SMB_VFS_NEXT_SYS_ACL_BLOB_GET_FD(handle, fsp, mem_ctx, blob_description, blob);
2252 clock_gettime_mono(&ts2);
2253 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2255 if (timediff > audit_timeout) {
2256 smb_time_audit_log("sys_acl_blob_get_fd", timediff);
2262 static int smb_time_audit_sys_acl_set_file(vfs_handle_struct *handle,
2263 const struct smb_filename *smb_fname,
2264 SMB_ACL_TYPE_T acltype,
2268 struct timespec ts1,ts2;
2271 clock_gettime_mono(&ts1);
2272 result = SMB_VFS_NEXT_SYS_ACL_SET_FILE(handle, smb_fname, acltype,
2274 clock_gettime_mono(&ts2);
2275 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2277 if (timediff > audit_timeout) {
2278 smb_time_audit_log_fname("sys_acl_set_file", timediff,
2279 smb_fname->base_name);
2285 static int smb_time_audit_sys_acl_set_fd(vfs_handle_struct *handle,
2290 struct timespec ts1,ts2;
2293 clock_gettime_mono(&ts1);
2294 result = SMB_VFS_NEXT_SYS_ACL_SET_FD(handle, fsp, theacl);
2295 clock_gettime_mono(&ts2);
2296 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2298 if (timediff > audit_timeout) {
2299 smb_time_audit_log_fsp("sys_acl_set_fd", timediff, fsp);
2305 static int smb_time_audit_sys_acl_delete_def_file(vfs_handle_struct *handle,
2306 const struct smb_filename *smb_fname)
2309 struct timespec ts1,ts2;
2312 clock_gettime_mono(&ts1);
2313 result = SMB_VFS_NEXT_SYS_ACL_DELETE_DEF_FILE(handle, smb_fname);
2314 clock_gettime_mono(&ts2);
2315 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2317 if (timediff > audit_timeout) {
2318 smb_time_audit_log_fname("sys_acl_delete_def_file", timediff,
2319 smb_fname->base_name);
2325 static ssize_t smb_time_audit_getxattr(struct vfs_handle_struct *handle,
2326 const struct smb_filename *smb_fname,
2332 struct timespec ts1,ts2;
2335 clock_gettime_mono(&ts1);
2336 result = SMB_VFS_NEXT_GETXATTR(handle, smb_fname, name, value, size);
2337 clock_gettime_mono(&ts2);
2338 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2340 if (timediff > audit_timeout) {
2341 smb_time_audit_log_fname("getxattr", timediff,
2342 smb_fname->base_name);
2348 static ssize_t smb_time_audit_fgetxattr(struct vfs_handle_struct *handle,
2349 struct files_struct *fsp,
2350 const char *name, void *value,
2354 struct timespec ts1,ts2;
2357 clock_gettime_mono(&ts1);
2358 result = SMB_VFS_NEXT_FGETXATTR(handle, fsp, name, value, size);
2359 clock_gettime_mono(&ts2);
2360 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2362 if (timediff > audit_timeout) {
2363 smb_time_audit_log_fsp("fgetxattr", timediff, fsp);
2369 static ssize_t smb_time_audit_listxattr(struct vfs_handle_struct *handle,
2370 const struct smb_filename *smb_fname,
2375 struct timespec ts1,ts2;
2378 clock_gettime_mono(&ts1);
2379 result = SMB_VFS_NEXT_LISTXATTR(handle, smb_fname, list, size);
2380 clock_gettime_mono(&ts2);
2381 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2383 if (timediff > audit_timeout) {
2384 smb_time_audit_log_fname("listxattr", timediff,
2385 smb_fname->base_name);
2391 static ssize_t smb_time_audit_flistxattr(struct vfs_handle_struct *handle,
2392 struct files_struct *fsp, char *list,
2396 struct timespec ts1,ts2;
2399 clock_gettime_mono(&ts1);
2400 result = SMB_VFS_NEXT_FLISTXATTR(handle, fsp, list, size);
2401 clock_gettime_mono(&ts2);
2402 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2404 if (timediff > audit_timeout) {
2405 smb_time_audit_log_fsp("flistxattr", timediff, fsp);
2411 static int smb_time_audit_removexattr(struct vfs_handle_struct *handle,
2412 const struct smb_filename *smb_fname,
2416 struct timespec ts1,ts2;
2419 clock_gettime_mono(&ts1);
2420 result = SMB_VFS_NEXT_REMOVEXATTR(handle, smb_fname, name);
2421 clock_gettime_mono(&ts2);
2422 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2424 if (timediff > audit_timeout) {
2425 smb_time_audit_log_fname("removexattr", timediff,
2426 smb_fname->base_name);
2432 static int smb_time_audit_fremovexattr(struct vfs_handle_struct *handle,
2433 struct files_struct *fsp,
2437 struct timespec ts1,ts2;
2440 clock_gettime_mono(&ts1);
2441 result = SMB_VFS_NEXT_FREMOVEXATTR(handle, fsp, name);
2442 clock_gettime_mono(&ts2);
2443 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2445 if (timediff > audit_timeout) {
2446 smb_time_audit_log_fsp("fremovexattr", timediff, fsp);
2452 static int smb_time_audit_setxattr(struct vfs_handle_struct *handle,
2453 const struct smb_filename *smb_fname,
2460 struct timespec ts1,ts2;
2463 clock_gettime_mono(&ts1);
2464 result = SMB_VFS_NEXT_SETXATTR(handle, smb_fname, name, value, size,
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_fname("setxattr", timediff,
2471 smb_fname->base_name);
2477 static int smb_time_audit_fsetxattr(struct vfs_handle_struct *handle,
2478 struct files_struct *fsp, const char *name,
2479 const void *value, size_t size, int flags)
2482 struct timespec ts1,ts2;
2485 clock_gettime_mono(&ts1);
2486 result = SMB_VFS_NEXT_FSETXATTR(handle, fsp, name, value, size, flags);
2487 clock_gettime_mono(&ts2);
2488 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2490 if (timediff > audit_timeout) {
2491 smb_time_audit_log_fsp("fsetxattr", timediff, fsp);
2497 static bool smb_time_audit_aio_force(struct vfs_handle_struct *handle,
2498 struct files_struct *fsp)
2501 struct timespec ts1,ts2;
2504 clock_gettime_mono(&ts1);
2505 result = SMB_VFS_NEXT_AIO_FORCE(handle, fsp);
2506 clock_gettime_mono(&ts2);
2507 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2509 if (timediff > audit_timeout) {
2510 smb_time_audit_log_fsp("aio_force", timediff, fsp);
2516 static NTSTATUS smb_time_audit_durable_cookie(struct vfs_handle_struct *handle,
2517 struct files_struct *fsp,
2518 TALLOC_CTX *mem_ctx,
2522 struct timespec ts1,ts2;
2525 clock_gettime_mono(&ts1);
2526 result = SMB_VFS_NEXT_DURABLE_COOKIE(handle, fsp, mem_ctx, cookie);
2527 clock_gettime_mono(&ts2);
2528 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2530 if (timediff > audit_timeout) {
2531 smb_time_audit_log_fsp("durable_cookie", timediff, fsp);
2537 static NTSTATUS smb_time_audit_durable_disconnect(struct vfs_handle_struct *handle,
2538 struct files_struct *fsp,
2539 const DATA_BLOB old_cookie,
2540 TALLOC_CTX *mem_ctx,
2541 DATA_BLOB *new_cookie)
2544 struct timespec ts1,ts2;
2547 clock_gettime_mono(&ts1);
2548 result = SMB_VFS_NEXT_DURABLE_DISCONNECT(handle, fsp, old_cookie,
2549 mem_ctx, new_cookie);
2550 clock_gettime_mono(&ts2);
2551 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2553 if (timediff > audit_timeout) {
2554 smb_time_audit_log_fsp("durable_disconnect", timediff, fsp);
2560 static NTSTATUS smb_time_audit_durable_reconnect(struct vfs_handle_struct *handle,
2561 struct smb_request *smb1req,
2562 struct smbXsrv_open *op,
2563 const DATA_BLOB old_cookie,
2564 TALLOC_CTX *mem_ctx,
2565 struct files_struct **fsp,
2566 DATA_BLOB *new_cookie)
2569 struct timespec ts1,ts2;
2572 clock_gettime_mono(&ts1);
2573 result = SMB_VFS_NEXT_DURABLE_RECONNECT(handle, smb1req, op, old_cookie,
2574 mem_ctx, fsp, new_cookie);
2575 clock_gettime_mono(&ts2);
2576 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2578 if (timediff > audit_timeout) {
2579 smb_time_audit_log("durable_reconnect", timediff);
2585 /* VFS operations */
2587 static struct vfs_fn_pointers vfs_time_audit_fns = {
2588 .connect_fn = smb_time_audit_connect,
2589 .disconnect_fn = smb_time_audit_disconnect,
2590 .disk_free_fn = smb_time_audit_disk_free,
2591 .get_quota_fn = smb_time_audit_get_quota,
2592 .set_quota_fn = smb_time_audit_set_quota,
2593 .get_shadow_copy_data_fn = smb_time_audit_get_shadow_copy_data,
2594 .statvfs_fn = smb_time_audit_statvfs,
2595 .fs_capabilities_fn = smb_time_audit_fs_capabilities,
2596 .get_dfs_referrals_fn = smb_time_audit_get_dfs_referrals,
2597 .opendir_fn = smb_time_audit_opendir,
2598 .fdopendir_fn = smb_time_audit_fdopendir,
2599 .readdir_fn = smb_time_audit_readdir,
2600 .seekdir_fn = smb_time_audit_seekdir,
2601 .telldir_fn = smb_time_audit_telldir,
2602 .rewind_dir_fn = smb_time_audit_rewinddir,
2603 .mkdir_fn = smb_time_audit_mkdir,
2604 .rmdir_fn = smb_time_audit_rmdir,
2605 .closedir_fn = smb_time_audit_closedir,
2606 .init_search_op_fn = smb_time_audit_init_search_op,
2607 .open_fn = smb_time_audit_open,
2608 .create_file_fn = smb_time_audit_create_file,
2609 .close_fn = smb_time_audit_close,
2610 .read_fn = smb_time_audit_read,
2611 .pread_fn = smb_time_audit_pread,
2612 .pread_send_fn = smb_time_audit_pread_send,
2613 .pread_recv_fn = smb_time_audit_pread_recv,
2614 .write_fn = smb_time_audit_write,
2615 .pwrite_fn = smb_time_audit_pwrite,
2616 .pwrite_send_fn = smb_time_audit_pwrite_send,
2617 .pwrite_recv_fn = smb_time_audit_pwrite_recv,
2618 .lseek_fn = smb_time_audit_lseek,
2619 .sendfile_fn = smb_time_audit_sendfile,
2620 .recvfile_fn = smb_time_audit_recvfile,
2621 .rename_fn = smb_time_audit_rename,
2622 .fsync_fn = smb_time_audit_fsync,
2623 .fsync_send_fn = smb_time_audit_fsync_send,
2624 .fsync_recv_fn = smb_time_audit_fsync_recv,
2625 .stat_fn = smb_time_audit_stat,
2626 .fstat_fn = smb_time_audit_fstat,
2627 .lstat_fn = smb_time_audit_lstat,
2628 .get_alloc_size_fn = smb_time_audit_get_alloc_size,
2629 .unlink_fn = smb_time_audit_unlink,
2630 .chmod_fn = smb_time_audit_chmod,
2631 .fchmod_fn = smb_time_audit_fchmod,
2632 .chown_fn = smb_time_audit_chown,
2633 .fchown_fn = smb_time_audit_fchown,
2634 .lchown_fn = smb_time_audit_lchown,
2635 .chdir_fn = smb_time_audit_chdir,
2636 .getwd_fn = smb_time_audit_getwd,
2637 .ntimes_fn = smb_time_audit_ntimes,
2638 .ftruncate_fn = smb_time_audit_ftruncate,
2639 .fallocate_fn = smb_time_audit_fallocate,
2640 .lock_fn = smb_time_audit_lock,
2641 .kernel_flock_fn = smb_time_audit_kernel_flock,
2642 .linux_setlease_fn = smb_time_audit_linux_setlease,
2643 .getlock_fn = smb_time_audit_getlock,
2644 .symlink_fn = smb_time_audit_symlink,
2645 .readlink_fn = smb_time_audit_readlink,
2646 .link_fn = smb_time_audit_link,
2647 .mknod_fn = smb_time_audit_mknod,
2648 .realpath_fn = smb_time_audit_realpath,
2649 .chflags_fn = smb_time_audit_chflags,
2650 .file_id_create_fn = smb_time_audit_file_id_create,
2651 .copy_chunk_send_fn = smb_time_audit_copy_chunk_send,
2652 .copy_chunk_recv_fn = smb_time_audit_copy_chunk_recv,
2653 .get_compression_fn = smb_time_audit_get_compression,
2654 .set_compression_fn = smb_time_audit_set_compression,
2655 .snap_check_path_fn = smb_time_audit_snap_check_path,
2656 .snap_create_fn = smb_time_audit_snap_create,
2657 .snap_delete_fn = smb_time_audit_snap_delete,
2658 .streaminfo_fn = smb_time_audit_streaminfo,
2659 .get_real_filename_fn = smb_time_audit_get_real_filename,
2660 .connectpath_fn = smb_time_audit_connectpath,
2661 .brl_lock_windows_fn = smb_time_audit_brl_lock_windows,
2662 .brl_unlock_windows_fn = smb_time_audit_brl_unlock_windows,
2663 .brl_cancel_windows_fn = smb_time_audit_brl_cancel_windows,
2664 .strict_lock_fn = smb_time_audit_strict_lock,
2665 .strict_unlock_fn = smb_time_audit_strict_unlock,
2666 .translate_name_fn = smb_time_audit_translate_name,
2667 .fsctl_fn = smb_time_audit_fsctl,
2668 .get_dos_attributes_fn = smb_time_get_dos_attributes,
2669 .fget_dos_attributes_fn = smb_time_fget_dos_attributes,
2670 .set_dos_attributes_fn = smb_time_set_dos_attributes,
2671 .fset_dos_attributes_fn = smb_time_fset_dos_attributes,
2672 .fget_nt_acl_fn = smb_time_audit_fget_nt_acl,
2673 .get_nt_acl_fn = smb_time_audit_get_nt_acl,
2674 .fset_nt_acl_fn = smb_time_audit_fset_nt_acl,
2675 .audit_file_fn = smb_time_audit_audit_file,
2676 .chmod_acl_fn = smb_time_audit_chmod_acl,
2677 .fchmod_acl_fn = smb_time_audit_fchmod_acl,
2678 .sys_acl_get_file_fn = smb_time_audit_sys_acl_get_file,
2679 .sys_acl_get_fd_fn = smb_time_audit_sys_acl_get_fd,
2680 .sys_acl_blob_get_file_fn = smb_time_audit_sys_acl_blob_get_file,
2681 .sys_acl_blob_get_fd_fn = smb_time_audit_sys_acl_blob_get_fd,
2682 .sys_acl_set_file_fn = smb_time_audit_sys_acl_set_file,
2683 .sys_acl_set_fd_fn = smb_time_audit_sys_acl_set_fd,
2684 .sys_acl_delete_def_file_fn = smb_time_audit_sys_acl_delete_def_file,
2685 .getxattr_fn = smb_time_audit_getxattr,
2686 .fgetxattr_fn = smb_time_audit_fgetxattr,
2687 .listxattr_fn = smb_time_audit_listxattr,
2688 .flistxattr_fn = smb_time_audit_flistxattr,
2689 .removexattr_fn = smb_time_audit_removexattr,
2690 .fremovexattr_fn = smb_time_audit_fremovexattr,
2691 .setxattr_fn = smb_time_audit_setxattr,
2692 .fsetxattr_fn = smb_time_audit_fsetxattr,
2693 .aio_force_fn = smb_time_audit_aio_force,
2694 .durable_cookie_fn = smb_time_audit_durable_cookie,
2695 .durable_disconnect_fn = smb_time_audit_durable_disconnect,
2696 .durable_reconnect_fn = smb_time_audit_durable_reconnect,
2697 .readdir_attr_fn = smb_time_audit_readdir_attr,
2701 NTSTATUS vfs_time_audit_init(TALLOC_CTX *);
2702 NTSTATUS vfs_time_audit_init(TALLOC_CTX *ctx)
2704 smb_vfs_assert_all_fns(&vfs_time_audit_fns, "time_audit");
2706 audit_timeout = (double)lp_parm_int(-1, "time_audit", "timeout",
2708 return smb_register_vfs(SMB_VFS_INTERFACE_VERSION, "time_audit",
2709 &vfs_time_audit_fns);