diff options
-rw-r--r-- | ChangeLog | 1 | ||||
-rw-r--r-- | doc/imjournal.html | 8 | ||||
-rwxr-xr-x | plugins/imjournal/imjournal.c | 43 | ||||
-rw-r--r-- | rsyslog.service.in | 3 | ||||
-rw-r--r-- | runtime/ratelimit.c | 4 | ||||
-rw-r--r-- | tools/syslogd.c | 2 |
6 files changed, 46 insertions, 15 deletions
@@ -28,6 +28,7 @@ Version 7.4.1 [v7.4-stable] 2013-06-?? if the message that tells about rate-limiting gets rate-limited itself, it will potentially create and endless loop - bugfix: potential segfault in imjournal if journal DB is corrupted +- bugfix: prevent a segfault in imjournal if state file is not defined - bugfix imzmq3: potential segfault on startup if no problem happend at startup, everything went fine Thanks to Hongfei Cheng and Brian Knox for the patch diff --git a/doc/imjournal.html b/doc/imjournal.html index e3f64502..df9a436a 100644 --- a/doc/imjournal.html +++ b/doc/imjournal.html @@ -11,6 +11,14 @@ <p><b>Description</b>:</p> <p>Provides the ability to import structured log messages from systemd journal to syslog.</p> +<p><b>Warning:</b> Some versions of systemd journal have problems with database +corruption, which leads to the journal to return the same data endlessly +in a thight loop. This results in massive message duplication inside rsyslog +probably resulting in a denial-of-service when the system ressouces get +exhausted. This can be somewhat mitigated by using proper rate-limiters, but +even then there are spikes of old data which are endlessly repeated. +<b>As such, it is strongly recommended to use this plugin only if there +is hard need to do so.</b> <p><b>Configuration Directives</b>:</p> <p><b>Module Directives</b></p> diff --git a/plugins/imjournal/imjournal.c b/plugins/imjournal/imjournal.c index cce45b9c..26b385ca 100755 --- a/plugins/imjournal/imjournal.c +++ b/plugins/imjournal/imjournal.c @@ -434,12 +434,13 @@ finalize_it: } -BEGINrunInput -CODESTARTrunInput - /* this is an endless loop - it is terminated when the thread is - * signalled to do so. This, however, is handled by the framework, - * right into the sleep below. - */ +/* This function loads a journal cursor from the state file. + */ +static rsRetVal +loadJournalState() +{ + DEFiRet; + if (cs.stateFile[0] != '/') { char *new_stateFile; @@ -479,6 +480,20 @@ CODESTARTrunInput } } +finalize_it: + RETiRet; +} + +BEGINrunInput +CODESTARTrunInput + /* this is an endless loop - it is terminated when the thread is + * signalled to do so. This, however, is handled by the framework. + */ + + if (cs.stateFile) { + CHKiRet(loadJournalState()); + } + while (glbl.GetGlobalInputTermState() == 0) { int count = 0, r; @@ -499,11 +514,13 @@ CODESTARTrunInput } CHKiRet(readjournal()); - /* TODO: This could use some finer metric. */ - count++; - if (count == cs.iPersistStateInterval) { - count = 0; - persistJournalState(); + if (cs.stateFile) { /* can't persist without a state file */ + /* TODO: This could use some finer metric. */ + count++; + if (count == cs.iPersistStateInterval) { + count = 0; + persistJournalState(); + } } } @@ -552,7 +569,9 @@ ENDwillRun /* close journal */ BEGINafterRun CODESTARTafterRun - persistJournalState(); + if (cs.stateFile) { /* can't persist without a state file */ + persistJournalState(); + } sd_journal_close(j); ENDafterRun diff --git a/rsyslog.service.in b/rsyslog.service.in index 08a4870f..8e2d64c2 100644 --- a/rsyslog.service.in +++ b/rsyslog.service.in @@ -1,9 +1,10 @@ [Unit] Description=System Logging Service +Requires=syslog.socket [Service] +Type=notify ExecStart=@sbindir@/rsyslogd -n -Sockets=syslog.socket StandardOutput=null [Install] diff --git a/runtime/ratelimit.c b/runtime/ratelimit.c index ec248550..6e1df3e2 100644 --- a/runtime/ratelimit.c +++ b/runtime/ratelimit.c @@ -128,8 +128,8 @@ tellLostCnt(ratelimit_t *ratelimit) snprintf((char*)msgbuf, sizeof(msgbuf), "%s: %u messages lost due to rate-limiting", ratelimit->name, ratelimit->missed); - logmsgInternal(RS_RET_RATE_LIMITED, LOG_SYSLOG|LOG_INFO, msgbuf, 0); ratelimit->missed = 0; + logmsgInternal(RS_RET_RATE_LIMITED, LOG_SYSLOG|LOG_INFO, msgbuf, 0); } } @@ -157,9 +157,9 @@ withinRatelimit(ratelimit_t *ratelimit, time_t tt) /* resume if we go out of out time window */ if(tt > ratelimit->begin + ratelimit->interval) { - tellLostCnt(ratelimit); ratelimit->begin = 0; ratelimit->done = 0; + tellLostCnt(ratelimit); } /* do actual limit check */ diff --git a/tools/syslogd.c b/tools/syslogd.c index 2bc80e44..2f0f64c3 100644 --- a/tools/syslogd.c +++ b/tools/syslogd.c @@ -2041,6 +2041,8 @@ int realMain(int argc, char **argv) ourConf->globals.bErrMsgToStderr = 0; } + sd_notify(0, "READY=1"); + mainloop(); /* do any de-init's that need to be done AFTER this comment */ |