summaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2012-03-12 17:00:21 +0100
committerRainer Gerhards <rgerhards@adiscon.com>2012-03-12 17:00:21 +0100
commitf90675f33f33b8a83046f8a8462dd8dbe7648a4a (patch)
treef695e6371b52141de4c4ce2295b317a1e487e7b3 /plugins
parent14d415e4a84e2c08df1b23a86959f0d9b0006687 (diff)
parent74e09afd6db56f6e23c965f0949cfb9979928f13 (diff)
downloadrsyslog-f90675f33f33b8a83046f8a8462dd8dbe7648a4a.tar.gz
rsyslog-f90675f33f33b8a83046f8a8462dd8dbe7648a4a.tar.xz
rsyslog-f90675f33f33b8a83046f8a8462dd8dbe7648a4a.zip
Merge branch 'v5-stable-newstats' into v5-devel
Conflicts: ChangeLog action.c configure.ac doc/imuxsock.html doc/manual.html runtime/queue.c
Diffstat (limited to 'plugins')
-rw-r--r--plugins/imklog/imklog.c27
-rw-r--r--plugins/imptcp/imptcp.c4
-rw-r--r--plugins/imudp/imudp.c4
-rw-r--r--plugins/imuxsock/imuxsock.c35
4 files changed, 62 insertions, 8 deletions
diff --git a/plugins/imklog/imklog.c b/plugins/imklog/imklog.c
index 6e83e780..1666473d 100644
--- a/plugins/imklog/imklog.c
+++ b/plugins/imklog/imklog.c
@@ -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"
@@ -67,6 +69,7 @@ DEF_IMOD_STATIC_DATA
DEFobjCurrIf(datetime)
DEFobjCurrIf(glbl)
DEFobjCurrIf(prop)
+DEFobjCurrIf(net)
/* configuration settings */
int dbgPrintSymbols = 0; /* this one is extern so the helpers can access it! */
@@ -74,6 +77,7 @@ 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;
@@ -258,10 +262,22 @@ 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));
- CHKiRet(prop.CreateStringProp(&pLocalHostIP, UCHAR_CONSTANT("127.0.0.1"), sizeof("127.0.0.1") - 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)));
iRet = klogWillRun();
finalize_it:
@@ -276,6 +292,7 @@ CODESTARTafterRun
prop.Destruct(&pInputName);
if(pLocalHostIP != NULL)
prop.Destruct(&pLocalHostIP);
+ free(pLocalIPIF);
ENDafterRun
@@ -283,6 +300,7 @@ BEGINmodExit
CODESTARTmodExit
/* release objects we used */
objRelease(glbl, CORE_COMPONENT);
+ objRelease(net, CORE_COMPONENT);
objRelease(datetime, CORE_COMPONENT);
objRelease(prop, CORE_COMPONENT);
if(pszPath != NULL)
@@ -307,6 +325,10 @@ 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;
}
@@ -318,6 +340,7 @@ CODEmodInit_QueryRegCFSLineHdlr
CHKiRet(objUse(datetime, CORE_COMPONENT));
CHKiRet(objUse(glbl, CORE_COMPONENT));
CHKiRet(objUse(prop, CORE_COMPONENT));
+ CHKiRet(objUse(net, CORE_COMPONENT));
iFacilIntMsg = klogFacilIntMsg();
@@ -329,6 +352,8 @@ 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/imptcp/imptcp.c b/plugins/imptcp/imptcp.c
index a735b0b2..f95d1193 100644
--- a/plugins/imptcp/imptcp.c
+++ b/plugins/imptcp/imptcp.c
@@ -290,7 +290,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);
diff --git a/plugins/imudp/imudp.c b/plugins/imudp/imudp.c
index 0db6bf9a..112738b4 100644
--- a/plugins/imudp/imudp.c
+++ b/plugins/imudp/imudp.c
@@ -244,8 +244,10 @@ static rsRetVal addListner(void __attribute__((unused)) *pVal, uchar *pNewVal)
lcnfRoot = newlcnfinfo;
if(lcnfLast == NULL)
lcnfLast = newlcnfinfo;
- else
+ else {
lcnfLast->next = newlcnfinfo;
+ lcnfLast = newlcnfinfo;
+ }
}
}
diff --git a/plugins/imuxsock/imuxsock.c b/plugins/imuxsock/imuxsock.c
index 29c9c949..29484ba3 100644
--- a/plugins/imuxsock/imuxsock.c
+++ b/plugins/imuxsock/imuxsock.c
@@ -90,6 +90,7 @@ DEF_IMOD_STATIC_DATA
DEFobjCurrIf(errmsg)
DEFobjCurrIf(glbl)
DEFobjCurrIf(prop)
+DEFobjCurrIf(net)
DEFobjCurrIf(parser)
DEFobjCurrIf(datetime)
DEFobjCurrIf(statsobj)
@@ -160,6 +161,7 @@ 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? */
@@ -947,6 +949,8 @@ ENDrunInput
BEGINwillRun
+ uchar myIP[128];
+ rsRetVal localRet;
CODESTARTwillRun
register int i;
int actSocks;
@@ -967,7 +971,7 @@ CODESTARTwillRun
else if(sd_booted()) {
struct stat st;
if(stat(SYSTEMD_JOURNAL, &st) != -1 && S_ISDIR(st.st_mode)) {
- listeners[0].sockName = SYSTEMD_PATH_LOG;
+ listeners[0].sockName = (uchar*)SYSTEMD_PATH_LOG;
}
}
if(ratelimitIntervalSysSock > 0) {
@@ -1011,6 +1015,23 @@ 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));
+
+
finalize_it:
ENDwillRun
@@ -1041,6 +1062,7 @@ CODESTARTafterRun
}
/* free no longer needed string */
free(pLogSockName);
+ free(pLocalIPIF);
free(pLogHostName);
discardLogSockets();
@@ -1085,6 +1107,10 @@ 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;
@@ -1117,6 +1143,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));
@@ -1142,10 +1169,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())));
@@ -1180,6 +1203,8 @@ 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