diff options
author | Rainer Gerhards <rgerhards@adiscon.com> | 2010-03-08 14:27:20 +0100 |
---|---|---|
committer | Rainer Gerhards <rgerhards@adiscon.com> | 2010-03-08 14:27:20 +0100 |
commit | 06387e5592ffb4f7b20ea631f0824ff2cc652c20 (patch) | |
tree | dc964b62013bf67dc18c73d3fc1f3a97e931fed0 /tools | |
parent | b4cdb7c997eee95df96321d11d03cf90e4a6caba (diff) | |
parent | 0b84d47f7a244c25f63fadcec92d12ebfbe319a4 (diff) | |
download | rsyslog-06387e5592ffb4f7b20ea631f0824ff2cc652c20.tar.gz rsyslog-06387e5592ffb4f7b20ea631f0824ff2cc652c20.tar.xz rsyslog-06387e5592ffb4f7b20ea631f0824ff2cc652c20.zip |
Merge branch 'v4-stable' into beta
Conflicts:
ChangeLog
configure.ac
doc/manual.html
tests/rt-init.c
Diffstat (limited to 'tools')
-rw-r--r-- | tools/msggen.c | 1 | ||||
-rw-r--r-- | tools/omfile.c | 16 | ||||
-rw-r--r-- | tools/omusrmsg.c | 25 | ||||
-rw-r--r-- | tools/regexp.c | 1 | ||||
-rw-r--r-- | tools/syslogd.c | 2 | ||||
-rw-r--r-- | tools/zpipe.c | 1 |
6 files changed, 36 insertions, 10 deletions
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 <stdio.h> #include <syslog.h> diff --git a/tools/omfile.c b/tools/omfile.c index 2499680d..5b672181 100644 --- a/tools/omfile.c +++ b/tools/omfile.c @@ -345,6 +345,7 @@ dynaFileFreeCacheEntries(instanceData *pData) for(i = 0 ; i < pData->iCurrCacheSize ; ++i) { dynaFileDelCacheEntry(pData->dynCache, i, 1); } + pData->iCurrElt = -1; /* invalidate current element */ ENDfunc; } @@ -528,6 +529,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++; @@ -559,7 +568,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]->clkTickAccessed = getClockFileAccess(); pData->iCurrElt = iFirstFree; @@ -812,7 +825,6 @@ BEGINdoHUP CODESTARTdoHUP if(pData->bDynamicName) { dynaFileFreeCacheEntries(pData); - pData->iCurrElt = -1; /* invalidate current element */ } else { if(pData->pStrm != NULL) { strm.Destruct(&pData->pStrm); diff --git a/tools/omusrmsg.c b/tools/omusrmsg.c index a89297d7..e788a006 100644 --- a/tools/omusrmsg.c +++ b/tools/omusrmsg.c @@ -52,8 +52,12 @@ #include <sys/param.h> #ifdef HAVE_UTMP_H # include <utmp.h> +# define STRUCTUTMP struct utmp +# define UTNAME ut_name #else # include <utmpx.h> +# define STRUCTUTMP struct utmpx +# define UTNAME ut_user #endif #include <unistd.h> #include <sys/uio.h> @@ -128,6 +132,12 @@ ENDdbgPrintInstInfo * need! rgerhards 2005-03-18 */ #ifdef OS_BSD +/* Since version 900007, FreeBSD has a POSIX compliant <utmpx.h> */ +#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) { @@ -138,9 +148,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; @@ -153,6 +163,7 @@ void endutent(void) fclose(BSD_uf); BSD_uf = NULL; } +#endif /* if defined(__FreeBSD__) */ #endif /* #ifdef OS_BSD */ @@ -177,8 +188,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 +202,13 @@ 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') + if(ut.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 (ut.UTNAME,"LOGIN", 6))) /* paranoia */ continue; /* should we send the message to this user? */ @@ -207,7 +218,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], ut.UTNAME, UNAMESZ) == 0) break; } if(i == MAXUNAMES) /* user not found? */ 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 <stdio.h> #include <stdlib.h> #include <string.h> diff --git a/tools/syslogd.c b/tools/syslogd.c index b0a5b3ad..887ffbd2 100644 --- a/tools/syslogd.c +++ b/tools/syslogd.c @@ -1992,7 +1992,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"); 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 <stdio.h> #include <string.h> #include <assert.h> |