Login
[x]
Log in using an account from:
Fedora Account System
Red Hat Associate
Red Hat Customer
Or login using a Red Hat Bugzilla account
Forgot Password
Login:
Hide Forgot
Create an Account
Red Hat Bugzilla – Attachment 152537 Details for
Bug 236356
realtime interface for rsyslog
[?]
New
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
|
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh83 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
This site requires JavaScript to be enabled to function correctly, please enable it.
[patch]
solution based on audit-dispatcher from audit package
sysklogd-1.4.2rh-dispatcher.patch (text/plain), 11.63 KB, created by
Peter Vrabec
on 2007-04-13 13:04:00 UTC
(
hide
)
Description:
solution based on audit-dispatcher from audit package
Filename:
MIME Type:
Creator:
Peter Vrabec
Created:
2007-04-13 13:04:00 UTC
Size:
11.63 KB
patch
obsolete
>--- sysklogd-1.4.2rh/sysklogd.8.dispatcher 2007-04-13 12:04:54.000000000 +0200 >+++ sysklogd-1.4.2rh/sysklogd.8 2007-04-13 14:31:41.000000000 +0200 >@@ -30,6 +30,9 @@ > .RB [ " \-s " > .I domainlist > ] >+.RB [ " \-D " >+.I dispatcher >+] > .RB [ " \-v " ] > .RB [ " \-x " ] > .LP >@@ -178,6 +181,14 @@ > once, the names of the facility and priority are logged with each > locally-written message. > .TP >+.BI "\-D " "dispatcher" >+The syslogd daemon will start up a dispatcher program and open >+standard input to the socketpair used to pass events. So, the >+dispatcher only needs to read stdin. Because IPC communication >+buffers have a limited size, it must read the events as fast >+as possible. The syslogd send SIGTERM to indicate that the >+dispatcher should exit. >+.TP > .B "\-v" > Print version and exit. > .TP >@@ -444,6 +455,19 @@ > kern.=debug |/usr/adm/debug > .fi > .LP >+.SH OUTPUT TO DISPATCHER >+If you run syslogd with the >+.B \-D >+option, you can route your messages >+to dispatcher process. To specify messages, which go to dispatcher, >+you use "!dispatcher" directive. >+.IP >+Following configuration routes info messages to a dispatcher process: >+.IP >+.nf >+ *.info !dispatcher >+.fi >+.LP > .SH INSTALLATION CONCERNS > There is probably one important consideration when installing this > version of syslogd. This version of syslogd is dependent on proper >--- /dev/null 2007-04-11 16:01:52.461576228 +0200 >+++ sysklogd-1.4.2rh/sysklogd-dispatch.h 2007-04-13 11:47:51.000000000 +0200 >@@ -0,0 +1,64 @@ >+/* sysklogd-dispatch.h -- >+ * Copyright 2007 Red Hat Inc., Durham, North Carolina. >+ * All Rights Reserved. >+ * >+ * This program is free software; you can redistribute it and/or modify >+ * it under the terms of the GNU General Public License as published by >+ * the Free Software Foundation; either version 2 of the License, or >+ * (at your option) any later version. >+ * >+ * This program is distributed in the hope that it will be useful, >+ * but WITHOUT ANY WARRANTY; without even the implied warranty of >+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >+ * GNU General Public License for more details. >+ * >+ * You should have received a copy of the GNU General Public License >+ * along with this program; if not, write to the Free Software >+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA >+ * >+ * Authors: >+ * Steve Grubb <sgrubb@redhat.com> >+ * Peter Vrabec <pvrabec@redhat.com> >+ * >+ */ >+ >+#ifndef SYSKLOGD_DISPATCH_H >+#define SYSKLOGD_DISPATCH_H >+ >+ >+typedef enum { QOS_NON_BLOCKING, QOS_BLOCKING } qos_t; >+ >+struct daemon_conf >+{ >+ char * dispatcher; >+ qos_t qos; /* use blocking/non-blocking sockets */ >+}; >+ >+/* Sysklogd protocol #1 contains only one type of reply message >+ and that is standart message. */ >+#define SYSKLOGD_PROTOCOL_VER 1 >+#define MAXLINE 1024 /* Should be same MAXLINE as in syslogd.c */ >+typedef enum { STD_MESS } mess_t; >+ >+struct sysklogd_reply { >+ mess_t type; >+ int len; >+ union { >+ const char *message; >+ }; >+}; >+ >+struct sysklogd_dispatcher_header { >+ int ver; /* The version of this protocol */ >+ int hlen; /* Header length */ >+ mess_t type; /* Message type */ >+ int size; /* Size of data following the header */ >+}; >+ >+ >+int init_dispatcher(const struct daemon_conf *config); >+void shutdown_dispatcher(void); >+void reconfigure_dispatcher(void); >+void dispatch_event(const struct sysklogd_reply *rep); >+ >+#endif >--- sysklogd-1.4.2rh/Makefile.dispatcher 2007-02-26 10:46:08.000000000 +0100 >+++ sysklogd-1.4.2rh/Makefile 2007-04-13 11:47:51.000000000 +0200 >@@ -59,8 +59,8 @@ > > install: install_man install_exec > >-syslogd: syslogd.o pidfile.o >- ${CC} ${LDFLAGS} -o syslogd syslogd.o pidfile.o ${LIBS} >+syslogd: syslogd.o pidfile.o sysklogd-dispatch.o >+ ${CC} ${LDFLAGS} -o syslogd syslogd.o pidfile.o sysklogd-dispatch.o ${LIBS} > > klogd: klogd.o syslog.o pidfile.o ksym.o ksym_mod.o > ${CC} ${LDFLAGS} -o klogd klogd.o syslog.o pidfile.o ksym.o \ >--- /dev/null 2007-04-11 16:01:52.461576228 +0200 >+++ sysklogd-1.4.2rh/sysklogd-dispatch.c 2007-04-13 11:47:51.000000000 +0200 >@@ -0,0 +1,185 @@ >+/* sysklogd-dispatch.c -- >+ * Copyright 2007 Red Hat Inc., Durham, North Carolina. >+ * All Rights Reserved. >+ * >+ * This program is free software; you can redistribute it and/or modify >+ * it under the terms of the GNU General Public License as published by >+ * the Free Software Foundation; either version 2 of the License, or >+ * (at your option) any later version. >+ * >+ * This program is distributed in the hope that it will be useful, >+ * but WITHOUT ANY WARRANTY; without even the implied warranty of >+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >+ * GNU General Public License for more details. >+ * >+ * You should have received a copy of the GNU General Public License >+ * along with this program; if not, write to the Free Software >+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA >+ * >+ * Authors: >+ * Steve Grubb <sgrubb@redhat.com> >+ * Junji Kanemaru <junji.kanemaru@linuon.com> >+ * Peter Vrabec <pvrabec@redhat.com> >+ */ >+ >+#include <unistd.h> >+#include <sys/uio.h> >+#include <fcntl.h> >+#include <signal.h> >+#include <errno.h> >+#include <string.h> >+#include <stdlib.h> >+#include <stdio.h> >+#include <sys/types.h> >+#include <sys/socket.h> >+ >+#include "sysklogd-dispatch.h" >+ >+/* This is the communications channel between sysklogd & the dispatcher */ >+static int disp_pipe[2] = {-1, -1}; >+static pid_t pid = 0; >+static int n_errs = 0; >+#define REPORT_LIMIT 10 >+ >+/* set_flags: to set flags to file desc */ >+static int set_flags(int fn, int flags) >+{ >+ int fl; >+ >+ if ((fl = fcntl(fn, F_GETFL, 0)) < 0) { >+ fprintf(stderr, "fcntl failed. Cannot get flags (%s)\n", >+ strerror(errno)); >+ return fl; >+ } >+ >+ fl |= flags; >+ >+ return fcntl(fn, F_SETFL, fl); >+} >+ >+/* This function returns 1 on error & 0 on success */ >+int init_dispatcher(const struct daemon_conf *config) >+{ >+ if (config->dispatcher == NULL) >+ return 0; >+ >+ if (socketpair(AF_UNIX, SOCK_STREAM, 0, disp_pipe)) { >+ fprintf(stderr, "Failed creating disp_pipe\n"); >+ return 1; >+ } >+ >+ /* Make both disp_pipe non-blocking */ >+ if (config->qos == QOS_NON_BLOCKING) { >+ if (set_flags(disp_pipe[0], O_NONBLOCK) < 0 || >+ set_flags(disp_pipe[1], O_NONBLOCK) < 0) { >+ fprintf(stderr, "Failed to set O_NONBLOCK flag\n"); >+ return 1; >+ } >+ } >+ >+ // do the fork >+ pid = fork(); >+ switch(pid) { >+ case 0: // child >+ dup2(disp_pipe[0], 0); >+ close(disp_pipe[0]); >+ close(disp_pipe[1]); >+ setsid(); >+ execl(config->dispatcher, config->dispatcher, NULL); >+ fprintf(stderr, "exec() failed\n"); >+ exit(1); >+ break; >+ case -1: // error >+ return 1; >+ break; >+ default: // parent >+ close(disp_pipe[0]); >+ disp_pipe[0] = -1; >+ /* Avoid leaking this */ >+ if (fcntl(disp_pipe[1], F_SETFD, FD_CLOEXEC) < 0) { >+ fprintf(stderr, >+ "Failed to set FD_CLOEXEC flag\n"); >+ return 1; >+ } >+ fprintf(stderr, "Started dispatcher: %s pid: %u\n", >+ config->dispatcher, pid); >+ break; >+ } >+ >+ return 0; >+} >+ >+void shutdown_dispatcher(void) >+{ >+ // kill child >+ if (pid) >+ kill(pid, SIGTERM); >+ // wait for term >+ // if not in time, send sigkill >+ pid = 0; >+ >+ // cleanup comm pipe >+ if (disp_pipe[0] >= 0) { >+ close(disp_pipe[0]); >+ disp_pipe[0] = -1; >+ } >+ if (disp_pipe[1] >= 0) { >+ close(disp_pipe[1]); >+ disp_pipe[1] = -1; >+ } >+} >+ >+void reconfigure_dispatcher(void) >+{ >+ // signal child >+ if (pid) >+ kill(pid, SIGHUP); >+} >+ >+void dispatch_event(const struct sysklogd_reply *rep) >+{ >+ int rc, count = 0; >+ struct iovec vec[2]; >+ struct sysklogd_dispatcher_header hdr; >+ >+ if (disp_pipe[1] == -1) >+ return; >+ >+ hdr.ver = SYSKLOGD_PROTOCOL_VER; /* Hard-coded to current protocol */ >+ hdr.hlen = sizeof(struct sysklogd_dispatcher_header); >+ hdr.type = rep->type; >+ hdr.size = rep->len; >+ >+ vec[0].iov_base = (void*)&hdr; >+ vec[0].iov_len = sizeof(hdr); >+ vec[1].iov_base = (void*)rep->message; >+ vec[1].iov_len = rep->len; >+ >+ do { >+ rc = writev(disp_pipe[1], vec, 2); >+ } while (rc < 0 && errno == EAGAIN && count++ < 10); >+ >+ // close pipe if no child or peer has been lost >+ if (rc <= 0) { >+ if (errno == EPIPE) { >+ shutdown_dispatcher(); >+ n_errs = 0; >+ } else { >+ if (n_errs <= REPORT_LIMIT) { >+ fprintf(stderr, >+ "dispatch err (%s) event lost\n", >+ errno == EAGAIN ? "pipe full" : >+ strerror(errno)); >+ n_errs++; >+ } >+ if (n_errs == REPORT_LIMIT) { >+ fprintf(stderr, >+ "dispatch error reporting limit\n" >+ " reached - ending report" >+ " notification."); >+ n_errs++; >+ } >+ } >+ } else >+ n_errs = 0; >+} >--- sysklogd-1.4.2rh/syslogd.c.dispatcher 2007-04-13 11:47:51.000000000 +0200 >+++ sysklogd-1.4.2rh/syslogd.c 2007-04-13 12:02:50.000000000 +0200 >@@ -507,6 +507,8 @@ > #endif > #include "version.h" > >+#include "sysklogd-dispatch.h" >+ > #if defined(__linux__) > #include <paths.h> > #endif >@@ -572,6 +574,8 @@ > static int alarm_signal = 0; > static int exit_on_signal = 0; > >+struct daemon_conf disp = { NULL, QOS_NON_BLOCKING }; >+ > #define MAXFUNIX 20 > > int nfunix = 1; >@@ -674,10 +678,11 @@ > #define F_FORW_SUSP 7 /* suspended host forwarding */ > #define F_FORW_UNKN 8 /* unknown host forwarding */ > #define F_PIPE 9 /* named pipe */ >+#define F_DISP 10 /* named pipe */ > char *TypeNames[] = { > "UNUSED", "FILE", "TTY", "CONSOLE", > "FORW", "USERS", "WALL", "FORW(SUSPENDED)", >- "FORW(UNKNOWN)", "PIPE" >+ "FORW(UNKNOWN)", "PIPE", "DISP" > }; > > struct filed *Files = (struct filed *) 0; >@@ -859,7 +864,7 @@ > funix[i] = -1; > } > >- while ((ch = getopt(argc, argv, "46Aa:dhf:l:m:np:rSs:vx")) != EOF) >+ while ((ch = getopt(argc, argv, "46Aa:dhf:D:l:m:np:rSs:vx")) != EOF) > switch((char)ch) { > case '4': > family = PF_INET; >@@ -881,6 +886,9 @@ > case 'd': /* debug */ > Debug = 1; > break; >+ case 'D': /* dispatcher */ >+ disp.dispatcher = optarg; >+ break; > case 'f': /* configuration file */ > ConfFile = optarg; > break; >@@ -1067,6 +1075,15 @@ > parts[i] = (char *) 0; > > dprintf("Starting.\n"); >+ >+ if( disp.dispatcher != NULL ) { >+ dprintf("Dispatcher initialisation.\n"); >+ if( init_dispatcher(&disp) == 1) { >+ dprintf("Dispatcher initialisation FAIL.\n"); >+ die(0); >+ } >+ } >+ > init(); > #ifndef TESTING > if ( Debug ) >@@ -1249,7 +1266,7 @@ > int usage() > { > fprintf(stderr, "usage: syslogd [-46AdiIrvxh] [-l hostlist] [-m markinterval] [-n] [-p path]\n" \ >- " [-s domainlist] [-f conffile]\n"); >+ " [-s domainlist] [-D dispatcher] [-f conffile]\n"); > exit(1); > } > >@@ -1767,6 +1784,7 @@ > time_t fwd_suspend; > struct addrinfo *saddr; > #endif >+ struct sysklogd_reply reply; > > dprintf("Called fprintlog, "); > >@@ -2012,7 +2030,19 @@ > } else if (f->f_flags & SYNC_FILE) > (void) fsync(f->f_file); > break; >- >+ case F_DISP: >+ f->f_time = now; >+ dprintf("\n"); >+ v->iov_base = ""; >+ v->iov_len = 0; >+ (void) snprintf(line, sizeof(line), "%s%s%s%s%s%s%s\n", (char *) iov[0].iov_base, >+ (char *) iov[1].iov_base, (char *) iov[2].iov_base, (char *) iov[3].iov_base, >+ (char *) iov[4].iov_base, (char *) iov[5].iov_base, (char *) iov[6].iov_base); >+ reply.type = STD_MESS; >+ reply.message = line; >+ reply.len = strlen(reply.message); >+ dispatch_event(&reply); >+ break; > case F_USERS: > case F_WALL: > f->f_time = now; >@@ -2868,7 +2898,15 @@ > if (strcmp(p, ctty) == 0) > f->f_type = F_CONSOLE; > break; >- >+ case '!': >+ if( !strncmp(++p, "dispatcher", 10) ) { >+ dprintf ("sending to: %s\n", disp.dispatcher); >+ f->f_type = F_DISP; >+ } >+ else { >+ dprintf ("\"!\" is not followed by \"dispatcher\"\n"); >+ } >+ break; > case '*': > dprintf ("write-all\n"); > f->f_type = F_WALL;
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 236356
: 152537 |
152539