Sophie

Sophie

distrib > Mandriva > mes5 > i586 > by-pkgid > 7ce23f99807f9a2f70929a432f12f6ae > files > 5

sysklogd-1.4.2-8mdv2009.0.src.rpm

--- sysklogd-1.4.2rh/sysklogd.8.includeFacPri	2007-02-26 10:46:08.000000000 +0100
+++ sysklogd-1.4.2rh/sysklogd.8	2007-04-11 17:46:34.000000000 +0200
@@ -172,6 +172,12 @@
 no domain would be cut, you will have to specify two domains like:
 .BR "\-s north.de:infodrom.north.de" .
 .TP
+.B "\-S"
+Verbose logging. If specified once, the numeric facility and priority
+are logged with each locally-written message. If specified more than
+once, the names of the facility and priority are logged with each
+locally-written message.
+.TP
 .B "\-v"
 Print version and exit.
 .TP
--- sysklogd-1.4.2rh/syslogd.c.includeFacPri	2007-04-11 17:46:34.000000000 +0200
+++ sysklogd-1.4.2rh/syslogd.c	2007-04-11 17:47:30.000000000 +0200
@@ -755,6 +755,8 @@
 char	**LocalHosts = NULL;	/* these hosts are logged with their hostname */
 int	NoHops = 1;		/* Can we bounce syslog messages through an
 				   intermediate host. */
+static int	LogFacPri = 0;	/* Put facility and priority in log message: */
+				/* 0=no, 1=numeric, 2=names */
 
 extern	int errno;
 
@@ -857,7 +859,7 @@
 		funix[i]  = -1;
 	}
 
-	while ((ch = getopt(argc, argv, "46Aa:dhf:l:m:np:rs:vx")) != EOF)
+	while ((ch = getopt(argc, argv, "46Aa:dhf:l:m:np:rSs:vx")) != EOF)
 		switch((char)ch) {
                 case '4':
                               family = PF_INET;
@@ -885,6 +887,9 @@
 		case 'h':
 			NoHops = 0;
 			break;
+		case 'S':		/* log facility and priority */
+		  	LogFacPri++;   
+			break;
 		case 'l':
 			if (LocalHosts) {
 				fprintf (stderr, "Only one -l argument allowed," \
@@ -1243,7 +1248,7 @@
 
 int usage()
 {
-	fprintf(stderr, "usage: syslogd [-46Adrvxh] [-l hostlist] [-m markinterval] [-n] [-p path]\n" \
+	fprintf(stderr, "usage: syslogd [-46AdiIrvxh] [-l hostlist] [-m markinterval] [-n] [-p path]\n" \
 		" [-s domainlist] [-f conffile]\n");
 	exit(1);
 }
@@ -1751,7 +1756,7 @@
 	int flags;
 	char *msg;
 {
-	struct iovec iov[6];
+	struct iovec iov[7];
 	struct addrinfo *r;
 	register struct iovec *v = iov;
 	char repbuf[80];
@@ -1771,6 +1776,49 @@
 	v->iov_base = " ";
 	v->iov_len = 1;
 	v++;
+
+        if (LogFacPri) {
+	  	static char fp_buf[30];	/* Hollow laugh */
+		int fac = f->f_prevpri & LOG_FACMASK;
+		int pri = LOG_PRI(f->f_prevpri);
+		const char *f_s = NULL;
+		char f_n[5];	/* Hollow laugh */
+		const char *p_s = NULL;
+		char p_n[5];	/* Hollow laugh */
+
+		if (LogFacPri > 1) {
+		  CODE *c;
+
+		  for (c = facilitynames; c->c_name; c++) {
+		    if (c->c_val == fac) {
+		      f_s = c->c_name;
+		      break;
+		    }
+		  }
+		  for (c = prioritynames; c->c_name; c++) {
+		    if (c->c_val == pri) {
+		      p_s = c->c_name;
+		      break;
+		    }
+		  }
+		}
+		if (!f_s) {
+		  snprintf(f_n, sizeof f_n, "%d", LOG_FAC(fac));
+		  f_s = f_n;
+		}
+		if (!p_s) {
+		  snprintf(p_n, sizeof p_n, "%d", pri);
+		  p_s = p_n;
+		}
+		snprintf(fp_buf, sizeof fp_buf, "<%s.%s> ", f_s, p_s);
+		v->iov_base = fp_buf;
+		v->iov_len = strlen(fp_buf);
+	} else {
+		v->iov_base = "";
+		v->iov_len = 0;
+	}
+	v++;
+
 	v->iov_base = f->f_prevhost;
 	v->iov_len = strlen(v->iov_base);
 	v++;
@@ -1865,7 +1913,7 @@
 		else {
 			f->f_time = now;
 			(void) snprintf(line, sizeof(line), "<%d>%s\n", f->f_prevpri, \
-				(char *) iov[4].iov_base);
+				(char *) iov[5].iov_base);
 			l = strlen(line);
 			if (l > MAXLINE)
 				l = MAXLINE;
@@ -1929,7 +1977,7 @@
 		if (f->f_file == -1)
 			break;
 
-		if (writev(f->f_file, iov, 6) < 0) {
+		if (writev(f->f_file, iov, 7) < 0) {
 			int e = errno;
 
 			/* If a named pipe is full, just ignore it for now