summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2012-03-22 16:06:57 +0100
committerRainer Gerhards <rgerhards@adiscon.com>2012-03-22 16:06:57 +0100
commit1d6d534df2368c906a2d80663634b2eef5535ef7 (patch)
treea77c3e8c677e4e0449eab1cdc68b9e124edcf8b7
parent49ec54d36984b9e91da7bd41e56e65dac22ce830 (diff)
downloadrsyslog-1d6d534df2368c906a2d80663634b2eef5535ef7.tar.gz
rsyslog-1d6d534df2368c906a2d80663634b2eef5535ef7.tar.xz
rsyslog-1d6d534df2368c906a2d80663634b2eef5535ef7.zip
unified use of $LocalHostIPIF among all locally-emitting inputs
with the exception of imdiag, which I humbly do not think needs this capabilit (even counter-productive for testbench use).
-rw-r--r--plugins/imklog/imklog.c24
-rw-r--r--plugins/imuxsock/imuxsock.c27
-rw-r--r--runtime/glbl.c2
3 files changed, 3 insertions, 50 deletions
diff --git a/plugins/imklog/imklog.c b/plugins/imklog/imklog.c
index 66d7d143..b6fd7c79 100644
--- a/plugins/imklog/imklog.c
+++ b/plugins/imklog/imklog.c
@@ -74,7 +74,6 @@ int symbols_twice = 0;
int use_syscall = 0;
int symbol_lookup = 0; /* on recent kernels > 2.6, the kernel does this */
int bPermitNonKernel = 0; /* permit logging of messages not having LOG_KERN facility */
-static uchar *pLocalIPIF = NULL;
int iFacilIntMsg; /* the facility to use for internal messages (set by driver) */
uchar *pszPath = NULL;
int console_log_level = -1;
@@ -237,22 +236,10 @@ ENDrunInput
BEGINwillRun
- uchar myIP[128];
- rsRetVal localRet;
CODESTARTwillRun
/* we need to create the inputName property (only once during our lifetime) */
CHKiRet(prop.CreateStringProp(&pInputName, UCHAR_CONSTANT("imklog"), sizeof("imklog") - 1));
- if(pLocalIPIF == NULL) {
- strcpy((char*)myIP, "127.0.0.1");
- } else {
- localRet = net.GetIFIPAddr(pLocalIPIF, AF_UNSPEC, myIP, (int) sizeof(myIP));
- if(localRet != RS_RET_OK) {
- DBGPRINTF("imuxsock: could not obtain my IP, using 127.0.0.1 instead\n");
- strcpy((char*)myIP, "127.0.0.1");
- }
- }
- DBGPRINTF("imklog: using '%s' as localhost IP\n", myIP);
- CHKiRet(prop.CreateStringProp(&pLocalHostIP, myIP, ustrlen(myIP)));
+ pLocalHostIP = glbl.GetLocalHostIP();
iRet = klogWillRun();
finalize_it:
@@ -265,9 +252,6 @@ CODESTARTafterRun
if(pInputName != NULL)
prop.Destruct(&pInputName);
- if(pLocalHostIP != NULL)
- prop.Destruct(&pLocalHostIP);
- free(pLocalIPIF);
ENDafterRun
@@ -300,10 +284,6 @@ static rsRetVal resetConfigVariables(uchar __attribute__((unused)) *pp, void __a
free(pszPath);
pszPath = NULL;
}
- if(pLocalIPIF != NULL) {
- free(pLocalIPIF);
- pLocalIPIF = NULL;
- }
iFacilIntMsg = klogFacilIntMsg();
return RS_RET_OK;
}
@@ -327,8 +307,6 @@ CODEmodInit_QueryRegCFSLineHdlr
CHKiRet(omsdRegCFSLineHdlr((uchar *)"klogpermitnonkernelfacility", 0, eCmdHdlrBinary, NULL, &bPermitNonKernel, STD_LOADABLE_MODULE_ID));
CHKiRet(omsdRegCFSLineHdlr((uchar *)"klogconsoleloglevel", 0, eCmdHdlrInt, NULL, &console_log_level, STD_LOADABLE_MODULE_ID));
CHKiRet(omsdRegCFSLineHdlr((uchar *)"kloginternalmsgfacility", 0, eCmdHdlrFacility, NULL, &iFacilIntMsg, STD_LOADABLE_MODULE_ID));
- CHKiRet(omsdRegCFSLineHdlr((uchar *)"kloglocalipif", 0, eCmdHdlrGetWord,
- NULL, &pLocalIPIF, STD_LOADABLE_MODULE_ID));
CHKiRet(omsdRegCFSLineHdlr((uchar *)"resetconfigvariables", 1, eCmdHdlrCustomHandler, resetConfigVariables, NULL, STD_LOADABLE_MODULE_ID));
ENDmodInit
/* vim:set ai:
diff --git a/plugins/imuxsock/imuxsock.c b/plugins/imuxsock/imuxsock.c
index 0e91a977..ad290331 100644
--- a/plugins/imuxsock/imuxsock.c
+++ b/plugins/imuxsock/imuxsock.c
@@ -158,7 +158,6 @@ static int sd_fds = 0; /* number of systemd activated sockets */
/* config settings */
static int bOmitLocalLogging = 0;
static uchar *pLogSockName = NULL;
-static uchar *pLocalIPIF = NULL;
static uchar *pLogHostName = NULL; /* host name to use with this socket */
static int bUseFlowCtl = 0; /* use flow control or not (if yes, only LIGHT is used! */
static int bIgnoreTimestamp = 1; /* ignore timestamps present in the incoming message? */
@@ -766,8 +765,6 @@ ENDrunInput
BEGINwillRun
- uchar myIP[128];
- rsRetVal localRet;
CODESTARTwillRun
register int i;
int actSocks;
@@ -830,22 +827,7 @@ CODESTARTwillRun
CHKiRet(prop.SetString(pInputName, UCHAR_CONSTANT("imuxsock"), sizeof("imuxsock") - 1));
CHKiRet(prop.ConstructFinalize(pInputName));
- if(pLocalIPIF == NULL) {
- strcpy((char*)myIP, "127.0.0.1");
- } else {
- localRet = net.GetIFIPAddr((uchar*)pLocalIPIF, AF_UNSPEC, myIP, (int) sizeof(myIP));
- if(localRet != RS_RET_OK) {
- DBGPRINTF("imuxsock: could not obtain my IP, using 127.0.0.1 instead\n");
- strcpy((char*)myIP, "127.0.0.1");
- }
- }
-
- DBGPRINTF("imuxsock: using '%s' as localhost IP\n", myIP);
-
- CHKiRet(prop.Construct(&pLocalHostIP));
- CHKiRet(prop.SetString(pLocalHostIP, myIP, ustrlen(myIP)));
- CHKiRet(prop.ConstructFinalize(pLocalHostIP));
-
+ pLocalHostIP = glbl.GetLocalHostIP();
finalize_it:
ENDwillRun
@@ -878,7 +860,6 @@ CODESTARTafterRun
}
/* free no longer needed string */
free(pLogSockName);
- free(pLocalIPIF);
free(pLogHostName);
discardLogSockets();
@@ -923,10 +904,6 @@ static rsRetVal resetConfigVariables(uchar __attribute__((unused)) *pp, void __a
free(pLogSockName);
pLogSockName = NULL;
}
- if(pLocalIPIF != NULL) {
- free(pLocalIPIF);
- pLocalIPIF = NULL;
- }
if(pLogHostName != NULL) {
free(pLogHostName);
pLogHostName = NULL;
@@ -1011,8 +988,6 @@ CODEmodInit_QueryRegCFSLineHdlr
NULL, &ratelimitSeverity, STD_LOADABLE_MODULE_ID));
CHKiRet(omsdRegCFSLineHdlr((uchar *)"resetconfigvariables", 1, eCmdHdlrCustomHandler,
resetConfigVariables, NULL, STD_LOADABLE_MODULE_ID));
- CHKiRet(omsdRegCFSLineHdlr((uchar *)"imuxsocklocalipif", 0, eCmdHdlrGetWord,
- NULL, &pLocalIPIF, STD_LOADABLE_MODULE_ID));
/* the following one is a (dirty) trick: the system log socket is not added via
* an "addUnixListenSocket" config format. As such, it's properties can not be modified
* via $InputUnixListenSocket*". So we need to add a special directive
diff --git a/runtime/glbl.c b/runtime/glbl.c
index 134e6c6e..4f2ee377 100644
--- a/runtime/glbl.c
+++ b/runtime/glbl.c
@@ -194,7 +194,7 @@ setLocalHostIPIF(void __attribute__((unused)) *pVal, uchar *pNewVal)
localRet = net.GetIFIPAddr(pNewVal, AF_UNSPEC, myIP, (int) sizeof(myIP));
if(localRet != RS_RET_OK) {
- errmsg.LogError(0, RS_RET_ERR, "$LocalIPIF: IP address for interface "
+ errmsg.LogError(0, RS_RET_ERR, "$LocalHostIPIF: IP address for interface "
"'%s' cannnot be obtained - ignoring directive", pNewVal);
} else {
storeLocalHostIPIF(myIP);