From 0f6300f1e6a038f37c406b2362218ea043def55b Mon Sep 17 00:00:00 2001 From: Georgi Georgiev Date: Tue, 13 Nov 2012 09:40:32 +0900 Subject: Silently ignore wildcard includes that match nothing This will avoid an error message when including an empty directory. --- grammar/rainerscript.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/grammar/rainerscript.c b/grammar/rainerscript.c index 39ff6df3..e54c9060 100644 --- a/grammar/rainerscript.c +++ b/grammar/rainerscript.c @@ -2778,8 +2778,15 @@ cnfDoInclude(char *name) } } /* Use GLOB_MARK to append a trailing slash for directories. */ - result = glob(finalName, GLOB_MARK, NULL, &cfgFiles); - if(result == GLOB_NOSPACE || result == GLOB_ABORTED || cfgFiles.gl_pathc == 0) { + /* Use GLOB_NOMAGIC to detect wildcards that match nothing. */ + result = glob(finalName, GLOB_MARK | GLOB_NOMAGIC, NULL, &cfgFiles); + + /* Silently ignore wildcards that match nothing */ + if(result == GLOB_NOMATCH) { + return 1; + } + + if(result == GLOB_NOSPACE || result == GLOB_ABORTED) { char errStr[1024]; rs_strerror_r(errno, errStr, sizeof(errStr)); parser_errmsg("error accessing config file or directory '%s': %s", @@ -2790,8 +2797,13 @@ cnfDoInclude(char *name) for(i = 0; i < cfgFiles.gl_pathc; i++) { cfgFile = cfgFiles.gl_pathv[i]; - if(stat(cfgFile, &fileInfo) != 0) - continue; /* continue with the next file if we can't stat() the file */ + if(stat(cfgFile, &fileInfo) != 0) + { + char errStr[1024]; + rs_strerror_r(errno, errStr, sizeof(errStr)); + parser_errmsg("error accessing config file or directory '%s': %s", + cfgFile, errStr); + } if(S_ISREG(fileInfo.st_mode)) { /* config file */ dbgprintf("requested to include config file '%s'\n", cfgFile); -- cgit v1.2.3 From 1d10872062828aede81c775bf19023f3ca8f85fa Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Wed, 14 Nov 2012 08:49:57 +0100 Subject: make sure inaccessible config file is not tried to be processed The processing loop was not terminated when an unaccessible file was detected, and so processing was done using unitialized data, which could lead to all sorts of problems. Also did some minor cleanup. --- grammar/rainerscript.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/grammar/rainerscript.c b/grammar/rainerscript.c index e54c9060..27ff5376 100644 --- a/grammar/rainerscript.c +++ b/grammar/rainerscript.c @@ -2777,6 +2777,7 @@ cnfDoInclude(char *name) finalName = nameBuf; } } + /* Use GLOB_MARK to append a trailing slash for directories. */ /* Use GLOB_NOMAGIC to detect wildcards that match nothing. */ result = glob(finalName, GLOB_MARK | GLOB_NOMAGIC, NULL, &cfgFiles); @@ -2796,13 +2797,12 @@ cnfDoInclude(char *name) for(i = 0; i < cfgFiles.gl_pathc; i++) { cfgFile = cfgFiles.gl_pathv[i]; - - if(stat(cfgFile, &fileInfo) != 0) - { + if(stat(cfgFile, &fileInfo) != 0) { char errStr[1024]; rs_strerror_r(errno, errStr, sizeof(errStr)); parser_errmsg("error accessing config file or directory '%s': %s", cfgFile, errStr); + continue; } if(S_ISREG(fileInfo.st_mode)) { /* config file */ -- cgit v1.2.3 From 0aa6afbc501611e2e0d0453b15e901344dfa6157 Mon Sep 17 00:00:00 2001 From: Georgi Georgiev Date: Sat, 10 Nov 2012 00:03:53 +0900 Subject: Fix the rsyslogd man page formatting for the -d flag The indentation around the "-d" flag description is in the wrong place and does not display properly. --- tools/rsyslogd.8 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/rsyslogd.8 b/tools/rsyslogd.8 index 9ded4b9b..620006f2 100644 --- a/tools/rsyslogd.8 +++ b/tools/rsyslogd.8 @@ -128,8 +128,8 @@ may not support it. .B "\-D" Runs the Bison config parser in debug mode. This may help when hard to find syntax errors are reported. Please note that the output generated is deeply -.TP technical and orignally targeted towards developers. +.TP .B "\-d" Turns on debug mode. Using this the daemon will not proceed a .BR fork (2) -- cgit v1.2.3 From 9c62c6b227bd98f6d26610ce0461124518731d0f Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Wed, 14 Nov 2012 09:21:24 +0100 Subject: bugfix: make rsyslog compile on kfreebsd again closes: http://bugzilla.adiscon.com/show_bug.cgi?id=380 --- ChangeLog | 3 +++ configure.ac | 2 +- plugins/imkmsg/kmsg.c | 2 ++ runtime/msg.c | 4 ++-- 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index b79ea79a..d794bdb2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -27,6 +27,9 @@ Version 7.2.2 [v7-stable] 2012-10-?? closes: http://bugzilla.adiscon.com/show_bug.cgi?id=376 The testbench was also enhanced to check for these cases. Thanks to Georgi Georgiev for the bug report. +- bugfix: make rsyslog compile on kfreebsd again + closes: http://bugzilla.adiscon.com/show_bug.cgi?id=380 + Thanks to Guillem Jover for the patch. ---------------------------------------------------------------------------- Version 7.2.1 [v7-stable] 2012-10-29 - bugfix: ruleset()-object did only support a single statement diff --git a/configure.ac b/configure.ac index 270eca5f..91571719 100644 --- a/configure.ac +++ b/configure.ac @@ -114,7 +114,7 @@ AC_TYPE_SIGNAL AC_FUNC_STAT AC_FUNC_STRERROR_R AC_FUNC_VPRINTF -AC_CHECK_FUNCS([flock basename alarm clock_gettime gethostbyname gethostname gettimeofday localtime_r memset mkdir regcomp select setid socket strcasecmp strchr strdup strerror strndup strnlen strrchr strstr strtol strtoul uname ttyname_r getline malloc_trim prctl epoll_create epoll_create1 fdatasync lseek64]) +AC_CHECK_FUNCS([flock basename alarm clock_gettime gethostbyname gethostname gettimeofday localtime_r memset mkdir regcomp select setid socket strcasecmp strchr strdup strerror strndup strnlen strrchr strstr strtol strtoul sysinfo uname ttyname_r getline malloc_trim prctl epoll_create epoll_create1 fdatasync lseek64]) # the check below is probably ugly. If someone knows how to do it in a better way, please # let me know! -- rgerhards, 2010-10-06 diff --git a/plugins/imkmsg/kmsg.c b/plugins/imkmsg/kmsg.c index 9ad98da4..b771d68a 100644 --- a/plugins/imkmsg/kmsg.c +++ b/plugins/imkmsg/kmsg.c @@ -32,7 +32,9 @@ #include #include #include +#ifdef OS_LINUX #include +#endif #include #include "rsyslog.h" diff --git a/runtime/msg.c b/runtime/msg.c index 1318de22..b627cd59 100644 --- a/runtime/msg.c +++ b/runtime/msg.c @@ -2883,8 +2883,8 @@ uchar *MsgGetProp(msg_t *pMsg, struct templateEntry *pTpe, *pbMustBeFreed = 0; break; case PROP_SYS_UPTIME: -# ifdef OS_SOLARIS - pRes = (uchar*) "UPTIME NOT available under Solaris"; +# ifndef HAVE_SYSINFO + pRes = (uchar*) "UPTIME NOT available on this system"; *pbMustBeFreed = 0; # else { -- cgit v1.2.3 From ec60ec8496b4e445f07fa4a9e21eb0c8f4506c7f Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Wed, 14 Nov 2012 09:43:56 +0100 Subject: bugfix: very small memory leak in imrelp This is not a real problem (thus no ChangeLog entry): we leaked a few bytes for every relp listener, but only at rsyslogd TERMINATION - where obviously the OS does the cleanup. However, the leak could cause some confusion with memory checkers like valgrind. --- plugins/imrelp/imrelp.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/plugins/imrelp/imrelp.c b/plugins/imrelp/imrelp.c index fe987a50..5ee3b4b9 100644 --- a/plugins/imrelp/imrelp.c +++ b/plugins/imrelp/imrelp.c @@ -303,7 +303,14 @@ ENDactivateCnf BEGINfreeCnf + instanceConf_t *inst, *del; CODESTARTfreeCnf + for(inst = pModConf->root ; inst != NULL ; ) { + free(inst->pszBindPort); + del = inst; + inst = inst->next; + free(del); + } ENDfreeCnf /* This is used to terminate the plugin. Note that the signal handler blocks -- cgit v1.2.3 From 9f3657ac8e8d9a69a435b94e31a9a0e05c0e0999 Mon Sep 17 00:00:00 2001 From: "bjarniig@rhi.hi.is" Date: Wed, 14 Nov 2012 10:54:05 +0100 Subject: bugfix: invalid formatting of man page --- tools/rsyslog.conf.5 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/rsyslog.conf.5 b/tools/rsyslog.conf.5 index 641ba9ba..fe9e083b 100644 --- a/tools/rsyslog.conf.5 +++ b/tools/rsyslog.conf.5 @@ -415,7 +415,7 @@ To escape: .sp 0 \\ = \\\\ --> '\\' is used to escape (as in C) .sp 0 -$template TraditionalFormat,"%timegenerated% %HOSTNAME% %syslogtag%%msg%\n" +$template TraditionalFormat,"%timegenerated% %HOSTNAME% %syslogtag%%msg%\\n" Properties can be accessed by the property replacer (see there for details). @@ -487,7 +487,7 @@ A template that resembles traditional syslogd file output: .RS $template TraditionalFormat,"%timegenerated% %HOSTNAME% .sp 0 -%syslogtag%%msg:::drop-last-lf%\n" +%syslogtag%%msg:::drop-last-lf%\\n" .RE A template that tells you a little more about the message: @@ -495,7 +495,7 @@ A template that tells you a little more about the message: .RS $template precise,"%syslogpriority%,%syslogfacility%,%timegenerated%,%HOSTNAME%, .sp 0 -%syslogtag%,%msg%\n" +%syslogtag%,%msg%\\n" .RE A template for RFC 3164 format: @@ -507,7 +507,7 @@ $template RFC3164fmt,"<%PRI%>%TIMESTAMP% %HOSTNAME% %syslogtag%%msg%" A template for the format traditionally used for user messages: .sp .RS -$template usermsg," XXXX%syslogtag%%msg%\n\r" +$template usermsg," XXXX%syslogtag%%msg%\\n\\r" .RE And a template with the traditional wall-message format: -- cgit v1.2.3 From 98d4437d0e5950118e5dd09fda0bf45e85512bfd Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Wed, 14 Nov 2012 11:07:35 +0100 Subject: doc: describe leading space problem with "startswith" comparison --- ChangeLog | 1 + doc/rsyslog_conf_filter.html | 11 ++++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index d794bdb2..cf633a6d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,6 @@ ---------------------------------------------------------------------------- Version 7.2.2 [v7-stable] 2012-10-?? +- doc improvements - enabled to build without libuuid, at loss of uuid functionality this enables smoother builds on older systems that do not support libuuid. Loss of functionality should usually not matter too much as diff --git a/doc/rsyslog_conf_filter.html b/doc/rsyslog_conf_filter.html index 3efa3967..a795193f 100644 --- a/doc/rsyslog_conf_filter.html +++ b/doc/rsyslog_conf_filter.html @@ -197,9 +197,14 @@ of the property value. For example, if you search for "val" with

it will be a match if msg contains "values are in this message" but it won't match if the msg contains "There are values in this message" (in the later case, contains would match). Please note -that "startswith" is by far faster than regular expressions. So even -once they are implemented, it can make very much sense -(performance-wise) to use "startswith".

+that "startswith" is by far faster than regular expressions. So +it makes very much sense (performance-wise) to use "startswith".

+

Note: when processing syslog messages, please note that $msg usually +starts with a space. The reason for this is RFC3164. Please read the +detail +description of what that means to you. In short, you need to make sure +that you include the first space if you use "startswith", otherwise you will +not get matches. -- cgit v1.2.3 From 05eb0a5052c5d679269ef33cfe07bd4394833a63 Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Wed, 14 Nov 2012 12:16:24 +0100 Subject: silence compiler warnings & some cleanup --- plugins/mmaudit/mmaudit.c | 6 +----- runtime/module-template.h | 3 ++- runtime/queue.c | 2 +- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/plugins/mmaudit/mmaudit.c b/plugins/mmaudit/mmaudit.c index 4934312b..018e1771 100644 --- a/plugins/mmaudit/mmaudit.c +++ b/plugins/mmaudit/mmaudit.c @@ -67,12 +67,8 @@ DEFobjCurrIf(errmsg); DEF_OMOD_STATIC_DATA typedef struct _instanceData { -} instanceData; - -typedef struct configSettings_s { int dummy; /* remove when the first real parameter is needed */ -} configSettings_t; -static configSettings_t cs; +} instanceData; BEGINinitConfVars /* (re)set config variables to default values */ CODESTARTinitConfVars diff --git a/runtime/module-template.h b/runtime/module-template.h index 9dd759a5..72a139c4 100644 --- a/runtime/module-template.h +++ b/runtime/module-template.h @@ -246,7 +246,8 @@ static rsRetVal dbgPrintInstInfo(void *pModData)\ instanceData *pData = NULL; #define CODESTARTdbgPrintInstInfo \ - pData = (instanceData*) pModData; + pData = (instanceData*) pModData; \ + (void)pData; /* prevent compiler warning if unused! */ #define ENDdbgPrintInstInfo \ RETiRet;\ diff --git a/runtime/queue.c b/runtime/queue.c index 0cd33701..fbf77108 100644 --- a/runtime/queue.c +++ b/runtime/queue.c @@ -127,7 +127,7 @@ static struct cnfparamblk pblk = }; /* debug aid */ -static void displayBatchState(batch_t *pBatch) +static inline void displayBatchState(batch_t *pBatch) { int i; for(i = 0 ; i < pBatch->nElem ; ++i) { -- cgit v1.2.3 From 25a33416e9597087e16483859ecbdd6cdac2df64 Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Wed, 14 Nov 2012 15:21:42 +0100 Subject: bugfix: garbled message if field name was used with jsonf property option The length for the field name was invalidly computed, resulting in either truncated field names or including extra random data. If the random data contained NULs, the rest of the message became unreadable. closes: http://bugzilla.adiscon.com/show_bug.cgi?id=374 --- ChangeLog | 7 ++++++- template.c | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index cf633a6d..0d948b3e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -20,7 +20,7 @@ Version 7.2.2 [v7-stable] 2012-10-?? This could happen in RainerScript comparisons (like contains); in some cases an unitialized variable was accessed, which could lead to an invalid free and in turn to a segfault. - Closes: http://bugzilla.adiscon.com/show_bug.cgi?id=372 + closes: http://bugzilla.adiscon.com/show_bug.cgi?id=372 Thanks to Georgi Georgiev for reporting this bug and his great help in solving it. - bugfix: no error msg on unreadable $IncludeConfig path @@ -31,6 +31,11 @@ Version 7.2.2 [v7-stable] 2012-10-?? - bugfix: make rsyslog compile on kfreebsd again closes: http://bugzilla.adiscon.com/show_bug.cgi?id=380 Thanks to Guillem Jover for the patch. +- bugfix: garbled message if field name was used with jsonf property option + The length for the field name was invalidly computed, resulting in either + truncated field names or including extra random data. If the random data + contained NULs, the rest of the message became unreadable. + closes: http://bugzilla.adiscon.com/show_bug.cgi?id=374 ---------------------------------------------------------------------------- Version 7.2.1 [v7-stable] 2012-10-29 - bugfix: ruleset()-object did only support a single statement diff --git a/template.c b/template.c index 9c24f2a9..1b8b2187 100644 --- a/template.c +++ b/template.c @@ -1096,7 +1096,7 @@ static int do_Parameter(unsigned char **pp, struct template *pTpl) } } else { pTpe->fieldName = ustrdup(cstrGetSzStrNoNULL(pStrField)); - pTpe->lenFieldName = cstrLen(pStrProp); + pTpe->lenFieldName = ustrlen(pTpe->fieldName); cstrDestruct(&pStrField); } if(pTpe->fieldName == NULL) -- cgit v1.2.3 From c0f5dd3fbf877799ac8fec4d00b2f2c69014b413 Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Wed, 14 Nov 2012 17:21:50 +0100 Subject: bugfix: potential segfault at startup with property-based filter If the property name was followed by a space before the comma, rsyslogd aborted on startup. Note that no segfault could happen if the initial startup went well (this was a problem with the config parser). closes: http://bugzilla.adiscon.com/show_bug.cgi?id=381 --- ChangeLog | 5 +++++ parse.c | 2 +- runtime/stringbuf.c | 4 +++- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0d948b3e..077e2b6f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -36,6 +36,11 @@ Version 7.2.2 [v7-stable] 2012-10-?? truncated field names or including extra random data. If the random data contained NULs, the rest of the message became unreadable. closes: http://bugzilla.adiscon.com/show_bug.cgi?id=374 +- bugfix: potential segfault at startup with property-based filter + If the property name was followed by a space before the comma, rsyslogd + aborted on startup. Note that no segfault could happen if the initial + startup went well (this was a problem with the config parser). + closes: http://bugzilla.adiscon.com/show_bug.cgi?id=381 ---------------------------------------------------------------------------- Version 7.2.1 [v7-stable] 2012-10-29 - bugfix: ruleset()-object did only support a single statement diff --git a/parse.c b/parse.c index 2d89030e..097e7470 100644 --- a/parse.c +++ b/parse.c @@ -262,7 +262,7 @@ rsRetVal parsDelimCStr(rsParsObj *pThis, cstr_t **ppCStr, char cDelim, int bTrim pC = rsCStrGetBufBeg(pThis->pCStr) + pThis->iCurrPos; - while(pThis->iCurrPos < rsCStrLen(pThis->pCStr) && *pC != cDelim && *pC != ' ') { + while(pThis->iCurrPos < rsCStrLen(pThis->pCStr) && *pC != cDelim) { CHKiRet(cstrAppendChar(pCStr, bConvLower ? tolower(*pC) : *pC)); ++pThis->iCurrPos; ++pC; diff --git a/runtime/stringbuf.c b/runtime/stringbuf.c index e7fd72c2..5bca009d 100644 --- a/runtime/stringbuf.c +++ b/runtime/stringbuf.c @@ -482,6 +482,8 @@ rsRetVal cstrTrimTrailingWhiteSpace(cstr_t *pThis) register uchar *pC; rsCHECKVALIDOBJECT(pThis, OIDrsCStr); + if(pThis->iStrLen == 0) + goto done; /* empty string -> nothing to trim ;) */ i = pThis->iStrLen; pC = pThis->pBuf + i - 1; while(i > 0 && isspace((int)*pC)) { @@ -492,7 +494,7 @@ rsRetVal cstrTrimTrailingWhiteSpace(cstr_t *pThis) pThis->iStrLen = i; pThis->pBuf[pThis->iStrLen] = '0'; /* we always have this space */ - return RS_RET_OK; +done: return RS_RET_OK; } /* compare two string objects - works like strcmp(), but operates -- cgit v1.2.3