[BusyBox] patch syslogd -p unconditional

Stuart Hughes stuarth at freescale.com
Thu Jul 21 08:57:37 MDT 2005


As a follow up to an earlier patch I sent, here's a patch that adds the 
'-p FILE' option to syslogd.  In this version there's no config option 
to turn it on/off, it's just on.

Regards, Stuart

Stuart Hughes wrote:
> 
> I've attached a patch against busybox-1.00 that implements this.
> 
> Regards, Stuart
> 
> 
>>> On 7/5/05, Stuart Hughes <stuarth at freescale.com 
>>> <mailto:stuarth at freescale.com>> wrote:
>>>
>>>     I'd like to run syslogd on a read-only root filesystem, but I can't
>>>     because /dev is not writable and the /dev/log socket needs to be 
>>> created
>>>     by syslogd.
>>>
>>>     On the fullup sysklogd version there is a "-p" option to specify the
>>>     location of this socket.
>>>
>>>     Are there any plans to add this option to busybox.
>>>
>>>     TIA, Stuart
-------------- next part --------------
Thu Jul 21 2005 Stuart Hughes <stuarth at freescale.com>

Unconditionally add the -p option to syslogd

diff --exclude CVS -uNr busybox-1.00/include/usage.h busybox-1.00.modified/include/usage.h
--- busybox-1.00/include/usage.h	2004-09-14 17:23:56.000000000 +0100
+++ busybox-1.00.modified/include/usage.h	2005-07-21 15:47:30.000000000 +0100
@@ -2329,6 +2329,7 @@
 	"Options:\n" \
 	"\t-m MIN\t\tMinutes between MARK lines (default=20, 0=off)\n" \
 	"\t-n\t\tRun as a foreground process\n" \
+	"\t-p FILE\t\tUse and alternate log socket (default=/dev/log)\n" \
 	"\t-O FILE\t\tUse an alternate log file (default=/var/log/messages)\n" \
 	"\t-S\t\tMake logging output smaller." \
 	USAGE_ROTATE_LOGFILE( \
diff --exclude CVS -uNr busybox-1.00/sysklogd/syslogd.c busybox-1.00.modified/sysklogd/syslogd.c
--- busybox-1.00/sysklogd/syslogd.c	2004-09-14 19:12:13.000000000 +0100
+++ busybox-1.00.modified/sysklogd/syslogd.c	2005-07-21 15:34:40.000000000 +0100
@@ -57,6 +57,7 @@
 
 /* Path to the unix socket */
 static char lfile[MAXPATHLEN];
+static const char *logSockPath = _PATH_LOG;
 
 static const char *logFilePath = __LOG_FILE;
 
@@ -551,7 +552,7 @@
 	alarm(MarkInterval);
 
 	/* Create the syslog file so realpath() can work. */
-	if (realpath(_PATH_LOG, lfile) != NULL) {
+	if (realpath(logSockPath, lfile) != NULL) {
 		unlink(lfile);
 	}
 
@@ -559,17 +560,16 @@
 	sunx.sun_family = AF_UNIX;
 	strncpy(sunx.sun_path, lfile, sizeof(sunx.sun_path));
 	if ((sock_fd = socket(AF_UNIX, SOCK_DGRAM, 0)) < 0) {
-		bb_perror_msg_and_die("Couldn't get file descriptor for socket "
-						   _PATH_LOG);
+		bb_perror_msg_and_die("Couldn't get file descriptor for socket %s", logSockPath);
 	}
 
 	addrLength = sizeof(sunx.sun_family) + strlen(sunx.sun_path);
 	if (bind(sock_fd, (struct sockaddr *) &sunx, addrLength) < 0) {
-		bb_perror_msg_and_die("Could not connect to socket " _PATH_LOG);
+		bb_perror_msg_and_die("Could not connect to socket %s", logSockPath);
 	}
 
 	if (chmod(lfile, 0666) < 0) {
-		bb_perror_msg_and_die("Could not set permission on " _PATH_LOG);
+		bb_perror_msg_and_die("Could not set permission on %s", logSockPath);
 	}
 #ifdef CONFIG_FEATURE_IPC_SYSLOG
 	if (circular_logging == TRUE) {
@@ -623,7 +623,7 @@
 	char *p;
 
 	/* do normal option parsing */
-	while ((opt = getopt(argc, argv, "m:nO:s:Sb:R:LC::")) > 0) {
+	while ((opt = getopt(argc, argv, "m:nO:s:p:Sb:R:LC::")) > 0) {
 		switch (opt) {
 		case 'm':
 			MarkInterval = atoi(optarg) * 60;
@@ -634,6 +634,9 @@
 		case 'O':
 			logFilePath = optarg;
 			break;
+		case 'p':
+			logSockPath = optarg;
+			break;
 #ifdef CONFIG_FEATURE_ROTATE_LOGFILE
 		case 's':
 			logFileSize = atoi(optarg) * 1024;


More information about the busybox mailing list