1637 Commits

Author SHA1 Message Date
Thomas Blume
4cacfc34e8 satisfy-gcc-flag-fno-common
Porting advice for gcc 10:

A common mistake in C is omitting <code>extern</code> when declaring a global
variable in a header file.  If the header is included by several files it
results in multiple definitions of the same variable.  In previous GCC versions
this error is ignored.  GCC 10 defaults to <code>-fno-common</code>, which
means a linker error will now be reported. To fix this, use <code>extern</code>
in header files when declaring global variables, and ensure each global is
defined in exactly one C file. As a workaround, legacy C code can be compiled
with -fcommon.
2020-01-09 11:16:22 +01:00
Rainer Gerhards
6f74f7e7b4
Merge pull request #4091 from alorbach/pr-issue-4035
ossl tls: Added support to configure certificate verify depth
2020-01-08 15:44:57 +01:00
fcffb063e3 tls: Added support to configure certificate verify depth
Support added in omfwd as instance parameter:
streamdriver.TlsVerifyDepth
Support added in imtcp as module parameter:
streamdriver.TlsVerifyDepth

Can be 2 or higher.

Support added into ossl driver
Support added into gtls driver
Added testcases for both drivers.

Parameter
streamdriver.TlsVerifyDepth

closes: https://github.com/rsyslog/rsyslog/issues/4035
2020-01-08 11:40:14 +01:00
Dagobert Michelsen
8834ce8e78 Use #ifdef instead of Ã#if 2020-01-06 14:32:23 +01:00
Simon Haggett
1f14b4f293 Reopen /dev/urandom file descriptor after fork on Linux systems
This patch updates prepareBackground() in tools/rsyslogd.c to reopen any file
descriptors used for random number generation in the child process. This fixes
an issue on Linux systems where the file descriptor obtained for /dev/urandom
by seedRandomNumber() in runtime/srutils.c was left closed after the fork. This
could be observed in procfs, where /proc/fd/ would show no open descriptors to
/dev/urandom in the forked process. /dev/urandom is reopened as the child may be
be operating in a jail, and so should not continue to use file descriptors from
outside the jail (i.e. inherited from the parent process).

I found that this issue led to rsyslog intermittently hanging during seedIV()
in runtime/libgcry.c. After the fork, the closed file descriptor number tended
to get re-assigned. randomNumber() would then read from an incorrect (although
still valid) file descriptor, and could block (depending on the state of that
file descriptor). This gave rise to the intermittent hang that I observed.

Signed-off-by: Simon Haggett <simon.haggett@gmail.com>
2019-12-26 10:35:48 +00:00
Rainer Gerhards
deb98fecc1
bugfixes: small issues detected by clang static analyzer 10 2019-12-18 11:37:00 +01:00
John Brooks
e85abfccb3 rsyslogd: Clean up decrement
Signed-off-by: John Brooks <jbrooks@ciena.com>
2019-11-15 15:21:17 -05:00
John Brooks
723f6fdfa6 rsyslogd: Fix race between signals and main loop timeout
The main loop sleeps in a select() call for a long interval in order to
periodically run housekeeping tasks. The main loop is also responsible for
responding to flags set by signal handlers, so this sleeping should be
interrupted by signals so that it can check those flags.

However, a signal could be delivered between when the flags are checked and
when select() is called. In which case the main loop will block for the
full interval (currently 10 minutes) before handling the signal. If this
occurs, it could take up to 10 minutes for rsyslogd to terminate after a
SIGTERM or respond to SIGHUP.

Fix this by blocking signals before checking the flags and using pselect()
to unblock the signals while waiting. This is recommended by the select(2)
manual page to avoid this very issue.

Signed-off-by: John Brooks <jbrooks@ciena.com>
2019-11-15 15:21:17 -05:00
Jiri Vymazal
937e278fdf Stricter GnuTLS operation
This commit adds to new flags which can be set to allow
1) checking of extendedKeyUsage certificate field
2) stricter checking of certificate name/adresses
2019-08-30 09:40:25 +02:00
Rainer Gerhards
bb7db923ad
iminternal bugfix: race on termination 2019-08-03 14:33:54 +02:00
Rainer Gerhards
689e657090
core/janitor bugfix: properly maintain dynafile cache
When the janitor cleans out timed-out files, it does not
properly indicate the entry is gone. Especially when running
in async mode this can lead to use-after-free and thus
memory corruption or segfault.

see also https://github.com/rsyslog/rsyslog/issues/3756
2019-08-01 15:57:52 +02:00
Thomas Blume
2e9d389419 iminternal: suppress mutex double-unlock
If there is a burst of log messages during a time when rsyslog is unable
to output (either during log rotation, an out-of-space condition, or
some other similar condition), rsyslog can SEGFAULT due to a mutex
double-unlock.
2019-07-11 12:58:10 +02:00
Rainer Gerhards
b9066d1c86
fix leading double space in rsyslog startup messages
see also https://github.com/rsyslog/rsyslog/issues/2979
2019-07-02 16:04:33 +02:00
Rainer Gerhards
b54a377f55
omfile: fix potential hang/segfault on HUP of dynafile action
when omfile was HUPed it did not sufficiently clear all dynafile
cache maintenance data structures. This usually lead to misadressing
and could result in various issues, including a hang of rsyslog
processing or segfaults. It could also have "no effect" by pure
luck of not hitting anything important. This actually seems to
have been the most frequent case.

This seems to be a long-standing bug, but the likelyhood of its
appearance seems to have been increased by commit 62fbef7
introduced in 8.1905. Note: the commit itself has no regression,
just increases the likelyhood to trigger the pre-existing bug.

special thanks to Alexandre Guédon for his help in analyzing
the issue - without him, we would probably still not know
what actually went wrong.

closes https://github.com/rsyslog/rsyslog/issues/3686
2019-06-21 13:14:49 +02:00
Rainer Gerhards
68686a3a51 debug: add instrumentation to investigate 8.1905.0 regression
see also https://github.com/rsyslog/rsyslog/issues/3686
2019-06-21 09:33:06 +02:00
Rainer Gerhards
1c8712415b platform bugfix: HUP did not work reliably on some platforms
... at least not on FreeBSD. The problem was that HUP did not awake
the main loop. We know interrupt it explicitely.
2019-06-14 08:39:44 +02:00
StrongestNumber9
8791323c92 Fixes #3667 2019-05-17 15:16:13 +03:00
Rainer Gerhards
d9d12071f3
change default of internalmsg.severity global parameter, add tests
also fix a problem in handling this parameter when rsyslog processed
internal messages itself (it did not work). As the parameter was
introduced today, we do not flag this follow-up commit as "bugfix".
The issue was noticed when we added the additional tests.

see also https://github.com/rsyslog/rsyslog/issues/3650
see also https://github.com/rsyslog/rsyslog/issues/3639
2019-05-09 12:13:45 +02:00
Rainer Gerhards
b7e18513fd core: harden shutdown processing on FreeBSD
root cause seems to be that SIGTERM is delivered differently under
FreeBSD. This causes the main thread to not be awaken, and so it
takes until the next janitor interval to come back to life - which
can be far too long. Fixed this bug explicitley awaking the main
thread.

also

* re-enable test that did not work because of this
* fix invalid message on SIGTERM in debug log
2019-05-09 11:08:38 +02:00
Rainer Gerhards
160f2d7a52
new global config parameter "internalmsg.severity"
permits to specify a severity filter for internal message. Only
messages with this severity level or more severe are logged.

Orignally this was done in rsyslog.conf as usual: you can filter
rsyslog messages on severity, just like any other. But with systemd,
we now emit primarily to the journal, and this is outside of rsyslog's
rule engine and so regular filters do not apply (at least in regard
to the journal). Logging to journal is good, because finally
folks begin to see the messages (traditional distro configs discard
them, for whatever is the reason).

This commit implements a global setting for a severity-based filter
for internal messages, before submitted to journal. So it's not 100%
of what rsyslog can do, but at least some way to customize.

see also https://github.com/rsyslog/rsyslog/issues/3639
2019-05-07 11:27:08 +02:00
Rainer Gerhards
32c5ade046
fix cosmetic coverity leak report (CID 207601)
While in theory this is a leak, in practice it's extremely unlikely
and irrelevant. Nevertheless, let's fix it ;-)
2019-04-30 08:52:46 +02:00
Rainer Gerhards
62fbef7f72
omfile bugfix: FlushOnTXEnd does not work reliably with dynafiles
The flush was only done to the last dynafile in use at end of
transactions. Dynafiles that were also modified during the
transaction were not flushed.

Special thanks to Duy Nguyen for pointing us to the bug and
suggesting a solution.

This commit also contains a bit of cosmetic cleanup inside
the file stream class.

closes https://github.com/rsyslog/rsyslog/issues/2502
2019-04-29 15:56:41 +02:00
Rainer Gerhards
68a00b0bd5
add capability to write full config file (-o cmdline option)
Introduces the capability to create an output config file that explodes
all "includes" into a single file. This provides a much better overview
of how exactly the configuration is crafted. That could often be a great
troubleshooting aid.

This commit also contains some slight not-really-related cleanup.

closes https://github.com/rsyslog/rsyslog/issues/3634
2019-04-28 11:52:51 +02:00
Rainer Gerhards
2ac1cfdac2
command line interface: finally remove old -s, -l options
These options generate warning messages that they will go away
for years now. Nobody has complained about this fact (the message
request that). So we assume it is safe to finally remove them.
This helps to clean up rsyslog code and remove unneeded cruft.
2019-04-17 18:46:23 +02:00
Philippe Duveau
3ec965f8b3 AIX_port: corrects style and compatibility issues (4) 2019-02-14 17:50:00 +01:00
Philippe Duveau
11c6365eba AIX_port: corrects style and compatibility issues (3) 2019-02-14 17:17:37 +01:00
Philippe Duveau
9ad7324dfa AIX_port: second phase 2019-02-14 14:36:05 +01:00
Homero Pawlowski
c456e79a87 Fixed typo in rsyslog.conf.5 2019-01-21 13:39:40 -05:00
Rainer Gerhards
5cc027084f
Merge pull request #3376 from Whissi/issue3346
omusrmsg: don't overwrite previous set _PATH_DEV value
2018-12-30 16:58:48 +01:00
Rainer Gerhards
34241cc1c5
Merge pull request #3328 from jsiwrk/child_exit_report_option
report child process exit status according to config parameter
2018-12-30 12:55:28 +01:00
Thomas Deutschmann
7a90ac51d1
omusrmsg: don't overwrite previous set _PATH_DEV value
Since commit 56ace5e418d149af27586c7c1264fccfbc6badf1, omusrmsg was broken
because "memcpy()" is not a suitable substitute for "strncat()" in this
context, it is actually replacing the previous added content.

Bug: https://bugs.gentoo.org/673004
Closes: https://github.com/rsyslog/rsyslog/issues/3346
2018-12-25 23:58:19 +01:00
Rainer Gerhards
9bd138d299
introduce new versioning scheme for rsyslog
see also https://rainer.gerhards.net/2018/12/rsyslog-version-numbering-change.html
2018-12-22 10:48:53 +01:00
Joan Sala
9315787c6d report child process exit status according to config parameter
Add new global setting 'reportChildProcessExits' with possible values
'none|errors|all' (default 'errors'), and new global function
'glblReportChildProcessExit' to report the exit status of a child
process according to the setting.

Invoke the report function whenever rsyslog reaps a child, namely in:
- rsyslogd.c (SIGCHLD signal handler)
- omprog
- mmexternal
- srutils.c (execProg function, invoked from stream.c and omshell)

Remove redundant "reaped by main loop" info log in omprog.

Promote debug message in mmexternal indicating that the child has
terminated prematurely to a warning log, like in omprog.

Closes #3281
2018-12-21 20:29:01 +01:00
3d9b8df6fb tls(ossl/gtls): add new Option "StreamDriver.PermitExpiredCerts"
The new Option can have one of the following values:
on = Expired certificates are allowed
off = Expired certificates are not allowed
warn = Expired certificates are allowed but warning will be logged (Default)

Includes necessary tests to validate new code.

closes https://github.com/rsyslog/rsyslog/issues/3364
2018-12-21 15:24:41 +01:00
937dbcb801 bugfix tls subsystem: Receiver hang due to insufficient TLS buffersize.
gtls and ossl driver used a default buffersize of 8 x 1024 bytes to store
received TLS packets. When tls read returned more than buffersize, the additional
buffer was not processed until new data arrived on the socket again.

TLS RFCs require up to 16KB buffer for a single TLS record.

closes https://github.com/rsyslog/rsyslog/issues/3325
2018-12-18 14:44:58 +01:00
Josh Soref
bfd9248670 spelling: https 2018-11-14 11:56:57 -05:00
Josh Soref
d642d984d3 canonical url www.rsyslog.com/doc/ 2018-11-14 12:03:20 -05:00
Rainer Gerhards
978cc7692d
AIX: handle forking in a defined way
albeit not necessarily correct - see code comment
2018-11-06 11:53:11 +01:00
Thomas Deutschmann
d5ffe6e10e
build system: don't link liblogging-stdlog when available but not enabled
When liblogging-stdlog was available but configure option "--disable-liblogging-stdlog"
was set, rsyslog was still linking against liblogging-stdlog.

This commit will ensure that rsyslog will only link against liblogging-stdlog when
"--enable-liblogging-stdlog" was set.

Bug: https://bugs.gentoo.org/667836
2018-11-03 23:21:29 +01:00
Rainer Gerhards
9bece39dc6
SQUASH
debug cleanup: remove some old, no longer used macros
2018-10-30 12:46:04 +01:00
Rainer Gerhards
d09416c95f
core: add operating state file capability (new feature)
adds global(operatingStateFile="fn") and related handling (see doc
for details).

closes https://github.com/rsyslog/rsyslog/issues/1721
2018-10-29 15:59:47 +01:00
Rainer Gerhards
223c03e536
cleanup: remove commented-out code
thanks to lgtm.com for the ability to detect commented out code!
2018-10-27 19:04:30 +02:00
Rainer Gerhards
21c4862623
Merge pull request #3188 from rgerhards/cleanup4
cleanup: remove unneeded code
2018-10-26 15:42:54 +02:00
Rainer Gerhards
f3fa82acd6
core/debug: data written to random fd 2 under some debug settings
This happens only during auto-backgrouding, where we cannot any longer
access stderr. Whatever is opened with fd2 receives some debug messages.
Note that the specific feature is usually turned on only in CI runs.
2018-10-26 11:14:11 +02:00
Rainer Gerhards
45b7a97daa
cleanup: remove unneeded code
The syncdemo program was actually that, a demo program to explain
some concepts. It's not really related to the rsyslog code base.
2018-10-26 09:41:50 +02:00
Rainer Gerhards
3b5ed2d046
cleanup: remove no longer needed code
see also https://github.com/rsyslog/rsyslog/issues/2211
2018-10-25 17:52:45 +02:00
Rainer Gerhards
bbd9e3f8f2
AIX portability: add missing symbol to export file
unfortunately, AIX does not export all public symbols (or I
consistently fail in trying to convince it...)
2018-10-20 11:36:35 +02:00
Rainer Gerhards
997de6f214
bugfix core msg: potential deadlock (and rsyslog hang)
can happen e.g. with headerless messages when app-name
property is used

closes https://github.com/rsyslog/rsyslog/issues/3135
2018-10-17 10:41:11 +02:00
Rainer Gerhards
949181c373
errmsg: remove no longer needed code
object-ish style is no longer needed and can finally be removed

closes https://github.com/rsyslog/rsyslog/issues/1684
2018-09-28 15:03:39 +02:00
Rainer Gerhards
50f239d17d
cleanup: remove no longer needed code 2018-09-22 16:04:13 +02:00