From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1Q8Yh2-0007lU-J4 for garchives@archives.gentoo.org; Sat, 09 Apr 2011 13:59:17 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id B1ED21C040; Sat, 9 Apr 2011 13:58:19 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id 72F081C040 for ; Sat, 9 Apr 2011 13:58:09 +0000 (UTC) Received: from pelican.gentoo.org (unknown [66.219.59.40]) (using TLSv1 with cipher ADH-CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id D454C1B4085 for ; Sat, 9 Apr 2011 13:58:08 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by pelican.gentoo.org (Postfix) with ESMTP id 4890C80065 for ; Sat, 9 Apr 2011 13:58:08 +0000 (UTC) From: "Mike Frysinger" To: gentoo-commits@lists.gentoo.org Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Mike Frysinger" Message-ID: <8022436648fc84b5015dec20339ddd58b9fbfcdf.vapier@gentoo> Subject: [gentoo-commits] proj/net-tools:master commit in: / X-VCS-Repository: proj/net-tools X-VCS-Files: hostname.c X-VCS-Directories: / X-VCS-Committer: vapier X-VCS-Committer-Name: Mike Frysinger X-VCS-Revision: 8022436648fc84b5015dec20339ddd58b9fbfcdf Date: Sat, 9 Apr 2011 13:58:08 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: quoted-printable X-Archives-Salt: X-Archives-Hash: 06250c9cb3a1ae0aa720f672b418691b commit: 8022436648fc84b5015dec20339ddd58b9fbfcdf Author: Mike Frysinger gentoo org> AuthorDate: Sat Apr 9 13:33:13 2011 +0000 Commit: Mike Frysinger gentoo org> CommitDate: Sat Apr 9 13:33:13 2011 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/net-tools.git= ;a=3Dcommit;h=3D80224366 hostname: fix FQDN handling with AAAA records patch by pasi.valminen hut.fi Gentoo bug 42650 --- hostname.c | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++++--= ----- 1 files changed, 59 insertions(+), 8 deletions(-) diff --git a/hostname.c b/hostname.c index c4c5aa0..4d87b4e 100644 --- a/hostname.c +++ b/hostname.c @@ -44,6 +44,11 @@ #include "version.h" #include "../intl.h" =20 +#if HAVE_AFINET6 +#include /* for PF_INET6 */ +#include /* for inet_ntop */ +#endif + #if HAVE_AFDECnet #include #endif @@ -125,15 +130,23 @@ static void setdname(char *dname) static void showhname(char *hname, int c) { struct hostent *hp; +#if HAVE_AFINET6 + struct in6_addr **ip6; +#endif register char *p, **alias; struct in_addr **ip; =20 if (opt_v) fprintf(stderr, _("Resolving `%s' ...\n"), hname); - if (!(hp =3D gethostbyname(hname))) { + if ( +#if HAVE_AFINET6 + !(hp =3D gethostbyname2(hname, PF_INET6)) && +#endif + !(hp =3D gethostbyname(hname))) { herror(program_name); exit(1); } + if (opt_v) { fprintf(stderr, _("Result: h_name=3D`%s'\n"), hp->h_name); @@ -142,11 +155,28 @@ static void showhname(char *hname, int c) while (alias[0]) fprintf(stderr, _("Result: h_aliases=3D`%s'\n"), *alias++); - - ip =3D (struct in_addr **) hp->h_addr_list; - while (ip[0]) - fprintf(stderr, _("Result: h_addr_list=3D`%s'\n"), - inet_ntoa(**ip++)); +#if HAVE_AFINET6 + if (hp->h_addrtype =3D=3D PF_INET6) { + char addr[INET6_ADDRSTRLEN + 1]; + addr[INET6_ADDRSTRLEN] =3D '\0'; + ip6 =3D (struct in6_addr **) hp->h_addr_list; + while (ip6[0]) { + if (inet_ntop(PF_INET6, *ip6++, addr, INET6_ADDRSTRLEN)) + fprintf(stderr, _("Result: h_addr_list=3D`%s'\n"), addr); + else if (errno =3D=3D EAFNOSUPPORT) + fprintf(stderr, _("%s: protocol family not supported\n"), + program_name); + else if (errno =3D=3D ENOSPC) + fprintf(stderr, _("%s: name too long\n"), program_name); + } + } else +#endif + { + ip =3D (struct in_addr **) hp->h_addr_list; + while (ip[0]) + fprintf(stderr, _("Result: h_addr_list=3D`%s'\n"), + inet_ntoa(**ip++)); + } } if (!(p =3D strchr(hp->h_name, '.')) && (c =3D=3D 'd')) return; @@ -158,8 +188,29 @@ static void showhname(char *hname, int c) printf("\n"); break; case 'i': - while (hp->h_addr_list[0]) - printf("%s ", inet_ntoa(*(struct in_addr *) *hp->h_addr_list++)); +#if HAVE_AFINET6 + if (hp->h_addrtype =3D=3D PF_INET6) { + char addr[INET6_ADDRSTRLEN + 1]; + addr[INET6_ADDRSTRLEN] =3D '\0'; + while (hp->h_addr_list[0]) { + if (inet_ntop(PF_INET6, (struct in6_addr *)*hp->h_addr_list++, + addr, INET6_ADDRSTRLEN)) { + printf("%s ", addr); + } else if (errno =3D=3D EAFNOSUPPORT) { + fprintf(stderr, _("\n%s: protocol family not supported\n"), + program_name); + exit(1); + } else if (errno =3D=3D ENOSPC) { + fprintf(stderr, _("\n%s: name too long\n"), program_name); + exit(1); + } + } + } else +#endif + { + while (hp->h_addr_list[0]) + printf("%s ", inet_ntoa(*(struct in_addr *)*hp->h_addr_list++)); + } printf("\n"); break; case 'd': From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1Q8Ygr-0007Vq-49 for garchives@archives.gentoo.org; Sat, 09 Apr 2011 13:59:08 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id C4B2C1C028; Sat, 9 Apr 2011 13:58:07 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id 826151C024 for ; Sat, 9 Apr 2011 13:58:07 +0000 (UTC) Received: from pelican.gentoo.org (unknown [66.219.59.40]) (using TLSv1 with cipher ADH-CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id EC5C21B408A for ; Sat, 9 Apr 2011 13:58:06 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by pelican.gentoo.org (Postfix) with ESMTP id 4109080076 for ; Sat, 9 Apr 2011 13:58:06 +0000 (UTC) From: "Mike Frysinger" To: gentoo-commits@lists.gentoo.org Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Mike Frysinger" Message-ID: <8022436648fc84b5015dec20339ddd58b9fbfcdf.vapier@gentoo> Subject: [gentoo-commits] proj/net-tools:gentoo commit in: / X-VCS-Repository: proj/net-tools X-VCS-Files: hostname.c X-VCS-Directories: / X-VCS-Committer: vapier X-VCS-Committer-Name: Mike Frysinger X-VCS-Revision: 8022436648fc84b5015dec20339ddd58b9fbfcdf Date: Sat, 9 Apr 2011 13:58:06 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: quoted-printable X-Archives-Salt: X-Archives-Hash: 2bce3fef4a03a71e411eade91dfd14c2 Message-ID: <20110409135806.5fEeC1O1QI8IegZsx33zH8xWCzt0eNHkAzOVOVSzQKA@z> commit: 8022436648fc84b5015dec20339ddd58b9fbfcdf Author: Mike Frysinger gentoo org> AuthorDate: Sat Apr 9 13:33:13 2011 +0000 Commit: Mike Frysinger gentoo org> CommitDate: Sat Apr 9 13:33:13 2011 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/net-tools.git= ;a=3Dcommit;h=3D80224366 hostname: fix FQDN handling with AAAA records patch by pasi.valminen hut.fi Gentoo bug 42650 --- hostname.c | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++++--= ----- 1 files changed, 59 insertions(+), 8 deletions(-) diff --git a/hostname.c b/hostname.c index c4c5aa0..4d87b4e 100644 --- a/hostname.c +++ b/hostname.c @@ -44,6 +44,11 @@ #include "version.h" #include "../intl.h" =20 +#if HAVE_AFINET6 +#include /* for PF_INET6 */ +#include /* for inet_ntop */ +#endif + #if HAVE_AFDECnet #include #endif @@ -125,15 +130,23 @@ static void setdname(char *dname) static void showhname(char *hname, int c) { struct hostent *hp; +#if HAVE_AFINET6 + struct in6_addr **ip6; +#endif register char *p, **alias; struct in_addr **ip; =20 if (opt_v) fprintf(stderr, _("Resolving `%s' ...\n"), hname); - if (!(hp =3D gethostbyname(hname))) { + if ( +#if HAVE_AFINET6 + !(hp =3D gethostbyname2(hname, PF_INET6)) && +#endif + !(hp =3D gethostbyname(hname))) { herror(program_name); exit(1); } + if (opt_v) { fprintf(stderr, _("Result: h_name=3D`%s'\n"), hp->h_name); @@ -142,11 +155,28 @@ static void showhname(char *hname, int c) while (alias[0]) fprintf(stderr, _("Result: h_aliases=3D`%s'\n"), *alias++); - - ip =3D (struct in_addr **) hp->h_addr_list; - while (ip[0]) - fprintf(stderr, _("Result: h_addr_list=3D`%s'\n"), - inet_ntoa(**ip++)); +#if HAVE_AFINET6 + if (hp->h_addrtype =3D=3D PF_INET6) { + char addr[INET6_ADDRSTRLEN + 1]; + addr[INET6_ADDRSTRLEN] =3D '\0'; + ip6 =3D (struct in6_addr **) hp->h_addr_list; + while (ip6[0]) { + if (inet_ntop(PF_INET6, *ip6++, addr, INET6_ADDRSTRLEN)) + fprintf(stderr, _("Result: h_addr_list=3D`%s'\n"), addr); + else if (errno =3D=3D EAFNOSUPPORT) + fprintf(stderr, _("%s: protocol family not supported\n"), + program_name); + else if (errno =3D=3D ENOSPC) + fprintf(stderr, _("%s: name too long\n"), program_name); + } + } else +#endif + { + ip =3D (struct in_addr **) hp->h_addr_list; + while (ip[0]) + fprintf(stderr, _("Result: h_addr_list=3D`%s'\n"), + inet_ntoa(**ip++)); + } } if (!(p =3D strchr(hp->h_name, '.')) && (c =3D=3D 'd')) return; @@ -158,8 +188,29 @@ static void showhname(char *hname, int c) printf("\n"); break; case 'i': - while (hp->h_addr_list[0]) - printf("%s ", inet_ntoa(*(struct in_addr *) *hp->h_addr_list++)); +#if HAVE_AFINET6 + if (hp->h_addrtype =3D=3D PF_INET6) { + char addr[INET6_ADDRSTRLEN + 1]; + addr[INET6_ADDRSTRLEN] =3D '\0'; + while (hp->h_addr_list[0]) { + if (inet_ntop(PF_INET6, (struct in6_addr *)*hp->h_addr_list++, + addr, INET6_ADDRSTRLEN)) { + printf("%s ", addr); + } else if (errno =3D=3D EAFNOSUPPORT) { + fprintf(stderr, _("\n%s: protocol family not supported\n"), + program_name); + exit(1); + } else if (errno =3D=3D ENOSPC) { + fprintf(stderr, _("\n%s: name too long\n"), program_name); + exit(1); + } + } + } else +#endif + { + while (hp->h_addr_list[0]) + printf("%s ", inet_ntoa(*(struct in_addr *)*hp->h_addr_list++)); + } printf("\n"); break; case 'd':