Commit Graph

326 Commits

Author SHA1 Message Date
Joachim Nilsson
fe3066f4c2 Connect to syslogd using SYSLOG_UNIX_PATH variable, if set
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-03 15:52:13 +01:00
Joachim Nilsson
cedff49662 Minor change to ingress
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-03 12:23:05 +01:00
Joachim Nilsson
8f582259d8 Document difference in log formats between RFC3164 and RFC5424
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-03 12:19:57 +01:00
Joachim Nilsson
d63b2e68f6 Update example syslog.conf with relevant and modern defaults
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-03 12:19:37 +01:00
Joachim Nilsson
cebec1202b Update man pages with new per-rule options and fix old paths
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-03 12:19:06 +01:00
Joachim Nilsson
84aa897628 Consolidate option parsing for syslog.conf rules
This patch changes the syntax for per-rule log rotation and makes it
possible to have enable log rotation and RFC5424 output formatting.

The new syntax looks like this:

    	EXPR		ACTION			;OPT,OPT,...

Example:

	*.notice	-/var/log/messages	;rotate=1M:5,RFC5424

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-03 12:15:05 +01:00
Joachim Nilsson
4066a1e9bf Add FreeBSD facilities: LOG_NTP, LOG_SECURITY, LOG_CONSOLE, ...
This patch is a major refactor of the priority and facility parsing in
syslogd.  The "new" facilities are taken from FreeBSD and are de facto
interpretations of facilities otherwise "reserved for system use", as
GLIBC syslog.h puts it.

___
... and LOG_CRON_SOL, but only for completness.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-03 08:21:44 +01:00
Joachim Nilsson
ff4f2cdb31 Replace homegrown PID file functions with std BSD pidfile()
- Import pidfile() v1.11 from OpenBSD and libite (-lite) project
- Import utimensat() replacement, for systems that don't have it
- Simplify syslogd and klogd program start and PID file creation
- Rip out -i and -I from klogd, uses old PID file functions, and
  they're only kill(1) wrappers anyway

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-02 21:03:28 +01:00
Joachim Nilsson
1236334c39 Fix some memory leaks, found by Valgrind
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-02 21:03:28 +01:00
Joachim Nilsson
8c0304a977 Remember to document libsyslog API
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-02 14:14:12 +01:00
Joachim Nilsson
b0a3d5cdd9 Document new include /etc/syslog.d/*.conf support
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-02 14:13:34 +01:00
Joachim Nilsson
dc2e7c013c TODO before v2.0
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-02 11:49:43 +01:00
Joachim Nilsson
62c651a979 Adapt unit tests to leverage and test /etc/syslog.d/*.conf support
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-02 11:47:45 +01:00
Joachim Nilsson
917ef4ed1d Add support for include /etc/syslog.d/*.conf in /etc/syslog.conf
- Massive refactor of the .conf file parsing
- Add queue.h v1.43 from OpenBSD, has _SAFE versions unlike GLIBC queue.h
- Use queue.h list macros instead of homegrown linked list
- Adopt NetBSD reconf style; on failure to reload keep old config

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-02 11:46:29 +01:00
Joachim Nilsson
ddaa0a1a82 Factor out ConfFile parsing to separate function
Also, fix segfault when syslogd is started without a .conf file.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-10-31 19:37:37 +01:00
Joachim Nilsson
c6a19049dc Trim remote test, restore startup/log sleep 2
Even on my laptop it sometimes takes a bit too long for tshark to start
up and syslogd to actually FWD the $MSG to remote.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-10-31 12:07:52 +01:00
Joachim Nilsson
3ef86e98b1 Import NetBSD syslog.3 v1.33 as syslogp.3
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-10-31 11:00:15 +01:00
Joachim Nilsson
892ee80e59 Trim test times now that we've fixed the root cause on Travis-CI
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-10-31 10:52:27 +01:00
Joachim Nilsson
3f5ae0e861 Travis-CI: Run test suite as super user, avoid sudo from within test
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-10-31 10:46:49 +01:00
Joachim Nilsson
1c14168558 Travis-CI: Require sudo to be able to run tshark on loopback
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-10-31 10:43:08 +01:00
Joachim Nilsson
cd7d2ca0be sudo do what I mean
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-10-31 10:35:19 +01:00
Joachim Nilsson
ef00787c5c Show any errors from tshark/tcpdump in error log
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-10-31 10:15:01 +01:00
Joachim Nilsson
aad95082fb Drop -fno-strength-reduce from default CFLAGS not supported by Clang
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-10-31 10:13:36 +01:00
Joachim Nilsson
ba9e494db2 Travis-CI: Debug networking capabilities
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-10-31 10:09:46 +01:00
Joachim Nilsson
495325dc51 Let remote unit test exit on first error
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-10-31 10:04:36 +01:00
Joachim Nilsson
0afeba201b Maintain error code when make check fails
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-10-31 10:02:08 +01:00
Joachim Nilsson
7a605f1435 Increase delay in remote logging test for Travis-CI
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-10-31 09:53:56 +01:00
Joachim Nilsson
8adb82494e Show test-suite.log if make check fails
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-10-31 09:03:21 +01:00
Joachim Nilsson
af97a5bb0a Build libsyslog.la and install it with syslog.h and libsyslog.pc
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-10-31 08:39:09 +01:00
Joachim Nilsson
358cbae1dc Update README to reflect the RFC compliance bump
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-10-31 08:07:02 +01:00
Joachim Nilsson
96d7fe596a Travis-CI: Enable make check to run unit tests on push
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-10-30 21:29:49 +01:00
Joachim Nilsson
8f459d349a test: Check sending log messages to remote server works
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-10-30 17:14:29 +01:00
Joachim Nilsson
72bbee7812 syslogd: Add support for '-b :service' to bind to another port
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-10-30 17:08:26 +01:00
Joachim Nilsson
dfff48fb04 Convert man pages to mdoc format, remove sysklogd.8 man page
- Major cleanup, simplifications, grammar corrections
- Remove inappropriate sections
- Update syntax and add tables for facility and priority

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-10-30 15:56:30 +01:00
Joachim Nilsson
a1e5680aee Disable logger default file rotation, must now be enabled with -r
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-10-30 09:30:42 +01:00
Joachim Nilsson
eb10b94f55 Update usage text; -b/-c removed in favor of -R
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-10-30 09:19:54 +01:00
Joachim Nilsson
87292c6f95 Verify logging to local file via syslogd
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-10-29 13:58:56 +01:00
Joachim Nilsson
fc4840a698 Add support for -P pid_file, like FreeBSD syslogd
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-10-29 13:58:56 +01:00
Joachim Nilsson
b67d57cf59 Initial test framework: make check
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-10-29 13:58:56 +01:00
Joachim Nilsson
ec9c92987f Add support for logger -u /tmp/foo to log to alternate socket
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-10-29 10:43:14 +01:00
Joachim Nilsson
08aa942ffb Minor, staticify global variables and fix indentation
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-10-29 10:42:45 +01:00
Joachim Nilsson
48a9f1fdd7 Remove old TESTING mode, incl. tsyslogd and syslog-tst
This special build option enabled reading syslog messages from stdin on
syslogd.  It also disabled all other standard features of syslogd, which
made it a bit too far from the real thing.

A better approac is to start syslogd with -p /tmp/foo and let a test
application, e.g. logger -u /tmp/foo, connect using the standard UNIX
domain socket API.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-10-29 10:39:56 +01:00
Joachim Nilsson
b6dcef71dd Enable remote syslog messages for testing
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-10-29 09:09:05 +01:00
Joachim Nilsson
176ba2d095 Support for logging to a file/stdout using syslog API
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-10-29 09:08:37 +01:00
Joachim Nilsson
ee2d0ce106 Sync with FreeBSD syslogd to get full RFC5424 support
This massive patch brings support for parsing incoming syslog messages,
remote or local, to determine if format is RFC5424 or the older RFC3164.
For logging syslogd currently defaults to RFC3164 for local files and
supports RFC5424 for sending to remote servers.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-10-29 09:01:01 +01:00
Joachim Nilsson
4f45f3c22f Minor, misc cleanup and simplification
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-10-29 08:59:54 +01:00
Joachim Nilsson
e9a546c683 Only chdir("/") when detaching from TTY and backgrounding process
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-10-29 08:54:30 +01:00
Joachim Nilsson
4f5124cb79 Change command line option for log rotation, from -b/-c --> -R b:c
We want to use -b for binding to an address:port, like FreeBSD/NetBSD
supports using this option.  Unfortunately breaks existing setups in
the wild already.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-10-29 06:37:55 +01:00
Joachim Nilsson
b66090ce4f Minor, sync variable name with FreeBSD
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-10-28 20:42:40 +01:00
Joachim Nilsson
4c6aa23dba Add missing include guards
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-10-27 21:32:37 +01:00