]> Pileus Git - ~andy/fetchmail/commitdiff
Fix for IPv6.
authorEric S. Raymond <esr@thyrsus.com>
Fri, 3 Mar 2000 23:21:32 +0000 (23:21 -0000)
committerEric S. Raymond <esr@thyrsus.com>
Fri, 3 Mar 2000 23:21:32 +0000 (23:21 -0000)
svn path=/trunk/; revision=2780

NEWS
conf.c
configure.in
socket.c

diff --git a/NEWS b/NEWS
index bf8654086c158de651cddebf5abb25c08fa654b4..bcfdd4cf8aaa35f9bc7d58e873643a64596fdc7d 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -9,6 +9,7 @@
   a different host than the one fetchmail runs on, and on using
   ssh for a secure passwordless connection.  Removed the FAQ entry
   on popclient.
+* Jun-ichiro itojun Hagino <itojun@iijlab.net> sent a fix for IPv6.
 
 fetchmail-5.3.0 (Tue Feb 22 08:53:31 PST 2000), 18618 lines:
 
diff --git a/conf.c b/conf.c
index 19f290f0fb6f14022036d945e1abcaa08de9665f..1f1039e24ae0e0e26fb96e6f1e5625970683ac32 100644 (file)
--- a/conf.c
+++ b/conf.c
@@ -249,9 +249,10 @@ void dump_config(struct runctl *runp, struct query *querylist)
            stringdump("via", ctl->server.via); 
            stringdump("protocol", 
                       using_kpop ? "KPOP" : showproto(ctl->server.protocol));
+#ifndef INET6_ENABLE
            numdump("port",  ctl->server.port);
-#if INET6_ENABLE
-           stringdump("service", ctl->server.service);
+#else
+           stringdump("port",  ctl->server.service);
 #endif
            numdump("timeout",  ctl->server.timeout);
            numdump("interval", ctl->server.interval);
index c1a1aede40ea5d512d0d0f27de6a0703114d5761..6abadb607b81578e0d04ba94cee888643005501a 100644 (file)
@@ -501,13 +501,10 @@ fi])
 AC_ARG_WITH(hesiod,
        [  --with-hesiod=DIR       point fetchmail compilation at a HESIOD directory])
 
-if test -n "$with_hesiod"
-then
-    # Path given
-    CEFLAGS="$CEFLAGS -DHESIOD -I$with_hesiod/include"
-    LDEFLAGS="$LDEFLAGS -L$with_hesiod/lib"
-    LIBS="$LIBS -lhesiod"
-else
+case "x$with_hesiod" in
+xno)
+    ;;
+x)
     for dir in /usr/athena /usr /usr/local
     do
       if test -f "$dir/include/hesiod.h"
@@ -519,7 +516,14 @@ else
         break
       fi
     done
-  fi
+    ;;
+*)
+    # Path given
+    CEFLAGS="$CEFLAGS -DHESIOD -I$with_hesiod/include"
+    LDEFLAGS="$LDEFLAGS -L$with_hesiod/lib"
+    LIBS="$LIBS -lhesiod"
+    ;;
+  esac
 fi
 
 ###    use option --with-gssapi=DIR to compile in GSSAPI support
index 3040a5fe29666d9394cf6b913a4dc6b3b92a6cd2..3d019e758d536e8e747e4dd994fa29ce93f20acf 100644 (file)
--- a/socket.c
+++ b/socket.c
@@ -121,7 +121,7 @@ int SockCheckOpen(int fd)
 int SockOpen(const char *host, const char *service, const char *options,
             const char *plugin)
 {
-    struct addrinfo *ai, req;
+    struct addrinfo *ai, *ai0, req;
     int i;
 #if NET_SECURITY
     void *request = NULL;
@@ -135,10 +135,10 @@ int SockOpen(const char *host, const char *service, const char *options,
     memset(&req, 0, sizeof(struct addrinfo));
     req.ai_socktype = SOCK_STREAM;
 
-    if (getaddrinfo(host, service, &req, &ai)) {
+    if (getaddrinfo(host, service, &req, &ai0)) {
        report(stderr, _("fetchmail: getaddrinfo(%s.%s)\n"), host,service);
        return -1;
-    };
+    }
 
 #if NET_SECURITY
     if (!options)
@@ -147,32 +147,36 @@ int SockOpen(const char *host, const char *service, const char *options,
        if (net_security_strtorequest((char *)options, &request, &requestlen))
            goto ret;
 
-    i = inner_connect(ai, request, requestlen, NULL, NULL, "fetchmail", NULL);
+    i = inner_connect(ai0, request, requestlen, NULL, NULL, "fetchmail", NULL);
     if (request)
        free(request);
 
  ret:
 #else /* NET_SECURITY */
 #ifdef HAVE_INNER_CONNECT
-    i = inner_connect(ai, NULL, 0, NULL, NULL, "fetchmail", NULL);
+    i = inner_connect(ai0, NULL, 0, NULL, NULL, "fetchmail", NULL);
+    if (i >= 0)
+       break;
 #else
-    i = socket(ai->ai_family, ai->ai_socktype, 0);
-    if (i < 0) {
-       freeaddrinfo(ai);
-       return -1;
-    }
-    if (connect(i, (struct sockaddr *) ai->ai_addr, ai->ai_addrlen) < 0) {
-       freeaddrinfo(ai);
-       close(i);       /* don't use SockClose, no traffic yet */
-       return -1;
+    i = -1;
+    for (ai = ai0; ai; ai = ai->ai_next) {
+       i = socket(ai->ai_family, ai->ai_socktype, 0);
+       if (i < 0)
+           continue;
+       if (connect(i, (struct sockaddr *) ai->ai_addr, ai->ai_addrlen) < 0) {
+           close(i);
+           i = -1;
+           continue;
+       }
+       break;
     }
 #endif
 #endif /* NET_SECURITY */
 
-    freeaddrinfo(ai);
+    freeaddrinfo(ai0);
 
     return i;
-};
+}
 #else /* INET6_ENABLE */
 #ifndef HAVE_INET_ATON
 #ifndef  INADDR_NONE