diff options
author | Michael Biebl <biebl@debian.org> | 2012-02-12 11:22:00 +0100 |
---|---|---|
committer | Michael Biebl <biebl@debian.org> | 2012-02-12 11:22:00 +0100 |
commit | 366cf57abdb1a9fec6f5dc3563e2243d1a883a1a (patch) | |
tree | 41c1f44a1e64e33180ae75ef39f0a919b3dd091d /tools/syslogd.c | |
parent | a7a3afdd81c8809fbc4927b360e1cb59e2e16b2e (diff) | |
download | rsyslog-366cf57abdb1a9fec6f5dc3563e2243d1a883a1a.tar.gz |
Imported Upstream version 5.8.7upstream/5.8.7
Diffstat (limited to 'tools/syslogd.c')
-rw-r--r-- | tools/syslogd.c | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/tools/syslogd.c b/tools/syslogd.c index 6bed6a1..0b7bbc9 100644 --- a/tools/syslogd.c +++ b/tools/syslogd.c @@ -2685,8 +2685,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, '.'))) { |