rsyslog patch

December 15, 2011 at 10:05 AM (Uncategorized) ()

--- a/tools/syslogd.c	2011-12-14 14:38:53.557984324 +0530
+++ b/tools/syslogd.c	2011-12-14 14:38:45.011984782 +0530
@@ -3177,6 +3177,7 @@
 	uchar *LocalHostName;
 	uchar *LocalDomain;
 	uchar *LocalFQDNName;
+	int i;

 	/* first, parse the command line options. We do not carry out any actual work, just
 	 * see what we should do. This relieves us from certain anomalies and we can process
@@ -3316,9 +3317,22 @@
 		 */
 		hent = gethostbyname((char*)LocalHostName);
 		if(hent) {
+			if(hent->h_aliases) {
+				for (i=0; hent->h_aliases[i]; i++) {
+					if(strstr((hent->h_aliases[i]), (char*)LocalHostName)) {
+						//found hostname matching in aliases. use currently found one and break loop
+						 break;
+					}
+				}
+			}
+
 			free(LocalHostName);
-			CHKmalloc(LocalHostName = (uchar*)strdup(hent->h_name));
-
+			if(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++ = '';
Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.