summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorTomas Heinrich <theinric@redhat.com>2012-01-16 16:53:18 +0100
committerRainer Gerhards <rgerhards@adiscon.com>2012-01-16 16:53:18 +0100
commit209a6d8e15afb83c0bf146dd95fc203bb9983242 (patch)
treedb9c6a0b92458e7c035e6437130a43ead0db6f14 /tools
parentbd22bf8cb414f12c7b307bef463fbda5d51bee22 (diff)
downloadrsyslog-209a6d8e15afb83c0bf146dd95fc203bb9983242.tar.gz
rsyslog-209a6d8e15afb83c0bf146dd95fc203bb9983242.tar.xz
rsyslog-209a6d8e15afb83c0bf146dd95fc203bb9983242.zip
FQDN hostname for multihomed host was not always set to the correct name
..if multiple aliases existed. Thanks to Tomas Heinreich for the patch. Signed-off-by: Rainer Gerhards <rgerhards@adiscon.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/syslogd.c24
1 files changed, 22 insertions, 2 deletions
diff --git a/tools/syslogd.c b/tools/syslogd.c
index f66cbee3..7254385e 100644
--- a/tools/syslogd.c
+++ b/tools/syslogd.c
@@ -3350,9 +3350,29 @@ 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, '.')))
{
*p++ = '\0';