summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--dirty.h5
-rw-r--r--plugins/imfile/imfile.c2
-rw-r--r--plugins/imklog/imklog.c6
-rw-r--r--plugins/imuxsock/imuxsock.c10
-rw-r--r--plugins/ommail/ommail.c6
-rw-r--r--runtime/glbl.h4
-rw-r--r--runtime/net.c15
-rw-r--r--tools/syslogd.c37
8 files changed, 49 insertions, 36 deletions
diff --git a/dirty.h b/dirty.h
index f8e9f959..fdded6ed 100644
--- a/dirty.h
+++ b/dirty.h
@@ -37,11 +37,6 @@
#define ADDDATE 0x004 /* add a date to the message */
#define MARK 0x008 /* this message is a mark */
-extern char **StripDomains;
-extern char *LocalDomain;
-extern char**LocalHosts;
-extern uchar *LocalHostName;
-
#define MSG_PARSE_HOSTNAME 1
#define MSG_DONT_PARSE_HOSTNAME 0
diff --git a/plugins/imfile/imfile.c b/plugins/imfile/imfile.c
index f95f9bc4..a5f1cc8f 100644
--- a/plugins/imfile/imfile.c
+++ b/plugins/imfile/imfile.c
@@ -97,7 +97,7 @@ static rsRetVal enqLine(fileInfo_t *pInfo, cstr_t *cstrLine)
MsgSetUxTradMsg(pMsg, (char*)rsCStrGetSzStr(cstrLine));
MsgSetRawMsg(pMsg, (char*)rsCStrGetSzStr(cstrLine));
MsgSetMSG(pMsg, (char*)rsCStrGetSzStr(cstrLine));
- MsgSetHOSTNAME(pMsg, (char*)LocalHostName);
+ MsgSetHOSTNAME(pMsg, (char*)glbl.GetLocalHostName());
MsgSetTAG(pMsg, (char*)pInfo->pszTag);
pMsg->iFacility = LOG_FAC(pInfo->iFacility);
pMsg->iSeverity = LOG_PRI(pInfo->iSeverity);
diff --git a/plugins/imklog/imklog.c b/plugins/imklog/imklog.c
index 1166b666..e5888620 100644
--- a/plugins/imklog/imklog.c
+++ b/plugins/imklog/imklog.c
@@ -52,12 +52,14 @@
#include "module-template.h"
#include "datetime.h"
#include "imklog.h"
+#include "glbl.h"
MODULE_TYPE_INPUT
/* Module static data */
DEF_IMOD_STATIC_DATA
DEFobjCurrIf(datetime)
+DEFobjCurrIf(glbl)
/* configuration settings */
int dbgPrintSymbols = 0; /* this one is extern so the helpers can access it! */
@@ -95,7 +97,7 @@ enqMsg(uchar *msg, uchar* pszTag, int iFacility, int iSeverity)
MsgSetUxTradMsg(pMsg, (char*)msg);
MsgSetRawMsg(pMsg, (char*)msg);
MsgSetMSG(pMsg, (char*)msg);
- MsgSetHOSTNAME(pMsg, (char*)LocalHostName);
+ MsgSetHOSTNAME(pMsg, (char*)glbl.GetLocalHostName());
MsgSetTAG(pMsg, (char*)pszTag);
pMsg->iFacility = LOG_FAC(iFacility);
pMsg->iSeverity = LOG_PRI(iSeverity);
@@ -225,6 +227,7 @@ ENDafterRun
BEGINmodExit
CODESTARTmodExit
/* release objects we used */
+ objRelease(glbl, CORE_COMPONENT);
objRelease(datetime, CORE_COMPONENT);
ENDmodExit
@@ -251,6 +254,7 @@ CODESTARTmodInit
*ipIFVersProvided = CURR_MOD_IF_VERSION; /* we only support the current interface specification */
CODEmodInit_QueryRegCFSLineHdlr
CHKiRet(objUse(datetime, CORE_COMPONENT));
+ CHKiRet(objUse(glbl, CORE_COMPONENT));
iFacilIntMsg = klogFacilIntMsg();
diff --git a/plugins/imuxsock/imuxsock.c b/plugins/imuxsock/imuxsock.c
index 3ef2c3d1..6c6b7f94 100644
--- a/plugins/imuxsock/imuxsock.c
+++ b/plugins/imuxsock/imuxsock.c
@@ -41,6 +41,7 @@
#include "srUtils.h"
#include "errmsg.h"
#include "net.h"
+#include "glbl.h"
MODULE_TYPE_INPUT
@@ -63,6 +64,7 @@ MODULE_TYPE_INPUT
/* Module static data */
DEF_IMOD_STATIC_DATA
DEFobjCurrIf(errmsg)
+DEFobjCurrIf(glbl)
static int startIndexUxLocalSockets; /* process funix from that index on (used to
* suppress local logging. rgerhards 2005-08-01
@@ -182,7 +184,7 @@ static rsRetVal readSocket(int fd, int bParseHost, int flags)
iRcvd = recv(fd, line, MAXLINE - 1, 0);
dbgprintf("Message from UNIX socket: #%d\n", fd);
if (iRcvd > 0) {
- parseAndSubmitMessage((char*)LocalHostName, line, iRcvd, bParseHost, flags, eFLOWCTL_LIGHT_DELAY);
+ parseAndSubmitMessage((char*)glbl.GetLocalHostName(), line, iRcvd, bParseHost, flags, eFLOWCTL_LIGHT_DELAY);
} else if (iRcvd < 0 && errno != EINTR) {
char errStr[1024];
rs_strerror_r(errno, errStr, sizeof(errStr));
@@ -290,6 +292,8 @@ ENDafterRun
BEGINmodExit
CODESTARTmodExit
+ objRelease(glbl, CORE_COMPONENT);
+ objRelease(errmsg, CORE_COMPONENT);
ENDmodExit
@@ -320,6 +324,7 @@ CODESTARTmodInit
*ipIFVersProvided = CURR_MOD_IF_VERSION; /* we only support the current interface specification */
CODEmodInit_QueryRegCFSLineHdlr
CHKiRet(objUse(errmsg, CORE_COMPONENT));
+ CHKiRet(objUse(glbl, CORE_COMPONENT));
/* initialize funixn[] array */
for(i = 1 ; i < MAXFUNIX ; ++i) {
@@ -347,6 +352,5 @@ CODEmodInit_QueryRegCFSLineHdlr
CHKiRet(omsdRegCFSLineHdlr((uchar *)"systemlogsocketignoremsgtimestamp", 0, eCmdHdlrBinary,
setSystemLogTimestampIgnore, NULL, STD_LOADABLE_MODULE_ID));
ENDmodInit
-/*
- * vi:set ai:
+/* vim:set ai:
*/
diff --git a/plugins/ommail/ommail.c b/plugins/ommail/ommail.c
index 0dda78e9..d4158975 100644
--- a/plugins/ommail/ommail.c
+++ b/plugins/ommail/ommail.c
@@ -50,6 +50,7 @@
#include "cfsysline.h"
#include "module-template.h"
#include "errmsg.h"
+#include "glbl.h"
MODULE_TYPE_OUTPUT
@@ -57,6 +58,7 @@ MODULE_TYPE_OUTPUT
*/
DEF_OMOD_STATIC_DATA
DEFobjCurrIf(errmsg)
+DEFobjCurrIf(glbl)
static uchar *pszSrv = NULL;
static uchar *pszSrvPort = NULL;
@@ -415,7 +417,7 @@ sendSMTP(instanceData *pData, uchar *body, uchar *subject)
CHKiRet(readResponse(pData, &iState, 220));
CHKiRet(Send(pData->md.smtp.sock, "HELO ", 5));
- CHKiRet(Send(pData->md.smtp.sock, (char*)LocalHostName, strlen((char*)LocalHostName)));
+ CHKiRet(Send(pData->md.smtp.sock, (char*)glbl.GetLocalHostName(), strlen((char*)glbl.GetLocalHostName())));
CHKiRet(Send(pData->md.smtp.sock, "\r\n", sizeof("\r\n") - 1));
CHKiRet(readResponse(pData, &iState, 250));
@@ -589,6 +591,7 @@ CODESTARTmodExit
freeConfigVariables();
/* release what we no longer need */
+ objRelease(glbl, CORE_COMPONENT);
objRelease(errmsg, CORE_COMPONENT);
ENDmodExit
@@ -616,6 +619,7 @@ CODESTARTmodInit
CODEmodInit_QueryRegCFSLineHdlr
/* tell which objects we need */
CHKiRet(objUse(errmsg, CORE_COMPONENT));
+ CHKiRet(objUse(glbl, CORE_COMPONENT));
CHKiRet(omsdRegCFSLineHdlr( (uchar *)"actionmailsmtpserver", 0, eCmdHdlrGetWord, NULL, &pszSrv, STD_LOADABLE_MODULE_ID));
CHKiRet(omsdRegCFSLineHdlr( (uchar *)"actionmailsmtpport", 0, eCmdHdlrGetWord, NULL, &pszSrvPort, STD_LOADABLE_MODULE_ID));
diff --git a/runtime/glbl.h b/runtime/glbl.h
index 3116b66b..eb0495b2 100644
--- a/runtime/glbl.h
+++ b/runtime/glbl.h
@@ -54,6 +54,10 @@ BEGINinterface(glbl) /* name must also be changed in ENDinterface macro! */
SIMP_PROP(DropMalPTRMsgs, int);
SIMP_PROP(Option_DisallowWarning, int);
SIMP_PROP(DisableDNS, int);
+ SIMP_PROP(LocalHostName, uchar*)
+ SIMP_PROP(LocalDomain, uchar*)
+ SIMP_PROP(StripDomains, char**)
+ SIMP_PROP(LocalHosts, char**)
#undef SIMP_PROP
ENDinterface(glbl)
#define glblCURR_IF_VERSION 1 /* increment whenever you change the interface structure! */
diff --git a/runtime/net.c b/runtime/net.c
index bc4404cb..777d3fad 100644
--- a/runtime/net.c
+++ b/runtime/net.c
@@ -55,7 +55,6 @@
#include <fcntl.h>
#include <unistd.h>
-#include "dirty.h"
#include "syslogd-types.h"
#include "module-template.h"
#include "parse.h"
@@ -814,7 +813,7 @@ rsRetVal cvthname(struct sockaddr_storage *f, uchar *pszHost, uchar *pszHostFQDN
*/
strcpy((char*)pszHost, (char*)pszHostFQDN);
if ((p = (uchar*) strchr((char*)pszHost, '.'))) { /* find start of domain name "machine.example.com" */
- if(strcmp((char*) (p + 1), LocalDomain) == 0) {
+ if(strcmp((char*)(p + 1), (char*)glbl.GetLocalDomain()) == 0) {
*p = '\0'; /* simply terminate the string */
} else {
/* now check if we belong to any of the domain names that were specified
@@ -823,10 +822,10 @@ rsRetVal cvthname(struct sockaddr_storage *f, uchar *pszHost, uchar *pszHostFQDN
* For proper modularization, this must be done different, e.g. via a
* "to be stripped" property of *this* object itself.
*/
- if (StripDomains) {
+ if(glbl.GetStripDomains() != NULL) {
count=0;
- while (StripDomains[count]) {
- if (strcmp((char*)(p + 1), StripDomains[count]) == 0) {
+ while(glbl.GetStripDomains()[count]) {
+ if (strcmp((char*)(p + 1), glbl.GetStripDomains()[count]) == 0) {
*p = '\0';
FINALIZE; /* we are done */
}
@@ -842,10 +841,10 @@ rsRetVal cvthname(struct sockaddr_storage *f, uchar *pszHost, uchar *pszHostFQDN
* still occurs at *p, which points at the first dot after the hostname.
* TODO: this must also go away - see comment above -- rgerhards, 2008-04-16
*/
- if (LocalHosts) {
+ if(glbl.GetLocalHosts() != NULL) {
count=0;
- while (LocalHosts[count]) {
- if (!strcmp((char*)pszHost, LocalHosts[count])) {
+ while (glbl.GetLocalHosts()[count]) {
+ if (!strcmp((char*)pszHost, (char*)glbl.GetLocalHosts()[count])) {
*p = '\0';
break; /* we are done */
}
diff --git a/tools/syslogd.c b/tools/syslogd.c
index 44607aea..33a33823 100644
--- a/tools/syslogd.c
+++ b/tools/syslogd.c
@@ -291,13 +291,9 @@ int iActExecOnceInterval = 0; /* execute action once every nn seconds */
uchar *glblModPath = NULL; /* module load path - only used during initial init, only settable via -M command line option */
/* end global config file state variables */
-uchar *LocalHostName = NULL;/* our hostname - read-only after startup */
-char *LocalDomain; /* our local domain name - read-only after startup */
int MarkInterval = 20 * 60; /* interval between marks in seconds - read-only after startup */
int send_to_all = 0; /* send message to all IPv4/IPv6 addresses */
static int NoFork = 0; /* don't fork - don't run in daemon mode - read-only after startup */
-char **StripDomains = NULL;/* these domains may be stripped before writing logs - r/o after s.u., never touched by init */
-char **LocalHosts = NULL;/* these hosts are logged with their hostname - read-only after startup, never touched by init */
static int bHaveMainQueue = 0;/* set to 1 if the main queue - in queueing mode - is available
* If the main queue is either not yet ready or not running in
* queueing mode (mode DIRECT!), then this is set to 0.
@@ -870,8 +866,8 @@ logmsgInternal(int pri, char *msg, int flags)
CHKiRet(msgConstruct(&pMsg));
MsgSetUxTradMsg(pMsg, msg);
MsgSetRawMsg(pMsg, msg);
- MsgSetHOSTNAME(pMsg, (LocalHostName == NULL) ? "[localhost]" : (char*)LocalHostName);
- MsgSetRcvFrom(pMsg, (LocalHostName == NULL) ? "[localhost]" : (char*)LocalHostName);
+ MsgSetHOSTNAME(pMsg, (char*)glbl.GetLocalHostName());
+ MsgSetRcvFrom(pMsg, (char*)glbl.GetLocalHostName());
MsgSetTAG(pMsg, "rsyslogd:");
pMsg->iFacility = LOG_FAC(pri);
pMsg->iSeverity = LOG_PRI(pri);
@@ -1841,8 +1837,6 @@ freeAllDynMemForTermination(void)
free(pszMainMsgQFName);
if(pModDir != NULL)
free(pModDir);
- if(LocalHostName != NULL)
- free(LocalHostName);
}
@@ -2938,7 +2932,7 @@ int realMain(int argc, char **argv)
DEFiRet;
register int i;
- register char *p;
+ register uchar *p;
int num_fds;
int ch;
struct hostent *hent;
@@ -2950,6 +2944,8 @@ int realMain(int argc, char **argv)
int bImUxSockLoaded = 0; /* already generated a $ModLoad imuxsock? */
char *arg; /* for command line option processing */
uchar legacyConfLine[80];
+ uchar *LocalHostName;
+ uchar *LocalDomain;
/* first, parse the command line options. We do not carry out any actual work, just
* see what we should do. This relieves us from certain anomalies and we can process
@@ -3063,11 +3059,11 @@ int realMain(int argc, char **argv)
* error log messages, which need the correct hostname. -- rgerhards, 2008-04-04
*/
net.getLocalHostname(&LocalHostName);
- if((p = strchr((char*)LocalHostName, '.'))) {
+ if((p = (uchar*)strchr((char*)LocalHostName, '.'))) {
*p++ = '\0';
LocalDomain = p;
} else {
- LocalDomain = "";
+ LocalDomain = (uchar*)"";
/* It's not clearly defined whether gethostname()
* should return the simple hostname or the fqdn. A
@@ -3087,7 +3083,7 @@ int realMain(int argc, char **argv)
free(LocalHostName);
CHKmalloc(LocalHostName = (uchar*)strdup(hent->h_name));
- if((p = strchr((char*)LocalHostName, '.')))
+ if((p = (uchar*)strchr((char*)LocalHostName, '.')))
{
*p++ = '\0';
LocalDomain = p;
@@ -3096,8 +3092,15 @@ int realMain(int argc, char **argv)
}
/* Convert to lower case to recognize the correct domain laterly */
- for (p = (char *)LocalDomain ; *p ; p++)
+ for(p = LocalDomain ; *p ; p++)
*p = (char)tolower((int)*p);
+
+ /* we now have our hostname and can set it inside the global vars.
+ * TODO: think if all of this would better be a runtime function
+ * rgerhards, 2008-04-17
+ */
+ glbl.SetLocalHostName(LocalHostName);
+ glbl.SetLocalDomain(LocalDomain);
/* initialize the objects */
if((iRet = modInitIminternal()) != RS_RET_OK) {
@@ -3158,10 +3161,10 @@ int realMain(int argc, char **argv)
PidFile = arg;
break;
case 'l':
- if (LocalHosts) {
+ if(glbl.GetLocalHosts() != NULL) {
fprintf (stderr, "rsyslogd: Only one -l argument allowed, the first one is taken.\n");
} else {
- LocalHosts = crunch_list(arg);
+ glbl.SetLocalHosts(crunch_list(arg));
}
break;
case 'm': /* mark interval */
@@ -3211,10 +3214,10 @@ int realMain(int argc, char **argv)
fprintf(stderr, "-r option only supported in compatibility modes 0 to 2 - ignored\n");
break;
case 's':
- if (StripDomains) {
+ if(glbl.GetStripDomains() != NULL) {
fprintf (stderr, "rsyslogd: Only one -s argument allowed, the first one is taken.\n");
} else {
- StripDomains = crunch_list(arg);
+ glbl.SetStripDomains(crunch_list(arg));
}
break;
case 't': /* enable tcp logging */