summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2012-04-12 15:11:50 +0200
committerRainer Gerhards <rgerhards@adiscon.com>2012-04-12 15:11:50 +0200
commit7177afe484e5ded6b0d65d19e18489cdacfeb0fa (patch)
tree721b623150baa67e9254d9176eac04773a395e9b
parente2978cd396551280274bd7a17ec3034e4a0dab9e (diff)
parent80d62d6bb7fe19c50f10732f98c8de90094845b0 (diff)
downloadrsyslog-7177afe484e5ded6b0d65d19e18489cdacfeb0fa.tar.gz
rsyslog-7177afe484e5ded6b0d65d19e18489cdacfeb0fa.tar.xz
rsyslog-7177afe484e5ded6b0d65d19e18489cdacfeb0fa.zip
Merge branch 'v5-beta'
Conflicts: ChangeLog configure.ac doc/manual.html plugins/imuxsock/imuxsock.c tools/syslogd.c
-rw-r--r--ChangeLog53
-rw-r--r--configure.ac2
-rw-r--r--doc/manual.html11
-rw-r--r--doc/rsyslog_conf_global.html9
-rw-r--r--doc/v5compatibility.html1
-rw-r--r--doc/version_naming.html4
-rw-r--r--plugins/imuxsock/imuxsock.c11
-rw-r--r--runtime/glbl.c88
-rw-r--r--tools/syslogd.c169
9 files changed, 210 insertions, 138 deletions
diff --git a/ChangeLog b/ChangeLog
index 32e58311..35a7edc2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,18 +1,4 @@
---------------------------------------------------------------------------
-Version 5.9.6 [V5-DEVEL], 2012-03-??
-- permit size modifiers (k,m,g,...) in integer config parameters
- Thanks to Jo Rhett for the suggestion.
-- bugfix: imklog invalidly computed facility and severity
- closes: http://bugzilla.adiscon.com/show_bug.cgi?id=313
-- 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
- added "date-unixtimestamp" property replacer option to format as a
@@ -26,6 +12,9 @@ Version 6.3.8 [DEVEL] 2012-02-??
- ommysql
- omlibdbi
- omsnmp
+- added configuration directives to customize queue light delay marks
+ $MainMsgQueueLightDelayMark, $ActionQueueLightDelayMark; both
+ specify number of messages starting at which a delay happens.
- added message property parsesuccess to indicate if the last run
higher-level parser could successfully parse the message or not
(see property replacer html doc for details)
@@ -34,6 +23,19 @@ Version 6.3.8 [DEVEL] 2012-02-??
- bugfix: property $!all-json made rsyslog abort if no normalized data
was available
- bugfix: memory leak in array passing output module mode
+- added configuration directives to customize queue light delay marks
+- permit size modifiers (k,m,g,...) in integer config parameters
+ Thanks to Jo Rhett for the suggestion.
+- bugfix: hostname was not requeried on HUP
+ Thanks to Per Jessen for reporting this bug and Marius Tomaschewski for
+ his help in testing the fix.
+- bugfix: imklog invalidly computed facility and severity
+ closes: http://bugzilla.adiscon.com/show_bug.cgi?id=313
+- 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
---------------------------------------------------------------------------
Version 6.3.7 [DEVEL] 2012-02-02
- imported refactored v5.9.6 imklog linux driver, now combined with BSD
@@ -383,6 +385,24 @@ expected that interfaces, even new ones, break during the initial
syslog plain tcp input plugin (NOT supporting TLS!)
[ported from v4]
---------------------------------------------------------------------------
+Version 5.9.6 [V5-BETA], 2012-04-12
+- added configuration directives to customize queue light delay marks
+- permit size modifiers (k,m,g,...) in integer config parameters
+ Thanks to Jo Rhett for the suggestion.
+- bugfix: hostname was not requeried on HUP
+ Thanks to Per Jessen for reporting this bug and Marius Tomaschewski for
+ his help in testing the fix.
+- bugfix: imklog invalidly computed facility and severity
+ closes: http://bugzilla.adiscon.com/show_bug.cgi?id=313
+- 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 5.9.5 [V5-DEVEL], 2012-01-27
- improved impstats subsystem, added many new counters
- enhanced module loader to not rely on PATH_MAX
@@ -498,6 +518,11 @@ Version 5.9.0 [V5-DEVEL] (rgerhards), 2011-06-08
affected directive was: $ActionExecOnlyWhenPreviousIsSuspended on
closes: http://bugzilla.adiscon.com/show_bug.cgi?id=236
---------------------------------------------------------------------------
+Version 5.8.11 [V5-stable] 2012-04-??
+- bugfix: hostname was not requeried on HUP
+ Thanks to Per Jessen for reporting this bug and Marius Tomaschewski for
+ his help in testing the fix.
+---------------------------------------------------------------------------
Version 5.8.10 [V5-stable] 2012-04-05
- bugfix: segfault on startup if $actionqueuefilename was missing for disk
queue config
diff --git a/configure.ac b/configure.ac
index 8642da2f..94d43d85 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2,7 +2,7 @@
# Process this file with autoconf to produce a configure script.
AC_PREREQ(2.61)
-AC_INIT([rsyslog],[6.3.7-tmp1],[rsyslog@lists.adiscon.com])
+AC_INIT([rsyslog],[6.3.8],[rsyslog@lists.adiscon.com])
AM_INIT_AUTOMAKE
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
diff --git a/doc/manual.html b/doc/manual.html
index 565b3758..8f74e806 100644
--- a/doc/manual.html
+++ b/doc/manual.html
@@ -19,7 +19,7 @@ rsyslog support</a> available directly from the source!</p>
<p><b>Please visit the <a href="http://www.rsyslog.com/sponsors">rsyslog sponsor's page</a>
to honor the project sponsors or become one yourself!</b> We are very grateful for any help towards the
project goals.</p>
-<p><b>This documentation is for version 6.3.7 (devel branch) of rsyslog.</b>
+<p><b>This documentation is for version 6.3.8 (devel branch) of rsyslog.</b>
Visit the <i><a href="http://www.rsyslog.com/status">rsyslog status page</a></i></b>
to obtain current version information and project status.
</p><p><b>If you like rsyslog, you might
@@ -49,8 +49,9 @@ if you do not read the doc, but doing so will definitely improve your experience
<li><a href="generic_design.html">backgrounder on generic syslog application design</a></li>
<li><a href="modules.html">description of rsyslog modules</a></li>
<li><a href="rsyslog_packages.html">rsyslog packages</a></li>
-<li><a href="http://cookbook.rsyslog.com">the rsyslog "cookbook"</a> - a set of configurations ready to use</li>
</ul>
+<p><b>To keep current on rsyslog development, follow
+<a href="http://twitter.com/rgerhards">Rainer's twitter feed</a>.</b></p>
<p><b>We have some in-depth papers on</b></p>
<ul>
<li><a href="install.html">installing rsyslog</a></li>
@@ -106,14 +107,16 @@ online documentation (most current version only)</a></li>
mailing list</a>. If you are interested in the "backstage", you
may find
<a href="http://www.gerhards.net/rainer">Rainer</a>'s
-<a href="http://rgerhards.blogspot.com/">blog</a> an
+<a href="http://blog.gerhards.net/">blog</a> an
interesting read (filter on syslog and rsyslog tags).
+Or meet <a href="http://www.facebook.com/people/Rainer-Gerhards/1349393098">Rainer Gerhards at Facebook</a>
+or <a href="https://plus.google.com/112402185904751517878/posts">Google+</a>.
If you would like to use rsyslog source code inside your open source project, you can do that without
any restriction as long as your license is GPLv3 compatible. If your license is incompatible to GPLv3,
you may even be still permitted to use rsyslog source code. However, then you need to look at the way
<a href="licensing.html">rsyslog is licensed</a>.</p>
<p>Feedback is always welcome, but if you have a support question, please do not
mail Rainer directly (<a href="free_support.html">why not?</a>) - use the
-<a href="http://lists.adiscon.net/mailman/listinfo/rsyslog">rsyslogmailing list</a>
+<a href="http://lists.adiscon.net/mailman/listinfo/rsyslog">rsyslog mailing list</a>
or <a href="http://kb.monitorware.com/rsyslog-f40.html">rsyslog formum</a> instead.
</body></html>
diff --git a/doc/rsyslog_conf_global.html b/doc/rsyslog_conf_global.html
index 8cfdd303..6c20f4c2 100644
--- a/doc/rsyslog_conf_global.html
+++ b/doc/rsyslog_conf_global.html
@@ -153,15 +153,6 @@ our paper on <a href="multi_ruleset.html">using multiple rule sets in rsyslog</a
<li><a href="rsconf1_gssforwardservicename.html">$GssForwardServiceName</a></li>
<li><a href="rsconf1_gsslistenservicename.html">$GssListenServiceName</a></li>
<li><a href="rsconf1_gssmode.html">$GssMode</a></li>
-<li>$HUPisRestart [on/<b>off</b>] - if set to on, a HUP is a full daemon restart. This means any queued messages are discarded (depending
-on queue configuration, of course) all modules are unloaded and reloaded. This mode keeps compatible with sysklogd, but is
-not recommended for use with rsyslog. To do a full restart, simply stop and start the daemon. The default (since 4.5.1) is "off".
-If it is set to "off", a HUP will only close open files. This is a much quicker action and usually
-the only one that is needed e.g. for log rotation. <b>Restart-type HUPs (value "on") are depricated</b>
-and will go away in rsyslog v5. So it is a good idea to change anything that needs it, now.
-Usually that should not be a big issue, as the restart-type HUP can easily be replaced by
-something along the lines of &quot;/etc/init.d/rsyslog restart&quot;.
-</li>
<li><a href="rsconf1_includeconfig.html">$IncludeConfig</a></li><li>MainMsgQueueCheckpointInterval &lt;number&gt;</li>
<li><b>$LocalHostName</b> [name] - this directive permits to overwrite the system
hostname with the one specified in the directive. If the directive is given
diff --git a/doc/v5compatibility.html b/doc/v5compatibility.html
index cc875b7b..fc4289c5 100644
--- a/doc/v5compatibility.html
+++ b/doc/v5compatibility.html
@@ -16,6 +16,7 @@ available. This processing was redundant and had a lot a drawbacks.
For details, please see the
<a href="v4compatibility.html">rsyslog v4 compatibility notes</a> which elaborate
on the reasons and the (few) things you may need to change.
+<p>Please note that starting with 5.8.11 HUP will also requery the local hostname.
<h2>Queue on-disk format</h2>
<p>The queue information file format has been changed. When upgrading from v4 to
v5, make sure that the queue is emptied and no on-disk structure present. We did
diff --git a/doc/version_naming.html b/doc/version_naming.html
index 8c1b9187..3bfa19bb 100644
--- a/doc/version_naming.html
+++ b/doc/version_naming.html
@@ -105,7 +105,7 @@ versions. It applies to versions 1.0.0 and above. Versions below that
are all unstable and have a different naming schema.</p>
<p><b>Please note that version naming is currently being
changed. There is a
-<a href="http://rgerhards.blogspot.com/2007/08/on-rsyslog-versions.html">blog
+<a href="http://blog.gerhards.net/2007/08/on-rsyslog-versions.html">blog
post about future rsyslog versions</a>.</b></p>
<p>The major version is incremented whenever a considerate, major
features have been added. This is expected to happen quite infrequently.</p>
@@ -127,4 +127,4 @@ expected to happen quite infrequently.</p>
<p>In general, the unstable branch carries all new development.
Once it concludes with a sufficiently-enhanced, quite stable version, a
new major stable version is assigned.</p>
-</body></html> \ No newline at end of file
+</body></html>
diff --git a/plugins/imuxsock/imuxsock.c b/plugins/imuxsock/imuxsock.c
index 4a7e7b42..ca762d64 100644
--- a/plugins/imuxsock/imuxsock.c
+++ b/plugins/imuxsock/imuxsock.c
@@ -379,8 +379,7 @@ addListner(instanceConf_t *inst)
}
CHKiRet(prop.Construct(&(listeners[nfd].hostName)));
if(inst->pLogHostName == NULL) {
- CHKiRet(prop.SetString(listeners[nfd].hostName, glbl.GetLocalHostName(),
- ustrlen(glbl.GetLocalHostName())));
+ listeners[nfd].hostName = NULL;
} else {
CHKiRet(prop.SetString(listeners[nfd].hostName, inst->pLogHostName, ustrlen(inst->pLogHostName)));
}
@@ -864,7 +863,7 @@ SubmitMsg(uchar *pRcv, int lenRcv, lstn_t *pLstn, struct ucred *cred, struct tim
pMsg->msgFlags = pLstn->flags;
}
- MsgSetRcvFrom(pMsg, pLstn->hostName);
+ MsgSetRcvFrom(pMsg, pLstn->hostName == NULL ? glbl.GetLocalHostNameProp() : pLstn->hostName);
CHKiRet(MsgSetRcvFromIP(pMsg, pLocalHostIP));
CHKiRet(submitMsg(pMsg));
@@ -1297,9 +1296,9 @@ CODEmodInit_QueryRegCFSLineHdlr
}
/* 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())));
- CHKiRet(prop.ConstructFinalize(listeners[0].hostName));
+ CHKiRet(prop.Construct(&pLocalHostIP));
+ CHKiRet(prop.SetString(pLocalHostIP, UCHAR_CONSTANT("127.0.0.1"), sizeof("127.0.0.1") - 1));
+ CHKiRet(prop.ConstructFinalize(pLocalHostIP));
/* register config file handlers */
CHKiRet(omsdRegCFSLineHdlr((uchar *)"omitlocallogging", 0, eCmdHdlrBinary,
diff --git a/runtime/glbl.c b/runtime/glbl.c
index a6c46789..537b7b4f 100644
--- a/runtime/glbl.c
+++ b/runtime/glbl.c
@@ -71,10 +71,10 @@ static int option_DisallowWarning = 1; /* complain if message from disallowed se
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 *LocalHostName = NULL;/* our hostname - read-only after startup, except HUP */
static uchar *LocalHostNameOverride = NULL;/* user-overridden hostname - read-only after startup */
-static uchar *LocalFQDNName = NULL;/* our hostname as FQDN - read-only after startup */
-static uchar *LocalDomain; /* our local domain name - read-only after startup */
+static uchar *LocalFQDNName = NULL;/* our hostname as FQDN - read-only after startup, except HUP */
+static uchar *LocalDomain = NULL;/* our local domain name - read-only after startup, except HUP */
static char **StripDomains = NULL;/* these domains may be stripped before writing logs - r/o after s.u., never touched by init */
static char **LocalHosts = NULL;/* these hosts are logged with their hostname - read-only after startup, never touched by init */
static uchar *pszDfltNetstrmDrvr = NULL; /* module name of default netstream driver */
@@ -140,15 +140,12 @@ SIMP_PROP(DefPFFamily, iDefPFFamily, int) /* note that in the future we may chec
SIMP_PROP(DropMalPTRMsgs, bDropMalPTRMsgs, int)
SIMP_PROP(Option_DisallowWarning, option_DisallowWarning, int)
SIMP_PROP(DisableDNS, bDisableDNS, int)
-SIMP_PROP(LocalDomain, LocalDomain, uchar*)
SIMP_PROP(StripDomains, StripDomains, char**)
SIMP_PROP(LocalHosts, LocalHosts, char**)
#ifdef USE_UNLIMITED_SELECT
SIMP_PROP(FdSetSize, iFdSetSize, int)
#endif
-SIMP_PROP_SET(LocalFQDNName, LocalFQDNName, uchar*)
-SIMP_PROP_SET(LocalHostName, LocalHostName, uchar*)
SIMP_PROP_SET(DfltNetstrmDrvr, pszDfltNetstrmDrvr, uchar*) /* TODO: use custom function which frees existing value */
SIMP_PROP_SET(DfltNetstrmDrvrCAF, pszDfltNetstrmDrvrCAF, uchar*) /* TODO: use custom function which frees existing value */
SIMP_PROP_SET(DfltNetstrmDrvrKeyFile, pszDfltNetstrmDrvrKeyFile, uchar*) /* TODO: use custom function which frees existing value */
@@ -297,6 +294,20 @@ GetLocalHostIP(void)
return(propLocalIPIF);
}
+
+/* set our local hostname. Free previous hostname, if it was already set.
+ * Note that we do now do this in a thread
+ * "once in a lifetime" action which can not be undone. -- gerhards, 2009-07-20
+ */
+static rsRetVal
+SetLocalHostName(uchar *newname)
+{
+ free(LocalHostName);
+ LocalHostName = newname;
+ return RS_RET_OK;
+}
+
+
/* return our local hostname. if it is not set, "[localhost]" is returned
*/
static uchar*
@@ -322,6 +333,26 @@ done:
}
+/* set our local domain name. Free previous domain, if it was already set.
+ */
+static rsRetVal
+SetLocalDomain(uchar *newname)
+{
+ free(LocalDomain);
+ LocalDomain = newname;
+ return RS_RET_OK;
+}
+
+
+/* return our local hostname. if it is not set, "[localhost]" is returned
+ */
+static uchar*
+GetLocalDomain(void)
+{
+ return LocalDomain;
+}
+
+
/* generate the local hostname property. This must be done after the hostname info
* has been set as well as PreserveFQDN.
* rgerhards, 2009-06-30
@@ -366,6 +397,14 @@ GetLocalHostNameProp(void)
}
+static rsRetVal
+SetLocalFQDNName(uchar *newname)
+{
+ free(LocalFQDNName);
+ LocalFQDNName = newname;
+ return RS_RET_OK;
+}
+
/* return the current localhost name as FQDN (requires FQDN to be set)
* TODO: we should set the FQDN ourselfs in here!
*/
@@ -469,30 +508,18 @@ ENDobjQueryInterface(glbl)
*/
static rsRetVal resetConfigVariables(uchar __attribute__((unused)) *pp, void __attribute__((unused)) *pVal)
{
- if(pszDfltNetstrmDrvr != NULL) {
- free(pszDfltNetstrmDrvr);
- pszDfltNetstrmDrvr = NULL;
- }
- if(pszDfltNetstrmDrvrCAF != NULL) {
- free(pszDfltNetstrmDrvrCAF);
- pszDfltNetstrmDrvrCAF = NULL;
- }
- if(pszDfltNetstrmDrvrKeyFile != NULL) {
- free(pszDfltNetstrmDrvrKeyFile);
- pszDfltNetstrmDrvrKeyFile = NULL;
- }
- if(pszDfltNetstrmDrvrCertFile != NULL) {
- free(pszDfltNetstrmDrvrCertFile);
- pszDfltNetstrmDrvrCertFile = NULL;
- }
- if(LocalHostNameOverride != NULL) {
- free(LocalHostNameOverride);
- LocalHostNameOverride = NULL;
- }
- if(pszWorkDir != NULL) {
- free(pszWorkDir);
- pszWorkDir = NULL;
- }
+ free(pszDfltNetstrmDrvr);
+ pszDfltNetstrmDrvr = NULL;
+ free(pszDfltNetstrmDrvrCAF);
+ pszDfltNetstrmDrvrCAF = NULL;
+ free(pszDfltNetstrmDrvrKeyFile);
+ pszDfltNetstrmDrvrKeyFile = NULL;
+ free(pszDfltNetstrmDrvrCertFile);
+ pszDfltNetstrmDrvrCertFile = NULL;
+ free(LocalHostNameOverride);
+ LocalHostNameOverride = NULL;
+ free(pszWorkDir);
+ pszWorkDir = NULL;
bDropMalPTRMsgs = 0;
bOptimizeUniProc = 1;
bPreserveFQDN = 0;
@@ -615,6 +642,7 @@ BEGINObjClassExit(glbl, OBJ_IS_CORE_MODULE) /* class, version */
free(pszDfltNetstrmDrvrKeyFile);
free(pszDfltNetstrmDrvrCertFile);
free(pszWorkDir);
+ free(LocalDomain);
free(LocalHostName);
free(LocalHostNameOverride);
free(LocalFQDNName);
diff --git a/tools/syslogd.c b/tools/syslogd.c
index 9f6b928b..04379dfb 100644
--- a/tools/syslogd.c
+++ b/tools/syslogd.c
@@ -21,7 +21,7 @@
* For further information, please see http://www.rsyslog.com
*
* rsyslog - An Enhanced syslogd Replacement.
- * Copyright 2003-2011 Rainer Gerhards and Adiscon GmbH.
+ * Copyright 2003-2012 Rainer Gerhards and Adiscon GmbH.
*
* This file is part of rsyslog.
*
@@ -143,6 +143,7 @@ DEFobjCurrIf(net) /* TODO: make go away! */
/* forward definitions */
static rsRetVal GlobalClassExit(void);
+static rsRetVal queryLocalHostname(void);
#ifndef _PATH_LOGCONF
@@ -1256,6 +1257,11 @@ DEFFUNC_llExecFunc(doHUPActions)
* is *NOT* the sighup handler. The signal is recorded by the handler, that record
* detected inside the mainloop and then this function is called to do the
* real work. -- rgerhards, 2008-10-22
+ * Note: there is a VERY slim chance of a data race when the hostname is reset.
+ * We prefer to take this risk rather than sync all accesses, because to the best
+ * of my analysis it can not really hurt (the actual property is reference-counted)
+ * but the sync would require some extra CPU for *each* message processed.
+ * rgerhards, 2012-04-11
*/
static inline void
doHUP(void)
@@ -1271,6 +1277,7 @@ doHUP(void)
logmsgInternal(NO_ERRCODE, LOG_SYSLOG|LOG_INFO, (uchar*)buf, 0);
}
+ queryLocalHostname(); /* re-read our name */
ruleset.IterateAllActions(ourConf, doHUPActions, NULL);
}
@@ -1487,6 +1494,93 @@ GlobalClassExit(void)
}
+/* query our host and domain names - we need to do this early as we may emit
+ * rgerhards, 2012-04-11
+ */
+static rsRetVal
+queryLocalHostname(void)
+{
+ uchar *LocalHostName;
+ uchar *LocalDomain;
+ uchar *LocalFQDNName;
+ uchar *p;
+ struct hostent *hent;
+ DEFiRet;
+
+ net.getLocalHostname(&LocalFQDNName);
+ CHKmalloc(LocalHostName = (uchar*) strdup((char*)LocalFQDNName));
+ glbl.SetLocalFQDNName(LocalFQDNName); /* set the FQDN before we modify it */
+ if((p = (uchar*)strchr((char*)LocalHostName, '.'))) {
+ *p++ = '\0';
+ LocalDomain = p;
+ } else {
+ LocalDomain = (uchar*)"";
+
+ /* It's not clearly defined whether gethostname()
+ * should return the simple hostname or the fqdn. A
+ * good piece of software should be aware of both and
+ * we want to distribute good software. Joey
+ *
+ * Good software also always checks its return values...
+ * If syslogd starts up before DNS is up & /etc/hosts
+ * doesn't have LocalHostName listed, gethostbyname will
+ * return NULL.
+ */
+ /* TODO: gethostbyname() is not thread-safe, but replacing it is
+ * not urgent as we do not run on multiple threads here. rgerhards, 2007-09-25
+ */
+ hent = gethostbyname((char*)LocalHostName);
+ if(hent) {
+ int i = 0;
+
+ if(hent->h_aliases) {
+ size_t hnlen;
+
+ hnlen = strlen((char *) LocalHostName);
+
+ for (i = 0; hent->h_aliases[i]; i++) {
+ if (!strncmp(hent->h_aliases[i], (char *) LocalHostName, hnlen)
+ && hent->h_aliases[i][hnlen] == '.') {
+ /* found a matching hostname */
+ break;
+ }
+ }
+ }
+
+ free(LocalHostName);
+ if(hent->h_aliases && hent->h_aliases[i]) {
+ CHKmalloc(LocalHostName = (uchar*)strdup(hent->h_aliases[i]));
+ } else {
+ CHKmalloc(LocalHostName = (uchar*)strdup(hent->h_name));
+ }
+
+ if((p = (uchar*)strchr((char*)LocalHostName, '.')))
+ {
+ *p++ = '\0';
+ LocalDomain = p;
+ }
+ }
+ }
+
+ /* LocalDomain is "" or part of LocalHostName, allocate a new string */
+ CHKmalloc(LocalDomain = (uchar*)strdup((char*)LocalDomain));
+
+ /* Convert to lower case to recognize the correct domain laterly */
+ 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);
+ glbl.GenerateLocalHostNameProperty(); /* must be redone after conf processing, FQDN setting may have changed */
+finalize_it:
+ RETiRet;
+}
+
+
/* some support for command line option parsing. Any non-trivial options must be
* buffered until the complete command line has been parsed. This is necessary to
* prevent dependencies between the options. That, in turn, means we need to have
@@ -1689,16 +1783,12 @@ int realMain(int argc, char **argv)
rsRetVal localRet;
register uchar *p;
int ch;
- struct hostent *hent;
extern int optind;
extern char *optarg;
int bEOptionWasGiven = 0;
int iHelperUOpt;
int bChDirRoot = 1; /* change the current working directory to "/"? */
char *arg; /* for command line option processing */
- uchar *LocalHostName;
- uchar *LocalDomain;
- uchar *LocalFQDNName;
char cwdbuf[128]; /* buffer to obtain/display current working directory */
DEFiRet;
@@ -1788,78 +1878,13 @@ int realMain(int argc, char **argv)
/* we need to create the inputName property (only once during our lifetime) */
CHKiRet(prop.Construct(&pInternalInputName));
- CHKiRet(prop.SetString(pInternalInputName, UCHAR_CONSTANT("rsyslogd"), sizeof("rsyslgod") - 1));
+ CHKiRet(prop.SetString(pInternalInputName, UCHAR_CONSTANT("rsyslogd"), sizeof("rsyslogd") - 1));
CHKiRet(prop.ConstructFinalize(pInternalInputName));
/* 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
*/
- net.getLocalHostname(&LocalFQDNName);
- CHKmalloc(LocalHostName = (uchar*) strdup((char*)LocalFQDNName));
- glbl.SetLocalFQDNName(LocalFQDNName); /* set the FQDN before we modify it */
- if((p = (uchar*)strchr((char*)LocalHostName, '.'))) {
- *p++ = '\0';
- LocalDomain = p;
- } else {
- LocalDomain = (uchar*)"";
-
- /* It's not clearly defined whether gethostname()
- * should return the simple hostname or the fqdn. A
- * good piece of software should be aware of both and
- * we want to distribute good software. Joey
- *
- * Good software also always checks its return values...
- * If syslogd starts up before DNS is up & /etc/hosts
- * doesn't have LocalHostName listed, gethostbyname will
- * return NULL.
- */
- /* TODO: gethostbyname() is not thread-safe, but replacing it is
- * not urgent as we do not run on multiple threads here. rgerhards, 2007-09-25
- */
- hent = gethostbyname((char*)LocalHostName);
- if(hent) {
- int i = 0;
-
- if(hent->h_aliases) {
- size_t hnlen;
-
- hnlen = strlen((char *) LocalHostName);
-
- for (i = 0; hent->h_aliases[i]; i++) {
- if (!strncmp(hent->h_aliases[i], (char *) LocalHostName, hnlen)
- && hent->h_aliases[i][hnlen] == '.') {
- /* found a matching hostname */
- break;
- }
- }
- }
-
- free(LocalHostName);
- if(hent->h_aliases && hent->h_aliases[i]) {
- CHKmalloc(LocalHostName = (uchar*)strdup(hent->h_aliases[i]));
- } else {
- CHKmalloc(LocalHostName = (uchar*)strdup(hent->h_name));
- }
-
- if((p = (uchar*)strchr((char*)LocalHostName, '.')))
- {
- *p++ = '\0';
- LocalDomain = p;
- }
- }
- }
-
- /* Convert to lower case to recognize the correct domain laterly */
- 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);
- glbl.GenerateLocalHostNameProperty(); /* must be redone after conf processing, FQDN setting may have changed */
+ queryLocalHostname();
/* initialize the objects */
if((iRet = modInitIminternal()) != RS_RET_OK) {