Commit Graph

331 Commits

Author SHA1 Message Date
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
64c6866667 Minor, drop debug log message for normal case
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-07 19:08:29 +01:00
Joachim Nilsson
f8e87f143d syslogd: Drop -a SOCK support, replaced with multiple -p SOCK args
The -p SOCK syntax is what NetBSD syslogd use, so this is more of an
alignment with upstream.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-07 19:08:29 +01:00
Joachim Nilsson
d723574eee logger: Update usage text with missing -u SOCK info
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-07 06:47:53 +01:00
Joachim Nilsson
1544cddd5a Drop unnecessary (and buggy) debug logs
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-06 16:53:48 +01:00
Joachim Nilsson
533ca61faa Support for sending messages to a custom port on remote server
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-06 14:23:03 +01:00
Joachim Nilsson
ff4b9e0499 Minor, code formatting
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-06 13:55:05 +01:00
Joachim Nilsson
d3abc7aa16 Minor, whitespace formatting
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-06 13:45:38 +01:00
Joachim Nilsson
fc4b804a6d Add LOG_WARN alias
Along with syslogp(), this is ia killer vendor lock-in feature.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-06 13:45:21 +01:00
Joachim Nilsson
31d7298516 Refactor, factor out getaddrinfo() code duplication to a sep. func.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-06 13:35:06 +01:00
Joachim Nilsson
65ac085a97 Add backwards compatibility handling with sysklogd v1.6
This patch adds compatibility with sysklgd v1.6 and also adds the new
action flag "RFC3164" to explicitly be able to set old format.  This
format is the default, except for remote syslog.  Also, the rotation
support added in v1.6 has chnaged syntax which this patch addresses.

- Remote syslog defaults to BSD format, w/o timestamp and hostname
- Support reading log rotation without ';rotate=' prefix

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-06 12:26:54 +01:00
Joachim Nilsson
02a67ef273 Refactor, move daemon defines to header file
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-06 12:08:09 +01:00
Joachim Nilsson
3ced4508b4 Add missing globfree(), found using -fsanitize=address
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-06 08:48:50 +01:00
Joachim Nilsson
ec06b220e4 If available, use O_TMPFILE, fix insecure tempfile found by Coverity
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-06 07:04:06 +01:00
Joachim Nilsson
3cff584621 Refactor wallmsg() slightly, fixes "unused value" found by Coverity
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-06 07:03:57 +01:00
Joachim Nilsson
e8674a8fd7 Check return value from setsockopt(), found by Coverity Scan
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-05 15:56:47 +01:00
Joachim Nilsson
3c2c353c37 Handle open() errors during log rotation, found by Coverity Scan
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-05 11:04:44 +01:00
Joachim Nilsson
0bf36c59a6 Refactor, close() may try to close -1, found by Coverity Scan
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-05 10:28:26 +01:00
Joachim Nilsson
2e8dffe893 If fstat() failes logrotate() cannot run, found by Coverity Scan
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-05 10:23:17 +01:00
Joachim Nilsson
1fe3c311ca Ignore return value from rename() to silence Coverity Scan
If we cannot rename our own files we're in a bit of a pickle.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-05 10:21:58 +01:00
Joachim Nilsson
58b243ea55 Replace unsafe strncpy() and strcpy() with safe strlcpy(),
C.f. Coverity CID 1076404

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-05 10:10:06 +01:00
Joachim Nilsson
f6ecb8b47b Fix Coverity CID 1406626, avoid strncat() in favor of snprintf()
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-05 09:37:07 +01:00
Joachim Nilsson
a4b09cc15b Clarify comment, _PATH_LOG applies to *sysklogd project*
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-05 08:57:15 +01:00
Joachim Nilsson
2fcfc0ad81 Drop #include "config.h" from syslog.h
Should not be in an exported header, obviously.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-05 08:42:29 +01:00
Joachim Nilsson
e202196152 Add missing files to distribution, found by make distcheck
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-04 20:09:15 +01:00
Joachim Nilsson
58da3b6bd2 Mark strlcat() and strlcpy() as weak functions, for libsyslog
The strlcat() and strlcpy() functions are only intended to be used
by syslog.c internally (and syslogd), when building libsyslog.

A user linking with libsyslog may have another library that provides
strlcat() or strlcpy() replacements.  We must therefore mark ours as
weak functions so they can be overridden.

This patch also add a convenience library for libsyslog, to control
the build deps. for libsyslog.  This is where external dependencies
should be addded (explicitly) when syslog.c is updated from NetBSD.
If you add new deps you likely want to mark them too as weak refs.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-04 11:04:13 +01:00
Joachim Nilsson
8f66822b2a Check for getprogname() et al, and use config.h for #ifndefs
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-04 10:55:52 +01:00
Joachim Nilsson
ad70b49790 Minor, whitspace alignment
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-04 06:21:50 +01:00
Joachim Nilsson
024dde00c2 Remove unused files
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-03 21:14:45 +01:00
Joachim Nilsson
11a16e16b8 syslogd: Strip whitespace in rule between action and option
Terminate action filename/pipe/host so we don't get any trailing tab or
space character in file or host names.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-03 19:48:22 +01:00
Joachim Nilsson
ff27d39cca syslogd: Fix double free() warning after SIGHUP
This cleanup section has moved to *after* cfparse()

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-03 19:47:54 +01:00
Joachim Nilsson
b2940cade1 Remove old Makefile, not needed anymore
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-03 17:30:12 +01:00
Joachim Nilsson
ea565153bc Remove last remnants of TESTING define
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-03 17:29:52 +01:00
Joachim Nilsson
3a825cf0da Update GPL license headers, wrong address for FSF
- Update last paragraph, with FSF address
- Drop gratuitous "this file is part of the sysklogd package"
- Fix indentation
- Update copyright years for my own contributions

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-03 17:21:06 +01:00
Joachim Nilsson
c05956010c Make sure libsyslog.la, incl. strlcpy.o, is built with -fPIC
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-11-03 15:55:25 +01:00
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
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
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
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
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
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
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
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
Joachim Nilsson
bf448fc6a1 Remove historical changelogs from files
We don't need to carry it any longer.  Anyone who wants to read them can
access an older GIT version, or released tarball.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-10-27 21:30:41 +01:00
Joachim Nilsson
0603849891 syslogd need _XOPEN_SOURCE for strptime()
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-10-27 21:27:30 +01:00
Joachim Nilsson
19f09ebb9d Change to use local version of syslog.h in syslogd
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-10-26 19:10:19 +02:00
Joachim Nilsson
bdb1d45f90 Refactor and drop '-n' option for rotation
The '-n' option is commonly used for remote servers, so let's
consolidate the log rotation under the '-r' flag instead, with
the same syntax as previously established in syslog.conf

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-10-25 16:06:36 +02:00
Joachim Nilsson
76b6981467 Factor out strtobytes() helper function from syslogd.c
For use in logger.c

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-10-25 15:51:19 +02:00
Joachim Nilsson
f6e17bd6b3 Update syslog.c, add syslog.h from NetBSD to get new syslogp() API
This patch merges the upstream NetBSD syslog.[ch], which adds syslogp()
family of APIs to support RFC5424.  This API will first go into use in
the logger tool, klogd, and syslog_tst, then it will also be exposed
as libsyslog and syslog/syslog.h for end-users.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-10-25 14:45:16 +02:00
Joachim Nilsson
d83f781dc0 Add OpenBSD strlcat() and strlcpy() safe string manipulation APIs
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-10-25 14:29:15 +02:00
Joachim Nilsson
2d64227d7d Send all test logs to /tmp/syslog_tst.log, for now ...
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-10-24 10:51:04 +02:00
Joachim Nilsson
a8060d0ad1 Fix tsyslogd, which reads from stdin, exit on EOF
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-10-24 10:51:04 +02:00
Joachim Nilsson
56ff4eedbe Simplify variable declarations in main(), strip #ifdefs
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-10-24 10:51:04 +02:00
Joachim Nilsson
27027456b5 Simplify, remove gratuitous 'return;' at end of functions + cleanup
- Add empty lines for readability, after return before new statement and
  after variable declarations
- Remove explicit typecasting, NULL is NULL regardless of type
- Remove unnecessary braces and else

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-10-24 10:51:04 +02:00
Joachim Nilsson
773ee73214 Simplify, memset() with 0 rather than '\0'
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-10-24 10:51:04 +02:00
Joachim Nilsson
6c23333feb Add wrapper for GLIBC __syslog_chk(), used for fortification
When a user links with syslog.c, or the future libsyslog, they may still
use the standard GLIBC header files.  GLIBC redirects syslog() to the
__syslog_chk() definition early on, but a user may not notice when a
simple non-optimized (-O0 or none) program is compiled.

This currently does not affect musl libc.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-10-24 10:51:04 +02:00
Joachim Nilsson
097d9efdbe Replace default optimization flag with -fno-strict-aliasing
The -fomit-frame-pointer is part of the standard optimization flags in
-O1 and above, so no need to enable it explicitly.

For reference https://lkml.org/lkml/2003/2/26/158

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-10-24 10:51:04 +02:00
Joachim Nilsson
6fa899db38 Misc, initial cleanup of syslog testing framework
- Let syslog_tst.c use local syslog.c API, for wrapping
- Add -DTESTING to build of syslog_tst & C:o
- Enable CLOEXEC on each opened log file in syslog.c
- Simplify code for readability

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-10-24 10:51:04 +02:00
Joachim Nilsson
1ba3dc5b87 Simplify, remove #ifdefs for INET6, always defined
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-10-24 10:51:04 +02:00
Joachim Nilsson
33411f8a0c Drop define of _SVID_SOURCE, not needed anymore
For compatibility with GLIBC <2.19 we only need to define _BSD_SOURCE,
and for compatibility with GLIBC >=2.19 we must defined _DEFAULT_SOURCE.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-10-24 10:51:04 +02:00
Joachim Nilsson
be5ce0af30 Simplify, no need to reset signal disposition in handler
On modern systems, both *BSD and Linux using GLIBC/musl, the signal's
disposition is not reset to SIG_DFL on invocation of its handler.  On
Linux this is true because GLIBC/musl wraps signal() in sigaction()
with the same semantics as BSD.

A follow-up commit will refactor to use sigaction().

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-10-24 10:51:04 +02:00
Joachim Nilsson
3309fb2d50 Misc, cleanup remaining SYSV #ifdefs and simplify a bit
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-10-24 10:51:04 +02:00
Joachim Nilsson
5114907afe Refactor, use linked list of struct filed instead of realloc'd array
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-10-24 10:51:04 +02:00
Joachim Nilsson
a1e3efc3c4 Refactor differences in signal sent from UNIX/Linux kernel on hangup
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-10-23 12:48:23 +02:00
Joachim Nilsson
98f498595c Simplify, CONT_LINE is always defined, remove all #ifdefs
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-10-23 12:47:39 +02:00
Joachim Nilsson
f67ed6934a Simplify, remove #ifdefs for always defined paths
We always want to build with support for UNIX domain socket and remote
syslog (both receive and send).  We can safely state that all systems
we aim to target supports FHS.

Also, start clean up gratuitous use of SYSV #ifdefs.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-10-23 10:37:14 +02:00
Joachim Nilsson
b3727fcf0b Simplify copyright[] and sccsid[] legacy from BSD
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-10-23 10:35:47 +02:00
Joachim Nilsson
97c107262c Simplify, syslogd unconditionally includes fcntl.h already
No need to check for SYSV (?) to include fcntl.h since syslogd.c already
includes it unconditionally.  If this turns out to be an actual problem
we should probe for fcntl.h in configure and use #ifdef HAVE_FCNTL_H.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-10-23 10:33:20 +02:00
Joachim Nilsson
bf6bba3493 Let logger use local syslog API
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-10-22 16:42:35 +02:00
Joachim Nilsson
1004498697 Add support for building tsyslogd and syslog_tst again
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-10-22 16:42:28 +02:00
Joachim Nilsson
d0360f47ed logger: Replace -h with -?, -h is reserved in POSIX for remote host
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-10-21 11:25:04 +02:00
Joachim Nilsson
4382136d18 Fix signed vs unsigned comparison warning from GCC
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-10-21 11:15:36 +02:00
Joachim Nilsson
e65f815333 Remove unused variable
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-10-21 11:15:15 +02:00
Joachim Nilsson
1844fa4385 Increase default compiler warnings, exempt unused parameters
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-10-21 11:10:39 +02:00
Joachim Nilsson
4fc2c478ef Reshuffle .gitignore content a bit
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-10-13 14:49:32 +02:00
Joachim Nilsson
1a09654e79 Add logger tool from Finit project to complement sysklogd
This patch introduces a relicensed logit from the Finit[1] project.  It
has been rebranded as logger to complement the features implemented in
the sysklogd project.

Note, logger conflicts with the tool of the same name from util-linux.

[1]: https://github.com/troglobit/finit

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-10-13 14:48:37 +02:00
Joachim Nilsson
4fcebdb03c Add SPDX license identifiers to all source files, BSD-3 & GPL-2
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-10-13 12:07:38 +02:00
Joachim Nilsson
52a33f1cf4 Minor, strip leading double spaces in license header
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-10-13 12:03:35 +02:00
Joachim Nilsson
2c8f20f1ea Update FSF address in GPL license header for all GPL:ed files
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-10-13 11:54:34 +02:00
Joachim Nilsson
d434d90b53 Unify license header comment style
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-10-13 11:46:19 +02:00
Joachim Nilsson
290c11d0d9 Sync. BSD license change with FreeBSD upstream
From upstream FreeBSD Subversion r165903:

  "Per Regents of the University of Calfornia letter,
   remove advertising clause."

This patch also includes the renumbering of the clauses, making
this codebase truly 3-clause BSD licensed.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-10-13 11:35:42 +02:00
Joachim Nilsson
301081604a Add RFC5424 support for remote syslog servers
This patch adds support for sending in RFC5424[1] style format to remote
log servers.  Section 6.5[2] lists some examples, here's one:

    <30>1 2019-10-12T18:21:01.123456+02:00 troglobit finit 321 - - Starting service 'firewalld:1'

Note, sysklogd currently does not support MSGID and structured data, see
the RFC for more information on this.

[1] - https://tools.ietf.org/html/rfc5424
[2] - https://tools.ietf.org/html/rfc5424#section-6.5

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-10-12 18:49:41 +02:00
Joachim Nilsson
760ec4cc36 Fix too small destination buffer in snprintf() call, found by GCC 8
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-10-12 11:34:11 +02:00
Joachim Nilsson
ea24aa5378 Usability, size modifiers to log rotate: 100k:5, 1G:3, and 100M:5
This applies to both the command line '-b SIZE' option and the
optional per log file setting.  Modifiers supported are: k, M, G

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2018-09-25 17:27:24 +02:00
Joachim Nilsson
ab24b2efff Add configurable retry timeout for remote syslog servers
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2018-09-25 10:10:28 +02:00
Joachim Nilsson
3039c285e3 Add missing getopt.h include
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2018-09-24 20:06:24 +02:00
Joachim Nilsson
234cd4e669 Add required feature flags for when building with -std=c11
These feature flags are required to build with modern GCC that default
to newser C standard.  However, we should never enforce a standard on
the user -- there are far too many old/embedded systems out there with
very old toolchains that just want bug fixes and minor features for an
otherwise stable system.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2018-09-24 20:06:24 +02:00
Joachim Nilsson
84437f88e3 Avoid for loop initial declarations
May need to build on/for systems with quite old GCC version.  Also,
fixes build on Travis-CI.  (Enabling C99 brings in a lot of other
warnings that we'll take care of at a later stage.)

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2018-09-24 17:28:26 +02:00
Joachim Nilsson
bc92e860ef Initial support for per log file rotate size:count as last arg.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2018-09-24 17:03:54 +02:00
Joachim Nilsson
01a46ae8cc Compress rotated files >= .1, keep .0 uncompressed
This patch adds support for rotating compressed files as well as
compressing (gzip) all files older than .1.

Props goes to @Znahoj for the first prototype implementation made at
Westermo.  Only minor changes to his draft were made.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2018-09-24 14:17:28 +02:00
Joachim Nilsson
aef7e07704 Refactor, use NULL and not (char *)0 and similar
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2018-08-05 19:02:25 +02:00
Joachim Nilsson
2e84a34758 Refctor, simplify return statements, no parenthesis needed
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2018-08-05 18:59:50 +02:00
Joachim Nilsson
f1f1ee3563 Reindent to Linux KNF
Most of the code base seemed to follow Linux style, loosely.  This patch
brings it all together.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2018-08-05 18:55:56 +02:00
Joachim Nilsson
53c4dd817d Fix archaic #include statements, for building with musl libc
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2018-08-05 16:51:13 +02:00
Joachim Nilsson
9f21a8a0f5 Refactor, replace reserved dprintf() with logit()
dprintf() was standardized by POSIX.1-2008.  This patch replaces
all occurrences with logit().

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2018-08-05 16:39:31 +02:00
Joachim Nilsson
ea586826be Flip logic to simplify code a bit
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2018-08-03 09:22:17 +02:00
Joachim Nilsson
0f01cf7cff Update usage, klogd probes for a System.map file by default
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2018-08-03 09:16:47 +02:00
Joachim Nilsson
d222e82d83 Add --with-syslogd-pidfile=FILE configure option
This enables the same functionality as the old build system, only
slightly more flexible since you don't need to edit the Makefile.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2018-08-03 09:07:36 +02:00
Joachim Nilsson
2b1dd66f0f Add missing syslog.c define from conversion to GNU configure & build
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2018-08-03 08:45:45 +02:00
Joachim Nilsson
0f4d458a59 Prop up usage text and launch on -? for both klogd and syslogd
Also, avoid returning error when user actually requests help.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2018-08-03 08:10:38 +02:00
Joachim Nilsson
a08b8ee38a Add missing '*' to Emacs local variables indentation hinting
A local variables section must start with /** otherwise Emacs will
prompt the user every time if the settings should be applied.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2018-08-03 01:32:33 +02:00
Joachim Nilsson
d7bfb2c66f Activate built-in log rotation feature, disabled by default
Basically just removes the #ifdef blocks around the code.  With the
feature disabled by defult this should be safe.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2018-08-03 00:58:42 +02:00
Joachim Nilsson
2fda4352ea Remove doc_DATE fro src/Makefile.am, archived now
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2018-08-02 23:29:45 +02:00
Joachim Nilsson
fc7e90d25a Archive old docs
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2018-08-02 23:12:26 +02:00
Joachim Nilsson
e6a88e13ed Replace version.h with auto-generated version from configure script
Also, remove DEBRELEASE, no longer a package with Debian focus, and add
'v' before version number in logs/usage text.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2018-08-02 23:02:49 +02:00
Joachim Nilsson
880cb2aa4d Relocate files to man/ and src/ and change to GNU configure & build
- Relocate all source files to src/ and manual pages to man/
- Replace static Makefile with GNU configure and build system

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2018-08-02 22:52:40 +02:00