The branch, master has been updated via 624e51a s3:smbd Bump the smbd vfs interface version to 30 via 5765d73 s3:vfs/time_audit: Add back pointer for sys_acl_delete_def_file_fn via dc9b622 s3:vfs/time_audit: add path names to log messages via cf7f685 s3:client use more access bits for snapshot display from ab33691 docs:build: make target "manpages" .PHONY, so manpages do get built...
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master - Log ----------------------------------------------------------------- commit 624e51a21a9dd371dae63ebbcb4c8d3a9ec15953 Author: Christian Ambach <a...@samba.org> Date: Mon Sep 10 17:24:57 2012 +0200 s3:smbd Bump the smbd vfs interface version to 30 that is what Samba 4.0.0 will ship with Autobuild-User(master): Christian Ambach <a...@samba.org> Autobuild-Date(master): Mon Sep 10 19:40:01 CEST 2012 on sn-devel-104 commit 5765d73f72e25f53bd899e17c5ebd6a3aada1686 Author: Christof Schmitt <christof.schm...@us.ibm.com> Date: Fri Aug 31 10:33:57 2012 -0700 s3:vfs/time_audit: Add back pointer for sys_acl_delete_def_file_fn Commit e25830dcd87387a237b96f0d70deb204a5bf0a54 removed the function pointer from the time_audit module, although the VFS function still exists. Add the function pointer again in time_audit as this seems to be an accidentally deletion. Signed-off-by: Christian Ambach <a...@samba.org> commit dc9b622d75d85c48441db5034136e6ff90c19811 Author: Ralph Wuerthner <ralph.wuerth...@de.ibm.com> Date: Wed Jul 25 18:39:57 2012 +0200 s3:vfs/time_audit: add path names to log messages Signed-off-by: Christian Ambach <a...@samba.org> commit cf7f68503de06c2dad5f7b65a9001bceaab542ef Author: Christian Ambach <a...@samba.org> Date: Wed Sep 5 15:07:54 2012 +0200 s3:client use more access bits for snapshot display otherwise Windows server will reject the request for shadow copy enumeration with access denied ----------------------------------------------------------------------- Summary of changes: source3/client/client.c | 3 +- source3/include/vfs.h | 3 +- source3/modules/vfs_time_audit.c | 251 ++++++++++++++++++++++++++------------ 3 files changed, 175 insertions(+), 82 deletions(-) Changeset truncated at 500 lines: diff --git a/source3/client/client.c b/source3/client/client.c index 2c949ac..1ee9856 100644 --- a/source3/client/client.c +++ b/source3/client/client.c @@ -1757,7 +1757,8 @@ static int do_allinfo(const char *name) } status = cli_ntcreate(cli, name, 0, - CREATE_ACCESS_READ, 0, + SEC_FILE_READ_DATA | SEC_FILE_READ_ATTRIBUTE | + SEC_STD_SYNCHRONIZE, 0, FILE_SHARE_READ|FILE_SHARE_WRITE |FILE_SHARE_DELETE, FILE_OPEN, 0x0, 0x0, &fnum); diff --git a/source3/include/vfs.h b/source3/include/vfs.h index 3e4eefe..17ec262 100644 --- a/source3/include/vfs.h +++ b/source3/include/vfs.h @@ -143,7 +143,8 @@ /* Leave at 29 - not yet released. Remove sys_acl functions other than set and get - abartlet */ /* Leave at 29 - not yet released. Added backup_intent bool to files_struct - JRA */ /* Leave at 29 - not yet released. Add durable handle functions - metze/obnox */ -#define SMB_VFS_INTERFACE_VERSION 29 +/* Bump to version 30 - Samba 4.0.0 will ship with interface version 30 */ +#define SMB_VFS_INTERFACE_VERSION 30 /* All intercepted VFS operations must be declared as static functions inside module source diff --git a/source3/modules/vfs_time_audit.c b/source3/modules/vfs_time_audit.c index 4a400bd..c80fc8a 100644 --- a/source3/modules/vfs_time_audit.c +++ b/source3/modules/vfs_time_audit.c @@ -35,12 +35,88 @@ static double audit_timeout; -static void smb_time_audit_log(const char *syscallname, double elapsed) +static void smb_time_audit_log_msg(const char *syscallname, double elapsed, + const char *msg) { - DEBUG(0, ("WARNING: System call \"%s\" took unexpectedly long " - "(%.2f seconds) -- Validate that file and storage " + DEBUG(0, ("WARNING: VFS call \"%s\" took unexpectedly long " + "(%.2f seconds) %s%s-- Validate that file and storage " "subsystems are operating normally\n", syscallname, - elapsed)); + elapsed, (msg != NULL) ? msg : "", + (msg != NULL) ? " " : "")); +} + +static void smb_time_audit_log(const char *syscallname, double elapsed) +{ + smb_time_audit_log_msg(syscallname, elapsed, NULL); +} + +static void smb_time_audit_log_fsp(const char *syscallname, double elapsed, + const struct files_struct *fsp) +{ + char *base_name = NULL; + char *connectpath = NULL; + char *msg = NULL; + + if (fsp == NULL) { + smb_time_audit_log(syscallname, elapsed); + return; + } + if (fsp->conn) + connectpath = fsp->conn->connectpath; + if (fsp->fsp_name) + base_name = fsp->fsp_name->base_name; + + if (connectpath != NULL && base_name != NULL) { + msg = talloc_asprintf(talloc_tos(), "filename = \"%s/%s\"", + connectpath, base_name); + } else if (connectpath != NULL && base_name == NULL) { + msg = talloc_asprintf(talloc_tos(), "connectpath = \"%s\", " + "base_name = <NULL>", + connectpath); + } else if (connectpath == NULL && base_name != NULL) { + msg = talloc_asprintf(talloc_tos(), "connectpath = <NULL>, " + "base_name = \"%s\"", + base_name); + } else { /* connectpath == NULL && base_name == NULL */ + msg = talloc_asprintf(talloc_tos(), "connectpath = <NULL>, " + "base_name = <NULL>"); + } + smb_time_audit_log_msg(syscallname, elapsed, msg); + TALLOC_FREE(msg); +} + +static void smb_time_audit_log_fname(const char *syscallname, double elapsed, + const char *fname) +{ + char cwd[PATH_MAX]; + char *msg = NULL; + + if (getcwd(cwd, sizeof(cwd)) == NULL) { + snprintf(cwd, sizeof(cwd), "<getcwd() error %d>", errno); + } + if (fname != NULL) { + msg = talloc_asprintf(talloc_tos(), + "cwd = \"%s\", filename = \"%s\"", + cwd, fname); + } else { + msg = talloc_asprintf(talloc_tos(), + "cwd = \"%s\", filename = <NULL>", + cwd); + } + smb_time_audit_log_msg(syscallname, elapsed, msg); + TALLOC_FREE(msg); +} + +static void smb_time_audit_log_smb_fname(const char *syscallname, double elapsed, + const struct smb_filename *smb_fname) +{ + if (smb_fname != NULL) { + smb_time_audit_log_fname(syscallname, elapsed, + smb_fname->base_name); + } else { + smb_time_audit_log_fname(syscallname, elapsed, + "smb_fname = <NULL>"); + } } static int smb_time_audit_connect(vfs_handle_struct *handle, @@ -59,7 +135,7 @@ static int smb_time_audit_connect(vfs_handle_struct *handle, clock_gettime_mono(&ts2); timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9; if (timediff > audit_timeout) { - smb_time_audit_log("connect", timediff); + smb_time_audit_log_msg("connect", timediff, user); } return result; } @@ -96,7 +172,7 @@ static uint64_t smb_time_audit_disk_free(vfs_handle_struct *handle, /* Don't have a reasonable notion of failure here */ if (timediff > audit_timeout) { - smb_time_audit_log("disk_free", timediff); + smb_time_audit_log_fname("disk_free", timediff, path); } return result; @@ -157,7 +233,7 @@ static int smb_time_audit_get_shadow_copy_data(struct vfs_handle_struct *handle, timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9; if (timediff > audit_timeout) { - smb_time_audit_log("get_shadow_copy_data", timediff); + smb_time_audit_log_fsp("get_shadow_copy_data", timediff, fsp); } return result; @@ -177,7 +253,7 @@ static int smb_time_audit_statvfs(struct vfs_handle_struct *handle, timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9; if (timediff > audit_timeout) { - smb_time_audit_log("statvfs", timediff); + smb_time_audit_log_fname("statvfs", timediff, path); } return result; @@ -216,7 +292,7 @@ static DIR *smb_time_audit_opendir(vfs_handle_struct *handle, timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9; if (timediff > audit_timeout) { - smb_time_audit_log("opendir", timediff); + smb_time_audit_log_fname("opendir", timediff, fname); } return result; @@ -236,7 +312,7 @@ static DIR *smb_time_audit_fdopendir(vfs_handle_struct *handle, timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9; if (timediff > audit_timeout) { - smb_time_audit_log("fdopendir", timediff); + smb_time_audit_log_fsp("fdopendir", timediff, fsp); } return result; @@ -328,7 +404,7 @@ static int smb_time_audit_mkdir(vfs_handle_struct *handle, timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9; if (timediff > audit_timeout) { - smb_time_audit_log("mkdir", timediff); + smb_time_audit_log_fname("mkdir", timediff, path); } return result; @@ -347,7 +423,7 @@ static int smb_time_audit_rmdir(vfs_handle_struct *handle, timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9; if (timediff > audit_timeout) { - smb_time_audit_log("rmdir", timediff); + smb_time_audit_log_fname("rmdir", timediff, path); } return result; @@ -403,7 +479,7 @@ static int smb_time_audit_open(vfs_handle_struct *handle, timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9; if (timediff > audit_timeout) { - smb_time_audit_log("open", timediff); + smb_time_audit_log_fsp("open", timediff, fsp); } return result; @@ -452,7 +528,12 @@ static NTSTATUS smb_time_audit_create_file(vfs_handle_struct *handle, timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9; if (timediff > audit_timeout) { - smb_time_audit_log("create_file", timediff); + /* + * can't use result_fsp this time, may have + * invalid content causing smbd crash + */ + smb_time_audit_log_smb_fname("create_file", timediff, + fname); } return result; @@ -470,7 +551,7 @@ static int smb_time_audit_close(vfs_handle_struct *handle, files_struct *fsp) timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9; if (timediff > audit_timeout) { - smb_time_audit_log("close", timediff); + smb_time_audit_log_fsp("close", timediff, fsp); } return result; @@ -489,7 +570,7 @@ static ssize_t smb_time_audit_read(vfs_handle_struct *handle, timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9; if (timediff > audit_timeout) { - smb_time_audit_log("read", timediff); + smb_time_audit_log_fsp("read", timediff, fsp); } return result; @@ -509,13 +590,14 @@ static ssize_t smb_time_audit_pread(vfs_handle_struct *handle, timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9; if (timediff > audit_timeout) { - smb_time_audit_log("pread", timediff); + smb_time_audit_log_fsp("pread", timediff, fsp); } return result; } struct smb_time_audit_pread_state { + struct files_struct *fsp; struct timespec ts1; ssize_t ret; int err; @@ -537,6 +619,7 @@ static struct tevent_req *smb_time_audit_pread_send( return NULL; } clock_gettime_mono(&state->ts1); + state->fsp = fsp; subreq = SMB_VFS_NEXT_PREAD_SEND(state, ev, handle, fsp, data, n, offset); @@ -570,7 +653,7 @@ static ssize_t smb_time_audit_pread_recv(struct tevent_req *req, int *err) timediff = nsec_time_diff(&ts2,&state->ts1)*1.0e-9; if (timediff > audit_timeout) { - smb_time_audit_log("pread", timediff); + smb_time_audit_log_fsp("pread", timediff, state->fsp); } if (tevent_req_is_unix_error(req, err)) { @@ -594,7 +677,7 @@ static ssize_t smb_time_audit_write(vfs_handle_struct *handle, timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9; if (timediff > audit_timeout) { - smb_time_audit_log("write", timediff); + smb_time_audit_log_fsp("write", timediff, fsp); } return result; @@ -615,13 +698,14 @@ static ssize_t smb_time_audit_pwrite(vfs_handle_struct *handle, timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9; if (timediff > audit_timeout) { - smb_time_audit_log("pwrite", timediff); + smb_time_audit_log_fsp("pwrite", timediff, fsp); } return result; } struct smb_time_audit_pwrite_state { + struct files_struct *fsp; struct timespec ts1; ssize_t ret; int err; @@ -643,6 +727,7 @@ static struct tevent_req *smb_time_audit_pwrite_send( return NULL; } clock_gettime_mono(&state->ts1); + state->fsp = fsp; subreq = SMB_VFS_NEXT_PWRITE_SEND(state, ev, handle, fsp, data, n, offset); @@ -676,7 +761,7 @@ static ssize_t smb_time_audit_pwrite_recv(struct tevent_req *req, int *err) timediff = nsec_time_diff(&ts2,&state->ts1)*1.0e-9; if (timediff > audit_timeout) { - smb_time_audit_log("pwrite", timediff); + smb_time_audit_log_fsp("pwrite", timediff, state->fsp); } if (tevent_req_is_unix_error(req, err)) { @@ -700,7 +785,7 @@ static off_t smb_time_audit_lseek(vfs_handle_struct *handle, timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9; if (timediff > audit_timeout) { - smb_time_audit_log("lseek", timediff); + smb_time_audit_log_fsp("lseek", timediff, fsp); } return result; @@ -721,7 +806,7 @@ static ssize_t smb_time_audit_sendfile(vfs_handle_struct *handle, int tofd, timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9; if (timediff > audit_timeout) { - smb_time_audit_log("sendfile", timediff); + smb_time_audit_log_fsp("sendfile", timediff, fromfsp); } return result; @@ -742,7 +827,7 @@ static ssize_t smb_time_audit_recvfile(vfs_handle_struct *handle, int fromfd, timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9; if (timediff > audit_timeout) { - smb_time_audit_log("recvfile", timediff); + smb_time_audit_log_fsp("recvfile", timediff, tofsp); } return result; @@ -762,7 +847,7 @@ static int smb_time_audit_rename(vfs_handle_struct *handle, timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9; if (timediff > audit_timeout) { - smb_time_audit_log("rename", timediff); + smb_time_audit_log_smb_fname("rename", timediff, newname); } return result; @@ -780,13 +865,14 @@ static int smb_time_audit_fsync(vfs_handle_struct *handle, files_struct *fsp) timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9; if (timediff > audit_timeout) { - smb_time_audit_log("fsync", timediff); + smb_time_audit_log_fsp("fsync", timediff, fsp); } return result; } struct smb_time_audit_fsync_state { + struct files_struct *fsp; struct timespec ts1; int ret; int err; @@ -807,6 +893,7 @@ static struct tevent_req *smb_time_audit_fsync_send( return NULL; } clock_gettime_mono(&state->ts1); + state->fsp = fsp; subreq = SMB_VFS_NEXT_FSYNC_SEND(state, ev, handle, fsp); if (tevent_req_nomem(subreq, req)) { @@ -839,7 +926,7 @@ static int smb_time_audit_fsync_recv(struct tevent_req *req, int *err) timediff = nsec_time_diff(&ts2,&state->ts1)*1.0e-9; if (timediff > audit_timeout) { - smb_time_audit_log("fsync", timediff); + smb_time_audit_log_fsp("fsync", timediff, state->fsp); } if (tevent_req_is_unix_error(req, err)) { @@ -862,7 +949,7 @@ static int smb_time_audit_stat(vfs_handle_struct *handle, timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9; if (timediff > audit_timeout) { - smb_time_audit_log("stat", timediff); + smb_time_audit_log_smb_fname("stat", timediff, fname); } return result; @@ -881,7 +968,7 @@ static int smb_time_audit_fstat(vfs_handle_struct *handle, files_struct *fsp, timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9; if (timediff > audit_timeout) { - smb_time_audit_log("fstat", timediff); + smb_time_audit_log_fsp("fstat", timediff, fsp); } return result; @@ -900,7 +987,7 @@ static int smb_time_audit_lstat(vfs_handle_struct *handle, timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9; if (timediff > audit_timeout) { - smb_time_audit_log("lstat", timediff); + smb_time_audit_log_smb_fname("lstat", timediff, path); } return result; @@ -920,7 +1007,7 @@ static uint64_t smb_time_audit_get_alloc_size(vfs_handle_struct *handle, timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9; if (timediff > audit_timeout) { - smb_time_audit_log("get_alloc_size", timediff); + smb_time_audit_log_fsp("get_alloc_size", timediff, fsp); } return result; @@ -939,7 +1026,7 @@ static int smb_time_audit_unlink(vfs_handle_struct *handle, timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9; if (timediff > audit_timeout) { - smb_time_audit_log("unlink", timediff); + smb_time_audit_log_smb_fname("unlink", timediff, path); } return result; @@ -958,7 +1045,7 @@ static int smb_time_audit_chmod(vfs_handle_struct *handle, timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9; if (timediff > audit_timeout) { - smb_time_audit_log("chmod", timediff); + smb_time_audit_log_fname("chmod", timediff, path); } return result; @@ -977,7 +1064,7 @@ static int smb_time_audit_fchmod(vfs_handle_struct *handle, files_struct *fsp, timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9; if (timediff > audit_timeout) { - smb_time_audit_log("fchmod", timediff); + smb_time_audit_log_fsp("fchmod", timediff, fsp); } return result; @@ -996,7 +1083,7 @@ static int smb_time_audit_chown(vfs_handle_struct *handle, timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9; if (timediff > audit_timeout) { - smb_time_audit_log("chown", timediff); + smb_time_audit_log_fname("chown", timediff, path); } return result; @@ -1015,7 +1102,7 @@ static int smb_time_audit_fchown(vfs_handle_struct *handle, files_struct *fsp, timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9; if (timediff > audit_timeout) { - smb_time_audit_log("fchown", timediff); + smb_time_audit_log_fsp("fchown", timediff, fsp); } return result; @@ -1034,7 +1121,7 @@ static int smb_time_audit_lchown(vfs_handle_struct *handle, timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9; if (timediff > audit_timeout) { - smb_time_audit_log("lchown", timediff); + smb_time_audit_log_fname("lchown", timediff, path); } return result; @@ -1052,7 +1139,7 @@ static int smb_time_audit_chdir(vfs_handle_struct *handle, const char *path) timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9; if (timediff > audit_timeout) { - smb_time_audit_log("chdir", timediff); + smb_time_audit_log_fname("chdir", timediff, path); } return result; @@ -1090,7 +1177,7 @@ static int smb_time_audit_ntimes(vfs_handle_struct *handle, timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9; if (timediff > audit_timeout) { - smb_time_audit_log("ntimes", timediff); + smb_time_audit_log_smb_fname("ntimes", timediff, path); } return result; @@ -1110,7 +1197,7 @@ static int smb_time_audit_ftruncate(vfs_handle_struct *handle, timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9; if (timediff > audit_timeout) { - smb_time_audit_log("ftruncate", timediff); + smb_time_audit_log_fsp("ftruncate", timediff, fsp); } return result; @@ -1132,7 +1219,7 @@ static int smb_time_audit_fallocate(vfs_handle_struct *handle, -- Samba Shared Repository