From owner-svn-src-all@freebsd.org Mon Mar 20 06:12:56 2017 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A7811D146DE; Mon, 20 Mar 2017 06:12:56 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 76A2312F6; Mon, 20 Mar 2017 06:12:56 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2K6Ct6S056171; Mon, 20 Mar 2017 06:12:55 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2K6Ctgw056170; Mon, 20 Mar 2017 06:12:55 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201703200612.v2K6Ctgw056170@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Ngie Cooper Date: Mon, 20 Mar 2017 06:12:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r315622 - head/usr.sbin/syslogd X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 20 Mar 2017 06:12:56 -0000 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) {