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 reporting of buffer over...



details:   https://anonhg.NetBSD.org/src/rev/e60733e3e36b
branches:  trunk
changeset: 445592:e60733e3e36b
user:      roy <roy%NetBSD.org@localhost>
date:      Sun Nov 04 20:45:21 2018 +0000

description:
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.

diffstat:

 usr.sbin/syslogd/syslogd.8 |   9 +++++++--
 usr.sbin/syslogd/syslogd.c |  26 +++++++++++++++++++-------
 2 files changed, 26 insertions(+), 9 deletions(-)

diffs (126 lines):

diff -r 27f7db739c33 -r e60733e3e36b usr.sbin/syslogd/syslogd.8
--- a/usr.sbin/syslogd/syslogd.8        Sun Nov 04 20:23:08 2018 +0000
+++ b/usr.sbin/syslogd/syslogd.8        Sun Nov 04 20:45:21 2018 +0000
@@ -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 @@
 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 @@
 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
diff -r 27f7db739c33 -r e60733e3e36b usr.sbin/syslogd/syslogd.c
--- a/usr.sbin/syslogd/syslogd.c        Sun Nov 04 20:23:08 2018 +0000
+++ b/usr.sbin/syslogd/syslogd.c        Sun Nov 04 20:45:21 2018 +0000
@@ -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 @@
 #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    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 @@
        /* should we set LC_TIME="C" to ensure correct timestamps&parsing? */
        (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 @@
                        if (LogFacPri < 2)
                                LogFacPri++;
                        break;
+               case 'X':
+                       LogOverflow = 0;
+                       break;
                default:
                        usage();
                }
@@ -663,7 +667,7 @@
 {
 
        (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 @@
        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 @@
        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), myname.sun_path);
        }
@@ -791,7 +801,9 @@
        len = sizeof(frominet);
        rv = recvfrom(fd, linebuf, linebufsize-1, 0,
            (struct sockaddr *)&frominet, &len);
-       if (rv == 0 || (rv < 0 && errno == EINTR))
+       if (rv == 0 ||
+           (rv < 0 && (errno == EINTR ||
+                       (errno == ENOBUFS && LogOverflow == 0))))
                return;
        else if (rv < 0) {
                logerror("recvfrom inet");



Home | Main Index | Thread Index | Old Index