[BusyBox] [PATCH] small bug in syslogd + fix

Felipe Kellermann felipek at exatas.unisinos.br
Tue Sep 14 16:39:37 UTC 2004


On Mon, 13 Sep 2004 8:16pm  +0200, Martin Volf wrote:

> Hello,
>
> with CONFIG_FEATURE_REMOTE_LOG enabled, the syslogd applet won't start
> without the -R option. It is fixed (I think) with the attached patch.
> Busybox version: current CVS 1.00-rc3.

Hi Martin Volf.  Yes, you are correct, this makes sense.  Thanks for
submitting the report.  I introduced this "bug" with a patch I sent
recently...  but I can't see the "won't start" you're describing  ;-)
(I removed the `die' of `init_RemoteLog', BTW)

But it obviously is missing that condition.  I installed the attached
modified diff (a little more abrangent than yours and adding comments
briefly explaining the code).  I'd suggest someone applying this ASAP.

Thanks,

-- 
Felipe Kellermann
-------------- next part --------------
Index: sysklogd/syslogd.c
===================================================================
RCS file: /var/cvs/busybox/sysklogd/syslogd.c,v
retrieving revision 1.116
diff -u -r1.116 syslogd.c
--- sysklogd/syslogd.c	8 Sep 2004 10:56:06 -0000	1.116
+++ sysklogd/syslogd.c	14 Sep 2004 16:31:38 -0000
@@ -432,24 +432,30 @@
 	/* todo: supress duplicates */
 
 #ifdef CONFIG_FEATURE_REMOTE_LOG
-	/* send message to remote logger */
-	if (-1 == remotefd) {
-		init_RemoteLog();
-	}
+	if (doRemoteLog == TRUE) {
+		/* trying connect the socket */
+		if (-1 == remotefd) {
+			init_RemoteLog();
+		}
 
-	if (-1 != remotefd) {
-		now = 1;
-		snprintf(line, sizeof(line), "<%d> %s", pri, msg);
-
-	retry:
-    	if(( -1 == sendto(remotefd, line, strlen(line), 0, 
-						(struct sockaddr *) &remoteaddr, 
-						sizeof(remoteaddr))) && (errno == EINTR)) {
-			sleep(now);
-			now *= 2;
-			goto retry;
+		/* if we have a valid socket, send the message */
+		if (-1 != remotefd) {
+			now = 1;
+			snprintf(line, sizeof(line), "<%d> %s", pri, msg);
+
+		retry:
+			/* send message to remote logger */
+			if(( -1 == sendto(remotefd, line, strlen(line), 0,
+							(struct sockaddr *) &remoteaddr,
+							sizeof(remoteaddr))) && (errno == EINTR)) {
+				/* sleep now seconds and retry (with now * 2) */
+				sleep(now);
+				now *= 2;
+				goto retry;
+			}
 		}
 	}
+
 	if (local_logging == TRUE)
 #endif
 	{


More information about the busybox mailing list