293 Commits

Author SHA1 Message Date
Bjoern A. Zeeb
005a443f43 MFC 344740:
Fix compilation of world with WITHOUT_{INET,INET6}_SUPPORT or both set.

  Buildworld failed when both WITHOUT_INET6_SUPPORT and INET equivalent were set.
  Fix netstat and syslogd by applying appropriate #ifdef INET/INET6 to make world
  compile again.
2019-04-19 17:29:20 +00:00
Hajimu UMEMOTO
47df76f2d1 MFC r344491: An IPv6 address matching should be fixed.
Specifying an IPv6 address by the -a option was broken
since r309933.
2019-03-03 03:42:51 +00:00
Ed Schouten
7cadca0119 MFC r336060:
Allow the use of slashes in process names of RFC 3164 formatted messages.

  Tools such as Postfix use slashes in process names for hierarchy
  (postfix/qmgr). By allowing these slashes, syslogd is able to extract
  the process name and process ID nicely, so that they can be stored in
  RFC 5424 message fields.
2018-07-15 13:50:01 +00:00
Ed Schouten
c69d2e7f2e MFC r335862:
Document that syslogd -v has no effect when RFC 5424 mode is enabled.

  The variable it sets, LogFacPri, is only used in the RFC 3164 formatting
  codepath.

PR:		229457
2018-07-07 11:39:20 +00:00
Ed Schouten
dc30b7c876 MFC r335861:
Restore the order in which RFC 3164 messages with fac/pri are formatted.

  The refactoring of the syslogd code to format messages using iovecs
  slightly altered the output of syslogd by placing the facility/priority
  after the hostname, as opposed to printing it right before. This change
  reverts the behaviour to be consistent with how it was before.

PR:		229457
2018-07-07 11:38:44 +00:00
Ed Schouten
18b5b2a5c3 MFC r335565:
Still parse messages that don't contain an RFC 3164 timestamp.

  The changes made in r326573 required that messages always start with an
  RFC 3164 timestamp. It looks like certain devices, but also certain
  logging libraries (Python 3's "logging" package) simply don't generate
  RFC 3164 formatted messages containing a timestamp.

  Make timestamps optional again. When the timestamp is missing, also
  assume that the message contains no hostname. The first word of the
  message likely already belongs to the message payload.

PR:		229236
2018-06-28 12:55:05 +00:00
Ed Schouten
ad0123421a MFC r335314:
Fix bad logic in iovlist_truncate().

  To conform to RFC 5426, this function is intended to truncate messages
  if they exceed the message size limits. Unfortunately, the amount of
  space was computed the wrong way around, causing messages to be
  truncated entirely.

Reported by:  Michael Grimm on stable@
2018-06-21 16:12:30 +00:00
Ed Schouten
3c867c36b5 MFC r309925, r309931, r309933, r310035, r310278, r310310, r310311,
r310323, r310349, r310350, r310351, r310352, r310383, r310384,
    r310385, r310386, r310393, r310453, r310456, r310494, r310504,
    r310528, r310890, r310893, r310974, r311918, r312921, r313357,
    r314563, r314585, r314642, r315322, r315618, r315620, r315622,
    r315643, r316951, r316973, r326338, r326339, r326573, r331270,
    r332099, r332110, r332111, r332118, r332165, r332510 and r332511.

This commit brings syslogd(8) in sync with the copy in HEAD. The key
improvement of this change is that it adds support for RFC 5424 log
ingestion and exposition (enabled by passing in -O rfc5424). This allows
for saner logging in environments with multiple time zones.

The list of changes to merge back were obtained by running:

    svn mergeinfo --show-revs eligible \
        ^/head/usr.sbin/syslogd ^/stable/11/usr.sbin/syslogd

Of the commits listed, r314436, r325188 and r326025 were excluded, as
they affect a significant number of unrelated files (SPDX and 4-clause
license renumbering). Due to the large number of directly committed
changes on this branch, I had no choice but to perform the merge as
follows:

    svn merge --accept=theirs-full -c <list of revisions> ^/head .

This would, however, cause some unrelated changes, such as undoing the
r333356 (MFC of r332877) and still adding the SPDX tag to syslogd.c.
These have been reverted manually.

Requested by:	Dave Cottlehuber
Thanks to:	dim@ for sharing his insight on hackers@
2018-06-13 13:41:23 +00:00
Xin LI
074da6ae90 MFC r332877: Correct size for allocation and bzero of fdsr.
Approved by:	re (gjb)
2018-05-08 05:10:06 +00:00
Eitan Adler
4ab2e064d7 Revert r330897:
This was intended to be a non-functional change. It wasn't. The commit
message was thus wrong. In addition it broke arm, and merged crypto
related code.

Revert with prejudice.

This revert skips files touched in r316370 since that commit was since
MFCed. This revert also skips files that require $FreeBSD$ property
changes.

Thank you to those who helped me get out of this mess including but not
limited to gonzo, kevans, rgrimes.

Requested by: gjb (re)
2018-03-29 02:50:57 +00:00
Eitan Adler
be5d0b9566 Partial merge of the SPDX changes
These changes are incomplete but are making it difficult
to determine what other changes can/should be merged.

No objections from:	pfg
2018-03-14 03:19:51 +00:00
David Bright
1c355ac5d4 MFC r330034
Fix a memory leak in syslogd

A memory leak in syslogd for processing of forward actions was
reported. This modification adapts the patch submitted with that bug
to fix the leak.

PR:		198385
Submitted by:	Sreeram <sreeramabs@yahoo.com>
Reported by:	Sreeram <sreeramabs@yahoo.com>
Sponsored by:	Dell EMC
2018-03-08 16:26:49 +00:00
Ollivier Robert
28449e350d In stable/11, support for including config. files is broken and only the
last one is taken into account.

Code in 12-CURRENT s different and works so commit is in stable/11.

Patch by Alexander Zagrebin <alex@zagrebin.ru> in the PR.

PR:		220884
Relnotes:	yes
Submitted by:	Dan McGregor <dan.mcgregor@usask.ca>
2017-12-29 16:48:14 +00:00
Gleb Smirnoff
f8ab9c7a4c Revert r326103, as it appeared to be incorrect. 2017-11-28 19:09:05 +00:00
Gleb Smirnoff
9973b6a8cc MFC r325558:
When parsing UDP messages skip optional hostname as described by
  RFC 3164.

PR:		200933
Submitted by:	maxim
Reported by:	Konstantin Pavlov <thresh nginx.com>
2017-11-22 21:20:26 +00:00
Eugene Grosbein
41fa2df163 MFC r310888:
Retry to open an F_PIPE process when it dies unexpectedly.

PR:           215335
Reviewed by:  ae
Approved by:  az (mentor)
2017-07-07 13:44:18 +00:00
Enji Cooper
217ceb68a9 MFC r314233:
Parameterize out the length of struct filed->f_lasttime as `MAXDATELEN`

This removes the hardcoded value for the field (16) and the equivalent
hardcoded lengths in logmsg(..).

This change is being done to help stage future work to add RFC5424/RFC5434
support to syslogd(8).

Obtained from:	Isilon OneFS (dcd33d13da) (as part of a larger change)
2017-03-12 04:55:06 +00:00
Enji Cooper
ab53e74420 MFC r314226:
Use SRCTOP instead of .CURDIR relative paths with ".."

This simplifies pathing in make/displayed output
2017-03-07 02:02:23 +00:00
Enji Cooper
012d8c9165 MFC r313356:
Fix typos in comments (returing -> returning)
2017-02-14 04:52:16 +00:00
Enji Cooper
4dde96481f MFC r313358,r313360:
r313358:

Sort sys/ #includes and zap an unnecessary trailing space nearby

r313360:

Sort sys/ #includes some more
2017-02-14 04:38:39 +00:00
Baptiste Daroussin
c23bb22b08 MFC r309194, r309216
Properly initialize nextp

Reported by:	Coverity via cem
MFC after:	2 days
CID:		1365665
2016-11-28 22:19:41 +00:00
Baptiste Daroussin
d89d921bf6 MFC r308160:
syslogd(8): add an 'include' keyword

All the '.conf' files not beginning with a '.' contained int he directory
following the keyword will be included.

This keyword can only be used in the first level configuration files.

Modify the default syslogd.conf to 'include' /etc/syslog.d and
/usr/local/etc/syslog.d

It simplify a lot handling of syslog from automation tools.

Reviewed by:	markj, kib (via irc)
Approved by:	markj
MFC after:	2 weeks
Relnotes:	yes
Differential Revision:	https://reviews.freebsd.org/D8402
2016-11-16 07:04:49 +00:00
Baptiste Daroussin
8df1311ea3 MFC r305707:
Directly set the O_NONBLOCK flags via open(2)
2016-10-22 20:57:51 +00:00
Alan Somers
f32e43a6a8 syslogd: Enable repeated line compression for lines of any length.
Enable repeated line compression for lines of any length, instead of only
short lines. AFAICT repeated line compression was limited to short lines as
a RAM optimization, which made sense when karels added it in 1988, but no
longer.  The penalty is a paltry 904B of RAM per file logged.

Reviewed by:	rpaulo
MFC after:	32 days
Sponsored by:	Spectra Logic Corp
Differential Revision:	https://reviews.freebsd.org/D4475
2016-01-27 16:17:15 +00:00
Kurt Lidl
247027652e Have syslogd honor 'mesg' status when logging to users.
PR:		bin/196742
Submitted by:	jef at mail acme com
Approved by:	rpaulo (mentor)
Differential Revision:	https://reviews.freebsd.org/D4270
2015-11-25 20:01:11 +00:00
Xin LI
e54569ecca die() would never return, mark it as so.
MFC after:	2 weeks
2015-08-27 18:11:00 +00:00
Enji Cooper
c1987c2852 Set f_file to -1/F_UNUSED when after closing when possible
This will help ensure we don't trash file descriptors that get used later on
in the daemon

Found via internal Coverity scan

MFC after: 2 weeks
Discussed with: cem, ed, markj
Differential Revision: https://reviews.freebsd.org/D3081
Submitted by: Miles Ohlrich <miles.ohlrich@isilon.com>
Sponsored by: EMC / Isilon Storage Division
2015-08-05 03:17:06 +00:00
Rui Paulo
baa557331e syslogd: re-read the timezone when receive a SIGHUP.
syslogd already re-reads the configuration file and the hostname when
receiving a SIGHUP, so it makes sense to reset the timezone.
Special care was taken to ensure we don't break installations running
with a custom TZ variable.

PR:		196905
Submitted by:	Kurt Lidl <lidl pix.net>
Sponsored by:	Pi-Coral, Inc.
2015-06-16 22:42:19 +00:00
Rui Paulo
e87161769c syslogd: don't leak finet0.
Submitted by:	Kurt Lidl <lidl pix.net>
Sponsored by:	Pi-Coral, Inc.
2015-06-16 22:31:38 +00:00
Rui Paulo
38076b4ba5 syslogd: support multiple -b options.
It's now possible to bind multiple sockets to different IP addresses.

PR:		159305
Submitted by:	Kurt Lidl <lidl pix.net>
Sponsored by:	Pi-Coral, Inc.
2015-06-16 22:26:22 +00:00
Simon J. Gerraty
ccfb965433 Add META_MODE support.
Off by default, build behaves normally.
WITH_META_MODE we get auto objdir creation, the ability to
start build from anywhere in the tree.

Still need to add real targets under targets/ to build packages.

Differential Revision:       D2796
Reviewed by: brooks imp
2015-06-13 19:20:56 +00:00
Simon J. Gerraty
44d314f704 dirdeps.mk now sets DEP_RELDIR 2015-06-08 23:35:17 +00:00
Simon J. Gerraty
98e0ffaefb Merge sync of head 2015-05-27 01:19:58 +00:00
Xin LI
e8a94f7104 path.h is not needed here. 2015-05-16 08:12:00 +00:00
Sergey Kandaurov
fb0e21cfe8 Update .Dd, sync usage() for -F. Missed in previous change. 2015-03-03 20:23:59 +00:00
Rui Paulo
36285e787f Add and document an option to cause syslogd to run in the
foreground.

This allows a separate process to monitor when and how
syslogd exits. That process can then restart syslogd if needed.

Differential Revision:	https://reviews.freebsd.org/D1985
Submitted by:	Ravi Pokala
Reviewed by:	allanjude (man page)
2015-03-03 20:07:59 +00:00
Ed Schouten
0f0d5f6e45 Make syslogd work in case shutdown() is POSIX-ly correct.
On POSIX conformant systems, shutdown() should return ENOTCONN when not
connected. We attempted to fix this once (kern/84761), but this change
got backed out because it 'breaks code' (r150155).

I just reapplied the patch and indeed, syslogd fails on startup. Make it
easier to re-enable this change in the future by paching up syslogd to
do the right thing.

MFC after:	3 weeks
Sponsored by:	Nuxi
2015-02-19 18:56:39 +00:00
Dimitry Andric
bd496ef499 Fix two clang 3.6.0 warnings in usr.sbin/syslogd:
usr.sbin/syslogd/syslogd.c:1023:10: error: address of array 'f->f_prevline' will always evaluate to 'true' [-Werror,-Wpointer-bool-conversion]
                    f->f_prevline && !strcmp(msg, f->f_prevline) &&
                    ~~~^~~~~~~~~~
usr.sbin/syslogd/syslogd.c:1178:16: error: address of array 'f->f_prevline' will always evaluate to 'true' [-Werror,-Wpointer-bool-conversion]
        } else if (f->f_prevline) {
               ~~  ~~~^~~~~~~~~~

In both cases, the f_prevline field of struct filed is a char array, so
it can never be null.  Remove the checks.

Reviewed by:	jilles
MFC after:	3 days
Differential Revision: https://reviews.freebsd.org/D1716
2015-02-05 22:28:00 +00:00
Andrey V. Elsukov
cf93a6321a Increase the buffer size to keep the list of programm names when
parsing programm specification. It is safe to not check out of bounds
access, because !isprint(p[i]) check will stop reading, when '\0'
character will be read from the input string.

Obtained from:	Yandex LLC
MFC after:	1 week
Sponsored by:	Yandex LLC
2014-12-12 11:29:54 +00:00
Baptiste Daroussin
c6db8143ed Convert usr.sbin to LIBADD
Reduce overlinking
2014-11-25 16:57:27 +00:00
Simon J. Gerraty
fae50821ae Updated dependencies 2014-05-16 14:09:51 +00:00
Simon J. Gerraty
76b28ad6ab Updated dependencies 2014-05-10 05:16:28 +00:00
Simon J. Gerraty
cc3f4b9965 Merge from head 2014-05-08 23:54:15 +00:00
Warner Losh
c6063d0da8 Use src.opts.mk in preference to bsd.own.mk except where we need stuff
from the latter.
2014-05-06 04:22:01 +00:00
Simon J. Gerraty
3b8f084595 Merge head 2014-04-28 07:50:45 +00:00
Ian Lepore
f0c7dfca42 Add ENETUNREACH and EADDRNOTAVAIL to the list of errors that are potentially
transient and shouldn't result in closing the socket and giving up forever.
2013-11-13 01:04:02 +00:00
Ian Lepore
6a3e86ff22 This fixes 3 problems in syslogd related to sizing receive buffers...
- A call was misplaced at the wrong level of nested if blocks, so that
  the buffers for unix domain sockets (/dev/log, /dev/klog) were never
  increased at all; they remained at a way-too-small default size of 4096.

- The function that was supposed to double the size of the buffer
  sometimes did nothing, and sometimes installed a wildly-wrong buffer
  size (either too large or too small) due to an unitialized 'slen'
  variable passed to getsockopt().  Most often it doubled the UDP buffers
  from 40k to 80k because accidentally there would be harmless stack
  garbage in the unitialized variables.

- The whole concept of blindly doubling a socket's buffer size without
  knowing what size it started at is a design flaw that has to be called a
  bug.  If the double_rbuf() function had worked at all (I.E., if the
  other two bugs didn't exist) this would lead to UDP sockets having an
  80k buffer while unix dgram sockets get an 8k buffer.  There's nothing
  about the problem being solved that requires larger buffers for UDP than
  for unix dgram sockets -- the buffering requirements are the same
  regardless of socket type.

This change renames the double_rbuf() function to increase_rbuf() and
increases the buffer size on all types of sockets to 80k.  80k was
chosen only because it appears to be the size the original change was
shooting for, and it certainly seems to be reasonably large (I might
have picked 64k in the absence of any historical guidance).

PR:		160433
Submitted by:	me, in 2011.
2013-11-13 01:01:15 +00:00
Simon J. Gerraty
d1d0158641 Merge from head 2013-09-05 20:18:59 +00:00
Jilles Tjoelker
f35bb1a01e syslogd: Use closefrom() instead of getdtablesize()/close() loop.
When syslogd forks a process for '|' destinations, it closes all file
descriptors greater than 2.

Use closefrom() for this instead of a getdtablesize()/close() loop because
it is both faster and avoids leaving file descriptors open because the limit
was lowered after they were opened.

MFC after:	1 week
2013-04-27 13:26:35 +00:00
Simon J. Gerraty
7cf3a1c6b2 Updated dependencies 2013-03-11 17:21:52 +00:00