Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 26 Sep 2012 09:40:04 GMT
From:      dfilter@FreeBSD.ORG (dfilter service)
To:        freebsd-bugs@FreeBSD.org
Subject:   Re: bin/161548: commit references a PR
Message-ID:  <201209260940.q8Q9e499090237@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help
The following reply was made to PR bin/161548; it has been noted by GNATS.

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/161548: commit references a PR
Date: Wed, 26 Sep 2012 09:31:29 +0000 (UTC)

 Author: kevlo
 Date: Wed Sep 26 09:29:48 2012
 New Revision: 240954
 URL: http://svn.freebsd.org/changeset/base/240954
 
 Log:
   Teach getent(1) to look up a hostname and find IPv6 addresses.
   
   PR:	bin/161548
   Submitted by:	matthew
 
 Modified:
   head/usr.bin/getent/getent.c
 
 Modified: head/usr.bin/getent/getent.c
 ==============================================================================
 --- head/usr.bin/getent/getent.c	Wed Sep 26 09:27:38 2012	(r240953)
 +++ head/usr.bin/getent/getent.c	Wed Sep 26 09:29:48 2012	(r240954)
 @@ -277,7 +277,7 @@ hostsprint(const struct hostent *he)
  static int
  hosts(int argc, char *argv[])
  {
 -	struct hostent	*he;
 +	struct hostent	*he4, *he6;
  	char		addr[IN6ADDRSZ];
  	int		i, rv;
  
 @@ -285,21 +285,31 @@ hosts(int argc, char *argv[])
  	assert(argv != NULL);
  
  	sethostent(1);
 +	he4 = he6 = NULL;
  	rv = RV_OK;
  	if (argc == 2) {
 -		while ((he = gethostent()) != NULL)
 -			hostsprint(he);
 +		while ((he4 = gethostent()) != NULL)
 +			hostsprint(he4);
  	} else {
  		for (i = 2; i < argc; i++) {
 -			if (inet_pton(AF_INET6, argv[i], (void *)addr) > 0)
 -				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]);
 -			if (he != NULL)
 -				hostsprint(he);
 -			else {
 +			if (inet_pton(AF_INET6, argv[i], (void *)addr) > 0) {
 +				he6 = gethostbyaddr(addr, IN6ADDRSZ, AF_INET6);
 +				if (he6 != NULL)
 +					hostsprint(he6);
 +			} else if (inet_pton(AF_INET, argv[i],
 +			    (void *)addr) > 0) {
 +				he4 = gethostbyaddr(addr, INADDRSZ, AF_INET);
 +				if (he4 != NULL)
 +					hostsprint(he4);
 +	       		} else {
 +				he6 = gethostbyname2(argv[i], AF_INET6);
 +				if (he6 != NULL)
 +					hostsprint(he6);
 +				he4 = gethostbyname(argv[i]);
 +				if (he4 != NULL)
 +					hostsprint(he4);
 +			}
 +			if ( he4 == NULL && he6 == NULL ) {
  				rv = RV_NOTFOUND;
  				break;
  			}
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 



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