Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.sbin/syslogd syslogd: allow the receiving buffer size to...
details: https://anonhg.NetBSD.org/src/rev/27f7db739c33
branches: trunk
changeset: 445591:27f7db739c33
user: roy <roy%NetBSD.org@localhost>
date: Sun Nov 04 20:23:08 2018 +0000
description:
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.
diffstat:
usr.sbin/syslogd/syslogd.8 | 9 +++++++--
usr.sbin/syslogd/syslogd.c | 23 +++++++++++++++--------
2 files changed, 22 insertions(+), 10 deletions(-)
diffs (111 lines):
diff -r 4a1e18dd8f47 -r 27f7db739c33 usr.sbin/syslogd/syslogd.8
--- a/usr.sbin/syslogd/syslogd.8 Sun Nov 04 20:02:07 2018 +0000
+++ b/usr.sbin/syslogd/syslogd.8 Sun Nov 04 20:23:08 2018 +0000
@@ -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 @@
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.
diff -r 4a1e18dd8f47 -r 27f7db739c33 usr.sbin/syslogd/syslogd.c
--- a/usr.sbin/syslogd/syslogd.c Sun Nov 04 20:02:07 2018 +0000
+++ b/usr.sbin/syslogd/syslogd.c Sun Nov 04 20:23:08 2018 +0000
@@ -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 @@
#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 @@
#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 @@
/* should we set LC_TIME="C" to ensure correct timestamps&parsing? */
(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 @@
{
(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 @@
static void
setsockbuf(int fd, const char *name)
{
- int buflen;
+ int curbuflen;
socklen_t socklen = sizeof(buflen);
- if (getsockopt(fd, SOL_SOCKET, SO_RCVBUF, &buflen, &socklen) == -1) {
+
+ if (getsockopt(fd, SOL_SOCKET, SO_RCVBUF, &curbuflen, &socklen) == -1) {
logerror("getsockopt: SO_RCVBUF: `%s'", name);
return;
}
- if (buflen >= RCVBUFLEN)
+ if (curbuflen >= buflen)
return;
- buflen = RCVBUFLEN;
if (setsockopt(fd, SOL_SOCKET, SO_RCVBUF, &buflen, socklen) == -1) {
logerror("setsockopt: SO_RCVBUF: `%s'", name);
return;
Home |
Main Index |
Thread Index |
Old Index