mirror of
https://github.com/rsyslog/rsyslog.git
synced 2025-12-17 09:20:41 +01:00
Merge branch 'v5-stable-newstats'
Conflicts: action.c configure.ac doc/imuxsock.html plugins/imklog/imklog.c plugins/imptcp/imptcp.c plugins/imtcp/imtcp.c plugins/imudp/imudp.c plugins/imuxsock/imuxsock.c runtime/glbl.c runtime/glbl.h runtime/net.c runtime/ruleset.c tcpsrv.h tools/syslogd.c
This commit is contained in:
commit
d6da57ae03
@ -1,3 +1,11 @@
|
||||
- added configuration directive to disable octet-counted framing
|
||||
for imtcp, directive is $InputTCPServerSupportOctetCountedFraming
|
||||
for imptcp, directive is $InputPTCPServerSupportOctetCountedFraming
|
||||
- added capability to use a local interface IP address as fromhost-ip for
|
||||
locally originating messages. New directive $LocalHostIPIF
|
||||
- added configuration directives to customize queue light delay marks
|
||||
$MainMsgQueueLightDelayMark, $ActionQueueLightDelayMark; both
|
||||
specify number of messages starting at which a delay happens.
|
||||
---------------------------------------------------------------------------
|
||||
Version 6.3.8 [DEVEL] 2012-02-??
|
||||
- added $PStatJSON directive to permit stats records in JSON format
|
||||
|
||||
@ -36,6 +36,11 @@ processing.<span style="font-weight: bold;"></span></li>
|
||||
<li><span style="font-weight: bold;"></span>$DebugPrintKernelSymbols
|
||||
[on/<b>off</b>]<br>
|
||||
Linux only, ignored on other platforms (but may be specified)</li>
|
||||
<li><b>$klogLocalIPIF</b> [interface name] - (available since 5.9.6) - if provided, the IP of the specified
|
||||
interface (e.g. "eth0") shall be used as fromhost-ip for imklog-originating messages.
|
||||
If this directive is not given OR the interface cannot be found (or has no IP address),
|
||||
the default of "127.0.0.1" is used.
|
||||
</li>
|
||||
<li>$klogSymbolLookup [on/<b>off</b>] --
|
||||
disables imklog kernel symbol translation (former klogd -x option). NOTE that
|
||||
this option is counter-productive on recent kernels (>= 2.6) because the
|
||||
|
||||
@ -43,6 +43,12 @@ very limited interest in fixing this issue. This directive <b>can not</b> fix th
|
||||
That would require much more code changes, which I was unable to do so far. Full details
|
||||
can be found at the <a href="http://www.rsyslog.com/Article321.phtml">Cisco tcp syslog anomaly</a>
|
||||
page.
|
||||
<li><b>$InputPTCPSupportOctetCountedFraming</b> <<b>on</b>|off><br>
|
||||
If set to "on", the legacy octed-counted framing (similar to RFC5425 framing) is
|
||||
activated. This is the default and should be left unchanged until you know
|
||||
very well what you do. It may be useful to turn it off, if you know this framing
|
||||
is not used and some senders emit multi-line messages into the message stream.
|
||||
</li>
|
||||
<li>$InputPTCPServerNotifyOnConnectionClose [on/<b>off</b>]<br>
|
||||
instructs imptcp to emit a message if the remote peer closes a connection.<br>
|
||||
<li><b>$InputPTCPServerKeepAlive</b> <on/<b>off</b>><br>
|
||||
|
||||
@ -86,6 +86,12 @@ listener. <id-string> semantics depend on the currently selected
|
||||
AuthMode and <a href="netstream.html">network stream driver</a>. PermittedPeers may not be set in anonymous modes.</li>
|
||||
<li><b>$InputTCPServerBindRuleset</b> <ruleset><br>
|
||||
Binds the listener to a specific <a href="multi_ruleset.html">ruleset</a>.</li>
|
||||
<li><b>$InputTCPSupportOctetCountedFraming</b> <<b>on</b>|off><br>
|
||||
If set to "on", the legacy octed-counted framing (similar to RFC5425 framing) is
|
||||
activated. This is the default and should be left unchanged until you know
|
||||
very well what you do. It may be useful to turn it off, if you know this framing
|
||||
is not used and some senders emit multi-line messages into the message stream.
|
||||
</li>
|
||||
</ul>
|
||||
<b>Caveats/Known Bugs:</b>
|
||||
<ul>
|
||||
|
||||
@ -76,6 +76,11 @@ burst in number of messages. Default is 200.
|
||||
<li><b>$IMUXSockRateLimitSeverity</b> [numerical severity] - specifies the severity of
|
||||
messages that shall be rate-limited.
|
||||
</li>
|
||||
<li><b>$IMUXSockLocalIPIF</b> [interface name] - (available since 5.9.6) - if provided, the IP of the specified
|
||||
interface (e.g. "eth0") shall be used as fromhost-ip for imuxsock-originating messages.
|
||||
If this directive is not given OR the interface cannot be found (or has no IP address),
|
||||
the default of "127.0.0.1" is used.
|
||||
</li>
|
||||
<li><b>$InputUnixListenSocketUsePIDFromSystem</b> [on/<b>off</b>] - specifies if the pid being logged shall
|
||||
be obtained from the log socket itself. If so, the TAG part of the message is rewritten.
|
||||
It is recommended to turn this option on, but the default is "off" to keep compatible
|
||||
@ -181,8 +186,10 @@ $SystemLogSocketAnnotate on
|
||||
<p>[<a href="rsyslog_conf.html">rsyslog.conf overview</a>]
|
||||
[<a href="manual.html">manual index</a>] [<a href="http://www.rsyslog.com/">rsyslog site</a>]</p>
|
||||
<p><font size="2">This documentation is part of the
|
||||
<a href="http://www.rsyslog.com/">rsyslog</a> project.<br>
|
||||
Copyright © 2008-2011 by <a href="http://www.gerhards.net/rainer">Rainer Gerhards</a> and
|
||||
<a href="http://www.rsyslog.com/">rsyslog</a>
|
||||
project.<br>
|
||||
Copyright © 2008-2012 by <a href="http://www.gerhards.net/rainer">Rainer
|
||||
Gerhards</a> and
|
||||
<a href="http://www.adiscon.com/">Adiscon</a>.
|
||||
Released under the GNU GPL version 3 or higher.</font></p>
|
||||
</body></html>
|
||||
|
||||
@ -302,6 +302,19 @@ the value, the less precise the timestamp.
|
||||
<li><b>$Sleep</b> <seconds> - puts the rsyslog main thread to sleep for the specified
|
||||
number of seconds immediately when the directive is encountered. You should have a
|
||||
good reason for using this directive!</li>
|
||||
<li><b>$LocalHostIPIF</b> <interface name> - (available since 5.9.6) - if provided, the IP of the specified
|
||||
interface (e.g. "eth0") shall be used as fromhost-ip for locall-originating messages.
|
||||
If this directive is not given OR the interface cannot be found (or has no IP address),
|
||||
the default of "127.0.0.1" is used. Note that this directive can be given only
|
||||
once. Trying to reset will result in an error message and the new value will
|
||||
be ignored. Please note that modules must have support for obtaining the local
|
||||
IP address set via this directive. While this is the case for rsyslog-provided
|
||||
modules, it may not always be the case for contributed plugins.
|
||||
<br><b>Important:</b> This directive shall be placed <b>right at the top of
|
||||
rsyslog.conf</b>. Otherwise, if error messages are triggered before this directive
|
||||
is processed, rsyslog will fix the local host IP to "127.0.0.1", what than can
|
||||
not be reset.
|
||||
</li>
|
||||
<li><a href="rsconf1_umask.html">$UMASK</a></li>
|
||||
</ul>
|
||||
<p><b>Where <size_nbr> is specified above,</b>
|
||||
|
||||
@ -381,7 +381,8 @@ static rsRetVal addTCPListener(void __attribute__((unused)) *pVal, uchar *pNewVa
|
||||
/* initialized, now add socket */
|
||||
CHKiRet(tcpsrv.SetInputName(pOurTcpsrv, pszInputName == NULL ?
|
||||
UCHAR_CONSTANT("imdiag") : pszInputName));
|
||||
tcpsrv.configureTCPListen(pOurTcpsrv, pNewVal);
|
||||
/* we support octect-cuunted frame (constant 1 below) */
|
||||
tcpsrv.configureTCPListen(pOurTcpsrv, pNewVal, 1);
|
||||
|
||||
finalize_it:
|
||||
if(iRet != RS_RET_OK) {
|
||||
|
||||
@ -340,7 +340,7 @@ addGSSListener(void __attribute__((unused)) *pVal, uchar *pNewVal)
|
||||
CHKiRet(tcpsrv.SetCBOnRegularClose(pOurTcpsrv, onRegularClose));
|
||||
CHKiRet(tcpsrv.SetCBOnErrClose(pOurTcpsrv, onErrClose));
|
||||
CHKiRet(tcpsrv.SetInputName(pOurTcpsrv, UCHAR_CONSTANT("imgssapi")));
|
||||
tcpsrv.configureTCPListen(pOurTcpsrv, pNewVal);
|
||||
tcpsrv.configureTCPListen(pOurTcpsrv, pNewVal, 1);
|
||||
CHKiRet(tcpsrv.ConstructFinalize(pOurTcpsrv));
|
||||
}
|
||||
|
||||
|
||||
@ -47,6 +47,7 @@
|
||||
#include <stdarg.h>
|
||||
#include <ctype.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
#include "dirty.h"
|
||||
#include "cfsysline.h"
|
||||
@ -55,6 +56,7 @@
|
||||
#include "module-template.h"
|
||||
#include "datetime.h"
|
||||
#include "imklog.h"
|
||||
#include "net.h"
|
||||
#include "glbl.h"
|
||||
#include "prop.h"
|
||||
#include "unicode-helper.h"
|
||||
@ -68,6 +70,7 @@ DEF_IMOD_STATIC_DATA
|
||||
DEFobjCurrIf(datetime)
|
||||
DEFobjCurrIf(glbl)
|
||||
DEFobjCurrIf(prop)
|
||||
DEFobjCurrIf(net)
|
||||
|
||||
/* config settings */
|
||||
typedef struct configSettings_s {
|
||||
@ -359,6 +362,7 @@ CODESTARTmodExit
|
||||
|
||||
/* release objects we used */
|
||||
objRelease(glbl, CORE_COMPONENT);
|
||||
objRelease(net, CORE_COMPONENT);
|
||||
objRelease(datetime, CORE_COMPONENT);
|
||||
objRelease(prop, CORE_COMPONENT);
|
||||
ENDmodExit
|
||||
@ -394,6 +398,7 @@ CODEmodInit_QueryRegCFSLineHdlr
|
||||
CHKiRet(objUse(datetime, CORE_COMPONENT));
|
||||
CHKiRet(objUse(glbl, CORE_COMPONENT));
|
||||
CHKiRet(objUse(prop, CORE_COMPONENT));
|
||||
CHKiRet(objUse(net, CORE_COMPONENT));
|
||||
|
||||
/* we need to create the inputName property (only once during our lifetime) */
|
||||
CHKiRet(prop.CreateStringProp(&pInputName, UCHAR_CONSTANT("imklog"), sizeof("imklog") - 1));
|
||||
|
||||
@ -75,7 +75,6 @@ static modConfData_t *runModConf = NULL;/* modConf ptr to use for the current lo
|
||||
static configSettings_t cs;
|
||||
|
||||
static prop_t *pInputName = NULL;
|
||||
static prop_t *pLocalHostIP = NULL;
|
||||
|
||||
BEGINisCompatibleWithFeature
|
||||
CODESTARTisCompatibleWithFeature
|
||||
@ -106,7 +105,7 @@ doSubmitMsg(uchar *line)
|
||||
MsgSetRawMsgWOSize(pMsg, (char*)line);
|
||||
MsgSetHOSTNAME(pMsg, glbl.GetLocalHostName(), ustrlen(glbl.GetLocalHostName()));
|
||||
MsgSetRcvFrom(pMsg, glbl.GetLocalHostNameProp());
|
||||
MsgSetRcvFromIP(pMsg, pLocalHostIP);
|
||||
MsgSetRcvFromIP(pMsg, glbl.GetLocalHostIP());
|
||||
MsgSetMSGoffs(pMsg, 0);
|
||||
MsgSetTAG(pMsg, UCHAR_CONSTANT("rsyslogd-pstats:"), sizeof("rsyslogd-pstats:") - 1);
|
||||
pMsg->iFacility = runModConf->iFacility;
|
||||
@ -221,7 +220,6 @@ ENDafterRun
|
||||
BEGINmodExit
|
||||
CODESTARTmodExit
|
||||
prop.Destruct(&pInputName);
|
||||
prop.Destruct(&pLocalHostIP);
|
||||
/* release objects we used */
|
||||
objRelease(glbl, CORE_COMPONENT);
|
||||
objRelease(prop, CORE_COMPONENT);
|
||||
@ -266,10 +264,6 @@ CODEmodInit_QueryRegCFSLineHdlr
|
||||
CHKiRet(prop.Construct(&pInputName));
|
||||
CHKiRet(prop.SetString(pInputName, UCHAR_CONSTANT("impstats"), sizeof("impstats") - 1));
|
||||
CHKiRet(prop.ConstructFinalize(pInputName));
|
||||
|
||||
CHKiRet(prop.Construct(&pLocalHostIP));
|
||||
CHKiRet(prop.SetString(pLocalHostIP, UCHAR_CONSTANT("127.0.0.1"), sizeof("127.0.0.1") - 1));
|
||||
CHKiRet(prop.ConstructFinalize(pLocalHostIP));
|
||||
ENDmodInit
|
||||
/* vi:set ai:
|
||||
*/
|
||||
|
||||
@ -97,6 +97,7 @@ typedef struct configSettings_s {
|
||||
int iKeepAliveProbes;
|
||||
int iKeepAliveTime;
|
||||
int bEmitMsgOnClose; /* emit an informational message on close by remote peer */
|
||||
int bSuppOctetFram; /* support octet-counted framing? */
|
||||
int iAddtlFrameDelim; /* addtl frame delimiter, e.g. for netscreen, default none */
|
||||
uchar *pszInputName; /* value for inputname property, NULL is OK and handled by core engine */
|
||||
uchar *lstnIP; /* which IP we should listen on? */
|
||||
@ -111,6 +112,7 @@ struct instanceConf_s {
|
||||
int iKeepAliveProbes;
|
||||
int iKeepAliveTime;
|
||||
int bEmitMsgOnClose;
|
||||
int bSuppOctetFram; /* support octet-counted framing? */
|
||||
int iAddtlFrameDelim;
|
||||
uchar *pszBindPort; /* port to bind to */
|
||||
uchar *pszBindAddr; /* IP to bind socket to */
|
||||
@ -145,6 +147,7 @@ struct ptcpsrv_s {
|
||||
ptcpsrv_t *pNext; /* linked list maintenance */
|
||||
uchar *port; /* Port to listen to */
|
||||
uchar *lstnIP; /* which IP we should listen on? */
|
||||
sbool bSuppOctetFram;
|
||||
int iAddtlFrameDelim;
|
||||
int iKeepAliveIntvl;
|
||||
int iKeepAliveProbes;
|
||||
@ -171,6 +174,7 @@ struct ptcpsess_s {
|
||||
//--- from tcps_sess.h
|
||||
int iMsg; /* index of next char to store in msg */
|
||||
int bAtStrtOfFram; /* are we at the very beginning of a new frame? */
|
||||
sbool bSuppOctetFram; /**< copy from listener, to speed up access */
|
||||
enum {
|
||||
eAtStrtFram,
|
||||
eInOctetCnt,
|
||||
@ -191,6 +195,7 @@ struct ptcplstn_s {
|
||||
ptcpsrv_t *pSrv; /* our server */
|
||||
ptcplstn_t *prev, *next;
|
||||
int sock;
|
||||
sbool bSuppOctetFram;
|
||||
epolld_t *epd;
|
||||
statsobj_t *stats; /* listener stats */
|
||||
STATSCOUNTER_DEF(ctrSubmit, mutCtrSubmit)
|
||||
@ -325,7 +330,9 @@ startupSrv(ptcpsrv_t *pSrv)
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
} else {
|
||||
isIPv6 = 0;
|
||||
}
|
||||
if(setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (char *) &on, sizeof(on)) < 0 ) {
|
||||
DBGPRINTF("error %d setting tcp socket option\n", errno);
|
||||
close(sock);
|
||||
@ -665,7 +672,7 @@ processDataRcvd(ptcpsess_t *pThis, char c, struct syslogTime *stTime, time_t ttG
|
||||
DEFiRet;
|
||||
|
||||
if(pThis->inputState == eAtStrtFram) {
|
||||
if(isdigit((int) c)) {
|
||||
if(pThis->bSuppOctetFram && isdigit((int) c)) {
|
||||
pThis->inputState = eInOctetCnt;
|
||||
pThis->iOctetsRemain = 0;
|
||||
pThis->eFraming = TCP_FRAMING_OCTET_COUNTING;
|
||||
@ -805,6 +812,7 @@ initConfigSettings(void)
|
||||
{
|
||||
cs.bEmitMsgOnClose = 0;
|
||||
cs.wrkrMax = 2;
|
||||
cs.bSuppOctetFram = 1;
|
||||
cs.iAddtlFrameDelim = TCPSRV_NO_ADDTL_DELIMITER;
|
||||
cs.pszInputName = NULL;
|
||||
cs.pszBindRuleset = NULL;
|
||||
@ -821,7 +829,7 @@ addEPollSock(epolld_type_t typ, void *ptr, int sock, epolld_t **pEpd)
|
||||
DEFiRet;
|
||||
epolld_t *epd = NULL;
|
||||
|
||||
CHKmalloc(epd = malloc(sizeof(epolld_t)));
|
||||
CHKmalloc(epd = calloc(sizeof(epolld_t), 1));
|
||||
epd->typ = typ;
|
||||
epd->ptr = ptr;
|
||||
*pEpd = epd;
|
||||
@ -883,6 +891,7 @@ addLstn(ptcpsrv_t *pSrv, int sock, int isIPv6)
|
||||
|
||||
CHKmalloc(pLstn = malloc(sizeof(ptcplstn_t)));
|
||||
pLstn->pSrv = pSrv;
|
||||
pLstn->bSuppOctetFram = pSrv->bSuppOctetFram;
|
||||
pLstn->sock = sock;
|
||||
/* support statistics gathering */
|
||||
CHKiRet(statsobj.Construct(&(pLstn->stats)));
|
||||
@ -891,6 +900,7 @@ addLstn(ptcpsrv_t *pSrv, int sock, int isIPv6)
|
||||
isIPv6 ? "IPv6" : "IPv4");
|
||||
statname[sizeof(statname)-1] = '\0'; /* just to be on the save side... */
|
||||
CHKiRet(statsobj.SetName(pLstn->stats, statname));
|
||||
STATSCOUNTER_INIT(pLstn->ctrSubmit, pLstn->mutCtrSubmit);
|
||||
CHKiRet(statsobj.AddCounter(pLstn->stats, UCHAR_CONSTANT("submitted"),
|
||||
ctrType_IntCtr, &(pLstn->ctrSubmit)));
|
||||
CHKiRet(statsobj.ConstructFinalize(pLstn->stats));
|
||||
@ -922,6 +932,7 @@ addSess(ptcplstn_t *pLstn, int sock, prop_t *peerName, prop_t *peerIP)
|
||||
CHKmalloc(pSess->pMsg = malloc(iMaxLine * sizeof(uchar)));
|
||||
pSess->pLstn = pLstn;
|
||||
pSess->sock = sock;
|
||||
pSess->bSuppOctetFram = pLstn->bSuppOctetFram;
|
||||
pSess->inputState = eAtStrtFram;
|
||||
pSess->iMsg = 0;
|
||||
pSess->bAtStrtOfFram = 1;
|
||||
@ -1013,6 +1024,7 @@ static rsRetVal addInstance(void __attribute__((unused)) *pVal, uchar *pNewVal)
|
||||
CHKmalloc(inst->pszInputName = ustrdup(cs.pszInputName));
|
||||
}
|
||||
inst->pBindRuleset = NULL;
|
||||
inst->bSuppOctetFram = cs.bSuppOctetFram;
|
||||
inst->bKeepAlive = cs.bKeepAlive;
|
||||
inst->iKeepAliveIntvl = cs.iKeepAliveTime;
|
||||
inst->iKeepAliveProbes = cs.iKeepAliveProbes;
|
||||
@ -1045,6 +1057,7 @@ addListner(modConfData_t __attribute__((unused)) *modConf, instanceConf_t *inst)
|
||||
pthread_mutex_init(&pSrv->mutSessLst, NULL);
|
||||
pSrv->pSess = NULL;
|
||||
pSrv->pLstn = NULL;
|
||||
pSrv->bSuppOctetFram = inst->bSuppOctetFram;
|
||||
pSrv->bKeepAlive = inst->bKeepAlive;
|
||||
pSrv->iKeepAliveIntvl = inst->iKeepAliveTime;
|
||||
pSrv->iKeepAliveProbes = inst->iKeepAliveProbes;
|
||||
@ -1530,6 +1543,7 @@ resetConfigVariables(uchar __attribute__((unused)) *pp, void __attribute__((unus
|
||||
cs.iKeepAliveProbes = 0;
|
||||
cs.iKeepAliveTime = 0;
|
||||
cs.iKeepAliveIntvl = 0;
|
||||
cs.bSuppOctetFram = 1;
|
||||
cs.iAddtlFrameDelim = TCPSRV_NO_ADDTL_DELIMITER;
|
||||
free(cs.pszInputName);
|
||||
cs.pszInputName = NULL;
|
||||
@ -1586,6 +1600,8 @@ CODEmodInit_QueryRegCFSLineHdlr
|
||||
NULL, &cs.iKeepAliveTime, STD_LOADABLE_MODULE_ID));
|
||||
CHKiRet(omsdRegCFSLineHdlr(UCHAR_CONSTANT("inputptcpserverkeepalive_intvl"), 0, eCmdHdlrInt,
|
||||
NULL, &cs.iKeepAliveIntvl, STD_LOADABLE_MODULE_ID));
|
||||
CHKiRet(omsdRegCFSLineHdlr(UCHAR_CONSTANT("inputptcpserversupportoctetcountedframing"), 0, eCmdHdlrBinary,
|
||||
NULL, &cs.bSuppOctetFram, STD_LOADABLE_MODULE_ID));
|
||||
CHKiRet(omsdRegCFSLineHdlr(UCHAR_CONSTANT("inputptcpservernotifyonconnectionclose"), 0,
|
||||
eCmdHdlrBinary, NULL, &cs.bEmitMsgOnClose, STD_LOADABLE_MODULE_ID));
|
||||
CHKiRet(omsdRegCFSLineHdlr(UCHAR_CONSTANT("inputptcpserveraddtlframedelimiter"), 0, eCmdHdlrInt,
|
||||
|
||||
@ -88,6 +88,7 @@ static permittedPeers_t *pPermPeersRoot = NULL;
|
||||
static struct configSettings_s {
|
||||
int iTCPSessMax;
|
||||
int iTCPLstnMax;
|
||||
int bSuppOctetFram;
|
||||
int iStrmDrvrMode;
|
||||
int bKeepAlive;
|
||||
int bEmitMsgOnClose;
|
||||
@ -104,6 +105,7 @@ struct instanceConf_s {
|
||||
uchar *pszBindRuleset; /* name of ruleset to bind to */
|
||||
ruleset_t *pBindRuleset; /* ruleset to bind listener to (use system default if unspecified) */
|
||||
uchar *pszInputName; /* value for inputname property, NULL is OK and handled by core engine */
|
||||
int bSuppOctetFram;
|
||||
struct instanceConf_s *next;
|
||||
};
|
||||
|
||||
@ -115,6 +117,7 @@ struct modConfData_s {
|
||||
int iTCPLstnMax; /* max number of sessions */
|
||||
int iStrmDrvrMode; /* mode for stream driver, driver-dependent (0 mostly means plain tcp) */
|
||||
int iAddtlFrameDelim; /* addtl frame delimiter, e.g. for netscreen, default none */
|
||||
int bSuppOctetFram;
|
||||
sbool bDisableLFDelim; /* disable standard LF delimiter */
|
||||
sbool bUseFlowControl; /* use flow control, what means indicate ourselfs a "light delayable" */
|
||||
sbool bKeepAlive;
|
||||
@ -222,6 +225,7 @@ static rsRetVal addInstance(void __attribute__((unused)) *pVal, uchar *pNewVal)
|
||||
} else {
|
||||
CHKmalloc(inst->pszInputName = ustrdup(cs.pszInputName));
|
||||
}
|
||||
inst->bSuppOctetFram = cs.bSuppOctetFram;
|
||||
inst->next = NULL;
|
||||
|
||||
/* node created, let's add to config */
|
||||
@ -274,7 +278,7 @@ addListner(modConfData_t *modConf, instanceConf_t *inst)
|
||||
CHKiRet(tcpsrv.SetRuleset(pOurTcpsrv, inst->pBindRuleset));
|
||||
CHKiRet(tcpsrv.SetInputName(pOurTcpsrv, inst->pszInputName == NULL ?
|
||||
UCHAR_CONSTANT("imtcp") : inst->pszInputName));
|
||||
tcpsrv.configureTCPListen(pOurTcpsrv, inst->pszBindPort);
|
||||
tcpsrv.configureTCPListen(pOurTcpsrv, inst->pszBindPort, inst->bSuppOctetFram);
|
||||
|
||||
finalize_it:
|
||||
if(iRet != RS_RET_OK) {
|
||||
@ -301,6 +305,7 @@ CODESTARTendCnfLoad
|
||||
pModConf->iTCPLstnMax = cs.iTCPLstnMax;
|
||||
pModConf->iStrmDrvrMode = cs.iStrmDrvrMode;
|
||||
pModConf->bEmitMsgOnClose = cs.bEmitMsgOnClose;
|
||||
pModConf->bSuppOctetFram = cs.bSuppOctetFram;
|
||||
pModConf->iAddtlFrameDelim = cs.iAddtlFrameDelim;
|
||||
pModConf->bDisableLFDelim = cs.bDisableLFDelim;
|
||||
pModConf->bUseFlowControl = cs.bUseFlowControl;
|
||||
@ -417,6 +422,7 @@ resetConfigVariables(uchar __attribute__((unused)) *pp, void __attribute__((unus
|
||||
{
|
||||
cs.iTCPSessMax = 200;
|
||||
cs.iTCPLstnMax = 20;
|
||||
cs.bSuppOctetFram = 1;
|
||||
cs.iStrmDrvrMode = 0;
|
||||
cs.bUseFlowControl = 0;
|
||||
cs.bKeepAlive = 0;
|
||||
@ -459,6 +465,8 @@ CODEmodInit_QueryRegCFSLineHdlr
|
||||
addInstance, NULL, STD_LOADABLE_MODULE_ID));
|
||||
CHKiRet(omsdRegCFSLineHdlr(UCHAR_CONSTANT("inputtcpserverkeepalive"), 0, eCmdHdlrBinary,
|
||||
NULL, &cs.bKeepAlive, STD_LOADABLE_MODULE_ID));
|
||||
CHKiRet(omsdRegCFSLineHdlr(UCHAR_CONSTANT("inputtcpserversupportoctetcountedframing"), 0, eCmdHdlrBinary,
|
||||
NULL, &cs.bSuppOctetFram, STD_LOADABLE_MODULE_ID));
|
||||
CHKiRet(omsdRegCFSLineHdlr(UCHAR_CONSTANT("inputtcpmaxsessions"), 0, eCmdHdlrInt,
|
||||
NULL, &cs.iTCPSessMax, STD_LOADABLE_MODULE_ID));
|
||||
CHKiRet(omsdRegCFSLineHdlr(UCHAR_CONSTANT("inputtcpmaxlisteners"), 0, eCmdHdlrInt,
|
||||
|
||||
@ -256,6 +256,7 @@ addListner(instanceConf_t *inst)
|
||||
snprintf((char*)statname, sizeof(statname), "imudp(%s:%s)", bindName, port);
|
||||
statname[sizeof(statname)-1] = '\0'; /* just to be on the save side... */
|
||||
CHKiRet(statsobj.SetName(newlcnfinfo->stats, statname));
|
||||
STATSCOUNTER_INIT(newlcnfinfo->ctrSubmit, newlcnfinfo->mutCtrSubmit);
|
||||
CHKiRet(statsobj.AddCounter(newlcnfinfo->stats, UCHAR_CONSTANT("submitted"),
|
||||
ctrType_IntCtr, &(newlcnfinfo->ctrSubmit)));
|
||||
CHKiRet(statsobj.ConstructFinalize(newlcnfinfo->stats));
|
||||
@ -266,9 +267,11 @@ addListner(instanceConf_t *inst)
|
||||
lcnfRoot = newlcnfinfo;
|
||||
if(lcnfLast == NULL)
|
||||
lcnfLast = newlcnfinfo;
|
||||
else
|
||||
else {
|
||||
lcnfLast->next = newlcnfinfo;
|
||||
lcnfLast = newlcnfinfo;
|
||||
#endif //>>>>>>> ef34821a2737799f48c3032b9616418e4f7fa34f
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -94,6 +94,7 @@ DEF_IMOD_STATIC_DATA
|
||||
DEFobjCurrIf(errmsg)
|
||||
DEFobjCurrIf(glbl)
|
||||
DEFobjCurrIf(prop)
|
||||
DEFobjCurrIf(net)
|
||||
DEFobjCurrIf(parser)
|
||||
DEFobjCurrIf(datetime)
|
||||
DEFobjCurrIf(statsobj)
|
||||
@ -1253,6 +1254,7 @@ CODESTARTmodInit
|
||||
CODEmodInit_QueryRegCFSLineHdlr
|
||||
CHKiRet(objUse(errmsg, CORE_COMPONENT));
|
||||
CHKiRet(objUse(glbl, CORE_COMPONENT));
|
||||
CHKiRet(objUse(net, CORE_COMPONENT));
|
||||
CHKiRet(objUse(prop, CORE_COMPONENT));
|
||||
CHKiRet(objUse(statsobj, CORE_COMPONENT));
|
||||
CHKiRet(objUse(datetime, CORE_COMPONENT));
|
||||
@ -1287,10 +1289,6 @@ CODEmodInit_QueryRegCFSLineHdlr
|
||||
listeners[i].fd = -1;
|
||||
}
|
||||
|
||||
CHKiRet(prop.Construct(&pLocalHostIP));
|
||||
CHKiRet(prop.SetString(pLocalHostIP, UCHAR_CONSTANT("127.0.0.1"), sizeof("127.0.0.1") - 1));
|
||||
CHKiRet(prop.ConstructFinalize(pLocalHostIP));
|
||||
|
||||
/* now init listen socket zero, the local log socket */
|
||||
CHKiRet(prop.Construct(&(listeners[0].hostName)));
|
||||
CHKiRet(prop.SetString(listeners[0].hostName, glbl.GetLocalHostName(), ustrlen(glbl.GetLocalHostName())));
|
||||
|
||||
@ -83,13 +83,13 @@ LogError(int iErrno, int iErrCode, char *fmt, ... )
|
||||
|
||||
if(iErrno != 0) {
|
||||
rs_strerror_r(iErrno, errStr, sizeof(errStr));
|
||||
if(iErrCode == NO_ERRCODE) {
|
||||
if(iErrCode == NO_ERRCODE || iErrCode == RS_RET_ERR) {
|
||||
snprintf(msg, sizeof(msg), "%s: %s", buf, errStr);
|
||||
} else {
|
||||
snprintf(msg, sizeof(msg), "%s: %s [try http://www.rsyslog.com/e/%d ]", buf, errStr, iErrCode * -1);
|
||||
}
|
||||
} else {
|
||||
if(iErrCode == NO_ERRCODE) {
|
||||
if(iErrCode == NO_ERRCODE || iErrCode == RS_RET_ERR) {
|
||||
snprintf(msg, sizeof(msg), "%s", buf);
|
||||
} else {
|
||||
snprintf(msg, sizeof(msg), "%s [try http://www.rsyslog.com/e/%d ]", buf, iErrCode * -1);
|
||||
|
||||
126
runtime/glbl.c
126
runtime/glbl.c
@ -11,21 +11,19 @@
|
||||
*
|
||||
* This file is part of the rsyslog runtime library.
|
||||
*
|
||||
* The rsyslog runtime library is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* The rsyslog runtime library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with the rsyslog runtime library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* A copy of the GPL can be found in the file "COPYING" in this distribution.
|
||||
* A copy of the LGPL can be found in the file "COPYING.LESSER" in this distribution.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* -or-
|
||||
* see COPYING.ASL20 in the source distribution
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
@ -45,6 +43,7 @@
|
||||
#include "atomic.h"
|
||||
#include "errmsg.h"
|
||||
#include "rainerscript.h"
|
||||
#include "net.h"
|
||||
|
||||
/* some defaults */
|
||||
#ifndef DFLT_NETSTRM_DRVR
|
||||
@ -55,6 +54,7 @@
|
||||
DEFobjStaticHelpers
|
||||
DEFobjCurrIf(prop)
|
||||
DEFobjCurrIf(errmsg)
|
||||
DEFobjCurrIf(net)
|
||||
|
||||
/* static data
|
||||
* For this object, these variables are obviously what makes the "meat" of the
|
||||
@ -69,6 +69,7 @@ static int iDefPFFamily = PF_UNSPEC; /* protocol family (IPv4, IPv6 or both)
|
||||
static int bDropMalPTRMsgs = 0;/* Drop messages which have malicious PTR records during DNS lookup */
|
||||
static int option_DisallowWarning = 1; /* complain if message from disallowed sender is received */
|
||||
static int bDisableDNS = 0; /* don't look up IP addresses of remote messages */
|
||||
static prop_t *propLocalIPIF = NULL;/* IP address to report for the local host (default is 127.0.0.1) */
|
||||
static prop_t *propLocalHostName = NULL;/* our hostname as FQDN - read-only after startup */
|
||||
static uchar *LocalHostName = NULL;/* our hostname - read-only after startup */
|
||||
static uchar *LocalHostNameOverride = NULL;/* user-overridden hostname - read-only after startup */
|
||||
@ -176,6 +177,60 @@ static void SetGlobalInputTermination(void)
|
||||
}
|
||||
|
||||
|
||||
/* set the local host IP address to a specific string. Helper to
|
||||
* small set of functions. No checks done, caller must ensure it is
|
||||
* ok to call. Most importantly, the IP address must not already have
|
||||
* been set. -- rgerhards, 2012-03-21
|
||||
*/
|
||||
static inline rsRetVal
|
||||
storeLocalHostIPIF(uchar *myIP)
|
||||
{
|
||||
DEFiRet;
|
||||
CHKiRet(prop.Construct(&propLocalIPIF));
|
||||
CHKiRet(prop.SetString(propLocalIPIF, myIP, ustrlen(myIP)));
|
||||
CHKiRet(prop.ConstructFinalize(propLocalIPIF));
|
||||
DBGPRINTF("rsyslog/glbl: using '%s' as localhost IP\n", myIP);
|
||||
finalize_it:
|
||||
RETiRet;
|
||||
}
|
||||
|
||||
|
||||
/* This function is used to set the IP address that is to be
|
||||
* reported for the local host. Note that in order to ease things
|
||||
* for the v6 config interface, we do not allow to set this more
|
||||
* than once.
|
||||
* rgerhards, 2012-03-21
|
||||
*/
|
||||
static rsRetVal
|
||||
setLocalHostIPIF(void __attribute__((unused)) *pVal, uchar *pNewVal)
|
||||
{
|
||||
uchar myIP[128];
|
||||
rsRetVal localRet;
|
||||
DEFiRet;
|
||||
|
||||
CHKiRet(objUse(net, CORE_COMPONENT));
|
||||
|
||||
if(propLocalIPIF != NULL) {
|
||||
errmsg.LogError(0, RS_RET_ERR, "$LocalHostIPIF is already set "
|
||||
"and cannot be reset; place it at TOP OF rsyslog.conf!");
|
||||
ABORT_FINALIZE(RS_RET_ERR_WRKDIR);
|
||||
}
|
||||
|
||||
localRet = net.GetIFIPAddr(pNewVal, AF_UNSPEC, myIP, (int) sizeof(myIP));
|
||||
if(localRet != RS_RET_OK) {
|
||||
errmsg.LogError(0, RS_RET_ERR, "$LocalHostIPIF: IP address for interface "
|
||||
"'%s' cannnot be obtained - ignoring directive", pNewVal);
|
||||
} else {
|
||||
storeLocalHostIPIF(myIP);
|
||||
}
|
||||
|
||||
|
||||
finalize_it:
|
||||
free(pNewVal); /* no longer needed -> is in prop! */
|
||||
RETiRet;
|
||||
}
|
||||
|
||||
|
||||
/* This function is used to set the global work directory name.
|
||||
* It verifies that the provided directory actually exists and
|
||||
* emits an error message if not.
|
||||
@ -226,6 +281,22 @@ finalize_it:
|
||||
RETiRet;
|
||||
}
|
||||
|
||||
/* return our local IP.
|
||||
* If no local IP is set, "127.0.0.1" is selected *and* set. This
|
||||
* is an intensional side effect that we do in order to keep things
|
||||
* consistent and avoid config errors (this will make us not accept
|
||||
* setting the local IP address once a module has obtained it - so
|
||||
* it forces the $LocalHostIPIF directive high up in rsyslog.conf)
|
||||
* rgerhards, 2012-03-21
|
||||
*/
|
||||
static prop_t*
|
||||
GetLocalHostIP(void)
|
||||
{
|
||||
if(propLocalIPIF == NULL)
|
||||
storeLocalHostIPIF((uchar*)"127.0.0.1");
|
||||
return(propLocalIPIF);
|
||||
}
|
||||
|
||||
/* return our local hostname. if it is not set, "[localhost]" is returned
|
||||
*/
|
||||
static uchar*
|
||||
@ -362,6 +433,7 @@ CODESTARTobjQueryInterface(glbl)
|
||||
pIf->GetWorkDir = GetWorkDir;
|
||||
pIf->GenerateLocalHostNameProperty = GenerateLocalHostNameProperty;
|
||||
pIf->GetLocalHostNameProp = GetLocalHostNameProp;
|
||||
pIf->GetLocalHostIP = GetLocalHostIP;
|
||||
pIf->SetGlobalInputTermination = SetGlobalInputTermination;
|
||||
pIf->GetGlobalInputTermState = GetGlobalInputTermState;
|
||||
#define SIMP_PROP(name) \
|
||||
@ -515,7 +587,7 @@ BEGINAbstractObjClassInit(glbl, 1, OBJ_IS_CORE_MODULE) /* class, version */
|
||||
CHKiRet(objUse(prop, CORE_COMPONENT));
|
||||
CHKiRet(objUse(errmsg, CORE_COMPONENT));
|
||||
|
||||
/* register config handlers (TODO: we need to implement a way to unregister them) */
|
||||
/* config handlers are never unregistered and need not be - we are always loaded ;) */
|
||||
CHKiRet(regCfSysLineHdlr((uchar *)"workdirectory", 0, eCmdHdlrGetWord, setWorkDir, NULL, NULL));
|
||||
CHKiRet(regCfSysLineHdlr((uchar *)"dropmsgswithmaliciousdnsptrrecords", 0, eCmdHdlrBinary, NULL, &bDropMalPTRMsgs, NULL));
|
||||
CHKiRet(regCfSysLineHdlr((uchar *)"defaultnetstreamdriver", 0, eCmdHdlrGetWord, NULL, &pszDfltNetstrmDrvr, NULL));
|
||||
@ -523,6 +595,7 @@ BEGINAbstractObjClassInit(glbl, 1, OBJ_IS_CORE_MODULE) /* class, version */
|
||||
CHKiRet(regCfSysLineHdlr((uchar *)"defaultnetstreamdriverkeyfile", 0, eCmdHdlrGetWord, NULL, &pszDfltNetstrmDrvrKeyFile, NULL));
|
||||
CHKiRet(regCfSysLineHdlr((uchar *)"defaultnetstreamdrivercertfile", 0, eCmdHdlrGetWord, NULL, &pszDfltNetstrmDrvrCertFile, NULL));
|
||||
CHKiRet(regCfSysLineHdlr((uchar *)"localhostname", 0, eCmdHdlrGetWord, NULL, &LocalHostNameOverride, NULL));
|
||||
CHKiRet(regCfSysLineHdlr((uchar *)"localhostipif", 0, eCmdHdlrGetWord, setLocalHostIPIF, NULL, NULL));
|
||||
CHKiRet(regCfSysLineHdlr((uchar *)"optimizeforuniprocessor", 0, eCmdHdlrBinary, NULL, &bOptimizeUniProc, NULL));
|
||||
CHKiRet(regCfSysLineHdlr((uchar *)"preservefqdn", 0, eCmdHdlrBinary, NULL, &bPreserveFQDN, NULL));
|
||||
CHKiRet(regCfSysLineHdlr((uchar *)"maxmessagesize", 0, eCmdHdlrSize,
|
||||
@ -537,21 +610,14 @@ ENDObjClassInit(glbl)
|
||||
* rgerhards, 2008-04-17
|
||||
*/
|
||||
BEGINObjClassExit(glbl, OBJ_IS_CORE_MODULE) /* class, version */
|
||||
if(pszDfltNetstrmDrvr != NULL)
|
||||
free(pszDfltNetstrmDrvr);
|
||||
if(pszDfltNetstrmDrvrCAF != NULL)
|
||||
free(pszDfltNetstrmDrvrCAF);
|
||||
if(pszDfltNetstrmDrvrKeyFile != NULL)
|
||||
free(pszDfltNetstrmDrvrKeyFile);
|
||||
if(pszDfltNetstrmDrvrCertFile != NULL)
|
||||
free(pszDfltNetstrmDrvrCertFile);
|
||||
if(pszWorkDir != NULL)
|
||||
free(pszWorkDir);
|
||||
if(LocalHostName != NULL)
|
||||
free(LocalHostName);
|
||||
free(pszDfltNetstrmDrvr);
|
||||
free(pszDfltNetstrmDrvrCAF);
|
||||
free(pszDfltNetstrmDrvrKeyFile);
|
||||
free(pszDfltNetstrmDrvrCertFile);
|
||||
free(pszWorkDir);
|
||||
free(LocalHostName);
|
||||
free(LocalHostNameOverride);
|
||||
if(LocalFQDNName != NULL)
|
||||
free(LocalFQDNName);
|
||||
free(LocalFQDNName);
|
||||
objRelease(prop, CORE_COMPONENT);
|
||||
DESTROY_ATOMIC_HELPER_MUT(mutTerminateInputs);
|
||||
ENDObjClassExit(glbl)
|
||||
|
||||
@ -8,25 +8,23 @@
|
||||
* Please note that there currently is no glbl.c file as we do not yet
|
||||
* have any implementations.
|
||||
*
|
||||
* Copyright 2008, 2009 Rainer Gerhards and Adiscon GmbH.
|
||||
* Copyright 2008-2012 Rainer Gerhards and Adiscon GmbH.
|
||||
*
|
||||
* This file is part of the rsyslog runtime library.
|
||||
*
|
||||
* The rsyslog runtime library is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* The rsyslog runtime library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with the rsyslog runtime library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* A copy of the GPL can be found in the file "COPYING" in this distribution.
|
||||
* A copy of the LGPL can be found in the file "COPYING.LESSER" in this distribution.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* -or-
|
||||
* see COPYING.ASL20 in the source distribution
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef GLBL_H_INCLUDED
|
||||
@ -77,7 +75,9 @@ BEGINinterface(glbl) /* name must also be changed in ENDinterface macro! */
|
||||
*/
|
||||
SIMP_PROP(FdSetSize, int)
|
||||
/* v7: was neeeded to mean v5+v6 - do NOT add anything else for that version! */
|
||||
/* next is v8! */
|
||||
/* next change is v9! */
|
||||
/* v8 - 2012-03-21 */
|
||||
prop_t* (*GetLocalHostIP)(void);
|
||||
#undef SIMP_PROP
|
||||
ENDinterface(glbl)
|
||||
#define glblCURR_IF_VERSION 7 /* increment whenever you change the interface structure! */
|
||||
|
||||
@ -54,6 +54,9 @@
|
||||
#include <fnmatch.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <ifaddrs.h>
|
||||
#include <sys/types.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#include "syslogd-types.h"
|
||||
#include "module-template.h"
|
||||
@ -1480,6 +1483,54 @@ finalize_it:
|
||||
}
|
||||
|
||||
|
||||
/* return the IP address (IPv4/6) for the provided interface. Returns
|
||||
* RS_RET_NOT_FOUND if interface can not be found in interface list.
|
||||
* The family must be correct (AF_INET vs. AF_INET6, AF_UNSPEC means
|
||||
* either of *these two*).
|
||||
* The function re-queries the interface list (at least in theory).
|
||||
* However, it caches entries in order to avoid too-frequent requery.
|
||||
* rgerhards, 2012-03-06
|
||||
*/
|
||||
static rsRetVal
|
||||
getIFIPAddr(uchar *szif, int family, uchar *pszbuf, int lenBuf)
|
||||
{
|
||||
struct ifaddrs * ifaddrs = NULL;
|
||||
struct ifaddrs * ifa;
|
||||
void * pAddr;
|
||||
DEFiRet;
|
||||
|
||||
if(getifaddrs(&ifaddrs) != 0) {
|
||||
ABORT_FINALIZE(RS_RET_ERR);
|
||||
}
|
||||
|
||||
for (ifa = ifaddrs; ifa != NULL; ifa = ifa->ifa_next) {
|
||||
if(strcmp(ifa->ifa_name, (char*)szif))
|
||||
continue;
|
||||
if( (family == AF_INET6 || family == AF_UNSPEC)
|
||||
&& ifa->ifa_addr->sa_family == AF_INET6) {
|
||||
pAddr = &((struct sockaddr_in6 *)ifa->ifa_addr)->sin6_addr;
|
||||
inet_ntop(AF_INET6, pAddr, (char*)pszbuf, lenBuf);
|
||||
break;
|
||||
} else if(/* (family == AF_INET || family == AF_UNSPEC)
|
||||
&&*/ ifa->ifa_addr->sa_family == AF_INET) {
|
||||
pAddr = &((struct sockaddr_in *)ifa->ifa_addr)->sin_addr;
|
||||
inet_ntop(AF_INET, pAddr, (char*)pszbuf, lenBuf);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(ifaddrs != NULL)
|
||||
freeifaddrs(ifaddrs);
|
||||
|
||||
if(ifa == NULL)
|
||||
iRet = RS_RET_NOT_FOUND;
|
||||
|
||||
finalize_it:
|
||||
RETiRet;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* queryInterface function
|
||||
* rgerhards, 2008-03-05
|
||||
*/
|
||||
@ -1511,6 +1562,7 @@ CODESTARTobjQueryInterface(net)
|
||||
pIf->PermittedPeerWildcardMatch = PermittedPeerWildcardMatch;
|
||||
pIf->CmpHost = CmpHost;
|
||||
pIf->HasRestrictions = HasRestrictions;
|
||||
pIf->GetIFIPAddr = getIFIPAddr;
|
||||
/* data members */
|
||||
pIf->pACLAddHostnameOnFail = &ACLAddHostnameOnFail;
|
||||
pIf->pACLDontResolve = &ACLDontResolve;
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/* Definitions for network-related stuff.
|
||||
*
|
||||
* Copyright 2007, 2008 Rainer Gerhards and Adiscon GmbH.
|
||||
* Copyright 2007-2012 Rainer Gerhards and Adiscon GmbH.
|
||||
*
|
||||
* This file is part of the rsyslog runtime library.
|
||||
*
|
||||
@ -151,11 +151,13 @@ BEGINinterface(net) /* name must also be changed in ENDinterface macro! */
|
||||
/* v6 interface additions - 2009-11-16 */
|
||||
rsRetVal (*HasRestrictions)(uchar *, int *bHasRestrictions);
|
||||
int (*isAllowedSender2)(uchar *pszType, struct sockaddr *pFrom, const char *pszFromHost, int bChkDNS);
|
||||
/* v7 interface additions - 2012-03-06 */
|
||||
rsRetVal (*GetIFIPAddr)(uchar *szif, int family, uchar *pszbuf, int lenBuf);
|
||||
/* data members - these should go away over time... TODO */
|
||||
int *pACLAddHostnameOnFail; /* add hostname to acl when DNS resolving has failed */
|
||||
int *pACLDontResolve; /* add hostname to acl instead of resolving it to IP(s) */
|
||||
ENDinterface(net)
|
||||
#define netCURR_IF_VERSION 6 /* increment whenever you change the interface structure! */
|
||||
#define netCURR_IF_VERSION 7 /* increment whenever you change the interface structure! */
|
||||
|
||||
/* prototypes */
|
||||
PROTOTYPEObj(net);
|
||||
|
||||
@ -2662,6 +2662,7 @@ DEFpropSetMeth(qqueue, iLowWtrMrk, int)
|
||||
DEFpropSetMeth(qqueue, iDiscardMrk, int)
|
||||
DEFpropSetMeth(qqueue, iFullDlyMrk, int)
|
||||
DEFpropSetMeth(qqueue, iDiscardSeverity, int)
|
||||
DEFpropSetMeth(qqueue, iLightDlyMrk, int)
|
||||
DEFpropSetMeth(qqueue, bIsDA, int)
|
||||
DEFpropSetMeth(qqueue, iMinMsgsPerWrkr, int)
|
||||
DEFpropSetMeth(qqueue, bSaveOnShutdown, int)
|
||||
|
||||
@ -205,6 +205,7 @@ PROTOTYPEpropSetMeth(qqueue, toQShutdown, long);
|
||||
PROTOTYPEpropSetMeth(qqueue, toActShutdown, long);
|
||||
PROTOTYPEpropSetMeth(qqueue, toWrkShutdown, long);
|
||||
PROTOTYPEpropSetMeth(qqueue, toEnq, long);
|
||||
PROTOTYPEpropSetMeth(qqueue, iLightDlyMrk, int);
|
||||
PROTOTYPEpropSetMeth(qqueue, iHighWtrMrk, int);
|
||||
PROTOTYPEpropSetMeth(qqueue, iLowWtrMrk, int);
|
||||
PROTOTYPEpropSetMeth(qqueue, iDiscardMrk, int);
|
||||
|
||||
@ -497,6 +497,7 @@ debugPrintAll(rsconf_t *conf)
|
||||
static inline rsRetVal
|
||||
doRulesetCreateQueue(rsconf_t *conf, int *pNewVal)
|
||||
{
|
||||
uchar *rulesetMainQName;
|
||||
DEFiRet;
|
||||
|
||||
if(conf->rulesets.pCurr == NULL) {
|
||||
@ -515,7 +516,9 @@ doRulesetCreateQueue(rsconf_t *conf, int *pNewVal)
|
||||
FINALIZE; /* if it is turned off, we do not need to change anything ;) */
|
||||
|
||||
dbgprintf("adding a ruleset-specific \"main\" queue");
|
||||
CHKiRet(createMainQueue(&conf->rulesets.pCurr->pQueue, UCHAR_CONSTANT("ruleset")));
|
||||
rulesetMainQName = (conf->rulesets.pCurr->pszName == NULL)? UCHAR_CONSTANT("ruleset") :
|
||||
conf->rulesets.pCurr->pszName;
|
||||
CHKiRet(createMainQueue(&conf->rulesets.pCurr->pQueue, rulesetMainQName));
|
||||
|
||||
finalize_it:
|
||||
RETiRet;
|
||||
|
||||
@ -200,6 +200,8 @@ SetLstnInfo(tcps_sess_t *pThis, tcpLstnPortList_t *pLstnInfo)
|
||||
ISOBJ_TYPE_assert(pThis, tcps_sess);
|
||||
assert(pLstnInfo != NULL);
|
||||
pThis->pLstnInfo = pLstnInfo;
|
||||
/* set cached elements */
|
||||
pThis->bSuppOctetFram = pLstnInfo->bSuppOctetFram;
|
||||
RETiRet;
|
||||
}
|
||||
|
||||
@ -366,7 +368,7 @@ processDataRcvd(tcps_sess_t *pThis, char c, struct syslogTime *stTime, time_t tt
|
||||
ISOBJ_TYPE_assert(pThis, tcps_sess);
|
||||
|
||||
if(pThis->inputState == eAtStrtFram) {
|
||||
if(isdigit((int) c)) {
|
||||
if(pThis->bSuppOctetFram && isdigit((int) c)) {
|
||||
pThis->inputState = eInOctetCnt;
|
||||
pThis->iOctetsRemain = 0;
|
||||
pThis->eFraming = TCP_FRAMING_OCTET_COUNTING;
|
||||
|
||||
@ -35,7 +35,8 @@ struct tcps_sess_s {
|
||||
tcpLstnPortList_t *pLstnInfo; /* pointer back to listener info */
|
||||
netstrm_t *pStrm;
|
||||
int iMsg; /* index of next char to store in msg */
|
||||
int bAtStrtOfFram; /* are we at the very beginning of a new frame? */
|
||||
sbool bAtStrtOfFram; /* are we at the very beginning of a new frame? */
|
||||
sbool bSuppOctetFram; /**< copy from listener, to speed up access */
|
||||
enum {
|
||||
eAtStrtFram,
|
||||
eInOctetCnt,
|
||||
|
||||
8
tcpsrv.c
8
tcpsrv.c
@ -119,7 +119,7 @@ static int wrkrRunning;
|
||||
* rgerhards, 2009-05-21
|
||||
*/
|
||||
static inline rsRetVal
|
||||
addNewLstnPort(tcpsrv_t *pThis, uchar *pszPort)
|
||||
addNewLstnPort(tcpsrv_t *pThis, uchar *pszPort, int bSuppOctetFram)
|
||||
{
|
||||
tcpLstnPortList_t *pEntry;
|
||||
uchar statname[64];
|
||||
@ -132,6 +132,7 @@ addNewLstnPort(tcpsrv_t *pThis, uchar *pszPort)
|
||||
pEntry->pszPort = pszPort;
|
||||
pEntry->pSrv = pThis;
|
||||
pEntry->pRuleset = pThis->pRuleset;
|
||||
pEntry->bSuppOctetFram = bSuppOctetFram;
|
||||
|
||||
/* we need to create a property */
|
||||
CHKiRet(prop.Construct(&pEntry->pInputName));
|
||||
@ -147,6 +148,7 @@ addNewLstnPort(tcpsrv_t *pThis, uchar *pszPort)
|
||||
snprintf((char*)statname, sizeof(statname), "%s(%s)", pThis->pszInputName, pszPort);
|
||||
statname[sizeof(statname)-1] = '\0'; /* just to be on the save side... */
|
||||
CHKiRet(statsobj.SetName(pEntry->stats, statname));
|
||||
STATSCOUNTER_INIT(pEntry->ctrSubmit, pEntry->mutCtrSubmit);
|
||||
CHKiRet(statsobj.AddCounter(pEntry->stats, UCHAR_CONSTANT("submitted"),
|
||||
ctrType_IntCtr, &(pEntry->ctrSubmit)));
|
||||
CHKiRet(statsobj.ConstructFinalize(pEntry->stats));
|
||||
@ -161,7 +163,7 @@ finalize_it:
|
||||
* rgerhards, 2008-03-20
|
||||
*/
|
||||
static rsRetVal
|
||||
configureTCPListen(tcpsrv_t *pThis, uchar *pszPort)
|
||||
configureTCPListen(tcpsrv_t *pThis, uchar *pszPort, int bSuppOctetFram)
|
||||
{
|
||||
int i;
|
||||
uchar *pPort = pszPort;
|
||||
@ -177,7 +179,7 @@ configureTCPListen(tcpsrv_t *pThis, uchar *pszPort)
|
||||
}
|
||||
|
||||
if(i >= 0 && i <= 65535) {
|
||||
CHKiRet(addNewLstnPort(pThis, pszPort));
|
||||
CHKiRet(addNewLstnPort(pThis, pszPort, bSuppOctetFram));
|
||||
} else {
|
||||
errmsg.LogError(0, NO_ERRCODE, "Invalid TCP listen port %s - ignored.\n", pszPort);
|
||||
}
|
||||
|
||||
6
tcpsrv.h
6
tcpsrv.h
@ -41,6 +41,7 @@ struct tcpLstnPortList_s {
|
||||
tcpsrv_t *pSrv; /**< pointer to higher-level server instance */
|
||||
ruleset_t *pRuleset; /**< associated ruleset */
|
||||
statsobj_t *stats; /**< associated stats object */
|
||||
sbool bSuppOctetFram; /**< do we support octect-counted framing? (if no->legay only!)*/
|
||||
STATSCOUNTER_DEF(ctrSubmit, mutCtrSubmit)
|
||||
tcpLstnPortList_t *pNext; /**< next port or NULL */
|
||||
};
|
||||
@ -105,7 +106,7 @@ BEGINinterface(tcpsrv) /* name must also be changed in ENDinterface macro! */
|
||||
rsRetVal (*Construct)(tcpsrv_t **ppThis);
|
||||
rsRetVal (*ConstructFinalize)(tcpsrv_t __attribute__((unused)) *pThis);
|
||||
rsRetVal (*Destruct)(tcpsrv_t **ppThis);
|
||||
rsRetVal (*configureTCPListen)(tcpsrv_t*, uchar *pszPort);
|
||||
rsRetVal (*configureTCPListen)(tcpsrv_t*, uchar *pszPort, int bSuppOctetFram);
|
||||
//rsRetVal (*SessAccept)(tcpsrv_t *pThis, tcpLstnPortList_t*, tcps_sess_t **ppSess, netstrm_t *pStrm);
|
||||
rsRetVal (*create_tcp_socket)(tcpsrv_t *pThis);
|
||||
rsRetVal (*Run)(tcpsrv_t *pThis);
|
||||
@ -142,11 +143,12 @@ BEGINinterface(tcpsrv) /* name must also be changed in ENDinterface macro! */
|
||||
/* added v11 -- rgerhards, 2011-05-09 */
|
||||
rsRetVal (*SetKeepAlive)(tcpsrv_t*, int);
|
||||
ENDinterface(tcpsrv)
|
||||
#define tcpsrvCURR_IF_VERSION 11 /* increment whenever you change the interface structure! */
|
||||
#define tcpsrvCURR_IF_VERSION 12 /* increment whenever you change the interface structure! */
|
||||
/* change for v4:
|
||||
* - SetAddtlFrameDelim() added -- rgerhards, 2008-12-10
|
||||
* - SetInputName() added -- rgerhards, 2008-12-10
|
||||
* change for v5 and up: see above
|
||||
* for v10: param bSuppOctetFram added to configureTCPListen
|
||||
*/
|
||||
|
||||
|
||||
|
||||
@ -190,7 +190,6 @@ static rsRetVal GlobalClassExit(void);
|
||||
rsconf_t *ourConf; /* our config object */
|
||||
|
||||
static prop_t *pInternalInputName = NULL; /* there is only one global inputName for all internally-generated messages */
|
||||
static prop_t *pLocalHostIP = NULL; /* there is only one global IP for all internally-generated messages */
|
||||
static uchar *ConfFile = (uchar*) _PATH_LOGCONF; /* read-only after startup */
|
||||
static char *PidFile = _PATH_LOGPID; /* read-only after startup */
|
||||
|
||||
@ -448,7 +447,8 @@ logmsgInternal(int iErr, int pri, uchar *msg, int flags)
|
||||
MsgSetRawMsgWOSize(pMsg, (char*)msg);
|
||||
MsgSetHOSTNAME(pMsg, glbl.GetLocalHostName(), ustrlen(glbl.GetLocalHostName()));
|
||||
MsgSetRcvFrom(pMsg, glbl.GetLocalHostNameProp());
|
||||
MsgSetRcvFromIP(pMsg, pLocalHostIP);
|
||||
dbgprintf("ZZZZ: pLocalHostIPIF used!\n");
|
||||
MsgSetRcvFromIP(pMsg, glbl.GetLocalHostIP());
|
||||
MsgSetMSGoffs(pMsg, 0);
|
||||
/* check if we have an error code associated and, if so,
|
||||
* adjust the tag. -- rgerhards, 2008-06-27
|
||||
@ -882,8 +882,6 @@ die(int sig)
|
||||
/* destruct our global properties */
|
||||
if(pInternalInputName != NULL)
|
||||
prop.Destruct(&pInternalInputName);
|
||||
if(pLocalHostIP != NULL)
|
||||
prop.Destruct(&pLocalHostIP);
|
||||
|
||||
/* terminate the remaining classes */
|
||||
GlobalClassExit();
|
||||
@ -1793,10 +1791,6 @@ int realMain(int argc, char **argv)
|
||||
CHKiRet(prop.SetString(pInternalInputName, UCHAR_CONSTANT("rsyslogd"), sizeof("rsyslgod") - 1));
|
||||
CHKiRet(prop.ConstructFinalize(pInternalInputName));
|
||||
|
||||
CHKiRet(prop.Construct(&pLocalHostIP));
|
||||
CHKiRet(prop.SetString(pLocalHostIP, UCHAR_CONSTANT("127.0.0.1"), sizeof("127.0.0.1") - 1));
|
||||
CHKiRet(prop.ConstructFinalize(pLocalHostIP));
|
||||
|
||||
/* get our host and domain names - we need to do this early as we may emit
|
||||
* error log messages, which need the correct hostname. -- rgerhards, 2008-04-04
|
||||
*/
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user