summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2009-06-16 12:31:27 +0200
committerRainer Gerhards <rgerhards@adiscon.com>2009-06-16 12:31:27 +0200
commit74b2b24f508be90d20961304d5e3cce648f3eb7c (patch)
treeb2575e22c7b6b0ced97b125c7e67417a6bbb92e6
parentf7579e68a67364c8040966be57c2eae4c9550ee5 (diff)
downloadrsyslog-74b2b24f508be90d20961304d5e3cce648f3eb7c.tar.gz
rsyslog-74b2b24f508be90d20961304d5e3cce648f3eb7c.tar.xz
rsyslog-74b2b24f508be90d20961304d5e3cce648f3eb7c.zip
removed long-obsoleted property UxTradMsg
... as well as some cleanup (some commented-out code is left to support UxTradMsg again is someone really complains ;)).
-rw-r--r--ChangeLog1
-rw-r--r--doc/property_replacer.html4
-rw-r--r--plugins/imfile/imfile.c1
-rw-r--r--plugins/imklog/imklog.c2
-rw-r--r--runtime/msg.c100
-rw-r--r--runtime/msg.h9
-rw-r--r--runtime/parser.c2
-rw-r--r--tools/syslogd.c23
8 files changed, 65 insertions, 77 deletions
diff --git a/ChangeLog b/ChangeLog
index f9e3e32b..beed5663 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,6 @@
---------------------------------------------------------------------------
Version 4.3.2 [DEVEL] (rgerhards), 2009-??-??
+- removed long-obsoleted property UxTradMsg
- added a generic network stream server (in addition to rather specific
syslog tcp server)
- added ability for the UDP output action to rebind its send socket after
diff --git a/doc/property_replacer.html b/doc/property_replacer.html
index a6e9b518..7b604ea0 100644
--- a/doc/property_replacer.html
+++ b/doc/property_replacer.html
@@ -30,10 +30,6 @@ Currently supported are:</p>
socket. Should be useful for debugging.</td>
</tr>
<tr>
-<td><b>uxtradmsg</b></td>
-<td>will disappear soon - do NOT use!</td>
-</tr>
-<tr>
<td><b>hostname</b></td>
<td>hostname from the message</td>
</tr>
diff --git a/plugins/imfile/imfile.c b/plugins/imfile/imfile.c
index e3882ce5..927cb82e 100644
--- a/plugins/imfile/imfile.c
+++ b/plugins/imfile/imfile.c
@@ -96,7 +96,6 @@ static rsRetVal enqLine(fileInfo_t *pInfo, cstr_t *cstrLine)
CHKiRet(msgConstruct(&pMsg));
MsgSetFlowControlType(pMsg, eFLOWCTL_FULL_DELAY);
MsgSetInputName(pMsg, UCHAR_CONSTANT("imfile"), sizeof("imfile")-1);
- MsgSetUxTradMsg(pMsg, (char*)rsCStrGetSzStr(cstrLine));
MsgSetRawMsg(pMsg, (char*)rsCStrGetSzStr(cstrLine));
MsgSetMSG(pMsg, (char*)rsCStrGetSzStr(cstrLine));
MsgSetHOSTNAME(pMsg, glbl.GetLocalHostName());
diff --git a/plugins/imklog/imklog.c b/plugins/imklog/imklog.c
index 45933436..420ebbf1 100644
--- a/plugins/imklog/imklog.c
+++ b/plugins/imklog/imklog.c
@@ -97,8 +97,6 @@ enqMsg(uchar *msg, uchar* pszTag, int iFacility, int iSeverity)
MsgSetFlowControlType(pMsg, eFLOWCTL_LIGHT_DELAY);
MsgSetInputName(pMsg, UCHAR_CONSTANT("imklog"), sizeof("imklog")-1);
MsgSetRawMsg(pMsg, (char*)msg);
- MsgSetUxTradMsg(pMsg, (char*)msg);
- MsgSetRawMsg(pMsg, (char*)msg);
MsgSetMSG(pMsg, (char*)msg);
MsgSetRcvFrom(pMsg, glbl.GetLocalHostName());
MsgSetRcvFromIP(pMsg, (uchar*)"127.0.0.1");
diff --git a/runtime/msg.c b/runtime/msg.c
index 55cc48b8..8122383a 100644
--- a/runtime/msg.c
+++ b/runtime/msg.c
@@ -343,7 +343,6 @@ CODESTARTobjDestruct(msg)
if(currRefCount == 0)
{
/* DEV Debugging Only! dbgprintf("msgDestruct\t0x%lx, RefCount now 0, doing DESTROY\n", (unsigned long)pThis); */
- free(pThis->pszUxTradMsg);
free(pThis->pszRawMsg);
free(pThis->pszTAG);
free(pThis->pszHOSTNAME);
@@ -437,6 +436,10 @@ msg_t* MsgDup(msg_t* pOld)
pNew->msgFlags = pOld->msgFlags;
pNew->iProtocolVersion = pOld->iProtocolVersion;
pNew->ttGenTime = pOld->ttGenTime;
+ /* enable this, if someone actually uses UxTradMsg, delete after some time has
+ * passed and nobody complained -- rgerhards, 2009-06-16
+ pNew->offAfterPRI = pOld->offAfterPRI;
+ */
memcpy(pNew->bufPRI, pOld->bufPRI, pOld->iLenPRI);
pNew->iLenPRI = pOld->iLenPRI;
tmpCOPYSZ(Severity);
@@ -445,7 +448,6 @@ msg_t* MsgDup(msg_t* pOld)
tmpCOPYSZ(FacilityStr);
tmpCOPYSZ(RawMsg);
tmpCOPYSZ(MSG);
- tmpCOPYSZ(UxTradMsg);
tmpCOPYSZ(TAG);
tmpCOPYSZ(HOSTNAME);
tmpCOPYSZ(RcvFrom);
@@ -494,10 +496,13 @@ static rsRetVal MsgSerialize(msg_t *pThis, strm_t *pStrm)
objSerializeSCALAR(pStrm, ttGenTime, INT);
objSerializeSCALAR(pStrm, tRcvdAt, SYSLOGTIME);
objSerializeSCALAR(pStrm, tTIMESTAMP, SYSLOGTIME);
+ /* enable this, if someone actually uses UxTradMsg, delete after some time has
+ * passed and nobody complained -- rgerhards, 2009-06-16
+ objSerializeSCALAR(pStrm, offsAfterPRI, SHORT);
+ */
objSerializePTR(pStrm, pszRawMsg, PSZ);
objSerializePTR(pStrm, pszMSG, PSZ);
- objSerializePTR(pStrm, pszUxTradMsg, PSZ);
objSerializePTR(pStrm, pszTAG, PSZ);
objSerializePTR(pStrm, pszHOSTNAME, PSZ);
objSerializePTR(pStrm, pszInputName, PSZ);
@@ -701,16 +706,17 @@ static char *getRawMsg(msg_t *pM)
return (char*)pM->pszRawMsg;
}
+
+/* enable this, if someone actually uses UxTradMsg, delete after some time has
+ * passed and nobody complained -- rgerhards, 2009-06-16
char *getUxTradMsg(msg_t *pM)
{
if(pM == NULL)
return "";
else
- if(pM->pszUxTradMsg == NULL)
- return "";
- else
- return (char*)pM->pszUxTradMsg;
+ return (char*)pM->pszRawMsg + pM->offAfterPRI;
}
+*/
char *getMSG(msg_t *pM)
{
@@ -724,21 +730,30 @@ char *getMSG(msg_t *pM)
}
+/* Get PRI value as integer */
+static int getPRIi(msg_t *pM)
+{
+ assert(pM != NULL);
+ return (pM->iFacility << 3) + (pM->iSeverity);
+}
+
+
/* Get PRI value in text form */
static inline char *getPRI(msg_t *pM)
{
if(pM == NULL)
return "";
- return (char*)pM->bufPRI;
-}
-
+ /* there are some cases where bufPRI may not contain a valid string,
+ * and then we need to build it.
+ */
+ MsgLock(pM);
+ if(pM->bufPRI[0] == '\0') {
+ snprintf((char*)pM->bufPRI, sizeof(pM->bufPRI), "<%d>", getPRIi(pM));
+ }
+ MsgUnlock(pM);
-/* Get PRI value as integer */
-static int getPRIi(msg_t *pM)
-{
- assert(pM != NULL);
- return (pM->iFacility << 3) + (pM->iSeverity);
+ return (char*)pM->bufPRI;
}
@@ -1017,6 +1032,17 @@ MsgSetFlowControlType(msg_t *pMsg, flowControl_t eFlowCtl)
RETiRet;
}
+/* set offset after which PRI in raw msg starts
+ * rgerhards, 2009-06-16
+ */
+rsRetVal
+MsgSetAfterPRIOffs(msg_t *pMsg, short offs)
+{
+ assert(pMsg != NULL);
+ pMsg->offAfterPRI = offs;
+ return RS_RET_OK;
+}
+
/* rgerhards 2004-11-24: set APP-NAME in msg object
* TODO: revisit msg locking code!
@@ -1520,40 +1546,6 @@ void MsgSetHOSTNAME(msg_t *pMsg, uchar* pszHOSTNAME)
}
-/* Set the UxTradMsg to a caller-provided string. This is thought
- * to be a heap buffer that the caller will no longer use. This
- * function is a performance optimization over MsgSetUxTradMsg().
- * rgerhards 2004-11-19
- */
-#if 0 /* This method is currently not called, be we like to preserve it */
-static void MsgAssignUxTradMsg(msg_t *pMsg, char *pBuf)
-{
- assert(pMsg != NULL);
- assert(pBuf != NULL);
- pMsg->iLenUxTradMsg = strlen(pBuf);
- pMsg->pszUxTradMsg = pBuf;
-}
-#endif
-
-
-/* rgerhards 2004-11-17: set the traditional Unix message in msg object
- */
-int MsgSetUxTradMsg(msg_t *pMsg, char* pszUxTradMsg)
-{
- assert(pMsg != NULL);
- assert(pszUxTradMsg != NULL);
- pMsg->iLenUxTradMsg = strlen(pszUxTradMsg);
- if(pMsg->pszUxTradMsg != NULL)
- free(pMsg->pszUxTradMsg);
- if((pMsg->pszUxTradMsg = malloc(pMsg->iLenUxTradMsg + 1)) != NULL)
- memcpy(pMsg->pszUxTradMsg, pszUxTradMsg, pMsg->iLenUxTradMsg + 1);
- else
- dbgprintf("Could not allocate memory for pszUxTradMsg buffer.");
-
- return(0);
-}
-
-
/* rgerhards 2004-11-09: set MSG in msg object
*/
void MsgSetMSG(msg_t *pMsg, char* pszMSG)
@@ -1732,8 +1724,11 @@ char *MsgGetProp(msg_t *pMsg, struct templateEntry *pTpe,
pRes = getMSG(pMsg);
} else if(!strcmp((char*) pName, "rawmsg")) {
pRes = getRawMsg(pMsg);
+ /* enable this, if someone actually uses UxTradMsg, delete after some time has
+ * passed and nobody complained -- rgerhards, 2009-06-16
} else if(!strcmp((char*) pName, "uxtradmsg")) {
pRes = getUxTradMsg(pMsg);
+ */
} else if(!strcmp((char*) pName, "inputname")) {
pRes = (char*) getInputName(pMsg);
} else if(!strcmp((char*) pName, "fromhost")) {
@@ -2457,10 +2452,15 @@ rsRetVal MsgSetProperty(msg_t *pThis, var_t *pProp)
pThis->msgFlags = pProp->val.num;
} else if(isProp("pszRawMsg")) {
MsgSetRawMsg(pThis, (char*) rsCStrGetSzStrNoNULL(pProp->val.pStr));
+ /* enable this, if someone actually uses UxTradMsg, delete after some time has
+ * passed and nobody complained -- rgerhards, 2009-06-16
+ } else if(isProp("offAfterPRI")) {
+ pThis->offAfterPRI = pProp->val.num;
+ */
} else if(isProp("pszMSG")) {
MsgSetMSG(pThis, (char*) rsCStrGetSzStrNoNULL(pProp->val.pStr));
} else if(isProp("pszUxTradMsg")) {
- MsgSetUxTradMsg(pThis, (char*) rsCStrGetSzStrNoNULL(pProp->val.pStr));
+ /*IGNORE*/; /* this *was* a property, but does no longer exist */
} else if(isProp("pszTAG")) {
MsgSetTAG(pThis, (char*) rsCStrGetSzStrNoNULL(pProp->val.pStr));
} else if(isProp("pszInputName")) {
diff --git a/runtime/msg.h b/runtime/msg.h
index 20360641..fe9f87fa 100644
--- a/runtime/msg.h
+++ b/runtime/msg.h
@@ -51,7 +51,7 @@
struct msg {
BEGINobjInstance; /* Data to implement generic object - MUST be the first data element! */
pthread_mutexattr_t mutAttr;
-short bDoLock; /* use the mutex? */
+ bool bDoLock; /* use the mutex? */
pthread_mutex_t mut;
flowControl_t flowCtlType; /**< type of flow control we can apply, for enqueueing, needs not to be persisted because
once data has entered the queue, this property is no longer needed. */
@@ -73,13 +73,13 @@ short bDoLock; /* use the mutex? */
int iLenFacility; /* ... and its length. */
uchar *pszFacilityStr; /* facility name... */
int iLenFacilityStr; /* ... and its length. */
- //uchar *pszPRI; /* the PRI as a string */
- uchar bufPRI[5];
+ uchar bufPRI[5]; /* PRI as string */
int iLenPRI; /* and its length */
uchar *pszRawMsg; /* message as it was received on the
* wire. This is important in case we
* need to preserve cryptographic verifiers.
*/
+ short offAfterPRI; /* offset, at which raw message WITHOUT PRI part starts in pszRawMsg */
int iLenRawMsg; /* length of raw message */
uchar *pszMSG; /* the MSG part itself */
int iLenMSG; /* Length of the MSG part */
@@ -158,7 +158,7 @@ void MsgSetRcvFrom(msg_t *pMsg, uchar* pszRcvFrom);
rsRetVal MsgSetRcvFromIP(msg_t *pMsg, uchar* pszRcvFromIP);
void MsgAssignHOSTNAME(msg_t *pMsg, char *pBuf);
void MsgSetHOSTNAME(msg_t *pMsg, uchar* pszHOSTNAME);
-int MsgSetUxTradMsg(msg_t *pMsg, char* pszUxTradMsg);
+rsRetVal MsgSetAfterPRIOffs(msg_t *pMsg, short offs);
void MsgSetMSG(msg_t *pMsg, char* pszMSG);
void MsgSetRawMsg(msg_t *pMsg, char* pszRawMsg);
void moveHOSTNAMEtoTAG(msg_t *pM);
@@ -183,6 +183,7 @@ uchar *getRcvFrom(msg_t *pM);
#if 0
char *getUxTradMsg(msg_t *pM);
+int MsgSetUxTradMsg(msg_t *pMsg, char* pszUxTradMsg);
#endif
/* The MsgPrepareEnqueue() function is a macro for performance reasons.
diff --git a/runtime/parser.c b/runtime/parser.c
index 13fb51ec..0b45bfd5 100644
--- a/runtime/parser.c
+++ b/runtime/parser.c
@@ -314,7 +314,7 @@ rsRetVal parseMsg(msg_t *pMsg)
}
pMsg->iFacility = LOG_FAC(pri);
pMsg->iSeverity = LOG_PRI(pri);
- MsgSetUxTradMsg(pMsg, (char*) msg);
+ MsgSetAfterPRIOffs(pMsg, msg - pMsg->pszRawMsg);
if(pMsg->bParseHOSTNAME == 0)
MsgSetHOSTNAME(pMsg, pMsg->pszRcvFrom);
diff --git a/tools/syslogd.c b/tools/syslogd.c
index c224087d..2f06d273 100644
--- a/tools/syslogd.c
+++ b/tools/syslogd.c
@@ -670,16 +670,9 @@ static inline rsRetVal printline(uchar *hname, uchar *hnameIP, uchar *msg, int f
if((pMsg->msgFlags & PARSE_HOSTNAME) == 0)
MsgSetHOSTNAME(pMsg, hname);
MsgSetRcvFrom(pMsg, hname);
+ MsgSetAfterPRIOffs(pMsg, p - msg);
CHKiRet(MsgSetRcvFromIP(pMsg, hnameIP));
- /* rgerhards 2004-11-19: well, well... we've now seen that we
- * have the "hostname problem" also with the traditional Unix
- * message. As we like to emulate it, we need to add the hostname
- * to it.
- */
- if(MsgSetUxTradMsg(pMsg, (char*)p) != 0)
- ABORT_FINALIZE(RS_RET_ERR);
-
logmsg(pMsg, flags);
finalize_it:
@@ -948,7 +941,6 @@ logmsgInternal(int iErr, int pri, uchar *msg, int flags)
CHKiRet(msgConstruct(&pMsg));
MsgSetInputName(pMsg, UCHAR_CONSTANT("rsyslogd"), sizeof("rsyslogd")-1);
- MsgSetUxTradMsg(pMsg, (char*)msg);
MsgSetRawMsg(pMsg, (char*)msg);
MsgSetHOSTNAME(pMsg, glbl.GetLocalHostName());
MsgSetRcvFrom(pMsg, glbl.GetLocalHostName());
@@ -1370,8 +1362,8 @@ int parseRFCSyslogMsg(msg_t *pMsg, int flags)
BEGINfunc
assert(pMsg != NULL);
- assert(pMsg->pszUxTradMsg != NULL);
- p2parse = pMsg->pszUxTradMsg;
+ assert(pMsg->pszRawMsg != NULL);
+ p2parse = pMsg->pszRawMsg + pMsg->offAfterPRI; /* point to start of text, after PRI */
/* do a sanity check on the version and eat it */
assert(p2parse[0] == '1' && p2parse[1] == ' ');
@@ -1471,8 +1463,8 @@ int parseLegacySyslogMsg(msg_t *pMsg, int flags)
BEGINfunc
assert(pMsg != NULL);
- assert(pMsg->pszUxTradMsg != NULL);
- p2parse = pMsg->pszUxTradMsg;
+ assert(pMsg->pszRawMsg != NULL);
+ p2parse = pMsg->pszRawMsg + pMsg->offAfterPRI; /* point to start of text, after PRI */
/* Check to see if msg contains a timestamp. We start by assuming
* that the message timestamp is the time of reciption (which we
@@ -1685,8 +1677,9 @@ logmsg(msg_t *pMsg, int flags)
BEGINfunc
assert(pMsg != NULL);
- assert(pMsg->pszUxTradMsg != NULL);
- msg = (char*) pMsg->pszUxTradMsg;
+ assert(pMsg->pszRawMsg != NULL);
+
+ msg = (char*) pMsg->pszRawMsg + pMsg->offAfterPRI; /* point to start of text, after PRI */
DBGPRINTF("logmsg: flags %x, from '%s', msg %s\n", flags, getRcvFrom(pMsg), msg);
/* rger 2005-11-24 (happy thanksgiving!): we now need to check if we have