summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2010-03-09 09:15:14 +0100
committerRainer Gerhards <rgerhards@adiscon.com>2010-03-09 09:15:14 +0100
commitde7726cbf0957384cc9261ac47d6bf65906739b5 (patch)
tree1d3dd581d5c2382c01d3bf39130b368ae0cc64e2
parenta27c67a590a4a6186ac79326fa3abe4b95ab10fc (diff)
parentd97ad63e218112d7cd3a390854b2918407804976 (diff)
downloadrsyslog-de7726cbf0957384cc9261ac47d6bf65906739b5.tar.gz
rsyslog-de7726cbf0957384cc9261ac47d6bf65906739b5.tar.xz
rsyslog-de7726cbf0957384cc9261ac47d6bf65906739b5.zip
Merge branch 'v4-stable' into v5-stable
Conflicts: ChangeLog runtime/datetime.h
-rw-r--r--ChangeLog10
-rw-r--r--doc/property_replacer.html13
-rw-r--r--runtime/datetime.c8
-rw-r--r--runtime/datetime.h7
-rw-r--r--runtime/msg.c10
-rw-r--r--template.c2
-rw-r--r--template.h2
-rw-r--r--tests/Makefile.am2
-rwxr-xr-xtests/parsertest.sh4
-rw-r--r--tests/testsuites/parse-3164-buggyday.conf8
-rw-r--r--tests/testsuites/samples.parse-3164-buggyday6
11 files changed, 64 insertions, 8 deletions
diff --git a/ChangeLog b/ChangeLog
index 29549628..902d75ad 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,9 @@
---------------------------------------------------------------------------
+Version 5.4.1 [v5-stable] (rgerhards), 2010-03-??
+- added new property replacer option "date-rfc3164-buggyday" primarily
+ to ease migration from syslog-ng. See property replacer doc for
+ details. [backport from 5.5.3 because urgently needed by some]
+---------------------------------------------------------------------------
Version 5.4.0 [v5-stable] (rgerhards), 2010-03-08
***************************************************************************
* This is a new stable v5 version. It contains all fixes and enhancements *
@@ -336,6 +341,11 @@ Version 4.7.0 [v4-devel] (rgerhards), 2009-09-??
See ticket for details: http://bugzilla.adiscon.com/show_bug.cgi?id=150
- imported changes from 4.5.6 and below
---------------------------------------------------------------------------
+Version 4.6.2 [v4-stable] (rgerhards), 2010-03-??
+- added new property replacer option "date-rfc3164-buggyday" primarily
+ to ease migration from syslog-ng. See property replacer doc for
+ details. [backport from 5.5.3 because urgently needed by some]
+---------------------------------------------------------------------------
Version 4.6.1 [v4-stable] (rgerhards), 2010-03-04
- re-enabled old pipe output (using new module ompipe, built-in) after
some problems with pipes (and especially in regard to xconsole) were
diff --git a/doc/property_replacer.html b/doc/property_replacer.html
index 7b604ea0..4d242a34 100644
--- a/doc/property_replacer.html
+++ b/doc/property_replacer.html
@@ -335,6 +335,19 @@ Especially useful for PIX.</td>
<td>format as RFC 3164 date</td>
</tr>
<tr>
+<tr>
+<td valign="top"><b>date-rfc3164-buggyday</b></td>
+<td>similar to date-rfc3164, but emulates a common coding error: RFC 3164 demands
+that a space is written for single-digit days. With this option, a zero is
+written instead. This format seems to be used by syslog-ng and the
+date-rfc3164-buggyday option can be used in migration scenarios where otherwise
+lots of scripts would need to be adjusted. It is recommended <i>not</i> to use this
+option when forwarding to remote hosts - they may treat the date as invalid
+(especially when parsing strictly according to RFC 3164).</td>
+<br><i>This feature was introduced in rsyslog 4.6.2 and v4 versions above and
+5.5.3 and all versions above.</i>
+</tr>
+<tr>
<td><b>date-rfc3339</b></td>
<td>format as RFC 3339 date</td>
</tr>
diff --git a/runtime/datetime.c b/runtime/datetime.c
index 47d7ac0e..de26762d 100644
--- a/runtime/datetime.c
+++ b/runtime/datetime.c
@@ -811,8 +811,12 @@ int formatTimestamp3339(struct syslogTime *ts, char* pBuf)
* buffer that will receive the resulting string. The function
* returns the size of the timestamp written in bytes (without
* the string termnator). If 0 is returend, an error occured.
+ * rgerhards, 2010-03-05: Added support to for buggy 3164 dates,
+ * where a zero-digit is written instead of a space for the first
+ * day character if day < 10. syslog-ng seems to do that, and some
+ * parsing scripts (in migration cases) rely on that.
*/
-int formatTimestamp3164(struct syslogTime *ts, char* pBuf)
+int formatTimestamp3164(struct syslogTime *ts, char* pBuf, int bBuggyDay)
{
static char* monthNames[12] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
@@ -825,7 +829,7 @@ int formatTimestamp3164(struct syslogTime *ts, char* pBuf)
pBuf[2] = monthNames[(ts->month - 1) % 12][2];
pBuf[3] = ' ';
iDay = (ts->day / 10) % 10; /* we need to write a space if the first digit is 0 */
- pBuf[4] = iDay ? iDay + '0' : ' ';
+ pBuf[4] = (bBuggyDay || iDay > 0) ? iDay + '0' : ' ';
pBuf[5] = ts->day % 10 + '0';
pBuf[6] = ' ';
pBuf[7] = (ts->hour / 10) % 10 + '0';
diff --git a/runtime/datetime.h b/runtime/datetime.h
index 1de3db95..82bd415b 100644
--- a/runtime/datetime.h
+++ b/runtime/datetime.h
@@ -39,17 +39,20 @@ BEGINinterface(datetime) /* name must also be changed in ENDinterface macro! */
int (*formatTimestampToMySQL)(struct syslogTime *ts, char* pDst);
int (*formatTimestampToPgSQL)(struct syslogTime *ts, char *pDst);
int (*formatTimestamp3339)(struct syslogTime *ts, char* pBuf);
- int (*formatTimestamp3164)(struct syslogTime *ts, char* pBuf);
+ int (*formatTimestamp3164)(struct syslogTime *ts, char* pBuf, int);
int (*formatTimestampSecFrac)(struct syslogTime *ts, char* pBuf);
/* v3, 2009-11-12 */
time_t (*GetTime)(time_t *ttSeconds);
ENDinterface(datetime)
-#define datetimeCURR_IF_VERSION 3 /* increment whenever you change the interface structure! */
+#define datetimeCURR_IF_VERSION 5 /* increment whenever you change the interface structure! */
/* interface changes:
* 1 - initial version
* 2 - not compatible to 1 - bugfix required ParseTIMESTAMP3164 to accept char ** as
* last parameter. Did not try to remain compatible as this is not something any
* third-party module should call. -- rgerhards, 2008.-09-12
+ * 3 - taken by v5 branch!
+ * 4 - formatTimestamp3164 takes a third int parameter
+ * 5 - merge of versions 3 + 4 (2010-03-09)
*/
/* prototypes */
diff --git a/runtime/msg.c b/runtime/msg.c
index 2fd4cff7..21aa236d 100644
--- a/runtime/msg.c
+++ b/runtime/msg.c
@@ -1217,10 +1217,12 @@ static inline char *getTimeReported(msg_t *pM, enum tplFormatTypes eFmt)
switch(eFmt) {
case tplFmtDefault:
case tplFmtRFC3164Date:
+ case tplFmtRFC3164BuggyDate:
MsgLock(pM);
if(pM->pszTIMESTAMP3164 == NULL) {
pM->pszTIMESTAMP3164 = pM->pszTimestamp3164;
- datetime.formatTimestamp3164(&pM->tTIMESTAMP, pM->pszTIMESTAMP3164);
+ datetime.formatTimestamp3164(&pM->tTIMESTAMP, pM->pszTIMESTAMP3164,
+ (eFmt == tplFmtRFC3164BuggyDate));
}
MsgUnlock(pM);
return(pM->pszTIMESTAMP3164);
@@ -1283,7 +1285,7 @@ static inline char *getTimeGenerated(msg_t *pM, enum tplFormatTypes eFmt)
MsgUnlock(pM);
return "";
}
- datetime.formatTimestamp3164(&pM->tRcvdAt, pM->pszRcvdAt3164);
+ datetime.formatTimestamp3164(&pM->tRcvdAt, pM->pszRcvdAt3164, 0);
}
MsgUnlock(pM);
return(pM->pszRcvdAt3164);
@@ -1310,13 +1312,15 @@ static inline char *getTimeGenerated(msg_t *pM, enum tplFormatTypes eFmt)
MsgUnlock(pM);
return(pM->pszRcvdAt_PgSQL);
case tplFmtRFC3164Date:
+ case tplFmtRFC3164BuggyDate:
MsgLock(pM);
if(pM->pszRcvdAt3164 == NULL) {
if((pM->pszRcvdAt3164 = MALLOC(16)) == NULL) {
MsgUnlock(pM);
return "";
}
- datetime.formatTimestamp3164(&pM->tRcvdAt, pM->pszRcvdAt3164);
+ datetime.formatTimestamp3164(&pM->tRcvdAt, pM->pszRcvdAt3164,
+ (eFmt == tplFmtRFC3164BuggyDate));
}
MsgUnlock(pM);
return(pM->pszRcvdAt3164);
diff --git a/template.c b/template.c
index d74da475..050905b0 100644
--- a/template.c
+++ b/template.c
@@ -487,6 +487,8 @@ static void doOptions(unsigned char **pp, struct templateEntry *pTpe)
pTpe->data.field.eDateFormat = tplFmtPgSQLDate;
} else if(!strcmp((char*)Buf, "date-rfc3164")) {
pTpe->data.field.eDateFormat = tplFmtRFC3164Date;
+ } else if(!strcmp((char*)Buf, "date-rfc3164-buggyday")) {
+ pTpe->data.field.eDateFormat = tplFmtRFC3164BuggyDate;
} else if(!strcmp((char*)Buf, "date-rfc3339")) {
pTpe->data.field.eDateFormat = tplFmtRFC3339Date;
} else if(!strcmp((char*)Buf, "date-subseconds")) {
diff --git a/template.h b/template.h
index 271e8271..71e8b428 100644
--- a/template.h
+++ b/template.h
@@ -48,7 +48,7 @@ struct template {
enum EntryTypes { UNDEFINED = 0, CONSTANT = 1, FIELD = 2 };
enum tplFormatTypes { tplFmtDefault = 0, tplFmtMySQLDate = 1,
tplFmtRFC3164Date = 2, tplFmtRFC3339Date = 3, tplFmtPgSQLDate = 4,
- tplFmtSecFrac = 5};
+ tplFmtSecFrac = 5, tplFmtRFC3164BuggyDate = 6};
enum tplFormatCaseConvTypes { tplCaseConvNo = 0, tplCaseConvUpper = 1, tplCaseConvLower = 2 };
#include "msg.h"
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 61fc808e..a31a6f42 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -119,6 +119,8 @@ EXTRA_DIST= 1.rstest 2.rstest 3.rstest err1.rstest \
testsuites/reallife.parse3 \
testsuites/parse_invld_regex.conf \
testsuites/samples.parse_invld_regex \
+ testsuites/parse-3164-buggyday.conf \
+ testsuites/samples.parse-3164-buggyday \
testsuites/omod-if-array.conf \
testsuites/1.omod-if-array \
testsuites/1.field1 \
diff --git a/tests/parsertest.sh b/tests/parsertest.sh
index fb392db3..ea2334c2 100755
--- a/tests/parsertest.sh
+++ b/tests/parsertest.sh
@@ -8,6 +8,8 @@ source $srcdir/diag.sh nettester parse3 udp
source $srcdir/diag.sh nettester parse3 tcp
source $srcdir/diag.sh nettester parse_invld_regex udp
source $srcdir/diag.sh nettester parse_invld_regex tcp
+source $srcdir/diag.sh nettester parse-3164-buggyday udp
+source $srcdir/diag.sh nettester parse-3164-buggyday tcp
echo \[parsertest.sh]: redoing tests in IPv4-only mode
source $srcdir/diag.sh nettester parse1 udp -4
@@ -18,4 +20,6 @@ source $srcdir/diag.sh nettester parse3 udp -4
source $srcdir/diag.sh nettester parse3 tcp -4
source $srcdir/diag.sh nettester parse_invld_regex udp -4
source $srcdir/diag.sh nettester parse_invld_regex tcp -4
+source $srcdir/diag.sh nettester parse-3164-buggyday udp -4
+source $srcdir/diag.sh nettester parse-3164-buggyday tcp -4
source $srcdir/diag.sh exit
diff --git a/tests/testsuites/parse-3164-buggyday.conf b/tests/testsuites/parse-3164-buggyday.conf
new file mode 100644
index 00000000..937f423a
--- /dev/null
+++ b/tests/testsuites/parse-3164-buggyday.conf
@@ -0,0 +1,8 @@
+$ModLoad ../plugins/omstdout/.libs/omstdout
+$IncludeConfig nettest.input.conf # This picks the to be tested input from the test driver!
+
+$ErrorMessagesToStderr off
+
+# use a special format that we can easily parse in expect
+$template expect,"%PRI%,%syslogfacility-text%,%syslogseverity-text%,%timestamp:::date-rfc3164-buggyday%,%hostname%,%programname%,%syslogtag%,%msg%\n"
+*.* :omstdout:;expect
diff --git a/tests/testsuites/samples.parse-3164-buggyday b/tests/testsuites/samples.parse-3164-buggyday
new file mode 100644
index 00000000..e21df980
--- /dev/null
+++ b/tests/testsuites/samples.parse-3164-buggyday
@@ -0,0 +1,6 @@
+# in 3164-buggyday mode, we need to have a leading zero in front of the day
+<38> Mar 7 19:06:53 example tag: testmessage (only date actually tested)
+38,auth,info,Mar 07 19:06:53,example,tag,tag:, testmessage (only date actually tested)
+# and now one with a complete date:
+<38> Mar 17 19:06:53 example tag: testmessage (only date actually tested)
+38,auth,info,Mar 17 19:06:53,example,tag,tag:, testmessage (only date actually tested)