summaryrefslogtreecommitdiffstats
path: root/tools/syslogd.c
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2012-01-16 17:04:10 +0100
committerRainer Gerhards <rgerhards@adiscon.com>2012-01-16 17:04:10 +0100
commitabb381b8a5861be1d065afea85f355f478d87e5d (patch)
treee6a68876e67f9c3a3ec0f87194a9bafccf08210b /tools/syslogd.c
parentd5a18a93ae585c25d67ec200b308f08c6bd6d5b2 (diff)
parentde52870bb16c9ad6acba92c40af86f2c70069c97 (diff)
downloadrsyslog-abb381b8a5861be1d065afea85f355f478d87e5d.tar.gz
rsyslog-abb381b8a5861be1d065afea85f355f478d87e5d.tar.xz
rsyslog-abb381b8a5861be1d065afea85f355f478d87e5d.zip
Merge branch 'v5-stable-newstats' into v5-devel
Conflicts: plugins/imtcp/imtcp.c
Diffstat (limited to 'tools/syslogd.c')
-rw-r--r--tools/syslogd.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/tools/syslogd.c b/tools/syslogd.c
index 61b56847..6879bafa 100644
--- a/tools/syslogd.c
+++ b/tools/syslogd.c
@@ -2688,8 +2688,28 @@ int realMain(int argc, char **argv)
*/
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);
- CHKmalloc(LocalHostName = (uchar*)strdup(hent->h_name));
+ 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, '.')))
{