Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 20 Mar 2017 06:12:55 +0000 (UTC)
From:      Ngie Cooper <ngie@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r315622 - head/usr.sbin/syslogd
Message-ID:  <201703200612.v2K6Ctgw056170@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: ngie
Date: Mon Mar 20 06:12:55 2017
New Revision: 315622
URL: https://svnweb.freebsd.org/changeset/base/315622

Log:
  syslogd: try to print out a more helpful message in socksetup(..) if/when
  getaddrinfo fails
  
  If the asprintf call fails, fall back to the old code (as a last ditch effort
  to provide the end-user with helpful output).
  
  Sponsored by:	Dell EMC Isilon

Modified:
  head/usr.sbin/syslogd/syslogd.c

Modified: head/usr.sbin/syslogd/syslogd.c
==============================================================================
--- head/usr.sbin/syslogd/syslogd.c	Mon Mar 20 05:15:55 2017	(r315621)
+++ head/usr.sbin/syslogd/syslogd.c	Mon Mar 20 06:12:55 2017	(r315622)
@@ -2907,8 +2907,17 @@ socksetup(struct peer *pe)
 		pe->pe_serv = "syslog";
 	error = getaddrinfo(pe->pe_name, pe->pe_serv, &hints, &res0);
 	if (error) {
-		logerror(gai_strerror(error));
+		char *msgbuf;
+
+		asprintf(&msgbuf, "getaddrinfo failed for %s%s: %s",
+		    pe->pe_name == NULL ? "" : pe->pe_name, pe->pe_serv,
+		    gai_strerror(error));
 		errno = 0;
+		if (msgbuf == NULL)
+			logerror(gai_strerror(error));
+		else
+			logerror(msgbuf);
+		free(msgbuf);
 		die(0);
 	}
 	for (res = res0; res != NULL; res = res->ai_next) {



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201703200612.v2K6Ctgw056170>