commit-inetutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[SCM] GNU Inetutils branch, master, updated. inetutils-1_9_1-267-g58d53


From: Mats Erik Andersson
Subject: [SCM] GNU Inetutils branch, master, updated. inetutils-1_9_1-267-g58d5337
Date: Fri, 05 Apr 2013 00:31:04 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU Inetutils ".

The branch, master has been updated
       via  58d533764dd4e50bd48c835db80d35693e5dabca (commit)
       via  c39250371e0e2f8a89ded6463e93c980b3e42f4d (commit)
      from  c2c33de07f6497883d4d5200f62a7798f3371db4 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit/inetutils.git/commit/?id=58d533764dd4e50bd48c835db80d35693e5dabca


commit 58d533764dd4e50bd48c835db80d35693e5dabca
Author: Mats Erik Andersson <address@hidden>
Date:   Fri Apr 5 02:11:25 2013 +0200

    talk: Address resolution.

diff --git a/ChangeLog b/ChangeLog
index ef743d4..912d03f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2013-04-05  Mats Erik Andersson  <address@hidden>
+
+       talk: Address resolution.
+
+       * talk/get_addrs.c (get_addrs): Implement resolver
+       using getaddrinfo().  This is now the preferred method.
+       [HAVE_DECL_GETADDRINFO || defined HAVE_IDN]:
+       Declare ERR with larger scope.
+       [HAVE_DECL_GETADDRINFO]: New variables HINTS, RES, AI.
+       Call getaddrinfo() for LHOST and RHOST.
+       [HAVE_DECL_GETADDRINFO && AI_IDN]: Add AI_IDN to
+       `hints.ai_flags'.
+
 2013-04-04  Mats Erik Andersson  <address@hidden>
 
        More IDN support for clients.
diff --git a/NEWS b/NEWS
index 8e8bcfb..6a60b90 100644
--- a/NEWS
+++ b/NEWS
@@ -5,6 +5,15 @@ See the end of this file for license conditions.
 
 Please send inetutils bug reports to <address@hidden>.
 
+* IDN -- International Domain Names
+
+The clients `ftp', `ping', `ping6', `talk', `telnet', `tftp',
+and `traceroute' are now capable of using libidn in resolving
+domain names with character sets richer than ASCII.
+
+Systems using Glibc achieve this ability by other means in the
+present code, so they do not need to link against libidn at all.
+
 * New tool 'dnsdomainname'.
 
 * ftp
diff --git a/talk/get_addrs.c b/talk/get_addrs.c
index d91a788..ed4d174 100644
--- a/talk/get_addrs.c
+++ b/talk/get_addrs.c
@@ -68,13 +68,18 @@
 int
 get_addrs (char *my_machine_name, char *his_machine_name)
 {
+#if HAVE_DECL_GETADDRINFO || defined HAVE_IDN
+  int err;
+#endif
   char *lhost, *rhost;
+#if HAVE_DECL_GETADDRINFO
+  struct addrinfo hints, *res, *ai;
+#else /* !HAVE_DECL_GETADDRINFO */
   struct hostent *hp;
+#endif
   struct servent *sp;
 
 #ifdef HAVE_IDN
-  int err;
-
   err = idna_to_ascii_lz (my_machine_name, &lhost, 0);
   if (err)
     {
@@ -96,7 +101,66 @@ get_addrs (char *my_machine_name, char *his_machine_name)
 #endif
 
   msg.pid = htonl (getpid ());
-  /* look up the address of the local host */
+
+  /* Look up the address of the local host.  */
+
+#if HAVE_DECL_GETADDRINFO
+  memset (&hints, 0, sizeof (hints));
+
+  /* The talk-protocol is IPv4 only!  */
+  hints.ai_family = AF_INET;
+  hints.ai_socktype = SOCK_DGRAM;
+# ifdef AI_IDN
+  hints.ai_flags |= AI_IDN;
+# endif
+
+  err = getaddrinfo (lhost, NULL, &hints, &res);
+  if (err)
+    {
+      fprintf (stderr, "talk: %s: %s\n", lhost, gai_strerror (err));
+      exit (-1);
+    }
+
+  /* Perform all sanity checks available.
+   * Reduction of tests?
+   */
+  for (ai = res; ai; ai = ai->ai_next)
+    {
+      int f;
+
+      if (ai->ai_family != AF_INET)
+       continue;
+
+      f = socket (ai->ai_family, ai->ai_socktype, ai->ai_protocol);
+      if (f < 0)
+       continue;
+
+      /* Attempt binding to this local address.  */
+      if (bind (f, ai->ai_addr, ai->ai_addrlen))
+        {
+         close (f);
+         f = -1;
+         continue;
+       }
+
+      /* We have a usable address.  */
+      close (f);
+      break;
+    }
+
+  if (ai)
+    memcpy (&my_machine_addr,
+           &((struct sockaddr_in *) ai->ai_addr)->sin_addr,
+           sizeof (my_machine_addr));
+
+  freeaddrinfo (res);
+  if (!ai)
+    {
+      fprintf (stderr, "talk: %s: %s\n", lhost, "address not found");
+      exit (-1);
+    }
+
+#else /* !HAVE_DECL_GETADDRINFO */
   hp = gethostbyname (lhost);
   if (hp == NULL)
     {
@@ -105,12 +169,52 @@ get_addrs (char *my_machine_name, char *his_machine_name)
       exit (-1);
     }
   memmove (&my_machine_addr, hp->h_addr, hp->h_length);
+#endif /* !HAVE_DECL_GETADDRINFO */
+
   /*
    * If the callee is on-machine, just copy the
    * network address, otherwise do a lookup...
    */
   if (strcmp (rhost, lhost))
     {
+#if HAVE_DECL_GETADDRINFO
+      err = getaddrinfo (rhost, NULL, &hints, &res);
+      if (err)
+       {
+         fprintf (stderr, "talk: %s: %s\n", rhost, gai_strerror (err));
+         exit (-1);
+       }
+
+      /* Perform all sanity checks available.  */
+      for (ai = res; ai; ai = ai->ai_next)
+       {
+         int f;
+
+         if (ai->ai_family != AF_INET)
+           continue;
+
+         f = socket (ai->ai_family, ai->ai_socktype, ai->ai_protocol);
+         if (f < 0)
+           continue;
+
+         /* We have a usable address family!  */
+         close (f);
+         break;
+       }
+
+      if (ai)
+       memcpy (&his_machine_addr,
+               &((struct sockaddr_in *) ai->ai_addr)->sin_addr,
+               sizeof (his_machine_addr));
+
+      freeaddrinfo (res);
+      if (!ai)
+       {
+         fprintf (stderr, "talk: %s: %s\n", rhost, "address not found");
+         exit (-1);
+       }
+
+#else /* !HAVE_DECL_GETADDRINFO */
       hp = gethostbyname (rhost);
       if (hp == NULL)
        {
@@ -119,10 +223,12 @@ get_addrs (char *my_machine_name, char *his_machine_name)
          exit (-1);
        }
       memmove (&his_machine_addr, hp->h_addr, hp->h_length);
+#endif /* !HAVE_DECL_GETADDRINFO */
     }
   else
     his_machine_addr = my_machine_addr;
-  /* find the server's port */
+
+  /* Find the server's port.  */
   sp = getservbyname ("ntalk", "udp");
   if (sp == 0)
     {

http://git.savannah.gnu.org/cgit/inetutils.git/commit/?id=c39250371e0e2f8a89ded6463e93c980b3e42f4d


commit c39250371e0e2f8a89ded6463e93c980b3e42f4d
Author: Mats Erik Andersson <address@hidden>
Date:   Thu Apr 4 00:51:05 2013 +0200

    More IDN support for clients.

diff --git a/ChangeLog b/ChangeLog
index 39bcba7..ef743d4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,58 @@
+2013-04-04  Mats Erik Andersson  <address@hidden>
+
+       More IDN support for clients.
+
+       * configure.ac <summary>: Uppdate ftp_PROPS,
+       talk_PROPS, telnet_PROPS, and tftp_PROPS using
+       LIBIDN.
+       * ftp/Makefile.am (AM_CPPFLAGS): Add $(INCIDN).
+       (LDADD): Add $(LIBIDN).
+       * talk/Makefile.am, telnet/Makefile.am
+       (AM_CPPFLAGS, LDADD): Likewise.
+       * src/Makefile.am (tftp_LDADD): Add $(LIBIDN).
+
+       * ftp/ftp.c [HAVE_IDNA_H]: Include <idna.h>.
+       (hookup): New variable RHOST.  Use RHOST in
+       getaddrinfo().
+       [HAVE_IDN]: Call idna_to_ascii_lz().
+       [!HAVE_IDN]: Strdup `host' as RHOST.
+       [AI_IDN]: Add to `hints.ai_flags'.
+       [AI_CANONIDN]: Likewise.
+       * ftp/main.c [HAVE_LOCALE_H]: Include <locale.h>.
+       (main) [HAVE_SETLOCALE]: Call setlocale().
+
+       * ping/libping.c (ping_set_dest) [AI_CANONIDN]:
+       Add to `hints.ai_flags' independently if AI_IDN.
+       * ping/ping6.c (ping_set_dest): Set AI_CANONNAME
+       on `hints.ai_flags'.  Strdup `result->ai_canonname'
+       to `ping->ping_hostname'.
+       [AI_CANONIDN]: Add to `hints.ai_flags'.
+
+       * src/tftp.c [HAVE_LOCALE_H]: Include <locale.h>.
+       [HAVE_IDNA_H]: Include <idna.h>.
+       (main) [HAVE_SETLOCALE): Call setlocale().
+       (resolve_name): New variable RNAME.  Use RNAME
+       with getaddrinfo().
+       [HAVE_IDN]: Call idna_to_ascii_lz().
+       [AI_IDN]: Add to `hints.ai_flags'.
+       [AI_CANONIDN]: Add to `hints.ai_flags'.
+
+       * talk/get_addrs.c [HAVE_IDNA_H]: Include <idna.h>.
+       (get_addrs): New variables LHOST, RHOST.  Use these
+       for address resolution with gethostbyname().
+       [HAVE_IDN]: Call idna_to_ascii_lz() twice.
+       * talk/talk.c [HAVE_LOCALE_H]: Include <locale.h>.
+       (main) [HAVE_SETLOCALE]: Call setlocale().
+
+       * telnet/commands.c [HAVE_IDNA_H]: Include <idna.h>.
+       (tn): New variable HOSTTMP.
+       [HAVE_IDN]: Call idna_to_ascii_lz() and let HOSTP
+       be identical to HOSTTMP if the call was successful.
+       Free HOSTTMP after use.
+       [IPV6 && AI_IDN]: Set `hints.ai_flags' to AI_IDN.
+       * telnet/main.c [HAVE_LOCALE_H]: Include <locale.h>.
+       (main) [HAVE_SETLOCALE]: Call setlocale().
+
 2013-03-30  Mats Erik Andersson  <address@hidden>
 
        * configure.ac <summary>: New variables `*_PROPS'
diff --git a/configure.ac b/configure.ac
index 6b5fd39..6c6de9f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1040,7 +1040,11 @@ rlogind_PROPS="${rlogind_PROPS:+$rlogind_PROPS }$LIBWRAP"
 
 # Support for libidn.
 
+ftp_PROPS="${ftp_PROPS:+$ftp_PROPS }${LIBIDN:+-libidn}"
 ping_PROPS="${ping_PROPS:+$ping_PROPS }${LIBIDN:+-libidn}"
+talk_PROPS="${talk_PROPS:+$talk_PROPS }${LIBIDN:+-libidn}"
+telnet_PROPS="${telnet_PROPS:+$telnet_PROPS }${LIBIDN:+-libidn}"
+tftp_PROPS="${tftp_PROPS:+$tftp_PROPS }${LIBIDN:+-libidn}"
 traceroute_PROPS="${traceroute_PROPS:+$traceroute_PROPS }${LIBIDN:+-libidn}"
 
 # Termcap variants.
diff --git a/ftp/Makefile.am b/ftp/Makefile.am
index 3d134c7..cedfa70 100644
--- a/ftp/Makefile.am
+++ b/ftp/Makefile.am
@@ -22,11 +22,13 @@
 
 AM_CPPFLAGS = \
        $(iu_INCLUDES) \
+       $(INCIDN) \
        $(PATHDEF_TMP) $(PATHDEF_BSHELL)
 
 LDADD = \
        $(iu_LIBRARIES) \
-       $(LIBGLOB) $(LIBREADLINE) $(LIBTERMCAP) $(LIBHISTORY)
+       $(LIBGLOB) $(LIBREADLINE) $(LIBTERMCAP) $(LIBHISTORY) \
+       $(LIBIDN)
 
 bin_PROGRAMS = $(ftp_BUILD)
 
diff --git a/ftp/ftp.c b/ftp/ftp.c
index 5c4eba2..34ef42d 100644
--- a/ftp/ftp.c
+++ b/ftp/ftp.c
@@ -83,6 +83,10 @@
 #include <stdarg.h>
 #include <sys/select.h>
 
+#ifdef HAVE_IDNA_H
+# include <idna.h>
+#endif
+
 #include "ftp_var.h"
 #include "unused-parameter.h"
 
@@ -129,6 +133,19 @@ hookup (char *host, int port)
   int s, tos;
   socklen_t len;
   static char hostnamebuf[80];
+  char *rhost;
+
+#ifdef HAVE_IDN
+  status = idna_to_ascii_lz (host, &rhost, 0);
+  if (status)
+    {
+      error (0, 0, "%s: %s", host, idna_strerror (status));
+      code = -1;
+      return ((char *) 0);
+    }
+#else /* !HAVE_IDN */
+  rhost = strdup (host);
+#endif
 
   snprintf (portstr, sizeof (portstr) - 1, "%u", port);
   memset (&hisctladdr, 0, sizeof (hisctladdr));
@@ -137,14 +154,22 @@ hookup (char *host, int port)
   hints.ai_family = usefamily;
   hints.ai_socktype = SOCK_STREAM;
   hints.ai_flags = AI_CANONNAME;
+#ifdef AI_IDN
+  hints.ai_flags |= AI_IDN;
+#endif
+#ifdef AI_CANONIDN
+  hints.ai_flags |= AI_CANONIDN;
+#endif
 
-  status = getaddrinfo (host, portstr, &hints, &res);
+  status = getaddrinfo (rhost, portstr, &hints, &res);
   if (status)
     {
-      error (0, 0, "%s: %s", host, gai_strerror (status));
+      error (0, 0, "%s: %s", rhost, gai_strerror (status));
       code = -1;
+      free (rhost);
       return ((char *) 0);
     }
+  free (rhost);
   strncpy (hostnamebuf, res->ai_canonname, sizeof (hostnamebuf));
   hostname = hostnamebuf;
 
diff --git a/ftp/main.c b/ftp/main.c
index 7ccb967..c01ba82 100644
--- a/ftp/main.c
+++ b/ftp/main.c
@@ -69,6 +69,9 @@
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
+#ifdef HAVE_LOCALE_H
+# include <locale.h>
+#endif
 
 /* Define macro to nothing so declarations in ftp_var.h become definitions. */
 #define FTP_EXTERN
@@ -198,6 +201,10 @@ main (int argc, char *argv[])
 
   set_program_name (argv[0]);
 
+#ifdef HAVE_SETLOCALE
+  setlocale (LC_ALL, "");
+#endif
+
   doglob = 1;
   interactive = 1;
   autologin = 1;
diff --git a/ping/libping.c b/ping/libping.c
index 4339458..6bcbe8e 100644
--- a/ping/libping.c
+++ b/ping/libping.c
@@ -285,9 +285,9 @@ ping_set_dest (PING * ping, char *host)
   hints.ai_flags = AI_CANONNAME;
 # ifdef AI_IDN
   hints.ai_flags |= AI_IDN;
-#  ifdef AI_CANONIDN
+# endif
+# ifdef AI_CANONIDN
   hints.ai_flags |= AI_CANONIDN;
-#  endif
 # endif
 
   rc = getaddrinfo (p, NULL, &hints, &res);
diff --git a/ping/ping6.c b/ping/ping6.c
index 203790c..cb37f3f 100644
--- a/ping/ping6.c
+++ b/ping/ping6.c
@@ -1011,8 +1011,12 @@ ping_set_dest (PING * ping, char *host)
 
   memset (&hints, 0, sizeof (hints));
   hints.ai_family = AF_INET6;
+  hints.ai_flags = AI_CANONNAME;
 #ifdef AI_IDN
-  hints.ai_flags = AI_IDN;
+  hints.ai_flags |= AI_IDN;
+#endif
+#ifdef AI_CANONIDN
+  hints.ai_flags |= AI_CANONIDN;
 #endif
 
   err = getaddrinfo (rhost, NULL, &hints, &result);
@@ -1024,9 +1028,9 @@ ping_set_dest (PING * ping, char *host)
 
   memcpy (&ping->ping_dest.ping_sockaddr6, result->ai_addr, 
result->ai_addrlen);
 
+  ping->ping_hostname = strdup (result->ai_canonname);
   freeaddrinfo (result);
 
-  ping->ping_hostname = strdup (host);
   if (!ping->ping_hostname)
     return 1;
 
diff --git a/src/Makefile.am b/src/Makefile.am
index 7cbcf98..189df7e 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -75,6 +75,7 @@ EXTRA_PROGRAMS += rsh
 
 bin_PROGRAMS += $(tftp_BUILD)
 tftp_SOURCES = tftp.c
+tftp_LDADD = $(LDADD) $(LIBIDN)
 EXTRA_PROGRAMS += tftp
 
 bin_PROGRAMS += $(traceroute_BUILD)
diff --git a/src/tftp.c b/src/tftp.c
index c2ed52c..c6d0424 100644
--- a/src/tftp.c
+++ b/src/tftp.c
@@ -72,6 +72,13 @@
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
+#ifdef HAVE_LOCALE_H
+# include <locale.h>
+#endif
+#ifdef HAVE_IDNA_H
+# include <idna.h>
+#endif
+
 #include <argp.h>
 #include <unused-parameter.h>
 
@@ -263,6 +270,9 @@ main (int argc, char *argv[])
   struct servent *sp;
 
   set_program_name (argv[0]);
+#ifdef HAVE_SETLOCALE
+  setlocale (LC_ALL, "");
+#endif
   iu_argp_init ("tftp", default_program_authors);
   argp_parse (&argp, argc, argv, 0, NULL, NULL);
 
@@ -301,21 +311,43 @@ static int
 resolve_name (char *name)
 {
   int err;
+  char *rname;
   struct sockaddr_storage ss;
   struct addrinfo hints, *ai, *aiptr;
 
+#ifdef HAVE_IDN
+  err = idna_to_ascii_lz (name, &rname, 0);
+  if (err)
+    {
+      fprintf (stderr, "tftp: %s: %s\n", name, idna_strerror (err));
+      return RESOLVE_FAIL;
+    }
+#else /* !HAVE_IDN */
+  rname = name;
+#endif
+
   memset (&hints, 0, sizeof (hints));
   hints.ai_family = AF_UNSPEC;
   hints.ai_socktype = SOCK_DGRAM;
   hints.ai_flags = AI_CANONNAME;
+#ifdef AI_IDN
+  hints.ai_flags |= AI_IDN;
+#endif
+#ifdef AI_CANONIDN
+  hints.ai_flags |= AI_CANONIDN;
+#endif
 
-  err = getaddrinfo (name, "tftp", &hints, &aiptr);
+  err = getaddrinfo (rname, "tftp", &hints, &aiptr);
   if (err)
     {
-      fprintf (stderr, "tftp: %s: %s\n", name, gai_strerror (err));
+      fprintf (stderr, "tftp: %s: %s\n", rname, gai_strerror (err));
       return RESOLVE_FAIL;
     }
 
+#ifdef HAVE_IDN
+  free (rname);
+#endif
+
   if (f >= 0)
     {
       close (f);
diff --git a/talk/Makefile.am b/talk/Makefile.am
index ce0f99b..e42a274 100644
--- a/talk/Makefile.am
+++ b/talk/Makefile.am
@@ -20,11 +20,11 @@
 
 AM_CPPFLAGS = \
        $(iu_INCLUDES) \
-       $(NCURSES_INCLUDE)
+       $(NCURSES_INCLUDE) $(INCIDN)
 
 LDADD = \
        $(iu_LIBRARIES) \
-       $(LIBCURSES)
+       $(LIBCURSES) $(LIBIDN)
 
 bin_PROGRAMS = $(talk_BUILD)
 
diff --git a/talk/get_addrs.c b/talk/get_addrs.c
index b5e9a0e..d91a788 100644
--- a/talk/get_addrs.c
+++ b/talk/get_addrs.c
@@ -59,20 +59,48 @@
 #include <netdb.h>
 #include <stdio.h>
 #include <unistd.h>
+#ifdef HAVE_IDNA_H
+# include <idna.h>
+#endif
+
 #include "talk_ctl.h"
 
 int
 get_addrs (char *my_machine_name, char *his_machine_name)
 {
+  char *lhost, *rhost;
   struct hostent *hp;
   struct servent *sp;
 
+#ifdef HAVE_IDN
+  int err;
+
+  err = idna_to_ascii_lz (my_machine_name, &lhost, 0);
+  if (err)
+    {
+      fprintf (stderr, "talk: %s: %s\n",
+              my_machine_name, idna_strerror (err));
+      exit (-1);
+    }
+
+  err = idna_to_ascii_lz (his_machine_name, &rhost, 0);
+  if (err)
+    {
+      fprintf (stderr, "talk: %s: %s\n",
+              his_machine_name, idna_strerror (err));
+      exit (-1);
+    }
+#else /* !HAVE_IDN */
+  lhost = my_machine_name;
+  rhost = his_machine_name;
+#endif
+
   msg.pid = htonl (getpid ());
   /* look up the address of the local host */
-  hp = gethostbyname (my_machine_name);
+  hp = gethostbyname (lhost);
   if (hp == NULL)
     {
-      fprintf (stderr, "talk: %s: ", my_machine_name);
+      fprintf (stderr, "talk: %s(%s): ", lhost, my_machine_name);
       herror ((char *) NULL);
       exit (-1);
     }
@@ -81,12 +109,12 @@ get_addrs (char *my_machine_name, char *his_machine_name)
    * If the callee is on-machine, just copy the
    * network address, otherwise do a lookup...
    */
-  if (strcmp (his_machine_name, my_machine_name))
+  if (strcmp (rhost, lhost))
     {
-      hp = gethostbyname (his_machine_name);
+      hp = gethostbyname (rhost);
       if (hp == NULL)
        {
-         fprintf (stderr, "talk: %s: ", his_machine_name);
+         fprintf (stderr, "talk: %s(%s): ", rhost, his_machine_name);
          herror ((char *) NULL);
          exit (-1);
        }
@@ -104,5 +132,10 @@ get_addrs (char *my_machine_name, char *his_machine_name)
     }
   daemon_port = ntohs (sp->s_port);
 
+#ifdef HAVE_IDN
+  free (lhost);
+  free (rhost);
+#endif
+
   return 0;
 }
diff --git a/talk/talk.c b/talk/talk.c
index cd6379b..7cead32 100644
--- a/talk/talk.c
+++ b/talk/talk.c
@@ -49,10 +49,13 @@
 
 #include <config.h>
 #include <stdlib.h>
+#include <unistd.h>
+#ifdef HAVE_LOCALE_H
+# include <locale.h>
+#endif
 
 #include "talk.h"
 #include <argp.h>
-#include <unistd.h>
 #include <libinetutils.h>
 
 void usage (void);
@@ -89,6 +92,9 @@ main (int argc, char *argv[])
   int index;
 
   set_program_name (argv[0]);
+#ifdef HAVE_SETLOCALE
+  setlocale (LC_ALL, "");
+#endif
   iu_argp_init ("talk", program_authors);
   argp_parse (&argp, argc, argv, 0, &index, NULL);
 
diff --git a/telnet/Makefile.am b/telnet/Makefile.am
index 29b3bcb..b9e771b 100644
--- a/telnet/Makefile.am
+++ b/telnet/Makefile.am
@@ -22,12 +22,12 @@ AM_CPPFLAGS = \
        -DTERMCAP -DLINEMODE -DKLUDGELINEMODE -DENV_HACK \
        $(iu_INCLUDES) \
        -I$(top_srcdir) \
-       $(NCURSES_INCLUDE)
+       $(NCURSES_INCLUDE) $(INCIDN)
 
 LDADD = \
        $(top_builddir)/libtelnet/libtelnet.a \
        $(iu_LIBRARIES) \
-       $(LIBTERMCAP) $(LIBCRYPT) $(LIBAUTH)
+       $(LIBTERMCAP) $(LIBCRYPT) $(LIBAUTH) $(LIBIDN)
 
 bin_PROGRAMS = $(telnet_BUILD)
 
diff --git a/telnet/commands.c b/telnet/commands.c
index 7c409a9..8553771 100644
--- a/telnet/commands.c
+++ b/telnet/commands.c
@@ -74,6 +74,10 @@
 #include <arpa/inet.h>
 #include <arpa/telnet.h>
 
+#ifdef HAVE_IDNA_H
+# include <idna.h>
+#endif
+
 #include <unused-parameter.h>
 #include <libinetutils.h>
 
@@ -2446,7 +2450,7 @@ tn (int argc, char *argv[])
 #endif
   const int on = 1;
   int err;
-  char *cmd, *hostp = 0, *portp = 0, *user = 0;
+  char *cmd, *hostp = 0, *hosttmp = 0, *portp = 0, *user = 0;
 
 #ifdef IPV6
   memset (&hints, 0, sizeof (hints));
@@ -2589,8 +2593,22 @@ tn (int argc, char *argv[])
   }
 #endif /* AUTHENTICATION || ENCRYPTION */
 
+#ifdef HAVE_IDN
+  err = idna_to_ascii_lz (hostp, &hosttmp, 0);
+  if (err)
+    {
+      printf ("Server lookup failure:  %s:%s, %s\n",
+             hostp, portp, idna_strerror (err));
+      return 0;
+    }
+  hostp = hosttmp;
+#endif /* !HAVE_IDN */
+
 #ifdef IPV6
   hints.ai_socktype = SOCK_STREAM;
+# ifdef AI_IDN
+  hints.ai_flags = AI_IDN;
+# endif
 
   err = getaddrinfo (hostp, portp, &hints, &result);
   if (err)
@@ -2757,7 +2775,13 @@ tn (int argc, char *argv[])
     }
   while (connected == 0);
 #endif /* !IPV6 */
+
   cmdrc (hostp, hostname);
+#ifdef HAVE_IDN
+  /* Last use of HOSTP, alias HOSTTMP.  */
+  free (hosttmp);
+#endif
+
   if (autologin && user == NULL)
     {
       struct passwd *pw;
diff --git a/telnet/main.c b/telnet/main.c
index cda8edc..15b0c10 100644
--- a/telnet/main.c
+++ b/telnet/main.c
@@ -52,6 +52,9 @@
 #include <sys/types.h>
 
 #include <stdlib.h>
+#ifdef HAVE_LOCALE_H
+# include <locale.h>
+#endif
 
 #include "ring.h"
 #include "defines.h"
@@ -335,6 +338,10 @@ main (int argc, char *argv[])
 
   set_program_name (argv[0]);
 
+#ifdef HAVE_SETLOCALE
+  setlocale (LC_ALL, "");
+#endif
+
   tninit ();                   /* Clear out things */
 #if defined CRAY && !defined __STDC__
   _setlist_init ();            /* Work around compiler bug */

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog          |   68 +++++++++++++++++++++++
 NEWS               |    9 +++
 configure.ac       |    4 ++
 ftp/Makefile.am    |    4 +-
 ftp/ftp.c          |   29 +++++++++-
 ftp/main.c         |    7 +++
 ping/libping.c     |    4 +-
 ping/ping6.c       |    8 ++-
 src/Makefile.am    |    1 +
 src/tftp.c         |   36 ++++++++++++-
 talk/Makefile.am   |    4 +-
 talk/get_addrs.c   |  153 +++++++++++++++++++++++++++++++++++++++++++++++++---
 talk/talk.c        |    8 +++-
 telnet/Makefile.am |    4 +-
 telnet/commands.c  |   26 +++++++++-
 telnet/main.c      |    7 +++
 16 files changed, 350 insertions(+), 22 deletions(-)


hooks/post-receive
-- 
GNU Inetutils 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]