Commit Graph

865 Commits

Author SHA1 Message Date
Steffen Nurpmeso
949e80f150 Implement forced log file rotation upon SIGUSR2 2022-03-14 05:52:46 +01:00
Joachim Wiberg
23a6d81ea2
Merge pull request #45 from sdaoden/notify
Notify handle

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-03-14 05:45:17 +01:00
Steffen Nurpmeso
f7abd0d10a test/notify.sh: address Joachim Wiberg's comments (pull/45) 2022-03-12 17:22:18 +01:00
Steffen Nurpmeso
7038e51a0f "notify": address Joachim Wiberg's comments (pull/45) 2022-03-12 17:22:18 +01:00
Steffen Nurpmeso
bc103013cb Test for "Add "notify" keyword" 2022-03-12 15:29:33 +01:00
Steffen Nurpmeso
72f2faef6e Add "notify" keyword 2022-03-12 15:28:02 +01:00
Joachim Wiberg
6022d3c7d0 Fix #49: add support for -8 command line option to allow 8-bit data
This patch allows the user to disable the 8-bit data check in the log
message validator.  If you have experienced problems with logging any
unicode (utf-8) messages after v1.6, this option is for you.

The correct way to handle this is to add proper parser support for the
Unicode BOM, defined in RFC5424[1], as NetBSD syslogd does[2], search
for IS_BOM().

[1]: https://datatracker.ietf.org/doc/html/rfc5424#appendix-A.8
[2]: http://cvsweb.netbsd.org/bsdweb.cgi/src/usr.sbin/syslogd/syslogd.c?rev=1.138

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-03-07 20:57:00 +01:00
Joachim Wiberg
eb6e85e851 test: minor test cleanup and comments
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-03-06 01:10:32 +01:00
Joachim Wiberg
13b1fd0aa0 test: minor, shellcheck fixes
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-03-06 01:10:32 +01:00
Joachim Wiberg
0a99c7f386 test: minor aesthetic, slightly improve test logging
Conforming tests should use SKIP/FAIL/OK, so let existing tests follow
that better.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-03-06 01:02:03 +01:00
Joachim Wiberg
f29f31340c test: refactor and generalize setup(), adding a setup2()
This patch refactors the way the primary and secondary syslogd is
started by the test framework.  The generalizations not only make the
code more readable, it hopefully also makes it easier to add new tests
in the future.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-03-06 00:56:03 +01:00
Joachim Wiberg
7707715c78 man: update '-b' option description to match '-a' and usage text
The usage text (syslogd -?) and the syslogd.8 man page was not in sync
wrt. the -b option.  This patch updates it to match the layout of -a,
the -a option is also slightly updated.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-03-06 00:49:25 +01:00
Joachim Wiberg
aceb4cddcf Add missing -H option to usage text, issue #41
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-03-05 18:37:49 +01:00
Joachim Wiberg
99028414c3 test: run all syslogd with kernel logging disabled
Since we currently cannot test kernel logging, and we don't want to risk
any log messages from the kernel to suddenly pop up and disturb tests,
this patch explicitly disables it.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-03-05 16:33:52 +01:00
Joachim Wiberg
e4330515e8 Disable KernLog in container
No need to save seqno when we've detected being in container and have
disabled kernel logging.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-03-05 15:31:46 +01:00
Joachim Wiberg
40622ef6c7 Fix build error introduced when fixing issue #48
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-03-05 15:31:46 +01:00
Joachim Wiberg
05e2a31662 Bump version for v2.4.0 development cycle
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-03-05 15:31:46 +01:00
Joachim Wiberg
c534556790 Auto-detect if we're running in a container and disable klogd
This patch adds a very rudimentary container check.  When one, of a
select few containers, are detected, sysklogd disables the kernel
logging -- since there's no point in logging kernel messages other
than from the host system.

Issue #48

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-02-14 00:28:28 +01:00
Joachim Wiberg
29e932008d Fix #48: add option ('-K') to disable kernel logging
This patch adds support for disabling kernel logging, opensys().  This
is in addition to the character device validation check, and primarily
for use in container use-cases -- where logging kernel is not needed.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-02-13 23:40:06 +01:00
Joachim Wiberg
49b99584a4 Verify the kernel log fifo is a proper character device
Issue #48 describes a problem with 100% CPU load in a container
use-case.  Turns out one of the issues was that /dev/kmsg was
not a proper character device.  This patch adds a very basic
check to ensure /dev/kmsg is usable.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-02-13 23:03:30 +01:00
Joachim Wiberg
e61e5abb88 Follow-up to 9856e07, rename '-K' option to '-t'
We need the '-K' option to disable kernel logging, so this option needs
to be renamed, unfortunately.  Fortunately it's not been released yet.

Issue #42

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-02-13 22:53:02 +01:00
Joachim Wiberg
f38fd01871
Merge pull request #44 from loebl/docs/small-typo-fixes
Docs/small typo fixes
2021-12-21 17:32:55 +01:00
Loebl
2c9c5263b6 Remove excess character 2021-12-21 16:34:16 +01:00
Loebl
32f5a98efe Fix log rotation option reference 2021-12-21 16:32:20 +01:00
Joachim Wiberg
03c2c9c68d Update changelogs for v2.3.0 (final) release
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-11-27 21:20:21 +01:00
Joachim Wiberg
f4f2ad365e Redo DNS lookup on failure to send to remote server
When entering the forwarding suspend timer, free any previous address
info and do a new DNS lookup when the timer elapses.  The failure to
send may be because we're using a stale IP address.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-11-27 20:21:45 +01:00
Joachim Wiberg
f516ff6023 Fix #36: retry DNS lookup of remote syslog servers with res_init()
This patch replaces the INET_SUSPEND_TIME for DNS lookup with a 5 sec
back-off to prevent DNS lookup on each message.

Also, reorder WARN() and NOTE() so they are called *after* setting the
f_type, otherwise we unleash endless recursive loops.

To avoid filling up the log with "Failed resolving ..." messages every
time we retry, we set a flag to remember we've already logged warning.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-11-27 20:18:21 +01:00
Joachim Wiberg
0a0380cbdd Minor, spellcheck comments
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-11-27 19:16:41 +01:00
Joachim Wiberg
9856e07e40 Fix #42: add option to always trust kernel timestamp
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-11-26 06:50:31 +01:00
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