From 81406f18983d2adb934c970e4949f4dafeb63308 Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Tue, 21 Jul 2009 10:36:47 +0200 Subject: fixed testbench compile problem on some platforms --- tests/rt-init.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/rt-init.c b/tests/rt-init.c index aaac7ed1..b9c4ce2e 100644 --- a/tests/rt-init.c +++ b/tests/rt-init.c @@ -21,10 +21,9 @@ * * A copy of the GPL can be found in the file "COPYING" in this distribution. */ -#include - #include "rsyslog.h" #include "testbench.h" +#include /* must be last, else we get a zlib compile error on some platforms */ MODULE_TYPE_TESTBENCH -- cgit v1.2.3 From eaf5be2ef1f35e7f3c104369a7f45c344eaa45b4 Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Tue, 28 Jul 2009 11:35:21 +0200 Subject: finishing touches for 5.1.3 --- ChangeLog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index f9857a75..4773b07d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,5 @@ --------------------------------------------------------------------------- -Version 5.1.3 [DEVEL] (rgerhards), 2009-07-?? +Version 5.1.3 [DEVEL] (rgerhards), 2009-07-28 - architecture change: queue now always has at least one worker thread if not running in direct mode. Previous versions could run without any active workers. This simplifies the code at a very small expense. -- cgit v1.2.3 From 9821ef26fb2a50e16f7f46f503b42bed4f9bb143 Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Tue, 28 Jul 2009 14:31:20 +0200 Subject: updated project status --- doc/status.html | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/doc/status.html b/doc/status.html index c5de1ad3..0b3f45ad 100644 --- a/doc/status.html +++ b/doc/status.html @@ -2,12 +2,12 @@ rsyslog status page

rsyslog status page

-

This page reflects the status as of 2009-07-15.

+

This page reflects the status as of 2009-07-28.

Current Releases

-

v5 development: 5.1.2 [2009-07-08] - -change log - -download +

v5 development: 5.1.3 [2009-07-28] - +change log - +download
v4 development: 4.5.1 [2009-07-15] - change log - -- cgit v1.2.3 From feeb622c4e0c622559df803f8df6da39bf3015e7 Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Thu, 30 Jul 2009 09:47:47 +0200 Subject: bugfix: discard action caused segfault --- ChangeLog | 3 +++ runtime/modules.c | 8 +++++--- tests/Makefile.am | 3 +++ tests/discard.sh | 16 ++++++++++++++++ tests/testsuites/discard.conf | 13 +++++++++++++ 5 files changed, 40 insertions(+), 3 deletions(-) create mode 100755 tests/discard.sh create mode 100644 tests/testsuites/discard.conf diff --git a/ChangeLog b/ChangeLog index 4773b07d..76fe3ff0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,7 @@ --------------------------------------------------------------------------- +Version 5.1.4 [DEVEL] (rgerhards), 2009-07-?? +- bugfix: discard action caused segfault +--------------------------------------------------------------------------- Version 5.1.3 [DEVEL] (rgerhards), 2009-07-28 - architecture change: queue now always has at least one worker thread if not running in direct mode. Previous versions could run without diff --git a/runtime/modules.c b/runtime/modules.c index b588909e..eee3b46e 100644 --- a/runtime/modules.c +++ b/runtime/modules.c @@ -466,10 +466,12 @@ doModInit(rsRetVal (*modInit)(int, int*, rsRetVal(**)(), rsRetVal(*)(), modInfo_ ABORT_FINALIZE(localRet); localRet = (*pNew->modQueryEtryPt)((uchar*)"endTransaction", &pNew->mod.om.endTransaction); - if(localRet == RS_RET_MODULE_ENTRY_POINT_NOT_FOUND) - pNew->mod.om.beginTransaction = dummyEndTransaction; - else if(localRet != RS_RET_OK) + if(localRet == RS_RET_MODULE_ENTRY_POINT_NOT_FOUND) { + pNew->mod.om.endTransaction = dummyEndTransaction; + //pNew->mod.om.beginTransaction = dummyEndTransaction; + } else if(localRet != RS_RET_OK) { ABORT_FINALIZE(localRet); + } break; case eMOD_LIB: break; diff --git a/tests/Makefile.am b/tests/Makefile.am index 4ea641f0..2a3dbaf2 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -21,6 +21,7 @@ TESTS += omod-if-array.sh \ inputname.sh \ threadingmq.sh \ threadingmqaq.sh \ + discard.sh \ fieldtest.sh endif @@ -114,6 +115,8 @@ EXTRA_DIST= 1.rstest 2.rstest 3.rstest err1.rstest \ testsuites/1.inputname_imtcp_12515 \ testsuites/1.inputname_imtcp_12516 \ omod-if-array.sh \ + discard.sh \ + testsuites/discard.conf \ diag.sh \ testsuites/diag-common.conf \ daqueue-persist.sh \ diff --git a/tests/discard.sh b/tests/discard.sh new file mode 100755 index 00000000..b230bc11 --- /dev/null +++ b/tests/discard.sh @@ -0,0 +1,16 @@ +# Test for discard functionality +# This test checks if discard works. It is not a perfect test but +# will find at least segfaults and obviously not discarded messages. +# added 2009-07-30 by Rgerhards +# This file is part of the rsyslog project, released under GPLv3 +# uncomment for debugging support: +echo TEST discard.sh: testing discard functionality +source $srcdir/diag.sh init +source $srcdir/diag.sh startup discard.conf +# 20000 messages should be enough - the disk test is slow enough ;) +sleep 4 +source $srcdir/diag.sh tcpflood 127.0.0.1 13514 1 10 1 +source $srcdir/diag.sh shutdown-when-empty # shut down rsyslogd when done processing messages +source $srcdir/diag.sh wait-shutdown +source $srcdir/diag.sh seq-check 2 10 +source $srcdir/diag.sh exit diff --git a/tests/testsuites/discard.conf b/tests/testsuites/discard.conf new file mode 100644 index 00000000..bbe2fe77 --- /dev/null +++ b/tests/testsuites/discard.conf @@ -0,0 +1,13 @@ +# Test for discard functionality +# rgerhards, 2009-07-30 +$IncludeConfig diag-common.conf + +$ModLoad ../plugins/imtcp/.libs/imtcp +$MainMsgQueueTimeoutShutdown 10000 +$InputTCPServerRun 13514 + +:msg, contains, "00000001" ~ + +$template outfmt,"%msg:F,58:2%\n" +$template dynfile,"rsyslog.out.log" # trick to use relative path names! +:msg, contains, "msgnum:" ?dynfile;outfmt -- cgit v1.2.3 From a6bda9b93f21cdbec1d7312078535eb092f32cb0 Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Thu, 30 Jul 2009 11:09:15 +0200 Subject: bugfix: discard action did not work (did not discard messages) --- ChangeLog | 1 + action.c | 56 ++++++++++++++++++++++++++++++++++++------------------- runtime/queue.c | 2 ++ runtime/rule.c | 2 ++ runtime/ruleset.c | 11 ++++++++--- tests/discard.sh | 2 +- 6 files changed, 51 insertions(+), 23 deletions(-) diff --git a/ChangeLog b/ChangeLog index 76fe3ff0..b3b3c82b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,6 @@ --------------------------------------------------------------------------- Version 5.1.4 [DEVEL] (rgerhards), 2009-07-?? +- bugfix: discard action did not work (did not discard messages) - bugfix: discard action caused segfault --------------------------------------------------------------------------- Version 5.1.3 [DEVEL] (rgerhards), 2009-07-28 diff --git a/action.c b/action.c index 8a29df2e..ab3a7866 100644 --- a/action.c +++ b/action.c @@ -808,41 +808,50 @@ tryDoAction(action_t *pAction, batch_t *pBatch, int *pnElem) assert(pBatch != NULL); assert(pnElem != NULL); +dbgprintf("XXXX: ENTER tryDoAction elt 0 state %d\n", pBatch->pElem[0].state); i = pBatch->iDoneUpTo; /* all messages below that index are processed */ iElemProcessed = 0; iCommittedUpTo = i; while(iElemProcessed <= *pnElem && i < pBatch->nElem) { pMsg = (msg_t*) pBatch->pElem[i].pUsrp; - dbgprintf("submitBatch: i:%d, batch size %d, to process %d, pMsg: %p\n", i, pBatch->nElem, *pnElem, pMsg);//remove later! - localRet = actionProcessMessage(pAction, pMsg); - dbgprintf("action call returned %d\n", localRet); - if(localRet == RS_RET_OK) { - /* mark messages as committed */ - while(iCommittedUpTo < i) { - pBatch->pElem[iCommittedUpTo++].state = BATCH_STATE_COMM; - } - } else if(localRet == RS_RET_PREVIOUS_COMMITTED) { - /* mark messages as committed */ - while(iCommittedUpTo < i - 1) { - pBatch->pElem[iCommittedUpTo++].state = BATCH_STATE_COMM; + dbgprintf("submitBatch: i:%d, batch size %d, to process %d, pMsg: %p, state %d\n", i, pBatch->nElem, *pnElem, pMsg, pBatch->pElem[i].state);//remove later! + if(pBatch->pElem[i].state != BATCH_STATE_DISC) { + localRet = actionProcessMessage(pAction, pMsg); + dbgprintf("action call returned %d\n", localRet); + if(localRet == RS_RET_OK) { + /* mark messages as committed */ + while(iCommittedUpTo < i) { + pBatch->pElem[iCommittedUpTo++].state = BATCH_STATE_COMM; + } + } else if(localRet == RS_RET_PREVIOUS_COMMITTED) { + /* mark messages as committed */ + while(iCommittedUpTo < i - 1) { + pBatch->pElem[iCommittedUpTo++].state = BATCH_STATE_COMM; + } + pBatch->pElem[i].state = BATCH_STATE_SUB; + } else if(localRet == RS_RET_PREVIOUS_COMMITTED) { + pBatch->pElem[i].state = BATCH_STATE_SUB; + } else if(localRet == RS_RET_DISCARDMSG) { + pBatch->pElem[i].state = BATCH_STATE_DISC; +dbgprintf("XXXX: discardmsg! change state to _DISC: %d\n", pBatch->pElem[i].state); + } else { + iRet = localRet; + FINALIZE; } - pBatch->pElem[i].state = BATCH_STATE_SUB; - } else if(localRet == RS_RET_PREVIOUS_COMMITTED) { - pBatch->pElem[i].state = BATCH_STATE_SUB; - } else { - iRet = localRet; - FINALIZE; } ++i; ++iElemProcessed; } finalize_it: - if(pBatch->iDoneUpTo != iCommittedUpTo) { + if(pBatch->nElem == 1 && pBatch->pElem[0].state == BATCH_STATE_DISC) { + iRet = RS_RET_DISCARDMSG; + } else if(pBatch->iDoneUpTo != iCommittedUpTo) { *pnElem += iCommittedUpTo - pBatch->iDoneUpTo; pBatch->iDoneUpTo = iCommittedUpTo; } +dbgprintf("XXXX: done tryDoAction elt 0 state %d, iret %d\n", pBatch->pElem[0].state, iRet); RETiRet; } @@ -865,6 +874,7 @@ submitBatch(action_t *pAction, batch_t *pBatch, int nElem) bDone = 0; do { localRet = tryDoAction(pAction, pBatch, &nElem); +dbgprintf("XXXX: submitBatch got state %d\n", localRet); if( localRet == RS_RET_OK || localRet == RS_RET_PREVIOUS_COMMITTED || localRet == RS_RET_DEFER_COMMIT) { @@ -874,10 +884,15 @@ submitBatch(action_t *pAction, batch_t *pBatch, int nElem) localRet = finishBatch(pAction); } +dbgprintf("XXXX: submitBatch got state %d\n", localRet); if( localRet == RS_RET_OK || localRet == RS_RET_PREVIOUS_COMMITTED || localRet == RS_RET_DEFER_COMMIT) { bDone = 1; + } else if(localRet == RS_RET_DISCARDMSG) { + iRet = RS_RET_DISCARDMSG; /* TODO: verify this sequence -- rgerhards, 2009-07-30 */ + bDone = 1; +dbgprintf("XXXX: submitBatch DONE state %d\n", localRet); } else if(localRet == RS_RET_SUSPENDED) { ; /* do nothing, this will retry the full batch */ } else if(localRet == RS_RET_ACTION_FAILED) { @@ -897,8 +912,10 @@ submitBatch(action_t *pAction, batch_t *pBatch, int nElem) bDone = 1; } } +dbgprintf("XXXX: submitBatch pre while state %d\n", localRet); } while(!bDone); /* do .. while()! */ +dbgprintf("XXXX: END submitBatch elt 0 state %d, iRet %d\n", pBatch->pElem[0].state, iRet); RETiRet; } @@ -1134,6 +1151,7 @@ actionWriteToAction(action_t *pAction) * So let's enqueue our message for execution. -- rgerhards, 2007-07-24 */ iRet = qqueueEnqObj(pAction->pQueue, pAction->f_pMsg->flowCtlType, (void*) MsgAddRef(pAction->f_pMsg)); +dbgprintf("XXXX: queueEnqObj returned %d\n", iRet); if(iRet == RS_RET_OK) pAction->f_prevcount = 0; /* message processed, so we start a new cycle */ diff --git a/runtime/queue.c b/runtime/queue.c index cb14b58d..8388d00e 100644 --- a/runtime/queue.c +++ b/runtime/queue.c @@ -1044,6 +1044,7 @@ static rsRetVal qAddDirect(qqueue_t *pThis, void* pUsr) iRet = pThis->pConsumer(pThis->pUsr, &singleBatch); objDestruct(pUsr); +dbgprintf("XXXX: qAddDirect returns %d\n", iRet); RETiRet; } @@ -2442,6 +2443,7 @@ doEnqSingleObj(qqueue_t *pThis, flowControl_t flowCtlType, void *pUsr) CHKiRet(qqueueAdd(pThis, pUsr)); finalize_it: +dbgprintf("XXXX: queueEnqObj returns %d\n", iRet); RETiRet; } diff --git a/runtime/rule.c b/runtime/rule.c index 182d616a..bcd82e5f 100644 --- a/runtime/rule.c +++ b/runtime/rule.c @@ -83,6 +83,7 @@ DEFFUNC_llExecFunc(processMsgDoActions) } iRetMod = actionCallAction(pAction, pDoActData->pMsg); +dbgprintf("XXXX: processMsgDoActions returns %d\n", iRet); if(iRetMod == RS_RET_DISCARDMSG) { ABORT_FINALIZE(RS_RET_DISCARDMSG); } else if(iRetMod == RS_RET_SUSPENDED) { @@ -271,6 +272,7 @@ processMsg(rule_t *pThis, msg_t *pMsg) } finalize_it: +dbgprintf("XXXX: rule.processMsg returns %d\n", iRet); RETiRet; } diff --git a/runtime/ruleset.c b/runtime/ruleset.c index d98b4217..c1b6d490 100644 --- a/runtime/ruleset.c +++ b/runtime/ruleset.c @@ -138,8 +138,11 @@ finalize_it: */ DEFFUNC_llExecFunc(processMsgDoRules) { + rsRetVal iRet; ISOBJ_TYPE_assert(pData, rule); - return rule.ProcessMsg((rule_t*) pData, (msg_t*) pParam); + iRet = rule.ProcessMsg((rule_t*) pData, (msg_t*) pParam); +dbgprintf("XXXX: pcoessMsgDoRules returns %d\n", iRet); + return iRet; } @@ -159,8 +162,10 @@ processMsg(msg_t *pMsg) CHKiRet(llExecFunc(&pThis->llRules, processMsgDoRules, pMsg)); finalize_it: - if(iRet == RS_RET_DISCARDMSG) - iRet = RS_RET_OK; +dbgprintf("XXXX: processMsg got return state %d\n", iRet); + + //if(iRet == RS_RET_DISCARDMSG) + //iRet = RS_RET_OK; RETiRet; } diff --git a/tests/discard.sh b/tests/discard.sh index b230bc11..0fafc7d9 100755 --- a/tests/discard.sh +++ b/tests/discard.sh @@ -12,5 +12,5 @@ sleep 4 source $srcdir/diag.sh tcpflood 127.0.0.1 13514 1 10 1 source $srcdir/diag.sh shutdown-when-empty # shut down rsyslogd when done processing messages source $srcdir/diag.sh wait-shutdown -source $srcdir/diag.sh seq-check 2 10 +source $srcdir/diag.sh seq-check 10 -s2 source $srcdir/diag.sh exit -- cgit v1.2.3 From 51aa94ea2c2ae57a6c7207aecf39dd4b578ad8f0 Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Thu, 30 Jul 2009 15:25:49 +0200 Subject: fixed left-over from merge failure thanks to Michael Biebl for pointing the problem out --- tests/Makefile.am | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/Makefile.am b/tests/Makefile.am index 02c67d81..3f92ac5d 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,4 +1,3 @@ -<<<<<<< HEAD:tests/Makefile.am TESTRUNS = rt_init rscript check_PROGRAMS = $(TESTRUNS) ourtail udptester TESTS = $(TESTRUNS) cfg.sh parsertest.sh omod-if-array.sh \ -- cgit v1.2.3 From aa10f7a16415112c014c6c628f2f25f4eb4beaa2 Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Mon, 17 Aug 2009 14:44:42 +0200 Subject: legacy syslog parser changed so that it now accepts date stamps in wrong case. Some devices seem to create them and I do not see any harm in supporting that. --- ChangeLog | 3 ++ runtime/datetime.c | 56 ++++++++++++++++++++++--------------- tests/testsuites/upcase-date.parse1 | 4 +++ 3 files changed, 41 insertions(+), 22 deletions(-) create mode 100644 tests/testsuites/upcase-date.parse1 diff --git a/ChangeLog b/ChangeLog index f5f3940d..10d3da0e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ --------------------------------------------------------------------------- Version 4.5.2 [DEVEL] (rgerhards), 2009-07-?? +- legacy syslog parser changed so that it now accepts date stamps in + wrong case. Some devices seem to create them and I do not see any harm + in supporting that. - bugfix: memory leak with some input modules. Those inputs that use parseAndSubmitMsg() leak two small memory blocks with every message. Typically, those process only relatively few messages, so the issue diff --git a/runtime/datetime.c b/runtime/datetime.c index 2db1d3c5..dfa56b4f 100644 --- a/runtime/datetime.c +++ b/runtime/datetime.c @@ -335,6 +335,10 @@ ParseTIMESTAMP3164(struct syslogTime *pTime, uchar** ppszTS) * We will use this for parsing, as it probably is the * fastest way to parse it. * + * 2009-08-17: we now do case-insensitive comparisons, as some devices obviously do not + * obey to the RFC-specified case. As we need to guess in any case, we can ignore case + * in the first place -- rgerhards + * * 2005-07-18, well sometimes it pays to be a bit more verbose, even in C... * Fixed a bug that lead to invalid detection of the data. The issue was that * we had an if(++pszTS == 'x') inside of some of the consturcts below. However, @@ -346,20 +350,21 @@ ParseTIMESTAMP3164(struct syslogTime *pTime, uchar** ppszTS) */ switch(*pszTS++) { + case 'j': case 'J': - if(*pszTS == 'a') { + if(*pszTS == 'a' || *pszTS == 'A') { ++pszTS; - if(*pszTS == 'n') { + if(*pszTS == 'n' || *pszTS == 'N') { ++pszTS; month = 1; } else ABORT_FINALIZE(RS_RET_INVLD_TIME); - } else if(*pszTS == 'u') { + } else if(*pszTS == 'u' || *pszTS == 'U') { ++pszTS; - if(*pszTS == 'n') { + if(*pszTS == 'n' || *pszTS == 'N') { ++pszTS; month = 6; - } else if(*pszTS == 'l') { + } else if(*pszTS == 'l' || *pszTS == 'L') { ++pszTS; month = 7; } else @@ -367,10 +372,11 @@ ParseTIMESTAMP3164(struct syslogTime *pTime, uchar** ppszTS) } else ABORT_FINALIZE(RS_RET_INVLD_TIME); break; + case 'f': case 'F': - if(*pszTS == 'e') { + if(*pszTS == 'e' || *pszTS == 'E') { ++pszTS; - if(*pszTS == 'b') { + if(*pszTS == 'b' || *pszTS == 'B') { ++pszTS; month = 2; } else @@ -378,13 +384,14 @@ ParseTIMESTAMP3164(struct syslogTime *pTime, uchar** ppszTS) } else ABORT_FINALIZE(RS_RET_INVLD_TIME); break; + case 'm': case 'M': - if(*pszTS == 'a') { + if(*pszTS == 'a' || *pszTS == 'A') { ++pszTS; - if(*pszTS == 'r') { + if(*pszTS == 'r' || *pszTS == 'R') { ++pszTS; month = 3; - } else if(*pszTS == 'y') { + } else if(*pszTS == 'y' || *pszTS == 'Y') { ++pszTS; month = 5; } else @@ -392,17 +399,18 @@ ParseTIMESTAMP3164(struct syslogTime *pTime, uchar** ppszTS) } else ABORT_FINALIZE(RS_RET_INVLD_TIME); break; + case 'a': case 'A': - if(*pszTS == 'p') { + if(*pszTS == 'p' || *pszTS == 'P') { ++pszTS; - if(*pszTS == 'r') { + if(*pszTS == 'r' || *pszTS == 'R') { ++pszTS; month = 4; } else ABORT_FINALIZE(RS_RET_INVLD_TIME); - } else if(*pszTS == 'u') { + } else if(*pszTS == 'u' || *pszTS == 'U') { ++pszTS; - if(*pszTS == 'g') { + if(*pszTS == 'g' || *pszTS == 'G') { ++pszTS; month = 8; } else @@ -410,10 +418,11 @@ ParseTIMESTAMP3164(struct syslogTime *pTime, uchar** ppszTS) } else ABORT_FINALIZE(RS_RET_INVLD_TIME); break; + case 's': case 'S': - if(*pszTS == 'e') { + if(*pszTS == 'e' || *pszTS == 'E') { ++pszTS; - if(*pszTS == 'p') { + if(*pszTS == 'p' || *pszTS == 'P') { ++pszTS; month = 9; } else @@ -421,10 +430,11 @@ ParseTIMESTAMP3164(struct syslogTime *pTime, uchar** ppszTS) } else ABORT_FINALIZE(RS_RET_INVLD_TIME); break; + case 'o': case 'O': - if(*pszTS == 'c') { + if(*pszTS == 'c' || *pszTS == 'C') { ++pszTS; - if(*pszTS == 't') { + if(*pszTS == 't' || *pszTS == 'T') { ++pszTS; month = 10; } else @@ -432,10 +442,11 @@ ParseTIMESTAMP3164(struct syslogTime *pTime, uchar** ppszTS) } else ABORT_FINALIZE(RS_RET_INVLD_TIME); break; + case 'n': case 'N': - if(*pszTS == 'o') { + if(*pszTS == 'o' || *pszTS == 'O') { ++pszTS; - if(*pszTS == 'v') { + if(*pszTS == 'v' || *pszTS == 'V') { ++pszTS; month = 11; } else @@ -443,10 +454,11 @@ ParseTIMESTAMP3164(struct syslogTime *pTime, uchar** ppszTS) } else ABORT_FINALIZE(RS_RET_INVLD_TIME); break; + case 'd': case 'D': - if(*pszTS == 'e') { + if(*pszTS == 'e' || *pszTS == 'E') { ++pszTS; - if(*pszTS == 'c') { + if(*pszTS == 'c' || *pszTS == 'C') { ++pszTS; month = 12; } else diff --git a/tests/testsuites/upcase-date.parse1 b/tests/testsuites/upcase-date.parse1 new file mode 100644 index 00000000..2d21222a --- /dev/null +++ b/tests/testsuites/upcase-date.parse1 @@ -0,0 +1,4 @@ +<6>AUG 10 22:18:24 2009 netips-warden2-p [audit] user=[*SMS] src=192.168.11.11 iface=5 access=9 Update State Reset +6,kern,info,Aug 10 22:18:24,2009,,, netips-warden2-p [audit] user=[*SMS] src=192.168.11.11 iface=5 access=9 Update State Reset +#Example from RFC3164, section 5.4 +#Only the first two lines are important, you may place anything behind them! -- cgit v1.2.3 From 9cab1036d23fdb59437ee6fcd82f041c555de094 Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Mon, 17 Aug 2009 16:23:37 +0200 Subject: bugfix: if tcp listen port could not be created, no error message was emitted --- ChangeLog | 2 ++ doc/imtcp.html | 5 +++-- tcpsrv.c | 8 ++++++-- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 10d3da0e..cf9d30ca 100644 --- a/ChangeLog +++ b/ChangeLog @@ -7,6 +7,8 @@ Version 4.5.2 [DEVEL] (rgerhards), 2009-07-?? use parseAndSubmitMsg() leak two small memory blocks with every message. Typically, those process only relatively few messages, so the issue does most probably not have any effect in practice. +- bugfix: if tcp listen port could not be created, no error message was + emitted --------------------------------------------------------------------------- Version 4.5.1 [DEVEL] (rgerhards), 2009-07-15 - CONFIG CHANGE: $HUPisRestart default is now "off". We are doing this diff --git a/doc/imtcp.html b/doc/imtcp.html index 9ea7efa1..34bfbfcf 100644 --- a/doc/imtcp.html +++ b/doc/imtcp.html @@ -43,8 +43,9 @@ can be found at the Cisco tcp page.

  • $InputTCPServerRun <port>
    Starts a TCP server on selected port
  • -
    • $InputTCPMaxSessions <number>
    -Sets the maximum number of sessions supported
  • $InputTCPServerStreamDriverMode <number>
    +
  • $InputTCPMaxSessions <number>
    +Sets the maximum number of sessions supported
  • +
  • $InputTCPServerStreamDriverMode <number>
    Sets the driver mode for the currently selected
    network stream driver. <number> is driver specifc.
  • $InputTCPServerInputName <name>
    Sets a name for the inputname property. If no name is set "imtcp" is used by default. Setting a diff --git a/tcpsrv.c b/tcpsrv.c index e8ea2b98..6f9ca108 100644 --- a/tcpsrv.c +++ b/tcpsrv.c @@ -327,15 +327,19 @@ finalize_it: static rsRetVal create_tcp_socket(tcpsrv_t *pThis) { - tcpLstnPortList_t *pEntry; DEFiRet; + rsRetVal localRet; + tcpLstnPortList_t *pEntry; ISOBJ_TYPE_assert(pThis, tcpsrv); /* init all configured ports */ pEntry = pThis->pLstnPorts; while(pEntry != NULL) { - CHKiRet(initTCPListener(pThis, pEntry)); + localRet = initTCPListener(pThis, pEntry); + if(localRet != RS_RET_OK) { + errmsg.LogError(0, localRet, "Could not create tcp listener, ignoring port %s.", pEntry->pszPort); + } pEntry = pEntry->pNext; } -- cgit v1.2.3 From 56b781e5bb1ea08b76d5dcc1d5e5eab10a40a4c6 Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Mon, 17 Aug 2009 17:18:19 +0200 Subject: added $InputTCPMaxListeners directive permits to specify how many TCP servers shall be possible (default is 20). --- ChangeLog | 2 ++ doc/imtcp.html | 7 +++++-- plugins/imtcp/imtcp.c | 5 +++++ tcpsrv.c | 39 ++++++++++++++++++++++++++------------- tcpsrv.h | 7 +++++-- 5 files changed, 43 insertions(+), 17 deletions(-) diff --git a/ChangeLog b/ChangeLog index cf9d30ca..b8e884e3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,6 +3,8 @@ Version 4.5.2 [DEVEL] (rgerhards), 2009-07-?? - legacy syslog parser changed so that it now accepts date stamps in wrong case. Some devices seem to create them and I do not see any harm in supporting that. +- added $InputTCPMaxListeners directive - permits to specify how many + TCP servers shall be possible (default is 20). - bugfix: memory leak with some input modules. Those inputs that use parseAndSubmitMsg() leak two small memory blocks with every message. Typically, those process only relatively few messages, so the issue diff --git a/doc/imtcp.html b/doc/imtcp.html index 34bfbfcf..5217634e 100644 --- a/doc/imtcp.html +++ b/doc/imtcp.html @@ -43,8 +43,10 @@ can be found at the Cisco tcp page.
  • $InputTCPServerRun <port>
    Starts a TCP server on selected port
  • +
  • $InputTCPMaxListeners <number>
    +Sets the maximum number of listeners (server ports) supported. Default is 20. This must be set before the first $InputTCPServerRun directive.
  • $InputTCPMaxSessions <number>
    -Sets the maximum number of sessions supported
  • +Sets the maximum number of sessions supported. Default is 200. This must be set before the first $InputTCPServerRun directive
  • $InputTCPServerStreamDriverMode <number>
    Sets the driver mode for the currently selected
    network stream driver. <number> is driver specifc.
  • $InputTCPServerInputName <name>
    @@ -52,7 +54,8 @@ Sets a name for the inputname property. If no name is set "imtcp" is used by def name is not strictly necessary, but can be useful to apply filtering based on which input the message was received from.
  • $InputTCPServerStreamDriverAuthMode <mode-string>
    -Sets the authentication mode for the currently selected network stream driver. <mode-string> is driver specifc.
  • $InputTCPServerStreamDriverPermittedPeer <id-string>
    +Sets the authentication mode for the currently selected network stream driver. <mode-string> is driver specifc.
  • +
  • $InputTCPServerStreamDriverPermittedPeer <id-string>
    Sets permitted peer IDs. Only these peers are able to connect to the listener. <id-string> semantics depend on the currently selected AuthMode and  network stream driver. PermittedPeers may not be set in anonymous modes.
  • diff --git a/plugins/imtcp/imtcp.c b/plugins/imtcp/imtcp.c index e1f513c8..01c4bc33 100644 --- a/plugins/imtcp/imtcp.c +++ b/plugins/imtcp/imtcp.c @@ -82,6 +82,7 @@ static permittedPeers_t *pPermPeersRoot = NULL; /* config settings */ static int iTCPSessMax = 200; /* max number of sessions */ +static int iTCPLstnMax = 20; /* max number of sessions */ static int iStrmDrvrMode = 0; /* mode for stream driver, driver-dependent (0 mostly means plain tcp) */ static int iAddtlFrameDelim = TCPSRV_NO_ADDTL_DELIMITER; /* addtl frame delimiter, e.g. for netscreen, default none */ static uchar *pszStrmDrvrAuthMode = NULL; /* authentication mode to use */ @@ -188,6 +189,7 @@ static rsRetVal addTCPListener(void __attribute__((unused)) *pVal, uchar *pNewVa if(pOurTcpsrv == NULL) { CHKiRet(tcpsrv.Construct(&pOurTcpsrv)); CHKiRet(tcpsrv.SetSessMax(pOurTcpsrv, iTCPSessMax)); + CHKiRet(tcpsrv.SetLstnMax(pOurTcpsrv, iTCPLstnMax)); CHKiRet(tcpsrv.SetCBIsPermittedHost(pOurTcpsrv, isPermittedHost)); CHKiRet(tcpsrv.SetCBRcvData(pOurTcpsrv, doRcvData)); CHKiRet(tcpsrv.SetCBOpenLstnSocks(pOurTcpsrv, doOpenLstnSocks)); @@ -273,6 +275,7 @@ static rsRetVal resetConfigVariables(uchar __attribute__((unused)) *pp, void __attribute__((unused)) *pVal) { iTCPSessMax = 200; + iTCPLstnMax = 20; iStrmDrvrMode = 0; iAddtlFrameDelim = TCPSRV_NO_ADDTL_DELIMITER; free(pszInputName); @@ -308,6 +311,8 @@ CODEmodInit_QueryRegCFSLineHdlr addTCPListener, NULL, STD_LOADABLE_MODULE_ID)); CHKiRet(omsdRegCFSLineHdlr(UCHAR_CONSTANT("inputtcpmaxsessions"), 0, eCmdHdlrInt, NULL, &iTCPSessMax, STD_LOADABLE_MODULE_ID)); + CHKiRet(omsdRegCFSLineHdlr(UCHAR_CONSTANT("inputtcpmaxlisteners"), 0, eCmdHdlrInt, + NULL, &iTCPLstnMax, STD_LOADABLE_MODULE_ID)); CHKiRet(omsdRegCFSLineHdlr(UCHAR_CONSTANT("inputtcpserverstreamdrivermode"), 0, eCmdHdlrInt, NULL, &iStrmDrvrMode, STD_LOADABLE_MODULE_ID)); CHKiRet(omsdRegCFSLineHdlr(UCHAR_CONSTANT("inputtcpserverstreamdriverauthmode"), 0, diff --git a/tcpsrv.c b/tcpsrv.c index 6f9ca108..0be723d1 100644 --- a/tcpsrv.c +++ b/tcpsrv.c @@ -261,7 +261,7 @@ static void deinit_tcp_listener(tcpsrv_t *pThis) } /* finally close our listen streams */ - for(i = 0 ; i < pThis->iLstnMax ; ++i) { + for(i = 0 ; i < pThis->iLstnCurr ; ++i) { netstrm.Destruct(pThis->ppLstn + i); } } @@ -280,12 +280,12 @@ addTcpLstn(void *pUsr, netstrm_t *pLstn) ISOBJ_TYPE_assert(pThis, tcpsrv); ISOBJ_TYPE_assert(pLstn, netstrm); - if(pThis->iLstnMax >= TCPLSTN_MAX_DEFAULT) + if(pThis->iLstnCurr >= pThis->iLstnMax) ABORT_FINALIZE(RS_RET_MAX_LSTN_REACHED); - pThis->ppLstn[pThis->iLstnMax] = pLstn; - pThis->ppLstnPort[pThis->iLstnMax] = pPortList; - ++pThis->iLstnMax; + pThis->ppLstn[pThis->iLstnCurr] = pLstn; + pThis->ppLstnPort[pThis->iLstnCurr] = pPortList; + ++pThis->iLstnCurr; finalize_it: RETiRet; @@ -485,7 +485,6 @@ Run(tcpsrv_t *pThis) * this thread. Thus, we also need to instantiate a cancel cleanup handler * to prevent us from leaking anything. -- rgerharsd, 20080-04-24 */ -RUNLOG_STR("XXXX: tcp server runs\n"); pthread_cleanup_push(RunCancelCleanup, (void*) &pSel); while(1) { CHKiRet(nssel.Construct(&pSel)); @@ -493,7 +492,7 @@ RUNLOG_STR("XXXX: tcp server runs\n"); CHKiRet(nssel.ConstructFinalize(pSel)); /* Add the TCP listen sockets to the list of read descriptors. */ - for(i = 0 ; i < pThis->iLstnMax ; ++i) { + for(i = 0 ; i < pThis->iLstnCurr ; ++i) { CHKiRet(nssel.Add(pSel, pThis->ppLstn[i], NSDSEL_RD)); } @@ -506,11 +505,10 @@ RUNLOG_STR("XXXX: tcp server runs\n"); iTCPSess = TCPSessGetNxtSess(pThis, iTCPSess); } -RUNLOG_STR("XXXX: tcp server select\n"); /* wait for io to become ready */ CHKiRet(nssel.Wait(pSel, &nfds)); - for(i = 0 ; i < pThis->iLstnMax ; ++i) { + for(i = 0 ; i < pThis->iLstnCurr ; ++i) { CHKiRet(nssel.IsReady(pSel, pThis->ppLstn[i], NSDSEL_RD, &bIsReady, &nfds)); if(bIsReady) { dbgprintf("New connect on NSD %p.\n", pThis->ppLstn[i]); @@ -518,7 +516,6 @@ RUNLOG_STR("XXXX: tcp server select\n"); --nfds; /* indicate we have processed one */ } } -RUNLOG_STR("XXXX: tcp server post select\n"); /* now check the sessions */ iTCPSess = TCPSessGetNxtSess(pThis, -1); @@ -582,7 +579,8 @@ finalize_it: /* this is a very special case - this time only we do not exit the /* Standard-Constructor */ BEGINobjConstruct(tcpsrv) /* be sure to specify the object type also in END macro! */ - pThis->iSessMax = TCPSESS_MAX_DEFAULT; /* TODO: useful default ;) */ + pThis->iSessMax = TCPSESS_MAX_DEFAULT; + pThis->iLstnMax = TCPLSTN_MAX_DEFAULT; pThis->addtlFrameDelim = TCPSRV_NO_ADDTL_DELIMITER; pThis->OnMsgReceive = NULL; ENDobjConstruct(tcpsrv) @@ -606,8 +604,8 @@ tcpsrvConstructFinalize(tcpsrv_t *pThis) CHKiRet(netstrms.ConstructFinalize(pThis->pNS)); /* set up listeners */ - CHKmalloc(pThis->ppLstn = calloc(TCPLSTN_MAX_DEFAULT, sizeof(netstrm_t*))); - CHKmalloc(pThis->ppLstnPort = calloc(TCPLSTN_MAX_DEFAULT, sizeof(tcpLstnPortList_t*))); + CHKmalloc(pThis->ppLstn = calloc(pThis->iLstnMax, sizeof(netstrm_t*))); + CHKmalloc(pThis->ppLstnPort = calloc(pThis->iLstnMax, sizeof(tcpLstnPortList_t*))); iRet = pThis->OpenLstnSocks(pThis); finalize_it: @@ -824,6 +822,20 @@ SetDrvrPermPeers(tcpsrv_t *pThis, permittedPeers_t *pPermPeers) * -------------------------------------------------------------------------- */ +/* set max number of listeners + * this must be called before ConstructFinalize, or it will have no effect! + * rgerhards, 2009-08-17 + */ +static rsRetVal +SetLstnMax(tcpsrv_t *pThis, int iMax) +{ + DEFiRet; + ISOBJ_TYPE_assert(pThis, tcpsrv); + pThis->iLstnMax = iMax; + RETiRet; +} + + /* set max number of sessions * this must be called before ConstructFinalize, or it will have no effect! * rgerhards, 2009-04-09 @@ -866,6 +878,7 @@ CODESTARTobjQueryInterface(tcpsrv) pIf->SetInputName = SetInputName; pIf->SetAddtlFrameDelim = SetAddtlFrameDelim; pIf->SetSessMax = SetSessMax; + pIf->SetLstnMax = SetLstnMax; pIf->SetDrvrMode = SetDrvrMode; pIf->SetDrvrAuthMode = SetDrvrAuthMode; pIf->SetDrvrPermPeers = SetDrvrPermPeers; diff --git a/tcpsrv.h b/tcpsrv.h index 70682398..64065aab 100644 --- a/tcpsrv.h +++ b/tcpsrv.h @@ -54,9 +54,10 @@ struct tcpsrv_s { uchar *pszInputName; /**< value to be used as input name */ ruleset_t *pRuleset; /**< ruleset to bind to */ permittedPeers_t *pPermPeers;/**< driver's permitted peers */ - int iLstnMax; /**< max nbr of listeners currently supported */ + int iLstnCurr; /**< max nbr of listeners currently supported */ netstrm_t **ppLstn; /**< our netstream listners */ tcpLstnPortList_t **ppLstnPort; /**< pointer to relevant listen port description */ + int iLstnMax; /**< max number of listners supported */ int iSessMax; /**< max number of sessions supported */ tcpLstnPortList_t *pLstnPorts; /**< head pointer for listen ports */ int addtlFrameDelim; /**< additional frame delimiter for plain TCP syslog framing (e.g. to handle NetScreen) */ @@ -111,8 +112,10 @@ BEGINinterface(tcpsrv) /* name must also be changed in ENDinterface macro! */ /* added v6 */ rsRetVal (*SetOnMsgReceive)(tcpsrv_t *pThis, rsRetVal (*OnMsgReceive)(tcps_sess_t*, uchar*, int)); /* 2009-05-24 */ rsRetVal (*SetRuleset)(tcpsrv_t *pThis, ruleset_t*); /* 2009-06-12 */ + /* added v7 */ + rsRetVal (*SetLstnMax)(tcpsrv_t *pThis, int iMaxLstn); /* 2009-08-17 */ ENDinterface(tcpsrv) -#define tcpsrvCURR_IF_VERSION 6 /* increment whenever you change the interface structure! */ +#define tcpsrvCURR_IF_VERSION 7 /* increment whenever you change the interface structure! */ /* change for v4: * - SetAddtlFrameDelim() added -- rgerhards, 2008-12-10 * - SetInputName() added -- rgerhards, 2008-12-10 -- cgit v1.2.3 From 224e87be0e57532baa658ec6b9656a879ccc2fa4 Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Tue, 18 Aug 2009 08:51:02 +0200 Subject: bugfix? (unconfirmed, testing): segfault when writing asynchronously I have undone a very small optimization with using pre-malloced memory, which seems to have some issues. Now I am doing mallocs and at least in test environment this seems to solve the issue. The code now needs more review. If it runs flawlessly for some time, I may try to re-enable to pre-malloc, but not necessarily: its performance benefit is very mild (aka: I don't think it justifies introducing bigger complexities). --- runtime/stream.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/runtime/stream.c b/runtime/stream.c index 605a9771..1b9beb5b 100644 --- a/runtime/stream.c +++ b/runtime/stream.c @@ -628,7 +628,8 @@ static rsRetVal strmConstructFinalize(strm_t *pThis) pthread_cond_init(&pThis->notEmpty, 0); pthread_cond_init(&pThis->isEmpty, 0); pThis->iCnt = pThis->iEnq = pThis->iDeq = 0; - for(i = 0 ; i < STREAM_ASYNC_NUMBUFS ; ++i) { + //for(i = 0 ; i < STREAM_ASYNC_NUMBUFS ; ++i) { + for(i = 0 ; i < 1 ; ++i) { // HOTFIX!!! CHKmalloc(pThis->asyncBuf[i].pBuf = (uchar*) malloc(sizeof(uchar) * pThis->sIOBufSize)); } pThis->pIOBuf = pThis->asyncBuf[0].pBuf; @@ -844,7 +845,10 @@ dbgprintf("XXX: doAsyncWriteInternal: strm %p, len %ld\n", pThis, (long) lenBuf) d_pthread_cond_wait(&pThis->notFull, &pThis->mut); pThis->asyncBuf[pThis->iEnq % STREAM_ASYNC_NUMBUFS].lenBuf = lenBuf; - pThis->pIOBuf = pThis->asyncBuf[++pThis->iEnq % STREAM_ASYNC_NUMBUFS].pBuf; + pThis->asyncBuf[pThis->iEnq % STREAM_ASYNC_NUMBUFS].pBuf = pThis->pIOBuf; + //pThis->pIOBuf = pThis->asyncBuf[++pThis->iEnq % STREAM_ASYNC_NUMBUFS].pBuf; + ++pThis->iEnq; + CHKmalloc(pThis->pIOBuf = (uchar*) malloc(sizeof(uchar) * pThis->sIOBufSize)); pThis->bDoTimedWait = 0; /* everything written, no need to timeout partial buffer writes */ if(++pThis->iCnt == 1) @@ -938,6 +942,8 @@ asyncWriterThread(void *pPtr) iDeq = pThis->iDeq++ % STREAM_ASYNC_NUMBUFS; doWriteInternal(pThis, pThis->asyncBuf[iDeq].pBuf, pThis->asyncBuf[iDeq].lenBuf); // TODO: error check????? 2009-07-06 + free(pThis->asyncBuf[iDeq].pBuf); + pThis->asyncBuf[iDeq].pBuf = NULL; --pThis->iCnt; if(pThis->iCnt < STREAM_ASYNC_NUMBUFS) { -- cgit v1.2.3 From dfc2b538ecdcd70a2ae091ad529a4972a91e3aa1 Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Tue, 18 Aug 2009 12:23:55 +0200 Subject: fixed compile problem introduced by merge --- runtime/stream.c | 1 + 1 file changed, 1 insertion(+) diff --git a/runtime/stream.c b/runtime/stream.c index 8d76780c..2abfb7fe 100644 --- a/runtime/stream.c +++ b/runtime/stream.c @@ -853,6 +853,7 @@ doAsyncWriteInternal(strm_t *pThis, size_t lenBuf) if(++pThis->iCnt == 1) pthread_cond_signal(&pThis->notEmpty); +finalize_it: RETiRet; } -- cgit v1.2.3 From bfc3eaf23cae0ef8685fc25b71e701e2c4690509 Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Tue, 18 Aug 2009 18:48:18 +0200 Subject: bugfix: potential segfault in output file writer (omfile) In async write mode, we use modular arithmetic to index the output buffer array. However, the counter variables accidently were signed, thus resulting in negative indizes after integer overflow. That in turn could lead to segfaults, but was depending on the memory layout of the instance in question (which in turn depended on a number of variables, like compile settings but also configuration). The counters are now unsigned (as they always should have been) and so the dangling mis-indexing does no longer happen. This bug potentially affected all installations, even if only some may actually have seen a segfault. --- ChangeLog | 10 ++++++++++ runtime/stream.c | 1 + runtime/stream.h | 4 ++-- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index b8e884e3..d1ba8617 100644 --- a/ChangeLog +++ b/ChangeLog @@ -11,6 +11,16 @@ Version 4.5.2 [DEVEL] (rgerhards), 2009-07-?? does most probably not have any effect in practice. - bugfix: if tcp listen port could not be created, no error message was emitted +- bugfix: potential segfault in output file writer (omfile) + In async write mode, we use modular arithmetic to index the output + buffer array. However, the counter variables accidently were signed, + thus resulting in negative indizes after integer overflow. That in turn + could lead to segfaults, but was depending on the memory layout of + the instance in question (which in turn depended on a number of + variables, like compile settings but also configuration). The counters + are now unsigned (as they always should have been) and so the dangling + mis-indexing does no longer happen. This bug potentially affected all + installations, even if only some may actually have seen a segfault. --------------------------------------------------------------------------- Version 4.5.1 [DEVEL] (rgerhards), 2009-07-15 - CONFIG CHANGE: $HUPisRestart default is now "off". We are doing this diff --git a/runtime/stream.c b/runtime/stream.c index 605a9771..a6ed70fe 100644 --- a/runtime/stream.c +++ b/runtime/stream.c @@ -833,6 +833,7 @@ finalize_it: * the very some producer comes back in sequence to submit the then-filled buffers. * This also enables us to timout on partially written buffers. -- rgerhards, 2009-07-06 */ +//#include static inline rsRetVal doAsyncWriteInternal(strm_t *pThis, size_t lenBuf) { diff --git a/runtime/stream.h b/runtime/stream.h index cb368835..64ffb6e1 100644 --- a/runtime/stream.h +++ b/runtime/stream.h @@ -131,8 +131,8 @@ typedef struct strm_s { pthread_cond_t notFull; pthread_cond_t notEmpty; pthread_cond_t isEmpty; - short iEnq; - short iDeq; + unsigned short iEnq; /* this MUST be unsigned as we use module arithmetic (else invalid indexing happens!) */ + unsigned short iDeq; /* this MUST be unsigned as we use module arithmetic (else invalid indexing happens!) */ short iCnt; /* current nbr of elements in buffer */ struct { uchar *pBuf; -- cgit v1.2.3 From 9bb9181572d445dd300546113fc617eb549866ba Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Tue, 18 Aug 2009 19:08:44 +0200 Subject: very minor cleanup --- runtime/stream.c | 1 - 1 file changed, 1 deletion(-) diff --git a/runtime/stream.c b/runtime/stream.c index a6ed70fe..605a9771 100644 --- a/runtime/stream.c +++ b/runtime/stream.c @@ -833,7 +833,6 @@ finalize_it: * the very some producer comes back in sequence to submit the then-filled buffers. * This also enables us to timout on partially written buffers. -- rgerhards, 2009-07-06 */ -//#include static inline rsRetVal doAsyncWriteInternal(strm_t *pThis, size_t lenBuf) { -- cgit v1.2.3 From 192bc01d9e029d86a832a3673f844d78d2a5da96 Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Wed, 19 Aug 2009 12:58:45 +0200 Subject: undid non-correct experimental fix I found out that the previous segfault fix did not correct the root cause of the problem. Thus, I can re-instantiate the more performance- optimal logic. In the next step, I'll merge in the real fix, so do NOT use this commit as code you actually run! --- runtime/stream.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/runtime/stream.c b/runtime/stream.c index 1b9beb5b..605a9771 100644 --- a/runtime/stream.c +++ b/runtime/stream.c @@ -628,8 +628,7 @@ static rsRetVal strmConstructFinalize(strm_t *pThis) pthread_cond_init(&pThis->notEmpty, 0); pthread_cond_init(&pThis->isEmpty, 0); pThis->iCnt = pThis->iEnq = pThis->iDeq = 0; - //for(i = 0 ; i < STREAM_ASYNC_NUMBUFS ; ++i) { - for(i = 0 ; i < 1 ; ++i) { // HOTFIX!!! + for(i = 0 ; i < STREAM_ASYNC_NUMBUFS ; ++i) { CHKmalloc(pThis->asyncBuf[i].pBuf = (uchar*) malloc(sizeof(uchar) * pThis->sIOBufSize)); } pThis->pIOBuf = pThis->asyncBuf[0].pBuf; @@ -845,10 +844,7 @@ dbgprintf("XXX: doAsyncWriteInternal: strm %p, len %ld\n", pThis, (long) lenBuf) d_pthread_cond_wait(&pThis->notFull, &pThis->mut); pThis->asyncBuf[pThis->iEnq % STREAM_ASYNC_NUMBUFS].lenBuf = lenBuf; - pThis->asyncBuf[pThis->iEnq % STREAM_ASYNC_NUMBUFS].pBuf = pThis->pIOBuf; - //pThis->pIOBuf = pThis->asyncBuf[++pThis->iEnq % STREAM_ASYNC_NUMBUFS].pBuf; - ++pThis->iEnq; - CHKmalloc(pThis->pIOBuf = (uchar*) malloc(sizeof(uchar) * pThis->sIOBufSize)); + pThis->pIOBuf = pThis->asyncBuf[++pThis->iEnq % STREAM_ASYNC_NUMBUFS].pBuf; pThis->bDoTimedWait = 0; /* everything written, no need to timeout partial buffer writes */ if(++pThis->iCnt == 1) @@ -942,8 +938,6 @@ asyncWriterThread(void *pPtr) iDeq = pThis->iDeq++ % STREAM_ASYNC_NUMBUFS; doWriteInternal(pThis, pThis->asyncBuf[iDeq].pBuf, pThis->asyncBuf[iDeq].lenBuf); // TODO: error check????? 2009-07-06 - free(pThis->asyncBuf[iDeq].pBuf); - pThis->asyncBuf[iDeq].pBuf = NULL; --pThis->iCnt; if(pThis->iCnt < STREAM_ASYNC_NUMBUFS) { -- cgit v1.2.3 From 7eb72ef77c8acbcc3d80644b9d3c5f15b44a9930 Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Wed, 19 Aug 2009 13:05:42 +0200 Subject: added important bug fix doc to current release the bug fix was imported from 4.5.1, but it is important enough to be highlighted in its own right. --- ChangeLog | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/ChangeLog b/ChangeLog index fdbf45cf..bb22bb91 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,16 @@ Version 5.1.4 [DEVEL] (rgerhards), 2009-07-?? - bugfix: discard action did not work (did not discard messages) - bugfix: discard action caused segfault +- bugfix: potential segfault in output file writer (omfile) + In async write mode, we use modular arithmetic to index the output + buffer array. However, the counter variables accidently were signed, + thus resulting in negative indizes after integer overflow. That in turn + could lead to segfaults, but was depending on the memory layout of + the instance in question (which in turn depended on a number of + variables, like compile settings but also configuration). The counters + are now unsigned (as they always should have been) and so the dangling + mis-indexing does no longer happen. This bug potentially affected all + installations, even if only some may actually have seen a segfault. --------------------------------------------------------------------------- Version 5.1.3 [DEVEL] (rgerhards), 2009-07-28 - architecture change: queue now always has at least one worker thread -- cgit v1.2.3 From 298b6feef1a617dcbb650f71a82c6ec1f0bb8dff Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Thu, 20 Aug 2009 09:58:42 +0200 Subject: preparing for 5.1.4 release --- ChangeLog | 13 ++++++++++++- configure.ac | 2 +- doc/manual.html | 2 +- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index bb22bb91..a97135c3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,16 @@ --------------------------------------------------------------------------- -Version 5.1.4 [DEVEL] (rgerhards), 2009-07-?? +Version 5.1.4 [DEVEL] (rgerhards), 2009-08-20 +- legacy syslog parser changed so that it now accepts date stamps in + wrong case. Some devices seem to create them and I do not see any harm + in supporting that. +- added $InputTCPMaxListeners directive - permits to specify how many + TCP servers shall be possible (default is 20). +- bugfix: memory leak with some input modules. Those inputs that + use parseAndSubmitMsg() leak two small memory blocks with every message. + Typically, those process only relatively few messages, so the issue + does most probably not have any effect in practice. +- bugfix: if tcp listen port could not be created, no error message was + emitted - bugfix: discard action did not work (did not discard messages) - bugfix: discard action caused segfault - bugfix: potential segfault in output file writer (omfile) diff --git a/configure.ac b/configure.ac index 3b17a927..e9bc9c9d 100644 --- a/configure.ac +++ b/configure.ac @@ -2,7 +2,7 @@ # Process this file with autoconf to produce a configure script. AC_PREREQ(2.61) -AC_INIT([rsyslog],[5.1.3],[rsyslog@lists.adiscon.com]) +AC_INIT([rsyslog],[5.1.4],[rsyslog@lists.adiscon.com]) AM_INIT_AUTOMAKE AC_CONFIG_SRCDIR([ChangeLog]) AC_CONFIG_MACRO_DIR([m4]) diff --git a/doc/manual.html b/doc/manual.html index f45a4952..b35b157a 100644 --- a/doc/manual.html +++ b/doc/manual.html @@ -19,7 +19,7 @@ rsyslog support available directly from the source!

    Please visit the rsyslog sponsor's page to honor the project sponsors or become one yourself! We are very grateful for any help towards the project goals.

    -

    This documentation is for version 5.1.3 (devel branch) of rsyslog. +

    This documentation is for version 5.1.4 (devel branch) of rsyslog. Visit the rsyslog status page to obtain current version information and project status.

    If you like rsyslog, you might -- cgit v1.2.3 From c7f746d8349b395b95b3aa70eb395afb07b9c4c7 Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Thu, 20 Aug 2009 12:52:33 +0200 Subject: added new config option $ActionWriteAllMarkMessages this option permites to process mark messages under all circumstances, even if an action was recently called. This can be useful to use mark messages as a kind of heartbeat. --- ChangeLog | 6 ++++++ action.c | 9 +++++++-- action.h | 1 + doc/rsyslog_conf_global.html | 6 ++++++ 4 files changed, 20 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index a97135c3..97ee9207 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,10 @@ --------------------------------------------------------------------------- +Version 5.1.5 [DEVEL] (rgerhards), 2009-08-?? +- added new config option $ActionWriteAllMarkMessages + this option permites to process mark messages under all circumstances, + even if an action was recently called. This can be useful to use mark + messages as a kind of heartbeat. +--------------------------------------------------------------------------- Version 5.1.4 [DEVEL] (rgerhards), 2009-08-20 - legacy syslog parser changed so that it now accepts date stamps in wrong case. Some devices seem to create them and I do not see any harm diff --git a/action.c b/action.c index ab3a7866..1e02d23e 100644 --- a/action.c +++ b/action.c @@ -65,8 +65,9 @@ static int glbliActionResumeInterval = 30; int glbliActionResumeRetryCount = 0; /* how often should suspended actions be retried? */ static int bActionRepMsgHasMsg = 0; /* last messsage repeated... has msg fragment in it */ +static int bActionWriteAllMarkMsgs = FALSE; /* should all mark messages be unconditionally written? */ static uchar *pszActionName; /* short name for the action */ -/* main message queue and its configuration parameters */ +/* action queue and its configuration parameters */ static queueType_t ActionQueType = QUEUETYPE_DIRECT; /* type of the main message queue above */ static int iActionQueueSize = 1000; /* size of the main message queue above */ static int iActionQueueDeqBatchSize = 16; /* batch size for action queues */ @@ -1186,7 +1187,8 @@ doActionCallAction(action_t *pAction, msg_t *pMsg) pAction->tActNow = -1; /* we do not yet know our current time (clear prev. value) */ /* don't output marks to recently written outputs */ - if((pMsg->msgFlags & MARK) && (getActNow(pAction) - pAction->f_time) < MarkInterval / 2) { + if(pAction->bWriteAllMarkMsgs == FALSE + && (pMsg->msgFlags & MARK) && (getActNow(pAction) - pAction->f_time) < MarkInterval / 2) { ABORT_FINALIZE(RS_RET_OK); } @@ -1278,6 +1280,7 @@ actionAddCfSysLineHdrl(void) CHKiRet(regCfSysLineHdlr((uchar *)"actionname", 0, eCmdHdlrGetWord, NULL, &pszActionName, NULL)); CHKiRet(regCfSysLineHdlr((uchar *)"actionqueuefilename", 0, eCmdHdlrGetWord, NULL, &pszActionQFName, NULL)); CHKiRet(regCfSysLineHdlr((uchar *)"actionqueuesize", 0, eCmdHdlrInt, NULL, &iActionQueueSize, NULL)); + CHKiRet(regCfSysLineHdlr((uchar *)"actionwriteallmarkmessages", 0, eCmdHdlrBinary, NULL, &bActionWriteAllMarkMsgs, NULL)); CHKiRet(regCfSysLineHdlr((uchar *)"actionqueuedequeuebatchsize", 0, eCmdHdlrInt, NULL, &iActionQueueDeqBatchSize, NULL)); CHKiRet(regCfSysLineHdlr((uchar *)"actionqueuemaxdiskspace", 0, eCmdHdlrSize, NULL, &iActionQueMaxDiskSpace, NULL)); CHKiRet(regCfSysLineHdlr((uchar *)"actionqueuehighwatermark", 0, eCmdHdlrInt, NULL, &iActionQHighWtrMark, NULL)); @@ -1332,6 +1335,8 @@ addAction(action_t **ppAction, modInfo_t *pMod, void *pModData, omodStringReques pAction->pModData = pModData; pAction->pszName = pszActionName; pszActionName = NULL; /* free again! */ + pAction->bWriteAllMarkMsgs = bActionWriteAllMarkMsgs; + bActionWriteAllMarkMsgs = FALSE; /* reset */ pAction->bExecWhenPrevSusp = bActExecWhenPrevSusp; pAction->iSecsExecOnceInterval = iActExecOnceInterval; pAction->iExecEveryNthOccur = iActExecEveryNthOccur; diff --git a/action.h b/action.h index a29936e5..cfa08db8 100644 --- a/action.h +++ b/action.h @@ -53,6 +53,7 @@ struct action_s { populated on an as-needed basis. This is a performance optimization. */ time_t tLastExec; /* time this action was last executed */ bool bExecWhenPrevSusp;/* execute only when previous action is suspended? */ + bool bWriteAllMarkMsgs;/* should all mark msgs be written (not matter how recent the action was executed)? */ int iSecsExecOnceInterval; /* if non-zero, minimum seconds to wait until action is executed again */ action_state_t eState; /* current state of action */ int bHadAutoCommit; /* did an auto-commit happen during doAction()? */ diff --git a/doc/rsyslog_conf_global.html b/doc/rsyslog_conf_global.html index f37dcc5a..4a88a97e 100644 --- a/doc/rsyslog_conf_global.html +++ b/doc/rsyslog_conf_global.html @@ -107,6 +107,12 @@ that it should be not be much more often than once per second).

  • $ActionSendUDPRebindInterval nbr- [available since 4.3.2] - instructs the UDP send action to rebind the send socket every nbr of messages sent. Zero, the default, means that no rebind is done. This directive is useful for use with load-balancers.
  • +
  • $ActionWriteAllMarkMessages [on/off]- [available since 5.1.5] - normally, mark messages +are written to actions only if the action was not recently executed (by default, recently means within the +past 20 minutes). If this setting is switched to "on", mark messages are always sent to actions, +no matter how recently they have been executed. In this mode, mark messages can be used as a kind of +heartbeat. +
  • $AllowedSender
  • $ControlCharacterEscapePrefix
  • $DebugPrintCFSyslineHandlerList
  • -- cgit v1.2.3 From 73b73fe5c31bcaf9052d9bbb13f38ff3a13fd22d Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Thu, 20 Aug 2009 14:18:41 +0200 Subject: bugfix: hostnames with dashes in them were incorrectly treated as malformed ... thus causing them to be treated as TAG (this was a regression introduced from the "rfc3164 strict" change in 4.5.0). Testbench has been updated to include a smaple message with a hostname containing a dash. --- ChangeLog | 4 ++++ doc/rsyslog_conf_global.html | 4 +++- doc/status.html | 8 ++++---- tools/syslogd.c | 2 +- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 97ee9207..84f3971a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -4,6 +4,10 @@ Version 5.1.5 [DEVEL] (rgerhards), 2009-08-?? this option permites to process mark messages under all circumstances, even if an action was recently called. This can be useful to use mark messages as a kind of heartbeat. +- bugfix: hostnames with dashes in them were incorrectly treated as + malformed, thus causing them to be treated as TAG (this was a regression + introduced from the "rfc3164 strict" change in 4.5.0). Testbench has been + updated to include a smaple message with a hostname containing a dash. --------------------------------------------------------------------------- Version 5.1.4 [DEVEL] (rgerhards), 2009-08-20 - legacy syslog parser changed so that it now accepts date stamps in diff --git a/doc/rsyslog_conf_global.html b/doc/rsyslog_conf_global.html index 4a88a97e..fa9c7eef 100644 --- a/doc/rsyslog_conf_global.html +++ b/doc/rsyslog_conf_global.html @@ -111,7 +111,9 @@ that no rebind is done. This directive is useful for use with load-balancers.all
    selector lines that should provide this +functionality.
  • $AllowedSender
  • $ControlCharacterEscapePrefix
  • diff --git a/doc/status.html b/doc/status.html index 0b3f45ad..b73bc85a 100644 --- a/doc/status.html +++ b/doc/status.html @@ -2,12 +2,12 @@ rsyslog status page

    rsyslog status page

    -

    This page reflects the status as of 2009-07-28.

    +

    This page reflects the status as of 2009-08-20.

    Current Releases

    -

    v5 development: 5.1.3 [2009-07-28] - -change log - -download +

    v5 development: 5.1.4 [2009-08-20] - +change log - +download
    v4 development: 4.5.1 [2009-07-15] - change log - diff --git a/tools/syslogd.c b/tools/syslogd.c index 40e9e92c..ff671138 100644 --- a/tools/syslogd.c +++ b/tools/syslogd.c @@ -1225,7 +1225,7 @@ int parseLegacySyslogMsg(msg_t *pMsg, int flags) if(flags & PARSE_HOSTNAME) { i = 0; while((isalnum(p2parse[i]) || p2parse[i] == '.' || p2parse[i] == '.' - || p2parse[i] == '_') && i < CONF_TAG_MAXSIZE) { + || p2parse[i] == '_' || p2parse[i] == '-') && i < CONF_TAG_MAXSIZE) { bufParseHOSTNAME[i] = p2parse[i]; ++i; } -- cgit v1.2.3 From daa76ad94428599336ddafdd6854dc0b71356180 Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Thu, 20 Aug 2009 14:22:33 +0200 Subject: bugfix: hostnames with dashes in them were incorrectly treated as malformed ... thus causing them to be treated as TAG (this was a regression introduced from the "rfc3164 strict" change in 4.5.0). --- ChangeLog | 3 +++ tools/syslogd.c | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index d1ba8617..0ab127bb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -21,6 +21,9 @@ Version 4.5.2 [DEVEL] (rgerhards), 2009-07-?? are now unsigned (as they always should have been) and so the dangling mis-indexing does no longer happen. This bug potentially affected all installations, even if only some may actually have seen a segfault. +- bugfix: hostnames with dashes in them were incorrectly treated as + malformed, thus causing them to be treated as TAG (this was a regression + introduced from the "rfc3164 strict" change in 4.5.0). --------------------------------------------------------------------------- Version 4.5.1 [DEVEL] (rgerhards), 2009-07-15 - CONFIG CHANGE: $HUPisRestart default is now "off". We are doing this diff --git a/tools/syslogd.c b/tools/syslogd.c index 3846e6a9..88588621 100644 --- a/tools/syslogd.c +++ b/tools/syslogd.c @@ -1218,7 +1218,7 @@ int parseLegacySyslogMsg(msg_t *pMsg, int flags) if(flags & PARSE_HOSTNAME) { i = 0; while((isalnum(p2parse[i]) || p2parse[i] == '.' || p2parse[i] == '.' - || p2parse[i] == '_') && i < CONF_TAG_MAXSIZE) { + || p2parse[i] == '_' || p2parse[i] == '-') && i < CONF_TAG_MAXSIZE) { bufParseHOSTNAME[i] = p2parse[i]; ++i; } -- cgit v1.2.3 From e22a26ddbf7832ae5ba91291be59e5a6f71b627e Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Thu, 20 Aug 2009 14:24:51 +0200 Subject: added forgotten testcase --- tests/Makefile.am | 1 + tests/testsuites/4.parse1 | 4 ++++ 2 files changed, 5 insertions(+) create mode 100644 tests/testsuites/4.parse1 diff --git a/tests/Makefile.am b/tests/Makefile.am index 2a3dbaf2..c31e9eaa 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -78,6 +78,7 @@ EXTRA_DIST= 1.rstest 2.rstest 3.rstest err1.rstest \ testsuites/1.parse1 \ testsuites/2.parse1 \ testsuites/3.parse1 \ + testsuites/4.parse1 \ testsuites/oversizeTag-1.parse1 \ testsuites/date1.parse1 \ testsuites/date2.parse1 \ diff --git a/tests/testsuites/4.parse1 b/tests/testsuites/4.parse1 new file mode 100644 index 00000000..07e2445a --- /dev/null +++ b/tests/testsuites/4.parse1 @@ -0,0 +1,4 @@ +<29>Jul 31 21:39:21 example-b example-gw[10538]: disconnect host=/192.0.2.1 destination=192.0.2.2/11282 in=3274 out=1448 duration=0 +29,daemon,notice,Jul 31 21:39:21,example-b,example-gw,example-gw[10538]:, disconnect host=/192.0.2.1 destination=192.0.2.2/11282 in=3274 out=1448 duration=0 +# yet another real-life sample where we had some issues with - the important +# part is the dash inside the hostname! -- cgit v1.2.3 From fc5c09a7224c2550249aefb19f021a7fabf2c010 Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Fri, 21 Aug 2009 10:54:15 +0200 Subject: preparing for 4.5.2 --- ChangeLog | 2 +- configure.ac | 2 +- doc/manual.html | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4fb45a12..55ca5b45 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,5 @@ --------------------------------------------------------------------------- -Version 4.5.2 [DEVEL] (rgerhards), 2009-07-?? +Version 4.5.2 [v4-beta] (rgerhards), 2009-08-21 - legacy syslog parser changed so that it now accepts date stamps in wrong case. Some devices seem to create them and I do not see any harm in supporting that. diff --git a/configure.ac b/configure.ac index 8709c25a..ab0c3a33 100644 --- a/configure.ac +++ b/configure.ac @@ -2,7 +2,7 @@ # Process this file with autoconf to produce a configure script. AC_PREREQ(2.61) -AC_INIT([rsyslog],[4.5.1],[rsyslog@lists.adiscon.com]) +AC_INIT([rsyslog],[4.5.2],[rsyslog@lists.adiscon.com]) AM_INIT_AUTOMAKE AC_CONFIG_SRCDIR([ChangeLog]) AC_CONFIG_MACRO_DIR([m4]) diff --git a/doc/manual.html b/doc/manual.html index 0fb91e1d..e1f7480e 100644 --- a/doc/manual.html +++ b/doc/manual.html @@ -19,7 +19,7 @@ rsyslog support available directly from the source!

    Please visit the rsyslog sponsor's page to honor the project sponsors or become one yourself! We are very grateful for any help towards the project goals.

    -

    This documentation is for version 4.5.1 (beta branch) of rsyslog. +

    This documentation is for version 4.5.2 (v4-beta branch) of rsyslog. Visit the rsyslog status page to obtain current version information and project status.

    If you like rsyslog, you might -- cgit v1.2.3 From c440ae1d15d78a41477a408688c838a36b6d483f Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Fri, 21 Aug 2009 11:06:52 +0200 Subject: updating project status to reflect new releases --- doc/status.html | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/doc/status.html b/doc/status.html index b73bc85a..02cc0d70 100644 --- a/doc/status.html +++ b/doc/status.html @@ -2,24 +2,26 @@ rsyslog status page

    rsyslog status page

    -

    This page reflects the status as of 2009-08-20.

    +

    This page reflects the status as of 2009-08-21.

    Current Releases

    v5 development: 5.1.4 [2009-08-20] - change log - download - -
    v4 development: 4.5.1 [2009-07-15] - +
    + -
    beta: 4.3.2 [2009-06-24] - -change log - -download

    +
    v4-beta: 4.5.2 [2009-08-21] - +change log - +download

    -

    v4 stable: 4.2.0 [2009-06-23] - -change log - -download +

    v4 stable: 4.4.0 [2009-08-21] - +change log - +download
    v3 stable: 3.22.1 [2009-07-02] - change log - -- cgit v1.2.3