Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 7 Sep 2000 11:39:32 -0400 (EDT)
From:      ak03@gte.com
To:        FreeBSD-gnats-submit@freebsd.org
Subject:   bin/21092: Resolver errors are not reported properly in NIS-only case 
Message-ID:  <200009071539.e87FdWd07360@h132-197-97-45.gte.com>

next in thread | raw e-mail | index | archive | help

>Number:         21092
>Category:       bin
>Synopsis:       _gethostbynis function does not set h_errno on failure
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Sep 07 08:40:00 PDT 2000
>Closed-Date:
>Last-Modified:
>Originator:     Alexander Kabaev
>Release:        FreeBSD 5.0-CURRENT i386
>Organization:
Verizon Laboratories Inc.
>Environment:

FreeBSD kanpc.gte.com 5.0-CURRENT FreeBSD 5.0-CURRENT #0: Wed Sep  6 12:19:50 EDT 2000     root@kanpc.gte.com:/usr/src/sys/compile/KANPC  i386

>Description:

If NIS is selected as the only source used for the name resolution in
host.conf or in nsswitch.conf on newer -CURRENT and then name resolution
attempted for an unknown hostname using gethostbyname* functions, h_error 
is not getting set correctly when resolution fails. 

It seems like _gethostbynis function fails to set h_errno variable to the 
appropriate value when returning. All other functions in the family, i.e.
_gethostbydns and _gethostbyht, do so.

Without attached patch, the following command returns with strange message:

[ak03@kanpc ~]$ ping sjkjss
ping: cannot resolve sjkjss: Resolver Error 0 (no error)
  
With patch applied, ping produces more reasonable output:
[ak03@kanpc ~]$ ping sjkjss
ping: cannot resolve sjkjss: Unknown host

>How-To-Repeat:

Comment out non-nis entries in host.conf or nsswitch.conf and try to ping 
some unknown host.


Index: gethostbynis.c
===================================================================
RCS file: /usr/ncvs/src/lib/libc/net/gethostbynis.c,v
retrieving revision 1.10
diff -u -r1.10 gethostbynis.c
--- gethostbynis.c	1999/08/28 00:00:06	1.10
+++ gethostbynis.c	2000/09/07 15:12:50
@@ -76,15 +76,20 @@
 	case AF_INET6:
 		size = NS_IN6ADDRSZ;
 		errno = EAFNOSUPPORT;
+		h_errno = NETDB_INTERNAL;
 		return NULL;
 	}
 
 	if (domain == (char *)NULL)
-		if (yp_get_default_domain (&domain))
+		if (yp_get_default_domain (&domain)) {
+			h_errno = NETDB_INTERNAL;
 			return ((struct hostent *)NULL);
+		}
 
-	if (yp_match(domain, map, name, strlen(name), &result, &resultlen))
+	if (yp_match(domain, map, name, strlen(name), &result, &resultlen)) {
+		h_errno = HOST_NOT_FOUND;
 		return ((struct hostent *)NULL);
+	}
 
 	/* avoid potential memory leak */
 	bcopy((char *)result, (char *)&ypbuf, resultlen);

>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted:


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message




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