This patch re-adds the -n flag, but now to disable DNS reverse-query for
all incoming messages. This can potentially speed up logging a lot for
small/embedded systems that act as log sink.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This change will probably break most installations. We do this to free
up '-n' for use as disabling DNS lookups, from FreeBSD *and* NetBSD.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This patch makes us wire-compatible with older versions of ourself, and
current versions set up to use default remote format.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This patch drops the configure flag --with-syslogd-pidfile=foo since
syslogd now natively supports custom PID file using -P foo.
Also, the default PID file and syslog.conf paths have been changed from
the hard-coded /var/run (_PATH_VARRUN) and /etc to use configure paths.
This may not be appreciated by everyone but allows the project to have
support for all use-cases in a de facto standard fashion.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This patch looks big, but it's really just fprintlog() being split up
into three new functions: fprintlog_first() & fprintlog_successive() and
fprintlog_write(). Similar to how the FreeBSD syslogd is structured.
In the refactoring process Joey's proxy-prevention was removed.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This patch fixes the omission of final ':' following a content TAG when
an app-name without a process ID is included.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
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>
- Update man page
- Enable -s in default systemd service settings
- Add support for SecureMode, with shutdown()
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
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>
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>
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>
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>
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>
- 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>
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>
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>
- 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>
- 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>
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>
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>
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>
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>
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>
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>
- 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>
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>
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>
- 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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
- 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>