summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2012-01-16 16:57:59 +0100
committerRainer Gerhards <rgerhards@adiscon.com>2012-01-16 16:57:59 +0100
commitde52870bb16c9ad6acba92c40af86f2c70069c97 (patch)
treeed56ce5f2b2c00894a0ad52084360b3c88092481 /tools
parent29807bb3c918603f41eeaa2d15e89852a2657f9c (diff)
parent2f2169c5c29d9f655a334c2da10d2582c5ffc82b (diff)
downloadrsyslog-de52870bb16c9ad6acba92c40af86f2c70069c97.tar.gz
rsyslog-de52870bb16c9ad6acba92c40af86f2c70069c97.tar.xz
rsyslog-de52870bb16c9ad6acba92c40af86f2c70069c97.zip
Merge branch 'v5-stable' into v5-stable-newstats
Diffstat (limited to 'tools')
-rw-r--r--tools/syslogd.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/tools/syslogd.c b/tools/syslogd.c
index 6bed6a1a..0b7bbc96 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, '.')))
{