[1175] in Kerberos-V5-bugs

home help back first fref pref prev next nref lref last post

krb5b4pl3: kdc/main.c should use syslog instead of vsyslog

daemon@ATHENA.MIT.EDU (Jonathan I. Kamens)
Tue Mar 14 16:43:36 1995

From: "Jonathan I. Kamens" <jik@cam.ov.com>
Date: Tue, 14 Mar 1995 16:46:45 -0500
To: krb5-bugs@MIT.EDU

We found when compiling the KDC that logging often wouldn't work
properly (e.g., messags were truncated) due to bugs in the vendor
implementation of vsyslog.  Rather than trying to get the vendors to
fix this, we modified the KDC to use syslog instead of vsyslog.  It's
gross, but it works on all the platforms we've tried it on, and the
old code didn.t.  Fix follows:

--- kdc/main.c	1995/03/09 15:31:00	1.2
+++ kdc/main.c	1995/03/09 15:35:19	1.3
@@ -61,41 +61,37 @@
 	va_list pvar;
 {
     /* XXX need some way to do this better... */
-
 #ifndef __STDC__
     extern int vfprintf();
 #endif
 
+    char syslogbuf[10240], tmpbuf[10240];
+
+    memset(syslogbuf, 0, sizeof(syslogbuf));
+    memset(tmpbuf, 0, sizeof(tmpbuf));
+
     if (whoami) {
         fputs(whoami, stderr);
         fputs(": ", stderr);
     }
+
     if (code) {
-        fputs(error_message(code), stderr);
-        fputs(" ", stderr);
+	sprintf(tmpbuf, error_message(code));
+	strcat(syslogbuf, tmpbuf);
+	strcat(syslogbuf, " ");
     }
+
     if (format) {
-        vfprintf (stderr, format, pvar);
+	vsprintf(tmpbuf, format, pvar);
+	strcat(syslogbuf, tmpbuf);
     }
+
+    fprintf(stderr, syslogbuf);
     putc('\n', stderr);
-    /* should do this only on a tty in raw mode */
-    putc('\r', stderr);
+    putc('\r', stderr); /* should do this only on a tty in raw mode */
     fflush(stderr);
-    if (format) {
-	/* now need to frob the format a bit... */
-	if (code) {
-	    char *nfmt;
-	    nfmt = malloc(strlen(format)+strlen(error_message(code))+2);
-	    strcpy(nfmt, error_message(code));
-	    strcat(nfmt, " ");
-	    strcat(nfmt, format);
-	    vsyslog(LOG_ERR, nfmt, pvar);
-	} else
-	    vsyslog(LOG_ERR, format, pvar);
-    } else {
-	if (code)
-	    syslog(LOG_ERR, "%s", error_message(code));
-    }
+
+    syslog(LOG_ERR, "%s", syslogbuf);
 
     return;
 }

Jonathan Kamens  |  OpenVision Technologies, Inc.  |   jik@cam.ov.com

home help back first fref pref prev next nref lref last post