Commit Graph

836 Commits

Author SHA1 Message Date
Joachim Wiberg
e69b0fe812 Fix #43: avoid assert() on and around 19 January 2038 03:14:07 UTC
When time_t wraps around on 32-bit UNIX systems we shouldn't assert (and
cause syslogd to be continously restarted) but instead try to handle the
wraparound more gracefully.

This change, initially proposed by Raul Porancea, checks for wraparound
and allows syslogd to continue on error.  Logging with invalid date is
better than no logs at all.  Thanks Raul for tracking this one down!

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-11-26 06:21:00 +01:00
Joachim Wiberg
cea845aaf4 libsyslog: handle EOVERFLOW from gettimeofday()
Turns out that gettimeofday() can return EOVERFLOW on systems with
32-bit time_t.  This occurs when the UNIX Epoch wraps around, the
exact time is 03:14:07 UTC on 19 January 2038.

EOVERFLOW is not documented in gettimeofday(2), but instead of messing
up the entire syslog message -- causing syslogd to drop it -- we can
handle the overflow by falling back to time(NULL) (returning seconds
since start of Epoch) and rely on syslogd to, in turn, handle the
wraparound gracefully.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-11-26 06:17:59 +01:00
Joachim Wiberg
30a5c6628d Avoid NULL pointers to internal logit() function
The logit() function winds up calling vfprintf(), GLIBC is friendly
enough to check for NULL and replace segfault with "(null)", but other
C-libs may not handle it as gracefully.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-11-26 06:02:49 +01:00
Joachim Wiberg
ac9749a240 Minor, slight improvement in debug output
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-11-24 09:03:07 +01:00
Joachim Wiberg
d297a23e5a test: remote: start a receiver syslogd to manually verify rfc3164
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-11-24 09:01:16 +01:00
Joachim Wiberg
9f6fbb3301 After initial read of /dev/kmsg, ignore kernel timestamp
The spec[1] says the /dev/kmsg timestamp is a monotonic clock and in
microseconds.  After a while you realize it's also relative to the boot
of the system, that fact was probably too obvious to be put in the spec.
However, what's *not* in the spec, and what takes a while to realize, is
that this monotonic time is *not* adjusted for suspend/resume cycles ...

On a frequently used laptop this can manifest itself as follows.  The
kernel is stuck on Nov 15, and for the life of me I cannot find any to
adjust for this offset:

    $ dmesg -T |tail -1; date
    [Mon Nov 15 01:42:08 2021] wlan0: Limiting TX power to 23 (23 - 0) dBm as advertised by 18:e8:29:55:b0:62
    Tue 23 Nov 2021 05:20:53 PM CET

Hence this patch.  After initial "emptying" of /dev/kmsg when syslogd
starts up, we raise a flag (denoting done with backlog), and after this
point we ignore the kernel's idea of time and replace it with the actual
time we have now, the same that userspace messages are logged with.

Sure, there will be occasions where there's a LOT of kernel messages to
read and we won't be able to keep track.  Yet, this patch is better than
the current state (where we log Nov 15).

[1]: https://www.kernel.org/doc/Documentation/ABI/testing/dev-kmsg

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-11-23 17:16:17 +01:00
Joachim Wiberg
c7e30c6bd0 Follow-up to eb454d7: use time(NULL) instead of weird calculus
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-11-23 17:14:31 +01:00
Joachim Wiberg
d18e485e0a .github: fix example build, relies on configure prefix
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-11-22 15:53:51 +01:00
Joachim Wiberg
f2fdc9043a .github: restore Build step and drop pwd debug
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-11-22 15:49:08 +01:00
Joachim Wiberg
76942ea6e9 .github: each workflow step resets back to the checked out dir
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-11-22 15:42:30 +01:00
Joachim Wiberg
4a3a5d213e .github: debug pwd
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-11-22 15:40:27 +01:00
Joachim Wiberg
22bfd79d8d .github: no need to run test with sudo, we use unshare now
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-11-22 15:18:28 +01:00
Joachim Wiberg
aad76ad03b test: refactor test.rc + start.sh + stop.sh -> lib.sh
Refactor test.rc, start.sh, and stop.sh into lib.sh that each test
sources and uses independently of each other.

More simplfication and cleanup needed.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-11-22 15:18:19 +01:00
Joachim Wiberg
2d95e0ccf0 test: fix search path for scripts
Fails when building in a sub-directory

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-11-22 11:22:04 +01:00
Joachim Wiberg
d0166e505d .github: add missing chmod arg and change --prefix
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-11-22 11:01:26 +01:00
Joachim Wiberg
7df454daa8 .github: try working around runner limitations in unshare
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-11-22 10:35:56 +01:00
Joachim Wiberg
50307c142c .github: simplify apt-get, from smcroute
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-11-22 05:02:28 +01:00
Joachim Wiberg
523926a07d test: initial refactor to support running in parallel in an unshare
The release suite fails with no permissions to dump loopback, so let's
run tests in an unshare, one per test, with and start as many syslogd as
needed for each test -- also easier to debug since all are then fully
stand-alone.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-11-22 04:59:23 +01:00
Joachim Wiberg
81eee2185e .github: sync release.yml apt-get with smcroute
Somehow tshark doesn't get installed with the correct permissions to dump loopback.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-11-22 04:58:16 +01:00
Joachim Wiberg
1018d4a7f4 Avoid NULL pointer to vsnprintf()
GLIBC is friendly enough to check for NULL and replace segfault with
"(null)", but other C-libs may not handle it as gracefully.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-11-22 04:35:01 +01:00
Joachim Wiberg
558caf1a10 .github: dump test logs from distcheck build directory
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-11-22 03:39:27 +01:00
Joachim Wiberg
f7b2479e7d .github: sync release with build, dump result of remote test
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-11-22 03:28:33 +01:00
Joachim Wiberg
6054df0864 Fix stray 'a' to AC_INIT(), release v2.3.0
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-11-22 02:25:38 +01:00
Joachim Wiberg
f62b70059e Update changelogs and bump version for v2.3.0 release
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-11-22 02:21:02 +01:00
Joachim Wiberg
f3ef9d7514 Revert "Extract version from GIT, inspiration from mdio-tools"
This reverts commit da7425f757.
2021-11-17 06:51:45 +01:00
Joachim Wiberg
17a62a7f31 Fix #41: add missing documentation for -H option
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-11-09 18:32:49 +01:00
Joachim Wiberg
37e05b6855 .github: add release general to automate release builds
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-11-08 07:05:56 +01:00
Joachim Wiberg
da7425f757 Extract version from GIT, inspiration from mdio-tools
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-11-08 07:05:56 +01:00
Joachim Wiberg
029115a23e Drop .deb package from release target
We're moving to automated releases using GitHub Actions, but the bots
cannot be trusted to do .deb packaging yet, so let's drop that from
the official release target for now.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-11-08 07:05:28 +01:00
Joachim Wiberg
1a91be0fca Adjust output from release target slightly (from mrouted)
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-11-08 07:05:28 +01:00
Joachim Wiberg
262ffea56b Update tag check in release-hook to prevent false positives
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-09-15 09:46:03 +02:00
Joachim Wiberg
340538ecaa .github: coverity: change step name to trigger build
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-07-27 00:14:56 +02:00
Joachim Wiberg
48930cd223 .github: add workflow for Coverity Scan (branch: dev)
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-07-27 00:01:53 +02:00
Joachim Wiberg
9d71746c17 .github: build: install systemd unit files in /tmp
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-07-26 23:46:05 +02:00
Joachim Wiberg
5d7c1e18d6 .github: build: install to fixed dir for pkg-config
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-07-26 23:43:01 +02:00
Joachim Wiberg
5163b76290 Drop Travis-CI in favor of GitHub Actions
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-07-26 23:38:07 +02:00
Joachim Wiberg
e89ccd44ec .github: build: rewrite and add clang+gcc build matrix
- add build matrix with both gcc and clang
 - run on all pushes and pull requests, except dev (coverity)
 - use DESTDIR for install, not --prefix
 - check install-strip with tree and ldd+size with usage
 - add example w/ libsyslog, from .travis.yml

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-07-26 23:31:44 +02:00
Joachim Wiberg
b0d4e4cc3f Fix #40: update docs and online help text wrt. caching of kmsg seqno
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-07-26 14:04:45 +02:00
Joachim Wiberg
5211bcee08 Update changelogs for upcoming release
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-07-01 00:12:41 +02:00
Joachim Wiberg
170673a18a Bump version for v2.3.0 release cycle, -beta1
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-07-01 00:01:27 +02:00
Joachim Wiberg
9ce3c2e8ec Fix #39: update tests to use -P fn and -C fn
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-06-30 23:00:09 +02:00
Joachim Wiberg
e381bc3620 Fix #38: add option -C file for alt. kernel seqno cache file
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-06-30 22:39:09 +02:00
Joachim Wiberg
39ffa1b4cb Fix #34: regression in internal logging, loss of restart msg
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-06-30 22:27:58 +02:00
Joachim Wiberg
75524d1878 syslogd: minor, improve flog() internal logging a bit
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-06-30 22:27:58 +02:00
Joachim Wiberg
eed3335caa logger: fix \m -> \n, found on Slackware current
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-06-30 22:27:58 +02:00
Joachim Wiberg
d7576c7fc0 syslogd.service: use journald socket, not /dev/log
This patch fixes integration with systemd-journald, and also sets the
now mandatory KillMode.

When running on systems with systemd-journald certain considerations
must be taken.  These are listed here:

  https://www.freedesktop.org/wiki/Software/systemd/syslog/

In it simplest form, the system as a whole logs through journald and
a BSD syslog daemon then gets its log messages from journald.

NOTE: due to issues with the Debian packaging of rsyslog, the sysklogd
      packages cannot be used to replace rsyslog.  First rsyslog must
      be purged to clear the syslog.socket symlink, then sysklogd can
      be installed.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-06-24 12:46:34 +02:00
Joachim Wiberg
287e009514 Fix #35: syslogd man page lists -v as verbose mode, is version
When syncing with the FreeBSD man page the audit missed this option.
The man page should detail what the daemon does, even though in this
case it would've been nice to have the FreeBSD behahvior for -v.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-06-22 08:24:43 +02:00
Joachim Wiberg
fc5096f1c2 syslogd: support for extracting user level messages from /dev/kmsg
It is well established practise on Linux to use /dev/kmsg (old or
new API) before syslogd is up (and /dev/log exists).  This patch
enables support for extracting non-kernel log messages and logging
them with their proper facility and priority.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-06-21 23:15:10 +02:00
Joachim Wiberg
7ce44f5b9e syslogd: ignore EINVAL from kernel, silently restart polling
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-06-21 23:14:57 +02:00
Joachim Wiberg
82b7e2bfcb man: update logger.1 with info on new -k option
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-06-21 23:12:54 +02:00