summaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/imdiag/imdiag.c14
-rw-r--r--plugins/imfile/imfile.c15
-rw-r--r--plugins/imklog/imklog.c19
-rw-r--r--plugins/imrelp/imrelp.c18
-rw-r--r--plugins/imudp/imudp.c2
-rw-r--r--plugins/imuxsock/imuxsock.c18
6 files changed, 75 insertions, 11 deletions
diff --git a/plugins/imdiag/imdiag.c b/plugins/imdiag/imdiag.c
index 4b004bc4..8d874a87 100644
--- a/plugins/imdiag/imdiag.c
+++ b/plugins/imdiag/imdiag.c
@@ -66,10 +66,12 @@ DEFobjCurrIf(net)
DEFobjCurrIf(netstrm)
DEFobjCurrIf(errmsg)
DEFobjCurrIf(datetime)
+DEFobjCurrIf(prop)
/* Module static data */
static tcpsrv_t *pOurTcpsrv = NULL; /* our TCP server(listener) TODO: change for multiple instances */
static permittedPeers_t *pPermPeersRoot = NULL;
+static prop_t *pInputName = NULL; /* there is only one global inputName for all messages generated by this input */
/* config settings */
@@ -206,7 +208,7 @@ doInjectMsg(int iNum)
/* we now create our own message object and submit it to the queue */
CHKiRet(msgConstructWithTime(&pMsg, &stTime, ttGenTime));
MsgSetRawMsg(pMsg, (char*) szMsg, ustrlen(szMsg));
- MsgSetInputNameStr(pMsg, UCHAR_CONSTANT("imdiag"), sizeof("imdiag")-1);
+ MsgSetInputName(pMsg, pInputName);
MsgSetFlowControlType(pMsg, eFLOWCTL_NO_DELAY);
pMsg->msgFlags = NEEDS_PARSING | PARSE_HOSTNAME;
pMsg->bParseHOSTNAME = 1;
@@ -376,13 +378,19 @@ CODESTARTwillRun
/* first apply some config settings */
if(pOurTcpsrv == NULL)
ABORT_FINALIZE(RS_RET_NO_RUN);
+ /* we need to create the inputName property (only once during our lifetime) */
+ CHKiRet(prop.Construct(&pInputName));
+ CHKiRet(prop.SetString(pInputName, UCHAR_CONSTANT("imdiag"), sizeof("imdiag") - 1));
+ CHKiRet(prop.ConstructFinalize(pInputName));
+
finalize_it:
ENDwillRun
BEGINafterRun
CODESTARTafterRun
- /* do cleanup here */
+ if(pInputName != NULL)
+ prop.Destruct(&pInputName);
ENDafterRun
@@ -402,6 +410,7 @@ CODESTARTmodExit
objRelease(tcpsrv, LM_TCPSRV_FILENAME);
objRelease(errmsg, CORE_COMPONENT);
objRelease(datetime, CORE_COMPONENT);
+ objRelease(prop, CORE_COMPONENT);
ENDmodExit
@@ -439,6 +448,7 @@ CODEmodInit_QueryRegCFSLineHdlr
CHKiRet(objUse(tcpsrv, LM_TCPSRV_FILENAME));
CHKiRet(objUse(errmsg, CORE_COMPONENT));
CHKiRet(objUse(datetime, CORE_COMPONENT));
+ CHKiRet(objUse(prop, CORE_COMPONENT));
/* register config file handlers */
CHKiRet(omsdRegCFSLineHdlr(UCHAR_CONSTANT("imdiagserverrun"), 0, eCmdHdlrGetWord,
diff --git a/plugins/imfile/imfile.c b/plugins/imfile/imfile.c
index fdd0c5f0..7c588f90 100644
--- a/plugins/imfile/imfile.c
+++ b/plugins/imfile/imfile.c
@@ -46,6 +46,7 @@
#include "glbl.h"
#include "datetime.h"
#include "unicode-helper.h"
+#include "prop.h"
MODULE_TYPE_INPUT /* must be present for input modules, do not remove */
@@ -57,6 +58,7 @@ DEFobjCurrIf(errmsg)
DEFobjCurrIf(glbl)
DEFobjCurrIf(datetime)
DEFobjCurrIf(strm)
+DEFobjCurrIf(prop)
typedef struct fileInfo_s {
uchar *pszFileName;
@@ -81,6 +83,7 @@ static int iFilPtr = 0; /* number of files to be monitored; pointer to next fre
#define MAX_INPUT_FILES 100
static fileInfo_t files[MAX_INPUT_FILES];
+static prop_t *pInputName = NULL; /* there is only one global inputName for all messages generated by this input */
/* enqueue the read file line as a message. The provided string is
* not freed - thuis must be done by the caller.
@@ -97,7 +100,7 @@ static rsRetVal enqLine(fileInfo_t *pInfo, cstr_t *cstrLine)
CHKiRet(msgConstruct(&pMsg));
MsgSetFlowControlType(pMsg, eFLOWCTL_FULL_DELAY);
- MsgSetInputNameStr(pMsg, UCHAR_CONSTANT("imfile"), sizeof("imfile")-1);
+ MsgSetInputName(pMsg, pInputName);
MsgSetRawMsg(pMsg, (char*)rsCStrGetSzStr(cstrLine), cstrLen(cstrLine));
MsgSetMSGoffs(pMsg, 0); /* we do not have a header... */
MsgSetHOSTNAME(pMsg, glbl.GetLocalHostName(), ustrlen(glbl.GetLocalHostName()));
@@ -336,6 +339,11 @@ CODESTARTwillRun
ABORT_FINALIZE(RS_RET_NO_RUN);
}
+ /* we need to create the inputName property (only once during our lifetime) */
+ CHKiRet(prop.Construct(&pInputName));
+ CHKiRet(prop.SetString(pInputName, UCHAR_CONSTANT("imfile"), sizeof("imfile") - 1));
+ CHKiRet(prop.ConstructFinalize(pInputName));
+
finalize_it:
ENDwillRun
@@ -391,6 +399,9 @@ CODESTARTafterRun
strm.Destruct(&(files[i].pStrm));
}
}
+
+ if(pInputName != NULL)
+ prop.Destruct(&pInputName);
ENDafterRun
@@ -405,6 +416,7 @@ CODESTARTmodExit
objRelease(datetime, CORE_COMPONENT);
objRelease(glbl, CORE_COMPONENT);
objRelease(errmsg, CORE_COMPONENT);
+ objRelease(prop, CORE_COMPONENT);
ENDmodExit
@@ -515,6 +527,7 @@ CODEmodInit_QueryRegCFSLineHdlr
CHKiRet(objUse(glbl, CORE_COMPONENT));
CHKiRet(objUse(datetime, CORE_COMPONENT));
CHKiRet(objUse(strm, CORE_COMPONENT));
+ CHKiRet(objUse(prop, CORE_COMPONENT));
CHKiRet(omsdRegCFSLineHdlr((uchar *)"inputfilename", 0, eCmdHdlrGetWord,
NULL, &pszFileName, STD_LOADABLE_MODULE_ID));
diff --git a/plugins/imklog/imklog.c b/plugins/imklog/imklog.c
index 21744c4b..10cc8b14 100644
--- a/plugins/imklog/imklog.c
+++ b/plugins/imklog/imklog.c
@@ -18,7 +18,7 @@
* Please note that this file replaces the klogd daemon that was
* also present in pre-v3 versions of rsyslog.
*
- * Copyright (C) 2008 by Rainer Gerhards and Adiscon GmbH
+ * Copyright (C) 2008, 2009 by Rainer Gerhards and Adiscon GmbH
*
* This file is part of rsyslog.
*
@@ -54,6 +54,7 @@
#include "datetime.h"
#include "imklog.h"
#include "glbl.h"
+#include "prop.h"
#include "unicode-helper.h"
MODULE_TYPE_INPUT
@@ -62,6 +63,7 @@ MODULE_TYPE_INPUT
DEF_IMOD_STATIC_DATA
DEFobjCurrIf(datetime)
DEFobjCurrIf(glbl)
+DEFobjCurrIf(prop)
/* configuration settings */
int dbgPrintSymbols = 0; /* this one is extern so the helpers can access it! */
@@ -81,6 +83,8 @@ char *symfile = NULL;
int console_log_level = -1;
+static prop_t *pInputName = NULL; /* there is only one global inputName for all messages generated by this module */
+
/* enqueue the the kernel message into the message queue.
* The provided msg string is not freed - thus must be done
* by the caller.
@@ -97,7 +101,7 @@ enqMsg(uchar *msg, uchar* pszTag, int iFacility, int iSeverity)
CHKiRet(msgConstruct(&pMsg));
MsgSetFlowControlType(pMsg, eFLOWCTL_LIGHT_DELAY);
- MsgSetInputNameStr(pMsg, UCHAR_CONSTANT("imklog"), sizeof("imklog")-1);
+ MsgSetInputName(pMsg, pInputName);
MsgSetRawMsgWOSize(pMsg, (char*)msg);
MsgSetMSGoffs(pMsg, 0); /* we do not have a header... */
MsgSetRcvFrom(pMsg, glbl.GetLocalHostName());
@@ -230,13 +234,22 @@ ENDrunInput
BEGINwillRun
CODESTARTwillRun
+ /* we need to create the inputName property (only once during our lifetime) */
+ CHKiRet(prop.Construct(&pInputName));
+ CHKiRet(prop.SetString(pInputName, UCHAR_CONSTANT("imklog"), sizeof("imklog") - 1));
+ CHKiRet(prop.ConstructFinalize(pInputName));
+
iRet = klogWillRun();
+finalize_it:
ENDwillRun
BEGINafterRun
CODESTARTafterRun
iRet = klogAfterRun();
+
+ if(pInputName != NULL)
+ prop.Destruct(&pInputName);
ENDafterRun
@@ -245,6 +258,7 @@ CODESTARTmodExit
/* release objects we used */
objRelease(glbl, CORE_COMPONENT);
objRelease(datetime, CORE_COMPONENT);
+ objRelease(prop, CORE_COMPONENT);
if(pszPath != NULL)
free(pszPath);
ENDmodExit
@@ -277,6 +291,7 @@ CODESTARTmodInit
CODEmodInit_QueryRegCFSLineHdlr
CHKiRet(objUse(datetime, CORE_COMPONENT));
CHKiRet(objUse(glbl, CORE_COMPONENT));
+ CHKiRet(objUse(prop, CORE_COMPONENT));
iFacilIntMsg = klogFacilIntMsg();
diff --git a/plugins/imrelp/imrelp.c b/plugins/imrelp/imrelp.c
index 2255e643..b9e7b2f8 100644
--- a/plugins/imrelp/imrelp.c
+++ b/plugins/imrelp/imrelp.c
@@ -4,7 +4,7 @@
*
* File begun on 2008-03-13 by RGerhards
*
- * Copyright 2008 Rainer Gerhards and Adiscon GmbH.
+ * Copyright 2008, 2009 Rainer Gerhards and Adiscon GmbH.
*
* This file is part of rsyslog.
*
@@ -43,15 +43,19 @@
#include "module-template.h"
#include "net.h"
#include "msg.h"
+#include "unicode-helper.h"
+#include "prop.h"
MODULE_TYPE_INPUT
/* static data */
DEF_IMOD_STATIC_DATA
DEFobjCurrIf(net)
+DEFobjCurrIf(prop)
/* Module static data */
static relpEngine_t *pRelpEngine; /* our relp engine */
+static prop_t *pInputName = NULL; /* there is only one global inputName for all messages generated by this module */
/* config settings */
@@ -85,7 +89,7 @@ onSyslogRcv(uchar *pHostname, uchar __attribute__((unused)) *pIP, uchar *pMsg, s
{
DEFiRet;
parseAndSubmitMessage(pHostname, (uchar*) "[unset]", pMsg, lenMsg, PARSE_HOSTNAME,
- eFLOWCTL_LIGHT_DELAY, (uchar*)"imrelp", NULL, 0);
+ eFLOWCTL_LIGHT_DELAY, pInputName, NULL, 0);
RETiRet;
}
@@ -130,6 +134,11 @@ CODESTARTwillRun
//net.PrintAllowedSenders(2); /* TCP */
if(pRelpEngine == NULL)
ABORT_FINALIZE(RS_RET_NO_RUN);
+
+ /* we need to create the inputName property (only once during our lifetime) */
+ CHKiRet(prop.Construct(&pInputName));
+ CHKiRet(prop.SetString(pInputName, UCHAR_CONSTANT("imrelp"), sizeof("imrelp") - 1));
+ CHKiRet(prop.ConstructFinalize(pInputName));
finalize_it:
ENDwillRun
@@ -143,6 +152,9 @@ CODESTARTafterRun
net.pAllowedSenders_TCP = NULL;
}
#endif
+
+ if(pInputName != NULL)
+ prop.Destruct(&pInputName);
ENDafterRun
@@ -152,6 +164,7 @@ CODESTARTmodExit
iRet = relpEngineDestruct(&pRelpEngine);
/* release objects we used */
+ objRelease(prop, CORE_COMPONENT);
objRelease(net, LM_NET_FILENAME);
ENDmodExit
@@ -177,6 +190,7 @@ CODESTARTmodInit
CODEmodInit_QueryRegCFSLineHdlr
pRelpEngine = NULL;
/* request objects we use */
+ CHKiRet(objUse(prop, CORE_COMPONENT));
CHKiRet(objUse(net, LM_NET_FILENAME));
/* register config file handlers */
diff --git a/plugins/imudp/imudp.c b/plugins/imudp/imudp.c
index 828b9636..dcdec1fc 100644
--- a/plugins/imudp/imudp.c
+++ b/plugins/imudp/imudp.c
@@ -245,7 +245,6 @@ processSocket(int fd, struct sockaddr_storage *frominetPrev, int *pbIsPermitted,
/* we now create our own message object and submit it to the queue */
CHKiRet(msgConstructWithTime(&pMsg, &stTime, ttGenTime));
MsgSetRawMsg(pMsg, (char*)pRcvBuf, lenRcvBuf);
- prop.AddRef(pInputName);
MsgSetInputName(pMsg, pInputName);
MsgSetFlowControlType(pMsg, eFLOWCTL_NO_DELAY);
pMsg->msgFlags = NEEDS_PARSING | PARSE_HOSTNAME;
@@ -346,7 +345,6 @@ CODESTARTwillRun
CHKiRet(prop.Construct(&pInputName));
CHKiRet(prop.SetString(pInputName, UCHAR_CONSTANT("imudp"), sizeof("imudp") - 1));
CHKiRet(prop.ConstructFinalize(pInputName));
- prop.AddRef(pInputName);
net.PrintAllowedSenders(1); /* UDP */
diff --git a/plugins/imuxsock/imuxsock.c b/plugins/imuxsock/imuxsock.c
index 1d88a2b5..424d0904 100644
--- a/plugins/imuxsock/imuxsock.c
+++ b/plugins/imuxsock/imuxsock.c
@@ -37,12 +37,14 @@
#include <sys/un.h>
#include "dirty.h"
#include "cfsysline.h"
+#include "unicode-helper.h"
#include "module-template.h"
#include "srUtils.h"
#include "errmsg.h"
#include "net.h"
#include "glbl.h"
#include "msg.h"
+#include "prop.h"
MODULE_TYPE_INPUT
@@ -66,7 +68,9 @@ MODULE_TYPE_INPUT
DEF_IMOD_STATIC_DATA
DEFobjCurrIf(errmsg)
DEFobjCurrIf(glbl)
+DEFobjCurrIf(prop)
+static prop_t *pInputName = NULL; /* our inputName currently is always "imudp", and this will hold it */
static int startIndexUxLocalSockets; /* process funix from that index on (used to
* suppress local logging. rgerhards 2005-08-01
* read-only after startup
@@ -223,7 +227,7 @@ static rsRetVal readSocket(int fd, int iSock)
parseAndSubmitMessage(funixHName[iSock] == NULL ? glbl.GetLocalHostName() : funixHName[iSock],
(uchar*)"127.0.0.1", pRcv,
iRcvd, funixParseHost[iSock] ? (funixFlags[iSock] | PARSE_HOSTNAME) : funixFlags[iSock],
- funixFlowCtl[iSock], (uchar*)"imuxsock", NULL, 0);
+ funixFlowCtl[iSock], pInputName, NULL, 0);
} else if (iRcvd < 0 && errno != EINTR) {
char errStr[1024];
rs_strerror_r(errno, errStr, sizeof(errStr));
@@ -306,7 +310,12 @@ CODESTARTwillRun
dbgprintf("Opened UNIX socket '%s' (fd %d).\n", funixn[i], funix[i]);
}
- RETiRet;
+ /* we need to create the inputName property (only once during our lifetime) */
+ CHKiRet(prop.Construct(&pInputName));
+ CHKiRet(prop.SetString(pInputName, UCHAR_CONSTANT("imudp"), sizeof("imudp") - 1));
+ CHKiRet(prop.ConstructFinalize(pInputName));
+
+finalize_it:
ENDwillRun
@@ -332,6 +341,9 @@ CODESTARTafterRun
discardFunixn();
nfunix = 1;
+
+ if(pInputName != NULL)
+ prop.Destruct(&pInputName);
ENDafterRun
@@ -339,6 +351,7 @@ BEGINmodExit
CODESTARTmodExit
objRelease(glbl, CORE_COMPONENT);
objRelease(errmsg, CORE_COMPONENT);
+ objRelease(prop, CORE_COMPONENT);
ENDmodExit
@@ -375,6 +388,7 @@ CODESTARTmodInit
CODEmodInit_QueryRegCFSLineHdlr
CHKiRet(objUse(errmsg, CORE_COMPONENT));
CHKiRet(objUse(glbl, CORE_COMPONENT));
+ CHKiRet(objUse(prop, CORE_COMPONENT));
dbgprintf("imuxsock version %s initializing\n", PACKAGE_VERSION);