summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2012-08-25 12:27:06 +0200
committerRainer Gerhards <rgerhards@adiscon.com>2012-08-25 12:27:06 +0200
commit27a0078958d808a323c945b58b77ee96ee690444 (patch)
tree2bcd479d0e5b42dd92c715e917722d6519c922b0
parent1eac94e11dab1e7caead5e31a57d2cae31b5ad62 (diff)
parentde71589ca3145dfbe8e34790bb49e3d86d3d3bce (diff)
downloadrsyslog-27a0078958d808a323c945b58b77ee96ee690444.tar.gz
rsyslog-27a0078958d808a323c945b58b77ee96ee690444.tar.xz
rsyslog-27a0078958d808a323c945b58b77ee96ee690444.zip
Merge branch 'master' into master-newtemplate
-rw-r--r--ChangeLog33
-rw-r--r--action.c16
-rw-r--r--doc/manual.html2
-rw-r--r--plugins/imsolaris/imsolaris.c4
-rw-r--r--plugins/imudp/imudp.c4
-rw-r--r--plugins/omudpspoof/omudpspoof.c6
-rw-r--r--runtime/modules.c8
-rw-r--r--runtime/msg.c2
-rw-r--r--runtime/obj.c37
-rw-r--r--runtime/parser.c20
-rw-r--r--runtime/ruleset.c9
-rw-r--r--runtime/srutils.c8
-rw-r--r--runtime/stream.c8
-rw-r--r--runtime/syslogd-types.h5
-rw-r--r--runtime/wti.c4
-rw-r--r--runtime/wtp.h4
-rw-r--r--tcpsrv.c2
-rw-r--r--template.c37
-rw-r--r--template.h35
-rw-r--r--tests/Makefile.am4
-rw-r--r--threads.c2
-rw-r--r--tools/omfwd.c6
-rw-r--r--tools/syslogd.c91
23 files changed, 238 insertions, 109 deletions
diff --git a/ChangeLog b/ChangeLog
index 492c27d6..1c6ec59f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -19,7 +19,16 @@ Version 6.5.0 [devel] 2012-0?-??
- $SystemLogParseTrusted config file option
Thanks to Milan Bartos for the patch
---------------------------------------------------------------------------
-Version 6.3.13 [BETA] 2012-07-??
+Version 6.4.1 [V6-STABLE] 2012-08-??
+- bugfix: multiple main queues with same queue file name were not detected
+ This lead to queue file corruption. While the root cause is a config
+ error, it is a bug that this important and hard to find config error
+ was not detected by rsyslog.
+---------------------------------------------------------------------------
+Version 6.4.0 [V6-STABLE] 2012-08-20
+- THIS IS THE FIRST VERSION OF THE 6.4.x STABLE BRANCH
+ It includes all enhancements made in 6.3.x plus what is written in the
+ ChangeLog below.
- omelasticsearch: support for parameters parent & dynparent added
- bugfix: imtcp aborted when more than 2 connections were used.
Incremented pthread stack size to 4MB for imtcp, imptcp and imttcp
@@ -538,7 +547,12 @@ expected that interfaces, even new ones, break during the initial
syslog plain tcp input plugin (NOT supporting TLS!)
[ported from v4]
---------------------------------------------------------------------------
-Version 5.9.8 [V5-BETA], 2012-05-??
+Version 5.10.0 [V5-STABLE], 2012-08-23
+
+NOTE: this is the new rsyslog v5-stable, incorporating all changes from the
+ 5.9.x series. In addition to that, it contains the fixes and
+ enhancements listed below in this entry.
+
- bugfix: delayble source could block action queue, even if there was
a disk queue associated with it. The root cause of this problem was
that it makes no sense to delay messages once they arrive in the
@@ -569,6 +583,10 @@ Version 5.9.8 [V5-BETA], 2012-05-??
Thanks to John N for reporting this issue.
- bugfix: "last message repeated n times" message was missing hostname
Thanks to Zdenek Salvet for finding this bug and to Bodik for reporting
+- bugfix: multiple main queues with same queue file name was not detected
+ This lead to queue file corruption. While the root cause is a config
+ error, it is a bug that this important and hard to find config error
+ was not detected by rsyslog.
---------------------------------------------------------------------------
Version 5.9.7 [V5-BETA], 2012-05-10
- added capability to specify substrings for field extraction mode
@@ -719,7 +737,7 @@ Version 5.9.0 [V5-DEVEL] (rgerhards), 2011-06-08
affected directive was: $ActionExecOnlyWhenPreviousIsSuspended on
closes: http://bugzilla.adiscon.com/show_bug.cgi?id=236
---------------------------------------------------------------------------
-Version 5.8.13 [V5-stable] 2012-06-??
+Version 5.8.13 [V5-stable] 2012-08-22
- bugfix: DA queue could cause abort
- bugfix: "last message repeated n times" message was missing hostname
Thanks to Zdenek Salvet for finding this bug and to Bodik for reporting
@@ -728,6 +746,15 @@ Version 5.8.13 [V5-stable] 2012-06-??
- bugfix: randomized IP option header in omudpspoof caused problems
closes: http://bugzilla.adiscon.com/show_bug.cgi?id=327
Thanks to Rick Brown for helping to test out the patch.
+- bugfix: potential abort if output plugin logged message during shutdown
+ note that none of the rsyslog-provided plugins does this
+ Thanks to bodik and Rohit Prasad for alerting us on this bug and
+ analyzing it.
+ fixes: http://bugzilla.adiscon.com/show_bug.cgi?id=347
+- bugfix: multiple main queues with same queue file name was not detected
+ This lead to queue file corruption. While the root cause is a config
+ error, it is a bug that this important and hard to find config error
+ was not detected by rsyslog.
---------------------------------------------------------------------------
Version 5.8.12 [V5-stable] 2012-06-06
- add small delay (50ms) after sending shutdown message
diff --git a/action.c b/action.c
index a16e8ce0..344bdc26 100644
--- a/action.c
+++ b/action.c
@@ -20,7 +20,7 @@
* - actionWriteToAction
* - qqueueEnqObj
* (now queue engine processing)
- * if(pThis->bWriteAllMarkMsgs == FALSE) - this is the DEFAULT
+ * if(pThis->bWriteAllMarkMsgs == RSFALSE) - this is the DEFAULT
* - doSubmitToActionQNotAllMarkBatch
* - doSubmitToActionQBatch (and from here like in the else case below!)
* else
@@ -331,7 +331,7 @@ rsRetVal actionConstruct(action_t **ppThis)
pThis->iResumeInterval = 30;
pThis->iResumeRetryCount = 0;
pThis->pszName = NULL;
- pThis->bWriteAllMarkMsgs = FALSE;
+ pThis->bWriteAllMarkMsgs = RSFALSE;
pThis->iExecEveryNthOccur = 0;
pThis->iExecEveryNthOccurTO = 0;
pThis->iSecsExecOnceInterval = 0;
@@ -411,7 +411,7 @@ actionConstructFinalize(action_t *pThis, struct cnfparamvals *queueParams)
pThis->iSecsExecOnceInterval
);
pThis->submitToActQ = doSubmitToActionQComplexBatch;
- } else if(pThis->bWriteAllMarkMsgs == FALSE) {
+ } else if(pThis->bWriteAllMarkMsgs == RSFALSE) {
/* nearly full-speed submission mode, default case */
pThis->submitToActQ = doSubmitToActionQNotAllMarkBatch;
} else {
@@ -1200,7 +1200,7 @@ prepareBatch(action_t *pAction, batch_t *pBatch)
if(pElem->bFilterOK && pElem->state != BATCH_STATE_DISC) {
pElem->state = BATCH_STATE_RDY;
if(prepareDoActionParams(pAction, pElem) != RS_RET_OK)
- pElem->bFilterOK = FALSE;
+ pElem->bFilterOK = RSFALSE;
}
}
RETiRet;
@@ -1492,7 +1492,7 @@ doActionCallAction(action_t *pAction, batch_t *pBatch, int idxBtch)
pAction->tActNow = -1; /* we do not yet know our current time (clear prev. value) */
/* don't output marks to recently written outputs */
- if(pAction->bWriteAllMarkMsgs == FALSE
+ if(pAction->bWriteAllMarkMsgs == RSFALSE
&& (pMsg->msgFlags & MARK) && (getActNow(pAction) - pAction->f_time) < MarkInterval / 2) {
ABORT_FINALIZE(RS_RET_OK);
}
@@ -1575,7 +1575,7 @@ activateActions(void)
/* This submits the message to the action queue in case where we need to handle
- * bWriteAllMarkMessage == FALSE only. Note that we use a non-blocking CAS loop
+ * bWriteAllMarkMessage == RSFALSE only. Note that we use a non-blocking CAS loop
* for the synchronization. Here, we just modify the filter condition to be false when
* a mark message must not be written. However, in this case we must save the previous
* filter as we may need it in the next action (potential future optimization: check if this is
@@ -1886,7 +1886,7 @@ addAction(action_t **ppAction, modInfo_t *pMod, void *pModData,
pAction->bRepMsgHasMsg = cs.bActionRepMsgHasMsg;
cs.iActExecEveryNthOccur = 0; /* auto-reset */
cs.iActExecEveryNthOccurTO = 0; /* auto-reset */
- cs.bActionWriteAllMarkMsgs = FALSE; /* auto-reset */
+ cs.bActionWriteAllMarkMsgs = RSFALSE; /* auto-reset */
cs.pszActionName = NULL; /* free again! */
} else {
actionApplyCnfParam(pAction, actParams);
@@ -1992,7 +1992,7 @@ resetConfigVariables(uchar __attribute__((unused)) *pp, void __attribute__((unus
static inline void
initConfigVariables(void)
{
- cs.bActionWriteAllMarkMsgs = FALSE;
+ cs.bActionWriteAllMarkMsgs = RSFALSE;
cs.glbliActionResumeRetryCount = 0;
cs.bActExecWhenPrevSusp = 0;
cs.iActExecOnceInterval = 0;
diff --git a/doc/manual.html b/doc/manual.html
index 12667161..de05d7ae 100644
--- a/doc/manual.html
+++ b/doc/manual.html
@@ -19,7 +19,7 @@ rsyslog support</a> available directly from the source!</p>
<p><b>Please visit the <a href="http://www.rsyslog.com/sponsors">rsyslog sponsor's page</a>
to honor the project sponsors or become one yourself!</b> We are very grateful for any help towards the
project goals.</p>
-<p><b>This documentation is for version 6.3.12 (beta branch) of rsyslog.</b>
+<p><b>This documentation is for version 6.4.0 (stable branch) of rsyslog.</b>
Visit the <i><a href="http://www.rsyslog.com/status">rsyslog status page</a></i></b>
to obtain current version information and project status.
</p><p><b>If you like rsyslog, you might
diff --git a/plugins/imsolaris/imsolaris.c b/plugins/imsolaris/imsolaris.c
index 8b607a84..a220e72a 100644
--- a/plugins/imsolaris/imsolaris.c
+++ b/plugins/imsolaris/imsolaris.c
@@ -252,12 +252,12 @@ getMsgs(thrdInfo_t *pThrd, int timeout)
CHKmalloc(pRcv = (uchar*) malloc(sizeof(uchar) * (iMaxLine + 1)));
}
- while(pThrd->bShallStop != TRUE) {
+ while(pThrd->bShallStop != RSTRUE) {
DBGPRINTF("imsolaris: waiting for next message (timeout %d)...\n", timeout);
if(timeout == 0) {
nfds = poll(&sun_Pfd, 1, timeout); /* wait without timeout */
- if(pThrd->bShallStop == TRUE) {
+ if(pThrd->bShallStop == RSTRUE) {
break;
}
diff --git a/plugins/imudp/imudp.c b/plugins/imudp/imudp.c
index d570e3e5..9c92ddde 100644
--- a/plugins/imudp/imudp.c
+++ b/plugins/imudp/imudp.c
@@ -290,7 +290,7 @@ processSocket(thrdInfo_t *pThrd, struct lstn_s *lstn, struct sockaddr_storage *f
assert(pThrd != NULL);
iNbrTimeUsed = 0;
while(1) { /* loop is terminated if we have a bad receive, done below in the body */
- if(pThrd->bShallStop == TRUE)
+ if(pThrd->bShallStop == RSTRUE)
ABORT_FINALIZE(RS_RET_FORCE_TERM);
socklen = sizeof(struct sockaddr_storage);
lenRcvBuf = recvfrom(lstn->sock, (char*) pRcvBuf, iMaxLine, 0, (struct sockaddr *)&frominet, &socklen);
@@ -560,7 +560,7 @@ rsRetVal rcvMainLoop(thrdInfo_t *pThrd)
nfds = epoll_wait(efd, currEvt, NUM_EPOLL_EVENTS, -1);
DBGPRINTF("imudp: epoll_wait() returned with %d fds\n", nfds);
- if(pThrd->bShallStop == TRUE)
+ if(pThrd->bShallStop == RSTRUE)
break; /* terminate input! */
for(i = 0 ; i < nfds ; ++i) {
diff --git a/plugins/omudpspoof/omudpspoof.c b/plugins/omudpspoof/omudpspoof.c
index 4ada8eb0..531a0dcf 100644
--- a/plugins/omudpspoof/omudpspoof.c
+++ b/plugins/omudpspoof/omudpspoof.c
@@ -344,7 +344,7 @@ UDPSend(instanceData *pData, uchar *pszSourcename, char *msg, size_t len)
inet_pton(AF_INET, (char*)pszSourcename, &(source_ip.sin_addr));
- bSendSuccess = FALSE;
+ bSendSuccess = RSFALSE;
d_pthread_mutex_lock(&mutLibnet);
bNeedUnlock = 1;
for (r = pData->f_addr; r; r = r->ai_next) {
@@ -387,12 +387,12 @@ UDPSend(instanceData *pData, uchar *pszSourcename, char *msg, size_t len)
if (lsent == -1) {
DBGPRINTF("Write error: %s\n", libnet_geterror(libnet_handle));
} else {
- bSendSuccess = TRUE;
+ bSendSuccess = RSTRUE;
break;
}
}
/* finished looping */
- if (bSendSuccess == FALSE) {
+ if (bSendSuccess == RSFALSE) {
DBGPRINTF("error forwarding via udp, suspending\n");
iRet = RS_RET_SUSPENDED;
}
diff --git a/runtime/modules.c b/runtime/modules.c
index bc8580f1..d3c51e90 100644
--- a/runtime/modules.c
+++ b/runtime/modules.c
@@ -657,11 +657,11 @@ doModInit(rsRetVal (*modInit)(int, int*, rsRetVal(**)(), rsRetVal(*)(), modInfo_
/* check some features */
localRet = pNew->isCompatibleWithFeature(sFEATUREAutomaticSanitazion);
if(localRet == RS_RET_OK){
- CHKiRet(parser.SetDoSanitazion(pParser, TRUE));
+ CHKiRet(parser.SetDoSanitazion(pParser, RSTRUE));
}
localRet = pNew->isCompatibleWithFeature(sFEATUREAutomaticPRIParsing);
if(localRet == RS_RET_OK){
- CHKiRet(parser.SetDoPRIParsing(pParser, TRUE));
+ CHKiRet(parser.SetDoPRIParsing(pParser, RSTRUE));
}
CHKiRet(parser.SetName(pParser, pName));
@@ -990,9 +990,9 @@ Load(uchar *pModName, sbool bConfLoad, struct nvlst *lst)
if(iModNameLen > 3 && !strcmp((char *) pModName + iModNameLen - 3, ".so")) {
iModNameLen -= 3;
- bHasExtension = TRUE;
+ bHasExtension = RSTRUE;
} else
- bHasExtension = FALSE;
+ bHasExtension = RSFALSE;
CHKiRet(findModule(pModName, iModNameLen, &pModInfo));
if(pModInfo != NULL) {
diff --git a/runtime/msg.c b/runtime/msg.c
index 99874317..da751dba 100644
--- a/runtime/msg.c
+++ b/runtime/msg.c
@@ -2814,11 +2814,13 @@ uchar *MsgGetProp(msg_t *pMsg, struct templateEntry *pTpe,
++pFld; /* skip to field terminator */
if(*pFld == pTpe->data.field.field_delim) {
++pFld; /* eat it */
+#ifdef STRICT_GPLV3
if (pTpe->data.field.field_expand != 0) {
while (*pFld == pTpe->data.field.field_delim) {
++pFld;
}
}
+#endif
++iCurrFld;
}
}
diff --git a/runtime/obj.c b/runtime/obj.c
index 99621124..eb151b67 100644
--- a/runtime/obj.c
+++ b/runtime/obj.c
@@ -610,6 +610,8 @@ static rsRetVal objDeserializeProperty(var_t *pProp, strm_t *pStrm)
number_t i;
number_t iLen;
uchar c;
+ int step = 0; /* which step was successful? */
+ int64 offs;
assert(pProp != NULL);
@@ -630,13 +632,16 @@ static rsRetVal objDeserializeProperty(var_t *pProp, strm_t *pStrm)
NEXTC;
}
CHKiRet(cstrFinalize(pProp->pcsName));
+ step = 1;
/* property type */
CHKiRet(objDeserializeNumber(&i, pStrm));
pProp->varType = i;
+ step = 2;
/* size (needed for strings) */
CHKiRet(objDeserializeNumber(&iLen, pStrm));
+ step = 3;
/* we now need to deserialize the value */
switch(pProp->varType) {
@@ -653,12 +658,44 @@ static rsRetVal objDeserializeProperty(var_t *pProp, strm_t *pStrm)
dbgprintf("invalid VARTYPE %d\n", pProp->varType);
break;
}
+ step = 4;
/* we should now be at the end of the line. So the next char must be \n */
NEXTC;
if(c != '\n') ABORT_FINALIZE(RS_RET_INVALID_PROPFRAME);
finalize_it:
+ if(Debug && iRet != RS_RET_OK) {
+ strm.GetCurrOffset(pStrm, &offs);
+ dbgprintf("error %d deserializing property name, offset %lld, step %d\n",
+ iRet, offs, step);
+ if(step >= 1) {
+ dbgprintf("error property name: '%s'\n", rsCStrGetSzStrNoNULL(pProp->pcsName));
+ }
+ if(step >= 2) {
+ dbgprintf("error var type: '%d'\n", pProp->varType);
+ }
+ if(step >= 3) {
+ dbgprintf("error len: '%d'\n", (int) iLen);
+ }
+ if(step >= 4) {
+ switch(pProp->varType) {
+ case VARTYPE_STR:
+ dbgprintf("error data string: '%s'\n",
+ rsCStrGetSzStrNoNULL(pProp->val.pStr));
+ break;
+ case VARTYPE_NUMBER:
+ dbgprintf("error number: %d\n", (int) pProp->val.num);
+ break;
+ case VARTYPE_SYSLOGTIME:
+ dbgprintf("syslog time was successfully parsed (but "
+ "is not displayed\n");
+ break;
+ default:
+ break;
+ }
+ }
+ }
RETiRet;
}
diff --git a/runtime/parser.c b/runtime/parser.c
index f0515484..645ea0f4 100644
--- a/runtime/parser.c
+++ b/runtime/parser.c
@@ -311,7 +311,7 @@ SanitizeMsg(msg_t *pMsg)
size_t iDst;
size_t iMaxLine;
size_t maxDest;
- sbool bUpdatedLen = FALSE;
+ sbool bUpdatedLen = RSFALSE;
uchar szSanBuf[32*1024]; /* buffer used for sanitizing a string */
assert(pMsg != NULL);
@@ -326,7 +326,7 @@ SanitizeMsg(msg_t *pMsg)
*/
if(pszMsg[lenMsg-1] == '\0') {
DBGPRINTF("dropped NUL at very end of message\n");
- bUpdatedLen = TRUE;
+ bUpdatedLen = RSTRUE;
lenMsg--;
}
@@ -339,7 +339,7 @@ SanitizeMsg(msg_t *pMsg)
DBGPRINTF("dropped LF at very end of message (DropTrailingLF is set)\n");
lenMsg--;
pszMsg[lenMsg] = '\0';
- bUpdatedLen = TRUE;
+ bUpdatedLen = RSTRUE;
}
/* it is much quicker to sweep over the message and see if it actually
@@ -370,7 +370,7 @@ SanitizeMsg(msg_t *pMsg)
}
if(!bNeedSanitize) {
- if(bUpdatedLen == TRUE)
+ if(bUpdatedLen == RSTRUE)
MsgSetRawMsgSize(pMsg, lenMsg);
FINALIZE;
}
@@ -508,17 +508,17 @@ ParseMsg(msg_t *pMsg)
DBGPRINTF("parse using parser list %p%s.\n", pParserList,
(pParserList == pDfltParsLst) ? " (the default list)" : "");
- bIsSanitized = FALSE;
- bPRIisParsed = FALSE;
+ bIsSanitized = RSFALSE;
+ bPRIisParsed = RSFALSE;
while(pParserList != NULL) {
pParser = pParserList->pParser;
- if(pParser->bDoSanitazion && bIsSanitized == FALSE) {
+ if(pParser->bDoSanitazion && bIsSanitized == RSFALSE) {
CHKiRet(SanitizeMsg(pMsg));
- if(pParser->bDoPRIParsing && bPRIisParsed == FALSE) {
+ if(pParser->bDoPRIParsing && bPRIisParsed == RSFALSE) {
CHKiRet(ParsePRI(pMsg));
- bPRIisParsed = TRUE;
+ bPRIisParsed = RSTRUE;
}
- bIsSanitized = TRUE;
+ bIsSanitized = RSTRUE;
}
localRet = pParser->pModule->mod.pm.parse(pMsg);
DBGPRINTF("Parser '%s' returned %d\n", pParser->pName, localRet);
diff --git a/runtime/ruleset.c b/runtime/ruleset.c
index ecded4a3..5cb34148 100644
--- a/runtime/ruleset.c
+++ b/runtime/ruleset.c
@@ -497,7 +497,7 @@ debugPrintAll(rsconf_t *conf)
static inline rsRetVal
doRulesetCreateQueue(rsconf_t *conf, int *pNewVal)
{
- uchar *rulesetMainQName;
+ uchar *rsname;
DEFiRet;
if(conf->rulesets.pCurr == NULL) {
@@ -515,10 +515,9 @@ doRulesetCreateQueue(rsconf_t *conf, int *pNewVal)
if(pNewVal == 0)
FINALIZE; /* if it is turned off, we do not need to change anything ;) */
- DBGPRINTF("adding a ruleset-specific \"main\" queue");
- rulesetMainQName = (conf->rulesets.pCurr->pszName == NULL)? UCHAR_CONSTANT("ruleset") :
- conf->rulesets.pCurr->pszName;
- CHKiRet(createMainQueue(&conf->rulesets.pCurr->pQueue, rulesetMainQName));
+ rsname = (conf->rulesets.pCurr->pszName == NULL) ? (uchar*) "[ruleset]" : conf->rulesets.pCurr->pszName;
+ DBGPRINTF("adding a ruleset-specific \"main\" queue for ruleset '%s'\n", rsname);
+ CHKiRet(createMainQueue(&conf->rulesets.pCurr->pQueue, rsname));
finalize_it:
RETiRet;
diff --git a/runtime/srutils.c b/runtime/srutils.c
index a473c83e..f420c0f7 100644
--- a/runtime/srutils.c
+++ b/runtime/srutils.c
@@ -41,8 +41,6 @@
#include <assert.h>
#include <sys/wait.h>
#include <ctype.h>
-#define TRUE 1
-#define FALSE 0
#include "srUtils.h"
#include "obj.h"
@@ -128,11 +126,11 @@ rsRetVal srUtilItoA(char *pBuf, int iLenBuf, number_t iToConv)
if(iToConv < 0)
{
- bIsNegative = TRUE;
+ bIsNegative = RSTRUE;
iToConv *= -1;
}
else
- bIsNegative = FALSE;
+ bIsNegative = RSFALSE;
/* first generate a string with the digits in the reverse direction */
i = 0;
@@ -148,7 +146,7 @@ rsRetVal srUtilItoA(char *pBuf, int iLenBuf, number_t iToConv)
return RS_RET_PROVIDED_BUFFER_TOO_SMALL;
/* then move it to the right direction... */
- if(bIsNegative == TRUE)
+ if(bIsNegative == RSTRUE)
*pBuf++ = '-';
while(i >= 0)
*pBuf++ = szBuf[i--];
diff --git a/runtime/stream.c b/runtime/stream.c
index bb1a0a42..742799d2 100644
--- a/runtime/stream.c
+++ b/runtime/stream.c
@@ -1010,6 +1010,7 @@ asyncWriterThread(void *pPtr)
struct timespec t;
sbool bTimedOut = 0;
strm_t *pThis = (strm_t*) pPtr;
+ int err;
ISOBJ_TYPE_assert(pThis, strm);
BEGINfunc
@@ -1036,8 +1037,7 @@ asyncWriterThread(void *pPtr)
bTimedOut = 0;
timeoutComp(&t, pThis->iFlushInterval * 1000); /* *1000 millisconds */
if(pThis->bDoTimedWait) {
- if(pthread_cond_timedwait(&pThis->notEmpty, &pThis->mut, &t) != 0) {
- int err = errno;
+ if((err = pthread_cond_timedwait(&pThis->notEmpty, &pThis->mut, &t)) != 0) {
if(err == ETIMEDOUT) {
bTimedOut = 1;
} else {
@@ -1170,7 +1170,7 @@ doZipWrite(strm_t *pThis, uchar *pBuf, size_t lenBuf)
{
z_stream zstrm;
int zRet; /* zlib return state */
- sbool bzInitDone = FALSE;
+ sbool bzInitDone = RSFALSE;
DEFiRet;
assert(pThis != NULL);
assert(pBuf != NULL);
@@ -1186,7 +1186,7 @@ doZipWrite(strm_t *pThis, uchar *pBuf, size_t lenBuf)
DBGPRINTF("error %d returned from zlib/deflateInit2()\n", zRet);
ABORT_FINALIZE(RS_RET_ZLIB_ERR);
}
- bzInitDone = TRUE;
+ bzInitDone = RSTRUE;
/* now doing the compression */
zstrm.next_in = (Bytef*) pBuf; /* as of zlib doc, this must be set BEFORE DeflateInit2 */
diff --git a/runtime/syslogd-types.h b/runtime/syslogd-types.h
index 30ce896a..6947a110 100644
--- a/runtime/syslogd-types.h
+++ b/runtime/syslogd-types.h
@@ -31,8 +31,9 @@
#include <syslog.h>
#endif
-#define FALSE 0
-#define TRUE 1
+/* we use RSTRUE/FALSE to prevent name claches with other packages */
+#define RSFALSE 0
+#define RSTRUE 1
#ifdef UT_NAMESIZE
# define UNAMESZ UT_NAMESIZE /* length of a login name */
diff --git a/runtime/wti.c b/runtime/wti.c
index 382f3668..f91fb5a9 100644
--- a/runtime/wti.c
+++ b/runtime/wti.c
@@ -86,7 +86,7 @@ rsRetVal
wtiSetAlwaysRunning(wti_t *pThis)
{
ISOBJ_TYPE_assert(pThis, wti);
- pThis->bAlwaysRunning = TRUE;
+ pThis->bAlwaysRunning = RSTRUE;
return RS_RET_OK;
}
@@ -198,7 +198,7 @@ wtiConstructFinalize(wti_t *pThis)
DBGPRINTF("%s: finalizing construction of worker instance data\n", wtiGetDbgHdr(pThis));
/* initialize our thread instance descriptor (no concurrency here) */
- pThis->bIsRunning = FALSE;
+ pThis->bIsRunning = RSFALSE;
/* we now alloc the array for user pointers. We obtain the max from the queue itself. */
CHKiRet(pThis->pWtp->pfGetDeqBatchSize(pThis->pWtp->pUsr, &iDeqBatchSize));
diff --git a/runtime/wtp.h b/runtime/wtp.h
index 7e24ec82..25992f7f 100644
--- a/runtime/wtp.h
+++ b/runtime/wtp.h
@@ -27,8 +27,8 @@
#include "atomic.h"
/* states for worker threads. */
-#define WRKTHRD_STOPPED FALSE
-#define WRKTHRD_RUNNING TRUE
+#define WRKTHRD_STOPPED RSFALSE
+#define WRKTHRD_RUNNING RSTRUE
/* possible states of a worker thread pool */
diff --git a/tcpsrv.c b/tcpsrv.c
index 65c24160..bf12f1fa 100644
--- a/tcpsrv.c
+++ b/tcpsrv.c
@@ -869,7 +869,7 @@ Run(tcpsrv_t *pThis)
DBGPRINTF("tcpsrv uses epoll() interface, nsdpoll driver found\n");
/* flag that we are in epoll mode */
- pThis->bUsingEPoll = TRUE;
+ pThis->bUsingEPoll = RSTRUE;
/* Add the TCP listen sockets to the list of sockets to monitor */
for(i = 0 ; i < pThis->iLstnCurr ; ++i) {
diff --git a/template.c b/template.c
index 01eab556..50db86a3 100644
--- a/template.c
+++ b/template.c
@@ -1,25 +1,30 @@
/* This is the template processing code of rsyslog.
- * Please see syslogd.c for license information.
* begun 2004-11-17 rgerhards
*
* Copyright 2004-2012 Rainer Gerhards and Adiscon
*
* This file is part of rsyslog.
*
- * Rsyslog is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * -or-
+ * see COPYING.ASL20 in the source distribution
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*
- * Rsyslog is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Rsyslog. If not, see <http://www.gnu.org/licenses/>.
- *
- * A copy of the GPL can be found in the file "COPYING" in this distribution.
+ * Note: there is a tiny bit of code left where I could not get any response
+ * from the author if this code can be placed under ASL2.0. I have guarded this
+ * with #ifdef STRICT_GPLV3. Only if that macro is defined, the code will be
+ * compiled. Otherwise this feature is not present. The plan is to do a
+ * different implementation in the future to get rid of this problem.
+ * rgerhards, 2012-08-25
*/
#include "config.h"
@@ -737,7 +742,9 @@ static int do_Parameter(unsigned char **pp, struct template *pTpl)
/* now we fall through the "regular" FromPos code */
#endif /* #ifdef FEATURE_REGEXP */
if(*p == 'F') {
+#ifdef STRICT_GPLV3
pTpe->data.field.field_expand = 0;
+#endif
/* we have a field counter, so indicate it in the template */
++p; /* eat 'F' */
if (*p == ':') {
@@ -765,10 +772,12 @@ static int do_Parameter(unsigned char **pp, struct template *pTpl)
pTpe->data.field.field_delim = 9;
} else {
pTpe->data.field.field_delim = iNum;
+# ifdef STRICT_GPLV3
if (*p == '+') {
pTpe->data.field.field_expand = 1;
p ++;
}
+# endif
if(*p == ',') { /* real fromPos? */
++p;
iNum = 0;
diff --git a/template.h b/template.h
index 9daf2c6b..c58d452c 100644
--- a/template.h
+++ b/template.h
@@ -1,25 +1,30 @@
/* This is the header for template processing code of rsyslog.
- * Please see syslogd.c for license information.
* begun 2004-11-17 rgerhards
*
* Copyright (C) 2004-2012 by Rainer Gerhards and Adiscon GmbH
*
* This file is part of rsyslog.
*
- * Rsyslog is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * -or-
+ * see COPYING.ASL20 in the source distribution
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*
- * Rsyslog is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Rsyslog. If not, see <http://www.gnu.org/licenses/>.
- *
- * A copy of the GPL can be found in the file "COPYING" in this distribution.
+ * Note: there is a tiny bit of code left where I could not get any response
+ * from the author if this code can be placed under ASL2.0. I have guarded this
+ * with #ifdef STRICT_GPLV3. Only if that macro is defined, the code will be
+ * compiled. Otherwise this feature is not present. The plan is to do a
+ * different implementation in the future to get rid of this problem.
+ * rgerhards, 2012-08-25
*/
#ifndef TEMPLATE_H_INCLUDED
@@ -89,7 +94,9 @@ struct templateEntry {
#endif
unsigned has_fields; /* support for field-counting: field to extract */
unsigned char field_delim; /* support for field-counting: field delemiter char */
+#ifdef STRICT_GPLV3
int field_expand; /* use multiple instances of the field delimiter as a single one? */
+#endif
es_str_t *propName; /**< property name (currently being used for CEE only) */
es_str_t *fieldName; /**< field name to be used for structured output */
diff --git a/tests/Makefile.am b/tests/Makefile.am
index aff44eef..c4560445 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -148,7 +148,9 @@ endif
endif
if ENABLE_EXTENDED_TESTS
-TESTS += random.sh
+# random.sh is temporarily disabled as it needs some work
+# to rsyslog core to complete in reasonable time
+#TESTS += random.sh
endif
if ENABLE_IMFILE
diff --git a/threads.c b/threads.c
index 16de5631..aea5de9f 100644
--- a/threads.c
+++ b/threads.c
@@ -102,7 +102,7 @@ thrdTerminateNonCancel(thrdInfo_t *pThis)
DBGPRINTF("request term via SIGTTIN for input thread '%s' 0x%x\n",
pThis->name, (unsigned) pThis->thrdID);
- pThis->bShallStop = TRUE;
+ pThis->bShallStop = RSTRUE;
do {
d_pthread_mutex_lock(&pThis->mutThrd);
pthread_kill(pThis->thrdID, SIGTTIN);
diff --git a/tools/omfwd.c b/tools/omfwd.c
index 7d05cb86..155e00d1 100644
--- a/tools/omfwd.c
+++ b/tools/omfwd.c
@@ -377,12 +377,12 @@ static rsRetVal UDPSend(instanceData *pData, char *msg, size_t len)
* call fails. Then, lsent has the error status, even though
* the sendto() succeeded. -- rgerhards, 2007-06-22
*/
- bSendSuccess = FALSE;
+ bSendSuccess = RSFALSE;
for (r = pData->f_addr; r; r = r->ai_next) {
for (i = 0; i < *pData->pSockArray; i++) {
lsent = sendto(pData->pSockArray[i+1], msg, len, 0, r->ai_addr, r->ai_addrlen);
if (lsent == len) {
- bSendSuccess = TRUE;
+ bSendSuccess = RSTRUE;
break;
} else {
int eno = errno;
@@ -395,7 +395,7 @@ static rsRetVal UDPSend(instanceData *pData, char *msg, size_t len)
break;
}
/* finished looping */
- if (bSendSuccess == FALSE) {
+ if (bSendSuccess == RSFALSE) {
dbgprintf("error forwarding via udp, suspending\n");
iRet = RS_RET_SUSPENDED;
}
diff --git a/tools/syslogd.c b/tools/syslogd.c
index 20a4aa12..219b41ab 100644
--- a/tools/syslogd.c
+++ b/tools/syslogd.c
@@ -216,6 +216,11 @@ int repeatinterval[2] = { 30, 60 }; /* # of secs before flush */
static pid_t ppid; /* This is a quick and dirty hack used for spliting main/startup thread */
+struct queuefilenames_s {
+ struct queuefilenames_s *next;
+ uchar *name;
+} *queuefilenames = NULL;
+
/* global variables for config file state */
int iCompatibilityMode = 0; /* version we should be compatible with; 0 means sysklogd. It is
the default, so if no -c<n> option is given, we make ourselvs
@@ -630,11 +635,19 @@ submitMsg(msg_t *pMsg)
ISOBJ_TYPE_assert(pMsg, msg);
pRuleset = MsgGetRuleset(pMsg);
-
pQueue = (pRuleset == NULL) ? pMsgQueue : ruleset.GetRulesetQueue(pRuleset);
+
+ /* if a plugin logs a message during shutdown, the queue may no longer exist */
+ if(pQueue == NULL) {
+ DBGPRINTF("submitMsg() could not submit message - "
+ "queue does (no longer?) exist - ignored\n");
+ FINALIZE;
+ }
+
MsgPrepareEnqueue(pMsg);
qqueueEnqObj(pQueue, pMsg->flowCtlType, (void*) pMsg);
+finalize_it:
RETiRet;
}
@@ -655,12 +668,20 @@ multiSubmitMsg(multi_submit_t *pMultiSub)
if(pMultiSub->nElem == 0)
FINALIZE;
+ pRuleset = MsgGetRuleset(pMultiSub->ppMsgs[0]);
+ pQueue = (pRuleset == NULL) ? pMsgQueue : ruleset.GetRulesetQueue(pRuleset);
+
+ /* if a plugin logs a message during shutdown, the queue may no longer exist */
+ if(pQueue == NULL) {
+ DBGPRINTF("multiSubmitMsg() could not submit message - "
+ "queue does (no longer?) exist - ignored\n");
+ FINALIZE;
+ }
+
for(i = 0 ; i < pMultiSub->nElem ; ++i) {
MsgPrepareEnqueue(pMultiSub->ppMsgs[i]);
}
- pRuleset = MsgGetRuleset(pMultiSub->ppMsgs[0]);
- pQueue = (pRuleset == NULL) ? pMsgQueue : ruleset.GetRulesetQueue(pRuleset);
iRet = pQueue->MultiEnq(pQueue, pMultiSub);
pMultiSub->nElem = 0;
@@ -1098,6 +1119,10 @@ finalize_it:
*/
rsRetVal createMainQueue(qqueue_t **ppQueue, uchar *pszQueueName)
{
+ struct queuefilenames_s *qfn;
+ uchar *qfname = NULL;
+ static int qfn_renamenum = 0;
+ uchar qfrenamebuf[1024];
DEFiRet;
/* switch the message object to threaded operation, if necessary */
@@ -1123,25 +1148,47 @@ rsRetVal createMainQueue(qqueue_t **ppQueue, uchar *pszQueueName)
errmsg.LogError(0, NO_ERRCODE, "Invalid " #directive ", error %d. Ignored, running with default setting", iRet); \
}
- setQPROP(qqueueSetMaxFileSize, "$MainMsgQueueFileSize", ourConf->globals.mainQ.iMainMsgQueMaxFileSize);
- setQPROP(qqueueSetsizeOnDiskMax, "$MainMsgQueueMaxDiskSpace", ourConf->globals.mainQ.iMainMsgQueMaxDiskSpace);
- setQPROP(qqueueSetiDeqBatchSize, "$MainMsgQueueDequeueBatchSize", ourConf->globals.mainQ.iMainMsgQueDeqBatchSize);
- setQPROPstr(qqueueSetFilePrefix, "$MainMsgQueueFileName", ourConf->globals.mainQ.pszMainMsgQFName);
- setQPROP(qqueueSetiPersistUpdCnt, "$MainMsgQueueCheckpointInterval", ourConf->globals.mainQ.iMainMsgQPersistUpdCnt);
- setQPROP(qqueueSetbSyncQueueFiles, "$MainMsgQueueSyncQueueFiles", ourConf->globals.mainQ.bMainMsgQSyncQeueFiles);
- setQPROP(qqueueSettoQShutdown, "$MainMsgQueueTimeoutShutdown", ourConf->globals.mainQ.iMainMsgQtoQShutdown );
- setQPROP(qqueueSettoActShutdown, "$MainMsgQueueTimeoutActionCompletion", ourConf->globals.mainQ.iMainMsgQtoActShutdown);
- setQPROP(qqueueSettoWrkShutdown, "$MainMsgQueueWorkerTimeoutThreadShutdown", ourConf->globals.mainQ.iMainMsgQtoWrkShutdown);
- setQPROP(qqueueSettoEnq, "$MainMsgQueueTimeoutEnqueue", ourConf->globals.mainQ.iMainMsgQtoEnq);
- setQPROP(qqueueSetiHighWtrMrk, "$MainMsgQueueHighWaterMark", ourConf->globals.mainQ.iMainMsgQHighWtrMark);
- setQPROP(qqueueSetiLowWtrMrk, "$MainMsgQueueLowWaterMark", ourConf->globals.mainQ.iMainMsgQLowWtrMark);
- setQPROP(qqueueSetiDiscardMrk, "$MainMsgQueueDiscardMark", ourConf->globals.mainQ.iMainMsgQDiscardMark);
- setQPROP(qqueueSetiDiscardSeverity, "$MainMsgQueueDiscardSeverity", ourConf->globals.mainQ.iMainMsgQDiscardSeverity);
- setQPROP(qqueueSetiMinMsgsPerWrkr, "$MainMsgQueueWorkerThreadMinimumMessages", ourConf->globals.mainQ.iMainMsgQWrkMinMsgs);
- setQPROP(qqueueSetbSaveOnShutdown, "$MainMsgQueueSaveOnShutdown", ourConf->globals.mainQ.bMainMsgQSaveOnShutdown);
- setQPROP(qqueueSetiDeqSlowdown, "$MainMsgQueueDequeueSlowdown", ourConf->globals.mainQ.iMainMsgQDeqSlowdown);
- setQPROP(qqueueSetiDeqtWinFromHr, "$MainMsgQueueDequeueTimeBegin", ourConf->globals.mainQ.iMainMsgQueueDeqtWinFromHr);
- setQPROP(qqueueSetiDeqtWinToHr, "$MainMsgQueueDequeueTimeEnd", ourConf->globals.mainQ.iMainMsgQueueDeqtWinToHr);
+ if(ourConf->globals.mainQ.pszMainMsgQFName != NULL) {
+ /* check if the queue file name is unique, else emit an error */
+ for(qfn = queuefilenames ; qfn != NULL ; qfn = qfn->next) {
+ dbgprintf("check queue file name '%s' vs '%s'\n", qfn->name, ourConf->globals.mainQ.pszMainMsgQFName );
+ if(!ustrcmp(qfn->name, ourConf->globals.mainQ.pszMainMsgQFName)) {
+ snprintf((char*)qfrenamebuf, sizeof(qfrenamebuf), "%d-%s-%s",
+ ++qfn_renamenum, ourConf->globals.mainQ.pszMainMsgQFName,
+ (pszQueueName == NULL) ? "NONAME" : (char*)pszQueueName);
+ qfname = ustrdup(qfrenamebuf);
+ errmsg.LogError(0, NO_ERRCODE, "Error: queue file name '%s' already in use "
+ " - using '%s' instead", ourConf->globals.mainQ.pszMainMsgQFName, qfname);
+ break;
+ }
+ }
+ if(qfname == NULL)
+ qfname = ustrdup(ourConf->globals.mainQ.pszMainMsgQFName);
+ qfn = malloc(sizeof(struct queuefilenames_s));
+ qfn->name = qfname;
+ qfn->next = queuefilenames;
+ queuefilenames = qfn;
+ }
+
+ setQPROP(qqueueSetMaxFileSize, "$MainMsgQueueFileSize", ourConf->globals.mainQ.iMainMsgQueMaxFileSize);
+ setQPROP(qqueueSetsizeOnDiskMax, "$MainMsgQueueMaxDiskSpace", ourConf->globals.mainQ.iMainMsgQueMaxDiskSpace);
+ setQPROP(qqueueSetiDeqBatchSize, "$MainMsgQueueDequeueBatchSize", ourConf->globals.mainQ.iMainMsgQueDeqBatchSize);
+ setQPROPstr(qqueueSetFilePrefix, "$MainMsgQueueFileName", qfname);
+ setQPROP(qqueueSetiPersistUpdCnt, "$MainMsgQueueCheckpointInterval", ourConf->globals.mainQ.iMainMsgQPersistUpdCnt);
+ setQPROP(qqueueSetbSyncQueueFiles, "$MainMsgQueueSyncQueueFiles", ourConf->globals.mainQ.bMainMsgQSyncQeueFiles);
+ setQPROP(qqueueSettoQShutdown, "$MainMsgQueueTimeoutShutdown", ourConf->globals.mainQ.iMainMsgQtoQShutdown );
+ setQPROP(qqueueSettoActShutdown, "$MainMsgQueueTimeoutActionCompletion", ourConf->globals.mainQ.iMainMsgQtoActShutdown);
+ setQPROP(qqueueSettoWrkShutdown, "$MainMsgQueueWorkerTimeoutThreadShutdown", ourConf->globals.mainQ.iMainMsgQtoWrkShutdown);
+ setQPROP(qqueueSettoEnq, "$MainMsgQueueTimeoutEnqueue", ourConf->globals.mainQ.iMainMsgQtoEnq);
+ setQPROP(qqueueSetiHighWtrMrk, "$MainMsgQueueHighWaterMark", ourConf->globals.mainQ.iMainMsgQHighWtrMark);
+ setQPROP(qqueueSetiLowWtrMrk, "$MainMsgQueueLowWaterMark", ourConf->globals.mainQ.iMainMsgQLowWtrMark);
+ setQPROP(qqueueSetiDiscardMrk, "$MainMsgQueueDiscardMark", ourConf->globals.mainQ.iMainMsgQDiscardMark);
+ setQPROP(qqueueSetiDiscardSeverity, "$MainMsgQueueDiscardSeverity", ourConf->globals.mainQ.iMainMsgQDiscardSeverity);
+ setQPROP(qqueueSetiMinMsgsPerWrkr, "$MainMsgQueueWorkerThreadMinimumMessages", ourConf->globals.mainQ.iMainMsgQWrkMinMsgs);
+ setQPROP(qqueueSetbSaveOnShutdown, "$MainMsgQueueSaveOnShutdown", ourConf->globals.mainQ.bMainMsgQSaveOnShutdown);
+ setQPROP(qqueueSetiDeqSlowdown, "$MainMsgQueueDequeueSlowdown", ourConf->globals.mainQ.iMainMsgQDeqSlowdown);
+ setQPROP(qqueueSetiDeqtWinFromHr, "$MainMsgQueueDequeueTimeBegin", ourConf->globals.mainQ.iMainMsgQueueDeqtWinFromHr);
+ setQPROP(qqueueSetiDeqtWinToHr, "$MainMsgQueueDequeueTimeEnd", ourConf->globals.mainQ.iMainMsgQueueDeqtWinToHr);
# undef setQPROP
# undef setQPROPstr