64 Commits

Author SHA1 Message Date
Radovan Sroka
89ce7cb535 _PID fallback
- added fallback for _PID proprety when SYSLOG_PID is not available
- introduced new option "usepid" which sets which property should
  rsyslog use, it has 3 states system|syslog|both, default is both
- deprecated "usepidfromsystem" option, still can be used
  and override the "usepid"
- it is possible to revert previous default with usepid="syslog"
2017-05-31 15:24:45 +02:00
Radovan Sroka
f2df6ed2f3 Fixed situation when time goes backwards
This is resolving the situation when system is after reboot and boot_id doesn't match
so cursor pointing into "future".
Usually sd_journal_next jump to head of journal due to journal aproximation,
but when system time goes backwards and cursor is still invalid, rsyslog stops logging.
We use sd_journal_get_cursor to validate our cursor.
When cursor is invalid we are trying to jump to the head of journal
This problem with time should not affect persistent journal,
but if cursor has been intentionally compromised it could stop logging even
with persistent journal.
2017-02-16 15:30:26 +01:00
Pascal Withopf
b63a6b9010 codestyle: line length adjusted 2017-01-17 08:54:37 +01:00
Tomas Sykora
5cc4d07409 Removed old config of ignorenonvalidstatefile 2016-12-22 04:50:41 -05:00
Tomas Sykora
6069d501ee Make state file handling in imjournal more robust 2016-12-08 10:32:55 -05:00
purnima
d45daa2af0 Rebase,redefine msgDestruct() as smsg_t is used 2016-11-22 14:24:25 +05:30
Rainer Gerhards
8a986092c6 fix old-style definitions (missing prototype in func def) 2016-06-03 10:08:57 +02:00
Rainer Gerhards
5e3b075d53 fix compiler warnings 2016-06-02 12:08:55 +02:00
Peter Portante
f98d4bf32e imjournal: fix off-by-one error in name cmprs
Looks like a long standing off-by-one comparison issue with the
invocation of strncmp.  The constant string was only 3 or 6 characters
long, but the comparison length was 4 or 7.

We have dropped this code entirely since it was not working at all.
2016-02-02 12:34:39 +00:00
271d74991f imjournal: Fixed problem in function timeval2syslogtime function call
Problem was introduced by changes in timeval2syslogtime api, see
following commit:
e8c8e96e27
2016-01-22 14:17:51 +01:00
Peter Portante
c95e863c37 Tighten down code under analysis 2015-12-09 23:28:18 +00:00
Max Prokhorov
64af99a04c imjournal: Initialize counter outside of while loop 2015-11-22 23:15:27 +03:00
Rainer Gerhards
9f5cf2b26d Merge branch 'master-imjournal-memleak' of https://github.com/theinric/rsyslog into master-candidate 2015-06-26 11:12:32 +02:00
Tomas Heinrich
833bd4a774 imjournal: don't sanitize empty messages
It is an error to pass an empty message to
parser.SanitizeMsg() and doing so could crash the daemon. Besides,
there's no point in doing so in the first place.
2015-06-23 19:04:40 +02:00
Tomas Heinrich
eec1996b0c bugfix: plug a memleak in imjournal
The leak was tiny and shutdown-time only.
2015-06-23 15:34:20 +02:00
Janmejay Singh
15afe8245f created param in add-flow to indicate if a graph being added to global-variable is shared, so it can be deep-copied instead of referenced (external modifications to which can not be protected from unsafe concurrent access) + killed an unused function 2015-05-26 09:41:35 +05:30
Tomas Heinrich
d0c8a3e334 imjournal: fix default message priority 2015-03-20 19:02:01 +01:00
Janmejay Singh
4ca5e217e2 Adds support for 'reset' statement (it has syntax similar to set 'set', but _unlike_ 'set' always force-sets the given value insteed of conditionally merging it, or not saving it because it is trying to replace an object with a leaf value etc).
Syntax:

reset $.foo = $!bar;

etc.
2014-12-17 11:39:31 +01:00
Tomas Heinrich
bb4139d16c imjournal: remove redundant condition 2014-11-26 16:37:38 +01:00
Rainer Gerhards
55b76c6a27 fix datatype conversion 2014-11-26 11:22:01 +01:00
Tomas Heinrich
e687dc5bc6 imjournal: add a new option UsePIDFromSystem
This option is analogous to the option of the same name from imuxsock.
When set, the PID is taken from the journal rather than the message.

Conflicts:
	plugins/imjournal/imjournal.c
2014-11-26 11:15:07 +01:00
Tomas Heinrich
ea8a9cf771 imjournal: make $IgnorePreviousMessages take effect even without a state file
Previously, $StateFile had to be specified for $IgnorePreviousMessages
to work.
2014-11-25 15:44:47 +01:00
Tomas Heinrich
e33c8ffaec imjournal: escape zero bytes in fields' values 2014-11-25 10:01:48 +01:00
Tomas Heinrich
25dab3b83a imjournal: sanitize messages as imuxsock does it
This change makes these directives available for imjournal:
  $ControlCharacterEscapePrefix
  $DropTrailingLFOnReception
  $Escape8bitCharactersOnReceive
  $EscapeControlCharacterTab
  $EscapeControlCharactersOnReceive
  $SpaceNLOnReceive
2014-11-13 15:14:54 +01:00
Tomas Heinrich
f71a6dc381 imjournal: consolidate goto labels in readjournal() 2014-11-13 15:14:34 +01:00
Rainer Gerhards
2bd17e5313 imjournal: remove unnecessary header 2014-10-08 13:11:22 +02:00
Rainer Gerhards
7d9bc80635 Merge branch 'v7-stable' into v8-stable 2014-10-08 12:41:09 +02:00
Rainer Gerhards
b33df7a083 bugfix: imjournal did not build properly
The build succeeded, but the module did not load due to a type in
a support function name, which kept unresolved during load.
2014-10-08 12:39:44 +02:00
Rainer Gerhards
b11bf2745c Merge branch 'v7-stable-prifix' into v8-stable-prifix
WARNING: does not compile, will be fixed with next commit

Conflicts:
	configure.ac
	tools/rsyslogd.c
2014-09-16 14:59:14 +02:00
Rainer Gerhards
1ac20ffe97 Merge branch 'v5-stable-prifix' into v7-stable-prifix
Conflicts:
	plugins/imklog/imklog.c
	plugins/imtemplate/imtemplate.c
	plugins/imuxsock/imuxsock.c
	runtime/msg.c
	runtime/rsyslog.h
	runtime/rule.c
	runtime/syslogd-types.h
	tools/syslogd.c
2014-09-16 14:48:29 +02:00
Rainer Gerhards
73f4234398 imjournal: avoid void* arithmetic
this worked, but could lead to unpredictable results on some platforms
(at least in theory)
2014-04-30 12:06:12 +02:00
Rainer Gerhards
f7ad21626f silence compiler warnings
mostly cosmetic things
2014-03-16 10:52:54 +01:00
Rainer Gerhards
5c6d7552c1 silence compiler warnings
mostly cosmetic things
2014-03-12 14:47:33 +01:00
Tomas Heinrich
a61f1fe227 imjournal: Make default priority configurable 2014-02-27 18:05:47 +01:00
Tomas Heinrich
4ebface847 imjournal: Set default facility for all messages
Some messages comming from journald don't have the SYSLOG_FACILITY
field. These are typically the messages logged through journald's
native API. Set the default facility for these messages to 'user'.
2014-02-27 18:05:20 +01:00
Tomas Heinrich
21fd5d8a8c imjournal: Set default severity for all messages
Some messages comming from journald don't have the SYSLOG_PRIORITY
field. These are typically the messages logged through journald's
native API. Set the default severity for these messages to 'notice'.
2014-02-27 18:05:20 +01:00
Tomas Heinrich
49ee57cc5c imjournal: Don't drop messages without the MESSAGE field 2014-02-27 18:05:20 +01:00
Rainer Gerhards
cdc73cfc8c nitfix: file system permissions
Thanks to Tomas Heinrich for reporting this.
2014-01-08 09:39:04 +01:00
Rainer Gerhards
3911b41420 imjournal: rate limiter was destructed too early
Too quick hacking, obviously, one too late, one too early, now
it should fit ;) Thanks to Tomas Heinrich for pointing this out.
2013-06-17 14:33:14 +02:00
Rainer Gerhards
1f6d402d50 imjournal fix: put ratelimiter destruction in wrong entry point
No regression, this was in recently written, never-released code.
2013-06-17 14:18:23 +02:00
Rainer Gerhards
4357348b96 implement new ratelimiting mode for imjournal
and make imjournal use it.

The new mode is needed, as imjournal uses journal's timestamp
as message generation time (which otherwise is when the message
entered the system, and the ratelimiter uses this as current
timestamp in order to save performance).

It is debatable if imjournal is doing the right thing here. But
it doesn't feel totally wrong. So let's safe that debate for
later ;)
2013-06-17 13:34:17 +02:00
Milan Bartos
49e4eca2f8 Add IgnorePreviousMessages option to imjournal.
This option specifies whether imjournal should ignore messages
that are currently in journal. This option is only used when there
is no StateFile to avoid message loss.

	modified:   doc/imjournal.html
	modified:   plugins/imjournal/imjournal.c

Conflicts:
	doc/imjournal.html
	plugins/imjournal/imjournal.c
2013-06-17 08:14:59 +02:00
Rainer Gerhards
2285e8da87 Merge branch 'tmp' into v7-stable
Conflicts:
	plugins/imjournal/imjournal.c
2013-06-17 07:53:29 +02:00
Milan Bartos
77fd80604e Rename legacy imjournal configs to have "imjournal" prepended.
modified:   doc/imjournal.html
	modified:   plugins/imjournal/imjournal.c
2013-06-17 07:50:21 +02:00
Rainer Gerhards
2a632dc6c9 imjournal: add legacy config statement for ratelimiting 2013-06-15 14:44:18 +02:00
Rainer Gerhards
9057b1ccfb imjournal: add ratelimiting capability
The original imjournal code did not support ratelimiting at all. We
now have our own ratelimiter. This can mitigate against journal
database corruption, when the journal re-sends old data. This is a
current bug in systemd journal, but we won't outrule this to happen
in the future again. So it is better to have a safeguard in place.
By default, we permit 20,000 messages witin 10 minutes. This may
be a bit restrictive, but given the risk potential it seems reasonable.
Users requiring larger traffic flows can always adjust the value.
2013-06-15 12:49:38 +02:00
Tomas Heinrich
d2b9feaf34 bugfix: prevent a segfault if state file is not defined 2013-06-14 08:06:17 +02:00
Tomas Heinrich
fc72c6cccc bugfix: be more tolerant to malformed journal fields
This prevents a segfault when a malformed journal entry field doesn't
contain an equal sign. Should not ever happen but was actually
triggered by a real bug in systemd journal.
2013-06-10 08:06:35 +02:00
Tomas Heinrich
ef6794aae0 bugfix: imjournal should respect termination request
sd_journal_wait() ignores EINTR and this behavior interferes with
module's termination signaling. Therefore, poll() is used instead.
2013-05-26 15:19:57 +02:00
Tomas Heinrich
388665abdf bugfix: imjournal's thread shouldn't be canceled
Because of cancelation, the correct possition in the journal was
lost. This resulted in duplicate messages appearing in the logs.
2013-05-26 15:19:57 +02:00