- Drop weak bindings, use simple #define in compat.h instead
- No need to #ifdef sources with HAVE_foo, configure handles this for us
- Move utimensat() declaration to compat.h from pidfile.c to be consistent
With these changes we can let libsyslog link with the replacement objs,
just like syslogd and logger does. Because even if the C-library does
*not* have strlcpy() & C:o *and* an application has a local copy of any
of these APIs, our versions are prefixed with __ in the symbol table.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
Only reset f_fime when the filed is in normal operation, not suspended,
otherwise the INET_SUSPEND_TIME handling is broken.
Signed-off-by: Johan Askerin <johan.askerin@gmail.com>
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
When sending to a remote syslog server, configured as an IP address or
when the DNS name has already been resolved, we may get temporary error
messages like ENETUNREACH and similar from sendmsg().
Before this patch the whole filed was placed in F_FORW_SUSP, like failed
DNS resolve, which introduces a 180 sec delay before even trying again.
A better approach is to just try again with the next syslog message.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
The original idea with libcompat was to keep as few objects as
possible for linking with libsyslog. That in turn to prevent
a user of libsyslog from suddenly also getting strong binding
to symbols like strlcpy() from libsyslog, rather than their C
library of choice.
However, this caused strlcpy.c to be built as both .o and .lo
files, which in turn caused really bizarre build problems due
to bad DAG dependency.
This patch drops libcompat and instead marks all replacement APIs
as weak symbols, which a C library can override.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
Internal log messages of INTERNAL_MARK time were created every 30
seconds (TIMERINTVL) instead of every MarkInterval (default 20 min).
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
The __BEGIN_DECLS and __END_DECLS are internal identifiers in glibc and
are not defined in any standard. Using them fails build on musl
libc, its better to avoid them
Signed-off-by: Khem Raj <raj.khem@gmail.com>
This patch removes one of the traditionally key pieces of the sysklogd
project, klogd. Now that syslogd performs logging of kernel messages
we no longer require a separate daemon for that.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
When building the sysklogd project --without-klogd we must disable the
kernel logging to console on Linux. This fix depends on how the sysctl
setting `kernel.printk` is configured. The patch only calls the kernel
to set console_loglevel to minimum_console_loglevel.
See the kernel docs for details:
https://www.kernel.org/doc/Documentation/sysctl/kernel.txt
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This patch adds a alarm()/SIGALRM based generic timer API to syslogd.
The API takes care to wrap SIGALRM and serialize all timer events to
a standard UNIX pipe(2) which syslogd can poll() for like any other
incoming event.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This bug caused syslogd to fall back to logging to /dev/console for
internal log messages/errors during reconfiguration at runtime.
syslogd has the FreeBSD style of keeping already open log files ready
for logging until re:init() has completed, when new log files are rolled
in and any old ones not to be used anymore are closed.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
Refactor of nslookup of unknown remote syslog servers, both when
(re)reading the .conf file and at runtime. This means we retry
DNS lookup every 30 sec, or INET_SUSPEND_TIME +/- 30 sec.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
The domark() timer handles a lot of the critical maintenance action in
syslogd, it must always be guaranteed to run.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
Only block signals *after* all sanity checking of log message has been
completed, otherwise we will end up with blocked SIGHUP and SIGALRM.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
We definitely want to be able to run syslogd in debug mode for extended
periods of time and still run under finit/systemd or similar, letting
users know we run as 'PID'.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
When logging to a remote server, using @fqdn syntax in syslog.conf,
syslogd calls getaddrinfo() to resolve the IP address. Older versions
of syslogd gave up after 10 retries. We want to retry forever since we
may be running in a setup with bad network connection to the DNS server
for longer periods of time.
This patch only removes the 'give up' mechanism, which unfortunately
reused the f_prevcount value, which in turn could cause that value to
become -1 and thus trigger an assert(). With this code out of the way,
and the type change in the previous commit, the counter can never again
be negative.
Note: The configurable suspend time before trying again remains at its
default of 3 minutes.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
When we fail sending to a remote host, help admin debug the issue by
stating which remote we failed to send to.
Also minor changes to other similar error messages, use same form.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
When creating Inet sockets we may get multiple struct addrinfo records.
With this patch we support up to 16 records per Internet peer. When
closing we iterate over all peers and all records.
Refactor socket_close() to clean up any lingering socket path when
closing UNIX socket.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
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>