Package: nullmailer Version: 1:1.00-2 Severity: wishlist Tags: patch Hi,
There is no support for IPv6 support in nullmailer, which is a shame and so I rolled out the attached patch. I actually sent this first to the upstream author but never received a reply :( Instead I thought I might aswell send it to the Debian maintainer :) I feel my patch is cleaner than the one recently posted on the nullmailer mailing list (beat me to the patch by two weeks :) http://lists.untroubled.org/?list=nullmailer&cmd=showmsg&msgnum=548 Which ever patch is chosen, one needs to go in...fight to the death? :) Cheers -- System Information: Debian Release: testing/unstable APT prefers unstable APT policy: (990, 'unstable') Architecture: i386 (i686) Shell: /bin/sh linked to /bin/bash Kernel: Linux 2.6.14-ck1 Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968) Versions of packages nullmailer depends on: ii debconf [debconf-2.0] 1.4.58 Debian configuration management sy ii libc6 2.3.5-7 GNU C Library: Shared libraries an ii libgcc1 1:4.0.2-3 GCC support library ii libstdc++6 4.0.2-3 The GNU Standard C++ Library v3 ii lsb-base 3.0-10 Linux Standard Base 3.0 init scrip ii ucf 2.003 Update Configuration File: preserv Versions of packages nullmailer recommends: ii sysklogd [system-log-daemon] 1.4.1-17 System Logging Daemon -- debconf information excluded
diff -u -r nullmailer-1.00.orig/configure.in nullmailer-1.00/configure.in --- nullmailer-1.00.orig/configure.in 2005-10-23 13:05:12.610696760 +0100 +++ nullmailer-1.00/configure.in 2005-10-23 13:05:18.755762568 +0100 @@ -47,6 +47,24 @@ dnl AC_CHECK_FUNCS(gettimeofday mkdir putenv rmdir socket) AC_CHECK_FUNCS(setenv srandom) +AC_MSG_CHECKING(for getaddrinfo) +AC_TRY_COMPILE([#include <sys/types.h> +#include <sys/socket.h> +#include <netdb.h>], [getaddrinfo(NULL, NULL, NULL, NULL)], has_getaddrinfo=yes, has_getaddrinfo=no) +if test "$has_getaddrinfo" = yes; then + AC_MSG_RESULT(yes) +else + AC_MSG_RESULT(no) +fi + +if test x-$has_getaddrinfo = "x-no" ; then + AC_MSG_RESULT(disabled: getaddrinfo missing) +else + AC_DEFINE(HAVE_GETADDRINFO,,[getaddrinfo code enabled]) +fi + +AC_SUBST(HAVE_GETADDRINFO) + AC_DEFINE(BUFSIZE, 4096, [Generic buffer size]) AM_CONDITIONAL(FDBUF_NO_MYSTRING, false) diff -u -r nullmailer-1.00.orig/lib/tcpconnect.cc nullmailer-1.00/lib/tcpconnect.cc --- nullmailer-1.00.orig/lib/tcpconnect.cc 2005-10-23 13:05:12.595699040 +0100 +++ nullmailer-1.00/lib/tcpconnect.cc 2005-10-23 13:05:24.110948456 +0100 @@ -28,7 +28,11 @@ #include <netinet/in.h> #include "errcodes.h" #include "connect.h" +#ifdef HAVE_GETADDRINFO +#include "lib/itoa.h" +#endif +#ifndef HAVE_GETADDRINFO static int sethostbyname(const mystring& hostname, struct sockaddr_in& sa) { struct hostent *he = gethostbyname(hostname.c_str()); @@ -44,13 +48,46 @@ memcpy(&sa.sin_addr, he->h_addr, he->h_length); return 0; } +#endif int tcpconnect(const mystring& hostname, int port) { +#ifdef HAVE_GETADDRINFO + struct addrinfo req, *res, *orig_res; + const char *service = itoa(port, 6); + + memset(&req, 0, sizeof(req)); + req.ai_flags = AI_NUMERICSERV; + req.ai_socktype = SOCK_STREAM; + int e = getaddrinfo(hostname.c_str(), service, &req, &res); +#else struct sockaddr_in sa; memset(&sa, 0, sizeof(sa)); int e = sethostbyname(hostname, sa); +#endif if(e) return e; +#ifdef HAVE_GETADDRINFO + int s; + orig_res = res; + + for (; res; res = res->ai_next ) { + s = socket(res->ai_family, res->ai_socktype, res->ai_protocol); + + if(s < 0) + continue; + + if(connect(s, res->ai_addr, res->ai_addrlen) != 0) + continue; + + /* sucessful connection */ + break; + } + + freeaddrinfo(orig_res); + + if(s < 0) + return -ERR_CONN_FAILED; +#else sa.sin_family = AF_INET; sa.sin_port = htons(port); int s = socket(PF_INET, SOCK_STREAM, 0); @@ -64,5 +101,6 @@ default: return -ERR_CONN_FAILED; } } +#endif return s; }