static void audit_disconnect(vfs_handle_struct *handle) { if (lp_syslog() > 0) { syslog(audit_syslog_priority(handle), "disconnected\n"); } DEBUG(10, ("Disconnected from VFS module extd_audit\n")); SMB_VFS_NEXT_DISCONNECT(handle); return; }
static int audit_fchmod_acl(vfs_handle_struct *handle, files_struct *fsp, mode_t mode) { int result; result = SMB_VFS_NEXT_FCHMOD_ACL(handle, fsp, mode); if (lp_syslog() > 0) { syslog(audit_syslog_priority(handle), "fchmod_acl %s mode 0x%x %s%s\n", fsp->fsp_name->base_name, mode, (result < 0) ? "failed: " : "", (result < 0) ? strerror(errno) : ""); } DEBUG(1, ("vfs_extd_audit: fchmod_acl %s mode 0x%x %s %s", fsp_str_dbg(fsp), (unsigned int)mode, (result < 0) ? "failed: " : "", (result < 0) ? strerror(errno) : "")); return result; }
static int audit_close(vfs_handle_struct *handle, files_struct *fsp) { int result; result = SMB_VFS_NEXT_CLOSE(handle, fsp); if (lp_syslog() > 0) { syslog(audit_syslog_priority(handle), "close fd %d %s%s\n", fsp->fh->fd, (result < 0) ? "failed: " : "", (result < 0) ? strerror(errno) : ""); } DEBUG(2, ("vfs_extd_audit: close fd %d %s %s\n", fsp->fh->fd, (result < 0) ? "failed: " : "", (result < 0) ? strerror(errno) : "")); return result; }
static int audit_chmod_acl(vfs_handle_struct *handle, const char *path, mode_t mode) { int result; result = SMB_VFS_NEXT_CHMOD_ACL(handle, path, mode); if (lp_syslog() > 0) { syslog(audit_syslog_priority(handle), "chmod_acl %s mode 0x%x %s%s\n", path, mode, (result < 0) ? "failed: " : "", (result < 0) ? strerror(errno) : ""); } DEBUG(1, ("vfs_extd_audit: chmod_acl %s mode 0x%x %s %s\n", path, (unsigned int)mode, (result < 0) ? "failed: " : "", (result < 0) ? strerror(errno) : "")); return result; }
static DIR *audit_opendir(vfs_handle_struct *handle, const char *fname, const char *mask, uint32_t attr) { DIR *result; result = SMB_VFS_NEXT_OPENDIR(handle, fname, mask, attr); if (lp_syslog() > 0) { syslog(audit_syslog_priority(handle), "opendir %s %s%s\n", fname, (result == NULL) ? "failed: " : "", (result == NULL) ? strerror(errno) : ""); } DEBUG(1, ("vfs_extd_audit: opendir %s %s %s\n", fname, (result == NULL) ? "failed: " : "", (result == NULL) ? strerror(errno) : "")); return result; }
static int audit_rmdir(vfs_handle_struct *handle, const char *path) { int result; result = SMB_VFS_NEXT_RMDIR(handle, path); if (lp_syslog() > 0) { syslog(audit_syslog_priority(handle), "rmdir %s %s%s\n", path, (result < 0) ? "failed: " : "", (result < 0) ? strerror(errno) : ""); } DEBUG(0, ("vfs_extd_audit: rmdir %s %s %s\n", path, (result < 0) ? "failed: " : "", (result < 0) ? strerror(errno) : "")); return result; }
static int audit_connect(vfs_handle_struct *handle, const char *svc, const char *user) { int result = SMB_VFS_NEXT_CONNECT(handle, svc, user); if (result < 0) { return result; } openlog("smbd_audit", LOG_PID, audit_syslog_facility(handle)); if (lp_syslog() > 0) { syslog(audit_syslog_priority(handle), "connect to service %s by user %s\n", svc, user); } DEBUG(10, ("Connected to service %s as user %s\n", svc, user)); return 0; }
static int audit_unlink(vfs_handle_struct *handle, const struct smb_filename *smb_fname) { int result; result = SMB_VFS_NEXT_UNLINK(handle, smb_fname); if (lp_syslog() > 0) { syslog(audit_syslog_priority(handle), "unlink %s %s%s\n", smb_fname->base_name, (result < 0) ? "failed: " : "", (result < 0) ? strerror(errno) : ""); } DEBUG(0, ("vfs_extd_audit: unlink %s %s %s\n", smb_fname_str_dbg(smb_fname), (result < 0) ? "failed: " : "", (result < 0) ? strerror(errno) : "")); return result; }
static int audit_chmod(vfs_handle_struct *handle, const struct smb_filename *smb_fname, mode_t mode) { int result; result = SMB_VFS_NEXT_CHMOD(handle, smb_fname, mode); if (lp_syslog() > 0) { syslog(audit_syslog_priority(handle), "chmod %s mode 0x%x %s%s\n", smb_fname->base_name, mode, (result < 0) ? "failed: " : "", (result < 0) ? strerror(errno) : ""); } DEBUG(1, ("vfs_extd_audit: chmod %s mode 0x%x %s %s\n", smb_fname->base_name, (unsigned int)mode, (result < 0) ? "failed: " : "", (result < 0) ? strerror(errno) : "")); return result; }
static int audit_mkdir(vfs_handle_struct *handle, const struct smb_filename *smb_fname, mode_t mode) { int result; result = SMB_VFS_NEXT_MKDIR(handle, smb_fname, mode); if (lp_syslog() > 0) { syslog(audit_syslog_priority(handle), "mkdir %s %s%s\n", smb_fname->base_name, (result < 0) ? "failed: " : "", (result < 0) ? strerror(errno) : ""); } DEBUG(0, ("vfs_extd_audit: mkdir %s %s %s\n", smb_fname->base_name, (result < 0) ? "failed: " : "", (result < 0) ? strerror(errno) : "")); return result; }
static int audit_open(vfs_handle_struct *handle, struct smb_filename *smb_fname, files_struct *fsp, int flags, mode_t mode) { int result; result = SMB_VFS_NEXT_OPEN(handle, smb_fname, fsp, flags, mode); if (lp_syslog() > 0) { syslog(audit_syslog_priority(handle), "open %s (fd %d) %s%s%s\n", smb_fname->base_name, result, ((flags & O_WRONLY) || (flags & O_RDWR)) ? "for writing " : "", (result < 0) ? "failed: " : "", (result < 0) ? strerror(errno) : ""); } DEBUG(2, ("vfs_extd_audit: open %s %s %s\n", smb_fname_str_dbg(smb_fname), (result < 0) ? "failed: " : "", (result < 0) ? strerror(errno) : "")); return result; }
static int audit_rename(vfs_handle_struct *handle, const struct smb_filename *smb_fname_src, const struct smb_filename *smb_fname_dst) { int result; result = SMB_VFS_NEXT_RENAME(handle, smb_fname_src, smb_fname_dst); if (lp_syslog() > 0) { syslog(audit_syslog_priority(handle), "rename %s -> %s %s%s\n", smb_fname_src->base_name, smb_fname_dst->base_name, (result < 0) ? "failed: " : "", (result < 0) ? strerror(errno) : ""); } DEBUG(1, ("vfs_extd_audit: rename old: %s newname: %s %s %s\n", smb_fname_str_dbg(smb_fname_src), smb_fname_str_dbg(smb_fname_dst), (result < 0) ? "failed: " : "", (result < 0) ? strerror(errno) : "")); return result; }
/* ************************************************************************** ** * Write an debug message on the debugfile. * This is called by dbghdr() and format_debug_text(). * ************************************************************************** ** */ int Debug1( const char *format_str, ... ) { va_list ap; int old_errno = errno; if( stdout_logging ) { va_start( ap, format_str ); if(dbf) (void)vfprintf( dbf, format_str, ap ); va_end( ap ); errno = old_errno; return( 0 ); } #ifdef WITH_SYSLOG if( !lp_syslog_only() ) #endif { if( !dbf ) { mode_t oldumask = umask( 022 ); if( append_log ) dbf = sys_fopen( debugf, "a" ); else dbf = sys_fopen( debugf, "w" ); (void)umask( oldumask ); if( dbf ) { setbuf( dbf, NULL ); } else { errno = old_errno; return(0); } } } #ifdef WITH_SYSLOG if( syslog_level < lp_syslog() ) { /* map debug levels to syslog() priorities * note that not all DEBUG(0, ...) calls are * necessarily errors */ static int priority_map[] = { LOG_ERR, /* 0 */ LOG_WARNING, /* 1 */ LOG_NOTICE, /* 2 */ LOG_INFO, /* 3 */ }; int priority; pstring msgbuf; if( syslog_level >= ( sizeof(priority_map) / sizeof(priority_map[0]) ) || syslog_level < 0) priority = LOG_DEBUG; else priority = priority_map[syslog_level]; va_start( ap, format_str ); vslprintf( msgbuf, sizeof(msgbuf)-1, format_str, ap ); va_end( ap ); msgbuf[255] = '\0'; syslog( priority, "%s", msgbuf ); } #endif check_log_size(); #ifdef WITH_SYSLOG if( !lp_syslog_only() ) #endif { va_start( ap, format_str ); if(dbf) (void)vfprintf( dbf, format_str, ap ); va_end( ap ); if(dbf) (void)fflush( dbf ); } errno = old_errno; return( 0 ); } /* Debug1 */