Subject: lib/7193: Syslog(3) stopped logging via the unix domain socket.
To: None <gnats-bugs@gnats.netbsd.org>
From: Takahiro Kambe <taca@sky.yamashina.kyoto.jp>
List: netbsd-bugs
Date: 03/18/1999 15:12:43
>Number:         7193
>Category:       lib
>Synopsis:       Syslog(3) stopped logging via the unix domain socket.
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    lib-bug-people (Library Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Mar 17 22:20:01 1999
>Last-Modified:
>Originator:     Takahiro Kambe
>Organization:
>Release:        NetBSD-current 1999/3/16
>Environment:
System: NetBSD edge.sky.yamashina.kyoto.jp 1.3K NetBSD 1.3K (ALN4PCVT) #8: Wed Mar 17 23:25:55 JST 1999 taca@edge.sky.yamashina.kyoto.jp:/usr/src/sys/arch/i386/compile/ALN4PCVT i386


>Description:
	Syslog(3) uses _PATH_LOG and it length increased a few days ago.
	In syslog.c, this unix domain socket is named specified with
	sockaddr structure not sockaddr_un structure.  So, its path is
	truncated by 13 bytes.
	
>How-To-Repeat:
	Install libc(3) after syslogd(8)'s change.
>Fix:
Use sockaddr_un structure.

--- lib/libc/gen/syslog.c.ORIG	Sat Feb  6 12:44:30 1999
+++ lib/libc/gen/syslog.c	Thu Mar 17 23:56:18 1999
@@ -47,6 +47,7 @@
 #include <sys/socket.h>
 #include <sys/syslog.h>
 #include <sys/uio.h>
+#include <sys/un.h>
 #include <netdb.h>
 
 #include <errno.h>
@@ -272,7 +273,7 @@
 	}
 }
 
-static struct sockaddr SyslogAddr;	/* AF_LOCAL address of local logger */
+static struct sockaddr_un SyslogAddr;	/* AF_LOCAL address of local logger */
 
 static void
 openlog_unlocked(ident, logstat, logfac)
@@ -287,9 +288,9 @@
 		LogFacility = logfac;
 
 	if (LogFile == -1) {
-		SyslogAddr.sa_family = AF_LOCAL;
-		(void)strncpy(SyslogAddr.sa_data, _PATH_LOG,
-		    sizeof(SyslogAddr.sa_data));
+		SyslogAddr.sun_family = AF_LOCAL;
+		(void)strncpy(SyslogAddr.sun_path, _PATH_LOG,
+		    sizeof(SyslogAddr.sun_path));
 		if (LogStat & LOG_NDELAY) {
 			if ((LogFile = socket(AF_LOCAL, SOCK_DGRAM, 0)) == -1)
 				return;
@@ -297,7 +298,8 @@
 		}
 	}
 	if (LogFile != -1 && !connected) {
-		if (connect(LogFile, &SyslogAddr, sizeof(SyslogAddr)) == -1) {
+		if (connect(LogFile, (struct sockaddr *)&SyslogAddr,
+			    SUN_LEN(&SyslogAddr)) == -1) {
 			(void)close(LogFile);
 			LogFile = -1;
 		} else
>Audit-Trail:
>Unformatted: