From 0b4f10eddd569ab9012699118f02883ffc61312a Mon Sep 17 00:00:00 2001 From: Martin Bacovsky Date: Tue, 27 Mar 2007 11:34:20 +0000 Subject: [PATCH] - Resolves: #234060: [PATCH] IDN (umlaut domains) support for ping and ping6 patch provided by Robert Scheck --- iputils-20070202-idn.patch | 131 +++++++++++++++++++++++++++++++++++++ iputils.spec | 9 ++- 2 files changed, 139 insertions(+), 1 deletion(-) create mode 100644 iputils-20070202-idn.patch diff --git a/iputils-20070202-idn.patch b/iputils-20070202-idn.patch new file mode 100644 index 0000000..f7c9277 --- /dev/null +++ b/iputils-20070202-idn.patch @@ -0,0 +1,131 @@ +Patch by Robert Scheck for iputils >= 20070202, which adds +IDN support (umlaut domains) to ping and ping6. For ping this requires the libidn +package installed. For ping6, glibc >= 2.3.4 or glibc 2.3.3 CVS >= 20031001 is +needed. + +--- iputils-s20070202/ping.c 2007-03-11 12:22:08.000000000 +0100 ++++ iputils-s20070202/ping.c.idn 2007-03-11 14:05:40.000000000 +0100 +@@ -58,6 +58,12 @@ + * This program has to run SUID to ROOT to access the ICMP socket. + */ + ++#define LIBIDN ++#ifdef LIBIDN ++#include ++#include ++#endif ++ + #include "ping_common.h" + + #include +@@ -115,6 +121,12 @@ + char *target, hnamebuf[MAXHOSTNAMELEN]; + char rspace[3 + 4 * NROUTES + 1]; /* record route space */ + ++#ifdef LIBIDN ++ char *idn; ++ int rc = 0; ++ setlocale(LC_ALL, ""); ++#endif ++ + icmp_sock = socket(AF_INET, SOCK_RAW, IPPROTO_ICMP); + socket_errno = errno; + +@@ -236,13 +248,35 @@ + if (argc == 1) + options |= F_NUMERIC; + } else { ++#ifdef LIBIDN ++ rc = idna_to_ascii_lz (target, &idn, 0); ++ if (rc == IDNA_SUCCESS) ++ hp = gethostbyname (idn); ++ else { ++ fprintf(stderr, "ping: IDN encoding of '%s' failed with error code %d\n", target, rc); ++ exit(2); ++ } ++ free(idn); ++#else + hp = gethostbyname(target); ++#endif + if (!hp) { + fprintf(stderr, "ping: unknown host %s\n", target); + exit(2); + } + memcpy(&whereto.sin_addr, hp->h_addr, 4); ++#ifdef LIBIDN ++ rc = idna_to_unicode_lzlz (hp->h_name, &idn, 0); ++ if (rc == IDNA_SUCCESS) ++ strncpy(hnamebuf, idn, sizeof(hnamebuf) - 1); ++ else { ++ fprintf(stderr, "ping: IDN encoding of '%s' failed with error code %d\n", hp->h_name, rc); ++ exit(2); ++ } ++ free(idn); ++#else + strncpy(hnamebuf, hp->h_name, sizeof(hnamebuf) - 1); ++#endif + hnamebuf[sizeof(hnamebuf) - 1] = 0; + hostname = hnamebuf; + } +--- iputils-s20070202/Makefile 2007-03-11 12:22:08.000000000 +0100 ++++ iputils-s20070202/Makefile.idn 2007-03-11 14:16:56.000000000 +0100 +@@ -35,8 +35,13 @@ + + + tftpd: tftpd.o tftpsubs.o ++ + ping: ping.o ping_common.o ++ $(CC) $(CFLAGS) ping.o ping_common.o -lidn -o ping ++ + ping6: ping6.o ping_common.o ++ $(CC) $(CFLAGS) ping6.o ping_common.o -o ping6 ++ + ping.o ping6.o ping_common.o: ping_common.h + tftpd.o tftpsubs.o: tftp.h + +--- iputils-s20070202/ping6.c 2007-03-25 13:21:27.000000000 +0200 ++++ iputils-s20070202/ping6.c.idn 2007-03-25 13:53:16.000000000 +0200 +@@ -66,6 +66,12 @@ + * More statistics could always be gathered. + * This program has to run SUID to ROOT to access the ICMP socket. + */ ++#define IDN ++#ifdef IDN ++#define _GNU_SOURCE ++#include ++#endif ++ + #include "ping_common.h" + + #include +@@ -210,6 +216,10 @@ + int err, csum_offset, sz_opt; + static uint32_t scope_id = 0; + ++#ifdef IDN ++ setlocale(LC_ALL, ""); ++#endif ++ + icmp_sock = socket(AF_INET6, SOCK_RAW, IPPROTO_ICMPV6); + socket_errno = errno; + +@@ -296,6 +306,9 @@ + + memset(&hints, 0, sizeof(hints)); + hints.ai_family = AF_INET6; ++#ifdef IDN ++ hints.ai_flags = AI_IDN; ++#endif + gai = getaddrinfo(target, NULL, &hints, &ai); + if (gai) { + fprintf(stderr, "unknown host\n"); +@@ -328,6 +341,9 @@ + + memset(&hints, 0, sizeof(hints)); + hints.ai_family = AF_INET6; ++#ifdef IDN ++ hints.ai_flags = AI_IDN; ++#endif + gai = getaddrinfo(target, NULL, &hints, &ai); + if (gai) { + fprintf(stderr, "unknown host\n"); diff --git a/iputils.spec b/iputils.spec index f6d9d1d..93e88c2 100644 --- a/iputils.spec +++ b/iputils.spec @@ -1,7 +1,7 @@ Summary: Network monitoring tools including ping Name: iputils Version: 20070202 -Release: 1%{?dist} +Release: 2%{?dist} License: BSD URL: http://www.skbuff.net/iputils Group: System Environment/Daemons @@ -18,11 +18,13 @@ Patch15: iputils-20020927-12-arping.patch Patch21: iputils-ping_cleanup.patch Patch22: iputils-ifenslave.patch Patch25: iputils-20020927-arping-infiniband.patch +Patch26: iputils-20070202-idn.patch BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) BuildRequires: docbook-utils perl-SGMLSpm BuildRequires: glibc-kernheaders >= 2.4-8.19 BuildRequires: libsysfs-devel +BuildRequires: libidn-devel Requires(post): chkconfig Requires(preun): chkconfig @@ -45,6 +47,7 @@ the target machine is alive and receiving network traffic. %patch21 -p1 -b .cleanup %patch22 -p1 -b .addr %patch25 -p1 -b .infiniband +%patch26 -p1 -b .idn %build %ifarch s390 s390x @@ -139,6 +142,10 @@ rm -rf ${RPM_BUILD_ROOT} %{_sysconfdir}/rc.d/init.d/rdisc %changelog +* Tue Mar 27 2007 Martin Bacovsky - 20070202-2 +- Resolves: #234060: [PATCH] IDN (umlaut domains) support for ping and ping6 + patch provided by Robert Scheck + * Thu Mar 15 2007 Martin Bacovsky - 20070202-1 - upgarde to new upstream iputils-s20070202 - Resolves: #229995