rpms/sysklogd/F-7 sysklogd-1.4.2rh-dispatcher.patch, 1.2, 1.3 sysklogd.spec, 1.57, 1.58

Peter Vrabec (pvrabec) fedora-extras-commits at redhat.com
Thu Jun 7 09:07:08 UTC 2007


Author: pvrabec

Update of /cvs/extras/rpms/sysklogd/F-7
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv8938

Modified Files:
	sysklogd-1.4.2rh-dispatcher.patch sysklogd.spec 
Log Message:
provide dispatcher sample program


sysklogd-1.4.2rh-dispatcher.patch:

Index: sysklogd-1.4.2rh-dispatcher.patch
===================================================================
RCS file: /cvs/extras/rpms/sysklogd/F-7/sysklogd-1.4.2rh-dispatcher.patch,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- sysklogd-1.4.2rh-dispatcher.patch	7 Jun 2007 07:23:12 -0000	1.2
+++ sysklogd-1.4.2rh-dispatcher.patch	7 Jun 2007 09:06:32 -0000	1.3
@@ -1,5 +1,5 @@
---- sysklogd-1.4.2rh/sysklogd.8.dispatcher	2007-05-14 16:53:48.000000000 +0200
-+++ sysklogd-1.4.2rh/sysklogd.8	2007-05-14 16:53:48.000000000 +0200
+--- sysklogd-1.4.2rh/sysklogd.8.dispatcher	2007-06-07 10:40:15.000000000 +0200
++++ sysklogd-1.4.2rh/sysklogd.8	2007-06-07 10:40:15.000000000 +0200
 @@ -30,6 +30,9 @@
  .RB [ " \-s "
  .I domainlist
@@ -45,8 +45,8 @@
  .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-05-10 11:02:57.435034000 +0200
-+++ sysklogd-1.4.2rh/sysklogd-dispatch.h	2007-05-14 16:53:48.000000000 +0200
+--- /dev/null	2007-06-04 11:07:53.480224378 +0200
++++ sysklogd-1.4.2rh/sysklogd-dispatch.h	2007-06-07 10:40:15.000000000 +0200
 @@ -0,0 +1,64 @@
 +/* sysklogd-dispatch.h -- 
 + * Copyright 2007 Red Hat Inc., Durham, North Carolina.
@@ -113,7 +113,7 @@
 +
 +#endif
 --- sysklogd-1.4.2rh/Makefile.dispatcher	2007-02-26 10:46:08.000000000 +0100
-+++ sysklogd-1.4.2rh/Makefile	2007-05-14 16:53:48.000000000 +0200
++++ sysklogd-1.4.2rh/Makefile	2007-06-07 10:40:15.000000000 +0200
 @@ -10,6 +10,7 @@
  INSTALL = /usr/bin/install
  BINDIR = $(TOPDIR)/sbin
@@ -146,8 +146,216 @@
  
  ## Red Hat specific additions
  
---- /dev/null	2007-05-10 11:02:57.435034000 +0200
-+++ sysklogd-1.4.2rh/sysklogd-dispatch.c	2007-05-14 16:53:48.000000000 +0200
+--- /dev/null	2007-06-04 11:07:53.480224378 +0200
++++ sysklogd-1.4.2rh/dispatcher_example.c	2007-06-07 10:38:28.000000000 +0200
+@@ -0,0 +1,205 @@
++/* dispatcher.c --
++ * 
++ * This is a sample program that you can customize to create your own syslog
++ * event handler. It will be started by syslog via the dispatcher option on
++ * command line. This program can be built as follows:
++ *
++ * gcc dispatcher_example.c -o dispatcher
++ */
++
++#include <stdio.h>
++#include <sys/types.h>
++#include <sys/stat.h>
++#include <sys/uio.h>
++#include <unistd.h>
++#include <stdlib.h>
++#include <signal.h>
++#include <fcntl.h>
++#include <errno.h>
++#include <string.h>
++#include <locale.h>
++#include <sys/socket.h>
++#include <arpa/inet.h>
++#include <sys/select.h>
++#include <sys/un.h>
++
++#include "sysklogd/sysklogd-dispatch.h"
++
++
++/* Local data */
++static volatile int signaled = 0;
++static int pipe_fd;
++static struct sockaddr_un my_addr;
++static int fd;
++
++/* Local functions */
++static int event_loop(void);
++
++/* SIGTERM handler */
++static void term_handler( int sig )
++{
++	signaled = 1;
++}
++
++
++/*
++ * main is started by sysklogd. See dispatcher in man sysklogd.
++ */
++int main(int argc, char *argv[])
++{
++	struct sigaction sa;
++	struct stat stat_buf;
++
++	setlocale (LC_ALL, "");
++	fprintf(stderr, "starting dispatcher...\n");
++
++#ifndef DEBUG
++	/* Make sure we are root */
++	if (getuid() != 0) {
++		fprintf(stderr, "You must be root to run this program.");
++		exit(1);
++	}
++#endif
++
++	/* register sighandlers */
++	sa.sa_flags = 0 ;
++	sa.sa_handler = term_handler;
++	sigemptyset( &sa.sa_mask ) ;
++	sigaction( SIGTERM, &sa, NULL );
++     /*	sa.sa_handler = term_handler;
++	sigemptyset( &sa.sa_mask ) ;
++	sigaction( SIGCHLD, &sa, NULL ); */
++	sa.sa_handler = SIG_IGN;
++	sigaction( SIGHUP, &sa, NULL );
++	sigaction( SIGPIPE, &sa, NULL );
++	(void)chdir("/");
++
++	/* change over to pipe_fd */
++	pipe_fd = dup(0);
++	close(0);
++	fcntl(pipe_fd, F_SETFD, FD_CLOEXEC);
++
++	/* Setup server */
++	if ((fd = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) {
++		perror("socket()");
++		exit(1);
++	}
++	fcntl(fd, F_SETFD, O_NONBLOCK);
++	my_addr.sun_family=AF_UNIX;  
++  	strncpy(my_addr.sun_path, "/tmp/dispatcher.sock", sizeof(my_addr.sun_path));
++	unlink(my_addr.sun_path); /* not necessary */
++	if (bind(fd, (struct sockaddr *) &my_addr, sizeof(my_addr)) == -1) {
++		perror("bind()");
++		exit(1);
++	}
++	stat(my_addr.sun_path, &stat_buf);
++	chmod(my_addr.sun_path, stat_buf.st_mode | S_IWOTH);
++	if (listen(fd, 1) == -1) {
++		perror("listen()");
++		exit(1);
++	}
++
++	/* Start the program */
++	return event_loop();
++}
++
++static int event_loop(void)
++{
++	void* data;
++	struct iovec vec[2];
++	struct sysklogd_dispatcher_header hdr;
++	pid_t pid;
++	static socklen_t addrlen;
++	int new_fd = -1;
++
++
++	/* Allocate data structures */
++	data = malloc(MAXLINE);
++	if (data == NULL) {
++		fprintf(stderr, "Cannot allocate buffer\n");
++		return 1;
++	}
++
++	do {
++		int rc;
++		struct timeval tv;
++		fd_set fdset;
++
++
++		/* if there isn't anybody connected to server, try accept */
++		if (new_fd == -1 ) {
++			addrlen = sizeof(my_addr);
++			if ((new_fd = accept( fd, (struct sockaddr *) &my_addr, &addrlen))==-1) {
++				perror("accept()");
++				exit(1);
++			}
++		}
++
++		memset(data, 0, MAXLINE);
++		memset(&hdr, 0, sizeof(hdr));
++
++		tv.tv_sec = 1;
++		tv.tv_usec = 0;
++		FD_ZERO(&fdset);
++		FD_SET(pipe_fd, &fdset);
++		rc = select(pipe_fd+1, &fdset, NULL, NULL, &tv);
++		if (rc == 0) 
++			continue;
++		 else if (rc == -1)
++			break;
++
++		/* Get header first. it is fixed size */
++		vec[0].iov_base = (void*)&hdr;
++		vec[0].iov_len = sizeof(hdr);
++		rc = readv(pipe_fd, vec, 1);
++		if (rc == 0 || rc == -1) {
++			fprintf(stderr, "rc == %d(%s)\n", rc, strerror(errno));
++			break;
++		}
++
++		/* Analyze header */
++			/*nothing to do at the momemnt */
++
++        	/* Next payload */
++		vec[1].iov_base = data;
++		vec[1].iov_len = MAXLINE; 
++		rc = readv(pipe_fd, &vec[1], 1);
++		if (rc == 0 || rc == -1) {
++			fprintf(stderr, "rc == %d(%s)\n", rc, strerror(errno));
++			break;
++		}
++
++		/* handle some events here. */
++		if (new_fd != -1) {
++			rc = write(new_fd, (char *)data, strlen(data));
++			if (rc <= 0) {
++				if (errno == EPIPE) {
++					close(new_fd);
++					new_fd=-1;
++				} else {	
++					perror("writev()");
++					new_fd=-1;
++				}
++			}
++		}		
++/*
++		if( strstr((char *)data, "oops") ) {
++			pid = fork();
++			if( !pid ) {
++				execl("/usr/bin/zenity","/usr/bin/zenity","--warning",
++				      "--text", (char *)data, NULL);
++				fprintf(stderr, "exec() failed\n");
++		        }
++		}
++*/
++/*
++		 fprintf(stderr,"type=%d, payload size=%d\n", 
++			hdr.type, hdr.size);
++		   fprintf(stderr,"data=\"%.*s\"\n", hdr.size,
++			(char *)data); 
++*/
++	} while(!signaled);
++
++	return 0;
++}
++
+--- /dev/null	2007-06-04 11:07:53.480224378 +0200
++++ sysklogd-1.4.2rh/sysklogd-dispatch.c	2007-06-07 10:40:15.000000000 +0200
 @@ -0,0 +1,190 @@
 +/* sysklogd-dispatch.c -- 
 + * Copyright 2007 Red Hat Inc., Durham, North Carolina.
@@ -339,8 +547,8 @@
 +	} else
 +		n_errs = 0;
 +}
---- sysklogd-1.4.2rh/syslogd.c.dispatcher	2007-05-14 16:53:48.000000000 +0200
-+++ sysklogd-1.4.2rh/syslogd.c	2007-05-14 17:00:50.000000000 +0200
+--- sysklogd-1.4.2rh/syslogd.c.dispatcher	2007-06-07 10:40:15.000000000 +0200
++++ sysklogd-1.4.2rh/syslogd.c	2007-06-07 10:40:15.000000000 +0200
 @@ -507,6 +507,8 @@
  #endif
  #include "version.h"


Index: sysklogd.spec
===================================================================
RCS file: /cvs/extras/rpms/sysklogd/F-7/sysklogd.spec,v
retrieving revision 1.57
retrieving revision 1.58
diff -u -r1.57 -r1.58
--- sysklogd.spec	7 Jun 2007 07:40:53 -0000	1.57
+++ sysklogd.spec	7 Jun 2007 09:06:32 -0000	1.58
@@ -1,7 +1,7 @@
 Summary: System logging and kernel message trapping daemons
 Name: sysklogd
 Version: 1.4.2
-Release: 7%{?dist}
+Release: 8%{?dist}
 License: GPL
 Group: System Environment/Daemons
 URL: http://www.infodrom.org/projects/sysklogd/
@@ -116,14 +116,18 @@
 
 %files devel
 %defattr(-,root,root)
+%doc dispatcher_example.c
 %dir %{_includedir}/sysklogd
 %{_includedir}/sysklogd/sysklogd-dispatch.h
 
 %changelog
-* Thu Jun 07 2007 Peter Vrabec <pvrabec at redhat.com> 1.4.2-7
+* Thu Jun 07 2007 Peter Vrabec <pvrabec at redhat.com> 1.4.2-8
+- provide dispatcher sample program
+
+* Wed Jun 06 2007 Peter Vrabec <pvrabec at redhat.com> 1.4.2-7
 - terminate dispatcher on exit
 
-* Thu Jun 07 2007 Peter Vrabec <pvrabec at redhat.com> 1.4.2-6
+* Wed Jun 06 2007 Peter Vrabec <pvrabec at redhat.com> 1.4.2-6
 - fix realtime interface
 - terminate parent of syslogd daemon on SIGCHLD
 




More information about the fedora-extras-commits mailing list