summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2012-01-16 16:57:46 +0100
committerRainer Gerhards <rgerhards@adiscon.com>2012-01-16 16:57:46 +0100
commit2f2169c5c29d9f655a334c2da10d2582c5ffc82b (patch)
treec693b28a6ea5548af0a25676992af8f519036ff9
parent18e60f46a1bbdbcb446369a0f03dbb04f29fb71e (diff)
parent209a6d8e15afb83c0bf146dd95fc203bb9983242 (diff)
downloadrsyslog-2f2169c5c29d9f655a334c2da10d2582c5ffc82b.tar.gz
rsyslog-2f2169c5c29d9f655a334c2da10d2582c5ffc82b.tar.xz
rsyslog-2f2169c5c29d9f655a334c2da10d2582c5ffc82b.zip
Merge branch 'v4-stable' into v5-stable
Conflicts: tools/syslogd.c
-rw-r--r--ChangeLog2
-rw-r--r--tools/syslogd.c22
2 files changed, 23 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 1425bc66..3ecbc960 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -863,6 +863,8 @@ Version 4.8.1 [v4-stable], 2011-09-??
- bugfix: potential fatal abort in omgssapi
Thanks to Tomas Heinrich for the patch.
- added doc for omprog
+- FQDN hostname for multihomed host was not always set to the correct name
+ if multiple aliases existed. Thanks to Tomas Heinreich for the patch.
---------------------------------------------------------------------------
Version 4.8.0 [v4-stable] (rgerhards), 2011-09-07
***************************************************************************
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, '.')))
{