diff options
author | Michael Biebl <biebl@debian.org> | 2014-09-26 23:40:38 +0200 |
---|---|---|
committer | Michael Biebl <biebl@debian.org> | 2014-09-26 23:40:38 +0200 |
commit | 7bfd178d59a2c706d46092d745b54c61403cb44a (patch) | |
tree | fe5db3a861d09953408ad79a21318eda3afed7de /plugins | |
parent | 1dfcd909d90f6fad4a612b6fd998d7473a9da399 (diff) | |
download | rsyslog-upstream/8.4.1.tar.gz |
Imported Upstream version 8.4.1upstream/8.4.1upstream
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/imfile/imfile.c | 16 | ||||
-rw-r--r-- | plugins/imjournal/imjournal.c | 6 | ||||
-rw-r--r-- | plugins/imklog/imklog.c | 6 | ||||
-rw-r--r-- | plugins/imkmsg/imkmsg.c | 2 | ||||
-rw-r--r-- | plugins/imkmsg/kmsg.c | 1 | ||||
-rw-r--r-- | plugins/impstats/impstats.c | 38 | ||||
-rw-r--r-- | plugins/imsolaris/imsolaris.c | 4 | ||||
-rw-r--r-- | plugins/imuxsock/imuxsock.c | 6 | ||||
-rw-r--r-- | plugins/mmanon/mmanon.c | 2 | ||||
-rw-r--r-- | plugins/mmfields/mmfields.c | 2 | ||||
-rw-r--r-- | plugins/omelasticsearch/omelasticsearch.c | 14 | ||||
-rw-r--r-- | plugins/ompgsql/ompgsql.c | 15 | ||||
-rw-r--r-- | plugins/omprog/omprog.c | 1 | ||||
-rw-r--r-- | plugins/omudpspoof/omudpspoof.c | 8 | ||||
-rw-r--r-- | plugins/sm_cust_bindcdr/Makefile.in | 2 | ||||
-rw-r--r-- | plugins/sm_cust_bindcdr/README | 10 |
16 files changed, 94 insertions, 39 deletions
diff --git a/plugins/imfile/imfile.c b/plugins/imfile/imfile.c index f8272d4..d37cb03 100644 --- a/plugins/imfile/imfile.c +++ b/plugins/imfile/imfile.c @@ -376,8 +376,8 @@ static rsRetVal enqLine(fileInfo_t *pInfo, cstr_t *cstrLine) MsgSetMSGoffs(pMsg, 0); /* we do not have a header... */ MsgSetHOSTNAME(pMsg, glbl.GetLocalHostName(), ustrlen(glbl.GetLocalHostName())); MsgSetTAG(pMsg, pInfo->pszTag, pInfo->lenTag); - pMsg->iFacility = LOG_FAC(pInfo->iFacility); - pMsg->iSeverity = LOG_PRI(pInfo->iSeverity); + pMsg->iFacility = pri2fac(pInfo->iFacility); + pMsg->iSeverity = pri2sev(pInfo->iSeverity); MsgSetRuleset(pMsg, pInfo->pRuleset); ratelimitAddMsg(pInfo->ratelimiter, &pInfo->multiSub, pMsg); finalize_it: @@ -422,6 +422,18 @@ openFile(fileInfo_t *pThis) /* read back in the object */ CHKiRet(obj.Deserialize(&pThis->pStrm, (uchar*) "strm", psSF, NULL, pThis)); + DBGPRINTF("imfile: deserialized state file, state file base name '%s', " + "configured base name '%s'\n", pThis->pStrm->pszFName, + pThis->pszFileName); + if(ustrcmp(pThis->pStrm->pszFName, pThis->pszFileName)) { + errmsg.LogError(0, RS_RET_STATEFILE_WRONG_FNAME, "imfile: state file '%s' " + "contains file name '%s', but is used for file '%s'. State " + "file deleted, starting from begin of file.", + pszSFNam, pThis->pStrm->pszFName, pThis->pszFileName); + + unlink((char*)pszSFNam); + ABORT_FINALIZE(RS_RET_STATEFILE_WRONG_FNAME); + } strm.CheckFileChange(pThis->pStrm); CHKiRet(strm.SeekCurrOffs(pThis->pStrm)); diff --git a/plugins/imjournal/imjournal.c b/plugins/imjournal/imjournal.c index 51a4aa7..6a97b25 100644 --- a/plugins/imjournal/imjournal.c +++ b/plugins/imjournal/imjournal.c @@ -91,8 +91,8 @@ static struct cnfparamblk modpblk = }; #define DFLT_persiststateinterval 10 -#define DFLT_SEVERITY LOG_PRI(LOG_NOTICE) -#define DFLT_FACILITY LOG_FAC(LOG_USER) +#define DFLT_SEVERITY pr2fac(LOG_NOTICE) +#define DFLT_FACILITY pri2sev(LOG_USER) static int bLegacyCnfModGlobalsPermitted = 1;/* are legacy module-global config parameters permitted? */ @@ -125,7 +125,7 @@ static rsRetVal facilityHdlr(uchar **pp, void *pVal) /* noop */; for (c = syslogFacNames; c->c_name; c++) { if (!strncasecmp(p, (char *) c->c_name, len)) { - *((int *) pVal) = LOG_FAC(c->c_val); + *((int *) pVal) = pri2fac(c->c_val); break; } } diff --git a/plugins/imklog/imklog.c b/plugins/imklog/imklog.c index 810ac26..4a76340 100644 --- a/plugins/imklog/imklog.c +++ b/plugins/imklog/imklog.c @@ -21,7 +21,7 @@ * To test under Linux: * echo test1 > /dev/kmsg * - * Copyright (C) 2008-2012 Adiscon GmbH + * Copyright (C) 2008-2014 Adiscon GmbH * * This file is part of rsyslog. * @@ -247,10 +247,10 @@ rsRetVal Syslog(int priority, uchar *pMsg, struct timeval *tp) /* if we don't get the pri, we use whatever we were supplied */ /* ignore non-kernel messages if not permitted */ - if(cs.bPermitNonKernel == 0 && LOG_FAC(priority) != LOG_KERN) + if(cs.bPermitNonKernel == 0 && pri2fac(priority) != LOG_KERN) FINALIZE; /* silently ignore */ - iRet = enqMsg((uchar*)pMsg, (uchar*) "kernel:", LOG_FAC(priority), LOG_PRI(priority), tp); + iRet = enqMsg((uchar*)pMsg, (uchar*) "kernel:", pri2fac(priority), pri2sev(priority), tp); finalize_it: RETiRet; diff --git a/plugins/imkmsg/imkmsg.c b/plugins/imkmsg/imkmsg.c index 2a97f82..8588223 100644 --- a/plugins/imkmsg/imkmsg.c +++ b/plugins/imkmsg/imkmsg.c @@ -144,7 +144,7 @@ rsRetVal imkmsgLogIntMsg(int priority, char *fmt, ...) rsRetVal Syslog(int priority, uchar *pMsg, struct timeval *tp, struct json_object *json) { DEFiRet; - iRet = enqMsg((uchar*)pMsg, (uchar*) "kernel:", LOG_FAC(priority), LOG_PRI(priority), tp, json); + iRet = enqMsg((uchar*)pMsg, (uchar*) "kernel:", pri2fac(priority), pri2sev(priority), tp, json); RETiRet; } diff --git a/plugins/imkmsg/kmsg.c b/plugins/imkmsg/kmsg.c index 172ff4d..3d9b78e 100644 --- a/plugins/imkmsg/kmsg.c +++ b/plugins/imkmsg/kmsg.c @@ -34,6 +34,7 @@ #include <ctype.h> #include <sys/klog.h> #include <sys/sysinfo.h> +#include <sys/time.h> #include <json.h> #include "rsyslog.h" diff --git a/plugins/impstats/impstats.c b/plugins/impstats/impstats.c index 8d79fb2..ede7c60 100644 --- a/plugins/impstats/impstats.c +++ b/plugins/impstats/impstats.c @@ -83,6 +83,7 @@ struct modConfData_s { statsFmtType_t statsFmt; sbool bLogToSyslog; sbool bResetCtrs; + sbool bBracketing; char *logfile; sbool configSetViaV2Method; uchar *pszBindRuleset; /* name of ruleset to bind to */ @@ -99,6 +100,7 @@ static struct cnfparamdescr modpdescr[] = { { "interval", eCmdHdlrInt, 0 }, { "facility", eCmdHdlrInt, 0 }, { "severity", eCmdHdlrInt, 0 }, + { "bracketing", eCmdHdlrBinary, 0 }, { "log.syslog", eCmdHdlrBinary, 0 }, { "resetcounters", eCmdHdlrBinary, 0 }, { "log.file", eCmdHdlrGetWord, 0 }, @@ -186,7 +188,7 @@ finalize_it: /* log stats message to file; limited error handling done */ static inline void -doLogToFile(cstr_t *cstr) +doLogToFile(uchar *ln, size_t lenLn) { struct iovec iov[4]; ssize_t nwritten; @@ -194,7 +196,7 @@ doLogToFile(cstr_t *cstr) time_t t; char timebuf[32]; - if(cstrLen(cstr) == 0) + if(lenLn == 0) goto done; if(runModConf->logfd == -1) { runModConf->logfd = open(runModConf->logfile, O_WRONLY|O_CREAT|O_APPEND|O_CLOEXEC, S_IRUSR|S_IWUSR); @@ -210,9 +212,9 @@ doLogToFile(cstr_t *cstr) iov[1].iov_base = ": "; iov[1].iov_len = 2; nexpect += 2; - iov[2].iov_base = rsCStrGetSzStrNoNULL(cstr); - iov[2].iov_len = (size_t) cstrLen(cstr); - nexpect += cstrLen(cstr); + iov[2].iov_base = ln; + iov[2].iov_len = lenLn; + nexpect += lenLn; iov[3].iov_base = "\n"; iov[3].iov_len = 1; nexpect++; @@ -226,6 +228,20 @@ done: return; } +/* submit a line to our log destinations. Line must be fully formatted as + * required (but may be a simple verb like "BEGIN" and "END". + */ +static rsRetVal +submitLine(uchar *const ln, const size_t lenLn) +{ + DEFiRet; + if(runModConf->bLogToSyslog) + doSubmitMsg(ln); + if(runModConf->logfile != NULL) + doLogToFile(ln, lenLn); + RETiRet; +} + /* callback for statsobj * Note: usrptr exists only to satisfy requirements of statsobj callback interface! */ @@ -233,10 +249,7 @@ static rsRetVal doStatsLine(void __attribute__((unused)) *usrptr, cstr_t *cstr) { DEFiRet; - if(runModConf->bLogToSyslog) - doSubmitMsg(rsCStrGetSzStrNoNULL(cstr)); - if(runModConf->logfile != NULL) - doLogToFile(cstr); + iRet = submitLine(rsCStrGetSzStrNoNULL(cstr), cstrLen(cstr)); RETiRet; } @@ -281,6 +294,7 @@ CODESTARTbeginCnfLoad loadModConf->logfile = NULL; loadModConf->pszBindRuleset = NULL; loadModConf->bLogToSyslog = 1; + loadModConf->bBracketing = 0; loadModConf->bResetCtrs = 0; bLegacyCnfModGlobalsPermitted = 1; /* init legacy config vars */ @@ -314,6 +328,8 @@ CODESTARTsetModCnf loadModConf->iFacility = (int) pvals[i].val.d.n; } else if(!strcmp(modpblk.descr[i].name, "severity")) { loadModConf->iSeverity = (int) pvals[i].val.d.n; + } else if(!strcmp(modpblk.descr[i].name, "bracketing")) { + loadModConf->bBracketing = (sbool) pvals[i].val.d.n; } else if(!strcmp(modpblk.descr[i].name, "log.syslog")) { loadModConf->bLogToSyslog = (sbool) pvals[i].val.d.n; } else if(!strcmp(modpblk.descr[i].name, "resetcounters")) { @@ -464,7 +480,11 @@ CODESTARTrunInput while(glbl.GetGlobalInputTermState() == 0) { srSleep(runModConf->iStatsInterval, 0); /* seconds, micro seconds */ DBGPRINTF("impstats: woke up, generating messages\n"); + if(runModConf->bBracketing) + submitLine((uchar*)"BEGIN", sizeof("BEGIN")-1); generateStatsMsgs(); + if(runModConf->bBracketing) + submitLine((uchar*)"END", sizeof("END")-1); } ENDrunInput diff --git a/plugins/imsolaris/imsolaris.c b/plugins/imsolaris/imsolaris.c index a220e72..36677e7 100644 --- a/plugins/imsolaris/imsolaris.c +++ b/plugins/imsolaris/imsolaris.c @@ -209,8 +209,8 @@ readLog(int fd, uchar *pRcv, int iMaxLine) MsgSetInputName(pMsg, pInputName); MsgSetRawMsg(pMsg, (char*)pRcv, strlen((char*)pRcv)); MsgSetHOSTNAME(pMsg, glbl.GetLocalHostName(), ustrlen(glbl.GetLocalHostName())); - pMsg->iFacility = LOG_FAC(hdr.pri); - pMsg->iSeverity = LOG_PRI(hdr.pri); + pMsg->iFacility = pri2fac(hdr.pri); + pMsg->iSeverity = pri2sev(hdr.pri); pMsg->msgFlags = NEEDS_PARSING | NO_PRI_IN_RAW; CHKiRet(submitMsg(pMsg)); } diff --git a/plugins/imuxsock/imuxsock.c b/plugins/imuxsock/imuxsock.c index a79fcc5..d99bed8 100644 --- a/plugins/imuxsock/imuxsock.c +++ b/plugins/imuxsock/imuxsock.c @@ -6,7 +6,7 @@ * * File begun on 2007-12-20 by RGerhards (extracted from syslogd.c) * - * Copyright 2007-2013 Rainer Gerhards and Adiscon GmbH. + * Copyright 2007-2014 Rainer Gerhards and Adiscon GmbH. * * This file is part of rsyslog. * @@ -772,8 +772,8 @@ SubmitMsg(uchar *pRcv, int lenRcv, lstn_t *pLstn, struct ucred *cred, struct tim ++parse; ++offs; } - facil = LOG_FAC(pri); - sever = LOG_PRI(pri); + facil = pri2fac(pri); + sever = pri2sev(pri); findRatelimiter(pLstn, cred, &ratelimiter); /* ignore error, better so than others... */ diff --git a/plugins/mmanon/mmanon.c b/plugins/mmanon/mmanon.c index 2879780..a85faa1 100644 --- a/plugins/mmanon/mmanon.c +++ b/plugins/mmanon/mmanon.c @@ -295,7 +295,7 @@ anonip(instanceData *pData, uchar *msg, int *pLenMsg, int *idx) int endpos; int lenMsg = *pLenMsg; - while(i < lenMsg && (msg[i] <= '0' || msg[i] >= '9')) { + while(i < lenMsg && (msg[i] <= '0' || msg[i] > '9')) { ++i; /* skip to first number */ } if(i >= lenMsg) diff --git a/plugins/mmfields/mmfields.c b/plugins/mmfields/mmfields.c index c408a6c..cdce199 100644 --- a/plugins/mmfields/mmfields.c +++ b/plugins/mmfields/mmfields.c @@ -43,7 +43,7 @@ MODULE_TYPE_NOKEEP MODULE_CNFNAME("mmfields") -DEFobjCurrIf(errmsg); +DEFobjCurrIf(errmsg) DEF_OMOD_STATIC_DATA /* config variables */ diff --git a/plugins/omelasticsearch/omelasticsearch.c b/plugins/omelasticsearch/omelasticsearch.c index 9a33f85..68fb3c1 100644 --- a/plugins/omelasticsearch/omelasticsearch.c +++ b/plugins/omelasticsearch/omelasticsearch.c @@ -577,10 +577,10 @@ DBGPRINTF("omelasticsearch: %d items in reply\n", numitems); "cannot obtain 'create' item for #%d\n", i); ABORT_FINALIZE(RS_RET_DATAFAIL); } - ok = cJSON_GetObjectItem(create, "ok"); - if(ok == NULL || ok->type != cJSON_True) { + ok = cJSON_GetObjectItem(create, "status"); + if(ok == NULL || ok->type != cJSON_Number || ok->valueint < 0 || ok->valueint > 299) { DBGPRINTF("omelasticsearch: error in elasticsearch reply: " - "item %d, prop ok (%p) not ok\n", i, ok); + "item %d, status is %d\n", i, ok->valueint); ABORT_FINALIZE(RS_RET_DATAFAIL); } } @@ -594,7 +594,7 @@ static inline rsRetVal checkResult(wrkrInstanceData_t *pWrkrData, uchar *reqmsg) { cJSON *root; - cJSON *ok; + cJSON *status; DEFiRet; root = cJSON_Parse(pWrkrData->reply); @@ -606,8 +606,10 @@ checkResult(wrkrInstanceData_t *pWrkrData, uchar *reqmsg) if(pWrkrData->pData->bulkmode) { iRet = checkResultBulkmode(pWrkrData, root); } else { - ok = cJSON_GetObjectItem(root, "ok"); - if(ok == NULL || ok->type != cJSON_True) { + status = cJSON_GetObjectItem(root, "status"); + /* as far as we know, no "status" means all went well */ + if(status != NULL && + (status->type == cJSON_Number || status->valueint >= 0 || status->valueint <= 299)) { iRet = RS_RET_DATAFAIL; } } diff --git a/plugins/ompgsql/ompgsql.c b/plugins/ompgsql/ompgsql.c index 4da0949..6b89717 100644 --- a/plugins/ompgsql/ompgsql.c +++ b/plugins/ompgsql/ompgsql.c @@ -235,9 +235,18 @@ writePgSQL(uchar *psz, instanceData *pData) if(bHadError || (PQstatus(pData->f_hpgsql) != CONNECTION_OK)) { /* error occured, try to re-init connection and retry */ - closePgSQL(pData); /* close the current handle */ - CHKiRet(initPgSQL(pData, 0)); /* try to re-open */ - bHadError = tryExec(psz, pData); /* retry */ + int inTransaction = 0; + if(pData->f_hpgsql != NULL) { + PGTransactionStatusType xactStatus = PQtransactionStatus(pData->f_hpgsql); + if((xactStatus == PQTRANS_INTRANS) || (xactStatus == PQTRANS_ACTIVE)) { + inTransaction = 1; + } + } + if ( inTransaction == 0 ) { + closePgSQL(pData); /* close the current handle */ + CHKiRet(initPgSQL(pData, 0)); /* try to re-open */ + bHadError = tryExec(psz, pData); /* retry */ + } if(bHadError || (PQstatus(pData->f_hpgsql) != CONNECTION_OK)) { /* we failed, giving up for now */ reportDBError(pData, 0); diff --git a/plugins/omprog/omprog.c b/plugins/omprog/omprog.c index 93dfbb4..2ba0b94 100644 --- a/plugins/omprog/omprog.c +++ b/plugins/omprog/omprog.c @@ -27,6 +27,7 @@ #include "config.h" #include "rsyslog.h" #include <stdio.h> +#include <syslog.h> #include <stdarg.h> #include <stdlib.h> #include <string.h> diff --git a/plugins/omudpspoof/omudpspoof.c b/plugins/omudpspoof/omudpspoof.c index ad3508c..92fa48f 100644 --- a/plugins/omudpspoof/omudpspoof.c +++ b/plugins/omudpspoof/omudpspoof.c @@ -383,7 +383,7 @@ UDPSend(wrkrInstanceData_t *pWrkrData, uchar *pszSourcename, char *msg, size_t l if(len > 65528) { DBGPRINTF("omudpspoof: msg with length %d truncated to 64k: '%.768s'\n", - len, msg); + (int) len, msg); len = 65528; } @@ -417,7 +417,7 @@ UDPSend(wrkrInstanceData_t *pWrkrData, uchar *pszSourcename, char *msg, size_t l libnet_clear_packet(pWrkrData->libnet_handle); /* note: libnet does need ports in host order NOT in network byte order! -- rgerhards, 2009-11-12 */ udp = libnet_build_udp( - ntohs(pWrkrData->sourcePort),/* source port */ + pWrkrData->sourcePort, /* source port */ ntohs(tempaddr->sin_port),/* destination port */ pktLen+LIBNET_UDP_H, /* packet length */ 0, /* checksum */ @@ -455,7 +455,7 @@ UDPSend(wrkrInstanceData_t *pWrkrData, uchar *pszSourcename, char *msg, size_t l * it is useful for consolidating with strace output. */ DBGPRINTF("omudpspoof: write error (total len %d): pktLen %d, sent %d, fd %d: %s\n", - len, LIBNET_IPV4_H+LIBNET_UDP_H+pktLen, lsent, pWrkrData->libnet_handle->fd, + (int) len, LIBNET_IPV4_H+LIBNET_UDP_H+pktLen, lsent, pWrkrData->libnet_handle->fd, libnet_geterror(pWrkrData->libnet_handle)); if(lsent != -1) { bSendSuccess = RSTRUE; @@ -504,7 +504,7 @@ UDPSend(wrkrInstanceData_t *pWrkrData, uchar *pszSourcename, char *msg, size_t l lsent = libnet_write(pWrkrData->libnet_handle); if(lsent != (int) (LIBNET_IPV4_H+pktLen)) { DBGPRINTF("omudpspoof: fragment write error len %d, sent %d: %s\n", - LIBNET_IPV4_H+LIBNET_UDP_H+len, lsent, libnet_geterror(pWrkrData->libnet_handle)); + (int) (LIBNET_IPV4_H+LIBNET_UDP_H+len), lsent, libnet_geterror(pWrkrData->libnet_handle)); bSendSuccess = RSFALSE; continue; } diff --git a/plugins/sm_cust_bindcdr/Makefile.in b/plugins/sm_cust_bindcdr/Makefile.in index f363d43..a9e36aa 100644 --- a/plugins/sm_cust_bindcdr/Makefile.in +++ b/plugins/sm_cust_bindcdr/Makefile.in @@ -35,7 +35,7 @@ POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ subdir = plugins/sm_cust_bindcdr -DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in +DIST_COMMON = README $(srcdir)/Makefile.am $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/atomic_operations.m4 \ $(top_srcdir)/m4/atomic_operations_64bit.m4 \ diff --git a/plugins/sm_cust_bindcdr/README b/plugins/sm_cust_bindcdr/README new file mode 100644 index 0000000..b1d28c5 --- /dev/null +++ b/plugins/sm_cust_bindcdr/README @@ -0,0 +1,10 @@ +This module was created for a custom project with a very specific use +case. It was included into the source tree as a sample if someone +would like to create similar work. I strongly doubt it has any +value to the community other than serving as an example. Thus, +I do not intend to maintain this module, except if a sponsor +comes up that actually wants this to be done. I prefer to +leave it in the source tree even if it is broken starting with v8. +If that creates a problem, I would simply delete it. + +Rainer Gerhards |