]> Pileus Git - ~andy/fetchmail/commitdiff
Use getaddrinfo to canonicalize hostnames if INET6_ENABLE. Patch by Matthias Andree.
authorMatthias Andree <matthias.andree@gmx.de>
Sun, 3 Jul 2005 21:50:16 +0000 (21:50 -0000)
committerMatthias Andree <matthias.andree@gmx.de>
Sun, 3 Jul 2005 21:50:16 +0000 (21:50 -0000)
svn path=/trunk/; revision=4078

NEWS
configure.ac
driver.c

diff --git a/NEWS b/NEWS
index 1d8343a3e75244450679d1906cd4f0aa38b33054..749c4f27f88f7ed70377f08bf9eb647f03c75d16 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -93,6 +93,8 @@ fetchmail 6.3.0 (not yet released officially):
   (Matthias Andree).
 * Internationalization (i18n) updates by Miloslav Trmac. (Matthias
   Andree)
+* Matthias Andree's fix for "couldn't find canonical DNS name of NN
+  (MM)" for hosts that have only IPv6 addresses.
 
 fetchmail-6.2.5 (Wed Oct 15 18:39:22 EDT 2003), 23079 lines:
 
index 06110c4e02ac5f0f7875c49066264446cda57c59..500c8d1eaf4a5a601483d425bdaa41b9d1003775 100644 (file)
@@ -4,7 +4,7 @@ dnl
 dnl Process this file with autoconf to produce a configure script.
 dnl
 
-AC_INIT([fetchmail],[6.2.6])
+AC_INIT([fetchmail],[6.2.6.alpha2])
 AC_CONFIG_SRCDIR([fetchmail.h])
 AC_CONFIG_HEADERS([config.h])
 AC_CONFIG_LIBOBJ_DIR([.])
@@ -29,7 +29,7 @@ AC_TYPE_SIGNAL
 AC_CHECK_HEADERS([unistd.h termios.h termio.h sgtty.h stdarg.h \
        alloca.h sys/itimer.h fcntl.h sys/fcntl.h memory.h sys/wait.h \
        arpa/inet.h arpa/nameser.h netinet/in.h net/socket.h \
-       sys/select.h sys/time.h langinfo.h])
+       sys/select.h sys/socket.h sys/time.h langinfo.h])
 AC_CHECK_HEADERS([resolv.h],,,[
 #include <sys/types.h>
 #ifdef HAVE_NETINET_IN_H
@@ -345,8 +345,13 @@ AC_ARG_ENABLE(opie,
        [with_opie=no])
 test "$with_opie" = "yes" && AC_DEFINE(OPIE_ENABLE,1,Define if you want OPIE support compiled in)
 
+### XXX FIXME: the inet6-apps library is no longer available,
+### http://www.inner.net/pub/ipv6/ states, as of 2005-07-03:
+### "/pub/ipv6
+### Our IPv6 software is now long defunct. Please find a more modern
+### source."
 AC_ARG_ENABLE(inet6,
-       [  --enable-inet6          support IPv6 (requires the inet6-apps library)],
+       [  --enable-inet6          support IPv6],
 
        [ AC_CHECK_FUNC(getaddrinfo, [with_inet6=yes],
          [ LDFLAGS="$LDFLAGS -L/usr/inet6/lib";
index f507b135c8e84a32fa67764c76a9fd5e10ca731f..0bdd0371e6dd59d838d4a78361d34f892e0817fb 100644 (file)
--- a/driver.c
+++ b/driver.c
@@ -28,6 +28,9 @@
 #include <sys/wait.h>
 #endif
 
+#ifdef HAVE_SYS_SOCKET_H
+#include <sys/socket.h>
+#endif
 #ifdef HAVE_NET_SOCKET_H
 #include <net/socket.h>
 #endif
@@ -1005,8 +1008,35 @@ static int do_session(
            }
            else
            {
+#ifdef INET6_ENABLE
+               struct addrinfo hints, *res;
+               int error;
+
+               memset(&hints, sizeof(hints), 0);
+               hints.ai_socktype = SOCK_STREAM;
+               hints.ai_family = AF_UNSPEC;
+               hints.ai_flags = AI_CANONNAME;
+
+               error = getaddrinfo(ctl->server.queryname, NULL, &hints, &res);
+               if (error)
+               {
+                   report(stderr,
+                          GT_("couldn't find canonical DNS name of %s (%s)\n"),
+                          ctl->server.pollname, ctl->server.queryname);
+                   err = PS_DNS;
+                   set_timeout(0);
+                   phase = oldphase;
+                   goto closeUp;
+               }
+               else
+               {
+                   ctl->server.truename=xstrdup(res->ai_canonname);
+                   ctl->server.trueaddr=xmalloc(res->ai_addrlen);
+                   memcpy(ctl->server.trueaddr, res->ai_addr, res->ai_addrlen);
+               }
+#else
                struct hostent  *namerec;
-                   
                /* 
                 * Get the host's IP, so we can report it like this:
                 *
@@ -1032,6 +1062,7 @@ static int do_session(
                           namerec->h_addr_list[0],
                           namerec->h_length);
                }
+#endif
            }
        }
 #endif /* HAVE_GETHOSTBYNAME */