From owner-freebsd-questions@FreeBSD.ORG Wed Sep 26 08:44:26 2012 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 4B7A81065673; Wed, 26 Sep 2012 08:44:26 +0000 (UTC) (envelope-from matthew@freebsd.org) Received: from smtp.infracaninophile.co.uk (smtp6.infracaninophile.co.uk [IPv6:2001:8b0:151:1:3cd3:cd67:fafa:3d78]) by mx1.freebsd.org (Postfix) with ESMTP id AF19A8FC1E; Wed, 26 Sep 2012 08:44:25 +0000 (UTC) Received: from rufus.webfusion.com (mail.heartinternet.co.uk [79.170.40.31]) (authenticated bits=0) by smtp.infracaninophile.co.uk (8.14.5/8.14.5) with ESMTP id q8Q8iLPu010780 (version=TLSv1/SSLv3 cipher=DHE-RSA-CAMELLIA256-SHA bits=256 verify=NO); Wed, 26 Sep 2012 09:44:21 +0100 (BST) (envelope-from matthew@freebsd.org) X-DKIM: OpenDKIM Filter v2.5.2 smtp.infracaninophile.co.uk q8Q8iLPu010780 Authentication-Results: smtp.infracaninophile.co.uk/q8Q8iLPu010780; dkim=none (no signature); dkim-adsp=none X-Authentication-Warning: lucid-nonsense.infracaninophile.co.uk: Host mail.heartinternet.co.uk [79.170.40.31] claimed to be rufus.webfusion.com Message-ID: <5062C065.2040603@freebsd.org> Date: Wed, 26 Sep 2012 09:44:21 +0100 From: Matthew Seaman User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:15.0) Gecko/20120911 Thunderbird/15.0.1 MIME-Version: 1.0 To: Kevin Lo References: <20120924172911.0839be5d@scorpio> <5061494D.1000203@FreeBSD.org> <5062A037.7080306@FreeBSD.org> In-Reply-To: <5062A037.7080306@FreeBSD.org> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Virus-Scanned: clamav-milter 0.97.6 at lucid-nonsense.infracaninophile.co.uk X-Virus-Status: Clean X-Spam-Status: No, score=-1.6 required=5.0 tests=AWL,BAYES_00,SPF_SOFTFAIL autolearn=no version=3.3.2 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on lucid-nonsense.infracaninophile.co.uk Cc: Jerry , FreeBSD Subject: Re: PR 161548 X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 26 Sep 2012 08:44:26 -0000 On 26/09/2012 07:27, Kevin Lo wrote: > On 2012/09/25 14:03, Matthew Seaman wrote: >> On 24/09/2012 22:29, Jerry wrote: >>> Is there any specific reason that this PR: 161548 is still marked as >>> open? >>> >>> o 2011/10/13 bin/161548 [patch] getent(1) inconsistent treatment of >>> IPv6 host data >> It simply hasn't attracted the attention of anyone with a src commit >> bit. Yet. > > There's no need to declare he4 and he6 as struct hostent, > the original declaration of he is fine. So here is patch. > > Index: usr.bin/getent/getent.c > =================================================================== > --- usr.bin/getent/getent.c (revision 240947) > +++ usr.bin/getent/getent.c (working copy) > @@ -285,6 +285,7 @@ hosts(int argc, char *argv[]) > assert(argv != NULL); > > sethostent(1); > + he = NULL; > rv = RV_OK; > if (argc == 2) { > while ((he = gethostent()) != NULL) > @@ -295,8 +296,9 @@ hosts(int argc, char *argv[]) > he = gethostbyaddr(addr, IN6ADDRSZ, > AF_INET6); > else if (inet_pton(AF_INET, argv[i], (void > *)addr) > 0) > he = gethostbyaddr(addr, INADDRSZ, > AF_INET); > - else > - he = gethostbyname(argv[i]); > + else if ((he = gethostbyname2(argv[i], > AF_INET6)) == > + NULL) > + he = gethostbyname2(argv[i], AF_INET); > if (he != NULL) > hostsprint(he); > else { Not so. Hosts frequently have both IPv6 and IPv4 addresses: your patch would print only the IPv6 address in that case. Cheers, Matthew