From d7755dd3dc5a653adff79a83b6115f872509b3d9 Mon Sep 17 00:00:00 2001 From: Cristiano Date: Tue, 2 Mar 2010 07:37:48 +0100 Subject: solved compile problems on FreeBSD 9.0 (those caused by utmpx.h) Signed-off-by: Rainer Gerhards --- tools/omusrmsg.c | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/tools/omusrmsg.c b/tools/omusrmsg.c index a89297d7..9279028c 100644 --- a/tools/omusrmsg.c +++ b/tools/omusrmsg.c @@ -52,8 +52,13 @@ #include #ifdef HAVE_UTMP_H # include +# define STRUCTUTMP struct utmp #else # include +# define _PATH_UTMP "/var/run/utx.active" +# define _PATH_WTMP "/var/log/utx.log" +# define _PATH_LASTLOG "/var/log/utx.lastlogin" +# define STRUCTUTMP struct utmpx #endif #include #include @@ -138,9 +143,9 @@ void setutent(void) } } -struct utmp* getutent(void) +STRUCTUTMP* getutent(void) { - static struct utmp st_utmp; + static STRUCTUTMP st_utmp; if(fread((char *)&st_utmp, sizeof(st_utmp), 1, BSD_uf) != 1) return NULL; @@ -177,8 +182,8 @@ static rsRetVal wallmsg(uchar* pMsg, instanceData *pData) int errnoSave; int ttyf; int wrRet; - struct utmp ut; - struct utmp *uptr; + STRUCTUTMP ut; + STRUCTUTMP *uptr; struct stat statb; DEFiRet; @@ -191,13 +196,21 @@ static rsRetVal wallmsg(uchar* pMsg, instanceData *pData) while((uptr = getutent())) { memcpy(&ut, uptr, sizeof(ut)); /* is this slot used? */ - if(ut.ut_name[0] == '\0') + + char UTNAME[MAXUNAMES]; +#ifdef HAVE_UTMP_H + strcpy(UTNAME,ut.ut_name); +#else + strcpy(UTNAME,ut.ut_user); +#endif + + if(UTNAME[0] == '\0') continue; #ifndef OS_BSD if(ut.ut_type != USER_PROCESS) continue; #endif - if(!(strncmp (ut.ut_name,"LOGIN", 6))) /* paranoia */ + if(!(strncmp (UTNAME,"LOGIN", 6))) /* paranoia */ continue; /* should we send the message to this user? */ @@ -207,7 +220,7 @@ static rsRetVal wallmsg(uchar* pMsg, instanceData *pData) i = MAXUNAMES; break; } - if(strncmp(pData->uname[i], ut.ut_name, UNAMESZ) == 0) + if(strncmp(pData->uname[i], UTNAME, UNAMESZ) == 0) break; } if(i == MAXUNAMES) /* user not found? */ -- cgit v1.2.3 From 6cf9bf703de35dc530170fcfdd5bb81041e8c2c9 Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Tue, 2 Mar 2010 11:32:43 +0100 Subject: bugfix: potential (but very impropable) segfaults in omfile - bugfix: potential segfault in omfile when a dynafile open failed In that case, a partial cache entry was written, and some internal pointers (iCurrElt) not correctly updated. In the next iteration, that could lead to a segfault, especially if iCurrElt then points to the then-partial record. Not very likely, but could happen in practice. - bugfix (theoretical): potential segfault in omfile under low memory condition. This is only a theoretical bug, because it would only happen when strdup() fails to allocate memory - which is highly unlikely and will probably lead to all other sorts of errors. --- ChangeLog | 9 +++++++++ tools/omfile.c | 16 ++++++++++++++-- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index a16c89da..893e67fd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -6,6 +6,15 @@ Version 4.6.1 [v4-stable] (rgerhards), 2010-02-?? - bugfix: fixed problem that caused compilation on FreeBSD 9.0 to fail. bugtracker: http://bugzilla.adiscon.com/show_bug.cgi?id=181 Thanks to Christiano for reporting. +- bugfix: potential segfault in omfile when a dynafile open failed + In that case, a partial cache entry was written, and some internal + pointers (iCurrElt) not correctly updated. In the next iteration, that + could lead to a segfault, especially if iCurrElt then points to the + then-partial record. Not very likely, but could happen in practice. +- bugfix (theoretical): potential segfault in omfile under low memory + condition. This is only a theoretical bug, because it would only + happen when strdup() fails to allocate memory - which is highly + unlikely and will probably lead to all other sorts of errors. - bugfix: comment char ('#') in literal terminated script parsing and thus could not be used. but tracker: http://bugzilla.adiscon.com/show_bug.cgi?id=119 diff --git a/tools/omfile.c b/tools/omfile.c index 069fc078..eb56201c 100644 --- a/tools/omfile.c +++ b/tools/omfile.c @@ -318,6 +318,7 @@ dynaFileFreeCacheEntries(instanceData *pData) for(i = 0 ; i < pData->iCurrCacheSize ; ++i) { dynaFileDelCacheEntry(pData->dynCache, i, 1); } + pData->iCurrElt = -1; /* invalidate current element */ ENDfunc; } @@ -486,6 +487,14 @@ prepareDynFile(instanceData *pData, uchar *newFileName, unsigned iMsgOpts) } /* we have not found an entry */ + + /* invalidate iCurrElt as we may error-exit out of this function when the currrent + * iCurrElt has been freed or otherwise become unusable. This is a precaution, and + * performance-wise it may be better to do that in each of the exits. However, that + * is error-prone, so I prefer to do it here. -- rgerhards, 2010-03-02 + */ + pData->iCurrElt = -1; + if(iFirstFree == -1 && (pData->iCurrCacheSize < pData->iDynaFileCacheSize)) { /* there is space left, so set it to that index */ iFirstFree = pData->iCurrCacheSize++; @@ -517,7 +526,11 @@ prepareDynFile(instanceData *pData, uchar *newFileName, unsigned iMsgOpts) ABORT_FINALIZE(localRet); } - CHKmalloc(pCache[iFirstFree]->pName = ustrdup(newFileName)); + if((pCache[iFirstFree]->pName = ustrdup(newFileName)) == NULL) { + /* we need to discard the entry, otherwise things could lead to a segfault! */ + dynaFileDelCacheEntry(pCache, iFirstFree, 1); + ABORT_FINALIZE(RS_RET_OUT_OF_MEMORY); + } pCache[iFirstFree]->pStrm = pData->pStrm; pCache[iFirstFree]->lastUsed = time(NULL); // monotonically increasing value! TODO: performance pData->iCurrElt = iFirstFree; @@ -752,7 +765,6 @@ BEGINdoHUP CODESTARTdoHUP if(pData->bDynamicName) { dynaFileFreeCacheEntries(pData); - pData->iCurrElt = -1; /* invalidate current element */ } else { if(pData->pStrm != NULL) { strm.Destruct(&pData->pStrm); -- cgit v1.2.3 From d080ffe467f6f58be82ee14dbeed94026002f1e0 Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Wed, 3 Mar 2010 09:24:40 +0100 Subject: reordered some include, because otherwise we get zlib-related errors on some platforms (namely Debian sid). This smells like a bug in zlib. Thanks to Michael Biebl for reporting the issue. --- 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 cd8c6abcc8cea54924e55dffe820364ad98a40df Mon Sep 17 00:00:00 2001 From: Yann Droneaud Date: Thu, 4 Mar 2010 08:00:39 +0100 Subject: Includes "config.h" before any other header. For consistency, ./configure generated "config.h" must be the first header include through out the project. Signed-off-by: Rainer Gerhards --- runtime/debug.c | 2 +- tests/ourtail.c | 1 + tests/rt-init.c | 1 + tools/msggen.c | 1 + tools/regexp.c | 1 + tools/zpipe.c | 1 + 6 files changed, 6 insertions(+), 1 deletion(-) diff --git a/runtime/debug.c b/runtime/debug.c index 9547eee6..20474a9a 100644 --- a/runtime/debug.c +++ b/runtime/debug.c @@ -1,4 +1,3 @@ -#include /* debug.c * * This file proides debug and run time error analysis support. Some of the @@ -550,6 +549,7 @@ if(pLog == NULL) { return; /* if we don't know it yet, we can not clean up... */ } #endif +#include /* we found the last lock entry. We now need to see from which FuncDB we need to * remove it. This is recorded inside the mutex log entry. diff --git a/tests/ourtail.c b/tests/ourtail.c index 4e8a6412..c31babb9 100644 --- a/tests/ourtail.c +++ b/tests/ourtail.c @@ -26,6 +26,7 @@ * * A copy of the GPL can be found in the file "COPYING" in this distribution. */ +#include "config.h" #include int main(int __attribute__((unused)) argc, char __attribute__((unused)) *argv[]) diff --git a/tests/rt-init.c b/tests/rt-init.c index b9c4ce2e..66a9ad32 100644 --- a/tests/rt-init.c +++ b/tests/rt-init.c @@ -21,6 +21,7 @@ * * A copy of the GPL can be found in the file "COPYING" in this distribution. */ +#include "config.h" #include "rsyslog.h" #include "testbench.h" #include /* must be last, else we get a zlib compile error on some platforms */ diff --git a/tools/msggen.c b/tools/msggen.c index 06244c18..29ade3a7 100644 --- a/tools/msggen.c +++ b/tools/msggen.c @@ -21,6 +21,7 @@ * A copy of the GPL can be found in the file "COPYING" in this distribution. */ +#include "config.h" #include #include diff --git a/tools/regexp.c b/tools/regexp.c index c8e4c681..e8bba4f4 100644 --- a/tools/regexp.c +++ b/tools/regexp.c @@ -26,6 +26,7 @@ * * A copy of the GPL can be found in the file "COPYING" in this distribution. */ +#include "config.h" #include #include #include diff --git a/tools/zpipe.c b/tools/zpipe.c index bde6c5c1..d2278359 100644 --- a/tools/zpipe.c +++ b/tools/zpipe.c @@ -22,6 +22,7 @@ files created by rsyslog's zip output writer. */ +#include "config.h" #include #include #include -- cgit v1.2.3 From 71ffb32ab8a1847f746a298ad20f7dd8b40570a0 Mon Sep 17 00:00:00 2001 From: Yann Droneaud Date: Wed, 3 Mar 2010 18:59:22 +0100 Subject: Fix Large File Support (LFS) support (bug #182) - _FILE_OFFSET_BITS must be defined before including any other system headers otherwise it does nothing. - Don't define it in rsyslog.h, let it be defined in config.h, and let ./configure script enable LFS since Autoconf provides a portable macro to enable LFS support : AC_SYS_LARGEFILE --- configure.ac | 19 ++++++------------- runtime/rsyslog.h | 9 --------- tools/syslogd.c | 2 +- 3 files changed, 7 insertions(+), 23 deletions(-) diff --git a/configure.ac b/configure.ac index b3d84b59..d229915e 100644 --- a/configure.ac +++ b/configure.ac @@ -152,19 +152,12 @@ AC_SUBST(moddirs) # Large file support -AC_ARG_ENABLE(largefile, - [AS_HELP_STRING([--enable-largefile],[Enable large file support @<:@default=yes@:>@])], - [case "${enableval}" in - yes) enable_largefile="yes" ;; - no) enable_largefile="no" ;; - *) AC_MSG_ERROR(bad value ${enableval} for --enable-largefile) ;; - esac], - [enable_largefile="yes"] -) -if test "$enable_largefile" = "no"; then - AC_DEFINE(NOLARGEFILE, 1, [Defined when large file support is disabled.]) -fi - +# http://www.gnu.org/software/autoconf/manual/html_node/System-Services.html#index-AC_005fSYS_005fLARGEFILE-1028 +AC_SYS_LARGEFILE +case "${enable_largefile}" in + no) ;; + *) enable_largefile="yes" ;; +esac # Regular expressions AC_ARG_ENABLE(regexp, diff --git a/runtime/rsyslog.h b/runtime/rsyslog.h index 0f489a7f..8979893a 100644 --- a/runtime/rsyslog.h +++ b/runtime/rsyslog.h @@ -46,15 +46,6 @@ * # End Config Settings # * * ############################################################# */ -#ifndef NOLARGEFILE -# undef _LARGEFILE_SOURCE -# undef _LARGEFILE64_SOURCE -# undef _FILE_OFFSET_BITS -# define _LARGEFILE_SOURCE -# define _LARGEFILE64_SOURCE -# define _FILE_OFFSET_BITS 64 -#endif - /* portability: not all platforms have these defines, so we * define them here if they are missing. -- rgerhards, 2008-03-04 */ diff --git a/tools/syslogd.c b/tools/syslogd.c index ba1dbb18..64b23566 100644 --- a/tools/syslogd.c +++ b/tools/syslogd.c @@ -2770,7 +2770,7 @@ static void printVersion(void) #else printf("\tFEATURE_REGEXP:\t\t\t\tNo\n"); #endif -#ifndef NOLARGEFILE +#if defined(_LARGE_FILES) || (defined (_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS >= 64) printf("\tFEATURE_LARGEFILE:\t\t\tYes\n"); #else printf("\tFEATURE_LARGEFILE:\t\t\tNo\n"); -- cgit v1.2.3 From ad8ec0577a78def820d01d457ad20dd3ac64214d Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Thu, 4 Mar 2010 09:27:36 +0100 Subject: cosmetic: ChangeLog update including proper credits to Mandriva team. --- ChangeLog | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ChangeLog b/ChangeLog index 893e67fd..caaa8a11 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,6 +3,14 @@ Version 4.6.1 [v4-stable] (rgerhards), 2010-02-?? - re-enabled old pipe output (using new module ompipe, built-in) after some problems with pipes (and especially in regard to xconsole) were discovered. Thanks to Michael Biebl for reporting the issues. +- bugfix: potential problems with large file support could cause segfault + ... and other weird problems. This seemed to affect 32bit-platforms + only, but I can not totally outrule there were issues on other + platforms as well. The previous code could cause system data types + to be defined inconsistently, and that could lead to various + troubles. Special thanks go to the Mandriva team for identifying + an initial problem, help discussing it and ultimately a fix they + contributed. - bugfix: fixed problem that caused compilation on FreeBSD 9.0 to fail. bugtracker: http://bugzilla.adiscon.com/show_bug.cgi?id=181 Thanks to Christiano for reporting. -- cgit v1.2.3 From 4c060687cf877e4c7faee02f33c219e5f6c8f8f6 Mon Sep 17 00:00:00 2001 From: Cristiano Date: Thu, 4 Mar 2010 09:51:28 +0100 Subject: streamlined BSD utmpx.h patch Signed-off-by: Rainer Gerhards --- tools/omusrmsg.c | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/tools/omusrmsg.c b/tools/omusrmsg.c index 9279028c..e788a006 100644 --- a/tools/omusrmsg.c +++ b/tools/omusrmsg.c @@ -53,12 +53,11 @@ #ifdef HAVE_UTMP_H # include # define STRUCTUTMP struct utmp +# define UTNAME ut_name #else # include -# define _PATH_UTMP "/var/run/utx.active" -# define _PATH_WTMP "/var/log/utx.log" -# define _PATH_LASTLOG "/var/log/utx.lastlogin" # define STRUCTUTMP struct utmpx +# define UTNAME ut_user #endif #include #include @@ -133,6 +132,12 @@ ENDdbgPrintInstInfo * need! rgerhards 2005-03-18 */ #ifdef OS_BSD +/* Since version 900007, FreeBSD has a POSIX compliant */ +#if defined(__FreeBSD__) && (__FreeBSD_version >= 900007) +# define setutent(void) setutxent(void) +# define getutent(void) getutxent(void) +# define endutent(void) endutxent(void) +#else static FILE *BSD_uf = NULL; void setutent(void) { @@ -158,6 +163,7 @@ void endutent(void) fclose(BSD_uf); BSD_uf = NULL; } +#endif /* if defined(__FreeBSD__) */ #endif /* #ifdef OS_BSD */ @@ -196,21 +202,13 @@ static rsRetVal wallmsg(uchar* pMsg, instanceData *pData) while((uptr = getutent())) { memcpy(&ut, uptr, sizeof(ut)); /* is this slot used? */ - - char UTNAME[MAXUNAMES]; -#ifdef HAVE_UTMP_H - strcpy(UTNAME,ut.ut_name); -#else - strcpy(UTNAME,ut.ut_user); -#endif - - if(UTNAME[0] == '\0') + if(ut.UTNAME[0] == '\0') continue; #ifndef OS_BSD if(ut.ut_type != USER_PROCESS) continue; #endif - if(!(strncmp (UTNAME,"LOGIN", 6))) /* paranoia */ + if(!(strncmp (ut.UTNAME,"LOGIN", 6))) /* paranoia */ continue; /* should we send the message to this user? */ @@ -220,7 +218,7 @@ static rsRetVal wallmsg(uchar* pMsg, instanceData *pData) i = MAXUNAMES; break; } - if(strncmp(pData->uname[i], UTNAME, UNAMESZ) == 0) + if(strncmp(pData->uname[i], ut.UTNAME, UNAMESZ) == 0) break; } if(i == MAXUNAMES) /* user not found? */ -- cgit v1.2.3 From 0b84d47f7a244c25f63fadcec92d12ebfbe319a4 Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Thu, 4 Mar 2010 11:42:21 +0100 Subject: prepared 4.6.1 --- ChangeLog | 2 +- configure.ac | 2 +- doc/manual.html | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index caaa8a11..2cf5f024 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,5 @@ --------------------------------------------------------------------------- -Version 4.6.1 [v4-stable] (rgerhards), 2010-02-?? +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 discovered. Thanks to Michael Biebl for reporting the issues. diff --git a/configure.ac b/configure.ac index d229915e..b059fe75 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.6.0],[rsyslog@lists.adiscon.com]) +AC_INIT([rsyslog],[4.6.1],[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 0e121edf..0efe5076 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.6.0 (v4-stable branch) of rsyslog. +

This documentation is for version 4.6.1 (v4-stable 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