Bug 68328 - [patch] syslogd(8) enable configuration of extra listen sockets in syslog.conf
Summary: [patch] syslogd(8) enable configuration of extra listen sockets in syslog.conf
Status: Open
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: Unspecified
Hardware: Any Any
: Normal Affects Only Me
Assignee: freebsd-bugs (Nobody)
URL:
Keywords: patch
Depends on:
Blocks:
 
Reported: 2004-06-25 15:30 UTC by Rene de Vries
Modified: 2022-10-17 12:40 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Rene de Vries 2004-06-25 15:30:22 UTC
	Allow the user to configure extra listen sockets in
	/etc/syslog.conf. Upon soft restart (SIGHUP) these lines
	are read and new sockets are created (and old ones removed).
	Each line starting with a '=' defines a socket.

Example "/etc/syslog.conf":

# syslog.conf
=/jail/one/var/run/log
*.err;kern.debug;auth.notice;mail.crit          /dev/console
*.notice;authpriv.none;kern.debug;lpr.info;mail.crit;news.err /var/log/messages

Diff against 4.8:

Index: usr.sbin/syslogd/syslogd.c
===================================================================
RCS file: usr.sbin/syslogd/syslogd.c,v
retrieving revision 1.1.1.6
retrieving revision 1.3
diff -u -r1.1.1.6 -r1.3
--- usr.sbin/syslogd/syslogd.c	2003/04/17 15:45:56	1.1.1.6
+++ usr.sbin/syslogd/syslogd.c	2004/04/05 12:51:34	1.3
@@ -128,9 +128,10 @@
 
 #define MAXUNAMES	20	/* maximum number of user names */
 
-#define MAXFUNIX       20
+#define MAXFUNIX       64
 
 int nfunix = 1;
+int nfunix_cmdline = 1;
 const char *funixn[MAXFUNIX] = { _PATH_LOG };
 int funix[MAXFUNIX];
 
@@ -366,9 +367,10 @@
 			KeepKernFac = 1;
 			break;
 		case 'l':
-			if (nfunix < MAXFUNIX)
-				funixn[nfunix++] = optarg;
-			else
+			if (nfunix < MAXFUNIX) {
+				funixn[nfunix++] = strdup(optarg);
+				nfunix_cmdline = nfunix;
+			} else
 				warnx("out of descriptors, ignoring %s",
 					optarg);
 			break;
@@ -379,7 +381,7 @@
 			resolve = 0;
 			break;
 		case 'p':		/* path */
-			funixn[0] = optarg;
+			funixn[0] = strdup(optarg);
 			break;
 		case 'P':		/* path for alt. PID */
 			PidFile = optarg;
@@ -1117,7 +1119,12 @@
 					    f->f_un.f_pipe.f_pname);
 			f->f_un.f_pipe.f_pid = 0;
 			errno = e;
-			logerror(f->f_un.f_pipe.f_pname);
+			/* if the error is EAGAIN, writev() failed to write to
+			 * the non-blocking pipe, which is a rather harmless
+			 * situation: silently ignore this.
+			 */
+			if ( errno != EAGAIN )
+				logerror(f->f_un.f_pipe.f_pname);
 		}
 		break;
 
@@ -1407,6 +1414,15 @@
 	Files = NULL;
 	nextp = &Files;
 
+	/* close nfunix syslog.conf sockets */
+	for (i = nfunix_cmdline; i < nfunix; i++) {
+		dprintf("closing log socket on %s\n", funixn[i]);
+		unlink(funixn[i]);
+		close(funix[i]);
+		free(funixn[i]);
+	}
+	nfunix = nfunix_cmdline;
+
 	/* open the configuration file */
 	if ((cf = fopen(ConfFile, "r")) == NULL) {
 		dprintf("cannot open %s\n", ConfFile);
@@ -1478,6 +1494,45 @@
 				prog[i] = p[i];
 			}
 			prog[i] = 0;
+			continue;
+		}
+		if (*p == '=') {
+			/* listen on */
+			if (nfunix < MAXFUNIX) {
+				char *e;
+				struct sockaddr_un sunx;
+				for (e = p; *e != '\0'; e++) {
+					if ((*e == '\r') || (*e == '\n')) {
+						*e = '\0';
+						break;
+					}
+				}
+				dprintf("opening log socket on %s\n", p+1);
+				funixn[nfunix] = strdup(p+1);
+				(void)unlink(funixn[nfunix]);
+				memset(&sunx, 0, sizeof(sunx));
+				sunx.sun_family = AF_UNIX;
+				(void)strlcpy(sunx.sun_path,
+					funixn[nfunix], sizeof(sunx.sun_path));
+				funix[nfunix] = socket(AF_UNIX, SOCK_DGRAM, 0);
+				if (funix[nfunix] < 0 ||
+				    bind(funix[nfunix],
+					 (struct sockaddr *)&sunx,
+					 SUN_LEN(&sunx)) < 0 ||
+				    chmod(funixn[nfunix], 0666) < 0) {
+					char line[256];
+					(void)snprintf(line, sizeof line,
+						"cannot create %s",
+						funixn[nfunix]);
+					logerror(line);
+					free(funixn[nfunix]);
+				} else nfunix++;
+			} else {
+				char line[256];
+				(void)snprintf(line, sizeof line,
+					"out of descriptors, ignoring %s", p);
+				logerror(line);
+			}
 			continue;
 		}
 		for (p = strchr(cline, '\0'); isspace(*--p);)
Comment 1 Eitan Adler freebsd_committer freebsd_triage 2017-12-31 08:00:38 UTC
For bugs matching the following criteria:

Status: In Progress Changed: (is less than) 2014-06-01

Reset to default assignee and clear in-progress tags.

Mail being skipped
Comment 2 Graham Perrin freebsd_committer freebsd_triage 2022-10-17 12:40:52 UTC
Keyword: 

    patch
or  patch-ready

– in lieu of summary line prefix: 

    [patch]

* bulk change for the keyword
* summary lines may be edited manually (not in bulk). 

Keyword descriptions and search interface: 

    <https://bugs.freebsd.org/bugzilla/describekeywords.cgi>