From: Marco van Wieringen Date: Tue, 3 Jul 2012 14:11:12 +0000 (+0200) Subject: Reset bsmtp to only send to IPv4 mailhosts. X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=a18404f0b6cfe448ed4b0fec4cda47ab40d5e83b;p=bacula%2Fbacula Reset bsmtp to only send to IPv4 mailhosts. As part of the support for getaddrinfo which replaces the obsolete gethostbyname interface in POSIX we can now connect to IPv6 mailhosts. As it seems on a lot of hosts localhost is defined first as IPv6 address and then as IPv4 address. As a result of this bsmtp tries to connect to a local mailhost using the ipv6 protocol but most people forget to allow relay rights for IPv6 local SMTP traffic and as such the mail is dropped. So for now we revert the behaviour of bsmtp to only connect to IPv4 mailhosts unless the -a option is given which will query the name service for any suitable protocol. --- diff --git a/bacula/src/tools/bsmtp.c b/bacula/src/tools/bsmtp.c index c8f90768c4..5ec0727859 100644 --- a/bacula/src/tools/bsmtp.c +++ b/bacula/src/tools/bsmtp.c @@ -97,6 +97,7 @@ static char *reply_addr = NULL; static int mailport = 25; static char my_hostname[MAXSTRING]; static bool content_utf8 = false; +static bool any_protocol = false; /* * Take input that may have names and other stuff and strip @@ -186,6 +187,7 @@ static void usage() _("\n" "Usage: %s [-f from] [-h mailhost] [-s subject] [-c copy] [recipient ...]\n" " -8 set charset to UTF-8\n" +" -a use any ip protocol to connect" " -c set the Cc: field\n" " -d set debug level to \n" " -dt print a timestamp in debug output\n" @@ -290,6 +292,10 @@ int main (int argc, char *argv[]) case '8': content_utf8 = true; break; + case 'a': + any_protocol = true; + break; + case 'c': Dmsg1(20, "cc=%s\n", optarg); cc_addr = optarg; @@ -430,7 +436,7 @@ int main (int argc, char *argv[]) lookup_host: #ifdef HAVE_GETADDRINFO memset(&hints, 0, sizeof(struct addrinfo)); - hints.ai_family = AF_UNSPEC; + hints.ai_family = (any_protocol) ? AF_UNSPEC : AF_INET; hints.ai_socktype = SOCK_STREAM; hints.ai_protocol = IPPROTO_TCP; hints.ai_flags = 0;