From arensb@ooblick.com  Mon Dec 25 02:40:54 2000
Return-Path: <arensb@ooblick.com>
Received: from ooblick.com (pm7a-19.his.com [216.200.82.19])
	by hub.freebsd.org (Postfix) with ESMTP id 82A1937B400
	for <FreeBSD-gnats-submit@freebsd.org>; Mon, 25 Dec 2000 02:40:52 -0800 (PST)
Received: from localhost (localhost [127.0.0.1])
	by  ooblick.com (8.9.3/8.9.3) with ESMTP id FAA30834;
	Mon, 25 Dec 2000 05:40:53 -0500 (EST)
	(envelope-from arensb@baa.ooblick.com)
Message-Id: <Pine.BSF.4.21.0012250539430.25734-100000@baa>
Date: Mon, 25 Dec 2000 05:40:53 -0500 (EST)
From: Andrew Arensburger <arensb@ooblick.com>
To: FreeBSD-gnats-submit@freebsd.org
Cc: Andrew Arensburger <arensb@ooblick.com>
Subject: gethostbyname2 man page inaccuracy

>Number:         23823
>Category:       docs
>Synopsis:       gethostbyname2 man page is inaccurate
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    alex
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          doc-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Dec 25 02:50:01 PST 2000
>Closed-Date:    Tue May 8 04:21:35 PDT 2001
>Last-Modified:  Tue May 08 04:22:06 PDT 2001
>Originator:     Andrew Arensburger
>Release:        FreeBSD 4.0-RELEASE i386
>Organization:
None
>Environment:

	FreeBSD 4.0-RELEASE i386, though this appears to apply to
FreeBSD 4.2-RELEASE as well.

>Description:

	The man page for gethostbyname2(3) says:

     The gethostbyname2() function is an evolution of gethostbyname() which is
     intended to allow lookups in address families other than AF_INET, for ex-
     ample AF_INET6. Currently the af argument must be specified as AF_INET
     else the function will return NULL after having set h_errno to
     NETDB_INTERNAL

This appears to be inaccurate: gethostbyname2("myhost6", AF_INET6)
returns valid results. From looking at the source, it would appear
that the manual is correct only when the resolver looks the name up in
NIS. However, I don't have an NIS server and have not tested this.

>How-To-Repeat:

* /etc/host.conf should contain:

	hosts

  (and optionally "bind", either before or after "hosts")

* /etc/hosts should contain:

	fec0::a:b:c:d   myhost6 myhost6.my.domain

* Compile ('cc -o foo foo.c') and run the following program:
	#include <stdio.h>
	#include <netdb.h>
	#include <sys/socket.h>

	main()
	{
		struct hostent *he;
		char buf[256];

		he = gethostbyname2("myhost6", AF_INET6);
		if (he == NULL)
		{
			perror("gethostbyname2");
			exit(1);
		}
		if (he->h_addrtype != AF_INET6)
			fprintf(stderr, "h_addrtype != AF_INET6 (%d)\n",
				he->h_addrtype);

		printf("address is [%s]\n",
		       inet_ntop(AF_INET6, he->h_addr_list[0], buf, 256));
	}

  This program prints
	address is [fec0::a:b:c:d]

>Fix:

	Suggestion: apply the following patch to
/usr/src/lib/libc/net/gethostbyname.3 :

--- lib/libc/net/gethostbyname.3.old	Sat Apr 22 13:06:04 2000
+++ lib/libc/net/gethostbyname.3	Sat Dec 23 07:02:16 2000
@@ -135,7 +135,7 @@
 .Dv AF_INET ,
 for example
 .Dv AF_INET6 .
-Currently the
+Currently, when using NIS, the
 .Fa af
 argument must be specified as
 .Dv AF_INET


>Release-Note:
>Audit-Trail:

From: alex@big.endian.de (Alexander Langer)
To: freebsd-gnats-submit@FreeBSD.org, arensb@ooblick.com
Cc:  
Subject: Re: docs/23823: gethostbyname2 man page is inaccurate
Date: Fri,  5 Jan 2001 21:17:18 +0100 (CET)

 Uhm - I'm just curious:
 
 What has _NIS_ to do with DNS issues????
 
 Alex
 
 
 

From: Andrew Arensburger <arensb@ooblick.com>
To: Alexander Langer <alex@big.endian.de>
Cc: <freebsd-gnats-submit@FreeBSD.org>, <arensb@ooblick.com>
Subject: Re: docs/23823: gethostbyname2 man page is inaccurate
Date: Fri, 5 Jan 2001 16:01:07 -0500 (EST)

 On Fri, 5 Jan 2001, Alexander Langer wrote:
 > Uhm - I'm just curious:
 >
 > What has _NIS_ to do with DNS issues????
 
 	Nothing directly. The gethost*() functions get the host
 information from either /etc/hosts, NIS, or DNS, as specified in
 /etc/host.conf .
 	gethostbyname() is the classic "get host information" function,
 but it only handles IPv4 (AF_INET). gethostbyname2() is more generic and
 can handle IPv6 (AF_INET6).
 	gethostbyname2("myhost.dom.ain", AF_INET6) works quite well for
 /etc/hosts and DNS. The only case in which it doesn't work, as far as I
 can tell, is with NIS. I don't know whether this is a limitation of NIS
 itself, or just FreeBSD's implementation of it.
 
 	At any rate, the man page for gethostbyname2() implies that
 only AF_INET works. This doesn't appear to be true.
 
 -- 
 Andrew Arensburger                      This message *does* represent the
 arensb@ooblick.com			views of ooblick.com
 		      ACK and you shall receive.
 
 
State-Changed-From-To: open->suspended 
State-Changed-By: alex 
State-Changed-When: Sat Jan 6 04:48:53 PST 2001 
State-Changed-Why:  
Committed to HEAD, leaving it open as a reminder to MFC. 


Responsible-Changed-From-To: freebsd-doc->alex 
Responsible-Changed-By: alex 
Responsible-Changed-When: Sat Jan 6 04:48:53 PST 2001 
Responsible-Changed-Why:  
I keep this open 

http://www.freebsd.org/cgi/query-pr.cgi?pr=23823 

From: ume@FreeBSD.org
To: freebsd-gnats-submit@FreeBSD.org, arensb@ooblick.com
Cc:  
Subject: Re: docs/23823: gethostbyname2 man page is inaccurate
Date: Sun, 18 Mar 2001 02:22:07 +0900 (JST)

 To query IPv6 address from NIS, we need to use special map
 `ipnodes.byname'.  -CURRENT version of getaddrinfo(3) do this (I dunno
 if it acutually works).  However, gethostbyname2(3) and
 getipnodebyname(3) don't do this.
 
State-Changed-From-To: suspended->closed 
State-Changed-By: alex 
State-Changed-When: Tue May 8 04:21:35 PDT 2001 
State-Changed-Why:  
Close this now. 

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=23823 
>Unformatted:
