Commit Graph

852 Commits

Author SHA1 Message Date
Joachim Nilsson
d92f8466f8 syslogd: Minor refactor, move init code from main() to init()
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-12 16:42:44 +01:00
Joachim Nilsson
823bb4cf2a Support for building the project w/o separate klogd (default)
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-12 16:42:44 +01:00
Joachim Nilsson
0455da805f syslogd: Rename -R flag to -r, same as logger tool
Now that we've dropped the previous -r flag we can rename the rotation
flag so it's the same between both logger and syslogd.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-12 13:30:25 +01:00
Joachim Nilsson
6ac6abe60e test: Verify new secure mode, and remote log to default port
It's a lot easier to debug the remote test with Wireshark if we log to
the default service port on the remote host.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-12 13:28:02 +01:00
Joachim Nilsson
11ab6c55bc test: Don't overwrite bar.conf
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-12 13:28:02 +01:00
Joachim Nilsson
2f72a17b8e syslogd: If system has SO_REUSEPORT, use it
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-12 13:28:02 +01:00
Joachim Nilsson
095aa56996 Minor, don't touch PID file on SIGHUP in debug mode
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-12 13:28:02 +01:00
Joachim Nilsson
f606667038 syslogd: Add support for FreeBSD -s, secure mode
- Update man page
- Enable -s in default systemd service settings
- Add support for SecureMode, with shutdown()

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-12 13:28:02 +01:00
Joachim Nilsson
d607d6b845 syslogd: Update usage text and man page for new -b flag, drop -r
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-12 13:28:02 +01:00
Joachim Nilsson
762e09d7e8 syslogd: Drop -l HOST flag, the RFCs are very clear on this point
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-12 13:28:02 +01:00
Joachim Nilsson
d1035377cc syslogd: Drop -s HOST flag in favor of future BSD SecureMode
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-12 13:28:02 +01:00
Joachim Nilsson
4ee6211277 syslogd: Refactor internals to use new socket API
This patch is inspired, in part, by FreeBSD syslogd but now diverges
onto its own path.  Special handling for AF_UNIX sockets are required
on Linux, which unlike BSD cannot use getaddrinfo() on UNIX sockets.

- Rip out old funix[] and finet support
- Add new concept of peers
- Linked list of peers can be > 20
- Temporarily open up to accept all remote conns
- Remove old logerror(), replaced with new log macros

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-12 13:28:01 +01:00
Joachim Nilsson
07677c78a5 Graft struct addrinfo support on top of new socket API
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-12 13:28:01 +01:00
Joachim Nilsson
a4c1acbca8 syslogd: Drop -r flag, to be replaced with BSD -s (secure) flag
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-12 09:19:54 +01:00
Joachim Nilsson
c66411e8c2 Use new log macros and err.h fns
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-12 08:56:06 +01:00
Joachim Nilsson
53c2d0e3d9 Export flog() function and define new log macros ERR(), WARN(), etc.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-11 18:52:00 +01:00
Joachim Nilsson
90fb520c06 Add socket helper functions from SMCRoute, licesened as 3-clause BSD
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-10 11:22:14 +01:00
Joachim Nilsson
c31a7d1031 Minor refactor/cleanup
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-10 09:35:01 +01:00
Joachim Nilsson
a2feba69e2 Allow klogd to send LOG_KERN messages to syslogd
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-09 11:46:56 +01:00
Joachim Nilsson
b15420fdc5 syslogd: Inherit parsed PRI value in RFC3164 front-end
The RFC5424 front-end already does this.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-09 11:23:03 +01:00
Joachim Nilsson
9aaa7ec8c4 syslogd: Install SIGHUP handler earlier
When a heavily loaded system starts up syslogd may not in time reach its
original installation of the SIGHUP handler before receiving the signal.
It will then die and have to be restarted by PID 1.

This patch installs the SIGHUP handler early, with all the other signals
right after command line parsing.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-08 16:15:29 +01:00
Joachim Nilsson
9ed0fe672a Bump version for second release candidate
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-08 16:04:04 +01:00
Joachim Nilsson
dd5b470342 Fix assert when buffer->hostname == NULL at startup
Default to use 'from' in RFC3164 parser, just like the RFC5424 parser
already does.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-08 15:50:09 +01:00
Joachim Nilsson
0435139ec9 man: Formatting fixes for readability
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-08 13:56:16 +01:00
Joachim Nilsson
625a0d4abc Relicense example code/readme/makefile as public domain
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-08 13:43:37 +01:00
Joachim Nilsson
1546d3ce94 Bump version for v2.0-rc1 release candidate
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-08 13:23:33 +01:00
Joachim Nilsson
9a3d5b6a4d Mention syslogp() code example and Dr. Wettstein's formative work
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-08 13:21:41 +01:00
Joachim Nilsson
307dcd073e Revert "Disable clang in Coverity Scan run"
This reverts commit bafdb29743.
2019-11-08 12:39:45 +01:00
Joachim Nilsson
fbb7c5ce86 Minor, same look for contact information as previous maintainers
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-08 12:37:47 +01:00
Joachim Nilsson
0a3c5e1544 syslogd: Update usage text, drop -a add -b and simplify
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-08 08:50:17 +01:00
Joachim Nilsson
3377f07a5a klogd: Update usage text, no more -i or -I
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-08 08:50:17 +01:00
Joachim Nilsson
172ae92887 test: Extend API test with logger verifing structured data
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-07 23:21:33 +01:00
Joachim Nilsson
cc96379252 syslogd: Fix RFC5424 structured-data parser
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-07 23:21:33 +01:00
Joachim Nilsson
22c3fa9fa3 syslogd: Increase debug logging of raw incoming and parsed messages
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-07 23:21:33 +01:00
Joachim Nilsson
3f68d765db logger: Change usage text slightly for readability
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-07 23:21:33 +01:00
Joachim Nilsson
31815d6143 logger: Add NetBSD -d SD for RFC5424 structured data
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-07 23:21:31 +01:00
Joachim Nilsson
12d5536dfc Update man page with missing -u SOCK documentation
Also, update FILES section with correct information on the UNIX domain
socket path used on Linux.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-07 23:20:14 +01:00
Joachim Nilsson
60239756af Reference syslogp(3) instead of native/old syslog(3) API
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-07 23:20:14 +01:00
Joachim Nilsson
e25f835a5a logger: Add NetBSD -m MSGID support for logging RFC5424 style
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-07 23:20:11 +01:00
Joachim Nilsson
f2e1793cda logger: Add NetBSD -n option for LOG_NDELAY
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-07 22:03:11 +01:00
Joachim Nilsson
0aa57978ee logger: Add NetBSD -i option for LOG_PID
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-07 21:54:47 +01:00
Joachim Nilsson
d3461fd6a3 logger: Add NetBSD -c option for LOG_CONS
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-07 21:08:01 +01:00
Joachim Nilsson
fff4368e80 RFC5424 sec 6.1 states that we *should* support 2048 byte long msgs
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-07 20:56:02 +01:00
Joachim Nilsson
07033382ee Minor, type cast logit() argument for Coverity Scan
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-07 20:35:54 +01:00
Joachim Nilsson
11819e5b7f Type cast arguments to logit(), fixes warnings from Coverity
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-07 19:37:12 +01:00
Joachim Nilsson
884a0a180b Use correct format specifier for ssize_t, found by Coverity Scan
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-07 19:37:04 +01:00
Joachim Nilsson
774523f6e2 Fix missing argument to logit() and clean up unreadable code
Found by Coverity Scan

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-07 19:36:49 +01:00
Joachim Nilsson
7533f96ca9 Fix invalid/missing/extra argument to logit(), found by Coverity
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-07 19:24:38 +01:00
Joachim Nilsson
bafdb29743 Disable clang in Coverity Scan run
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-07 19:17:18 +01:00
Joachim Nilsson
6059d873a5 Fix stray 'g' that sneaked in last test update
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-07 19:13:28 +01:00