Commit Graph

669 Commits

Author SHA1 Message Date
Joachim Nilsson
0a8cecfa84 syslogd: Handle DNS lookup of unknown remote hosts in domark()
Refactor of nslookup of unknown remote syslog servers, both when
(re)reading the .conf file and at runtime.  This means we retry
DNS lookup every 30 sec, or INET_SUSPEND_TIME +/- 30 sec.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-29 11:23:05 +01:00
Joachim Nilsson
90dd1b1c37 syslogd: Always domark() timer, regardless of -mfoo value
The domark() timer handles a lot of the critical maintenance action in
syslogd, it must always be guaranteed to run.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-29 11:23:05 +01:00
Joachim Nilsson
280b5fd3ec syslogd: Fix blocking of SIGHUP/ALRM during logmsg()
Only block signals *after* all sanity checking of log message has been
completed, otherwise we will end up with blocked SIGHUP and SIGALRM.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-29 11:23:05 +01:00
Joachim Nilsson
05c5b6752d syslogd: Always create PID file, even in debug mode
We definitely want to be able to run syslogd in debug mode for extended
periods of time and still run under finit/systemd or similar, letting
users know we run as 'PID'.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-29 11:23:05 +01:00
Joachim Nilsson
8e255b7f9d syslogd: Only set debugging_on in Debug (-d) mode
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-28 15:27:52 +01:00
Joachim Nilsson
b7d4225ef1 syslogd: Retry address lookup forever, never give up
When logging to a remote server, using @fqdn syntax in syslog.conf,
syslogd calls getaddrinfo() to resolve the IP address.  Older versions
of syslogd gave up after 10 retries.  We want to retry forever since we
may be running in a setup with bad network connection to the DNS server
for longer periods of time.

This patch only removes the 'give up' mechanism, which unfortunately
reused the f_prevcount value, which in turn could cause that value to
become -1 and thus trigger an assert().  With this code out of the way,
and the type change in the previous commit, the counter can never again
be negative.

Note: The configurable suspend time before trying again remains at its
default of 3 minutes.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-28 14:53:07 +01:00
Joachim Nilsson
49e168601e syslogd: Change f_prevcount type; int --> size_t
If it wraps around to zero we want to log the message anyway.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-28 14:39:12 +01:00
Joachim Nilsson
90a993f5a2 Update ChangeLog and bump version for v2.0.2 release
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-28 10:08:03 +01:00
Joachim Nilsson
1d8fe4944d syslogd: Reset prevcount in fprintlog_first() to prevent assert()
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-28 10:00:34 +01:00
Joachim Nilsson
3d4b8cb84d syslogd: Improve log messages on error, eg. INET sendto()
When we fail sending to a remote host, help admin debug the issue by
stating which remote we failed to send to.

Also minor changes to other similar error messages, use same form.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-28 09:38:22 +01:00
Joachim Nilsson
0e6c141f4f Fix #6: Add workaround for systems with vanilla/older autoconf
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-26 21:42:36 +01:00
Joachim Nilsson
87cef2d268 Update ChangeLog and bump version for v2.0.1
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-25 14:06:47 +01:00
Joachim Nilsson
84b7acf55f Allow --prefix= to install to /sbin
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-25 12:50:09 +01:00
Joachim Nilsson
15b8d386b3 Expand directories for configuration summary
Unexpanded defaults:

  sysconfdir  => ${prefix}/etc
  runstatedir => ${localstatedir}/run

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-25 12:14:18 +01:00
Joachim Nilsson
7793fcbd14 Fix #3: Don't guess PID file location, use configure --runstatedir
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-24 18:52:31 +01:00
Joachim Nilsson
4396004fba Add missing '-k' and '-T' command line flags to getopt()
Fixes GitHub issue #2

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-24 18:38:26 +01:00
Joachim Nilsson
b80a225f73 Minor, simplify previous commit and add logger on/off to summary
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-18 17:54:35 +01:00
Joachim Nilsson
076bd964cf
Merge pull request #1 from Polynomial-C/optional_logger
build: make logger and its man page optional
2019-11-18 17:39:00 +01:00
Lars Wendler
227008ec0f
build: make logger and its man page optional
There are other packages that provide a logger program like util-linux
We should respekt that

Signed-off-by: Lars Wendler <polynomial-c@gentoo.org>
2019-11-18 12:36:25 +01:00
Joachim Nilsson
b22e1339c9 Update ChangeLog and bump version for v2.0 release
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-15 11:16:09 +01:00
Joachim Nilsson
c2061b8f53 Add workaround for systemd unit files in distcheck
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-15 11:07:46 +01:00
Joachim Nilsson
7937cd0f55 test: Include new fwd.sh test in dist
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-15 11:07:28 +01:00
Joachim Nilsson
e45d7d0671 test: No need to export MSG variable
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-15 11:07:15 +01:00
Joachim Nilsson
c7122811fb Remove files that are no longer needed
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-15 10:08:14 +01:00
Joachim Nilsson
ac8b8ebf0d klogd.8: Remove wording on role and superiority over syslogd
For most use-cases a kernel with CONFIG_KALLSYMS and a stand-alone
syslogd is sufficient.  No need for the complexity of klogd.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-15 09:59:18 +01:00
Joachim Nilsson
49968d977e syslogd.8: Update section on SECURITY and .conf differences
- We have the -a PEER and -s to limit exposure to remote attacks
- Mention include file syntax in .conf file differences section
- Mention SECURITY section in BUGS, there are countermeasures

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-15 09:44:15 +01:00
Joachim Nilsson
8dda39c382 logger.1: Clarify use of stand-alone log file
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-15 09:24:23 +01:00
Joachim Nilsson
245dea43bc test: Sender randomizes port, allow any in FWD test syslogd
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-15 09:11:53 +01:00
Joachim Nilsson
6bf74351c7 Final touches to ChangeLog for v2.0 release
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-15 08:58:41 +01:00
Joachim Nilsson
a2d88e732e Update feature list and add <PRI> field to logo :)
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-15 08:58:16 +01:00
Joachim Nilsson
f44a026d86 syslogd: Fix broken wallmsg(), off-by one iov
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-15 08:31:46 +01:00
Joachim Nilsson
bd5903509d syslogd: Fix RFC3164 formatting, no space after <PRI> field
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-15 08:26:21 +01:00
Joachim Nilsson
7343c55f6e test: Shift delay to *really* wati for tshark to start before logging
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-14 01:40:33 +01:00
Joachim Nilsson
fcded43abf test: Add FWD test, two syslog daemons, a custom port and RFC5424
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-14 01:36:41 +01:00
Joachim Nilsson
eb524bf8da syslogd: Minor man page update after last command line change
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-14 01:20:00 +01:00
Joachim Nilsson
09f6b7bf6c syslogd: Minor, don't log to console when exiting ...
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-13 19:13:49 +01:00
Joachim Nilsson
54edca09d9 syslogd: Close open UNIX and inet sockets on SIGTERM
When creating Inet sockets we may get multiple struct addrinfo records.
With this patch we support up to 16 records per Internet peer.  When
closing we iterate over all peers and all records.

Refactor socket_close() to clean up any lingering socket path when
closing UNIX socket.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-13 19:11:34 +01:00
Joachim Nilsson
4192e543a5 syslogd: Use common nomenclature for next pointer
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-13 18:44:01 +01:00
Joachim Nilsson
6350bf2474 syslogd: Fix invalid free(), found by Valgrind
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-13 18:44:01 +01:00
Joachim Nilsson
b0ff1aa5c7 Travis-CI: Fix build w/o messing up example code build
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-13 17:54:35 +01:00
Joachim Nilsson
e373165a3a Revert "Travis-CI: Disable clang for Coverity Scan run"
This reverts commit 113168f53a.
2019-11-13 17:28:04 +01:00
Joachim Nilsson
1599eb904f Travis-CI: Use DESTDIR instead of --prefix to work-around systemd
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-13 17:26:46 +01:00
Joachim Nilsson
113168f53a Travis-CI: Disable clang for Coverity Scan run
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-13 17:19:20 +01:00
Joachim Nilsson
0f0f8f845d syslogd: Add FreeBSD and NetBSD -n flag to disable DNS query
This patch re-adds the -n flag, but now to disable DNS reverse-query for
all incoming messages.  This can potentially speed up logging a lot for
small/embedded systems that act as log sink.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-13 17:16:51 +01:00
Joachim Nilsson
cf9d281e5b syslogd: Adopt FreeBSD -F instead of -n to run in foreground
This change will probably break most installations.  We do this to free
up '-n' for use as disabling DNS lookups, from FreeBSD *and* NetBSD.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-13 17:08:47 +01:00
Joachim Nilsson
9d415f313f syslogd: Add FreeBSD -k option to allow LOG_KERNEL facility messages
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-13 16:44:51 +01:00
Joachim Nilsson
c465f340bc syslogd: NetBSD/FreeBSD -T option, log remote msgs with local time
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-13 16:16:23 +01:00
Joachim Nilsson
12fa1f6682 syslogd: Accept pre-RFC3164 formatted messages from remote hosts
This patch makes us wire-compatible with older versions of ourself, and
current versions set up to use default remote format.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-13 16:09:20 +01:00
Joachim Nilsson
06b26aae7b syslogd: Reformat usage text a bit for readability, hopefully
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-13 15:16:05 +01:00
Joachim Nilsson
0c61fe73f2 logger: Sort options in usage text alphabetically
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-13 14:49:05 +01:00