fetchmail-friends
[Top] [All Lists]

Re: [fetchmail]IPv6 DNS Problems

2005-07-10 19:44:13
Sebastian Wiesinger <fetchmail(_at_)tracker(_dot_)fire-world(_dot_)de> writes:

* Sebastian Wiesinger <fetchmail(_at_)tracker(_dot_)fire-world(_dot_)de> 
[2005-03-28 01:33]:
I attached my hotfix for this (which is poorly written, but works for
me) to this mail.

I made a new diff because I forgot to include the whole "else" tree
for IPv6. :(

It would be nice if someone could implement something (better) like
that.

Done. See 6.2.6-pre4, which uses the POSIX-standardized getaddrinfo()
rather than the less portable resolver. OTOH it assumes that you have
gethostbyname if you have getaddrinfo.

Please test either 6.2.6-pre4 from http://home.pages.de/~mandree/fetchmail/ 
or this patch (I don't even know if it applies - it was ripped from SVN
and edited to avoid obvious conflicts).

--- configure.ac~
+++ configure.ac
@@ -29,7 +29,7 @@
 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
--- driver.c~
+++ 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 @@
            }
            else
            {
+#ifdef INET6_ENABLE
+               struct addrinfo hints, *res;
+               int error;
+
+               memset(&hints, 0, sizeof(hints));
+               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 @@
                           namerec->h_addr_list[0],
                           namerec->h_length);
                }
+#endif
            }
        }
 #endif /* HAVE_GETHOSTBYNAME */


-- 
Matthias Andree


<Prev in Thread] Current Thread [Next in Thread>
  • Re: [fetchmail]IPv6 DNS Problems, Matthias Andree <=