summaryrefslogtreecommitdiffstats
path: root/syslogd.c
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2008-04-04 12:19:24 +0000
committerRainer Gerhards <rgerhards@adiscon.com>2008-04-04 12:19:24 +0000
commiteb5339d4ab214e1b01a81d9f26e595148f60d939 (patch)
tree1ca350e6e7edcf8c5f3d2a38c771e3a2dac62998 /syslogd.c
parentcd9762ddae5e0350ede5431c88346690799a688e (diff)
downloadrsyslog-eb5339d4ab214e1b01a81d9f26e595148f60d939.zip
rsyslog-eb5339d4ab214e1b01a81d9f26e595148f60d939.tar.gz
rsyslog-eb5339d4ab214e1b01a81d9f26e595148f60d939.tar.xz
bugfix: some messages were emited without hostname
Diffstat (limited to 'syslogd.c')
-rw-r--r--syslogd.c81
1 files changed, 40 insertions, 41 deletions
diff --git a/syslogd.c b/syslogd.c
index 99e0efc..355689c 100644
--- a/syslogd.c
+++ b/syslogd.c
@@ -2962,6 +2962,46 @@ int realMain(int argc, char **argv)
int bImUxSockLoaded = 0; /* already generated a $ModLoad imuxsock? */
uchar legacyConfLine[80];
+ gethostname(LocalHostName, sizeof(LocalHostName));
+ if ( (p = strchr(LocalHostName, '.')) ) {
+ *p++ = '\0';
+ LocalDomain = p;
+ }
+ else
+ {
+ LocalDomain = "";
+
+ /* 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(LocalHostName);
+ if(hent) {
+ snprintf(LocalHostName, sizeof(LocalHostName), "%s", hent->h_name);
+
+ if ( (p = strchr(LocalHostName, '.')) )
+ {
+ *p++ = '\0';
+ LocalDomain = p;
+ }
+ }
+ }
+
+ /* Convert to lower case to recognize the correct domain laterly
+ */
+ for (p = (char *)LocalDomain; *p ; p++)
+ if (isupper((int) *p))
+ *p = (char)tolower((int)*p);
+
CHKiRet(InitGlobalClasses());
/* doing some core initializations */
@@ -3232,47 +3272,6 @@ int realMain(int argc, char **argv)
}
myPid = getpid(); /* save our pid for further testing (also used for messages) */
-
- gethostname(LocalHostName, sizeof(LocalHostName));
- if ( (p = strchr(LocalHostName, '.')) ) {
- *p++ = '\0';
- LocalDomain = p;
- }
- else
- {
- LocalDomain = "";
-
- /* 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(LocalHostName);
- if(hent) {
- snprintf(LocalHostName, sizeof(LocalHostName), "%s", hent->h_name);
-
- if ( (p = strchr(LocalHostName, '.')) )
- {
- *p++ = '\0';
- LocalDomain = p;
- }
- }
- }
-
- /* Convert to lower case to recognize the correct domain laterly
- */
- for (p = (char *)LocalDomain; *p ; p++)
- if (isupper((int) *p))
- *p = (char)tolower((int)*p);
-
memset(&sigAct, 0, sizeof (sigAct));
sigemptyset(&sigAct.sa_mask);