summaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2009-05-22 17:23:08 +0200
committerRainer Gerhards <rgerhards@adiscon.com>2009-05-22 17:23:08 +0200
commit0fa5486a4ace7a9be82b37979cf4693aff237340 (patch)
tree6c1b10bca2629acc171c1bb8719ef9fe6202a5c0 /plugins
parent737614054caadf8340b638b368d43f55b7bb3741 (diff)
parentaba90e82484118f3568ec51c01de5ba845da589a (diff)
downloadrsyslog-0fa5486a4ace7a9be82b37979cf4693aff237340.tar.gz
rsyslog-0fa5486a4ace7a9be82b37979cf4693aff237340.tar.xz
rsyslog-0fa5486a4ace7a9be82b37979cf4693aff237340.zip
Merge branch 'master' into ultra-reliable
Conflicts: runtime/rsyslog.h tests/Makefile.am tools/syslogd.c
Diffstat (limited to 'plugins')
-rw-r--r--plugins/imdiag/imdiag.c36
-rw-r--r--plugins/imfile/imfile.c5
-rw-r--r--plugins/imgssapi/imgssapi.c4
-rw-r--r--plugins/imklog/imklog.c7
-rw-r--r--plugins/imtcp/imtcp.c35
-rw-r--r--plugins/imudp/imudp.c5
6 files changed, 52 insertions, 40 deletions
diff --git a/plugins/imdiag/imdiag.c b/plugins/imdiag/imdiag.c
index 3cd2dcf8..90c5d9ee 100644
--- a/plugins/imdiag/imdiag.c
+++ b/plugins/imdiag/imdiag.c
@@ -7,7 +7,7 @@
*
* File begun on 2008-07-25 by RGerhards
*
- * Copyright 2008 Rainer Gerhards and Adiscon GmbH.
+ * Copyright 2008, 2009 Rainer Gerhards and Adiscon GmbH.
*
* This file is part of rsyslog.
*
@@ -48,6 +48,7 @@
#include "module-template.h"
#include "net.h"
#include "netstrm.h"
+#include "netstrms.h"
#include "errmsg.h"
MODULE_TYPE_INPUT
@@ -56,12 +57,13 @@ MODULE_TYPE_INPUT
DEF_IMOD_STATIC_DATA
DEFobjCurrIf(net)
DEFobjCurrIf(netstrm)
+DEFobjCurrIf(netstrms)
DEFobjCurrIf(errmsg)
/* Module static data */
netstrms_t *pNS; /**< pointer to network stream subsystem */
-netstrm_t **ppLstn[10]; /**< our netstream listners */
-int iLstnMax = 0; /**< max nbr of listeners currently supported */
+netstrm_t *arrLstn[10]; /**< our netstream listners */
+int iLstnMax = 0; /**< max nbr of listeners currently supported */
/* config settings */
@@ -71,16 +73,16 @@ int iLstnMax = 0; /**< max nbr of listeners currently supported */
* invoked from the netstrm class. -- rgerhards, 2008-04-23
*/
static rsRetVal
-addTcpLstn(void *pUsr, netstrm_t *pLstn)
+addTcpLstn(netstrm_t *pLstn)
{
DEFiRet;
ISOBJ_TYPE_assert(pLstn, netstrm);
- if(iLstnMax >= sizeof(ppLstn)/sizeof(netstrm_t))
+ if((unsigned)iLstnMax >= sizeof(arrLstn)/sizeof(netstrm_t*))
ABORT_FINALIZE(RS_RET_MAX_LSTN_REACHED);
- ppLstn[pThis->iLstnMax] = pLstn;
+ arrLstn[iLstnMax] = pLstn;
++iLstnMax;
finalize_it:
@@ -100,15 +102,15 @@ initNetstrm(void)
//CHKiRet(netstrms.SetDrvrAuthMode(pThis->pNS, pThis->pszDrvrAuthMode));
//CHKiRet(netstrms.SetDrvrPermPeers(pThis->pNS, pThis->pPermPeers));
// TODO: set driver!
- CHKiRet(netstrms.ConstructFinalize(pThis->pNS));
+ CHKiRet(netstrms.ConstructFinalize(&pNS));
/* set up listeners */
- CHKiRet(netstrm.LstnInit(pNS, NULL, addTcpLstn, "127.0.0.1", "44514", 1));
+ CHKiRet(netstrm.LstnInit(pNS, NULL, addTcpLstn, "127.0.0.1", (uchar*)"44514", 1));
finalize_it:
if(iRet != RS_RET_OK) {
- if(pThis->pNS != NULL)
- netstrms.Destruct(&pThis->pNS);
+ if(pNS != NULL)
+ netstrms.Destruct(&pNS);
}
RETiRet;
}
@@ -130,11 +132,12 @@ ENDwillRun
BEGINafterRun
+ int i;
CODESTARTafterRun
/* do cleanup here */
/* finally close our listen streams */
for(i = 0 ; i < iLstnMax ; ++i) {
- netstrm.Destruct(ppLstn + i);
+ netstrm.Destruct(arrLstn[i]);
}
/* destruct netstream subsystem */
@@ -146,7 +149,8 @@ BEGINmodExit
CODESTARTmodExit
/* release objects we used */
objRelease(net, LM_NET_FILENAME);
- objRelease(netstrm, LM_NETSTRMS_FILENAME);
+ objRelease(netstrm, DONT_LOAD_LIB);
+ objRelease(netstrms, LM_NETSTRMS_FILENAME);
objRelease(errmsg, CORE_COMPONENT);
ENDmodExit
@@ -169,14 +173,14 @@ BEGINmodInit()
CODESTARTmodInit
*ipIFVersProvided = CURR_MOD_IF_VERSION; /* we only support the current interface specification */
CODEmodInit_QueryRegCFSLineHdlr
- pOurTcpsrv = NULL;
/* request objects we use */
CHKiRet(objUse(net, LM_NET_FILENAME));
- CHKiRet(objUse(netstrm, LM_NETSTRMS_FILENAME));
+ CHKiRet(objUse(netstrms, LM_NETSTRMS_FILENAME));
+ CHKiRet(objUse(netstrm, DONT_LOAD_LIB));
CHKiRet(objUse(errmsg, CORE_COMPONENT));
-#if 0
/* register config file handlers */
+#if 0
CHKiRet(omsdRegCFSLineHdlr((uchar *)"inputtcpserverrun", 0, eCmdHdlrGetWord,
addTCPListener, NULL, STD_LOADABLE_MODULE_ID));
CHKiRet(omsdRegCFSLineHdlr((uchar *)"inputtcpmaxsessions", 0, eCmdHdlrInt,
@@ -187,9 +191,9 @@ CODEmodInit_QueryRegCFSLineHdlr
eCmdHdlrGetWord, NULL, &pszStrmDrvrAuthMode, STD_LOADABLE_MODULE_ID));
CHKiRet(omsdRegCFSLineHdlr((uchar *)"inputtcpserverstreamdriverpermittedpeer", 0,
eCmdHdlrGetWord, setPermittedPeer, NULL, STD_LOADABLE_MODULE_ID));
+#endif
CHKiRet(omsdRegCFSLineHdlr((uchar *)"resetconfigvariables", 1, eCmdHdlrCustomHandler,
resetConfigVariables, NULL, STD_LOADABLE_MODULE_ID));
-#endif
ENDmodInit
diff --git a/plugins/imfile/imfile.c b/plugins/imfile/imfile.c
index b0211bf6..92fd30c3 100644
--- a/plugins/imfile/imfile.c
+++ b/plugins/imfile/imfile.c
@@ -45,6 +45,7 @@
#include "errmsg.h"
#include "glbl.h"
#include "datetime.h"
+#include "unicode-helper.h"
MODULE_TYPE_INPUT /* must be present for input modules, do not remove */
@@ -94,11 +95,11 @@ static rsRetVal enqLine(fileInfo_t *pInfo, cstr_t *cstrLine)
CHKiRet(msgConstruct(&pMsg));
MsgSetFlowControlType(pMsg, eFLOWCTL_FULL_DELAY);
- MsgSetInputName(pMsg, "imfile");
+ MsgSetInputName(pMsg, UCHAR_CONSTANT("imfile"));
MsgSetUxTradMsg(pMsg, (char*)rsCStrGetSzStr(cstrLine));
MsgSetRawMsg(pMsg, (char*)rsCStrGetSzStr(cstrLine));
MsgSetMSG(pMsg, (char*)rsCStrGetSzStr(cstrLine));
- MsgSetHOSTNAME(pMsg, (char*)glbl.GetLocalHostName());
+ MsgSetHOSTNAME(pMsg, glbl.GetLocalHostName());
MsgSetTAG(pMsg, (char*)pInfo->pszTag);
pMsg->iFacility = LOG_FAC(pInfo->iFacility);
pMsg->iSeverity = LOG_PRI(pInfo->iSeverity);
diff --git a/plugins/imgssapi/imgssapi.c b/plugins/imgssapi/imgssapi.c
index b9d7dfe3..d8791880 100644
--- a/plugins/imgssapi/imgssapi.c
+++ b/plugins/imgssapi/imgssapi.c
@@ -9,7 +9,7 @@
* NOTE: read comments in module-template.h to understand how this file
* works!
*
- * Copyright 2007 Rainer Gerhards and Adiscon GmbH.
+ * Copyright 2007, 2009 Rainer Gerhards and Adiscon GmbH.
*
* This file is part of rsyslog.
*
@@ -330,7 +330,7 @@ addGSSListener(void __attribute__((unused)) *pVal, uchar *pNewVal)
CHKiRet(tcpsrv.SetCBOnSessAccept(pOurTcpsrv, onSessAccept));
CHKiRet(tcpsrv.SetCBOnRegularClose(pOurTcpsrv, onRegularClose));
CHKiRet(tcpsrv.SetCBOnErrClose(pOurTcpsrv, onErrClose));
- tcpsrv.configureTCPListen(pOurTcpsrv, (char *) pNewVal);
+ tcpsrv.configureTCPListen(pOurTcpsrv, pNewVal);
CHKiRet(tcpsrv.ConstructFinalize(pOurTcpsrv));
}
diff --git a/plugins/imklog/imklog.c b/plugins/imklog/imklog.c
index 20bc34ab..ecb6c100 100644
--- a/plugins/imklog/imklog.c
+++ b/plugins/imklog/imklog.c
@@ -53,6 +53,7 @@
#include "datetime.h"
#include "imklog.h"
#include "glbl.h"
+#include "unicode-helper.h"
MODULE_TYPE_INPUT
@@ -94,14 +95,14 @@ enqMsg(uchar *msg, uchar* pszTag, int iFacility, int iSeverity)
CHKiRet(msgConstruct(&pMsg));
MsgSetFlowControlType(pMsg, eFLOWCTL_LIGHT_DELAY);
- MsgSetInputName(pMsg, "imklog");
+ MsgSetInputName(pMsg, UCHAR_CONSTANT("imklog"));
MsgSetRawMsg(pMsg, (char*)msg);
MsgSetUxTradMsg(pMsg, (char*)msg);
MsgSetRawMsg(pMsg, (char*)msg);
MsgSetMSG(pMsg, (char*)msg);
- MsgSetRcvFrom(pMsg, (char*)glbl.GetLocalHostName());
+ MsgSetRcvFrom(pMsg, glbl.GetLocalHostName());
MsgSetRcvFromIP(pMsg, (uchar*)"127.0.0.1");
- MsgSetHOSTNAME(pMsg, (char*)glbl.GetLocalHostName());
+ MsgSetHOSTNAME(pMsg, glbl.GetLocalHostName());
MsgSetTAG(pMsg, (char*)pszTag);
pMsg->iFacility = LOG_FAC(iFacility);
pMsg->iSeverity = LOG_PRI(iSeverity);
diff --git a/plugins/imtcp/imtcp.c b/plugins/imtcp/imtcp.c
index 9883fa89..acac38b2 100644
--- a/plugins/imtcp/imtcp.c
+++ b/plugins/imtcp/imtcp.c
@@ -3,7 +3,7 @@
*
* File begun on 2007-12-21 by RGerhards (extracted from syslogd.c)
*
- * Copyright 2007 Rainer Gerhards and Adiscon GmbH.
+ * Copyright 2007, 2009 Rainer Gerhards and Adiscon GmbH.
*
* This file is part of rsyslog.
*
@@ -56,6 +56,7 @@
#include "dirty.h"
#include "cfsysline.h"
#include "module-template.h"
+#include "unicode-helper.h"
#include "net.h"
#include "netstrm.h"
#include "errmsg.h"
@@ -91,7 +92,7 @@ static int
isPermittedHost(struct sockaddr *addr, char *fromHostFQDN, void __attribute__((unused)) *pUsrSrv,
void __attribute__((unused)) *pUsrSess)
{
- return net.isAllowedSender((uchar*) "TCP", addr, fromHostFQDN);
+ return net.isAllowedSender(UCHAR_CONSTANT("TCP"), addr, fromHostFQDN);
}
@@ -169,7 +170,6 @@ static rsRetVal addTCPListener(void __attribute__((unused)) *pVal, uchar *pNewVa
CHKiRet(tcpsrv.SetCBOnRegularClose(pOurTcpsrv, onRegularClose));
CHKiRet(tcpsrv.SetCBOnErrClose(pOurTcpsrv, onErrClose));
CHKiRet(tcpsrv.SetDrvrMode(pOurTcpsrv, iStrmDrvrMode));
- CHKiRet(tcpsrv.SetInputName(pOurTcpsrv, pszInputName == NULL ? (uchar*)"imtcp" : pszInputName));
CHKiRet(tcpsrv.SetAddtlFrameDelim(pOurTcpsrv, iAddtlFrameDelim));
/* now set optional params, but only if they were actually configured */
if(pszStrmDrvrAuthMode != NULL) {
@@ -178,11 +178,14 @@ static rsRetVal addTCPListener(void __attribute__((unused)) *pVal, uchar *pNewVa
if(pPermPeersRoot != NULL) {
CHKiRet(tcpsrv.SetDrvrPermPeers(pOurTcpsrv, pPermPeersRoot));
}
- /* most params set, now start listener */
- tcpsrv.configureTCPListen(pOurTcpsrv, (char *) pNewVal);
- CHKiRet(tcpsrv.ConstructFinalize(pOurTcpsrv));
}
+dbgprintf("XXX: try add listen port %s\n", pNewVal);
+ /* initialized, now add socket */
+ CHKiRet(tcpsrv.SetInputName(pOurTcpsrv, pszInputName == NULL ?
+ UCHAR_CONSTANT("imtcp") : pszInputName));
+ tcpsrv.configureTCPListen(pOurTcpsrv, pNewVal);
+
finalize_it:
if(iRet != RS_RET_OK) {
errmsg.LogError(0, NO_ERRCODE, "error %d trying to add listener", iRet);
@@ -199,7 +202,9 @@ CODESTARTrunInput
/* TODO: we must be careful to start the listener here. Currently, tcpsrv.c seems to
* do that in ConstructFinalize
*/
+ CHKiRet(tcpsrv.ConstructFinalize(pOurTcpsrv));
iRet = tcpsrv.Run(pOurTcpsrv);
+finalize_it:
ENDrunInput
@@ -217,7 +222,7 @@ ENDwillRun
BEGINafterRun
CODESTARTafterRun
/* do cleanup here */
- net.clearAllowedSenders((uchar*)"TCP");
+ net.clearAllowedSenders(UCHAR_CONSTANT("TCP"));
ENDafterRun
@@ -273,21 +278,21 @@ CODEmodInit_QueryRegCFSLineHdlr
CHKiRet(objUse(errmsg, CORE_COMPONENT));
/* register config file handlers */
- CHKiRet(omsdRegCFSLineHdlr((uchar *)"inputtcpserverrun", 0, eCmdHdlrGetWord,
+ CHKiRet(omsdRegCFSLineHdlr(UCHAR_CONSTANT("inputtcpserverrun"), 0, eCmdHdlrGetWord,
addTCPListener, NULL, STD_LOADABLE_MODULE_ID));
- CHKiRet(omsdRegCFSLineHdlr((uchar *)"inputtcpmaxsessions", 0, eCmdHdlrInt,
+ CHKiRet(omsdRegCFSLineHdlr(UCHAR_CONSTANT("inputtcpmaxsessions"), 0, eCmdHdlrInt,
NULL, &iTCPSessMax, STD_LOADABLE_MODULE_ID));
- CHKiRet(omsdRegCFSLineHdlr((uchar *)"inputtcpserverstreamdrivermode", 0,
+ CHKiRet(omsdRegCFSLineHdlr(UCHAR_CONSTANT("inputtcpserverstreamdrivermode"), 0,
eCmdHdlrInt, NULL, &iStrmDrvrMode, STD_LOADABLE_MODULE_ID));
- CHKiRet(omsdRegCFSLineHdlr((uchar *)"inputtcpserverstreamdriverauthmode", 0,
+ CHKiRet(omsdRegCFSLineHdlr(UCHAR_CONSTANT("inputtcpserverstreamdriverauthmode"), 0,
eCmdHdlrGetWord, NULL, &pszStrmDrvrAuthMode, STD_LOADABLE_MODULE_ID));
- CHKiRet(omsdRegCFSLineHdlr((uchar *)"inputtcpserverstreamdriverpermittedpeer", 0,
+ CHKiRet(omsdRegCFSLineHdlr(UCHAR_CONSTANT("inputtcpserverstreamdriverpermittedpeer"), 0,
eCmdHdlrGetWord, setPermittedPeer, NULL, STD_LOADABLE_MODULE_ID));
- CHKiRet(omsdRegCFSLineHdlr((uchar *)"inputtcpserveraddtlframedelimiter", 0, eCmdHdlrInt,
+ CHKiRet(omsdRegCFSLineHdlr(UCHAR_CONSTANT("inputtcpserveraddtlframedelimiter"), 0, eCmdHdlrInt,
NULL, &iAddtlFrameDelim, STD_LOADABLE_MODULE_ID));
- CHKiRet(omsdRegCFSLineHdlr((uchar *)"inputtcpserverinputname", 0,
+ CHKiRet(omsdRegCFSLineHdlr(UCHAR_CONSTANT("inputtcpserverinputname"), 0,
eCmdHdlrGetWord, NULL, &pszInputName, STD_LOADABLE_MODULE_ID));
- CHKiRet(omsdRegCFSLineHdlr((uchar *)"resetconfigvariables", 1, eCmdHdlrCustomHandler,
+ CHKiRet(omsdRegCFSLineHdlr(UCHAR_CONSTANT("resetconfigvariables"), 1, eCmdHdlrCustomHandler,
resetConfigVariables, NULL, STD_LOADABLE_MODULE_ID));
ENDmodInit
diff --git a/plugins/imudp/imudp.c b/plugins/imudp/imudp.c
index c7e8c1d4..f3448095 100644
--- a/plugins/imudp/imudp.c
+++ b/plugins/imudp/imudp.c
@@ -43,6 +43,7 @@
#include "msg.h"
#include "parser.h"
#include "datetime.h"
+#include "unicode-helper.h"
MODULE_TYPE_INPUT
@@ -219,11 +220,11 @@ processSocket(int fd, struct sockaddr_storage *frominetPrev, int *pbIsPermitted,
CHKmalloc(pMsg->pszRawMsg = malloc(sizeof(uchar)* lenRcvBuf));
memcpy(pMsg->pszRawMsg, pRcvBuf, lenRcvBuf);
pMsg->iLenRawMsg = lenRcvBuf;
- MsgSetInputName(pMsg, "imudp");
+ MsgSetInputName(pMsg, UCHAR_CONSTANT("imudp"));
MsgSetFlowControlType(pMsg, eFLOWCTL_NO_DELAY);
pMsg->msgFlags = NEEDS_PARSING | PARSE_HOSTNAME;
pMsg->bParseHOSTNAME = 1;
- MsgSetRcvFrom(pMsg, (char*)fromHost);
+ MsgSetRcvFrom(pMsg, fromHost);
CHKiRet(MsgSetRcvFromIP(pMsg, fromHostIP));
CHKiRet(submitMsg(pMsg));
}