From owner-freebsd-bugs@FreeBSD.ORG Mon Jul 28 09:50:18 2003 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id DCA0037B401 for ; Mon, 28 Jul 2003 09:50:18 -0700 (PDT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 642E743F93 for ; Mon, 28 Jul 2003 09:50:17 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.9/8.12.9) with ESMTP id h6SGoHUp074073 for ; Mon, 28 Jul 2003 09:50:17 -0700 (PDT) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.9/8.12.9/Submit) id h6SGoHeb074072; Mon, 28 Jul 2003 09:50:17 -0700 (PDT) Date: Mon, 28 Jul 2003 09:50:17 -0700 (PDT) Message-Id: <200307281650.h6SGoHeb074072@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org From: Jonathan Lennox Subject: Re: misc/54189: DNS resolver should resolve hostnames with underscores X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: Jonathan Lennox List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Jul 2003 16:50:19 -0000 The following reply was made to PR misc/54189; it has been noted by GNATS. From: Jonathan Lennox To: sub_0@netcabo.pt Cc: freebsd-bugs@FreeBSD.org, freebsd-gnats-submit@FreeBSD.org Subject: Re: misc/54189: DNS resolver should resolve hostnames with underscores Date: Mon, 28 Jul 2003 12:40:51 -0400 --p4dH/IeS7Q Content-Type: text/plain; charset=iso-8859-1 Content-Description: message body text Content-Transfer-Encoding: quoted-printable On , July 19 2003, "M=E1rio Freitas" wrote to "freebsd-bugs@FreeBSD.org= , lennox@cs.columbia.edu" saying: > The problem you submitted is due to mozilla's gethostbyname() own(bad= ) > implementation. FreeBSD's resolver can deal with underscores in > hostnames without any problem at all. I think you should submit that > problem to mozilla's bug tracking system(yes I succeded resolving tha= t > hostname in FreeBSD 4.8 and 5.1). Not so, at least if you go through the gethostbyname() or getaddrinfo()= APIs. I've attached a small program that exercises both APIs, compiled= it on both FreeBSD 4.8-RELEASE and on Red Hat Linux 7.1, and executed b= oth on the same FreeBSD 4.8 machine (the Linux binary running under emulati= on): conrail $ ./gethostbyname dear=5Fraed.blogspot.com dear=5Fraed.blogspot.com: gethostbyname lookup failed: Unknown server e= rror (3) dear=5Fraed.blogspot.com: getaddrinfo lookup failed: Non-recoverable fa= ilure in name resolution (4) conrail $ ./gethostbyname-linux dear=5Fraed.blogspot.com dear=5Fraed.blogspot.com [ghbn]: 216.34.7.189=20 dear=5Fraed.blogspot.com [gai]: 216.34.7.189 216.34.7.189 216.34.7.189=20= The FreeBSD 'nslookup' and 'host' programs, which bypass these APIs and= do DNS queries directly, can indeed resolve the hostname: conrail $ nslookup dear=5Fraed.blogspot.com Server: sutton.cs.columbia.edu Address: 128.59.22.38 Non-authoritative answer: Name: dear=5Fraed.blogspot.com Address: 216.34.7.189 conrail $ host dear=5Fraed.blogspot.com dear=5Fraed.blogspot.com has address 216.34.7.189 --p4dH/IeS7Q Content-Type: text/plain Content-Disposition: inline; filename="gethostbyname.c" Content-Transfer-Encoding: 7bit #include #include #include #include #include #include #include #include int main(int argc, char *argv[]) { int i; struct addrinfo hints; if (argc < 2) { fprintf(stderr, "Usage: %s hostname [...]", argv[0]); exit(1); } memset(&hints, 0, sizeof(hints)); hints.ai_family = AF_INET; for (i = 1; i < argc; i++) { int ret; struct hostent *he; struct addrinfo *ai; he = gethostbyname(argv[i]); if (he == NULL) { printf("%s: gethostbyname lookup failed: %s (%d)\n", argv[i], hstrerror(h_errno), h_errno); } else { int j; printf("%s [ghbn]: ", argv[i]); for (j = 0; he->h_addr_list[j] != NULL; j++) { printf("%s ", inet_ntoa(*(struct in_addr*)(he->h_addr_list[j]))); } printf("\n"); } ret = getaddrinfo(argv[i], NULL, &hints, &ai); if (ret != 0) { printf("%s: getaddrinfo lookup failed: %s (%d)\n", argv[i], gai_strerror(ret), ret); } else { struct addrinfo* this_ai; printf("%s [gai]: ", argv[i]); for (this_ai = ai; this_ai != NULL; this_ai = this_ai->ai_next) { printf("%s ", inet_ntoa(((struct sockaddr_in*)(this_ai->ai_addr))->sin_addr)); } printf("\n"); freeaddrinfo(ai); } } return 0; } --p4dH/IeS7Q Content-Type: text/plain; charset=us-ascii Content-Description: .signature Content-Transfer-Encoding: 7bit -- Jonathan Lennox lennox@cs.columbia.edu --p4dH/IeS7Q--