CVS commit: src/usr.sbin/syslogd

2020-11-07 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Sun Nov  8 01:12:46 UTC 2020

Modified Files:
src/usr.sbin/syslogd: syslogd.c

Log Message:
syslogd: in die(), don't call die() again recursively.

Particularly not for something as immaterial as close failing.

PR 55795


To generate a diff of this commit:
cvs rdiff -u -r1.135 -r1.136 src/usr.sbin/syslogd/syslogd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/syslogd/syslogd.c
diff -u src/usr.sbin/syslogd/syslogd.c:1.135 src/usr.sbin/syslogd/syslogd.c:1.136
--- src/usr.sbin/syslogd/syslogd.c:1.135	Sat Nov  7 17:46:56 2020
+++ src/usr.sbin/syslogd/syslogd.c	Sun Nov  8 01:12:46 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: syslogd.c,v 1.135 2020/11/07 17:46:56 christos Exp $	*/
+/*	$NetBSD: syslogd.c,v 1.136 2020/11/08 01:12:46 dholland Exp $	*/
 
 /*
  * Copyright (c) 1983, 1988, 1993, 1994
@@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1983, 19
 #if 0
 static char sccsid[] = "@(#)syslogd.c	8.3 (Berkeley) 4/4/94";
 #else
-__RCSID("$NetBSD: syslogd.c,v 1.135 2020/11/07 17:46:56 christos Exp $");
+__RCSID("$NetBSD: syslogd.c,v 1.136 2020/11/08 01:12:46 dholland Exp $");
 #endif
 #endif /* not lint */
 
@@ -3012,10 +3012,7 @@ die(int fd, short event, void *ev)
 	 */
 	if (finet) {
 		for (i = 0; i < finet->fd; i++) {
-			if (close(finet[i+1].fd) < 0) {
-logerror("close() failed");
-die(0, 0, NULL);
-			}
+			(void)close(finet[i+1].fd);
 			DEL_EVENT(finet[i+1].ev);
 			FREEPTR(finet[i+1].ev);
 		}



CVS commit: src/usr.sbin/syslogd

2020-11-07 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Nov  7 17:46:57 UTC 2020

Modified Files:
src/usr.sbin/syslogd: syslogd.c

Log Message:
make the buffer fit any 32 bit number.


To generate a diff of this commit:
cvs rdiff -u -r1.134 -r1.135 src/usr.sbin/syslogd/syslogd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/syslogd/syslogd.c
diff -u src/usr.sbin/syslogd/syslogd.c:1.134 src/usr.sbin/syslogd/syslogd.c:1.135
--- src/usr.sbin/syslogd/syslogd.c:1.134	Sat Nov  7 11:16:33 2020
+++ src/usr.sbin/syslogd/syslogd.c	Sat Nov  7 12:46:56 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: syslogd.c,v 1.134 2020/11/07 16:16:33 christos Exp $	*/
+/*	$NetBSD: syslogd.c,v 1.135 2020/11/07 17:46:56 christos Exp $	*/
 
 /*
  * Copyright (c) 1983, 1988, 1993, 1994
@@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1983, 19
 #if 0
 static char sccsid[] = "@(#)syslogd.c	8.3 (Berkeley) 4/4/94";
 #else
-__RCSID("$NetBSD: syslogd.c,v 1.134 2020/11/07 16:16:33 christos Exp $");
+__RCSID("$NetBSD: syslogd.c,v 1.135 2020/11/07 17:46:56 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -207,7 +207,7 @@ bool	BSDOutputFormat = true;	/* if true 
  */
 char	appname[]   = "syslogd";/* the APPNAME for own messages */
 char   *include_pid;		/* include PID in own messages */
-char	include_pid_buf[6];
+char	include_pid_buf[11];
 
 
 /* init and setup */



CVS commit: src/usr.sbin/syslogd

2020-11-07 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Nov  7 16:16:33 UTC 2020

Modified Files:
src/usr.sbin/syslogd: syslogd.c

Log Message:
PR/55794: Jan Schaumann: Eliminate unchecked malloc


To generate a diff of this commit:
cvs rdiff -u -r1.133 -r1.134 src/usr.sbin/syslogd/syslogd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/syslogd/syslogd.c
diff -u src/usr.sbin/syslogd/syslogd.c:1.133 src/usr.sbin/syslogd/syslogd.c:1.134
--- src/usr.sbin/syslogd/syslogd.c:1.133	Tue Sep 29 10:08:43 2020
+++ src/usr.sbin/syslogd/syslogd.c	Sat Nov  7 11:16:33 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: syslogd.c,v 1.133 2020/09/29 14:08:43 gson Exp $	*/
+/*	$NetBSD: syslogd.c,v 1.134 2020/11/07 16:16:33 christos Exp $	*/
 
 /*
  * Copyright (c) 1983, 1988, 1993, 1994
@@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1983, 19
 #if 0
 static char sccsid[] = "@(#)syslogd.c	8.3 (Berkeley) 4/4/94";
 #else
-__RCSID("$NetBSD: syslogd.c,v 1.133 2020/09/29 14:08:43 gson Exp $");
+__RCSID("$NetBSD: syslogd.c,v 1.134 2020/11/07 16:16:33 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -206,7 +206,8 @@ bool	BSDOutputFormat = true;	/* if true 
  * configurations (e.g. with SG="0").
  */
 char	appname[]   = "syslogd";/* the APPNAME for own messages */
-char   *include_pid = NULL;	/* include PID in own messages */
+char   *include_pid;		/* include PID in own messages */
+char	include_pid_buf[6];
 
 
 /* init and setup */
@@ -573,9 +574,8 @@ getgroup:
 #endif /* __NetBSD_Version__ */
 	}
 
-#define MAX_PID_LEN 5
-	include_pid = malloc(MAX_PID_LEN+1);
-	snprintf(include_pid, MAX_PID_LEN+1, "%d", getpid());
+	include_pid = include_pid_buf;
+	snprintf(include_pid_buf, sizeof(include_pid_buf), "%d", getpid());
 
 	/*
 	 * Create the global kernel event descriptor.



CVS commit: src/usr.sbin/syslogd

2020-09-29 Thread Andreas Gustafsson
Module Name:src
Committed By:   gson
Date:   Tue Sep 29 14:08:43 UTC 2020

Modified Files:
src/usr.sbin/syslogd: syslogd.c

Log Message:
When reporting an error before daemonizing, prefix the error message
with the program name.


To generate a diff of this commit:
cvs rdiff -u -r1.132 -r1.133 src/usr.sbin/syslogd/syslogd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/syslogd/syslogd.c
diff -u src/usr.sbin/syslogd/syslogd.c:1.132 src/usr.sbin/syslogd/syslogd.c:1.133
--- src/usr.sbin/syslogd/syslogd.c:1.132	Thu Dec 26 04:53:12 2019
+++ src/usr.sbin/syslogd/syslogd.c	Tue Sep 29 14:08:43 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: syslogd.c,v 1.132 2019/12/26 04:53:12 msaitoh Exp $	*/
+/*	$NetBSD: syslogd.c,v 1.133 2020/09/29 14:08:43 gson Exp $	*/
 
 /*
  * Copyright (c) 1983, 1988, 1993, 1994
@@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1983, 19
 #if 0
 static char sccsid[] = "@(#)syslogd.c	8.3 (Berkeley) 4/4/94";
 #else
-__RCSID("$NetBSD: syslogd.c,v 1.132 2019/12/26 04:53:12 msaitoh Exp $");
+__RCSID("$NetBSD: syslogd.c,v 1.133 2020/09/29 14:08:43 gson Exp $");
 #endif
 #endif /* not lint */
 
@@ -2881,7 +2881,7 @@ logerror(const char *fmt, ...)
 	if (!daemonized && Debug)
 		DPRINTF(D_MISC, "%s\n", outbuf);
 	if (!daemonized && !Debug)
-		printf("%s\n", outbuf);
+		printf("%s: %s\n", getprogname(), outbuf);
 
 	logerror_running = 0;
 }



CVS commit: src/usr.sbin/syslogd

2019-02-11 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Mon Feb 11 19:45:54 UTC 2019

Modified Files:
src/usr.sbin/syslogd: syslogd.h

Log Message:
add parens around defines with expressions that could expand poorly
depending on the usage.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/usr.sbin/syslogd/syslogd.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/syslogd/syslogd.h
diff -u src/usr.sbin/syslogd/syslogd.h:1.7 src/usr.sbin/syslogd/syslogd.h:1.8
--- src/usr.sbin/syslogd/syslogd.h:1.7	Tue Sep  8 18:33:12 2015
+++ src/usr.sbin/syslogd/syslogd.h	Mon Feb 11 19:45:54 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: syslogd.h,v 1.7 2015/09/08 18:33:12 plunky Exp $	*/
+/*	$NetBSD: syslogd.h,v 1.8 2019/02/11 19:45:54 mrg Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -243,8 +243,8 @@ void dbprintf(const char *, const char *
 } while (/*CONSTCOND*/0)
 
 #define MAXUNAMES		20	/* maximum number of user names */
-#define BSD_TIMESTAMPLEN	14+1
-#define MAX_TIMESTAMPLEN	31+1
+#define BSD_TIMESTAMPLEN	(14+1)
+#define MAX_TIMESTAMPLEN	(31+1)
 
 /* maximum field lengths in syslog-protocol */
 #define PRI_MAX	  5



CVS commit: src/usr.sbin/syslogd

2018-11-05 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Nov  5 10:27:06 UTC 2018

Modified Files:
src/usr.sbin/syslogd: syslogd.c

Log Message:
Revert previous - local merge mishap


To generate a diff of this commit:
cvs rdiff -u -r1.129 -r1.130 src/usr.sbin/syslogd/syslogd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/syslogd/syslogd.c
diff -u src/usr.sbin/syslogd/syslogd.c:1.129 src/usr.sbin/syslogd/syslogd.c:1.130
--- src/usr.sbin/syslogd/syslogd.c:1.129	Mon Nov  5 09:22:30 2018
+++ src/usr.sbin/syslogd/syslogd.c	Mon Nov  5 10:27:06 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: syslogd.c,v 1.129 2018/11/05 09:22:30 wiz Exp $	*/
+/*	$NetBSD: syslogd.c,v 1.130 2018/11/05 10:27:06 martin Exp $	*/
 
 /*
  * Copyright (c) 1983, 1988, 1993, 1994
@@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1983, 19
 #if 0
 static char sccsid[] = "@(#)syslogd.c	8.3 (Berkeley) 4/4/94";
 #else
-__RCSID("$NetBSD: syslogd.c,v 1.129 2018/11/05 09:22:30 wiz Exp $");
+__RCSID("$NetBSD: syslogd.c,v 1.130 2018/11/05 10:27:06 martin Exp $");
 #endif
 #endif /* not lint */
 
@@ -75,9 +75,6 @@ __RCSID("$NetBSD: syslogd.c,v 1.129 2018
 #include "syslogd.h"
 #include "extern.h"
 
-/* Minimum size of the logpath socket buffer */
-#define	RCVBUFLEN		16384
-
 #ifndef DISABLE_SIGN
 #include "sign.h"
 struct sign_global_t GlobalSign = {
@@ -496,9 +493,6 @@ getgroup:
 		die(0, 0, NULL);
 	}
 	for (j = 0, pp = LogPaths; *pp; pp++, j++) {
-		int buf_len;
-		socklen_t socklen = sizeof(buf_len);
-
 		DPRINTF(D_NET, "Making unix dgram socket `%s'\n", *pp);
 		unlink(*pp);
 		memset(, 0, sizeof(sunx));
@@ -513,19 +507,6 @@ getgroup:
 		}
 		setsockbuf(funix[j], *pp);
 		DPRINTF(D_NET, "Listening on unix dgram socket `%s'\n", *pp);
-		if (getsockopt(funix[j], SOL_SOCKET, SO_RCVBUF,
-			   _len, ) == -1) {
-			logerror("getsockopt: SO_RCVBUF: `%s'", *pp);
-			continue;
-		}
-		if (buf_len >= RCVBUFLEN)
-			continue;
-		buf_len = RCVBUFLEN;
-		if (setsockopt(funix[j], SOL_SOCKET, SO_RCVBUF,
-			   _len, socklen) == -1) {
-			logerror("setsockopt: SO_RCVBUF: `%s'", *pp);
-			continue;
-		}
 	}
 
 	if ((fklog = open(_PATH_KLOG, O_RDONLY, 0)) < 0) {



CVS commit: src/usr.sbin/syslogd

2018-11-05 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Mon Nov  5 09:22:30 UTC 2018

Modified Files:
src/usr.sbin/syslogd: syslogd.8 syslogd.c

Log Message:
Sort options.


To generate a diff of this commit:
cvs rdiff -u -r1.57 -r1.58 src/usr.sbin/syslogd/syslogd.8
cvs rdiff -u -r1.128 -r1.129 src/usr.sbin/syslogd/syslogd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/syslogd/syslogd.8
diff -u src/usr.sbin/syslogd/syslogd.8:1.57 src/usr.sbin/syslogd/syslogd.8:1.58
--- src/usr.sbin/syslogd/syslogd.8:1.57	Sun Nov  4 20:45:21 2018
+++ src/usr.sbin/syslogd/syslogd.8	Mon Nov  5 09:22:30 2018
@@ -1,4 +1,4 @@
-.\"	$NetBSD: syslogd.8,v 1.57 2018/11/04 20:45:21 roy Exp $
+.\"	$NetBSD: syslogd.8,v 1.58 2018/11/05 09:22:30 wiz Exp $
 .\"
 .\" Copyright (c) 1983, 1986, 1991, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -38,8 +38,8 @@
 .Sh SYNOPSIS
 .Nm
 .Op Fl dnrSsTUvX
-.Op Fl b Ar bind_address
 .Op Fl B Ar buffer_length
+.Op Fl b Ar bind_address
 .Op Fl f Ar config_file
 .Op Fl g Ar group
 .Op Fl m Ar mark_interval
@@ -57,10 +57,6 @@ reads and logs messages to the system co
 machines and/or users as specified by its configuration file.
 The options are as follows:
 .Bl -tag -width 15n
-.It Fl b Ar bind_address
-Specify one specific IP address or hostname to bind to.
-If a hostname is specified, the IPv4 or IPv6 address
-which corresponds to it is used.
 .It Fl B Ar buffer_length
 Sets the receiving buffer length.
 The default is 16384 bytes.
@@ -68,6 +64,10 @@ If syslogd reports buffer overflow, this
 If you don't care about it being reported, see the
 .Fl X
 option.
+.It Fl b Ar bind_address
+Specify one specific IP address or hostname to bind to.
+If a hostname is specified, the IPv4 or IPv6 address
+which corresponds to it is used.
 .It Fl d
 Enable debugging to the standard output,
 and do not disassociate from the controlling terminal.
@@ -126,20 +126,16 @@ which
 runs is subject to attack over the network and it is desired
 that the machine be protected from attempts to remotely fill logs
 and similar attacks.
-.It Fl t Ar chroot_dir
-.Xr chroot 2
-to
-.Ar chroot_dir
-after the sockets and log files have been opened.
 .It Fl T
 Always use the local time and date for messages received from the
 network, instead of the timestamp field supplied in the message
 by the remote host.
 This is useful if some of the originating hosts can't keep time
 properly or are unable to generate a correct timestamp.
-.It Fl u Ar user
-Set UID to
-.Ar user
+.It Fl t Ar chroot_dir
+.Xr chroot 2
+to
+.Ar chroot_dir
 after the sockets and log files have been opened.
 .It Fl U
 Unique priority logging.
@@ -151,6 +147,10 @@ This option changes the default priority
 .Sq >=
 to
 .Sq = .
+.It Fl u Ar user
+Set UID to
+.Ar user
+after the sockets and log files have been opened.
 .It Fl v
 Verbose logging.
 If specified once, the numeric facility and priority are logged with

Index: src/usr.sbin/syslogd/syslogd.c
diff -u src/usr.sbin/syslogd/syslogd.c:1.128 src/usr.sbin/syslogd/syslogd.c:1.129
--- src/usr.sbin/syslogd/syslogd.c:1.128	Mon Nov  5 08:34:20 2018
+++ src/usr.sbin/syslogd/syslogd.c	Mon Nov  5 09:22:30 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: syslogd.c,v 1.128 2018/11/05 08:34:20 martin Exp $	*/
+/*	$NetBSD: syslogd.c,v 1.129 2018/11/05 09:22:30 wiz Exp $	*/
 
 /*
  * Copyright (c) 1983, 1988, 1993, 1994
@@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1983, 19
 #if 0
 static char sccsid[] = "@(#)syslogd.c	8.3 (Berkeley) 4/4/94";
 #else
-__RCSID("$NetBSD: syslogd.c,v 1.128 2018/11/05 08:34:20 martin Exp $");
+__RCSID("$NetBSD: syslogd.c,v 1.129 2018/11/05 09:22:30 wiz Exp $");
 #endif
 #endif /* not lint */
 
@@ -686,7 +686,7 @@ usage(void)
 {
 
 	(void)fprintf(stderr,
-	"usage: %s [-dnrSsTUvX] [-b bind_address] [-B buffer_length]\n"
+	"usage: %s [-dnrSsTUvX] [-B buffer_length] [-b bind_address]\n"
 	"\t[-f config_file] [-g group]\n"
 	"\t[-m mark_interval] [-P file_list] [-p log_socket\n"
 	"\t[-p log_socket2 ...]] [-t chroot_dir] [-u user]\n",



CVS commit: src/usr.sbin/syslogd

2018-11-05 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Nov  5 08:34:20 UTC 2018

Modified Files:
src/usr.sbin/syslogd: syslogd.c

Log Message:
Make it compilable with gcc


To generate a diff of this commit:
cvs rdiff -u -r1.127 -r1.128 src/usr.sbin/syslogd/syslogd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/syslogd/syslogd.c
diff -u src/usr.sbin/syslogd/syslogd.c:1.127 src/usr.sbin/syslogd/syslogd.c:1.128
--- src/usr.sbin/syslogd/syslogd.c:1.127	Sun Nov  4 20:45:21 2018
+++ src/usr.sbin/syslogd/syslogd.c	Mon Nov  5 08:34:20 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: syslogd.c,v 1.127 2018/11/04 20:45:21 roy Exp $	*/
+/*	$NetBSD: syslogd.c,v 1.128 2018/11/05 08:34:20 martin Exp $	*/
 
 /*
  * Copyright (c) 1983, 1988, 1993, 1994
@@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1983, 19
 #if 0
 static char sccsid[] = "@(#)syslogd.c	8.3 (Berkeley) 4/4/94";
 #else
-__RCSID("$NetBSD: syslogd.c,v 1.127 2018/11/04 20:45:21 roy Exp $");
+__RCSID("$NetBSD: syslogd.c,v 1.128 2018/11/05 08:34:20 martin Exp $");
 #endif
 #endif /* not lint */
 
@@ -75,6 +75,9 @@ __RCSID("$NetBSD: syslogd.c,v 1.127 2018
 #include "syslogd.h"
 #include "extern.h"
 
+/* Minimum size of the logpath socket buffer */
+#define	RCVBUFLEN		16384
+
 #ifndef DISABLE_SIGN
 #include "sign.h"
 struct sign_global_t GlobalSign = {
@@ -493,6 +496,9 @@ getgroup:
 		die(0, 0, NULL);
 	}
 	for (j = 0, pp = LogPaths; *pp; pp++, j++) {
+		int buf_len;
+		socklen_t socklen = sizeof(buf_len);
+
 		DPRINTF(D_NET, "Making unix dgram socket `%s'\n", *pp);
 		unlink(*pp);
 		memset(, 0, sizeof(sunx));
@@ -507,6 +513,19 @@ getgroup:
 		}
 		setsockbuf(funix[j], *pp);
 		DPRINTF(D_NET, "Listening on unix dgram socket `%s'\n", *pp);
+		if (getsockopt(funix[j], SOL_SOCKET, SO_RCVBUF,
+			   _len, ) == -1) {
+			logerror("getsockopt: SO_RCVBUF: `%s'", *pp);
+			continue;
+		}
+		if (buf_len >= RCVBUFLEN)
+			continue;
+		buf_len = RCVBUFLEN;
+		if (setsockopt(funix[j], SOL_SOCKET, SO_RCVBUF,
+			   _len, socklen) == -1) {
+			logerror("setsockopt: SO_RCVBUF: `%s'", *pp);
+			continue;
+		}
 	}
 
 	if ((fklog = open(_PATH_KLOG, O_RDONLY, 0)) < 0) {



CVS commit: src/usr.sbin/syslogd

2018-11-04 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Sun Nov  4 20:45:21 UTC 2018

Modified Files:
src/usr.sbin/syslogd: syslogd.8 syslogd.c

Log Message:
syslogd: allow the reporting of buffer overflows to be disabled.

This generally isn't a good thing, nothing should be discard silently.
However, for systems that don't want big syslogd buffers or are too slow
to log effectively this reporting can now be disabled.


To generate a diff of this commit:
cvs rdiff -u -r1.56 -r1.57 src/usr.sbin/syslogd/syslogd.8
cvs rdiff -u -r1.126 -r1.127 src/usr.sbin/syslogd/syslogd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/syslogd/syslogd.8
diff -u src/usr.sbin/syslogd/syslogd.8:1.56 src/usr.sbin/syslogd/syslogd.8:1.57
--- src/usr.sbin/syslogd/syslogd.8:1.56	Sun Nov  4 20:23:08 2018
+++ src/usr.sbin/syslogd/syslogd.8	Sun Nov  4 20:45:21 2018
@@ -1,4 +1,4 @@
-.\"	$NetBSD: syslogd.8,v 1.56 2018/11/04 20:23:08 roy Exp $
+.\"	$NetBSD: syslogd.8,v 1.57 2018/11/04 20:45:21 roy Exp $
 .\"
 .\" Copyright (c) 1983, 1986, 1991, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -37,7 +37,7 @@
 .Nd log systems messages
 .Sh SYNOPSIS
 .Nm
-.Op Fl dnrSsTUv
+.Op Fl dnrSsTUvX
 .Op Fl b Ar bind_address
 .Op Fl B Ar buffer_length
 .Op Fl f Ar config_file
@@ -65,6 +65,9 @@ which corresponds to it is used.
 Sets the receiving buffer length.
 The default is 16384 bytes.
 If syslogd reports buffer overflow, this needs increasing.
+If you don't care about it being reported, see the
+.Fl X
+option.
 .It Fl d
 Enable debugging to the standard output,
 and do not disassociate from the controlling terminal.
@@ -154,6 +157,8 @@ If specified once, the numeric facility 
 each locally-written message.
 If specified more than once, the names of the facility and priority are
 logged with each locally-written message.
+.It Fl X
+Disable logging of buffer overflow.
 .El
 .Pp
 .Nm

Index: src/usr.sbin/syslogd/syslogd.c
diff -u src/usr.sbin/syslogd/syslogd.c:1.126 src/usr.sbin/syslogd/syslogd.c:1.127
--- src/usr.sbin/syslogd/syslogd.c:1.126	Sun Nov  4 20:23:08 2018
+++ src/usr.sbin/syslogd/syslogd.c	Sun Nov  4 20:45:21 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: syslogd.c,v 1.126 2018/11/04 20:23:08 roy Exp $	*/
+/*	$NetBSD: syslogd.c,v 1.127 2018/11/04 20:45:21 roy Exp $	*/
 
 /*
  * Copyright (c) 1983, 1988, 1993, 1994
@@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1983, 19
 #if 0
 static char sccsid[] = "@(#)syslogd.c	8.3 (Berkeley) 4/4/94";
 #else
-__RCSID("$NetBSD: syslogd.c,v 1.126 2018/11/04 20:23:08 roy Exp $");
+__RCSID("$NetBSD: syslogd.c,v 1.127 2018/11/04 20:45:21 roy Exp $");
 #endif
 #endif /* not lint */
 
@@ -193,6 +193,7 @@ int	SyncKernel = 0;		/* write kernel mes
 int	UniquePriority = 0;	/* only log specified priority */
 int	LogFacPri = 0;		/* put facility and priority in log messages: */
 /* 0=no, 1=numeric, 2=names */
+int	LogOverflow = 1;	/* 0=no, any other value = yes */
 bool	BSDOutputFormat = true;	/* if true emit traditional BSD Syslog lines,
  * otherwise new syslog-protocol lines
  *
@@ -316,7 +317,7 @@ main(int argc, char *argv[])
 	/* should we set LC_TIME="C" to ensure correct timestamps? */
 	(void)setlocale(LC_ALL, "");
 
-	while ((ch = getopt(argc, argv, "b:B:dnsSf:m:o:p:P:ru:g:t:TUv")) != -1)
+	while ((ch = getopt(argc, argv, "b:B:dnsSf:m:o:p:P:ru:g:t:TUvX")) != -1)
 		switch(ch) {
 		case 'b':
 			bindhostname = optarg;
@@ -395,6 +396,9 @@ main(int argc, char *argv[])
 			if (LogFacPri < 2)
 LogFacPri++;
 			break;
+		case 'X':
+			LogOverflow = 0;
+			break;
 		default:
 			usage();
 		}
@@ -663,7 +667,7 @@ usage(void)
 {
 
 	(void)fprintf(stderr,
-	"usage: %s [-dnrSsTUv] [-b bind_address] [-B buffer_length]\n"
+	"usage: %s [-dnrSsTUvX] [-b bind_address] [-B buffer_length]\n"
 	"\t[-f config_file] [-g group]\n"
 	"\t[-m mark_interval] [-P file_list] [-p log_socket\n"
 	"\t[-p log_socket2 ...]] [-t chroot_dir] [-u user]\n",
@@ -712,7 +716,10 @@ dispatch_read_klog(int fd, short event, 
 	if (rv > 0) {
 		klog_linebuf[klog_linebufoff + rv] = '\0';
 		printsys(klog_linebuf);
-	} else if (rv < 0 && errno != EINTR) {
+	} else if (rv < 0 &&
+	errno != EINTR &&
+	(errno != ENOBUFS || LogOverflow))
+	{
 		/*
 		 * /dev/klog has croaked.  Disable the event
 		 * so it won't bother us again.
@@ -756,7 +763,10 @@ dispatch_read_funix(int fd, short event,
 	if (rv > 0) {
 		linebuf[rv] = '\0';
 		printline(LocalFQDN, linebuf, 0);
-	} else if (rv < 0 && errno != EINTR) {
+	} else if (rv < 0 &&
+	errno != EINTR &&
+	(errno != ENOBUFS || LogOverflow))
+	{
 		logerror("recvfrom() unix `%.*s'",
 			(int)SUN_PATHLEN(), myname.sun_path);
 	}
@@ -791,7 +801,9 @@ dispatch_read_finet(int fd, short event,
 	len = sizeof(frominet);
 	rv = recvfrom(fd, linebuf, linebufsize-1, 0,
 	(struct sockaddr *), );
-	if (rv == 0 || (rv < 0 && errno == EINTR))
+	

CVS commit: src/usr.sbin/syslogd

2018-11-04 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Sun Nov  4 20:23:08 UTC 2018

Modified Files:
src/usr.sbin/syslogd: syslogd.8 syslogd.c

Log Message:
syslogd: allow the receiving buffer size to be set.

This allows the admin to try and avoid buffer overflow when a log of
logging appears in bursts.


To generate a diff of this commit:
cvs rdiff -u -r1.55 -r1.56 src/usr.sbin/syslogd/syslogd.8
cvs rdiff -u -r1.125 -r1.126 src/usr.sbin/syslogd/syslogd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/syslogd/syslogd.8
diff -u src/usr.sbin/syslogd/syslogd.8:1.55 src/usr.sbin/syslogd/syslogd.8:1.56
--- src/usr.sbin/syslogd/syslogd.8:1.55	Mon Jul  3 21:35:32 2017
+++ src/usr.sbin/syslogd/syslogd.8	Sun Nov  4 20:23:08 2018
@@ -1,4 +1,4 @@
-.\"	$NetBSD: syslogd.8,v 1.55 2017/07/03 21:35:32 wiz Exp $
+.\"	$NetBSD: syslogd.8,v 1.56 2018/11/04 20:23:08 roy Exp $
 .\"
 .\" Copyright (c) 1983, 1986, 1991, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -29,7 +29,7 @@
 .\"
 .\" from: @(#)syslogd.8	8.1 (Berkeley) 6/6/93
 .\"
-.Dd March 28, 2012
+.Dd November 4, 2018
 .Dt SYSLOGD 8
 .Os
 .Sh NAME
@@ -39,6 +39,7 @@
 .Nm
 .Op Fl dnrSsTUv
 .Op Fl b Ar bind_address
+.Op Fl B Ar buffer_length
 .Op Fl f Ar config_file
 .Op Fl g Ar group
 .Op Fl m Ar mark_interval
@@ -60,6 +61,10 @@ The options are as follows:
 Specify one specific IP address or hostname to bind to.
 If a hostname is specified, the IPv4 or IPv6 address
 which corresponds to it is used.
+.It Fl B Ar buffer_length
+Sets the receiving buffer length.
+The default is 16384 bytes.
+If syslogd reports buffer overflow, this needs increasing.
 .It Fl d
 Enable debugging to the standard output,
 and do not disassociate from the controlling terminal.

Index: src/usr.sbin/syslogd/syslogd.c
diff -u src/usr.sbin/syslogd/syslogd.c:1.125 src/usr.sbin/syslogd/syslogd.c:1.126
--- src/usr.sbin/syslogd/syslogd.c:1.125	Sun May  6 19:16:36 2018
+++ src/usr.sbin/syslogd/syslogd.c	Sun Nov  4 20:23:08 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: syslogd.c,v 1.125 2018/05/06 19:16:36 christos Exp $	*/
+/*	$NetBSD: syslogd.c,v 1.126 2018/11/04 20:23:08 roy Exp $	*/
 
 /*
  * Copyright (c) 1983, 1988, 1993, 1994
@@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1983, 19
 #if 0
 static char sccsid[] = "@(#)syslogd.c	8.3 (Berkeley) 4/4/94";
 #else
-__RCSID("$NetBSD: syslogd.c,v 1.125 2018/05/06 19:16:36 christos Exp $");
+__RCSID("$NetBSD: syslogd.c,v 1.126 2018/11/04 20:23:08 roy Exp $");
 #endif
 #endif /* not lint */
 
@@ -114,6 +114,7 @@ typedef struct deadq_entry {
 #define DQ_TIMO_INIT	2
 
 #define	RCVBUFLEN	16384
+int	buflen = RCVBUFLEN;
 /*
  * Intervals at which we flush out "message repeated" messages,
  * in seconds after previous message is logged.	 After each flush,
@@ -315,11 +316,16 @@ main(int argc, char *argv[])
 	/* should we set LC_TIME="C" to ensure correct timestamps? */
 	(void)setlocale(LC_ALL, "");
 
-	while ((ch = getopt(argc, argv, "b:dnsSf:m:o:p:P:ru:g:t:TUv")) != -1)
+	while ((ch = getopt(argc, argv, "b:B:dnsSf:m:o:p:P:ru:g:t:TUv")) != -1)
 		switch(ch) {
 		case 'b':
 			bindhostname = optarg;
 			break;
+		case 'B':
+			buflen = atoi(optarg);
+			if (buflen < RCVBUFLEN)
+buflen = RCVBUFLEN;
+			break;
 		case 'd':		/* debug */
 			Debug = D_DEFAULT;
 			/* is there a way to read the integer value
@@ -657,7 +663,8 @@ usage(void)
 {
 
 	(void)fprintf(stderr,
-	"usage: %s [-dnrSsTUv] [-b bind_address] [-f config_file] [-g group]\n"
+	"usage: %s [-dnrSsTUv] [-b bind_address] [-B buffer_length]\n"
+	"\t[-f config_file] [-g group]\n"
 	"\t[-m mark_interval] [-P file_list] [-p log_socket\n"
 	"\t[-p log_socket2 ...]] [-t chroot_dir] [-u user]\n",
 	getprogname());
@@ -667,15 +674,15 @@ usage(void)
 static void
 setsockbuf(int fd, const char *name)
 {
-	int buflen;
+	int curbuflen;
 	socklen_t socklen = sizeof(buflen);
-	if (getsockopt(fd, SOL_SOCKET, SO_RCVBUF, , ) == -1) {
+
+	if (getsockopt(fd, SOL_SOCKET, SO_RCVBUF, , ) == -1) {
 		logerror("getsockopt: SO_RCVBUF: `%s'", name);
 		return;
 	}
-	if (buflen >= RCVBUFLEN)
+	if (curbuflen >= buflen)
 		return;
-	buflen = RCVBUFLEN;
 	if (setsockopt(fd, SOL_SOCKET, SO_RCVBUF, , socklen) == -1) {
 		logerror("setsockopt: SO_RCVBUF: `%s'", name);
 		return;



CVS commit: src/usr.sbin/syslogd

2018-05-06 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun May  6 19:16:37 UTC 2018

Modified Files:
src/usr.sbin/syslogd: syslogd.c

Log Message:
grow AF_UNIX receive buffer size


To generate a diff of this commit:
cvs rdiff -u -r1.124 -r1.125 src/usr.sbin/syslogd/syslogd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/syslogd/syslogd.c
diff -u src/usr.sbin/syslogd/syslogd.c:1.124 src/usr.sbin/syslogd/syslogd.c:1.125
--- src/usr.sbin/syslogd/syslogd.c:1.124	Sun Sep 10 13:01:07 2017
+++ src/usr.sbin/syslogd/syslogd.c	Sun May  6 15:16:36 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: syslogd.c,v 1.124 2017/09/10 17:01:07 ginsbach Exp $	*/
+/*	$NetBSD: syslogd.c,v 1.125 2018/05/06 19:16:36 christos Exp $	*/
 
 /*
  * Copyright (c) 1983, 1988, 1993, 1994
@@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1983, 19
 #if 0
 static char sccsid[] = "@(#)syslogd.c	8.3 (Berkeley) 4/4/94";
 #else
-__RCSID("$NetBSD: syslogd.c,v 1.124 2017/09/10 17:01:07 ginsbach Exp $");
+__RCSID("$NetBSD: syslogd.c,v 1.125 2018/05/06 19:16:36 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -113,6 +113,7 @@ typedef struct deadq_entry {
  */
 #define DQ_TIMO_INIT	2
 
+#define	RCVBUFLEN	16384
 /*
  * Intervals at which we flush out "message repeated" messages,
  * in seconds after previous message is logged.	 After each flush,
@@ -272,6 +273,8 @@ static inline void
 #endif /* !DISABLE_TLS */
 static int writev1(int, struct iovec *, size_t);
 
+static void setsockbuf(int, const char *);
+
 /* for make_timestamp() */
 char	timestamp[MAX_TIMESTAMPLEN + 1];
 /*
@@ -492,6 +495,7 @@ getgroup:
 			logerror("Cannot create `%s'", *pp);
 			die(0, 0, NULL);
 		}
+		setsockbuf(funix[j], *pp);
 		DPRINTF(D_NET, "Listening on unix dgram socket `%s'\n", *pp);
 	}
 
@@ -660,6 +664,24 @@ usage(void)
 	exit(1);
 }
 
+static void
+setsockbuf(int fd, const char *name)
+{
+	int buflen;
+	socklen_t socklen = sizeof(buflen);
+	if (getsockopt(fd, SOL_SOCKET, SO_RCVBUF, , ) == -1) {
+		logerror("getsockopt: SO_RCVBUF: `%s'", name);
+		return;
+	}
+	if (buflen >= RCVBUFLEN)
+		return;
+	buflen = RCVBUFLEN;
+	if (setsockopt(fd, SOL_SOCKET, SO_RCVBUF, , socklen) == -1) {
+		logerror("setsockopt: SO_RCVBUF: `%s'", name);
+		return;
+	}
+}
+
 /*
  * Dispatch routine for reading /dev/klog
  *



CVS commit: src/usr.sbin/syslogd

2018-02-08 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Feb  9 02:23:32 UTC 2018

Modified Files:
src/usr.sbin/syslogd: Makefile

Log Message:
only set api compat for 1.0


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/usr.sbin/syslogd/Makefile

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/syslogd/Makefile
diff -u src/usr.sbin/syslogd/Makefile:1.26 src/usr.sbin/syslogd/Makefile:1.27
--- src/usr.sbin/syslogd/Makefile:1.26	Thu Feb  8 13:28:42 2018
+++ src/usr.sbin/syslogd/Makefile	Thu Feb  8 21:23:32 2018
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.26 2018/02/08 18:28:42 jakllsch Exp $
+#	$NetBSD: Makefile,v 1.27 2018/02/09 02:23:32 christos Exp $
 #	from: @(#)Makefile	8.1 (Berkeley) 6/6/93
 .include 
 
@@ -22,7 +22,9 @@ CPPFLAGS+=-DINET6
 .endif
 
 CPPFLAGS+=-DLIBWRAP
+.if ${HAVE_OPENSSL} < 11
 CPPFLAGS+=-DOPENSSL_API_COMPAT=0x1010L
+.endif
 LDADD+=	-lwrap
 DPADD+=	${LIBWRAP}
 



CVS commit: src/usr.sbin/syslogd

2018-02-08 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Thu Feb  8 18:28:42 UTC 2018

Modified Files:
src/usr.sbin/syslogd: Makefile

Log Message:
define OPENSSL_API_COMPAT

(doesn't entirely unbreak build yet)


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/usr.sbin/syslogd/Makefile

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/syslogd/Makefile
diff -u src/usr.sbin/syslogd/Makefile:1.25 src/usr.sbin/syslogd/Makefile:1.26
--- src/usr.sbin/syslogd/Makefile:1.25	Sun May 21 15:28:43 2017
+++ src/usr.sbin/syslogd/Makefile	Thu Feb  8 18:28:42 2018
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.25 2017/05/21 15:28:43 riastradh Exp $
+#	$NetBSD: Makefile,v 1.26 2018/02/08 18:28:42 jakllsch Exp $
 #	from: @(#)Makefile	8.1 (Berkeley) 6/6/93
 .include 
 
@@ -22,6 +22,7 @@ CPPFLAGS+=-DINET6
 .endif
 
 CPPFLAGS+=-DLIBWRAP
+CPPFLAGS+=-DOPENSSL_API_COMPAT=0x1010L
 LDADD+=	-lwrap
 DPADD+=	${LIBWRAP}
 



CVS commit: src/usr.sbin/syslogd

2018-02-08 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Feb  8 17:45:30 UTC 2018

Modified Files:
src/usr.sbin/syslogd: tls.c tls.h

Log Message:
include dh.h in the right spot.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/usr.sbin/syslogd/tls.c
cvs rdiff -u -r1.2 -r1.3 src/usr.sbin/syslogd/tls.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/syslogd/tls.c
diff -u src/usr.sbin/syslogd/tls.c:1.15 src/usr.sbin/syslogd/tls.c:1.16
--- src/usr.sbin/syslogd/tls.c:1.15	Tue Feb  6 17:04:22 2018
+++ src/usr.sbin/syslogd/tls.c	Thu Feb  8 12:45:29 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: tls.c,v 1.15 2018/02/06 22:04:22 maya Exp $	*/
+/*	$NetBSD: tls.c,v 1.16 2018/02/08 17:45:29 christos Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -45,7 +45,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: tls.c,v 1.15 2018/02/06 22:04:22 maya Exp $");
+__RCSID("$NetBSD: tls.c,v 1.16 2018/02/08 17:45:29 christos Exp $");
 
 #ifndef DISABLE_TLS
 #include 
@@ -84,9 +84,6 @@ static const char *TLS_CONN_STATES[] = {
 
 DH *get_dh1024(void);
 /* DH parameter precomputed with "openssl dhparam -C -2 1024" */
-#ifndef HEADER_DH_H
-#include 
-#endif
 DH *
 get_dh1024(void)
 {

Index: src/usr.sbin/syslogd/tls.h
diff -u src/usr.sbin/syslogd/tls.h:1.2 src/usr.sbin/syslogd/tls.h:1.3
--- src/usr.sbin/syslogd/tls.h:1.2	Fri Nov  7 02:36:38 2008
+++ src/usr.sbin/syslogd/tls.h	Thu Feb  8 12:45:29 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: tls.h,v 1.2 2008/11/07 07:36:38 minskim Exp $	*/
+/*	$NetBSD: tls.h,v 1.3 2018/02/08 17:45:29 christos Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -45,6 +45,7 @@
 #include 
 #include 
 #include 
+#include 
 
 /* initial size for TLS inbuf, minimum prefix + linelength
  * guaranteed to be accepted */



CVS commit: src/usr.sbin/syslogd

2018-02-06 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Tue Feb  6 22:04:22 UTC 2018

Modified Files:
src/usr.sbin/syslogd: tls.c

Log Message:
Correct misleading indentation.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/usr.sbin/syslogd/tls.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/syslogd/tls.c
diff -u src/usr.sbin/syslogd/tls.c:1.14 src/usr.sbin/syslogd/tls.c:1.15
--- src/usr.sbin/syslogd/tls.c:1.14	Tue Feb  6 21:36:46 2018
+++ src/usr.sbin/syslogd/tls.c	Tue Feb  6 22:04:22 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: tls.c,v 1.14 2018/02/06 21:36:46 christos Exp $	*/
+/*	$NetBSD: tls.c,v 1.15 2018/02/06 22:04:22 maya Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -45,7 +45,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: tls.c,v 1.14 2018/02/06 21:36:46 christos Exp $");
+__RCSID("$NetBSD: tls.c,v 1.15 2018/02/06 22:04:22 maya Exp $");
 
 #ifndef DISABLE_TLS
 #include 
@@ -116,8 +116,8 @@ get_dh1024(void)
 		goto out;
 	return dh;
 out:
-		DH_free(dh);
-		return NULL;
+	DH_free(dh);
+	return NULL;
 }
 
 #define ST_CHANGE(x, y) do {	\



CVS commit: src/usr.sbin/syslogd

2018-02-06 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Feb  6 21:36:47 UTC 2018

Modified Files:
src/usr.sbin/syslogd: sign.c tls.c

Log Message:
Adjust to OpenSSL-1.1


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/usr.sbin/syslogd/sign.c
cvs rdiff -u -r1.13 -r1.14 src/usr.sbin/syslogd/tls.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/syslogd/sign.c
diff -u src/usr.sbin/syslogd/sign.c:1.6 src/usr.sbin/syslogd/sign.c:1.7
--- src/usr.sbin/syslogd/sign.c:1.6	Tue Feb 10 15:38:15 2015
+++ src/usr.sbin/syslogd/sign.c	Tue Feb  6 16:36:46 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: sign.c,v 1.6 2015/02/10 20:38:15 christos Exp $	*/
+/*	$NetBSD: sign.c,v 1.7 2018/02/06 21:36:46 christos Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -55,7 +55,7 @@
  * 1. check; next draft will be clearer and specify the format as implemented.
  * 2. check; definitely only DSA in this version.
  * 3. remains a problem, so far no statement from authors or WG.
- * 4. check; used EVP_dss1 method implements FIPS.
+ * 4. check; used EVP_sha1 method implements FIPS.
  */
 /*
  * Limitations of this implementation:
@@ -66,7 +66,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: sign.c,v 1.6 2015/02/10 20:38:15 christos Exp $");
+__RCSID("$NetBSD: sign.c,v 1.7 2018/02/06 21:36:46 christos Exp $");
 
 #ifndef DISABLE_SIGN
 #include "syslogd.h"
@@ -99,15 +99,19 @@ sign_global_init(struct filed *Files)
 	EVP_MD_CTX_init(GlobalSign.sigctx);
 
 	/* the signature algorithm depends on the type of key */
-	if (EVP_PKEY_DSA == EVP_PKEY_type(GlobalSign.pubkey->type)) {
-		GlobalSign.sig = EVP_dss1();
+	switch (EVP_PKEY_base_id(GlobalSign.pubkey)) {
+	case EVP_PKEY_DSA:
+		GlobalSign.sig = EVP_sha1();
 		GlobalSign.sig_len_b64 = SIGN_B64SIGLEN_DSS;
-/* this is the place to add non-DSA key types and algorithms
-	} else if (EVP_PKEY_RSA == EVP_PKEY_type(GlobalSign.pubkey->type)) {
+		break;
+#ifdef notyet
+	/* this is the place to add non-DSA key types and algorithms */
+	case EVP_PKEY_RSA:
 		GlobalSign.sig = EVP_sha1();
 		GlobalSign.sig_len_b64 = 28;
-*/
-	} else {
+		break;
+#endif
+	default:
 		logerror("key type not supported for syslog-sign");
 		return false;
 	}
@@ -115,7 +119,6 @@ sign_global_init(struct filed *Files)
 	assert(GlobalSign.keytype == 'C' || GlobalSign.keytype == 'K');
 	assert(GlobalSign.pubkey_b64 && GlobalSign.privkey &&
 	GlobalSign.pubkey);
-	assert(GlobalSign.privkey->pkey.dsa->priv_key);
 
 	GlobalSign.gbc = 0;
 	STAILQ_INIT();
@@ -126,7 +129,7 @@ sign_global_init(struct filed *Files)
 	EVP_MD_CTX_init(GlobalSign.mdctx);
 
 	/* values for SHA-1 */
-	GlobalSign.md = EVP_dss1();
+	GlobalSign.md = EVP_sha1();
 	GlobalSign.md_len_b64 = 28;
 	GlobalSign.ver = "0111";
 
@@ -191,7 +194,7 @@ sign_get_keys(void)
 		 */
 		FREE_SSL(ssl);
 
-		if (EVP_PKEY_DSA != EVP_PKEY_type(pubkey->type)) {
+		if (EVP_PKEY_DSA != EVP_PKEY_base_id(pubkey)) {
 			DPRINTF(D_SIGN, "X.509 cert has no DSA key\n");
 			EVP_PKEY_free(pubkey);
 			privkey = NULL;
@@ -234,8 +237,15 @@ sign_get_keys(void)
 			logerror("EVP_PKEY_new() failed");
 			return false;
 		}
-		dsa = DSA_generate_parameters(SIGN_GENCERT_BITS, NULL, 0,
-			NULL, NULL, NULL, NULL);
+		if ((dsa = DSA_new()) == NULL) {
+			logerror("DSA_new() failed");
+			return false;
+		}
+		if (!DSA_generate_parameters_ex(dsa, SIGN_GENCERT_BITS, NULL, 0,
+			NULL, NULL, NULL)) {
+			logerror("DSA_generate_parameters_ex() failed");
+			return false;
+		}
 		if (!DSA_generate_key(dsa)) {
 			logerror("DSA_generate_key() failed");
 			return false;

Index: src/usr.sbin/syslogd/tls.c
diff -u src/usr.sbin/syslogd/tls.c:1.13 src/usr.sbin/syslogd/tls.c:1.14
--- src/usr.sbin/syslogd/tls.c:1.13	Tue Jan 10 16:05:42 2017
+++ src/usr.sbin/syslogd/tls.c	Tue Feb  6 16:36:46 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: tls.c,v 1.13 2017/01/10 21:05:42 christos Exp $	*/
+/*	$NetBSD: tls.c,v 1.14 2018/02/06 21:36:46 christos Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -45,7 +45,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: tls.c,v 1.13 2017/01/10 21:05:42 christos Exp $");
+__RCSID("$NetBSD: tls.c,v 1.14 2018/02/06 21:36:46 christos Exp $");
 
 #ifndef DISABLE_TLS
 #include 
@@ -104,16 +104,20 @@ get_dh1024(void)
 		0x88,0xEC,0xA6,0xBA,0x9F,0x4F,0x85,0x43 };
 	static const unsigned char dh1024_g[]={ 0x02 };
 	DH *dh;
+	BIGNUM *p, *g;
 
-	if ((dh=DH_new()) == NULL)
+	if ((dh = DH_new()) == NULL)
 		return NULL;
-	dh->p = BN_bin2bn(dh1024_p, sizeof(dh1024_p), NULL);
-	dh->g = BN_bin2bn(dh1024_g, sizeof(dh1024_g), NULL);
-	if ((dh->p == NULL) || (dh->g == NULL)) {
+	p = BN_bin2bn(dh1024_p, sizeof(dh1024_p), NULL);
+	g = BN_bin2bn(dh1024_g, sizeof(dh1024_g), NULL);
+	if (p == NULL || g == NULL)
+		goto out;
+	if (!DH_set0_pqg(dh, p, NULL, g))
+		goto out;
+	return dh;
+out:
 		DH_free(dh);
 		return NULL;
-	}
-	return dh;
 }
 
 #define ST_CHANGE(x, y) do {	

CVS commit: src/usr.sbin/syslogd

2017-09-10 Thread Brian Ginsbach
Module Name:src
Committed By:   ginsbach
Date:   Sun Sep 10 17:01:07 UTC 2017

Modified Files:
src/usr.sbin/syslogd: syslogd.c

Log Message:
Use looked up remote host for remote message without a hostname

An incoming remote message may not necessarily have a hostname
between the timestamp and the message. The the source of the remote
sender is already looked up so use that hostname/IP address rather
than the local hostname.

XXX: pullup-8
XXX: pullup-7
XXX: pullup-6


To generate a diff of this commit:
cvs rdiff -u -r1.123 -r1.124 src/usr.sbin/syslogd/syslogd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/syslogd/syslogd.c
diff -u src/usr.sbin/syslogd/syslogd.c:1.123 src/usr.sbin/syslogd/syslogd.c:1.124
--- src/usr.sbin/syslogd/syslogd.c:1.123	Sat Jun 11 16:55:10 2016
+++ src/usr.sbin/syslogd/syslogd.c	Sun Sep 10 17:01:07 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: syslogd.c,v 1.123 2016/06/11 16:55:10 christos Exp $	*/
+/*	$NetBSD: syslogd.c,v 1.124 2017/09/10 17:01:07 ginsbach Exp $	*/
 
 /*
  * Copyright (c) 1983, 1988, 1993, 1994
@@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1983, 19
 #if 0
 static char sccsid[] = "@(#)syslogd.c	8.3 (Berkeley) 4/4/94";
 #else
-__RCSID("$NetBSD: syslogd.c,v 1.123 2016/06/11 16:55:10 christos Exp $");
+__RCSID("$NetBSD: syslogd.c,v 1.124 2017/09/10 17:01:07 ginsbach Exp $");
 #endif
 #endif /* not lint */
 
@@ -1277,7 +1277,7 @@ printline_bsdsyslog(const char *hname, c
 		} else if (*p == '[' || (*p == ':'
 			&& (*(p+1) == ' ' || *(p+1) == '\0'))) {
 			/* no host in message */
-			buffer->host = LocalFQDN;
+			buffer->host = strdup(hname);
 			buffer->prog = strndup(start, p - start);
 			break;
 		} else {



CVS commit: src/usr.sbin/syslogd

2017-02-21 Thread Abhinav Upadhyay
Module Name:src
Committed By:   abhinav
Date:   Tue Feb 21 18:36:39 UTC 2017

Modified Files:
src/usr.sbin/syslogd: syslog.conf.5

Log Message:
Remove duplicate word from the sentence.


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/usr.sbin/syslogd/syslog.conf.5

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/syslogd/syslog.conf.5
diff -u src/usr.sbin/syslogd/syslog.conf.5:1.23 src/usr.sbin/syslogd/syslog.conf.5:1.24
--- src/usr.sbin/syslogd/syslog.conf.5:1.23	Tue Feb 21 18:28:28 2017
+++ src/usr.sbin/syslogd/syslog.conf.5	Tue Feb 21 18:36:39 2017
@@ -1,4 +1,4 @@
-.\"	$NetBSD: syslog.conf.5,v 1.23 2017/02/21 18:28:28 abhinav Exp $
+.\"	$NetBSD: syslog.conf.5,v 1.24 2017/02/21 18:36:39 abhinav Exp $
 .\"
 .\" Copyright (c) 1990, 1991, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -511,7 +511,7 @@ message containing hashes of previous me
 .Pp
 To detect later manipulation one has to keep a copy of the key used for
 signing (otherwise an attacker could alter the logs and sign them with his
-his own key).
+own key).
 If TLS is used with a DSA key then the same key will be used for signing.
 This is the recommended setup because it makes it easy to have copies of
 the certificate (with the public key) in backups.



CVS commit: src/usr.sbin/syslogd

2017-02-21 Thread Abhinav Upadhyay
Module Name:src
Committed By:   abhinav
Date:   Tue Feb 21 18:28:28 UTC 2017

Modified Files:
src/usr.sbin/syslogd: syslog.conf.5

Log Message:
Fix typos.


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/usr.sbin/syslogd/syslog.conf.5

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/syslogd/syslog.conf.5
diff -u src/usr.sbin/syslogd/syslog.conf.5:1.22 src/usr.sbin/syslogd/syslog.conf.5:1.23
--- src/usr.sbin/syslogd/syslog.conf.5:1.22	Tue Jan  5 00:41:30 2016
+++ src/usr.sbin/syslogd/syslog.conf.5	Tue Feb 21 18:28:28 2017
@@ -1,4 +1,4 @@
-.\"	$NetBSD: syslog.conf.5,v 1.22 2016/01/05 00:41:30 khorben Exp $
+.\"	$NetBSD: syslog.conf.5,v 1.23 2017/02/21 18:28:28 abhinav Exp $
 .\"
 .\" Copyright (c) 1990, 1991, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -330,7 +330,7 @@ program on the named host.
 After the closing bracket a colon
 .Pq Sq \&:
 and a port or service name may be appended.
-Additional options are configured in parantheses in the form of key="value".
+Additional options are configured in parentheses in the form of key="value".
 Recognized keywords are
 .Ar subject ,
 .Ar fingerprint ,
@@ -476,7 +476,7 @@ and the hashes of the certificates given
 On any match the client is authenticated.
 .Sh BUFFERING
 .Xr syslogd 8
-is able to buffer temporary not writeable messages in memory.
+is able to buffer temporary not writable messages in memory.
 To limit the memory consumed for this buffering the following optons may be
 given:
 .Bl -ohang
@@ -590,7 +590,7 @@ mail.*	/var/log/maillog
 
 # Log all messages of level info or higher to another
 # machine using TLS with an alternative portname and a
-# fingerprint for athentication
+# fingerprint for authentication
 *.info			@[logserver]:1234(fingerprint="SHA1:01:02:...")
 
 # Root and Eric get alert and higher messages.



CVS commit: src/usr.sbin/syslogd

2017-01-10 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Jan 10 21:05:42 UTC 2017

Modified Files:
src/usr.sbin/syslogd: tls.c

Log Message:
need 


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/usr.sbin/syslogd/tls.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/syslogd/tls.c
diff -u src/usr.sbin/syslogd/tls.c:1.12 src/usr.sbin/syslogd/tls.c:1.13
--- src/usr.sbin/syslogd/tls.c:1.12	Wed Feb  3 00:34:21 2016
+++ src/usr.sbin/syslogd/tls.c	Tue Jan 10 16:05:42 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: tls.c,v 1.12 2016/02/03 05:34:21 christos Exp $	*/
+/*	$NetBSD: tls.c,v 1.13 2017/01/10 21:05:42 christos Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -45,9 +45,10 @@
  */
 
 #include 
-__RCSID("$NetBSD: tls.c,v 1.12 2016/02/03 05:34:21 christos Exp $");
+__RCSID("$NetBSD: tls.c,v 1.13 2017/01/10 21:05:42 christos Exp $");
 
 #ifndef DISABLE_TLS
+#include 
 #include "syslogd.h"
 #include "tls.h"
 #include 



CVS commit: src/usr.sbin/syslogd

2016-06-11 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Jun 11 16:55:10 UTC 2016

Modified Files:
src/usr.sbin/syslogd: syslogd.c

Log Message:
PR/51234: Onno van der Linden: syslogd sometimes incorrectly handles iso to
bsd time conversion


To generate a diff of this commit:
cvs rdiff -u -r1.122 -r1.123 src/usr.sbin/syslogd/syslogd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/syslogd/syslogd.c
diff -u src/usr.sbin/syslogd/syslogd.c:1.122 src/usr.sbin/syslogd/syslogd.c:1.123
--- src/usr.sbin/syslogd/syslogd.c:1.122	Sat Sep  5 16:19:43 2015
+++ src/usr.sbin/syslogd/syslogd.c	Sat Jun 11 12:55:10 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: syslogd.c,v 1.122 2015/09/05 20:19:43 dholland Exp $	*/
+/*	$NetBSD: syslogd.c,v 1.123 2016/06/11 16:55:10 christos Exp $	*/
 
 /*
  * Copyright (c) 1983, 1988, 1993, 1994
@@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1983, 19
 #if 0
 static char sccsid[] = "@(#)syslogd.c	8.3 (Berkeley) 4/4/94";
 #else
-__RCSID("$NetBSD: syslogd.c,v 1.122 2015/09/05 20:19:43 dholland Exp $");
+__RCSID("$NetBSD: syslogd.c,v 1.123 2016/06/11 16:55:10 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -1745,27 +1745,28 @@ check_timestamp(unsigned char *from_buf,
 		struct tm parsed;
 		time_t timeval;
 		char tsbuf[MAX_TIMESTAMPLEN];
-		int i = 0;
+		int i = 0, j;
 
 		DPRINTF(D_CALL, "check_timestamp(): convert ISO->BSD\n");
 		for(i = 0; i < MAX_TIMESTAMPLEN && from_buf[i] != '\0'
 		&& from_buf[i] != '.' && from_buf[i] != ' '; i++)
 			tsbuf[i] = from_buf[i]; /* copy date & time */
+		j = i;
 		for(; i < MAX_TIMESTAMPLEN && from_buf[i] != '\0'
 		&& from_buf[i] != '+' && from_buf[i] != '-'
 		&& from_buf[i] != 'Z' && from_buf[i] != ' '; i++)
 			;			   /* skip fraction digits */
 		for(; i < MAX_TIMESTAMPLEN && from_buf[i] != '\0'
-		&& from_buf[i] != ':' && from_buf[i] != ' ' ; i++)
-			tsbuf[i] = from_buf[i]; /* copy TZ */
+		&& from_buf[i] != ':' && from_buf[i] != ' ' ; i++, j++)
+			tsbuf[j] = from_buf[i]; /* copy TZ */
 		if (from_buf[i] == ':') i++;	/* skip colon */
 		for(; i < MAX_TIMESTAMPLEN && from_buf[i] != '\0'
-		&& from_buf[i] != ' ' ; i++)
-			tsbuf[i] = from_buf[i]; /* copy TZ */
+		&& from_buf[i] != ' ' ; i++, j++)
+			tsbuf[j] = from_buf[i]; /* copy TZ */
 
 		(void)memset(, 0, sizeof(parsed));
-		parsed.tm_isdst = -1;
 		(void)strptime(tsbuf, "%FT%T%z", );
+		parsed.tm_isdst = -1;
 		timeval = mktime();
 
 		*to_buf = make_timestamp(, false, BSD_TIMESTAMPLEN);



CVS commit: src/usr.sbin/syslogd

2016-02-02 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Feb  3 05:34:21 UTC 2016

Modified Files:
src/usr.sbin/syslogd: tls.c

Log Message:
PR/50751: David Binderman: check bounds before dereferencing.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/usr.sbin/syslogd/tls.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/syslogd/tls.c
diff -u src/usr.sbin/syslogd/tls.c:1.11 src/usr.sbin/syslogd/tls.c:1.12
--- src/usr.sbin/syslogd/tls.c:1.11	Mon May 27 19:15:51 2013
+++ src/usr.sbin/syslogd/tls.c	Wed Feb  3 00:34:21 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: tls.c,v 1.11 2013/05/27 23:15:51 christos Exp $	*/
+/*	$NetBSD: tls.c,v 1.12 2016/02/03 05:34:21 christos Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -45,7 +45,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: tls.c,v 1.11 2013/05/27 23:15:51 christos Exp $");
+__RCSID("$NetBSD: tls.c,v 1.12 2016/02/03 05:34:21 christos Exp $");
 
 #ifndef DISABLE_TLS
 #include "syslogd.h"
@@ -1590,8 +1590,8 @@ tls_split_messages(struct TLS_Incoming_C
 	}
 
 	/* read length prefix, always at start of buffer */
-	while (isdigit((unsigned char)c->inbuf[offset])
-	&& offset < c->read_pos) {
+	while (offset < c->read_pos && isdigit((unsigned char)c->inbuf[offset]))
+	{
 		msglen *= 10;
 		msglen += c->inbuf[offset] - '0';
 		offset++;



CVS commit: src/usr.sbin/syslogd

2016-01-04 Thread Pierre Pronchery
Module Name:src
Committed By:   khorben
Date:   Tue Jan  5 00:41:30 UTC 2016

Modified Files:
src/usr.sbin/syslogd: syslog.conf.5

Log Message:
Typo


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/usr.sbin/syslogd/syslog.conf.5

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/syslogd/syslog.conf.5
diff -u src/usr.sbin/syslogd/syslog.conf.5:1.21 src/usr.sbin/syslogd/syslog.conf.5:1.22
--- src/usr.sbin/syslogd/syslog.conf.5:1.21	Sun Nov 10 00:13:50 2013
+++ src/usr.sbin/syslogd/syslog.conf.5	Tue Jan  5 00:41:30 2016
@@ -1,4 +1,4 @@
-.\"	$NetBSD: syslog.conf.5,v 1.21 2013/11/10 00:13:50 wiz Exp $
+.\"	$NetBSD: syslog.conf.5,v 1.22 2016/01/05 00:41:30 khorben Exp $
 .\"
 .\" Copyright (c) 1990, 1991, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -297,7 +297,7 @@ To ensure that kernel messages are writt
 calls
 .Xr fsync 2
 after writing messages from the kernel.
-Other messages are not synced explcitly.
+Other messages are not synced explicitly.
 You may disable syncing of files specified to receive kernel messages
 by prefixing the pathname with a minus sign
 .Ql - .



CVS commit: src/usr.sbin/syslogd

2015-09-08 Thread Iain Hibbert
Module Name:src
Committed By:   plunky
Date:   Tue Sep  8 18:33:12 UTC 2015

Modified Files:
src/usr.sbin/syslogd: syslogd.h

Log Message:
according to C99 6.5.15 in a conditional expression, both
operands should be of compatible types.

So, use ((void)0) here to match `void dbprintf()'


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/usr.sbin/syslogd/syslogd.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/syslogd/syslogd.h
diff -u src/usr.sbin/syslogd/syslogd.h:1.6 src/usr.sbin/syslogd/syslogd.h:1.7
--- src/usr.sbin/syslogd/syslogd.h:1.6	Sun Feb 15 14:51:57 2015
+++ src/usr.sbin/syslogd/syslogd.h	Tue Sep  8 18:33:12 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: syslogd.h,v 1.6 2015/02/15 14:51:57 joerg Exp $	*/
+/*	$NetBSD: syslogd.h,v 1.7 2015/09/08 18:33:12 plunky Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -154,7 +154,7 @@ char *strndup(const char *str, size_t n)
 void dbprintf(const char *, const char *, size_t, const char *, ...)
 __printflike(4, 5);
 #define DPRINTF(x, ...) /*LINTED null effect */(void)(Debug & (x) \
-? dbprintf(__FILE__, __func__, __LINE__, __VA_ARGS__) : 0)
+? dbprintf(__FILE__, __func__, __LINE__, __VA_ARGS__) : ((void)0))
 #endif
 
 /* shortcuts for libevent */



CVS commit: src/usr.sbin/syslogd

2015-09-05 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Sat Sep  5 20:19:43 UTC 2015

Modified Files:
src/usr.sbin/syslogd: syslogd.c

Log Message:
tidy/fix printing of paths from sockaddr_un


To generate a diff of this commit:
cvs rdiff -u -r1.121 -r1.122 src/usr.sbin/syslogd/syslogd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/syslogd/syslogd.c
diff -u src/usr.sbin/syslogd/syslogd.c:1.121 src/usr.sbin/syslogd/syslogd.c:1.122
--- src/usr.sbin/syslogd/syslogd.c:1.121	Tue Feb 10 20:38:15 2015
+++ src/usr.sbin/syslogd/syslogd.c	Sat Sep  5 20:19:43 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: syslogd.c,v 1.121 2015/02/10 20:38:15 christos Exp $	*/
+/*	$NetBSD: syslogd.c,v 1.122 2015/09/05 20:19:43 dholland Exp $	*/
 
 /*
  * Copyright (c) 1983, 1988, 1993, 1994
@@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1983, 19
 #if 0
 static char sccsid[] = "@(#)syslogd.c	8.3 (Berkeley) 4/4/94";
 #else
-__RCSID("$NetBSD: syslogd.c,v 1.121 2015/02/10 20:38:15 christos Exp $");
+__RCSID("$NetBSD: syslogd.c,v 1.122 2015/09/05 20:19:43 dholland Exp $");
 #endif
 #endif /* not lint */
 
@@ -714,9 +714,11 @@ dispatch_read_funix(int fd, short event,
 		return;
 	}
 
+#define SUN_PATHLEN(su) \
+	((su)->sun_len - (sizeof(*(su)) - sizeof((su)->sun_path)))
+
 	DPRINTF((D_CALL|D_EVENT|D_NET), "Unix socket (%.*s) active (%d, %d %p)"
-		" with linebuf@%p, size %zu)\n", (int)(myname.sun_len
-		- sizeof(myname.sun_len) - sizeof(myname.sun_family)),
+		" with linebuf@%p, size %zu)\n", (int)SUN_PATHLEN(),
 		myname.sun_path, fd, event, ev, linebuf, linebufsize-1);
 
 	sunlen = sizeof(fromunix);
@@ -727,7 +729,7 @@ dispatch_read_funix(int fd, short event,
 		printline(LocalFQDN, linebuf, 0);
 	} else if (rv < 0 && errno != EINTR) {
 		logerror("recvfrom() unix `%.*s'",
-			myname.sun_len, myname.sun_path);
+			(int)SUN_PATHLEN(), myname.sun_path);
 	}
 }
 



CVS commit: src/usr.sbin/syslogd

2015-02-15 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Sun Feb 15 14:51:57 UTC 2015

Modified Files:
src/usr.sbin/syslogd: syslogd.h

Log Message:
Format string annotation.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/usr.sbin/syslogd/syslogd.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/syslogd/syslogd.h
diff -u src/usr.sbin/syslogd/syslogd.h:1.5 src/usr.sbin/syslogd/syslogd.h:1.6
--- src/usr.sbin/syslogd/syslogd.h:1.5	Tue Feb 10 20:38:15 2015
+++ src/usr.sbin/syslogd/syslogd.h	Sun Feb 15 14:51:57 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: syslogd.h,v 1.5 2015/02/10 20:38:15 christos Exp $	*/
+/*	$NetBSD: syslogd.h,v 1.6 2015/02/15 14:51:57 joerg Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -151,7 +151,8 @@ char *strndup(const char *str, size_t n)
 #ifdef NDEBUG
 #define DPRINTF(x, ...) (void)0
 #else
-void dbprintf(const char *, const char *, size_t, const char *, ...);
+void dbprintf(const char *, const char *, size_t, const char *, ...)
+__printflike(4, 5);
 #define DPRINTF(x, ...) /*LINTED null effect */(void)(Debug  (x) \
 ? dbprintf(__FILE__, __func__, __LINE__, __VA_ARGS__) : 0)
 #endif



CVS commit: src/usr.sbin/syslogd

2015-02-10 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Feb 10 20:38:15 UTC 2015

Modified Files:
src/usr.sbin/syslogd: extern.h sign.c syslogd.c syslogd.h

Log Message:
- always set *to_buf to a timestamp, even if there was none reported/parseable
  (Frank Kardel).
- merge the timestamp copying code to one place.
- factor out the debugging printf function.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/usr.sbin/syslogd/extern.h
cvs rdiff -u -r1.5 -r1.6 src/usr.sbin/syslogd/sign.c
cvs rdiff -u -r1.120 -r1.121 src/usr.sbin/syslogd/syslogd.c
cvs rdiff -u -r1.4 -r1.5 src/usr.sbin/syslogd/syslogd.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/syslogd/extern.h
diff -u src/usr.sbin/syslogd/extern.h:1.3 src/usr.sbin/syslogd/extern.h:1.4
--- src/usr.sbin/syslogd/extern.h:1.3	Wed Jun  9 17:55:42 2010
+++ src/usr.sbin/syslogd/extern.h	Tue Feb 10 15:38:15 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: extern.h,v 1.3 2010/06/09 21:55:42 riz Exp $	*/
+/*	$NetBSD: extern.h,v 1.4 2015/02/10 20:38:15 christos Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -73,7 +73,7 @@ extern struct event *allocev(void);
 extern void	send_queue(int __unused, short __unused, void *);
 extern void	schedule_event(struct event **, struct timeval *,
 void (*)(int, short, void *), void *);
-extern char*make_timestamp(time_t *, bool);
+extern char*make_timestamp(time_t *, bool, size_t);
 #ifndef DISABLE_TLS
 extern struct filed *get_f_by_conninfo(struct tls_conn_settings *conn_info);
 #endif

Index: src/usr.sbin/syslogd/sign.c
diff -u src/usr.sbin/syslogd/sign.c:1.5 src/usr.sbin/syslogd/sign.c:1.6
--- src/usr.sbin/syslogd/sign.c:1.5	Tue Jun  5 20:33:45 2012
+++ src/usr.sbin/syslogd/sign.c	Tue Feb 10 15:38:15 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: sign.c,v 1.5 2012/06/06 00:33:45 christos Exp $	*/
+/*	$NetBSD: sign.c,v 1.6 2015/02/10 20:38:15 christos Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -66,7 +66,7 @@
  */
 
 #include sys/cdefs.h
-__RCSID($NetBSD: sign.c,v 1.5 2012/06/06 00:33:45 christos Exp $);
+__RCSID($NetBSD: sign.c,v 1.6 2015/02/10 20:38:15 christos Exp $);
 
 #ifndef DISABLE_SIGN
 #include syslogd.h
@@ -514,7 +514,7 @@ sign_send_certificate_block(struct signa
 		return false;
 
 	DPRINTF((D_CALL|D_SIGN), sign_send_certificate_block(%p)\n, sg);
-	tstamp = make_timestamp(NULL, true);
+	tstamp = make_timestamp(NULL, true, (size_t)-1);
 
 	payload_len = snprintf(payload, sizeof(payload), %s %c %s, tstamp,
 		GlobalSign.keytype, GlobalSign.pubkey_b64);
@@ -801,7 +801,7 @@ sign_msg_sign(struct buf_msg **bufferptr
 
 	/* set up buffer */
 	buffer = buf_msg_new(0);
-	buffer-timestamp = strdup(make_timestamp(NULL, !BSDOutputFormat));
+	buffer-timestamp = make_timestamp(NULL, !BSDOutputFormat, 0);
 	buffer-prog = appname;
 	buffer-pid = include_pid;
 	buffer-recvhost = buffer-host = LocalFQDN;

Index: src/usr.sbin/syslogd/syslogd.c
diff -u src/usr.sbin/syslogd/syslogd.c:1.120 src/usr.sbin/syslogd/syslogd.c:1.121
--- src/usr.sbin/syslogd/syslogd.c:1.120	Mon Aug 18 01:21:16 2014
+++ src/usr.sbin/syslogd/syslogd.c	Tue Feb 10 15:38:15 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: syslogd.c,v 1.120 2014/08/18 05:21:16 jnemeth Exp $	*/
+/*	$NetBSD: syslogd.c,v 1.121 2015/02/10 20:38:15 christos Exp $	*/
 
 /*
  * Copyright (c) 1983, 1988, 1993, 1994
@@ -39,7 +39,7 @@ __COPYRIGHT(@(#) Copyright (c) 1983, 19
 #if 0
 static char sccsid[] = @(#)syslogd.c	8.3 (Berkeley) 4/4/94;
 #else
-__RCSID($NetBSD: syslogd.c,v 1.120 2014/08/18 05:21:16 jnemeth Exp $);
+__RCSID($NetBSD: syslogd.c,v 1.121 2015/02/10 20:38:15 christos Exp $);
 #endif
 #endif /* not lint */
 
@@ -273,9 +273,7 @@ static inline void
 static int writev1(int, struct iovec *, size_t);
 
 /* for make_timestamp() */
-#define TIMESTAMPBUFSIZE 35
-char timestamp[TIMESTAMPBUFSIZE];
-
+char	timestamp[MAX_TIMESTAMPLEN + 1];
 /*
  * Global line buffer.	Since we only process one event at a time,
  * a global one will do.  But for klog, we use own buffer so that
@@ -1045,8 +1043,7 @@ printline_syslogprotocol(const char *hna
 
 	if (flags  ADDDATE) {
 		FREEPTR(buffer-timestamp);
-		buffer-timestamp = strdup(make_timestamp(NULL,
-			!BSDOutputFormat));
+		buffer-timestamp = make_timestamp(NULL, !BSDOutputFormat, 0);
 	}
 
 	start = p;
@@ -1262,8 +1259,7 @@ printline_bsdsyslog(const char *hname, c
 
 	if (flags  ADDDATE || !buffer-timestamp) {
 		FREEPTR(buffer-timestamp);
-		buffer-timestamp = strdup(make_timestamp(NULL,
-			!BSDOutputFormat));
+		buffer-timestamp = make_timestamp(NULL, !BSDOutputFormat, 0);
 	}
 
 	if (*p == ' ') p++; /* SP */
@@ -1421,7 +1417,7 @@ printline_kernelprintf(const char *hname
 		\%s\, \%s\, %d, %d)\n, hname, msg, flags, pri);
 
 	buffer = buf_msg_new(0);
-	buffer-timestamp = strdup(make_timestamp(NULL, !BSDOutputFormat));
+	buffer-timestamp = make_timestamp(NULL, !BSDOutputFormat, 0);
 	buffer-pri = 

CVS commit: src/usr.sbin/syslogd

2014-08-17 Thread John Nemeth
Module Name:src
Committed By:   jnemeth
Date:   Mon Aug 18 05:21:16 UTC 2014

Modified Files:
src/usr.sbin/syslogd: syslogd.c

Log Message:
- when checking hostname of incoming remote messages, fallback to checking
  remote host if the message doesn't contain a hostname
- don't truncate IP addresses when reading syslogd.conf


To generate a diff of this commit:
cvs rdiff -u -r1.119 -r1.120 src/usr.sbin/syslogd/syslogd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/syslogd/syslogd.c
diff -u src/usr.sbin/syslogd/syslogd.c:1.119 src/usr.sbin/syslogd/syslogd.c:1.120
--- src/usr.sbin/syslogd/syslogd.c:1.119	Wed Nov 27 20:48:28 2013
+++ src/usr.sbin/syslogd/syslogd.c	Mon Aug 18 05:21:16 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: syslogd.c,v 1.119 2013/11/27 20:48:28 christos Exp $	*/
+/*	$NetBSD: syslogd.c,v 1.120 2014/08/18 05:21:16 jnemeth Exp $	*/
 
 /*
  * Copyright (c) 1983, 1988, 1993, 1994
@@ -39,7 +39,7 @@ __COPYRIGHT(@(#) Copyright (c) 1983, 19
 #if 0
 static char sccsid[] = @(#)syslogd.c	8.3 (Berkeley) 4/4/94;
 #else
-__RCSID($NetBSD: syslogd.c,v 1.119 2013/11/27 20:48:28 christos Exp $);
+__RCSID($NetBSD: syslogd.c,v 1.120 2014/08/18 05:21:16 jnemeth Exp $);
 #endif
 #endif /* not lint */
 
@@ -1854,21 +1854,22 @@ logmsg(struct buf_msg *buffer)
 	}
 
 	for (f = Files; f; f = f-f_next) {
+		char *h;	/* host to use for comparing */
+
 		/* skip messages that are incorrect priority */
 		if (!MATCH_PRI(f, fac, prilev)
 		|| f-f_pmask[fac] == INTERNAL_NOPRI)
 			continue;
 
 		/* skip messages with the incorrect host name */
-		/* do we compare with host (IMHO correct) or recvhost */
-		/* (compatible)? */
-		if (f-f_host != NULL  buffer-host != NULL) {
-			char shost[MAXHOSTNAMELEN + 1], *h;
-			if (!BSDOutputFormat) {
-h = buffer-host;
-			} else {
-(void)strlcpy(shost, buffer-host,
-sizeof(shost));
+		/* compare with host (which is supposedly more correct), */
+		/* but fallback to recvhost if host is NULL */
+		h = (buffer-host != NULL) ? buffer-host : buffer-recvhost;
+		if (f-f_host != NULL  h != NULL) {
+			char shost[MAXHOSTNAMELEN + 1];
+
+			if (BSDOutputFormat) {
+(void)strlcpy(shost, h, sizeof(shost));
 trim_anydomain(shost);
 h = shost;
 			}
@@ -3740,7 +3741,7 @@ cfline(size_t linenum, const char *line,
 		f-f_host = NULL;
 	else {
 		f-f_host = strdup(host);
-		trim_anydomain(f-f_host);
+		trim_anydomain(f-f_host[1]);	/* skip +/- at beginning */
 	}
 
 	/* save program name, if any */



CVS commit: src/usr.sbin/syslogd

2013-11-27 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Nov 27 20:48:28 UTC 2013

Modified Files:
src/usr.sbin/syslogd: syslogd.c

Log Message:
CID 1132759: Abort on dehumanize_number error on constant built-in string.


To generate a diff of this commit:
cvs rdiff -u -r1.118 -r1.119 src/usr.sbin/syslogd/syslogd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/syslogd/syslogd.c
diff -u src/usr.sbin/syslogd/syslogd.c:1.118 src/usr.sbin/syslogd/syslogd.c:1.119
--- src/usr.sbin/syslogd/syslogd.c:1.118	Mon Nov 11 11:39:21 2013
+++ src/usr.sbin/syslogd/syslogd.c	Wed Nov 27 15:48:28 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: syslogd.c,v 1.118 2013/11/11 16:39:21 christos Exp $	*/
+/*	$NetBSD: syslogd.c,v 1.119 2013/11/27 20:48:28 christos Exp $	*/
 
 /*
  * Copyright (c) 1983, 1988, 1993, 1994
@@ -39,7 +39,7 @@ __COPYRIGHT(@(#) Copyright (c) 1983, 19
 #if 0
 static char sccsid[] = @(#)syslogd.c	8.3 (Berkeley) 4/4/94;
 #else
-__RCSID($NetBSD: syslogd.c,v 1.118 2013/11/11 16:39:21 christos Exp $);
+__RCSID($NetBSD: syslogd.c,v 1.119 2013/11/27 20:48:28 christos Exp $);
 #endif
 #endif /* not lint */
 
@@ -3207,13 +3207,15 @@ read_config_file(FILE *cf, struct filed 
 		if (!TypeInfo[i].queue_length_string
 		|| dehumanize_number(TypeInfo[i].queue_length_string,
 		TypeInfo[i].queue_length) == -1)
-			dehumanize_number(TypeInfo[i].default_length_string,
-	  TypeInfo[i].queue_length);
+			if (dehumanize_number(TypeInfo[i].default_length_string,
+			TypeInfo[i].queue_length) == -1)
+abort();
 		if (!TypeInfo[i].queue_size_string
 		|| dehumanize_number(TypeInfo[i].queue_size_string,
 		TypeInfo[i].queue_size) == -1)
-			dehumanize_number(TypeInfo[i].default_size_string,
-	  TypeInfo[i].queue_size);
+			if (dehumanize_number(TypeInfo[i].default_size_string,
+			TypeInfo[i].queue_size) == -1)
+abort();
 	}
 
 #ifndef DISABLE_SIGN



CVS commit: src/usr.sbin/syslogd

2013-11-11 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Nov 11 16:39:21 UTC 2013

Modified Files:
src/usr.sbin/syslogd: syslogd.c

Log Message:
CID 1128379: Fix TOCTOU, always open the file first with non-blocking I/O,
do that stat later and leave the file as non-blocking because it does not
make a difference for plain files.


To generate a diff of this commit:
cvs rdiff -u -r1.117 -r1.118 src/usr.sbin/syslogd/syslogd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/syslogd/syslogd.c
diff -u src/usr.sbin/syslogd/syslogd.c:1.117 src/usr.sbin/syslogd/syslogd.c:1.118
--- src/usr.sbin/syslogd/syslogd.c:1.117	Sat Nov  9 14:00:18 2013
+++ src/usr.sbin/syslogd/syslogd.c	Mon Nov 11 11:39:21 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: syslogd.c,v 1.117 2013/11/09 19:00:18 christos Exp $	*/
+/*	$NetBSD: syslogd.c,v 1.118 2013/11/11 16:39:21 christos Exp $	*/
 
 /*
  * Copyright (c) 1983, 1988, 1993, 1994
@@ -39,7 +39,7 @@ __COPYRIGHT(@(#) Copyright (c) 1983, 19
 #if 0
 static char sccsid[] = @(#)syslogd.c	8.3 (Berkeley) 4/4/94;
 #else
-__RCSID($NetBSD: syslogd.c,v 1.117 2013/11/09 19:00:18 christos Exp $);
+__RCSID($NetBSD: syslogd.c,v 1.118 2013/11/11 16:39:21 christos Exp $);
 #endif
 #endif /* not lint */
 
@@ -3898,26 +3898,25 @@ cfline(size_t linenum, const char *line,
 			f-f_flags |= FFLAG_SIGN;
 #endif /* !DISABLE_SIGN */
 		(void)strlcpy(f-f_un.f_fname, p, sizeof(f-f_un.f_fname));
-		if (!stat(p, sb)  S_ISFIFO(sb.st_mode)) {
+		if ((f-f_file = open(p, O_WRONLY|O_APPEND|O_NONBLOCK, 0))  0)
+		{
+			f-f_type = F_UNUSED;
+			logerror(%s, p);
+			break;
+		}
+		if (!fstat(f-f_file, sb)  S_ISFIFO(sb.st_mode)) {
 			f-f_file = -1;
 			f-f_type = F_FIFO;
 			break;
 		}
 
-		if ((f-f_file = open(p, O_WRONLY|O_APPEND, 0))  0) {
-			f-f_type = F_UNUSED;
-			logerror(%s, p);
-			break;
-		}
 		if (isatty(f-f_file)) {
 			f-f_type = F_TTY;
 			if (strcmp(p, ctty) == 0)
 f-f_type = F_CONSOLE;
-			if (fcntl(f-f_file, F_SETFL, O_NONBLOCK) == -1)
-logerror(Warning: cannot change tty fd for
- `%s' to non-blocking., p);
 		} else
 			f-f_type = F_FILE;
+
 		if (syncfile)
 			f-f_flags |= FFLAG_SYNC;
 		break;



CVS commit: src/usr.sbin/syslogd

2013-11-09 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Nov  9 18:58:22 UTC 2013

Modified Files:
src/usr.sbin/syslogd: syslogd.c

Log Message:
fix two bugs related to queues (Anthony Mallet)
- the default values are in humanized number form so strtol does not work
- fix reversed size tests


To generate a diff of this commit:
cvs rdiff -u -r1.115 -r1.116 src/usr.sbin/syslogd/syslogd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/syslogd/syslogd.c
diff -u src/usr.sbin/syslogd/syslogd.c:1.115 src/usr.sbin/syslogd/syslogd.c:1.116
--- src/usr.sbin/syslogd/syslogd.c:1.115	Mon May 27 19:15:51 2013
+++ src/usr.sbin/syslogd/syslogd.c	Sat Nov  9 13:58:22 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: syslogd.c,v 1.115 2013/05/27 23:15:51 christos Exp $	*/
+/*	$NetBSD: syslogd.c,v 1.116 2013/11/09 18:58:22 christos Exp $	*/
 
 /*
  * Copyright (c) 1983, 1988, 1993, 1994
@@ -39,7 +39,7 @@ __COPYRIGHT(@(#) Copyright (c) 1983, 19
 #if 0
 static char sccsid[] = @(#)syslogd.c	8.3 (Berkeley) 4/4/94;
 #else
-__RCSID($NetBSD: syslogd.c,v 1.115 2013/05/27 23:15:51 christos Exp $);
+__RCSID($NetBSD: syslogd.c,v 1.116 2013/11/09 18:58:22 christos Exp $);
 #endif
 #endif /* not lint */
 
@@ -3143,13 +3143,13 @@ read_config_file(FILE *cf, struct filed 
 		if (!TypeInfo[i].queue_length_string
 		|| dehumanize_number(TypeInfo[i].queue_length_string,
 		TypeInfo[i].queue_length) == -1)
-			TypeInfo[i].queue_length = strtol(
-			TypeInfo[i].default_length_string, NULL, 10);
+			dehumanize_number(TypeInfo[i].default_length_string,
+	  TypeInfo[i].queue_length);
 		if (!TypeInfo[i].queue_size_string
 		|| dehumanize_number(TypeInfo[i].queue_size_string,
 		TypeInfo[i].queue_size) == -1)
-			TypeInfo[i].queue_size = strtol(
-			TypeInfo[i].default_size_string, NULL, 10);
+			dehumanize_number(TypeInfo[i].default_size_string,
+	  TypeInfo[i].queue_size);
 	}
 
 #ifndef DISABLE_SIGN
@@ -4366,9 +4366,9 @@ message_queue_purge(struct filed *f, siz
 
 	while (removed  del_entries
 	|| (TypeInfo[f-f_type].queue_length != -1
-	 (size_t)TypeInfo[f-f_type].queue_length  f-f_qelements)
+	 (size_t)TypeInfo[f-f_type].queue_length = f-f_qelements)
 	|| (TypeInfo[f-f_type].queue_size != -1
-	 (size_t)TypeInfo[f-f_type].queue_size  f-f_qsize)) {
+	 (size_t)TypeInfo[f-f_type].queue_size = f-f_qsize)) {
 		qentry = find_qentry_to_delete(f-f_qhead, strategy, 0);
 		if (message_queue_remove(f, qentry))
 			removed++;



CVS commit: src/usr.sbin/syslogd

2013-11-09 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Nov  9 19:00:18 UTC 2013

Modified Files:
src/usr.sbin/syslogd: syslog.conf.5 syslogd.c

Log Message:
add support for outputting to FIFO's (Anthony Mallet)


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/usr.sbin/syslogd/syslog.conf.5
cvs rdiff -u -r1.116 -r1.117 src/usr.sbin/syslogd/syslogd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/syslogd/syslog.conf.5
diff -u src/usr.sbin/syslogd/syslog.conf.5:1.19 src/usr.sbin/syslogd/syslog.conf.5:1.20
--- src/usr.sbin/syslogd/syslog.conf.5:1.19	Fri Oct  5 12:15:45 2012
+++ src/usr.sbin/syslogd/syslog.conf.5	Sat Nov  9 14:00:18 2013
@@ -1,4 +1,4 @@
-.\	$NetBSD: syslog.conf.5,v 1.19 2012/10/05 16:15:45 msaitoh Exp $
+.\	$NetBSD: syslog.conf.5,v 1.20 2013/11/09 19:00:18 christos Exp $
 .\
 .\ Copyright (c) 1990, 1991, 1993
 .\	The Regents of the University of California.  All rights reserved.
@@ -286,7 +286,11 @@ There are five forms:
 .Bl -bullet
 .It
 A pathname (beginning with a leading slash).
-Selected messages are appended to the file.
+Selected messages are appended to the file, unless
+pathname points to an existing FIFO special file.
+.Xr syslogd 8
+treats FIFO specially by opening them in non-blocking mode and
+discarding messages sent when no reader is listening on the other side.
 .Pp
 To ensure that kernel messages are written to disk promptly,
 .Xr syslogd 8

Index: src/usr.sbin/syslogd/syslogd.c
diff -u src/usr.sbin/syslogd/syslogd.c:1.116 src/usr.sbin/syslogd/syslogd.c:1.117
--- src/usr.sbin/syslogd/syslogd.c:1.116	Sat Nov  9 13:58:22 2013
+++ src/usr.sbin/syslogd/syslogd.c	Sat Nov  9 14:00:18 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: syslogd.c,v 1.116 2013/11/09 18:58:22 christos Exp $	*/
+/*	$NetBSD: syslogd.c,v 1.117 2013/11/09 19:00:18 christos Exp $	*/
 
 /*
  * Copyright (c) 1983, 1988, 1993, 1994
@@ -39,7 +39,7 @@ __COPYRIGHT(@(#) Copyright (c) 1983, 19
 #if 0
 static char sccsid[] = @(#)syslogd.c	8.3 (Berkeley) 4/4/94;
 #else
-__RCSID($NetBSD: syslogd.c,v 1.116 2013/11/09 18:58:22 christos Exp $);
+__RCSID($NetBSD: syslogd.c,v 1.117 2013/11/09 19:00:18 christos Exp $);
 #endif
 #endif /* not lint */
 
@@ -70,6 +70,7 @@ __RCSID($NetBSD: syslogd.c,v 1.116 2013
  * TLS, syslog-protocol, and syslog-sign code by Martin Schuette.
  */
 #define SYSLOG_NAMES
+#include sys/stat.h
 #include poll.h
 #include syslogd.h
 #include extern.h
@@ -133,7 +134,8 @@ int	repeatinterval[] = { 30, 120, 600 };
 #define F_USERS		5		/* list of users */
 #define F_WALL		6		/* everyone logged on */
 #define F_PIPE		7		/* pipe to program */
-#define F_TLS		8
+#define F_FIFO		8		/* mkfifo(2) file */
+#define F_TLS		9
 
 struct TypeInfo {
 	const char *name;
@@ -155,6 +157,7 @@ struct TypeInfo {
 	{USERS,   NULL,0, NULL,	  0, 0, 0,  1024},
 	{WALL,NULL,0, NULL,	  0, 0, 0,  1024},
 	{PIPE,NULL, 1024, NULL,	 1M, 0, 0, 16384},
+	{FIFO,NULL, 1024, NULL,	 1M, 0, 0, 16384},
 #ifndef DISABLE_TLS
 	{TLS,	NULL,   -1, NULL, 16M, 0, 0, 16384}
 #endif /* !DISABLE_TLS */
@@ -2187,7 +2190,8 @@ fprintlog(struct filed *f, struct buf_ms
 	|| (f-f_type == F_TTY)
 	|| (f-f_type == F_CONSOLE)
 	|| (f-f_type == F_USERS)
-	|| (f-f_type == F_WALL))) {
+	|| (f-f_type == F_WALL)
+	|| (f-f_type == F_FIFO))) {
 		DELREF(buffer);
 		return;
 	}
@@ -2196,7 +2200,8 @@ fprintlog(struct filed *f, struct buf_ms
 	if (qentry
 	 (f-f_type != F_TLS)
 	 (f-f_type != F_PIPE)
-	 (f-f_type != F_FILE)) {
+	 (f-f_type != F_FILE)
+	 (f-f_type != F_FIFO)) {
 		errno = 0;
 		logerror(Warning: unexpected message type %d in buffer,
 		f-f_type);
@@ -2253,6 +2258,7 @@ fprintlog(struct filed *f, struct buf_ms
 		len = linelen - tlsprefixlen;
 		break;
 	case F_PIPE:
+	case F_FIFO:
 	case F_FILE:  /* fallthrough */
 		if (f-f_flags  FFLAG_FULL) {
 			v-iov_base = line + tlsprefixlen;
@@ -2453,6 +2459,60 @@ fprintlog(struct filed *f, struct buf_ms
 		}
 		break;
 
+	case F_FIFO:
+		DPRINTF(D_MISC, Logging to %s %s\n,
+			TypeInfo[f-f_type].name, f-f_un.f_fname);
+		if (f-f_file  0) {
+			f-f_file =
+			  open(f-f_un.f_fname, O_WRONLY|O_NONBLOCK, 0);
+			e = errno;
+			if (f-f_file  0  e == ENXIO) {
+/* Drop messages with no reader */
+if (qentry)
+	message_queue_remove(f, qentry);
+break;
+			}
+		}
+
+		if (f-f_file = 0  writev(f-f_file, iov, v - iov)  0) {
+			e = errno;
+
+			/* Enqueue if the fifo buffer is full */
+			if (e == EAGAIN) {
+if (f-f_lasterror != e)
+	logerror(%s, f-f_un.f_fname);
+f-f_lasterror = e;
+error = true;	/* enqueue on return */
+break;
+			}
+
+			close(f-f_file);
+			f-f_file = -1;
+
+			/* Drop messages with no reader */
+			if (e == EPIPE) {
+if (qentry)
+	message_queue_remove(f, qentry);
+break;
+			}
+		}
+
+		if (f-f_file  0) {
+			f-f_type = F_UNUSED;
+			errno = e;
+			f-f_lasterror 

CVS commit: src/usr.sbin/syslogd

2013-11-09 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Sun Nov 10 00:13:50 UTC 2013

Modified Files:
src/usr.sbin/syslogd: syslog.conf.5

Log Message:
Bump date for FIFO support.


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/usr.sbin/syslogd/syslog.conf.5

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/syslogd/syslog.conf.5
diff -u src/usr.sbin/syslogd/syslog.conf.5:1.20 src/usr.sbin/syslogd/syslog.conf.5:1.21
--- src/usr.sbin/syslogd/syslog.conf.5:1.20	Sat Nov  9 19:00:18 2013
+++ src/usr.sbin/syslogd/syslog.conf.5	Sun Nov 10 00:13:50 2013
@@ -1,4 +1,4 @@
-.\	$NetBSD: syslog.conf.5,v 1.20 2013/11/09 19:00:18 christos Exp $
+.\	$NetBSD: syslog.conf.5,v 1.21 2013/11/10 00:13:50 wiz Exp $
 .\
 .\ Copyright (c) 1990, 1991, 1993
 .\	The Regents of the University of California.  All rights reserved.
@@ -29,7 +29,7 @@
 .\
 .\ from: @(#)syslog.conf.5	8.1 (Berkeley) 6/9/93
 .\
-.Dd October 16, 2012
+.Dd November 9, 2013
 .Dt SYSLOG.CONF 5
 .Os
 .Sh NAME



CVS commit: src/usr.sbin/syslogd

2013-05-27 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon May 27 23:15:51 UTC 2013

Modified Files:
src/usr.sbin/syslogd: syslogd.c syslogd.h tls.c

Log Message:
PR/47861: Fredrik Pettai: keep track of the address family for each socket
opened and don't send the a message to the wrong family type.


To generate a diff of this commit:
cvs rdiff -u -r1.114 -r1.115 src/usr.sbin/syslogd/syslogd.c
cvs rdiff -u -r1.3 -r1.4 src/usr.sbin/syslogd/syslogd.h
cvs rdiff -u -r1.10 -r1.11 src/usr.sbin/syslogd/tls.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/syslogd/syslogd.c
diff -u src/usr.sbin/syslogd/syslogd.c:1.114 src/usr.sbin/syslogd/syslogd.c:1.115
--- src/usr.sbin/syslogd/syslogd.c:1.114	Thu Jan 17 13:54:28 2013
+++ src/usr.sbin/syslogd/syslogd.c	Mon May 27 19:15:51 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: syslogd.c,v 1.114 2013/01/17 18:54:28 christos Exp $	*/
+/*	$NetBSD: syslogd.c,v 1.115 2013/05/27 23:15:51 christos Exp $	*/
 
 /*
  * Copyright (c) 1983, 1988, 1993, 1994
@@ -39,7 +39,7 @@ __COPYRIGHT(@(#) Copyright (c) 1983, 19
 #if 0
 static char sccsid[] = @(#)syslogd.c	8.3 (Berkeley) 4/4/94;
 #else
-__RCSID($NetBSD: syslogd.c,v 1.114 2013/01/17 18:54:28 christos Exp $);
+__RCSID($NetBSD: syslogd.c,v 1.115 2013/05/27 23:15:51 christos Exp $);
 #endif
 #endif /* not lint */
 
@@ -2496,6 +2496,8 @@ udp_send(struct filed *f, char *line, si
 	for (r = f-f_un.f_forw.f_addr; r; r = r-ai_next) {
 		retry = 0;
 		for (j = 0; j  finet-fd; j++) {
+			if (finet[j+1].af != r-ai_family)
+continue;
 sendagain:
 			lsent = sendto(finet[j+1].fd, line, len, 0,
 			r-ai_addr, r-ai_addrlen);
@@ -3994,6 +3996,7 @@ socksetup(int af, const char *hostname)
 			logerror(socket() failed);
 			continue;
 		}
+		s-af = r-ai_family;
 		if (r-ai_family == AF_INET6  setsockopt(s-fd, IPPROTO_IPV6,
 		IPV6_V6ONLY, on, sizeof(on))  0) {
 			logerror(setsockopt(IPV6_V6ONLY) failed);

Index: src/usr.sbin/syslogd/syslogd.h
diff -u src/usr.sbin/syslogd/syslogd.h:1.3 src/usr.sbin/syslogd/syslogd.h:1.4
--- src/usr.sbin/syslogd/syslogd.h:1.3	Mon Apr 20 05:56:08 2009
+++ src/usr.sbin/syslogd/syslogd.h	Mon May 27 19:15:51 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: syslogd.h,v 1.3 2009/04/20 09:56:08 mschuett Exp $	*/
+/*	$NetBSD: syslogd.h,v 1.4 2013/05/27 23:15:51 christos Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -302,6 +302,7 @@ STAILQ_HEAD(buf_queue_head, buf_queue);
 /* a pair of a socket and an associated event object */
 struct socketEvent {
 	int fd;
+	int af;
 	struct event *ev;
 };
 

Index: src/usr.sbin/syslogd/tls.c
diff -u src/usr.sbin/syslogd/tls.c:1.10 src/usr.sbin/syslogd/tls.c:1.11
--- src/usr.sbin/syslogd/tls.c:1.10	Tue Jun  5 20:33:45 2012
+++ src/usr.sbin/syslogd/tls.c	Mon May 27 19:15:51 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: tls.c,v 1.10 2012/06/06 00:33:45 christos Exp $	*/
+/*	$NetBSD: tls.c,v 1.11 2013/05/27 23:15:51 christos Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -45,7 +45,7 @@
  */
 
 #include sys/cdefs.h
-__RCSID($NetBSD: tls.c,v 1.10 2012/06/06 00:33:45 christos Exp $);
+__RCSID($NetBSD: tls.c,v 1.11 2013/05/27 23:15:51 christos Exp $);
 
 #ifndef DISABLE_TLS
 #include syslogd.h
@@ -851,6 +851,7 @@ socksetup_tls(const int af, const char *
 			logerror(socket() failed: %s, strerror(errno));
 			continue;
 		}
+		s-af = r-ai_family;
 		if (r-ai_family == AF_INET6
 		  setsockopt(s-fd, IPPROTO_IPV6, IPV6_V6ONLY,
 			on, sizeof(on)) == -1) {



CVS commit: src/usr.sbin/syslogd

2013-01-17 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Jan 17 18:54:29 UTC 2013

Modified Files:
src/usr.sbin/syslogd: syslogd.c

Log Message:
ut_line does not have /dev in front of it. Add it, from dholland@


To generate a diff of this commit:
cvs rdiff -u -r1.113 -r1.114 src/usr.sbin/syslogd/syslogd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/syslogd/syslogd.c
diff -u src/usr.sbin/syslogd/syslogd.c:1.113 src/usr.sbin/syslogd/syslogd.c:1.114
--- src/usr.sbin/syslogd/syslogd.c:1.113	Tue Jan 15 17:37:04 2013
+++ src/usr.sbin/syslogd/syslogd.c	Thu Jan 17 13:54:28 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: syslogd.c,v 1.113 2013/01/15 22:37:04 christos Exp $	*/
+/*	$NetBSD: syslogd.c,v 1.114 2013/01/17 18:54:28 christos Exp $	*/
 
 /*
  * Copyright (c) 1983, 1988, 1993, 1994
@@ -39,7 +39,7 @@ __COPYRIGHT(@(#) Copyright (c) 1983, 19
 #if 0
 static char sccsid[] = @(#)syslogd.c	8.3 (Berkeley) 4/4/94;
 #else
-__RCSID($NetBSD: syslogd.c,v 1.113 2013/01/15 22:37:04 christos Exp $);
+__RCSID($NetBSD: syslogd.c,v 1.114 2013/01/17 18:54:28 christos Exp $);
 #endif
 #endif /* not lint */
 
@@ -2563,8 +2563,10 @@ wallmsg(struct filed *f, struct iovec *i
 break;
 			if (strcmp(f-f_un.f_uname[i], ep-name) == 0) {
 struct stat st;
-
-if (stat(ep-line, st) != -1 
+char tty[MAXPATHLEN];
+snprintf(tty, sizeof(tty), %s/%s, _PATH_DEV,
+ep-line);
+if (stat(tty, st) != -1 
 (st.st_mode  S_IWGRP) == 0)
 	break;
 



CVS commit: src/usr.sbin/syslogd

2013-01-15 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Jan 15 22:37:04 UTC 2013

Modified Files:
src/usr.sbin/syslogd: syslogd.c

Log Message:
PR/47449: David Holland: Don't log to terminals with mesg n, unless it is a
wall message.


To generate a diff of this commit:
cvs rdiff -u -r1.112 -r1.113 src/usr.sbin/syslogd/syslogd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/syslogd/syslogd.c
diff -u src/usr.sbin/syslogd/syslogd.c:1.112 src/usr.sbin/syslogd/syslogd.c:1.113
--- src/usr.sbin/syslogd/syslogd.c:1.112	Tue Jun 19 21:39:34 2012
+++ src/usr.sbin/syslogd/syslogd.c	Tue Jan 15 17:37:04 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: syslogd.c,v 1.112 2012/06/20 01:39:34 christos Exp $	*/
+/*	$NetBSD: syslogd.c,v 1.113 2013/01/15 22:37:04 christos Exp $	*/
 
 /*
  * Copyright (c) 1983, 1988, 1993, 1994
@@ -39,7 +39,7 @@ __COPYRIGHT(@(#) Copyright (c) 1983, 19
 #if 0
 static char sccsid[] = @(#)syslogd.c	8.3 (Berkeley) 4/4/94;
 #else
-__RCSID($NetBSD: syslogd.c,v 1.112 2012/06/20 01:39:34 christos Exp $);
+__RCSID($NetBSD: syslogd.c,v 1.113 2013/01/15 22:37:04 christos Exp $);
 #endif
 #endif /* not lint */
 
@@ -2562,6 +2562,12 @@ wallmsg(struct filed *f, struct iovec *i
 			if (!f-f_un.f_uname[i][0])
 break;
 			if (strcmp(f-f_un.f_uname[i], ep-name) == 0) {
+struct stat st;
+
+if (stat(ep-line, st) != -1 
+(st.st_mode  S_IWGRP) == 0)
+	break;
+
 if ((p = ttymsg(iov, iovcnt, ep-line,
 TTYMSGTIME)) != NULL) {
 	errno = 0;	/* already in msg */



CVS commit: src/usr.sbin/syslogd

2013-01-13 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Mon Jan 14 03:05:41 UTC 2013

Modified Files:
src/usr.sbin/syslogd: syslogd.8

Log Message:
fix thinko


To generate a diff of this commit:
cvs rdiff -u -r1.53 -r1.54 src/usr.sbin/syslogd/syslogd.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/syslogd/syslogd.8
diff -u src/usr.sbin/syslogd/syslogd.8:1.53 src/usr.sbin/syslogd/syslogd.8:1.54
--- src/usr.sbin/syslogd/syslogd.8:1.53	Tue Oct 30 23:03:02 2012
+++ src/usr.sbin/syslogd/syslogd.8	Mon Jan 14 03:05:41 2013
@@ -1,4 +1,4 @@
-.\	$NetBSD: syslogd.8,v 1.53 2012/10/30 23:03:02 wiz Exp $
+.\	$NetBSD: syslogd.8,v 1.54 2013/01/14 03:05:41 dholland Exp $
 .\
 .\ Copyright (c) 1983, 1986, 1991, 1993
 .\	The Regents of the University of California.  All rights reserved.
@@ -95,7 +95,7 @@ Multiple
 options create multiple log sockets.
 If no
 .Fl p
-arguments are created, the default socket of
+arguments are given, the default socket of
 .Pa /var/run/log
 is used.
 .It Fl r



CVS commit: src/usr.sbin/syslogd

2012-10-30 Thread Radoslaw Kujawa
Module Name:src
Committed By:   rkujawa
Date:   Tue Oct 30 21:24:26 UTC 2012

Modified Files:
src/usr.sbin/syslogd: syslogd.8

Log Message:
Note enchancements that appeared in NetBSD 6.0.


To generate a diff of this commit:
cvs rdiff -u -r1.51 -r1.52 src/usr.sbin/syslogd/syslogd.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/syslogd/syslogd.8
diff -u src/usr.sbin/syslogd/syslogd.8:1.51 src/usr.sbin/syslogd/syslogd.8:1.52
--- src/usr.sbin/syslogd/syslogd.8:1.51	Sun Apr  8 22:00:41 2012
+++ src/usr.sbin/syslogd/syslogd.8	Tue Oct 30 21:24:26 2012
@@ -1,4 +1,4 @@
-.\	$NetBSD: syslogd.8,v 1.51 2012/04/08 22:00:41 wiz Exp $
+.\	$NetBSD: syslogd.8,v 1.52 2012/10/30 21:24:26 rkujawa Exp $
 .\
 .\ Copyright (c) 1983, 1986, 1991, 1993
 .\	The Regents of the University of California.  All rights reserved.
@@ -267,3 +267,6 @@ Support for multiple log sockets appeare
 .Nx 1.4 .
 libwrap support appeared in
 .Nx 1.6 .
+Support for RFC 5424, TLS encryption and authentication, signed messages 
+appeared in
+.Nx 6.0 .



CVS commit: src/usr.sbin/syslogd

2012-10-30 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Tue Oct 30 23:03:02 UTC 2012

Modified Files:
src/usr.sbin/syslogd: syslogd.8

Log Message:
Remove trailing whitespace.


To generate a diff of this commit:
cvs rdiff -u -r1.52 -r1.53 src/usr.sbin/syslogd/syslogd.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/syslogd/syslogd.8
diff -u src/usr.sbin/syslogd/syslogd.8:1.52 src/usr.sbin/syslogd/syslogd.8:1.53
--- src/usr.sbin/syslogd/syslogd.8:1.52	Tue Oct 30 21:24:26 2012
+++ src/usr.sbin/syslogd/syslogd.8	Tue Oct 30 23:03:02 2012
@@ -1,4 +1,4 @@
-.\	$NetBSD: syslogd.8,v 1.52 2012/10/30 21:24:26 rkujawa Exp $
+.\	$NetBSD: syslogd.8,v 1.53 2012/10/30 23:03:02 wiz Exp $
 .\
 .\ Copyright (c) 1983, 1986, 1991, 1993
 .\	The Regents of the University of California.  All rights reserved.
@@ -267,6 +267,6 @@ Support for multiple log sockets appeare
 .Nx 1.4 .
 libwrap support appeared in
 .Nx 1.6 .
-Support for RFC 5424, TLS encryption and authentication, signed messages 
+Support for RFC 5424, TLS encryption and authentication, signed messages
 appeared in
 .Nx 6.0 .



CVS commit: src/usr.sbin/syslogd

2012-10-05 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Fri Oct  5 16:15:45 UTC 2012

Modified Files:
src/usr.sbin/syslogd: syslog.conf.5

Log Message:
RFC 5848


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/usr.sbin/syslogd/syslog.conf.5

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/syslogd/syslog.conf.5
diff -u src/usr.sbin/syslogd/syslog.conf.5:1.18 src/usr.sbin/syslogd/syslog.conf.5:1.19
--- src/usr.sbin/syslogd/syslog.conf.5:1.18	Fri Jan  1 21:44:07 2010
+++ src/usr.sbin/syslogd/syslog.conf.5	Fri Oct  5 16:15:45 2012
@@ -1,4 +1,4 @@
-.\	$NetBSD: syslog.conf.5,v 1.18 2010/01/01 21:44:07 wiz Exp $
+.\	$NetBSD: syslog.conf.5,v 1.19 2012/10/05 16:15:45 msaitoh Exp $
 .\
 .\ Copyright (c) 1990, 1991, 1993
 .\	The Regents of the University of California.  All rights reserved.
@@ -29,7 +29,7 @@
 .\
 .\ from: @(#)syslog.conf.5	8.1 (Berkeley) 6/9/93
 .\
-.Dd January 1, 2010
+.Dd October 16, 2012
 .Dt SYSLOG.CONF 5
 .Os
 .Sh NAME
@@ -500,7 +500,7 @@ and
 .Sh SIGNING
 .Xr syslogd 8
 is able to digitally sign all processed messages.
-The used protocol is defined by RFC  (syslog-sign):
+The used protocol is defined by RFC 5848 (syslog-sign):
 at the start of a session the signing sender sends so called certificate
 blocks containing its public key; after that it periodically sends a signed
 message containing hashes of previous messages.



CVS commit: src/usr.sbin/syslogd

2012-06-19 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Jun 19 13:44:35 UTC 2012

Modified Files:
src/usr.sbin/syslogd: syslogd.c

Log Message:
- fix writev1() to pre-decrement count.
- always open ttys with O_NDELAY.


To generate a diff of this commit:
cvs rdiff -u -r1.110 -r1.111 src/usr.sbin/syslogd/syslogd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/syslogd/syslogd.c
diff -u src/usr.sbin/syslogd/syslogd.c:1.110 src/usr.sbin/syslogd/syslogd.c:1.111
--- src/usr.sbin/syslogd/syslogd.c:1.110	Mon Jun 18 15:17:42 2012
+++ src/usr.sbin/syslogd/syslogd.c	Tue Jun 19 09:44:35 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: syslogd.c,v 1.110 2012/06/18 19:17:42 christos Exp $	*/
+/*	$NetBSD: syslogd.c,v 1.111 2012/06/19 13:44:35 christos Exp $	*/
 
 /*
  * Copyright (c) 1983, 1988, 1993, 1994
@@ -39,7 +39,7 @@ __COPYRIGHT(@(#) Copyright (c) 1983, 19
 #if 0
 static char sccsid[] = @(#)syslogd.c	8.3 (Berkeley) 4/4/94;
 #else
-__RCSID($NetBSD: syslogd.c,v 1.110 2012/06/18 19:17:42 christos Exp $);
+__RCSID($NetBSD: syslogd.c,v 1.111 2012/06/19 13:44:35 christos Exp $);
 #endif
 #endif /* not lint */
 
@@ -2422,7 +2422,7 @@ fprintlog(struct filed *f, struct buf_ms
 			 */
 			if ((e == EIO || e == EBADF)  f-f_type != F_FILE) {
 f-f_file = open(f-f_un.f_fname,
-O_WRONLY|O_APPEND|O_NDELAY, 0);
+O_WRONLY|O_APPEND|O_NDELAY|O_NONBLOCK, 0);
 if (f-f_file  0) {
 	f-f_type = F_UNUSED;
 	logerror(%s, f-f_un.f_fname);
@@ -3822,7 +3822,7 @@ cfline(size_t linenum, const char *line,
 			f-f_flags |= FFLAG_SIGN;
 #endif /* !DISABLE_SIGN */
 		(void)strlcpy(f-f_un.f_fname, p, sizeof(f-f_un.f_fname));
-		if ((f-f_file = open(p, O_WRONLY|O_APPEND, 0))  0) {
+		if ((f-f_file = open(p, O_WRONLY|O_APPEND|O_NDELAY, 0))  0) {
 			f-f_type = F_UNUSED;
 			logerror(%s, p);
 			break;
@@ -4708,6 +4708,8 @@ writev1(int fd, struct iovec *iov, size_
 	ssize_t nw = 0, tot = 0;
 	size_t ntries = 5;
 
+	if (count == 0)
+		return 0;
 	while (ntries--) {
 		switch ((nw = writev(fd, iov, count))) {
 		case -1:
@@ -4718,8 +4720,8 @@ writev1(int fd, struct iovec *iov, size_
 pfd.revents = 0;
 (void)poll(pfd, 1, 500);
 continue;
-			} else
-return -1;
+			}
+			return -1;
 		case 0:
 			return 0;
 		default:
@@ -4727,10 +4729,11 @@ writev1(int fd, struct iovec *iov, size_
 			while (nw  0) {
 if (iov-iov_len  (size_t)nw) {
 	iov-iov_len -= nw;
-	iov-iov_base = (char *)iov-iov_base + nw;
+	iov-iov_base =
+	(char *)iov-iov_base + nw;
 	break;
 } else {
-	if (count-- == 0)
+	if (--count == 0)
 		return tot;
 	nw -= iov-iov_len;
 	iov++;



CVS commit: src/usr.sbin/syslogd

2012-06-19 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Jun 20 01:39:35 UTC 2012

Modified Files:
src/usr.sbin/syslogd: syslogd.c

Log Message:
remove dup O_NDELAY.


To generate a diff of this commit:
cvs rdiff -u -r1.111 -r1.112 src/usr.sbin/syslogd/syslogd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/syslogd/syslogd.c
diff -u src/usr.sbin/syslogd/syslogd.c:1.111 src/usr.sbin/syslogd/syslogd.c:1.112
--- src/usr.sbin/syslogd/syslogd.c:1.111	Tue Jun 19 09:44:35 2012
+++ src/usr.sbin/syslogd/syslogd.c	Tue Jun 19 21:39:34 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: syslogd.c,v 1.111 2012/06/19 13:44:35 christos Exp $	*/
+/*	$NetBSD: syslogd.c,v 1.112 2012/06/20 01:39:34 christos Exp $	*/
 
 /*
  * Copyright (c) 1983, 1988, 1993, 1994
@@ -39,7 +39,7 @@ __COPYRIGHT(@(#) Copyright (c) 1983, 19
 #if 0
 static char sccsid[] = @(#)syslogd.c	8.3 (Berkeley) 4/4/94;
 #else
-__RCSID($NetBSD: syslogd.c,v 1.111 2012/06/19 13:44:35 christos Exp $);
+__RCSID($NetBSD: syslogd.c,v 1.112 2012/06/20 01:39:34 christos Exp $);
 #endif
 #endif /* not lint */
 
@@ -2422,7 +2422,7 @@ fprintlog(struct filed *f, struct buf_ms
 			 */
 			if ((e == EIO || e == EBADF)  f-f_type != F_FILE) {
 f-f_file = open(f-f_un.f_fname,
-O_WRONLY|O_APPEND|O_NDELAY|O_NONBLOCK, 0);
+O_WRONLY|O_APPEND|O_NONBLOCK, 0);
 if (f-f_file  0) {
 	f-f_type = F_UNUSED;
 	logerror(%s, f-f_un.f_fname);
@@ -3822,7 +3822,7 @@ cfline(size_t linenum, const char *line,
 			f-f_flags |= FFLAG_SIGN;
 #endif /* !DISABLE_SIGN */
 		(void)strlcpy(f-f_un.f_fname, p, sizeof(f-f_un.f_fname));
-		if ((f-f_file = open(p, O_WRONLY|O_APPEND|O_NDELAY, 0))  0) {
+		if ((f-f_file = open(p, O_WRONLY|O_APPEND, 0))  0) {
 			f-f_type = F_UNUSED;
 			logerror(%s, p);
 			break;



CVS commit: src/usr.sbin/syslogd

2012-06-18 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Jun 18 19:17:43 UTC 2012

Modified Files:
src/usr.sbin/syslogd: syslogd.c

Log Message:
don't call isatty() to the fd before opening it.


To generate a diff of this commit:
cvs rdiff -u -r1.109 -r1.110 src/usr.sbin/syslogd/syslogd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/syslogd/syslogd.c
diff -u src/usr.sbin/syslogd/syslogd.c:1.109 src/usr.sbin/syslogd/syslogd.c:1.110
--- src/usr.sbin/syslogd/syslogd.c:1.109	Tue Jun  5 20:33:45 2012
+++ src/usr.sbin/syslogd/syslogd.c	Mon Jun 18 15:17:42 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: syslogd.c,v 1.109 2012/06/06 00:33:45 christos Exp $	*/
+/*	$NetBSD: syslogd.c,v 1.110 2012/06/18 19:17:42 christos Exp $	*/
 
 /*
  * Copyright (c) 1983, 1988, 1993, 1994
@@ -39,7 +39,7 @@ __COPYRIGHT(@(#) Copyright (c) 1983, 19
 #if 0
 static char sccsid[] = @(#)syslogd.c	8.3 (Berkeley) 4/4/94;
 #else
-__RCSID($NetBSD: syslogd.c,v 1.109 2012/06/06 00:33:45 christos Exp $);
+__RCSID($NetBSD: syslogd.c,v 1.110 2012/06/18 19:17:42 christos Exp $);
 #endif
 #endif /* not lint */
 
@@ -3608,7 +3608,7 @@ cfline(size_t linenum, const char *line,
 const char *host)
 {
 	struct addrinfo hints, *res;
-	interror, i, pri, syncfile, flags;
+	interror, i, pri, syncfile;
 	const char   *p, *q;
 	char *bp;
 	char   buf[MAXLINE];
@@ -3822,20 +3822,20 @@ cfline(size_t linenum, const char *line,
 			f-f_flags |= FFLAG_SIGN;
 #endif /* !DISABLE_SIGN */
 		(void)strlcpy(f-f_un.f_fname, p, sizeof(f-f_un.f_fname));
+		if ((f-f_file = open(p, O_WRONLY|O_APPEND, 0))  0) {
+			f-f_type = F_UNUSED;
+			logerror(%s, p);
+			break;
+		}
 		if (isatty(f-f_file)) {
 			f-f_type = F_TTY;
 			if (strcmp(p, ctty) == 0)
 f-f_type = F_CONSOLE;
-			flags = O_NDELAY;
-		} else {
+			if (fcntl(f-f_file, F_SETFL, O_NONBLOCK) == -1)
+logerror(Warning: cannot change tty fd for
+ `%s' to non-blocking., p);
+		} else
 			f-f_type = F_FILE;
-			flags = 0;
-		}
-		if ((f-f_file = open(p, O_WRONLY|O_APPEND|flags, 0))  0) {
-			f-f_type = F_UNUSED;
-			logerror(%s, p);
-			break;
-		}
 		if (syncfile)
 			f-f_flags |= FFLAG_SYNC;
 		break;



CVS commit: src/usr.sbin/syslogd

2012-06-05 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Jun  5 19:33:18 UTC 2012

Modified Files:
src/usr.sbin/syslogd: syslogd.c

Log Message:
Open and write to ttys using non-blocking I/O to prevent DoS when hardware
or software flow control prevents tty writes or when the tty line is too
slow to respond.


To generate a diff of this commit:
cvs rdiff -u -r1.107 -r1.108 src/usr.sbin/syslogd/syslogd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/syslogd/syslogd.c
diff -u src/usr.sbin/syslogd/syslogd.c:1.107 src/usr.sbin/syslogd/syslogd.c:1.108
--- src/usr.sbin/syslogd/syslogd.c:1.107	Mon May 14 21:22:50 2012
+++ src/usr.sbin/syslogd/syslogd.c	Tue Jun  5 15:33:17 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: syslogd.c,v 1.107 2012/05/15 01:22:50 christos Exp $	*/
+/*	$NetBSD: syslogd.c,v 1.108 2012/06/05 19:33:17 christos Exp $	*/
 
 /*
  * Copyright (c) 1983, 1988, 1993, 1994
@@ -39,7 +39,7 @@ __COPYRIGHT(@(#) Copyright (c) 1983, 19
 #if 0
 static char sccsid[] = @(#)syslogd.c	8.3 (Berkeley) 4/4/94;
 #else
-__RCSID($NetBSD: syslogd.c,v 1.107 2012/05/15 01:22:50 christos Exp $);
+__RCSID($NetBSD: syslogd.c,v 1.108 2012/06/05 19:33:17 christos Exp $);
 #endif
 #endif /* not lint */
 
@@ -70,6 +70,7 @@ __RCSID($NetBSD: syslogd.c,v 1.107 2012
  * TLS, syslog-protocol, and syslog-sign code by Martin Schuette.
  */
 #define SYSLOG_NAMES
+#include poll.h
 #include syslogd.h
 #include extern.h
 
@@ -266,6 +267,7 @@ void		free_cred_SLIST(struct peer_cred_h
 static inline void
 		free_incoming_tls_sockets(void);
 #endif /* !DISABLE_TLS */
+static int writev1(int, struct iovec *, size_t);
 
 /* for make_timestamp() */
 #define TIMESTAMPBUFSIZE 35
@@ -1835,7 +1837,7 @@ logmsg(struct buf_msg *buffer)
 	/* log the message to the particular outputs */
 	if (!Initialized) {
 		f = consfile;
-		f-f_file = open(ctty, O_WRONLY, 0);
+		f-f_file = open(ctty, O_WRONLY | O_NDELAY, 0);
 
 		if (f-f_file = 0) {
 			DELREF(f-f_prevmsg);
@@ -2404,7 +2406,8 @@ fprintlog(struct filed *f, struct buf_ms
 		DPRINTF(D_MISC, Logging to %s %s\n,
 			TypeInfo[f-f_type].name, f-f_un.f_fname);
 	again:
-		if (writev(f-f_file, iov, v - iov)  0) {
+		if ((f-f_type == F_FILE ? writev(f-f_file, iov, v - iov) :
+		writev1(f-f_file, iov, v - iov))  0) {
 			e = errno;
 			if (f-f_type == F_FILE  e == ENOSPC) {
 int lasterror = f-f_lasterror;
@@ -2419,7 +2422,7 @@ fprintlog(struct filed *f, struct buf_ms
 			 */
 			if ((e == EIO || e == EBADF)  f-f_type != F_FILE) {
 f-f_file = open(f-f_un.f_fname,
-O_WRONLY|O_APPEND, 0);
+O_WRONLY|O_APPEND|O_NDELAY, 0);
 if (f-f_file  0) {
 	f-f_type = F_UNUSED;
 	logerror(%s, f-f_un.f_fname);
@@ -3605,7 +3608,7 @@ cfline(size_t linenum, const char *line,
 const char *host)
 {
 	struct addrinfo hints, *res;
-	interror, i, pri, syncfile;
+	interror, i, pri, syncfile, flags;
 	const char   *p, *q;
 	char *bp;
 	char   buf[MAXLINE];
@@ -3819,19 +3822,22 @@ cfline(size_t linenum, const char *line,
 			f-f_flags |= FFLAG_SIGN;
 #endif /* !DISABLE_SIGN */
 		(void)strlcpy(f-f_un.f_fname, p, sizeof(f-f_un.f_fname));
-		if ((f-f_file = open(p, O_WRONLY|O_APPEND, 0))  0) {
+		if (isatty(f-f_file)) {
+			f-f_type = F_TTY;
+			if (strcmp(p, ctty) == 0)
+f-f_type = F_CONSOLE;
+			flags = O_NDELAY;
+		} else {
+			f-f_type = F_FILE;
+			flags = 0;
+		}
+		if ((f-f_file = open(p, O_WRONLY|O_APPEND|flags, 0))  0) {
 			f-f_type = F_UNUSED;
 			logerror(%s, p);
 			break;
 		}
 		if (syncfile)
 			f-f_flags |= FFLAG_SYNC;
-		if (isatty(f-f_file))
-			f-f_type = F_TTY;
-		else
-			f-f_type = F_FILE;
-		if (strcmp(p, ctty) == 0)
-			f-f_type = F_CONSOLE;
 		break;
 
 	case '|':
@@ -4695,3 +4701,42 @@ copy_config_value_word(char **mem, const
 	*p = ++q;
 	return true;
 }
+
+static int
+writev1(int fd, struct iovec *iov, size_t count)
+{
+	ssize_t nw = 0, tot = 0;
+	size_t ntries = 5;
+
+	while (ntries--) {
+		switch ((nw = writev(fd, iov, count))) {
+		case -1:
+			if (errno == EAGAIN || errno == EWOULDBLOCK) {
+struct pollfd pfd;
+pfd.fd = fd;
+pfd.events = POLLOUT;
+pfd.revents = 0;
+(void)poll(pfd, 1, 500);
+continue;
+			} else
+return -1;
+		case 0:
+			return 0;
+		default:
+			tot += nw;
+			while (nw  0) {
+if (iov-iov_len  nw) {
+	iov-iov_len -= nw;
+	iov-iov_base += nw;
+	break;
+} else {
+	if (count-- == 0)
+		return tot;
+	nw -= iov-iov_len;
+	iov++;
+}
+			}
+		}
+	}
+	return tot == 0 ? nw : tot;
+}



CVS commit: src/usr.sbin/syslogd

2012-06-05 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Jun  6 00:33:45 UTC 2012

Modified Files:
src/usr.sbin/syslogd: Makefile sign.c syslogd.c tls.c

Log Message:
WARNS=4


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/usr.sbin/syslogd/Makefile
cvs rdiff -u -r1.4 -r1.5 src/usr.sbin/syslogd/sign.c
cvs rdiff -u -r1.108 -r1.109 src/usr.sbin/syslogd/syslogd.c
cvs rdiff -u -r1.9 -r1.10 src/usr.sbin/syslogd/tls.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/syslogd/Makefile
diff -u src/usr.sbin/syslogd/Makefile:1.23 src/usr.sbin/syslogd/Makefile:1.24
--- src/usr.sbin/syslogd/Makefile:1.23	Wed Jun  9 17:55:42 2010
+++ src/usr.sbin/syslogd/Makefile	Tue Jun  5 20:33:45 2012
@@ -1,7 +1,8 @@
-#	$NetBSD: Makefile,v 1.23 2010/06/09 21:55:42 riz Exp $
+#	$NetBSD: Makefile,v 1.24 2012/06/06 00:33:45 christos Exp $
 #	from: @(#)Makefile	8.1 (Berkeley) 6/6/93
 .include bsd.own.mk
 
+WARNS?=4
 USE_FORT?= yes	# network server
 
 LINTFLAGS+=-X 132,247,135,259,117,298

Index: src/usr.sbin/syslogd/sign.c
diff -u src/usr.sbin/syslogd/sign.c:1.4 src/usr.sbin/syslogd/sign.c:1.5
--- src/usr.sbin/syslogd/sign.c:1.4	Mon Feb 13 02:40:24 2012
+++ src/usr.sbin/syslogd/sign.c	Tue Jun  5 20:33:45 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: sign.c,v 1.4 2012/02/13 07:40:24 spz Exp $	*/
+/*	$NetBSD: sign.c,v 1.5 2012/06/06 00:33:45 christos Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -66,7 +66,7 @@
  */
 
 #include sys/cdefs.h
-__RCSID($NetBSD: sign.c,v 1.4 2012/02/13 07:40:24 spz Exp $);
+__RCSID($NetBSD: sign.c,v 1.5 2012/06/06 00:33:45 christos Exp $);
 
 #ifndef DISABLE_SIGN
 #include syslogd.h
@@ -154,7 +154,7 @@ sign_global_init(struct filed *Files)
  * GlobalSign.privkey, and GlobalSign.pubkey
  */
 bool
-sign_get_keys()
+sign_get_keys(void)
 {
 	EVP_PKEY *pubkey = NULL, *privkey = NULL;
 	unsigned char *der_pubkey = NULL, *ptr_der_pubkey = NULL;
@@ -447,7 +447,7 @@ sign_sg_init(struct filed *Files)
  * free all SGs for a given algorithm
  */
 void
-sign_global_free()
+sign_global_free(void)
 {
 	struct signature_group_t *sg, *tmp_sg;
 	struct filed_queue *fq, *tmp_fq;
@@ -894,7 +894,7 @@ sign_string_sign(char *line, char **sign
 }
 
 void
-sign_new_reboot_session()
+sign_new_reboot_session(void)
 {
 	struct signature_group_t *sg;
 
@@ -930,7 +930,7 @@ sign_assign_msg_num(struct signature_gro
 
 /* increment gbc, check overflow */
 void
-sign_inc_gbc()
+sign_inc_gbc(void)
 {
 	if (++GlobalSign.gbc  SIGN_MAX_COUNT)
 		sign_new_reboot_session();

Index: src/usr.sbin/syslogd/syslogd.c
diff -u src/usr.sbin/syslogd/syslogd.c:1.108 src/usr.sbin/syslogd/syslogd.c:1.109
--- src/usr.sbin/syslogd/syslogd.c:1.108	Tue Jun  5 15:33:17 2012
+++ src/usr.sbin/syslogd/syslogd.c	Tue Jun  5 20:33:45 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: syslogd.c,v 1.108 2012/06/05 19:33:17 christos Exp $	*/
+/*	$NetBSD: syslogd.c,v 1.109 2012/06/06 00:33:45 christos Exp $	*/
 
 /*
  * Copyright (c) 1983, 1988, 1993, 1994
@@ -39,7 +39,7 @@ __COPYRIGHT(@(#) Copyright (c) 1983, 19
 #if 0
 static char sccsid[] = @(#)syslogd.c	8.3 (Berkeley) 4/4/94;
 #else
-__RCSID($NetBSD: syslogd.c,v 1.108 2012/06/05 19:33:17 christos Exp $);
+__RCSID($NetBSD: syslogd.c,v 1.109 2012/06/06 00:33:45 christos Exp $);
 #endif
 #endif /* not lint */
 
@@ -4725,9 +4725,9 @@ writev1(int fd, struct iovec *iov, size_
 		default:
 			tot += nw;
 			while (nw  0) {
-if (iov-iov_len  nw) {
+if (iov-iov_len  (size_t)nw) {
 	iov-iov_len -= nw;
-	iov-iov_base += nw;
+	iov-iov_base = (char *)iov-iov_base + nw;
 	break;
 } else {
 	if (count-- == 0)

Index: src/usr.sbin/syslogd/tls.c
diff -u src/usr.sbin/syslogd/tls.c:1.9 src/usr.sbin/syslogd/tls.c:1.10
--- src/usr.sbin/syslogd/tls.c:1.9	Mon Feb 13 02:40:24 2012
+++ src/usr.sbin/syslogd/tls.c	Tue Jun  5 20:33:45 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: tls.c,v 1.9 2012/02/13 07:40:24 spz Exp $	*/
+/*	$NetBSD: tls.c,v 1.10 2012/06/06 00:33:45 christos Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -45,7 +45,7 @@
  */
 
 #include sys/cdefs.h
-__RCSID($NetBSD: tls.c,v 1.9 2012/02/13 07:40:24 spz Exp $);
+__RCSID($NetBSD: tls.c,v 1.10 2012/06/06 00:33:45 christos Exp $);
 
 #ifndef DISABLE_TLS
 #include syslogd.h
@@ -143,7 +143,7 @@ getVerifySetting(const char *x509verifys
  * calls die() on serious error.
  */
 char*
-init_global_TLS_CTX()
+init_global_TLS_CTX(void)
 {
 	const char *keyfilename	  = tls_opt.keyfile;
 	const char *certfilename  = tls_opt.certfile;



CVS commit: src/usr.sbin/syslogd

2012-05-14 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue May 15 01:22:51 UTC 2012

Modified Files:
src/usr.sbin/syslogd: syslogd.c

Log Message:
improve error handling.


To generate a diff of this commit:
cvs rdiff -u -r1.106 -r1.107 src/usr.sbin/syslogd/syslogd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/syslogd/syslogd.c
diff -u src/usr.sbin/syslogd/syslogd.c:1.106 src/usr.sbin/syslogd/syslogd.c:1.107
--- src/usr.sbin/syslogd/syslogd.c:1.106	Wed Mar 28 13:39:33 2012
+++ src/usr.sbin/syslogd/syslogd.c	Mon May 14 21:22:50 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: syslogd.c,v 1.106 2012/03/28 17:39:33 christos Exp $	*/
+/*	$NetBSD: syslogd.c,v 1.107 2012/05/15 01:22:50 christos Exp $	*/
 
 /*
  * Copyright (c) 1983, 1988, 1993, 1994
@@ -39,7 +39,7 @@ __COPYRIGHT(@(#) Copyright (c) 1983, 19
 #if 0
 static char sccsid[] = @(#)syslogd.c	8.3 (Berkeley) 4/4/94;
 #else
-__RCSID($NetBSD: syslogd.c,v 1.106 2012/03/28 17:39:33 christos Exp $);
+__RCSID($NetBSD: syslogd.c,v 1.107 2012/05/15 01:22:50 christos Exp $);
 #endif
 #endif /* not lint */
 
@@ -471,7 +471,7 @@ getgroup:
 	if (funixsize == 0)
 		logpath_add(LogPaths, funixsize,
 		funixmaxsize, _PATH_LOG);
-	funix = (int *)malloc(sizeof(int) * funixsize);
+	funix = malloc(sizeof(*funix) * funixsize);
 	if (funix == NULL) {
 		logerror(Couldn't allocate funix descriptors);
 		die(0, 0, NULL);
@@ -505,9 +505,10 @@ getgroup:
 	(void) SSL_library_init();
 	OpenSSL_add_all_digests();
 	/* OpenSSL PRNG needs /dev/urandom, thus initialize before chroot() */
-	if (!RAND_status())
+	if (!RAND_status()) {
+		errno = 0;
 		logerror(Unable to initialize OpenSSL PRNG);
-	else {
+	} else {
 		DPRINTF(D_TLS, Initializing PRNG\n);
 	}
 #endif /* (!defined(DISABLE_TLS)  !defined(DISABLE_SIGN)) */
@@ -526,7 +527,7 @@ getgroup:
 	 * All files are open, we can drop privileges and chroot
 	 */
 	DPRINTF(D_MISC, Attempt to chroot to `%s'\n, root);
-	if (chroot(root)) {
+	if (chroot(root) == -1) {
 		logerror(Failed to chroot to `%s', root);
 		die(0, 0, NULL);
 	}
@@ -2194,7 +2195,9 @@ fprintlog(struct filed *f, struct buf_ms
 	 (f-f_type != F_TLS)
 	 (f-f_type != F_PIPE)
 	 (f-f_type != F_FILE)) {
-		logerror(Warning: unexpected message in buffer);
+		errno = 0;
+		logerror(Warning: unexpected message type %d in buffer,
+		f-f_type);
 		DELREF(buffer);
 		return;
 	}
@@ -2332,8 +2335,8 @@ fprintlog(struct filed *f, struct buf_ms
 			if ((f-f_file = p_open(f-f_un.f_pipe.f_pname,
 			f-f_un.f_pipe.f_pid))  0) {
 f-f_type = F_UNUSED;
-message_queue_freeall(f);
 logerror(%s, f-f_un.f_pipe.f_pname);
+message_queue_freeall(f);
 break;
 			} else if (!qentry) /* prevent recursion */
 SEND_QUEUE(f);
@@ -2362,8 +2365,8 @@ fprintlog(struct filed *f, struct buf_ms
 if ((f-f_file = p_open(f-f_un.f_pipe.f_pname,
  f-f_un.f_pipe.f_pid))  0) {
 	f-f_type = F_UNUSED;
-	message_queue_freeall(f);
 	logerror(%s, f-f_un.f_pipe.f_pname);
+	message_queue_freeall(f);
 	break;
 }
 if (writev(f-f_file, iov, v - iov)  0) {
@@ -3801,6 +3804,7 @@ cfline(size_t linenum, const char *line,
 		error = getaddrinfo(f-f_un.f_forw.f_hname, syslog, hints,
 		res);
 		if (error) {
+			errno = 0;
 			logerror(%s, gai_strerror(error));
 			break;
 		}
@@ -3954,8 +3958,8 @@ socksetup(int af, const char *hostname)
 	hints.ai_socktype = SOCK_DGRAM;
 	error = getaddrinfo(hostname, syslog, hints, res);
 	if (error) {
-		logerror(%s, gai_strerror(error));
 		errno = 0;
+		logerror(%s, gai_strerror(error));
 		die(0, 0, NULL);
 	}
 
@@ -4029,7 +4033,6 @@ p_open(char *prog, pid_t *rpid)
 	int pfd[2], nulldesc, i;
 	pid_t pid;
 	char *argv[4];	/* sh -c cmd NULL */
-	char errmsg[200];
 
 	if (pipe(pfd) == -1)
 		return -1;
@@ -4084,10 +4087,8 @@ p_open(char *prog, pid_t *rpid)
 	 */
 	if (fcntl(pfd[1], F_SETFL, O_NONBLOCK) == -1) {
 		/* This is bad. */
-		(void) snprintf(errmsg, sizeof(errmsg),
-		Warning: cannot change pipe to pid %d to 
+		logerror(Warning: cannot change pipe to pid %d to 
 		non-blocking., (int) pid);
-		logerror(%s, errmsg);
 	}
 	*rpid = pid;
 	return pfd[1];
@@ -4112,7 +4113,6 @@ deadq_enter(pid_t pid, const char *name)
 
 	p = malloc(sizeof(*p));
 	if (p == NULL) {
-		errno = 0;
 		logerror(panic: out of memory!);
 		exit(1);
 	}
@@ -4641,6 +4641,7 @@ copy_config_value_quoted(const char *key
 		return false;
 	q = *p += strlen(keyword);
 	if (!(q = strchr(*p, ''))) {
+		errno = 0;
 		logerror(unterminated \\n);
 		return false;
 	}
@@ -4665,6 +4666,7 @@ copy_config_value(const char *keyword, c
 	while (isspace((unsigned char)**p))
 		*p += 1;
 	if (**p != '=') {
+		errno = 0;
 		logerror(expected \=\ in file %s, line %d, file, line);
 		return false;
 	}



CVS commit: src/usr.sbin/syslogd

2012-03-28 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Mar 28 17:39:33 UTC 2012

Modified Files:
src/usr.sbin/syslogd: syslogd.8 syslogd.c

Log Message:
add aliases for the protocol format


To generate a diff of this commit:
cvs rdiff -u -r1.49 -r1.50 src/usr.sbin/syslogd/syslogd.8
cvs rdiff -u -r1.105 -r1.106 src/usr.sbin/syslogd/syslogd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/syslogd/syslogd.8
diff -u src/usr.sbin/syslogd/syslogd.8:1.49 src/usr.sbin/syslogd/syslogd.8:1.50
--- src/usr.sbin/syslogd/syslogd.8:1.49	Thu Oct 15 16:35:07 2009
+++ src/usr.sbin/syslogd/syslogd.8	Wed Mar 28 13:39:33 2012
@@ -1,4 +1,4 @@
-.\	$NetBSD: syslogd.8,v 1.49 2009/10/15 20:35:07 plunky Exp $
+.\	$NetBSD: syslogd.8,v 1.50 2012/03/28 17:39:33 christos Exp $
 .\
 .\ Copyright (c) 1983, 1986, 1991, 1993
 .\	The Regents of the University of California.  All rights reserved.
@@ -29,7 +29,7 @@
 .\
 .\ from: @(#)syslogd.8	8.1 (Berkeley) 6/6/93
 .\
-.Dd October 15, 2009
+.Dd March 28, 2012
 .Dt SYSLOGD 8
 .Os
 .Sh NAME
@@ -97,9 +97,9 @@ Do not perform hostname lookups; report 
 .It Fl o Ar output_format
 Select output message format.
 .Bl -hang
-.It Em rfc3164
+.It Em bsd , rfc3164
 traditional BSD Syslog format (default)
-.It Em syslog
+.It Em syslog , rfc5424
 new syslog-protocol format
 .El
 .It Fl P

Index: src/usr.sbin/syslogd/syslogd.c
diff -u src/usr.sbin/syslogd/syslogd.c:1.105 src/usr.sbin/syslogd/syslogd.c:1.106
--- src/usr.sbin/syslogd/syslogd.c:1.105	Wed Aug 31 12:25:00 2011
+++ src/usr.sbin/syslogd/syslogd.c	Wed Mar 28 13:39:33 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: syslogd.c,v 1.105 2011/08/31 16:25:00 plunky Exp $	*/
+/*	$NetBSD: syslogd.c,v 1.106 2012/03/28 17:39:33 christos Exp $	*/
 
 /*
  * Copyright (c) 1983, 1988, 1993, 1994
@@ -39,7 +39,7 @@ __COPYRIGHT(@(#) Copyright (c) 1983, 19
 #if 0
 static char sccsid[] = @(#)syslogd.c	8.3 (Berkeley) 4/4/94;
 #else
-__RCSID($NetBSD: syslogd.c,v 1.105 2011/08/31 16:25:00 plunky Exp $);
+__RCSID($NetBSD: syslogd.c,v 1.106 2012/03/28 17:39:33 christos Exp $);
 #endif
 #endif /* not lint */
 
@@ -334,9 +334,10 @@ main(int argc, char *argv[])
 			UseNameService = 0;
 			break;
 		case 'o':		/* message format */
-			if (!strncmp(optarg, rfc3164, sizeof(rfc3164)-1))
+#define EQ(a)		(strncmp(optarg, # a, sizeof(# a) - 1) == 0)
+			if (EQ(bsd) || EQ(rfc3264))
 BSDOutputFormat = true;
-			else if (!strncmp(optarg, syslog, sizeof(syslog)-1))
+			else if (EQ(syslog) || EQ(rfc5424))
 BSDOutputFormat = false;
 			else
 usage();



CVS commit: src/usr.sbin/syslogd

2012-02-12 Thread S.P.Zeidler
Module Name:src
Committed By:   spz
Date:   Mon Feb 13 07:40:24 UTC 2012

Modified Files:
src/usr.sbin/syslogd: sign.c tls.c

Log Message:
fix resource leaks and NULL uses found by Coverity scan.
Releng-ok by riz


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/usr.sbin/syslogd/sign.c
cvs rdiff -u -r1.8 -r1.9 src/usr.sbin/syslogd/tls.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/syslogd/sign.c
diff -u src/usr.sbin/syslogd/sign.c:1.3 src/usr.sbin/syslogd/sign.c:1.4
--- src/usr.sbin/syslogd/sign.c:1.3	Sun Jan 18 10:35:26 2009
+++ src/usr.sbin/syslogd/sign.c	Mon Feb 13 07:40:24 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: sign.c,v 1.3 2009/01/18 10:35:26 lukem Exp $	*/
+/*	$NetBSD: sign.c,v 1.4 2012/02/13 07:40:24 spz Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -66,7 +66,7 @@
  */
 
 #include sys/cdefs.h
-__RCSID($NetBSD: sign.c,v 1.3 2009/01/18 10:35:26 lukem Exp $);
+__RCSID($NetBSD: sign.c,v 1.4 2012/02/13 07:40:24 spz Exp $);
 
 #ifndef DISABLE_SIGN
 #include syslogd.h
@@ -258,6 +258,8 @@ sign_get_keys()
 		}
 		if (i2d_DSA_PUBKEY(dsa, ptr_der_pubkey) = 0) {
 			logerror(i2d_DSA_PUBKEY() failed);
+			free(der_pubkey);
+			free(pubkey_b64);
 			return false;
 		}
 		b64_ntop(der_pubkey, der_len, pubkey_b64, der_len*2);

Index: src/usr.sbin/syslogd/tls.c
diff -u src/usr.sbin/syslogd/tls.c:1.8 src/usr.sbin/syslogd/tls.c:1.9
--- src/usr.sbin/syslogd/tls.c:1.8	Fri Oct  7 10:50:01 2011
+++ src/usr.sbin/syslogd/tls.c	Mon Feb 13 07:40:24 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: tls.c,v 1.8 2011/10/07 10:50:01 joerg Exp $	*/
+/*	$NetBSD: tls.c,v 1.9 2012/02/13 07:40:24 spz Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -45,7 +45,7 @@
  */
 
 #include sys/cdefs.h
-__RCSID($NetBSD: tls.c,v 1.8 2011/10/07 10:50:01 joerg Exp $);
+__RCSID($NetBSD: tls.c,v 1.9 2012/02/13 07:40:24 spz Exp $);
 
 #ifndef DISABLE_TLS
 #include syslogd.h
@@ -1139,7 +1139,8 @@ parse_tls_destination(const char *p, str
 		calloc(1, sizeof(*f-f_un.f_tls.tls_conn)))
 	 || !(f-f_un.f_tls.tls_conn-event = allocev())
 	 || !(f-f_un.f_tls.tls_conn-retryevent = allocev())) {
-		free(f-f_un.f_tls.tls_conn-event);
+		if (f-f_un.f_tls.tls_conn)
+			free(f-f_un.f_tls.tls_conn-event);
 		free(f-f_un.f_tls.tls_conn);
 		logerror(Couldn't allocate memory for TLS config);
 		return false;
@@ -1409,7 +1410,8 @@ dispatch_socket_accept(int fd, short eve
 	if (!(conn_info = calloc(1, sizeof(*conn_info)))
 	|| !(conn_info-event = allocev())
 	|| !(conn_info-retryevent = allocev())) {
-		free(conn_info-event);
+		if (conn_info)
+			free(conn_info-event);
 		free(conn_info);
 		SSL_free(ssl);
 		close(newsock);
@@ -1968,10 +1970,13 @@ write_x509files(EVP_PKEY *pkey, X509 *ce
 {
 	FILE *certfile, *keyfile;
 
-	if (!(umask(0177),(keyfile  = fopen(keyfilename,  a)))
-	|| !(umask(0122),(certfile = fopen(certfilename, a {
-		logerror(Unable to write to files \%s\ and \%s\,
-		keyfilename, certfilename);
+	if (!(umask(0177),(keyfile  = fopen(keyfilename,  a {
+		logerror(Unable to write to file \%s\, keyfilename);
+		return false;
+	}
+	if (!(umask(0122),(certfile = fopen(certfilename, a {
+		logerror(Unable to write to file \%s\, certfilename);
+		(void)fclose(keyfile);
 		return false;
 	}
 	if (!PEM_write_PrivateKey(keyfile, pkey, NULL, NULL, 0, NULL, NULL))



CVS commit: src/usr.sbin/syslogd

2011-10-07 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Fri Oct  7 10:50:01 UTC 2011

Modified Files:
src/usr.sbin/syslogd: tls.c

Log Message:
Simplify.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/usr.sbin/syslogd/tls.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/syslogd/tls.c
diff -u src/usr.sbin/syslogd/tls.c:1.7 src/usr.sbin/syslogd/tls.c:1.8
--- src/usr.sbin/syslogd/tls.c:1.7	Mon Aug  1 12:28:53 2011
+++ src/usr.sbin/syslogd/tls.c	Fri Oct  7 10:50:01 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: tls.c,v 1.7 2011/08/01 12:28:53 mbalmer Exp $	*/
+/*	$NetBSD: tls.c,v 1.8 2011/10/07 10:50:01 joerg Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -45,7 +45,7 @@
  */
 
 #include sys/cdefs.h
-__RCSID($NetBSD: tls.c,v 1.7 2011/08/01 12:28:53 mbalmer Exp $);
+__RCSID($NetBSD: tls.c,v 1.8 2011/10/07 10:50:01 joerg Exp $);
 
 #ifndef DISABLE_TLS
 #include syslogd.h
@@ -1368,8 +1368,9 @@ dispatch_socket_accept(int fd, short eve
 		peername = NULL;
 	}
 	else {
-		MALLOC(peername, strlen(hbuf)+1);
-		(void)strlcpy(peername, hbuf, strlen(hbuf)+1);
+		size_t len = strlen(hbuf) + 1;
+		MALLOC(peername, len);
+		(void)memcpy(peername, hbuf, len);
 	}
 
 #ifdef LIBWRAP



CVS commit: src/usr.sbin/syslogd

2011-06-20 Thread enami tsugutomo
Module Name:src
Committed By:   enami
Date:   Mon Jun 20 08:27:15 UTC 2011

Modified Files:
src/usr.sbin/syslogd: syslogd.c

Log Message:
Now need to use own buffer for klog read due to previous change.


To generate a diff of this commit:
cvs rdiff -u -r1.103 -r1.104 src/usr.sbin/syslogd/syslogd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/syslogd/syslogd.c
diff -u src/usr.sbin/syslogd/syslogd.c:1.103 src/usr.sbin/syslogd/syslogd.c:1.104
--- src/usr.sbin/syslogd/syslogd.c:1.103	Mon Jun 20 00:42:11 2011
+++ src/usr.sbin/syslogd/syslogd.c	Mon Jun 20 08:27:15 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: syslogd.c,v 1.103 2011/06/20 00:42:11 enami Exp $	*/
+/*	$NetBSD: syslogd.c,v 1.104 2011/06/20 08:27:15 enami Exp $	*/
 
 /*
  * Copyright (c) 1983, 1988, 1993, 1994
@@ -39,7 +39,7 @@
 #if 0
 static char sccsid[] = @(#)syslogd.c	8.3 (Berkeley) 4/4/94;
 #else
-__RCSID($NetBSD: syslogd.c,v 1.103 2011/06/20 00:42:11 enami Exp $);
+__RCSID($NetBSD: syslogd.c,v 1.104 2011/06/20 08:27:15 enami Exp $);
 #endif
 #endif /* not lint */
 
@@ -273,10 +273,11 @@
 
 /*
  * Global line buffer.	Since we only process one event at a time,
- * a global one will do.
+ * a global one will do.  But for klog, we use own buffer so that
+ * partial line at the end of buffer can be deferred.
  */
-char *linebuf;
-size_t linebufsize, linebufoff;
+char *linebuf, *klog_linebuf;
+size_t linebufsize, klog_linebufoff;
 
 static const char *bindhostname = NULL;
 
@@ -457,6 +458,11 @@
 		logerror(Couldn't allocate buffer);
 		die(0, 0, NULL);
 	}
+	if (!(klog_linebuf = malloc(linebufsize))) {
+		logerror(Couldn't allocate buffer for klog);
+		die(0, 0, NULL);
+	}
+
 
 #ifndef SUN_LEN
 #define SUN_LEN(unp) (strlen((unp)-sun_path) + 2)
@@ -662,16 +668,16 @@
 dispatch_read_klog(int fd, short event, void *ev)
 {
 	ssize_t rv;
-	size_t resid = linebufsize - linebufoff;
+	size_t resid = linebufsize - klog_linebufoff;
 
 	DPRINTF((D_CALL|D_EVENT), Kernel log active (%d, %d, %p)
 		 with linebuf@%p, length %zu)\n, fd, event, ev,
-		linebuf, linebufsize);
+		klog_linebuf, linebufsize);
 
-	rv = read(fd, linebuf[linebufoff], resid - 1);
+	rv = read(fd, klog_linebuf[klog_linebufoff], resid - 1);
 	if (rv  0) {
-		linebuf[linebufoff + rv] = '\0';
-		printsys(linebuf);
+		klog_linebuf[klog_linebufoff + rv] = '\0';
+		printsys(klog_linebuf);
 	} else if (rv  0  errno != EINTR) {
 		/*
 		 * /dev/klog has croaked.  Disable the event
@@ -1504,7 +1510,7 @@
 	char *p, *q;
 	struct buf_msg *buffer;
 
-	linebufoff = 0;
+	klog_linebufoff = 0;
 	for (p = msg; *p != '\0'; ) {
 		bool bsdsyslog = true;
 
@@ -1537,7 +1543,7 @@
 		if (*q != '\0')
 			*q++ = '\0';
 		else {
-			memcpy(linebuf, p, linebufoff = q - p);
+			memcpy(linebuf, p, klog_linebufoff = q - p);
 			break;
 		}
 



CVS commit: src/usr.sbin/syslogd

2011-06-19 Thread enami tsugutomo
Module Name:src
Committed By:   enami
Date:   Mon Jun 20 00:42:12 UTC 2011

Modified Files:
src/usr.sbin/syslogd: syslogd.c

Log Message:
Defer the processing of incomplete line at the end of buffer so that
kernel printf messages logged to /var/log/messages become always
easier to read.


To generate a diff of this commit:
cvs rdiff -u -r1.102 -r1.103 src/usr.sbin/syslogd/syslogd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/syslogd/syslogd.c
diff -u src/usr.sbin/syslogd/syslogd.c:1.102 src/usr.sbin/syslogd/syslogd.c:1.103
--- src/usr.sbin/syslogd/syslogd.c:1.102	Tue May 24 13:26:04 2011
+++ src/usr.sbin/syslogd/syslogd.c	Mon Jun 20 00:42:11 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: syslogd.c,v 1.102 2011/05/24 13:26:04 joerg Exp $	*/
+/*	$NetBSD: syslogd.c,v 1.103 2011/06/20 00:42:11 enami Exp $	*/
 
 /*
  * Copyright (c) 1983, 1988, 1993, 1994
@@ -39,7 +39,7 @@
 #if 0
 static char sccsid[] = @(#)syslogd.c	8.3 (Berkeley) 4/4/94;
 #else
-__RCSID($NetBSD: syslogd.c,v 1.102 2011/05/24 13:26:04 joerg Exp $);
+__RCSID($NetBSD: syslogd.c,v 1.103 2011/06/20 00:42:11 enami Exp $);
 #endif
 #endif /* not lint */
 
@@ -276,7 +276,7 @@
  * a global one will do.
  */
 char *linebuf;
-size_t linebufsize;
+size_t linebufsize, linebufoff;
 
 static const char *bindhostname = NULL;
 
@@ -662,14 +662,15 @@
 dispatch_read_klog(int fd, short event, void *ev)
 {
 	ssize_t rv;
+	size_t resid = linebufsize - linebufoff;
 
 	DPRINTF((D_CALL|D_EVENT), Kernel log active (%d, %d, %p)
 		 with linebuf@%p, length %zu)\n, fd, event, ev,
 		linebuf, linebufsize);
 
-	rv = read(fd, linebuf, linebufsize - 1);
+	rv = read(fd, linebuf[linebufoff], resid - 1);
 	if (rv  0) {
-		linebuf[rv] = '\0';
+		linebuf[linebufoff + rv] = '\0';
 		printsys(linebuf);
 	} else if (rv  0  errno != EINTR) {
 		/*
@@ -1503,6 +1504,7 @@
 	char *p, *q;
 	struct buf_msg *buffer;
 
+	linebufoff = 0;
 	for (p = msg; *p != '\0'; ) {
 		bool bsdsyslog = true;
 
@@ -1534,6 +1536,10 @@
 			 * trust the kernel to send ASCII only */;
 		if (*q != '\0')
 			*q++ = '\0';
+		else {
+			memcpy(linebuf, p, linebufoff = q - p);
+			break;
+		}
 
 		if (pri ~ (LOG_FACMASK|LOG_PRIMASK))
 			pri = DEFSPRI;



CVS commit: src/usr.sbin/syslogd

2011-05-24 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Tue May 24 13:25:25 UTC 2011

Modified Files:
src/usr.sbin/syslogd: syslogd.c

Log Message:
Properly use format strings


To generate a diff of this commit:
cvs rdiff -u -r1.100 -r1.101 src/usr.sbin/syslogd/syslogd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/syslogd/syslogd.c
diff -u src/usr.sbin/syslogd/syslogd.c:1.100 src/usr.sbin/syslogd/syslogd.c:1.101
--- src/usr.sbin/syslogd/syslogd.c:1.100	Wed Jun  9 21:55:42 2010
+++ src/usr.sbin/syslogd/syslogd.c	Tue May 24 13:25:25 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: syslogd.c,v 1.100 2010/06/09 21:55:42 riz Exp $	*/
+/*	$NetBSD: syslogd.c,v 1.101 2011/05/24 13:25:25 joerg Exp $	*/
 
 /*
  * Copyright (c) 1983, 1988, 1993, 1994
@@ -39,7 +39,7 @@
 #if 0
 static char sccsid[] = @(#)syslogd.c	8.3 (Berkeley) 4/4/94;
 #else
-__RCSID($NetBSD: syslogd.c,v 1.100 2010/06/09 21:55:42 riz Exp $);
+__RCSID($NetBSD: syslogd.c,v 1.101 2011/05/24 13:25:25 joerg Exp $);
 #endif
 #endif /* not lint */
 
@@ -2320,7 +2320,7 @@
 			f-f_un.f_pipe.f_pid))  0) {
 f-f_type = F_UNUSED;
 message_queue_freeall(f);
-logerror(f-f_un.f_pipe.f_pname);
+logerror(%s, f-f_un.f_pipe.f_pname);
 break;
 			} else if (!qentry) /* prevent recursion */
 SEND_QUEUE(f);
@@ -2350,7 +2350,7 @@
  f-f_un.f_pipe.f_pid))  0) {
 	f-f_type = F_UNUSED;
 	message_queue_freeall(f);
-	logerror(f-f_un.f_pipe.f_pname);
+	logerror(%s, f-f_un.f_pipe.f_pname);
 	break;
 }
 if (writev(f-f_file, iov, v - iov)  0) {
@@ -2367,7 +2367,7 @@
 			}
 			if (e != 0  !error) {
 errno = e;
-logerror(f-f_un.f_pipe.f_pname);
+logerror(%s, f-f_un.f_pipe.f_pname);
 			}
 		}
 		if (e == 0  qentry) { /* sent buffered msg */
@@ -2394,7 +2394,7 @@
 int lasterror = f-f_lasterror;
 f-f_lasterror = e;
 if (lasterror != e)
-	logerror(f-f_un.f_fname);
+	logerror(%s, f-f_un.f_fname);
 error = true;	/* enqueue on return */
 			}
 			(void)close(f-f_file);
@@ -2406,7 +2406,7 @@
 O_WRONLY|O_APPEND, 0);
 if (f-f_file  0) {
 	f-f_type = F_UNUSED;
-	logerror(f-f_un.f_fname);
+	logerror(%s, f-f_un.f_fname);
 	message_queue_freeall(f);
 } else
 	goto again;
@@ -2414,7 +2414,7 @@
 f-f_type = F_UNUSED;
 errno = e;
 f-f_lasterror = e;
-logerror(f-f_un.f_fname);
+logerror(%s, f-f_un.f_fname);
 message_queue_freeall(f);
 			}
 		} else {
@@ -2534,7 +2534,7 @@
 			if ((p = ttymsg(iov, iovcnt, ep-line, TTYMSGTIME))
 			!= NULL) {
 errno = 0;	/* already in msg */
-logerror(p);
+logerror(%s, p);
 			}
 			continue;
 		}
@@ -2546,7 +2546,7 @@
 if ((p = ttymsg(iov, iovcnt, ep-line,
 TTYMSGTIME)) != NULL) {
 	errno = 0;	/* already in msg */
-	logerror(p);
+	logerror(%s, p);
 }
 break;
 			}
@@ -3548,7 +3548,7 @@
 
 #ifndef DISABLE_TLS
 	if (tls_status_msg) {
-		loginfo(tls_status_msg);
+		loginfo(%s, tls_status_msg);
 		free(tls_status_msg);
 	}
 	DPRINTF((D_NET|D_TLS), Preparing sockets for TLS\n);
@@ -3788,7 +3788,7 @@
 		error = getaddrinfo(f-f_un.f_forw.f_hname, syslog, hints,
 		res);
 		if (error) {
-			logerror(gai_strerror(error));
+			logerror(%s, gai_strerror(error));
 			break;
 		}
 		f-f_un.f_forw.f_addr = res;
@@ -3804,7 +3804,7 @@
 		(void)strlcpy(f-f_un.f_fname, p, sizeof(f-f_un.f_fname));
 		if ((f-f_file = open(p, O_WRONLY|O_APPEND, 0))  0) {
 			f-f_type = F_UNUSED;
-			logerror(p);
+			logerror(%s, p);
 			break;
 		}
 		if (syncfile)
@@ -3941,7 +3941,7 @@
 	hints.ai_socktype = SOCK_DGRAM;
 	error = getaddrinfo(hostname, syslog, hints, res);
 	if (error) {
-		logerror(gai_strerror(error));
+		logerror(%s, gai_strerror(error));
 		errno = 0;
 		die(0, 0, NULL);
 	}
@@ -4074,7 +4074,7 @@
 		(void) snprintf(errmsg, sizeof(errmsg),
 		Warning: cannot change pipe to pid %d to 
 		non-blocking., (int) pid);
-		logerror(errmsg);
+		logerror(%s, errmsg);
 	}
 	*rpid = pid;
 	return pfd[1];
@@ -4146,7 +4146,7 @@
 	(void) snprintf(buf, sizeof(buf),
 	Logging subprocess %d (%s) exited %s %d.,
 	pid, name, reason, code);
-	logerror(buf);
+	logerror(%s, buf);
 }
 
 struct event *



CVS commit: src/usr.sbin/syslogd

2011-05-24 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Tue May 24 13:26:04 UTC 2011

Modified Files:
src/usr.sbin/syslogd: syslogd.c

Log Message:
Explicitly mark a NEWREF as unused


To generate a diff of this commit:
cvs rdiff -u -r1.101 -r1.102 src/usr.sbin/syslogd/syslogd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/syslogd/syslogd.c
diff -u src/usr.sbin/syslogd/syslogd.c:1.101 src/usr.sbin/syslogd/syslogd.c:1.102
--- src/usr.sbin/syslogd/syslogd.c:1.101	Tue May 24 13:25:25 2011
+++ src/usr.sbin/syslogd/syslogd.c	Tue May 24 13:26:04 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: syslogd.c,v 1.101 2011/05/24 13:25:25 joerg Exp $	*/
+/*	$NetBSD: syslogd.c,v 1.102 2011/05/24 13:26:04 joerg Exp $	*/
 
 /*
  * Copyright (c) 1983, 1988, 1993, 1994
@@ -39,7 +39,7 @@
 #if 0
 static char sccsid[] = @(#)syslogd.c	8.3 (Berkeley) 4/4/94;
 #else
-__RCSID($NetBSD: syslogd.c,v 1.101 2011/05/24 13:25:25 joerg Exp $);
+__RCSID($NetBSD: syslogd.c,v 1.102 2011/05/24 13:26:04 joerg Exp $);
 #endif
 #endif /* not lint */
 
@@ -2129,7 +2129,7 @@
 	 * this enables the buffer in the else branch to be freed
 	 * -- every branch needs one NEWREF() or buf_msg_new()! */
 	if (buffer) {
-		NEWREF(buffer);
+		(void)NEWREF(buffer);
 	} else {
 		if (f-f_prevcount  1) {
 			/* possible syslog-sign incompatibility:



CVS commit: src/usr.sbin/syslogd

2010-06-09 Thread Jeff Rizzo
Module Name:src
Committed By:   riz
Date:   Wed Jun  9 21:55:42 UTC 2010

Modified Files:
src/usr.sbin/syslogd: Makefile extern.h syslogd.c

Log Message:
Allow syslogd to compile when MKCRYPTO=no.  No promises as to whether
it works or not, as this has been broken since late 2008, when the
encrypted connections support was added to syslogd.


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/usr.sbin/syslogd/Makefile
cvs rdiff -u -r1.2 -r1.3 src/usr.sbin/syslogd/extern.h
cvs rdiff -u -r1.99 -r1.100 src/usr.sbin/syslogd/syslogd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/syslogd/Makefile
diff -u src/usr.sbin/syslogd/Makefile:1.22 src/usr.sbin/syslogd/Makefile:1.23
--- src/usr.sbin/syslogd/Makefile:1.22	Wed Apr 22 15:23:08 2009
+++ src/usr.sbin/syslogd/Makefile	Wed Jun  9 21:55:42 2010
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.22 2009/04/22 15:23:08 lukem Exp $
+#	$NetBSD: Makefile,v 1.23 2010/06/09 21:55:42 riz Exp $
 #	from: @(#)Makefile	8.1 (Berkeley) 6/6/93
 .include bsd.own.mk
 
@@ -26,6 +26,8 @@
 
 .if ${MKCRYPTO} != no
 LDADD+=	-lssl -lcrypto
+.else
+CPPFLAGS+=-DDISABLE_TLS -DDISABLE_SIGN
 .endif
 
 .include bsd.prog.mk

Index: src/usr.sbin/syslogd/extern.h
diff -u src/usr.sbin/syslogd/extern.h:1.2 src/usr.sbin/syslogd/extern.h:1.3
--- src/usr.sbin/syslogd/extern.h:1.2	Fri Nov  7 07:36:38 2008
+++ src/usr.sbin/syslogd/extern.h	Wed Jun  9 21:55:42 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: extern.h,v 1.2 2008/11/07 07:36:38 minskim Exp $	*/
+/*	$NetBSD: extern.h,v 1.3 2010/06/09 21:55:42 riz Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -74,7 +74,9 @@
 extern void	schedule_event(struct event **, struct timeval *,
 void (*)(int, short, void *), void *);
 extern char*make_timestamp(time_t *, bool);
+#ifndef DISABLE_TLS
 extern struct filed *get_f_by_conninfo(struct tls_conn_settings *conn_info);
+#endif
 extern bool	message_queue_remove(struct filed *, struct buf_queue *);
 extern void	buf_msg_free(struct buf_msg *msg);
 extern void	message_queue_freeall(struct filed *);

Index: src/usr.sbin/syslogd/syslogd.c
diff -u src/usr.sbin/syslogd/syslogd.c:1.99 src/usr.sbin/syslogd/syslogd.c:1.100
--- src/usr.sbin/syslogd/syslogd.c:1.99	Fri Feb  6 21:09:46 2009
+++ src/usr.sbin/syslogd/syslogd.c	Wed Jun  9 21:55:42 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: syslogd.c,v 1.99 2009/02/06 21:09:46 mschuett Exp $	*/
+/*	$NetBSD: syslogd.c,v 1.100 2010/06/09 21:55:42 riz Exp $	*/
 
 /*
  * Copyright (c) 1983, 1988, 1993, 1994
@@ -39,7 +39,7 @@
 #if 0
 static char sccsid[] = @(#)syslogd.c	8.3 (Berkeley) 4/4/94;
 #else
-__RCSID($NetBSD: syslogd.c,v 1.99 2009/02/06 21:09:46 mschuett Exp $);
+__RCSID($NetBSD: syslogd.c,v 1.100 2010/06/09 21:55:42 riz Exp $);
 #endif
 #endif /* not lint */
 
@@ -2114,7 +2114,7 @@
 	int e = 0, len = 0;
 	size_t msglen, linelen, tlsprefixlen, prilen;
 	char *p, *line = NULL, *lineptr = NULL;
-#ifndef DISABLE_TLS
+#ifndef DISABLE_SIGN
 	bool newhash = false;
 #endif
 #define REPBUFSIZE 80
@@ -3248,8 +3248,8 @@
 	struct filed *f, *newf, **nextp, *f2;
 	char *p;
 	sigset_t newmask, omask;
-	char *tls_status_msg = NULL;
 #ifndef DISABLE_TLS
+	char *tls_status_msg = NULL;
 	struct peer_cred *cred = NULL;
 #endif /* !DISABLE_TLS */
 
@@ -3818,8 +3818,10 @@
 		break;
 
 	case '|':
+#ifndef DISABLE_SIGN
 		if (GlobalSign.sg == 3)
 			f-f_flags |= FFLAG_SIGN;
+#endif
 		f-f_un.f_pipe.f_pid = 0;
 		(void) strlcpy(f-f_un.f_pipe.f_pname, p + 1,
 		sizeof(f-f_un.f_pipe.f_pname));
@@ -4200,6 +4202,7 @@
 #define SQ_CHUNK_SIZE 250
 	size_t cnt = 0;
 
+#ifndef DISABLE_TLS
 	if (f-f_type == F_TLS) {
 		/* use a flag to prevent recursive calls to send_queue() */
 		if (f-f_un.f_tls.tls_conn-send_queue)
@@ -4209,6 +4212,7 @@
 	}
 	DPRINTF((D_DATA|D_CALL), send_queue(f...@%p with %zu msgs, 
 		c...@%p = %zu)\n, f, f-f_qelements, cnt, cnt);
+#endif /* !DISABLE_TLS */
 
 	while ((qentry = STAILQ_FIRST(f-f_qhead))) {
 #ifndef DISABLE_TLS
@@ -4246,8 +4250,11 @@
 			break;
 		}
 	}
+#ifndef DISABLE_TLS
 	if (f-f_type == F_TLS)
 		f-f_un.f_tls.tls_conn-send_queue = false;
+#endif
+
 }
 
 /*



CVS commit: src/usr.sbin/syslogd

2010-01-01 Thread Marc Balmer
Module Name:src
Committed By:   mbalmer
Date:   Fri Jan  1 21:26:18 UTC 2010

Modified Files:
src/usr.sbin/syslogd: syslog.conf.5

Log Message:
fold long lines.


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/usr.sbin/syslogd/syslog.conf.5

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/syslogd/syslog.conf.5
diff -u src/usr.sbin/syslogd/syslog.conf.5:1.16 src/usr.sbin/syslogd/syslog.conf.5:1.17
--- src/usr.sbin/syslogd/syslog.conf.5:1.16	Thu Apr  9 02:41:44 2009
+++ src/usr.sbin/syslogd/syslog.conf.5	Fri Jan  1 21:26:18 2010
@@ -1,4 +1,4 @@
-.\	$NetBSD: syslog.conf.5,v 1.16 2009/04/09 02:41:44 joerg Exp $
+.\	$NetBSD: syslog.conf.5,v 1.17 2010/01/01 21:26:18 mbalmer Exp $
 .\
 .\ Copyright (c) 1990, 1991, 1993
 .\	The Regents of the University of California.  All rights reserved.
@@ -29,7 +29,7 @@
 .\
 .\ from: @(#)syslog.conf.5	8.1 (Berkeley) 6/9/93
 .\
-.Dd August 8, 2008
+.Dd January 1st, 2010
 .Dt SYSLOG.CONF 5
 .Os
 .Sh NAME
@@ -404,7 +404,8 @@
 Service name or port number to bind to.
 Default is
 .Sq syslog .
-.Em As long as no official port is assigned this option is required for TLS servers.
+.Em As long as no official port is assigned this option is required for TLS
+servers.
 .It Em tls_bindhost
 Hostname or IP to bind to.
 .It Em tls_gen_cert
@@ -586,7 +587,7 @@
 # Log all messages of level info or higher to another
 # machine using TLS with an alternative portname and a
 # fingerprint for athentication
-*.info	@[logserver]:1234(fingerprint=SHA1:01:02:...)
+*.info			@[logserver]:1234(fingerprint=SHA1:01:02:...)
 
 # Root and Eric get alert and higher messages.
 *.alert	root,eric



CVS commit: src/usr.sbin/syslogd

2010-01-01 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Fri Jan  1 21:44:08 UTC 2010

Modified Files:
src/usr.sbin/syslogd: syslog.conf.5

Log Message:
Fix previous: Dd argument and lost Em markup.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/usr.sbin/syslogd/syslog.conf.5

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/syslogd/syslog.conf.5
diff -u src/usr.sbin/syslogd/syslog.conf.5:1.17 src/usr.sbin/syslogd/syslog.conf.5:1.18
--- src/usr.sbin/syslogd/syslog.conf.5:1.17	Fri Jan  1 21:26:18 2010
+++ src/usr.sbin/syslogd/syslog.conf.5	Fri Jan  1 21:44:07 2010
@@ -1,4 +1,4 @@
-.\	$NetBSD: syslog.conf.5,v 1.17 2010/01/01 21:26:18 mbalmer Exp $
+.\	$NetBSD: syslog.conf.5,v 1.18 2010/01/01 21:44:07 wiz Exp $
 .\
 .\ Copyright (c) 1990, 1991, 1993
 .\	The Regents of the University of California.  All rights reserved.
@@ -29,7 +29,7 @@
 .\
 .\ from: @(#)syslog.conf.5	8.1 (Berkeley) 6/9/93
 .\
-.Dd January 1st, 2010
+.Dd January 1, 2010
 .Dt SYSLOG.CONF 5
 .Os
 .Sh NAME
@@ -404,8 +404,8 @@
 Service name or port number to bind to.
 Default is
 .Sq syslog .
-.Em As long as no official port is assigned this option is required for TLS
-servers.
+.Em As long as no official port is assigned this option is required
+.Em for TLS servers.
 .It Em tls_bindhost
 Hostname or IP to bind to.
 .It Em tls_gen_cert



CVS commit: src/usr.sbin/syslogd

2009-10-15 Thread Iain Hibbert
Module Name:src
Committed By:   plunky
Date:   Thu Oct 15 20:35:07 UTC 2009

Modified Files:
src/usr.sbin/syslogd: syslogd.8

Log Message:
reinstate a sentence partly removed in v1.43 regarding the default
facility/priority for local kernel messages


To generate a diff of this commit:
cvs rdiff -u -r1.48 -r1.49 src/usr.sbin/syslogd/syslogd.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/syslogd/syslogd.8
diff -u src/usr.sbin/syslogd/syslogd.8:1.48 src/usr.sbin/syslogd/syslogd.8:1.49
--- src/usr.sbin/syslogd/syslogd.8:1.48	Thu Jul 16 13:33:44 2009
+++ src/usr.sbin/syslogd/syslogd.8	Thu Oct 15 20:35:07 2009
@@ -1,4 +1,4 @@
-.\	$NetBSD: syslogd.8,v 1.48 2009/07/16 13:33:44 yamt Exp $
+.\	$NetBSD: syslogd.8,v 1.49 2009/10/15 20:35:07 plunky Exp $
 .\
 .\ Copyright (c) 1983, 1986, 1991, 1993
 .\	The Regents of the University of California.  All rights reserved.
@@ -29,7 +29,7 @@
 .\
 .\ from: @(#)syslogd.8	8.1 (Berkeley) 6/6/93
 .\
-.Dd July 16, 2009
+.Dd October 15, 2009
 .Dt SYSLOGD 8
 .Os
 .Sh NAME
@@ -235,6 +235,8 @@
 format.
 See RFC 3164 (BSD Syslog) and RFC 5424 (Syslog Protocol) for detailed
 description of the message format.
+Messages from the local kernel that are not tagged with a priority code
+receive the default facility
 .Dv LOG_KERN
 and priority
 .Dv LOG_NOTICE .



CVS commit: src/usr.sbin/syslogd

2009-07-16 Thread YAMAMOTO Takashi
Module Name:src
Committed By:   yamt
Date:   Thu Jul 16 13:33:44 UTC 2009

Modified Files:
src/usr.sbin/syslogd: syslogd.8

Log Message:
draft-ietf-syslog-protocol-23 - RFC 5424


To generate a diff of this commit:
cvs rdiff -u -r1.47 -r1.48 src/usr.sbin/syslogd/syslogd.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/syslogd/syslogd.8
diff -u src/usr.sbin/syslogd/syslogd.8:1.47 src/usr.sbin/syslogd/syslogd.8:1.48
--- src/usr.sbin/syslogd/syslogd.8:1.47	Sun Feb  1 12:59:05 2009
+++ src/usr.sbin/syslogd/syslogd.8	Thu Jul 16 13:33:44 2009
@@ -1,4 +1,4 @@
-.\	$NetBSD: syslogd.8,v 1.47 2009/02/01 12:59:05 wiz Exp $
+.\	$NetBSD: syslogd.8,v 1.48 2009/07/16 13:33:44 yamt Exp $
 .\
 .\ Copyright (c) 1983, 1986, 1991, 1993
 .\	The Regents of the University of California.  All rights reserved.
@@ -29,7 +29,7 @@
 .\
 .\ from: @(#)syslogd.8	8.1 (Berkeley) 6/6/93
 .\
-.Dd February 1, 2009
+.Dd July 16, 2009
 .Dt SYSLOGD 8
 .Os
 .Sh NAME
@@ -233,9 +233,8 @@
 .Nm
 accepts messages in traditional BSD Syslog or in newer Syslog Protocol
 format.
-See RFC 3164 (BSD Syslog) and RFC
-.Em 
-(Syslog Protocol) for detailed description of the message format.
+See RFC 3164 (BSD Syslog) and RFC 5424 (Syslog Protocol) for detailed
+description of the message format.
 .Dv LOG_KERN
 and priority
 .Dv LOG_NOTICE .
@@ -270,10 +269,10 @@
 .%T The BSD syslog Protocol
 .Re
 .Rs
-.%R Internet-Draft
-.%N draft-ietf-syslog-protocol-23
-.%D September 2007
-.%T The syslog Protocol
+.%R RFC
+.%N 5424
+.%D March 2009
+.%T The Syslog Protocol
 .Re
 .Sh HISTORY
 The



CVS commit: src/usr.sbin/syslogd

2009-04-08 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Thu Apr  9 02:41:44 UTC 2009

Modified Files:
src/usr.sbin/syslogd: syslog.conf.5

Log Message:
.br - .Pp, capitalize subsection titles


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/usr.sbin/syslogd/syslog.conf.5

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/syslogd/syslog.conf.5
diff -u src/usr.sbin/syslogd/syslog.conf.5:1.15 src/usr.sbin/syslogd/syslog.conf.5:1.16
--- src/usr.sbin/syslogd/syslog.conf.5:1.15	Fri Nov  7 07:36:38 2008
+++ src/usr.sbin/syslogd/syslog.conf.5	Thu Apr  9 02:41:44 2009
@@ -1,4 +1,4 @@
-.\	$NetBSD: syslog.conf.5,v 1.15 2008/11/07 07:36:38 minskim Exp $
+.\	$NetBSD: syslog.conf.5,v 1.16 2009/04/09 02:41:44 joerg Exp $
 .\
 .\ Copyright (c) 1990, 1991, 1993
 .\	The Regents of the University of California.  All rights reserved.
@@ -435,7 +435,7 @@
 Unless authentication is disabled by setting
 .Sq tls_verify=off
 the following rules are used:
-.Ss as client:
+.Ss As client:
 A client can be configured not to check a server's certificate by setting the
 parameter
 .Ar verify
@@ -453,14 +453,14 @@
 .Ar subject
 to authenticate the TLS connection without having to add the IP to the X.509
 certificate.
-.br
+.Pp
 If no CA is used or no trust path between CA and server certificate exists, then
 hash value of the server's certificate is compared with the hash given in
 .Ar fingerprint
 and the hash of the certificate in
 .Ar cert .
 If the hashes are equal then the server is authenticated.
-.Ss as server:
+.Ss As server:
 If using a CA and the client's certificate is signed by it then the client is
 authenticated.
 Otherwise the hash of the client's certificate is compared with the hashes given