Commit Graph

731 Commits

Author SHA1 Message Date
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
6b07e96753 Add Emacs mode hinting, mostly for syslog.conf.5
Emacs is by default fooled into defaulting to conf-file-mode for
syslog.conf.5, so we add hinting to all man pages for consistency.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-10-25 16:06:36 +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
3b9a856417 Update ChangeLog in preparation for v2.0
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-10-13 14:57:05 +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
ac718fe969 Document new RFC5424 style formatting for sending to remote hosts
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-10-12 21:37:28 +02:00
Joachim Nilsson
34d764ed57 Bump version for v2.0 release cycle
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-10-12 18:52:04 +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
a2eb744f26 Ignore popular ctags/global files
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2019-10-12 11:35:09 +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