History log of /freebsd-current/usr.sbin/syslogd/syslogd.c
Revision Date Author Comments
# 0b8224d1 24-Nov-2023 Warner Losh <imp@FreeBSD.org>

Remove copyright strings ifdef'd out

We've ifdef'd out the copyright strings for some time now. Go ahead and
remove the ifdefs. Plus whatever other detritis was left over from other
recent removals. These copyright strings are present in the comments and
are largely from CSRG's attempt at adding their copyright to every
binary file (which modern interpretations of the license doesn't
require).

Sponsored by: Netflix


# 8a7b6120 23-Nov-2023 Warner Losh <imp@FreeBSD.org>

usr.sbin: Remove ancient SCCS tags.

Remove ancient SCCS tags from the tree, automated scripting, with two
minor fixup to keep things compiling. All the common forms in the tree
were removed with a perl script.

Sponsored by: Netflix


# d556719e 15-Oct-2023 Jake Freeland <jfree@FreeBSD.org>

syslogd: Keep console and tty descriptors open

Console and tty descriptors are initially opened in parse_action() to
determine whether they are valid using isatty(). That descriptor is then
closed because it is never accessed by syslogd again; ttymsg() will reopen
the tty/console under a new descriptor when needed.

If the user attempts to log to a tty that is inactive outside of
syslogd, then syslogd must keep that descriptor open so the tty remains
accessible. For example, logging to `/dev/ttyvb` requires the initial
`/dev/ttyvb` descriptor to stay open so the user can view its buffer at
any time via CTRL+ALT+F12.

As a result, console and tty descriptors must remain open until a
potential configuration reload or a system shutdown. The given
descriptor will be closed in close_filed() in such circumstances.

PR: 274454
Fixes: c3175a6e1c5a ("syslogd: Do not open console descriptor")
Reported by: Trond Endrestøl <Trond.Endrestol@ximalas.info>
Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D42215


# 94cae4cb 31-Aug-2023 Jake Freeland <jfree@FreeBSD.org>

syslogd: Do not add shutdown sockets to the kqueue

If syslogd is in secure mode, all INET sockets are shutdown. Do not
add these to the kqueue because we can't read from them.

Also, remove the listen() call when setting up sockets. Syslogd
exclusively uses SOCK_DGRAM sockets, so calling listen() is useless.

Reviewed by: markj
MFC after: 3 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D41526


# 8536447a 31-Aug-2023 Jake Freeland <jfree@FreeBSD.org>

syslogd: Use pipe to communicate with daemon

Previously, syslogd's daemon process would signal that it had finished
initialization using SIGALRM. In capability mode, signal delivery is not
allowed, so use a pipe to indicate that it is ready to accept messages.

Reviewed by: markj
MFC after: 3 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D41459


# 4ac65824 31-Aug-2023 Jake Freeland <jfree@FreeBSD.org>

syslogd: Ignore signals in sigcatch[]

Instead of blocking signals in sigcatch[], just ignore them. This frees
up some space on the proc's sigqueue.

Reviewed by: markj
MFC after: 3 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D41433


# 7428ebfe 31-Aug-2023 Jake Freeland <jfree@FreeBSD.org>

syslogd: Pre-open null file descriptor

Open _PATH_DEVNULL before entering capability mode. Access to /dev/null
is needed for dup2() when piping commands.

Reviewed by: markj
MFC after: 3 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D41381


# c3175a6e 31-Aug-2023 Jake Freeland <jfree@FreeBSD.org>

syslogd: Do not open console descriptor

Setup consfile filed for logging while Initialized is false, but do not
bother opening the console. Close console/tty descriptors after parsing,
as well. The ttymsg() function will re-open these descriptors for us.

Also, remove references to the ctty global variable since it will always
be _PATH_CONSOLE.

Reviewed by: markj
MFC after: 3 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D41380


# 5b44c24f 31-Aug-2023 Jake Freeland <jfree@FreeBSD.org>

syslogd: unlink() -> unlinkat()

Save basename and dirname for use in unlinkat() when removing UNIX
sockets from fs.

Reviewed by: markj, emaste
MFC after: 3 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D41379


# 3854dd52 31-Aug-2023 Jake Freeland <jfree@FreeBSD.org>

syslogd: Add closelogfiles() function

The closelogfiles() function completely disassembles the global filed
list by freeing all filed components and removing them from the list.

Reviewed by: markj
MFC after: 3 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D41388


# 09080d8e 31-Aug-2023 Jake Freeland <jfree@FreeBSD.org>

syslogd: Fix sizeof() styling

Use parentheses when applying sizeof() per style(9).

Reviewed by: markj, emaste
MFC after: 3 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D41376


# 8f49f83e 31-Aug-2023 Jake Freeland <jfree@FreeBSD.org>

syslogd: Move action parsing into its own function

Clean up the cfline() function by moving action parsing into its own
function.

Reviewed by: markj
MFC after: 3 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D41375


# f4b4a10a 31-Aug-2023 Jake Freeland <jfree@FreeBSD.org>

syslogd: Move selector parsing into its own function

Clean up the cfline() function by moving selector parsing into its
own function.

Reviewed by: markj
MFC after: 3 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D41374


# 688ecad8 31-Aug-2023 Jake Freeland <jfree@FreeBSD.org>

syslogd: Move prop_filter allocation into function

Clean up the cfline() function by moving the prop_filter memory
allocation into the prop_filter_compile() function.

Reviewed by: markj
MFC after: 3 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D41373


# cd90f3af 31-Aug-2023 Jake Freeland <jfree@FreeBSD.org>

syslogd: Do not print bad data

If errno is zero, then buf is never filled and we're printing
uninitialized data. Print the msg buffer instead to mitigate this.

Reviewed by: markj, emaste
MFC after: 3 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D41371


# bbde787c 31-Aug-2023 Jake Freeland <jfree@FreeBSD.org>

syslogd: Merge loops

Merge the two loops that traverse the global filed queue. Both loops'
actions are not dependent on the other, so combining them is safe.

Reviewed by: markj
MFC after: 3 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D41370


# fe233250 31-Aug-2023 Jake Freeland <jfree@FreeBSD.org>

syslogd: Do not reap child processes

Use the SA_NOCLDWAIT sigaction() flag to disable the creation of
zombie processes. This leaves no reason to wait() on children, so
remove the reaping routine.

Previously, deadq entries were removed in reapchild(). Move deadq
removal into markit() after SIGKILL is sent.

Reviewed by: markj
MFC after: 3 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D41415


# 95381c01 31-Aug-2023 Jake Freeland <jfree@FreeBSD.org>

syslogd: Use process descriptors

Prepare for program Capsicumization by storing process descriptors
instead of pids. Signal delivery is not permitted in capability mode,
so we can use pdkill(2) to terminate child processes.

Reviewed by: markj
MFC after: 3 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D41369


# 599db1e0 31-Aug-2023 Jake Freeland <jfree@FreeBSD.org>

syslogd: Simplify filed structure

Rearrange fields and add some comments.

Reviewed by: markj
MFC after: 3 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D41368


# 929568b9 31-Aug-2023 Jake Freeland <jfree@FreeBSD.org>

syslogd: Style fixes

Reviewed by: markj, emaste
MFC after: 3 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D41367


# fcc1e177 31-Aug-2023 Jake Freeland <jfree@FreeBSD.org>

syslogd: Simplify property filters

* Use enums for property filter properties and comparisons.
* Rename property and comparison values.

Reviewed by: markj
MFC after: 3 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D41366


# b772f1ce 31-Aug-2023 Jake Freeland <jfree@FreeBSD.org>

syslogd: Clean up allowedpeer structure

* Use boolean values in validate() and struct allowedpeer.
* Remove useless peer count loop.

Reviewed by: markj, emaste
MFC after: 3 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D41365


# f30b063e 31-Aug-2023 Jake Freeland <jfree@FreeBSD.org>

syslogd: Only use peerlist during flag parsing

Add logging sockets directly to the socklist, unless parsing flags. The
peerlist is still needed to temporarily hold socket information until
the configuration flags have been parsed.

It is tempting to remove the entire peerlist, but addsock() can not
determine if syslogd is in secure mode unless the flags have been
parsed.

Also, call pidfile_open() right after flag parsing so we can terminate
if another syslogd instance is already running.

Reviewed by: markj
MFC after: 3 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D41364


# 1bb61348 31-Aug-2023 Jake Freeland <jfree@FreeBSD.org>

syslogd: Use boolean reload parameter for init()

Replace init()'s integer "signo" parameter with boolean "reload"
for clarity.

Reviewed by: markj, emaste
MFC after: 3 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D41416


# f804f236 31-Aug-2023 Jake Freeland <jfree@FreeBSD.org>

syslogd: Centralize operations into a kevent loop

Use kqueue(2) for socket I/O and signal notification. Previously,
select(2) and traditional signal handlers were being used.

This change centralizes all of the async notification delivery into a
single loop so future Capsicum sandboxing will be easier. It also
simplifies the code by removing boiler-plate cruft that comes with the
older interfaces.

Reviewed by: Slawa Olhovchenkov, markj, emaste
MFC after: 3 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D41363


# 3f8b49dd 31-Aug-2023 Jake Freeland <jfree@FreeBSD.org>

syslogd: Replace int with bool, where applicable

Many of syslogd's global configuration options are declared as integers
but are treated as booleans. Declare those options as booleans instead.

Reviewed by: markj, emaste
MFC after: 3 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D41362


# 8113e030 31-Aug-2023 Jake Freeland <jfree@FreeBSD.org>

syslogd: Move fhead under filed struct declaration

Reviewed by: markj, emaste
MFC after: 3 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D41360


# 2d69e4c3 31-Aug-2023 Jake Freeland <jfree@FreeBSD.org>

syslogd: Remove addfile() and free up some memory

cfline() already allocates a filed structure on the heap, so we can
avoid redundant memory allocations by skipping a second calloc() inside
addfile().

addfile() can be removed altogether since a simple STAILQ_INSERT_TAIL()
will add the filed to the global filed list.

Reviewed by: markj, emaste
MFC after: 3 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D41359


# 931d05fc 31-Aug-2023 Jake Freeland <jfree@FreeBSD.org>

syslogd: Read configuration outside of init loop

Move all configuration-file code outside of the initialization loop and
into its own set of functions. Create a readconfigfile() to open the
config and call parseconfigfile() to parse it.

The init() function no longer returns if there was a failure to open the
configuration file. Initialization will be finished, using the backup
logging rules: *.ERR to /dev/console and *.PANIC to all logged in users.

Reviewed by: markj, emaste
MFC after: 3 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D41358


# 518bd541 31-Aug-2023 Mark Johnston <markjdb@gmail.com>

syslogd: Fix fd type, add enum for filed types

Reviewed by: markj, emaste
MFC after: 3 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D41357


# 1d386b48 16-Aug-2023 Warner Losh <imp@FreeBSD.org>

Remove $FreeBSD$: one-line .c pattern

Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/


# a81b559d 06-Jul-2023 Vadim Goncharov <vadimnuclight@gmail.com>

Fix saving STRUCTURED-DATA in RFC 5424 log format

When saving log files in RFC 5424 format presence of STRUCTURED-DATA
in message caused line to not appear in log file at all, because
a variable forgotten to initialize. This could be tested by (slightly
modified) example from RFC:

echo '<165>1 2003-10-11T22:14:15.003Z mymachine.example.com su 12345 ID47 [exampleSDID@32473 iut="3" eventSource="Application" eventID="1011"][id@2 test="tast"] BOM"su root" failed for lonvick on /dev/pts/8" ' | nc -w1 -Uu /var/run/log

While here, update stale information in comment to logmsg() that RFC 5424
log format was not supported.

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/717


# 4d846d26 10-May-2023 Warner Losh <imp@FreeBSD.org>

spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSD

The SPDX folks have obsoleted the BSD-2-Clause-FreeBSD identifier. Catch
up to that fact and revert to their recommended match of BSD-2-Clause.

Discussed with: pfg
MFC After: 3 days
Sponsored by: Netflix


# 9589362b 28-Sep-2021 jfranklin13 <jfranklin13@protonmail.com>

syslogd: Fix bug that caused -N to drop SecureMode if specified after -s

MFC after: 2 weeks
Pull Request: https://github.com/freebsd/freebsd-src/pull/541


# 3b4cc56e 27-Sep-2021 Eugene Grosbein <eugen@FreeBSD.org>

syslogd: undo regression after r326573

Restore ability for our syslogd to collect pre-RFC3164 formatted
messages from remote hosts that was broken with r326573.

For example, the line from Cisco SCE8000 splitted for readability:

1130: 03:37:57: %USER-6-PORT_OPERSTATUS_CHANGE_TRAP: CPU#000 trap:link
down EntityAdminState: 4 EntityAlarmStatus: 32

Such line was collected and stored before mentioned change
but silently dropped after that. Now syslogd saves it again.

Note that parsing of RFC5424 format not changed.

MFC after: 1 month


# f06fa6f8 12-Jun-2021 Artem Khramov <akhramov@pm.me>

syslogd: fix WITHOUT_INET builds

Since 2d82b47 syslogd can't be built with `WITHOUT_INET` or
`WITHOUT_INET6` build variables set, because `iovlist_truncate` is not
defined but used.

This change wraps the problematic `iovlist_truncate` call within ifdef
directive. It's compiled out in this situation...

Pull Request: https://github.com/freebsd/freebsd-src/pull/475
Reviewed by: imp@ (commit message slightly tweaked)


# 2d82b47a 22-Mar-2021 Dmitry Wagin <dmitry.wagin@ya.ru>

syslogd: Increase message size limits

Add a -M option to control the maximum length of forwarded messages.
syslogd(8) used to truncate forwarded messages to 1024 bytes, but after
commit 1a874a126a54 ("Add RFC 5424 syslog message output to syslogd.")
applies a more conservative limit of 480 bytes for IPv4 per RFC 5426
section 3.2. Restore the old default behaviour of truncating to 1024
bytes. RFC 5424 specifies no upper limit on the length of forwarded
messages, while for RFC 3164 the limit is 1024 bytes.

Increase MAXLINE to 8192 bytes to correspond to commit 672ef817a192.

Replaced bootfile[] size for MAXPATHLEN used in getbootfile(3) as a
returned value. Using (MAXLINE+1) as a size for bootfile[] is excessive.

PR: 241937
MFC after: 1 month
Differential Revision: https://reviews.freebsd.org/D27206


# 37d8e9a3 10-Dec-2020 John-Mark Gurney <jmg@FreeBSD.org>

fix up documentation/comments: processname is not defined, but programname
is..

a couple other minor documentation fixes that igor caught...

MFC after: 1 week


# ce558a3f 07-Nov-2020 Cy Schubert <cy@FreeBSD.org>

Fix build post-r367455.

MFC after: 2 weeks
X-MFC with: r367455


# 9470af39 07-Nov-2020 Bryan Drewery <bdrewery@FreeBSD.org>

syslogd: Stop trying to send remote messages through special sockets

Specifically this was causing the /dev/klog fd and the signal pipe
handling fd to get a sendmsg(2) called on them and always returned
[ENOTSOCK].

r310350 combined these sockets into the main socket list and properly
skipped AF_UNSPEC at the sendmsg(2) call but later in r344739 it was
broken such that these special sockets were no longer excluded since
the AF_UNSPEC check specifically excluded these special sockets. Only
these special sockets have sl_sa = NULL. The sl_family checks should
be redundant now but are left in case of future changes so the intent
is clearer.

MFC after: 2 weeks


# b0eefff7 09-Oct-2020 Mark Johnston <markj@FreeBSD.org>

syslogd: Avoid trimming host names in RFC 5424 mode

RFC 5424 says that implementations should log hostnames in FQDN
format. Only trim host names in RFC 3164 mode.

PR: 250014
Submitted by: Dmitry Wagin <dmitry.wagin@ya.ru>
MFC after: 1 month
Differential Revision: https://reviews.freebsd.org/D26644


# 18bcf5a0 28-Apr-2020 Bryan Drewery <bdrewery@FreeBSD.org>

Restore local kernel "prog" filtering lost in r332099.

This behavior is most relevant for ipfw(4) as documented in syslog.conf(5).
The recent addition of property-based regex filters in r359327 is a
fine workaround for this but the behavior was present since 1997 and
documented.

This only fixes local matching of the "kernel program". It does not
change the forwarded format at all. On the remote side it will still
be "kernel: ipfw:" and not be parsed as a kernel message. This matches
old behavior.

MFC after: 2 weeks
Reviewed by: markj
Relnotes: yes
Differential Revision: https://reviews.freebsd.org/D24286


# 7d367c51 26-Mar-2020 Andrey V. Elsukov <ae@FreeBSD.org>

Add property-based filters for syslogd.

Property-based filters allow substring and regular expressions
(see re_format(7)) matching against various message attributes.
Filter specification starts with '#:' or ':' followed by three
comma-separated fields property, operator, "value". Value must be
double-quoted. A double quote and backslash must be escaped by a
blackslash.

Following properties are supported as test value:
o msg - body of the message received;
o programname - program name sent the message;
o hostname - hostname of message's originator;
o source - an alias for hostname.

Supported operators:
o contains - true if filter value is found as a substring of property;
o isequal - true if filter value is equal to property;
o startswith - true if property starts with filter value;
o regex - true if property matches basic regular expression defined
in filter value;
o ereregex - true if property matches extended regular expression
defined in filter value;

Operator may be prefixed by '!' to invert compare logic or by
'icase_' to make comparison function case insensitive.

Submitted by: Boris N. Lytochkin <lytboris at gmail com>
MFC after: 2 weeks
Relnotes: yes
Differential Revision: https://reviews.freebsd.org/D23468


# 9784899d 03-Mar-2019 Bjoern A. Zeeb <bz@FreeBSD.org>

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.

Reviewed by: ngie, hrs, ume
Welcomed by: Michael Dexter (D17040)
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D19418


# 27a1e609 02-Mar-2019 Hiroki Sato <hrs@FreeBSD.org>

Use struct addrinfo instead of struct sockaddr_storage
to store peer addresses.


# 22cd7e92 23-Feb-2019 Hajimu UMEMOTO <ume@FreeBSD.org>

An IPv6 address matching should be fixed. Specifying an IPv6
address by the -a option was broken since r309933.

Reported by: "O. Hartmann" <ohartmann [...] walstatt.org>
MFC after: 1 week


# 066a4ba1 07-Jul-2018 Ed Schouten <ed@FreeBSD.org>

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.

MFC after: 1 week


# 8a66bdb4 02-Jul-2018 Ed Schouten <ed@FreeBSD.org>

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
Reported by: Andre Albsmeier
MFC after: 1 week


# 531b4569 22-Jun-2018 Ed Schouten <ed@FreeBSD.org>

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
Reported by: Michael Grimm & Marek Zarychta
Reviewed by: glebius (cursory)
MFC after: 1 week


# 8803b859 18-Jun-2018 Ed Schouten <ed@FreeBSD.org>

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@
MFC after: 3 days


# 5992da2c 23-Apr-2018 Xin LI <delphij@FreeBSD.org>

Correct size for allocation and bzero of fdsr.

MFC after: 2 weeks


# 1a874a12 15-Apr-2018 Ed Schouten <ed@FreeBSD.org>

Add RFC 5424 syslog message output to syslogd.

- Move all of the code responsible for transmitting log messages into a
separate function, fprintlog_write().
- Instead of manually modifying a list of iovecs, add a structure
iovlist with some helper functions.
- Alter the F_FORW (UDP message forwarding) case to also use iovecs like
the other cases. Use sendmsg() instead of sendto().
- In the case of F_FORW, truncate the message to a size dependent on the
address family (AF_INET, AF_INET6), as proposed by RFC 5426.
- Move all traditional message formatting into fprintlog_bsd(). Get rid
of some of the string copying and snprintf()'ing. Simply emit more
iovecs to get the job done.
- Increase ttymsg()'s limit of 7 iovecs to 32. Add a definition for this
limit, so it can be reused by iovlist.
- Add fprintlog_rfc5424() to emit RFC 5424 formatted log entries.
- Add a "-O" command line option to enable RFC 5424 formatting. It would
have been nicer if we supported "-o rfc5424", just like on NetBSD.
Unfortunately, the "-o" flag is already used for a different purpose
on FreeBSD.
- Don't truncate hostnames in the RFC 5424 case, as suggested by that
specific RFC.

For people interested in using this, this feature can be enabled by
adding the following line to /etc/rc.conf:

syslogd_flags="-s -O rfc5424"

Differential Revision: https://reviews.freebsd.org/D15011


# 671d7001 07-Apr-2018 Ed Schouten <ed@FreeBSD.org>

Fix enough warnings that we can build syslogd on all targets at WARNS=6.

This also fixes the build on MIPS.

Reported by: cy (MIPS build failure)


# b484e3fe 06-Apr-2018 Ed Schouten <ed@FreeBSD.org>

Push RFC 5424 message format from logmsg() into fprintlog().

Now that all of parsemsg() parses both RFC 3164 and 5424 messages and
hands them to logmsg(), alter the latter to properly forward all RFC
5424 message attributes to fprintlog(). While there, make some minor
cleanups to this code:

- Instead of extending the existing code that compares hostnames and
message bodies for deduplication, print all of the relevant message
fields into a single string that we can compare ('saved').

- No longer let the behaviour of fprintflog() depend on whether
'msg == NULL' to print repetition messages, Simply decompose this
function into fprintlog_first() and fprintlog_successive(). This
makes the interpretation of function arguments less magical and also
allows us to get consistent behaviour across RFC 3164 and 5424 when
adding support for the RFC 5424 output format.

- As RFC 5424 syslog messages have a dedicated application name field,
alter the repetition messages to be printed on behalf of syslogd on
the current system. Change these messages to use the local hostname,
so that it's obvious which syslogd instance detected the repetition.
Remove f_prevhost, as it has now become unnecessary.

- Remove a useless strdup(). Deconsting the message string is safe in
this specific case.


# 228e9d5b 06-Apr-2018 Ed Schouten <ed@FreeBSD.org>

Remove some places where error messages are prefixed with "syslogd".

Due to using RFC 5424, the application name is stored in a dedicated
field. It can simply be passed as an argument to logmsg() now.


# 10b15433 06-Apr-2018 Ed Schouten <ed@FreeBSD.org>

Properly respect the passed in hostname for RFC 5424 messages.

Only override the hostname in case none is provided or when remote
hostnames should be ignored.


# 77f0ef9a 05-Apr-2018 Ed Schouten <ed@FreeBSD.org>

Add RFC 5424 syslog message parsing to syslogd.

Syslogd currently uses the RFC 3164 format for its log messages.One
limitation of RFC 3164 is that it cannot be used to log entries with
sub-second precision timestamps. One of our users has expressed a desire
for doing this for doing some basic performance measurements.

This change attempts to make a first cut at switching to RFC 5424 based
logging. The first step is to alter syslogd's input path to properly
parse such messages. It alters the logmsg() prototype to match the
fields of RFC 5424. The parsemsg() function is extended to parse both
RFC 3164 and 5424 messages and call into logmsg() accordingly.

Additional changes include:

- Introducing proper parsing of timestamps, so that they can be printed
in any desired output format. This means we need to infer the year and
timezone for RFC 3164 timestamps.
- Removing ISKERNEL. This can now be realised by simply providing an
APP-NAME (== "kernel").
- Extending RFC 3164 parsing to trim off the TAG prefix and using that
to derive APP-NAME and PROCID.
- Increase MAXLINE. RFC 5424 mentions we should support 2k messages.

Differential Revision: https://reviews.freebsd.org/D14926


# c176562d 20-Mar-2018 Gleb Smirnoff <glebius@FreeBSD.org>

Fix whitespace issues in r330034. No functional changes.


# 91766355 26-Feb-2018 David Bright <dab@FreeBSD.org>

Fix two memory leaks 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. While testing the modification, another leak was also
found and fixed.

PR: 198385
Submitted by: Sreeram <sreeramabs@yahoo.com>
Reported by: Sreeram <sreeramabs@yahoo.com>
Reviewed by: hrs
MFC after: 1 week
Sponsored by: Dell EMC
Differential Revision: https://reviews.freebsd.org/D14510


# 50387adc 05-Dec-2017 Gleb Smirnoff <glebius@FreeBSD.org>

When parsing remote messages, require them to have standard timestamp
field, and support properly parse out the hostname as described by RFC3164,
which wasn't done before. However, don't discard message if it doesn't
have hostname, for compatibility.

Enable logging of the message supplied hostname instead of real hostname
with -H switch.

PR: 200933
Reported by: Konstantin Pavlov <thresh nginx.com>
MFC after: 2 months


# eb7ec397 28-Nov-2017 Gleb Smirnoff <glebius@FreeBSD.org>

Revert r325558 as it is incorrect.


# 09f87661 28-Nov-2017 Gleb Smirnoff <glebius@FreeBSD.org>

Fix obvious NULL pointer dereference from r310350.


# 8a16b7a1 20-Nov-2017 Pedro F. Giffuni <pfg@FreeBSD.org>

General further adoption of SPDX licensing ID tags.

Mainly focus on files that use BSD 3-Clause license.

The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.

Special thanks to Wind River for providing access to "The Duke of
Highlander" tool: an older (2014) run over FreeBSD tree was useful as a
starting point.


# b9a63e5c 08-Nov-2017 Gleb Smirnoff <glebius@FreeBSD.org>

When parsing UDP messages skip optional hostname as described by
RFC 3164.

PR: 200933
Submitted by: maxim
Reported by: Konstantin Pavlov <thresh nginx.com>
MFC after: 2 weeks


# 02365345 15-Apr-2017 Maxim Sobolev <sobomax@FreeBSD.org>

Fix another logic bug that came out of recent syslogd refactoring and exposed by
the r316874: don't call shutdown(2) on all sockets, but only net ones, which seems
to be the behaviour existed before that refactoring. Also don't call listen(2)
in datagram sockets and fix misplaced debug messages while I am here.

Reported by: peter


# b98582b1 14-Apr-2017 Maxim Sobolev <sobomax@FreeBSD.org>

Since shutdown(2) on datagram socket is no longer a NOP after rev 316874
don't bother to select/recv on that socket. This prevents syslogd(8)
from spinning endlessly when started with the -s option (default).

Reported by: peter


# f7f99edf 20-Mar-2017 Hiroki Sato <hrs@FreeBSD.org>

Fix a regression which prevented an IPv6 address in a -b option from
working.

PR: 217939
Differential Revision: https://reviews.freebsd.org/D10064


# b79299b5 20-Mar-2017 Enji Cooper <ngie@FreeBSD.org>

syslogd: try to print out a more helpful message in socksetup(..) if/when
getaddrinfo fails

If the asprintf call fails, fall back to the old code (as a last ditch effort
to provide the end-user with helpful output).

Sponsored by: Dell EMC Isilon


# 9c2aa0a0 19-Mar-2017 Enji Cooper <ngie@FreeBSD.org>

syslogd: fix dprintf in socksetup(..)

- Make the explanation more complete
- Correct a minor grammar nit with verb tense.
- Don't emit the message if `pe->pe_name` is NULL (it doesn't
have much value).

MFC after: 1 week
Sponsored by: Dell EMC Isilon


# 4863f2fc 19-Mar-2017 Enji Cooper <ngie@FreeBSD.org>

syslogd: don't leak `f` on failure in cfline(..)

Free `f` if an unknown priority or facility is parsed with the function.

MFC after: 1 week
Reported by: Coverity
CID: 1368068
Sponsored by: Dell EMC Isilon


# a393b6c8 15-Mar-2017 Enji Cooper <ngie@FreeBSD.org>

syslogd: fix memory leaks in main(..) and allowaddr(..)

- main(..): free memory assigned to fdsr before calling die(..).
- allowaddr(..): free memory assigned to ap before returning from the
function early. Add a `err` goto label to reduce freeaddrinfo/free(ap)
logic duplication.

MFC after: 1 week
X-MFC notes: some of this is dependent on refactoring not MFCed
Reported by: clang static analyzer, Coverity
CID: 1367750 (ap leakage in allowaddr(..))
Submitted by: Tom Rix <trix@juniper.net>
Reviewed by: ngie
Sponsored by: Dell EMC Isilon, Juniper
Differential Revision: D10004


# fbbd9655 28-Feb-2017 Warner Losh <imp@FreeBSD.org>

Renumber copyright clause 4

Renumber cluase 4 to 3, per what everybody else did when BSD granted
them permission to remove clause 3. My insistance on keeping the same
numbering for legal reasons is too pedantic, so give up on that point.

Submitted by: Jan Schaumann <jschauma@stevens.edu>
Pull Request: https://github.com/freebsd/freebsd/pull/96


# 15f0eea5 24-Feb-2017 Enji Cooper <ngie@FreeBSD.org>

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)
Submitted by: John Bauman <john.bauman@isilon.com>
MFC after: 2 weeks
Sponsored by: Dell EMC Isilon


# 916aa577 06-Feb-2017 Enji Cooper <ngie@FreeBSD.org>

Sort sys/ #includes some more

MFC after: 1 week
X-MFC with: r313358
Sponsored by: Dell EMC Isilon


# 688e4de4 06-Feb-2017 Enji Cooper <ngie@FreeBSD.org>

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

MFC after: 1 week
Sponsored by: Dell EMC Isilon


# 72e28247 06-Feb-2017 Enji Cooper <ngie@FreeBSD.org>

Use a flexible array for TypeNames instead of hardcoding the array length

MFC after: 1 week
Sponsored by: Dell EMC Isilon


# bc64f428 06-Feb-2017 Enji Cooper <ngie@FreeBSD.org>

Fix typos in comments (returing -> returning)

MFC after: 1 week
Sponsored by: Dell EMC Isilon


# 2f1c6436 28-Jan-2017 Hiroki Sato <hrs@FreeBSD.org>

Fix a bug which caused not to create AF_LOCAL sockets when family
is specified.

Spotted by: Alex Deiter


# b4d60f98 11-Jan-2017 Hiroki Sato <hrs@FreeBSD.org>

Add more #ifdef INET and INET6.


# 8ffb87bf 31-Dec-2016 Hiroki Sato <hrs@FreeBSD.org>

- Use more descriptive names for variables.
- Set O_CLOEXEC to the signal pipe and /dev/klog.
- Use a single signal handler to catch both SIGHUP and SIGCHLD.
- Fix a bug which did FD_SET() the writer-end of the pipe.


# 00f6082b 31-Dec-2016 Hiroki Sato <hrs@FreeBSD.org>

Remove extra NULL-check before free(3).


# 34694ebe 30-Dec-2016 Hiroki Sato <hrs@FreeBSD.org>

Replace two fat signal handlers with function calls in
the main I/O multiplex loop. select() now watches
a pipe which is written by the new skinny signal
handlers and the received signals are handled inside
the loop sequencially.

This eliminates a complex signal mask to guarantee
async-signal safety.


# 407cd978 30-Dec-2016 Hiroki Sato <hrs@FreeBSD.org>

Retry to open an F_PIPE process when it dies unexpectedly.

Reported by: Eugene Grosbein
PR: 215335


# 77e315c9 24-Dec-2016 Hiroki Sato <hrs@FreeBSD.org>

- Fix -N flag (NoBind) for AF_LOCAL sockets.
- Do setsockopt(SO_RCVBUF) for AF_LOCAL sockets regardless of -s flag.


# d97b8afd 23-Dec-2016 Enji Cooper <ngie@FreeBSD.org>

Unbreak syslogd after r310494

Don't close all file descriptors greater than STDERR_FILENO (2) in
waitdaemon(..) -- only close fd (file descriptor for /dev/null used in
subsequent calls to dup2) if it's greater than STDERR_FILENO.

Reported by: subbsd@gmail.com, danny@cs.huji.ac.il
Pointyhat to: hrs
X-MFC with: r310494


# 4c06e939 24-Dec-2016 Hiroki Sato <hrs@FreeBSD.org>

- Remove unused code.
- Use closefrom().


# acdd9d6a 22-Dec-2016 Hiroki Sato <hrs@FreeBSD.org>

- More ifdef INET and INET6.
- Use STDERR_FILENO + 1 instead of "3".
- Fix dprintf() in cvthname().


# 732c7a25 22-Dec-2016 Hiroki Sato <hrs@FreeBSD.org>

- Fix a use-after-free bug when dq_timeout == 1 and
sending SIGTERM to the process failed. It is an
unusual situation but it can happen.
- Split deadq_remove() into deadq_remove() and
deadq_removebypid().
- Normalize variable names of struct deadq_entry *.


# 066f8db8 21-Dec-2016 Hiroki Sato <hrs@FreeBSD.org>

Add a missing "default:" case.


# dd87e059 21-Dec-2016 Hiroki Sato <hrs@FreeBSD.org>

Initialize a structure by using a compound literal to avoid forgetting
to zero unspecified members.


# 1ef75d66 21-Dec-2016 Hiroki Sato <hrs@FreeBSD.org>

Fix debug log in the case of AF_INET6.


# cb7c8422 21-Dec-2016 Hiroki Sato <hrs@FreeBSD.org>

- Simplify masklen->netmask conversion for AF_INET6.
- Use iov[N] by array index instead of using pointer v = &iov[0] to
make the compiler catch an out-of-range access of the array.


# bbe85c38 21-Dec-2016 Hiroki Sato <hrs@FreeBSD.org>

Simplify type casting of struct sockaddr_in.


# e46b059e 20-Dec-2016 Hiroki Sato <hrs@FreeBSD.org>

- Initialize deadq_head statically.
- Fix indent.
- Add missing -S flag into usage().
- Use nitems() for an iov array instead of a macro.


# e5610451 20-Dec-2016 Hiroki Sato <hrs@FreeBSD.org>

- Add fklog into struct socklist. Files and local/remote sockets are
now processed in struct socklist in a consistent manner.
- Add helper functions to add a new entry of struct socklist, filed, or peer.
- Use the same routine for -l, -p, and -S.
- Close /dev/klog when read(2) failed.


# c5323862 20-Dec-2016 Hiroki Sato <hrs@FreeBSD.org>

- Use fnmatch(3) for domanname matching of -a options.
- Document the patten matching.
- Document -S flag in SYNOPSIS.


# 2e0ef629 19-Dec-2016 Hiroki Sato <hrs@FreeBSD.org>

Add a NULL check.


# 27efdcd8 19-Dec-2016 Hiroki Sato <hrs@FreeBSD.org>

Add a default socket bound to *:514 when no -b option is specified.
This was accidentally removed at r309933.

Spotted by: Michael Butler


# a5636d2a 19-Dec-2016 Hiroki Sato <hrs@FreeBSD.org>

Add a missing STAILQ_INSERT_TAIL() for allowaddr rule.


# 442f3ba3 13-Dec-2016 Hiroki Sato <hrs@FreeBSD.org>

Remove an extra "break" which could incorrectly terminate an
STAILQ_FOREACH() loop when an AF_INET6 rule matched.

Spotted by: cem


# dc96a41b 12-Dec-2016 Hiroki Sato <hrs@FreeBSD.org>

- Refactor listening socket list. All of the listening sockets are
now maintained in a single linked-list in a transport-independent manner.
- Use queue.h for linked-list structure.
- Use linked-list for AllowedPeers.
- Use getaddrinfo(8) even for Unix Domain sockets.
- Use macros to type-casting from/to struct sockaddr{,_in,_in6}.
- Define fu_* macro for union f_un to shorten the member names.
- Remove an extra #include <sys/type.h>.
- Add "static" to non-exported symbols.
- !INET support is still incomplete but will be fixed later.

There is no functional change except for some minor debug messages.


# 8555a6e0 12-Dec-2016 Hiroki Sato <hrs@FreeBSD.org>

Temporarily backout the previous commit because it was totally broken due to
unresolved merge conflicts.

Pointy hat to: hrs


# 783e461c 12-Dec-2016 Hiroki Sato <hrs@FreeBSD.org>

- Refactor listening socket list. All of the listening sockets are
now maintained in a single linked-list in a transport-independent manner.
- Use queue.h for linked-list structure.
- Use linked-list for AllowedPeers.
- Use getaddrinfo(8) even for Unix Domain sockets.
- Use macros to type-casting from/to struct sockaddr{,_in,_in6}.
- Define fu_* macro for union f_un to shorten the member names.
- Remove an extra #include <sys/type.h>.
- Add "static" to non-exported symbols.
- !INET support is still incomplete but will be fixed later.

There is no functional change except for some minor debug messages.


# 8ecd7189 27-Nov-2016 Baptiste Daroussin <bapt@FreeBSD.org>

Properly initialize nextp

MFC after: 1 day


# dd83a7df 26-Nov-2016 Baptiste Daroussin <bapt@FreeBSD.org>

initialize *nextp which could be left uninitialized in case the configuration
file cannot be open/read

Reported by: Coverity via cem
MFC after: 2 days
CID: 1365665


# fdec22c3 31-Oct-2016 Baptiste Daroussin <bapt@FreeBSD.org>

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


# fafe86ce 11-Sep-2016 Baptiste Daroussin <bapt@FreeBSD.org>

Directly set the O_NONBLOCK flags via open(2)


# f32e43a6 27-Jan-2016 Alan Somers <asomers@FreeBSD.org>

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


# 24702765 25-Nov-2015 Kurt Lidl <lidl@FreeBSD.org>

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


# e54569ec 27-Aug-2015 Xin LI <delphij@FreeBSD.org>

die() would never return, mark it as so.

MFC after: 2 weeks


# c1987c28 04-Aug-2015 Enji Cooper <ngie@FreeBSD.org>

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


# baa55733 16-Jun-2015 Rui Paulo <rpaulo@FreeBSD.org>

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.


# e8716176 16-Jun-2015 Rui Paulo <rpaulo@FreeBSD.org>

syslogd: don't leak finet0.

Submitted by: Kurt Lidl <lidl pix.net>
Sponsored by: Pi-Coral, Inc.


# 38076b4b 16-Jun-2015 Rui Paulo <rpaulo@FreeBSD.org>

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.


# fb0e21cf 03-Mar-2015 Sergey Kandaurov <pluknet@FreeBSD.org>

Update .Dd, sync usage() for -F. Missed in previous change.


# 36285e78 03-Mar-2015 Rui Paulo <rpaulo@FreeBSD.org>

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)


# 0f0d5f6e 19-Feb-2015 Ed Schouten <ed@FreeBSD.org>

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


# bd496ef4 05-Feb-2015 Dimitry Andric <dim@FreeBSD.org>

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


# cf93a632 12-Dec-2014 Andrey V. Elsukov <ae@FreeBSD.org>

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


# f0c7dfca 12-Nov-2013 Ian Lepore <ian@FreeBSD.org>

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.


# 6a3e86ff 12-Nov-2013 Ian Lepore <ian@FreeBSD.org>

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.


# f35bb1a0 27-Apr-2013 Jilles Tjoelker <jilles@FreeBSD.org>

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


# f26612d3 20-Dec-2012 Mark Johnston <markj@FreeBSD.org>

- Make sure that errno isn't modified before calling logerror() in error
conditions.
- Don't check for AF_INET6 when compiled without INET6 support.

PR: bin/173930
Submitted by: Garrett Cooper <yanegomi@gmail.com>
Approved by: rstone (co-mentor)
MFC after: 1 week


# 39893d56 19-Oct-2012 Ed Schouten <ed@FreeBSD.org>

Add missing const keywords.


# 2c0a5e3c 12-Sep-2012 Baptiste Daroussin <bapt@FreeBSD.org>

Add support for ipv6 addresses as destination

PR: bin/150530
Submitted by: andy white <andywhite@gmail.com>
Tested by: Olivier Cochard-Labbe <olivier@cochard.me>
MFC after: 1 month


# 35741267 14-Jul-2011 Xin LI <delphij@FreeBSD.org>

Add a new option, -N to disable the default and recommended syslogd(8)
behavior, which binds to the well known UDP port.

This option implies -s.

MFC after: 2 months


# 98d1f19b 19-Jan-2011 David Malone <dwmalone@FreeBSD.org>

Here v->iov_len has been assigned the return value from snprintf.
Checking if it is > 0 doesn't make sense, because snprintf returns
how much space is needed if the buffer is too small. Instead, check
if the return value was greater than the buffer size, and truncate
the message if it was too long.

It isn't clear if snprintf can return a negative value in the case
of an error - I don't believe it can. If it can, then testing
v->iov_len won't help 'cos it is a size_t, not an ssize_t.

Also, as clang points out, we must always increment v here, because
later code depends on the message being in iov[5].


# a7d5f7eb 19-Oct-2010 Jamie Gritton <jamie@FreeBSD.org>

A new jail(8) with a configuration file, to replace the work currently done
by /etc/rc.d/jail.


# 974835c9 07-Aug-2010 Oliver Fromme <olli@FreeBSD.org>

syslogd(8) already supports *sending* log messages to non-
standard ports, but it can't *receive* them (port 514 is
hardcoded). This commit adds that missing feature.

(NB: I actually needed this feature for a server farm where
multiple jails run with shared IP addresses, and every jail
should have its own syslogd process.)

As a side effect, syslogd now compiles with WARNS=6.

Approved by: des (mentor)
MFC after: 3 weeks


# fe0506d7 09-Mar-2010 Marcel Moolenaar <marcel@FreeBSD.org>

Create the altix project branch. The altix project will add support
for the SGI Altix 350 to FreeBSD/ia64. The hardware used for porting
is a two-module system, consisting of a base compute module and a
CPU expansion module. SGI's NUMAFlex architecture can be an excellent
platform to test CPU affinity and NUMA-aware features in FreeBSD.


# b5810e94 13-Jan-2010 Ed Schouten <ed@FreeBSD.org>

Port all applications in usr.sbin/ from libulog to utmpx.


# 2734cf8c 24-Dec-2009 Ed Schouten <ed@FreeBSD.org>

Let syslogd use utmpx.

Because strings are guaranteed to be null terminated, there is no need
for excessive copying of strings, such as the line name.


# acd3c015 19-Dec-2009 Attilio Rao <attilio@FreeBSD.org>

MFC r199804:
Avoid sshd, crond, inetd and syslogd to be killed in an high-pressure
swapping environment.

Sponsored by: Sandvine Incorporated


# 7a7043c7 25-Nov-2009 Attilio Rao <attilio@FreeBSD.org>

Avoid sshd, cron, syslogd and inetd to be killed under high-pressure swap
environments.
Please note that this can't be done while such processes run in jails.

Note: in future it would be interesting to find a way to do that
selectively for any desired proccess (choosen by user himself), probabilly
via a ptrace interface or whatever.

Obtained from: Sandvine Incorporated
Reviewed by: emaste, arch@
Sponsored by: Sandvine Incorporated
MFC: 1 month


# 7ad0654c 19-Dec-2008 Xin LI <delphij@FreeBSD.org>

Constify 'name' field in struct funix. This commit makes syslogd(8)
WARNS?=6 on amd64 but I have not tested under universe so keep WARNS?=
level as-is for now.


# 2db461e4 17-Dec-2008 Tai-hwa Liang <avatar@FreeBSD.org>

Fixing !INET6 builds after bumping WARNS to 3.


# 58a841ef 17-Dec-2008 David E. O'Brien <obrien@FreeBSD.org>

Use passed parameter rather than the #define.
(more accurate extraction of Juniper Networks change)


# 97f37b32 17-Dec-2008 David E. O'Brien <obrien@FreeBSD.org>

Rather than hardcode the 'struct iovec iov' array size, use a #define.
While I'm here bump WARNS to 3.

Obtained from: Juniper Networks


# d7f03759 19-Oct-2008 Ulf Lilleengen <lulf@FreeBSD.org>

- Import the HEAD csup code which is the basis for the cvsmode work.


# cfcf794e 25-Sep-2008 David Malone <dwmalone@FreeBSD.org>

Add a flag, -T, that tells syslogd to always replace the timestamp on
messages from the network. We already replace malformatted timestamps
and this option lets us replace timestamps that are correctly formatted
but wrong.

PR: 120891
Submitted by: Thomas Vogt <thomas@bsdunix.ch>
MFC after: 1 week


# 16d2cd94 01-Sep-2008 David E. O'Brien <obrien@FreeBSD.org>

Remove extraneous NULL pointer check - the pointer is guaranteed to be non-NULL.


# 7e1535c5 09-Jul-2008 Maxim Sobolev <sobomax@FreeBSD.org>

Allow comment to be placed at the end of a configuration line.

MFC after: 2 weeks


# d7022add 13-May-2008 Brian Somers <brian@FreeBSD.org>

Add a -8 switch to syslogd to prevent it from mangling 8-bit data.


# 6f540420 20-Feb-2008 David Malone <dwmalone@FreeBSD.org>

Two no-op fixes to improve corretness of syslogd code:

1) Use [AP]F_LOCAL rather than [AP]F_UNIX.
2) When copying a pipe's name, use f->f_un.f_pipe.f_pname, not f->f_un.f_fname.

PR: 20889
Submitted by: Damieon Stark
PR: 116642
Submitted by: Jim Pirzyk
Reviewed by: md5


# e7ec0d57 10-Dec-2007 David E. O'Brien <obrien@FreeBSD.org>

+ Open ctty in non-blocking mode to avoid hangs during open and close(waiting
for the port to drain).
+ Handle "*" as a priority properly.
+ Test what is free'ed.
+ Dynamically determine length vs. hardcoding it.
+ Free the previous message buffer (f_prevline) only after logging all the
messages and just before the process exit. Also check f_prevline for NULL
before using it.
+ The time displayed is not synchornized with the other log destinations.
+ Fix a comment.

Obtained from: Juniper Networks


# 817a9ffc 05-Dec-2007 David E. O'Brien <obrien@FreeBSD.org>

style(9)


# b3e2f7a6 29-Sep-2006 Ruslan Ermilov <ru@FreeBSD.org>

Sync usage() with manpage's SYNOPSIS.


# be389c75 17-Apr-2006 Julian Elischer <julian@FreeBSD.org>

Add the ability to log to an arbitrary udp port as well as the
standard syslog port. This allows syslog to easily export lines of interest to
an external logging system.


# ae4f0fc3 30-Mar-2006 Christian S.J. Peron <csjp@FreeBSD.org>

Currently, if writing out a log entry fails, we unlink that log entry from our
internal list of logfiles. So if writev(2) fails for potentially transient
errors like ENOSPC, syslogd requires a restart, even if the filesystem has
purged.

This change allows syslogd to ignore ENOSPC space errors, so that when the
filesystem is cleaned up, syslogd will automatically start logging again
without requiring the reset. This makes syslogd(8) a bit more reliable.

MFC after: 1 week


# c503ddf2 06-Mar-2006 Pawel Jakub Dawidek <pjd@FreeBSD.org>

By default (for security reasons) syslogd(8) doesn't create log files
when they don't exist, but sometimes its quite useful (eg. we use
non-standard log files and memory backed /var/, which is populated on
boot).

Add -C option which tells syslogd(8) to create log files if they don't
exist.

Glanced at by: phk
MFC after: 3 days


# 327608b2 17-Oct-2005 Warner Losh <imp@FreeBSD.org>

style(9) nitlet:

foo() {
}

to

foo()
{
}


# c825862e 28-Sep-2005 Olivier Houchard <cognet@FreeBSD.org>

setsockopt() will return -1 on error, not 0.

Pointy hat to: Jeremie Le Hen


# 20c0b2d3 28-Sep-2005 Olivier Houchard <cognet@FreeBSD.org>

Use SO_REUSEADDR on the socket, to make the use of syslogd in jails easier.

Submitted by: Jeremie Le Hen <jeremie le-hen org>


# fa393916 24-Aug-2005 Pawel Jakub Dawidek <pjd@FreeBSD.org>

Use pidfile(3) in syslogd(8).


# 8e56d2ee 19-May-2005 Christian S.J. Peron <csjp@FreeBSD.org>

Add cases for ENOBUFS and ENETDOWN. We need to make sure that we
catch all transient errors. This fixes situations where transient
error conditions such as network interfaces losing carrier signals
or the system running out of mbufs would result in the permanent
removal of forwarding syslog messages.

MFC after: 1 week


# 4f101318 13-May-2005 Hajimu UMEMOTO <ume@FreeBSD.org>

NI_WITHSCOPEID cleanup. Neither RFC 2553 nor RFC 3493 defines
NI_WITHSCOPEID, and our getaddrinfo(3) does nothing special
for it, now.


# 15f3d79b 12-Apr-2005 Hiroki Sato <hrs@FreeBSD.org>

Add -S option which allows to change the pathname of the privileged
socket /var/run/logpriv.

Reviewed by: glebius and kensmith
MFC after: 2 days


# b4e85290 28-Mar-2005 Gleb Smirnoff <glebius@FreeBSD.org>

Check that supplied facility is not bigger than LOG_NFACILITIES.

PR: bin/79260
Submitted by: Shuichi KITAGUCHI


# f56bb70a 28-Dec-2004 David Malone <dwmalone@FreeBSD.org>

Allow ':' and '%' in hostname specifications so that we can specify IPv6
addresses and scope IDs.

MFC after: 3 weeks


# 62f29f30 28-Dec-2004 David Malone <dwmalone@FreeBSD.org>

Some syslog messages delimit the program tag with whitespace rather
than a colon, so don't allow whitespace in program names. To be
consistent with hostnames, don't allow whitespace in the program
name specifiers in syslog.conf either.

(The first change is by Markus from the PR, the second is mine.)

PR: 68691
Submitted by: Markus Oestreicher <m.oe@x-trader.de>
MFC after: 3 weeks


# d6c85264 17-Nov-2004 Giorgos Keramidas <keramida@FreeBSD.org>

Fix a minor comment typo: priveleged = privileged.


# a7c23514 11-Nov-2004 Ruslan Ermilov <ru@FreeBSD.org>

Really revert the whitespace change to usage().


# 24f3d18a 11-Nov-2004 Gleb Smirnoff <glebius@FreeBSD.org>

Change TABs back to spaces in usage string constants.

Requested by: ru


# 033b92f3 11-Nov-2004 Gleb Smirnoff <glebius@FreeBSD.org>

Whitespace.

Approved by: cvs diff -b


# 43af2cc4 11-Nov-2004 Gleb Smirnoff <glebius@FreeBSD.org>

Double receive buffer size on sockets.

PR: bin/72366
Ok'd by: dwmalone
Approved by: julian (mentor)
Obtained from: OpenBSD
MFC after: 1 month


# 240d5a9b 04-Nov-2004 Gleb Smirnoff <glebius@FreeBSD.org>

Protect against local flooder of /var/run/log. Do not loop forever in
syslog(3) if we are a priveleged program (sshd, su, etc.).

- Make syslogd open an additional socket /var/run/logpriv, with 0600
permissions.
- In libc, try to use this socket.
- Do not loop forever if we are using this socket (partial backout of 1.31)

Reviewed by: dwmalone, Andrea Campi <andrea webcom it>
Approved by: julian (mentor)
MFC after: 1 month


# 24744467 04-Nov-2004 Gleb Smirnoff <glebius@FreeBSD.org>

- Use stailqueue for sockets instead of socket buffer. Thus
remove limit for 20 sockets.
- Add possibility to specify file mode for sockets created with '-l'.
- Check that socket name in '-l' is absolute.

Reviewed by: dwmalone, Andrea Campi <andrea webcom it>
Approved by: julian (mentor)


# 486c8cc4 06-Aug-2004 Warner Losh <imp@FreeBSD.org>

Per letter dated July 22, 1999 remove 3rd clause of Berkeley derived software
(with permission of addtional copyright holders where appropriate)


# decbf84e 04-Jul-2004 Colin Percival <cperciva@FreeBSD.org>

Fix dofsync() declaration.

Pointed out by: dwmalone


# e1906bda 04-Jul-2004 Colin Percival <cperciva@FreeBSD.org>

Where syslogd would have fsync()ed a file in the past, instead set a flag
FFLAG_NEEDSYNC and fsync the file when select() next returns zero. This
dramatically speeds up the process of logging large amounts of data, while
leaving the essential semantics (that data can be expected to be on disk
if we crash) unchanged.

In my tests, this speeds up the rc phase of booting by 18-20%. [1]

YES PLEASE! by: phk [1]


# 2b1071b2 30-May-2004 David Malone <dwmalone@FreeBSD.org>

Also terminate program names if we hit a '/' - this is to be slightly
more friendly to postfix log messages.

PR: 50912
Submitted by: Stanislav Lapshansky <slapsh@slapsh.pp.ru>


# 0f2ffc4e 30-May-2004 David Malone <dwmalone@FreeBSD.org>

A log file name may now be prefixed by a '-' if it should not be
explicitly fsynced after kernel messages are logged. This option
should be syntax compatible with a similar option in Linux syslogd.

I've made some small changes to Pekka's patch, hoepfully I haven't
goofed anything.

PR: 66790
Submitted by: Pekka Savola <pekkas@netcore.fi>
Obtained from: Martin Schulze's syslogd
MFC after: 1 month


# 3b7e1201 29-May-2004 David Malone <dwmalone@FreeBSD.org>

Try to be more careful about using using the file descriptor f_file.
Syslogd should ensure that f_file is a valid file descriptor when
f_type is FILE, CONSOLE, TTY and for a PIPE where f_pid > 0. If the
descriptor is closed/invalid then the type should be set to UNUSED
or the pid should be set to 0.

To this end:
1) Don't close(f->f_file) if we can't send a message to a remote
host because the file descriptor used for remote logging is
stored in finet, not in f->f_file. f->f_file is probably
uninitialised, so I guess we usually end up closing fd 0.
2) Don't close PIPE file descriptors if they are invalid.
3) If the call to p_open fails, don't set the pid.

The OpenBSD patches in this area set f_file to -1 after the fd is
closed and then avoids calling close if f_file < 0. I haven't done
this, but it might be a good idea too.

Inspired by: PR 67139/OpenBSD


# 75030d06 29-May-2004 David Malone <dwmalone@FreeBSD.org>

Some string fixes.
1) Use strncpy on strings out of utmp.
2) Avoid running off the start of one string while removing white space.
(I've used slightly different code to OpenBSD here.)
3) Ignore trailing spaces in the priority.

PR: 67139
Submitted by: Xin LI <delphij@FreeBSD.org.cn>
Obtained from: OpenBSD


# 6f8c2640 29-May-2004 David Malone <dwmalone@FreeBSD.org>

Exit with a warning if the path to one of the logging sockets is
too long, rather than silently truncating them.

PR: 67139
Inspired by: OpenBSD


# ac3a1548 29-May-2004 David Malone <dwmalone@FreeBSD.org>

Fix some bugs that don't manifest themselves in practice.

1) Don't check for getopt returning '?', we have a default case.
2) Check if the priority is LOG_KERN correctly - in practice
LOG_KERN is 0, so it makes no difference. OpenBSD fixed a
different nearby bug that we don't have 'cos our definition
of LOG_MAKEPRI is different to OpenBSD's.

Copy a comment from OpenBSD, observing that LOG_KERN is 0.

Inspired by PR: 67139


# a9442131 29-May-2004 David Malone <dwmalone@FreeBSD.org>

Update a couple of comments.

PR: 67139
Submitted by: Xin LI <[3]delphij@FreeBSD.org.cn>
Obtained from: OpenBSD


# ef4dd325 26-May-2004 David Malone <dwmalone@FreeBSD.org>

Silence some constness and printf type warnings. Most of the
const fixes are ugly 'cos the types in an iovec aren't quite
right for a writev.


# 9323dbdb 31-Jan-2004 Ian Dowse <iedowse@FreeBSD.org>

Use strtol to parse the <%d> tags in printline() and printsys().
Sort local variables declarations in these functions.

Submitted by: bde


# ff96c77d 25-Jan-2004 Ian Dowse <iedowse@FreeBSD.org>

Be much more strict about parsing tagged log messages from /dev/klog;
if the line doesn't match ^<%d>, then treat it as a regular kernel
printf line. Previously if a kernel printf message started with "<"
it would be interpreted as a log message, often with LOG_EMERG
level. This was triggered by some printfs in sys/dev/aic7xxx/, and
can also happen with the partial lines that result if syslogd cannot
keep up with the rate of arrival of kernel messages.

Reviewed by: dwmalone
MFC after: 1 week


# de4aac0d 16-Nov-2003 David Malone <dwmalone@FreeBSD.org>

logerror is used in syslogd to log errors from syslogd itself. It
is possible for an error to occur while trying to log an error, and
this can result in infinite recursion (or at least until we run out
of stack).

Rather than this, we ignore requests to log an error while logging an
error.

PR: 51253
MFC after: 2 weeks


# 3c453e20 16-Nov-2003 David Malone <dwmalone@FreeBSD.org>

Remove an argument to printf that is unused.


# cc227858 17-May-2003 Gregory Neil Shapiro <gshapiro@FreeBSD.org>

Avoid a corrupt timestamp on the console

PR: 51587
Submitted by: Dmitry Sivachenko <mitya@cavia.pp.ru>
Approved by: re (rwatson)
MFC after: 3 days


# a22139f9 17-May-2003 Gregory Neil Shapiro <gshapiro@FreeBSD.org>

Avoid code duplication by using libutil's trimdomain() instead of
an incorrect re-implementation.

PR: 52223, 52342
Submitted by: Dan Nelson <dnelson@allantgroup.com>
Approved by: re (bmah/rwatson)
MFC after: 2 days


# 4095c651 04-May-2003 Gregory Neil Shapiro <gshapiro@FreeBSD.org>

Cleanup hostname matching in syslogd:

1. Hostnames were not treated case insensitively in all cases.

2. The method for stripping hostnames when reading the syslog.conf
differed from that when finding the hostname of an incoming request.
This lead to a broken match check. In my case, it meant I had to
have '@scooter.smi.example.com.example.com' to have 'logger.example.com'
properly save messages from 'scooter.smi.sendmail.com'.

3. Add paranoia to cfline() such that it doesn't try to access memory
outside of the bounds of the f_host string.

4. While I am here, get rid of an outdated comment, argv[{0,1,2}] are now
checked for NULL after the strdup() calls.

Reviewed by: dwmalone
MFC after: 1 week


# f3a9f784 21-Feb-2003 Thomas Quinot <thomas@FreeBSD.org>

Hostname specifications must allow commas in the value. They are
used to separate multiple host names.

Noted by: Dan Nelson <dnelson@allantgroup.com>
Reviewed by: roberto


# 7ac1f02e 12-Feb-2003 Thomas Quinot <thomas@FreeBSD.org>

Allow multiple hosts or programs to be named in program
or host specifications, eg:

!foo,bar
*.* /var/log/only_foo_or_bar.log

!-foo,bar
*.* /var/log/all_except_foo_or_bar.log

Reviewed by: roberto
Not objected to by: arch@


# 68883704 07-Nov-2002 Thomas Quinot <thomas@FreeBSD.org>

Factor out the code that determines whether a message must be skipped
as a consequence of a host or program name specification into a common
function, skip_pmessage.

Reviewed by: roberto


# cd9a4d5d 27-Oct-2002 Garrett Wollman <wollman@FreeBSD.org>

Add used #include <limits.h>.


# 50a4cf33 18-Oct-2002 Tim J. Robbins <tjr@FreeBSD.org>

Sync usage() with reality and sort it alphabetically.

PR: 42620
Submitted by: Jeff Ito
MFC after: 1 month


# 695df15d 06-Oct-2002 Dag-Erling Smørgrav <des@FreeBSD.org>

Avoid referencing a removed (and freed) queue entry. This partially reverts
revision 1.101 (which did not introduce the bug but made it harder to fix)

PR: misc/40363
Submitted by: David Dunham <dwdunham@isilon.com>
MFC after: 2 weeks


# f50b861c 23-Sep-2002 Daniel C. Sobral <dcs@FreeBSD.org>

Introduce to the !program specification a capability similar to the one
that already exists for hosts: being able to specify a section that applies
to every program *except* the one in question.

The normal syntax for program specification is still valid. For the new
capability, one uses:

!-program

Since there is no way to specify a program beginning with a dash in the old
syntax, as it would be interpreted as the case above, the following
alternative syntax to the original capability is provided:

!+program

This shouldn't introduce incompatibilities with any syslogd configuration
in production because -stable's syslogd does not support a dash anywhere in
the program specification.

MFC after: 2 weeks


# ef21d92f 04-Sep-2002 David Malone <dwmalone@FreeBSD.org>

Make syslogd -u treat "*" as all levels by explictly setting pri_cmp
for it.

While I'm here, add a the ability to say "!level" in a way which
should be compatible with Linux's syslogd.

PR: 28935
No objections: audit
MFC after: 2 weeks


# fcfce977 25-Aug-2002 Crist J. Clark <cjc@FreeBSD.org>

Don't give up on a remote log host when we get a EHOSTUNREACH or
EHOSTDOWN. These are often transient errors (when the remote host
reboots, temporary network problems, etc.), and we'd rather err on the
side of caution and keep trying send messages that never arrive than
just give up.

Note that this is not an implementation of the "back-off" methods
given in the PR. Those just seem too complicated. Why not just keep
trying each time? Trying and failing doesn't really consume
significantly more resources than if we were successful for each
message.

PR: bin/31029
MFC after: 1 week


# 7c33f2d1 25-Jul-2002 Robert Drehmel <robert@FreeBSD.org>

When parsing the program name from the incoming log message
from a client, accept all printable characters as being part
of the program name, except ':' and '[', because each is a
possible delimiter.


# 52384d03 25-Jul-2002 Robert Drehmel <robert@FreeBSD.org>

When reading a program name from the syslog configuration file,
do not stop copying it into a buffer when encountering a
non-alphanumerical character. Only stop at unprintable characters.
This makes syslogd work correctly with executables like `interp.bin',
`httpd_old', etc.

PR: misc/40941
MFC after: 1 week


# fc99a00c 22-Jul-2002 Hajimu UMEMOTO <ume@FreeBSD.org>

use IPV6_V6ONLY instead of non standard IPV6_BINDV6ONLY.

MFC after: 1 week


# 083500e4 23-Mar-2002 Dag-Erling Smørgrav <des@FreeBSD.org>

Remove spaces between (void) and function calls. Use TAILQ_FOREACH
instead of hand-rolled equivalent. Add curly braces for symmetry
around else.


# 91f3557e 23-Mar-2002 Dag-Erling Smørgrav <des@FreeBSD.org>

Parenthesize return values and pull an orphaned { back into the fold.


# 32b02794 23-Mar-2002 Dag-Erling Smørgrav <des@FreeBSD.org>

__FBSDID, ANSIfy function definitions, staticize functions and globals,
don't initialize globals to 0, some reindentation of declarations, some
comments added or reworded.


# 840f7e95 23-Mar-2002 Dag-Erling Smørgrav <des@FreeBSD.org>

Un-__P().


# e1178b3b 13-Feb-2002 Maxim Konovalov <maxim@FreeBSD.org>

Remove unnecessary setjmp.h.

Reviewed by: ru
Approved by: ru
Obtained from: OpenBSD
MFC after: 1 week


# 191c3043 13-Feb-2002 Maxim Konovalov <maxim@FreeBSD.org>

Unlink all log sockets at startup.

PR: misc/34839
Reviewed by: ru
Approved by: ru
Obtained from: OpenBSD
MFC after: 2 weeks


# 8da986fe 09-Jan-2002 Daniel Eischen <deischen@FreeBSD.org>

Initialze a stack variable with NULL to unbreak buildworld with -Wall.
I don't know about anyone else, but the compiler was always aborting
on this stupid warning, and has been doing so for weeks.


# 3a0ac995 05-Jan-2002 Archie Cobbs <archie@FreeBSD.org>

Add a new flag '-c' to disable repeated line compression when the output
is a pipe to another program, or, if specified twice, in all cases.

PR: bin/32420


# a53dffb7 27-Nov-2001 Dima Dorfman <dd@FreeBSD.org>

Make the default kernel prefix "kernel:" instead of the boot file,
with the old behavior available via the -o option (it might still be
useful if one has many kernels and cares which messages came from
which). If the boot file is not used as the prefix, it is still
logged once at startup.

This change is prompted by the fact that the boot file is now much
longer ("/boot/kernel/kernel" vs. "/kernel"), which significanlty
bloats the syslogd output.

Reviewed by: peter


# 4741693c 14-Nov-2001 Paul Saab <ps@FreeBSD.org>

If the mask length is zero, there is no need to convert it to a
netmask.

PR: 31947
Submitted by: Aaron Scarisbrick <aaronsca@hotmail.com>
MFC after: 1 week


# 46ae3bbf 30-Sep-2001 Dag-Erling Smørgrav <des@FreeBSD.org>

Check the return values from calls to malloc(), calloc(), strdup() etc.

Submitted by: Philippe Charnier <charnier@xp11.frmug.org>
MFC after: 2 weeks


# f28f539f 13-Sep-2001 Dag-Erling Smørgrav <des@FreeBSD.org>

Add a strcasecmp() call I forgot in my hurry to commit the previous fix.
Without this call, the hostname check would in some cases yield false
positives.

Pointed out by: ru


# db87d61a 13-Sep-2001 Dag-Erling Smørgrav <des@FreeBSD.org>

The previous commit appeared to just shove the bug under the carpet rather
than really solve it. This approach (inspired by Ruslan's patch) solves
the real problem by stripping the local domain off the host name in the
config line structure.

Also mark a bunch of code sections that either do not check the return value
of a strdup(), malloc() or calloc() call, or do not properly handle a NULL
return.


# a5cc8abe 12-Sep-2001 Dag-Erling Smørgrav <des@FreeBSD.org>

Fix logging from remote hosts, which has been broken since (at least) revision
1.64, i.e. July of last year. Also fix a minor style bug in the same code.

PR: bin/28634
Pointy hat to: dwmalone
Pointed out by: my buggy DSL router's remote logging facility


# 7e848a70 11-Sep-2001 Ruslan Ermilov <ru@FreeBSD.org>

Fixed the free(3) panic overlooked due to the -Wno-uninitialized.


# d3ca0b13 09-Sep-2001 Dima Dorfman <dd@FreeBSD.org>

- Silence warnings: apply `const' generously, mark some variables
__unused, and change local variables named `sin' (struct
sockaddr_in) to `sin4'. (`sin' conflicts with the definition of
sin(3), which gcc assumes to be defined even if math.h isn't
included (it's a builtin). This is probably a bug in gcc.)

- Apply WARNS=1. WARNS=2 was not used because this program assigns
string literals to (struct iovec).iov_base for writing, and the only
clean way to silence -Wwrite-strings in that case would be to
strdup() and consequently free() those literals, which I considered
too disruptive.

Reviewed by: bde (partially)


# 7e2f1d04 04-Sep-2001 Kris Kennaway <kris@FreeBSD.org>

Correct a last minute sizeof() bogon in my previous commit.


# f676ae2b 01-Sep-2001 Dima Dorfman <dd@FreeBSD.org>

Introduce a -b option that allows the user to specify which address to
bind to. This is useful for hosts running jails that need syslog to
maintain an open socket to log to a remote host.

Reviewed by: sheldonh


# dc2bdcbd 01-Sep-2001 Kris Kennaway <kris@FreeBSD.org>

Fix some unsafe signal handlers, and be careful not to overflow on fd_set.
Fix some string buffer operations.

Based on: OpenBSD
Reviewed by: audit
MFC after: 2 weeks


# ba1cc906 27-Aug-2001 Crist J. Clark <cjc@FreeBSD.org>

Gives syslogd(8) the ability to refresh its idea of the hostname of
the system on which it is running. The hostname is reloaded when
'HUPped' and a log message generated to note a change (before anyone
points it out, this is not an added security feature).

PR: bin/24444
Reviewed by: freebsd-audit
Approved by: ru
MFC after: 2 weeks


# 36c1612b 20-Aug-2001 Brian Somers <brian@FreeBSD.org>

Handle snprintf() returning -1.

MFC after: 2 weeks


# 74fd29e0 19-Jul-2001 Hajimu UMEMOTO <ume@FreeBSD.org>

- `-a' option for IPv6 was not working correctly.
- Lose any stray host bits that a user may have entered when providing
a network number and netmask to the `-a' option for IPv6. This is
corresponding to 1.79 that is for IPv4 only.

MFC after: 1 week


# 6ca048f8 02-Jul-2001 Crist J. Clark <cjc@FreeBSD.org>

Lose any stray host bits that a user may have entered when providing
a network number and netmask to the '-a' option.

Approved by: ru
MFC after: 1 week


# 38f612a1 21-May-2001 David Malone <dwmalone@FreeBSD.org>

Fix constness warning introduced in syslog.h 1.21.


# f0ee9598 10-May-2001 David Malone <dwmalone@FreeBSD.org>

Add the ability to specify alternate PID file for syslogd.

PR: 25784
Submitted by: Jon Villarreal <jonv@ivmg.net>
Reviewed by: iedowse


# e47bf70d 09-Mar-2001 Brian Somers <brian@FreeBSD.org>

MAXHOSTNAMELEN includes the NUL


# 8bc588fa 04-Feb-2001 David Malone <dwmalone@FreeBSD.org>

This seems to stop syslog console messages looping. The problem
is that LOG_FAC doesn't do quite what you think it does.

PR: 24704


# 38816289 16-Dec-2000 Hajimu UMEMOTO <ume@FreeBSD.org>

IPv6 support for syslogd.

Reviewed by: freebsd-current
Obtained from: NetBSD


# ea250e5b 25-Nov-2000 Poul-Henning Kamp <phk@FreeBSD.org>

Add the "LOG_CONSOLE" facility and tell syslogd to not log it on
console devices.


# 481a1902 17-Oct-2000 David Malone <dwmalone@FreeBSD.org>

Syslogd normally converts messages of facility kern to facility
user unless they come directly from the kernel. Document this and
add a flag to syslogd which prevents this conversion.

Sort getopt args while I'm at it.

PR: 21788
Submitted by: Andre Albsmeier <andre.albsmeier@mchp.siemens.de>


# 29441679 19-Sep-2000 Warner Losh <imp@FreeBSD.org>

Fix unexploitable off by one error as mentioned on Bugtraq.


# d3069399 06-Aug-2000 Paul Saab <ps@FreeBSD.org>

Update the usage string to reflect -n as an option.


# 2835a5d8 06-Aug-2000 Paul Saab <ps@FreeBSD.org>

Actually make syslogd understand the new -n option by putting it
in getopt.

Submitted by: Clive Lin <clive@CirX.ORG>


# 23e726a0 03-Aug-2000 David Malone <dwmalone@FreeBSD.org>

Sort cases in getopt switch statement.
Remove extra parens from my host selection commit.
Add white space after if, while, for and switch.
Get rid of braces around a single statement if.

There should be no functional changes in this commit.

Reviewed by: sheldonh


# 3b208425 03-Aug-2000 David Malone <dwmalone@FreeBSD.org>

Replace two calls to strlen+calloc+strcpy with strdup.

Reviewed by: sheldonh


# ede8823b 28-Jul-2000 Paul Saab <ps@FreeBSD.org>

Change option -r to -n inline with conventions we use elsewhere.
I guess it serves me right for using a patch directly from Jan
Koum. :)

Requested by: many


# 779fbd1b 28-Jul-2000 Paul Saab <ps@FreeBSD.org>

Add option 'r' to syslogd which will disable dns queries for every
request. This is useful when you have a large site pointed at a
single syslog server.

Submitted by: Jan Koum <jkb@yahoo-inc.com>


# a144588d 24-Jul-2000 David Malone <dwmalone@FreeBSD.org>

Allow syslogd to select messages based on the originating host in
a similar way to the way it can select messages from a given program.

Lines beginning with "+hostname" or "#+hostname" select messaes
from that hostname and lines beginning with "-hostname" or "#-hostname"
match messages not from that hostname.

There are some significant style issues left in the original program
selection code and the man page. This should be cleared up in some
later commits.

Reviewed by: sheldonh
Based on an original patch by: Bernd Walter <ticso@cicely8.cicely.de>
Man page stylist: sheldonh


# a8cc952f 07-Jun-2000 Kris Kennaway <kris@FreeBSD.org>

Prevent a non-exploitable remote buffer overflow.

Reported by: twitch <twitch@vicar.org>
Submitted by: Guido van Rooij <guido@gvr.org>
Reviewed by: security-officer


# e3975643 25-May-2000 Jake Burkholder <jake@FreeBSD.org>

Back out the previous change to the queue(3) interface.
It was not discussed and should probably not happen.

Requested by: msmith and others


# 740a1973 23-May-2000 Jake Burkholder <jake@FreeBSD.org>

Change the way that the queue(3) structures are declared; don't assume that
the type argument to *_HEAD and *_ENTRY is a struct.

Suggested by: phk
Reviewed by: phk
Approved by: mdodd


# 8d396be5 17-Apr-2000 Andrey A. Chernov <ache@FreeBSD.org>

Enable 8bit chars excepting high controls


# debf48c5 29-Feb-2000 Joerg Wunsch <joerg@FreeBSD.org>

Fix a nit in my previous commit: make SIGHUP and SIGCHLD restartable
as they ought to be. The description of SA_RESTART was a little
unobvious to me in the man page, so i missed it. Thanks to Bruce for
spotting this.

Submitted by: bde


# 6b5c2dd6 28-Feb-2000 Joerg Wunsch <joerg@FreeBSD.org>

Fix a serious bug in syslogd regarding the handling of pipes. The bug
would cause syslogd to eventually kill innocent processes in the
system over time (note: not `could' but `would'). Many thanks to my
colleague Mirko for digging into the kernel structures and providing
me with the debugging framework to find out about the nature of this
bug (and to isolate that syslogd was the culprit) in a rather large
set of distributed machines at client sites where this happened
occasionally.

Whenever a child process was no longer responsive, or when syslogd
receives a SIGHUP so it closes all its logging file descriptors, for
any descriptor that refers to a pipe syslogd enters the data about the
old logging child process into a `dead queue', where it is being
removed from (and the status of the dead kitten being fetched) upon
receipt of a SIGCHLD. However, there's a high probability that the
SIGCHLD already arrives before the child's data are actually entered
into the dead queue inside the SIGHUP handler, so the SIGCHLD handler
has nothing to fetch and remove and simply continues. Whenever this
happens, the process'es data remain on the dead queue forever, and
since domark() tried to get rid of totally unresponsive children by
first sending a SIGTERM and later a SIGKILL, it was only a matter of
time until the system had recycled enough PIDs so an innocent process
got shot to death.

Fix the race by masking SIGHUP and SIGCHLD from both handlers mutually.

Add additional bandaids ``just in case'', i. e. don't enter a process
into the dead queue if we can't signal it (this should only happen in
case it is already dead by that time so we can fetch the status
immediately instead of deferring this to the SIGCHLD handler); for the
kill(2) inside domark(), check for an error status (/* Can't happen */
:) and remove it from the dead queue in this case (which if it would
have been there in the first place would have reduced the problem to a
statistically minimal likelihood so i certainly would never have
noticed the bug at all :).

Mirko also reviewed the fix in priciple (mutual blocking of both
signals inside the handlers), but not the actual code.

Reviewed by: Mirko Kaffka <mirko@interface-business.de>
Approved by: jkh


# 922a51ee 23-Jan-2000 Philippe Charnier <charnier@FreeBSD.org>

Add section number to .Xr. Use .Pa for filenames.
fprintf -> warnx.


# 3a625563 14-Jan-2000 Dag-Erling Smørgrav <des@FreeBSD.org>

Do this the Right Way (tm), i.e. use shutdown() instead of fooling around
with the size of the receive buffer.

Pointed out by: ru


# e0d22b94 14-Jan-2000 Dag-Erling Smørgrav <des@FreeBSD.org>

Slight change of secure mode semantics: instead of reading (and counting)
vogons, set the size of the receive buffer to 1 and rely on the kernel to
simply drop incoming packets. The logging code was buggy anyway.

Use socklen_t instead of int for the length argument to recvfrom.

Add a 'continue' at the end of a loop for ANSI conformance.


# 533eb913 12-Jan-2000 Ruslan Ermilov <ru@FreeBSD.org>

Fix page fault in -vv mode.

PR: 16098
Submitted by: Alan.Judge@indigo.ie
Reviewed by: ru


# 97d92980 27-Aug-1999 Peter Wemm <peter@FreeBSD.org>

$Id$ -> $FreeBSD$


# 2d3411d3 16-Aug-1999 Brian Somers <brian@FreeBSD.org>

Make hostname comparisons case insensitive


# 70c03db5 06-May-1999 Dmitrij Tejblum <dt@FreeBSD.org>

readklog(): rename variable 'l' to 'len', to avoid possible confusion with 'i'
and '1'.

Requested by: mckay


# 4e880257 04-May-1999 Dag-Erling Smørgrav <des@FreeBSD.org>

Is there a limit to how stupid I can get?


# 1b44fb03 02-May-1999 Dmitrij Tejblum <dt@FreeBSD.org>

Little fix in previous: watch NUL-termination.


# 823da688 01-May-1999 Dmitrij Tejblum <dt@FreeBSD.org>

Fight with false newlines in kernel message logs. Output a line into log only
after we read a newline, or we have nothing to read from /dev/klog. Read
/dev/klog in non-blocking mode.


# d35f30aa 29-Apr-1999 Dag-Erling Smørgrav <des@FreeBSD.org>

Implement fascist mode (do not open a datagram socket at all).


# c807beb4 29-Dec-1998 Chris Timmons <cwt@FreeBSD.org>

Ensure a terminating null when processing hostname strings from
arbitrary sources.
Obtained from: OpenBSD


# e1b5d151 29-Dec-1998 Chris Timmons <cwt@FreeBSD.org>

Accept "!*" as a valid all-programs tag line as documented.
PR: 8447
Submitted by: Gaspar Chilingarov <nightmar@lemming.acc.am>


# 65f14c00 27-Dec-1998 Chris Timmons <cwt@FreeBSD.org>

Block SIGHUP during call to gethostbyaddr().
PR: 5548
Reviewed by: Matthew Dillon <dillon@apollo.backplane.com>
Obtained from: OpenBSD


# 60159a06 03-Dec-1998 Jordan K. Hubbard <jkh@FreeBSD.org>

Allow either tabs or spaces in configuration files.

PR: 8762
Submitted by: Igor Roshchin <str@giganda.komkon.org>


# 624bb2d1 05-Nov-1998 David Greenman <dg@FreeBSD.org>

When warning about discarding packets in secure mode, include the IP
address of the most recent offender.


# 352ef9ec 25-Aug-1998 Julian Elischer <julian@FreeBSD.org>

Submitted by: archie@whistle.com

quieten cc -Wall


# 6a19bdc8 27-Jul-1998 Poul-Henning Kamp <phk@FreeBSD.org>

Harlan.Stenn@pfcs.com added two (very interesting) options to syslogd for
-current (Thanks Harald). However, on my attempt to try this on -STABLE,
I found that when forwarding to another host the actual messages gets lost.
This is due to a wrong index because when the -v option was added, the
indexes shifted one place.

PR: 7407
Submitted by: Andre Albsmeier <andre.albsmeier@mchp.siemens.de>


# 2eec1ab0 22-Jul-1998 Poul-Henning Kamp <phk@FreeBSD.org>

Add -u, -v and -vv options to syslogd, this improves the control and
logging verbosity about facility & priority levels.
PR: 7278
Reviewed by: phk
Submitted by: Harlan Stenn <Harlan.Stenn@pfcs.com>


# 78cda230 06-Jul-1998 Bruce Evans <bde@FreeBSD.org>

Fixed printf format errors.


# 1af721d6 02-Jul-1998 Guido van Rooij <guido@FreeBSD.org>

Fix off by 1 error.


# 25d0f8a5 27-Jun-1998 Steve Price <steve@FreeBSD.org>

Note in log file if messages are being forwarded from a
remote machine.

PR: 7055
Submitted by: Edwin Groothus <edwin@nwm.wan.philips.com>


# 79962d3e 25-Jun-1998 Guido van Rooij <guido@FreeBSD.org>

Implement new argument -l (OpenBSD has -a but we already use that).
This allows one to specify additional sockets in the unix domain
that syslogd listens to. Its primary use is to create log sockets in
chroot environments.
Obtained from:OpenBSD (with a bug fixed d


# e2c597dd 24-Jun-1998 Julian Elischer <julian@FreeBSD.org>

Reviewed by: guido@mouse.gvr.org
Submitted by: Archie@whistle.com
redo the last patch to allow differentiated kernel logging in
a much better way.


# d2b4b1fa 09-Jun-1998 Julian Elischer <julian@FreeBSD.org>

Allow syslogd to separate out kernel log messages with a known
category.
e.g. separate out ipfw entries to a separate file.

Reviewed by: (briefly) phk
Submitted by: archie@whistle.com
Obtained from: Whistle source tree


# 76aba7e4 18-May-1998 Poul-Henning Kamp <phk@FreeBSD.org>

Remove a bogus dependency on the size of the inkernel msgbuf.
This change is likely to introduce a few linebreaks in the boot
messages, but that is not easy to solve without breaking syslogd
semantics. Maybe the right fix is to return an integral number
of lines from the kernel driver.

Noticed by: dg


# a9558767 06-May-1998 Brian Somers <brian@FreeBSD.org>

Make syslogd function in non-secure mode.
Log the correct ^2 packet as per the last commit comment.


# c46308e8 24-Apr-1998 Poul-Henning Kamp <phk@FreeBSD.org>

Augment the last change after some deliberation with rgrimes & peter.
It is important that we keep the ability to send packets to a remote
server and that the packets come from our well-known port, also in
that case.

Reviewed by: peter, rgrimes.


# 94a60328 22-Apr-1998 Poul-Henning Kamp <phk@FreeBSD.org>

Even with '-s', syslogd still creates an AF_INET socket, although
it is not bind(2)ed.

PR: 6366
Reviewed by: phk
Submitted by: Soren S. Jorvang <soren@dt.dk>


# 194787f3 28-Feb-1998 James Raynard <jraynard@FreeBSD.org>

Don't assume sigset_t and int are equivalent. Also, get
sigprocmask arguments the right way round.


# b8b7e105 19-Oct-1997 Philippe Charnier <charnier@FreeBSD.org>

Cosmetic in usage string.


# 173471e6 19-Sep-1997 Brian Somers <brian@FreeBSD.org>

Use snprintf() instead of sprintf() most of the time.
Obtained from: OpenBSD

Make usage() consistent with man page.


# 35486063 03-May-1997 Joerg Wunsch <joerg@FreeBSD.org>

Nobody ever seemed to be interested in reviewing these changes, and i
found that my syslogd is now running them for several months...

Add an option to syslogd to restrict the IP addresses that are allowed
to log to this syslogd. It's too late to develop the inter-syslogd
communications protocol mentioned in the BUGS section, some 10 years
too late. Thus, restricting the IP address range is about the most
effective change we can do if we want to allow incoming syslog
messages at all.

IMHO, we should encourage the system administrators to use this option,
and thus provide a knob in /etc/rc.* for it, defaulting to -a 127.0.0.1/32
(just as a hint about the usage).

Please state opinions about whether to merge this change into 2.2 or
not (i've got it running on RELENG_2_2 anyway).


# cf27d94b 25-Apr-1997 Paul Traina <pst@FreeBSD.org>

Whoops -- code inspection showed I forgot to clean up getopt string


# 26bed90f 25-Apr-1997 Paul Traina <pst@FreeBSD.org>

Secure mode (-s) incorrectly disabled both sending and receiving of syslog
packets over UDP. Secure boxes should still be able to send packets.


# 6c3f552a 30-Mar-1997 Warner Losh <imp@FreeBSD.org>

compare return value from getopt against -1 rather than EOF, per the final
posix standard on the topic.


# d086327d 13-Mar-1997 Joerg Wunsch <joerg@FreeBSD.org>

Save and restore the state of the variable Initialized inside die().
Otherwise, the shutdown message will print out with 15 NUL bytes in
front, due to a missing timestamp.


# 476602a9 22-Feb-1997 Peter Wemm <peter@FreeBSD.org>

Revert $FreeBSD$ to $Id$


# 5fadfc4c 21-Feb-1997 Joerg Wunsch <joerg@FreeBSD.org>

The "burn-in" phase has finished: this set of patches seems to run
stable now at a customer's site.

Finally add the ability to syslogd to pipe particular messages through
an arbitrary filtering command. Idea stolen from IRIX.

This code is courtesy of the interface business GmbH, Dresden.

Comment about whether to also merge this into 2.2 or not, please.

Reviewed by: (long ago) peter


# 1130b656 14-Jan-1997 Jordan K. Hubbard <jkh@FreeBSD.org>

Make the long-awaited change from $Id$ to $FreeBSD$

This will make a number of things easier in the future, as well as (finally!)
avoiding the Id-smashing problem which has plagued developers for so long.

Boy, I'm glad we're not using sup anymore. This update would have been
insane otherwise.


# e960bb49 03-Jan-1997 Jordan K. Hubbard <jkh@FreeBSD.org>

Unlink LogName before attempting to open it. Since we now have a lovely
bug in syslogd which causes it to die after random amounts of time (widely
reported), this at least allows the administrator to easily restart it
without wondering why it simply exits again each time.


# 5bb4699e 10-Dec-1996 Peter Wemm <peter@FreeBSD.org>

Revert part of the previous change. syslogd (when logging to ttys)
has always held an open file descriptor. This allowed logging to
spare virtual consoles and being able to switch to them.

My previous change removed this since all writes were done with ttymsg()
which opens it's own fd, and hence syslogd didn't need it's own fd to
send messages on... but this caused an unexpected behavior change.

This should close PR#2176


# a66a1e11 25-Nov-1996 Peter Wemm <peter@FreeBSD.org>

Don't close f->f_file on F_TTY types on error returns from ttymsg() since
it wasn't open in the first place..


# d486bc8f 25-Nov-1996 Peter Wemm <peter@FreeBSD.org>

Make the handling of the /dev/ prefix for tty names more consistant.
ttymsg() insists on them not being there.

Also, since ttymsg() opens the tty "on demand", don't keep an fd open
ourselves. This would interfere with HUPCL etc.

This should close PR#2103 from <xaa@stack.nl>


# a30a31bb 18-Nov-1996 Peter Wemm <peter@FreeBSD.org>

put on my flame resistant suit and tempt fate by attempting to fix some of
the races in my previous commits here, and fix some other problems with
syslogd as well.

- if the child process exited early (eg: could not bind to the socket),
the boot process would hang for 30 seconds. The parent was not noticing
that the child had exited. (my fault)
- when writing to tty devices, instead of treating them like files that
need \r\n instead of \n, actually use ttymsg() which has specific code
intended to write to potentially blocking ttys safely. I had a machine
lock up last night because /dev/console on a serial port got flow control
blocked. Setting comcontrol drainwait fixed everything but syslogd which
was going into a spin trying to write to the console and completely
ignoreing everything else.
- fix a couple of nonsensical bits of code while here.. eg: wait3 takes
a pointer to an int. There is no sense in declaring it as 'union wait',
then casting the pointer to (int *), then forgetting about it.


# 1c0899bb 28-Oct-1996 Joerg Wunsch <joerg@FreeBSD.org>

Back out the entire change from rev 1.11 of syslogd.c. It was bogus.
Correct the man page to reflect the new reality.


# 36be1f6b 23-Oct-1996 Julian Elischer <julian@FreeBSD.org>

Reviewed by: various (mailing list feedback)
Submitted by: whistle communications

move the socket from /dev to /var/run by default
TRANSITIONALLY make syslog add a symlink..
I PROMISE I'll remove that as soon as I have the makefiles etc fixed as well.


# 4ed8e95b 05-Oct-1996 Peter Wemm <peter@FreeBSD.org>

syslogd has always bugged me with it's async startup at boot time.
For me, more often than not, the backgrounded syslogd daemon is not
yet ready to process log messages before other things (such as named)
want to log a heap of them. It seems that it's the O_SYNC writes of
the stuff coming in from /dev/klog that's the slowdown.

Anyway, instead of using the libc daemon, roll a modified version. This
one has a timeout. The child will wait for either the timeout to expire
or the child process to signal it to let it know that it's "ready" and
the /dev/log socket is set up and active, so it's safe to continue the
boot. It adds a small fraction of a second pause to the boot time, but on
the other hand the overall boot time is *quicker* since the disk is not
being thrashed while the log messages are getting written out synchronously
one by one while other daemons are loading in parallel.

The timeout is in case the child segfaults or something before becoming
fully operational.


# a13e9951 22-Jul-1996 Paul Traina <pst@FreeBSD.org>

Bring in some fixes from NetBSD and re-hack our syslogd to be option-compatible
with theirs (change the -I option to -s (but leave -I in for backwards compat.)
Also eliminate an make sane some magic numbers, and fix a small bug where we'd
send to an unopened socket.

Reviewed by: wollman
Obtained from: NetBSD


# be467afa 14-Nov-1995 Peter Wemm <peter@FreeBSD.org>

With the recent 'make install' change in the kernel build makefiles, an
`interesting' feature of syslogd turned up. It calls getbootfile() for each
log entry. Since the kernel makefile now changes kern.bootfile when doing
a 'make install', it's quite startling to see the syslog lines change.

This change makes it call getbootfile() once at startup and cache it,
saving a syscall per loop, and keeping something a little more asthetically
pleasing in /var/log/messages...


# a2029046 12-Oct-1995 Garrett Wollman <wollman@FreeBSD.org>

Add a command-line option `-I' to disable logging from UDP.
Document `-d' and `-I'. Add a BUGS section noting that
logging from UDP is an unauthenticated remote disk-filling service,
and probably should be disabled by default in the absence of some sort
of authentication.


# df1e48c2 11-Sep-1995 Paul Richards <paul@FreeBSD.org>

Remove unconditional unlink at startup and conditionalised the unlink at exit
so that it only unlinks the file if syslogd knows it created it.

If the path specified for the socket already exists then syslogd
will now exit with an "address already in use" error which is more
sensible than blindly unlinking the existing filename. This stops
syslogd -d foo/bar from unlinking foo/bar if it's a real file.


# d9edc66f 22-Aug-1995 Paul Traina <pst@FreeBSD.org>

Fix up warning about const being lost.


# 709e8f9a 29-May-1995 Rodney W. Grimes <rgrimes@FreeBSD.org>

Remove trailing whitespace.


# d9dc7658 29-Dec-1994 Garrett Wollman <wollman@FreeBSD.org>

Extend syslogd to allow selection of log destinations by program.
Use getbootfile() to determine the kernel name.

Submitted by: Peter da Silva


# b3bfc719 05-Aug-1994 David Greenman <dg@FreeBSD.org>

Converted 'vmunix' to 'kernel'.


# dea673e9 25-May-1994 Rodney W. Grimes <rgrimes@FreeBSD.org>

BSD 4.4 Lite usr.sbin Sources