149 lines
4.0 KiB
Diff
149 lines
4.0 KiB
Diff
|
--- manpages/bsmtp.1.old.old 2012-06-28 16:52:03.000000000 +0200
|
||
|
+++ manpages/bsmtp.1 2012-07-10 14:39:27.818315931 +0200
|
||
|
@@ -2,7 +2,7 @@
|
||
|
.\" First parameter, NAME, should be all caps
|
||
|
.\" Second parameter, SECTION, should be 1-8, maybe w/ subsection
|
||
|
.\" other parameters are allowed: see man(7), man(1)
|
||
|
-.TH BSMTP 1 "6 December 2009" "Kern Sibbald" "Network backup, recovery and verification"
|
||
|
+.TH BSMTP 1 "3 July 2012" "Kern Sibbald" "Network backup, recovery and verification"
|
||
|
.\" Please adjust this date whenever revising the manpage.
|
||
|
.\"
|
||
|
.SH NAME
|
||
|
@@ -23,9 +23,18 @@
|
||
|
|
||
|
.SH OPTIONS
|
||
|
.TP
|
||
|
+.B \-4
|
||
|
+Forces bsmtp to use IPv4 addresses only.
|
||
|
+.TP
|
||
|
+.B \-6
|
||
|
+Forces bsmtp to use IPv6 addresses only.
|
||
|
+.TP
|
||
|
.B \-8
|
||
|
Encode the mail in UTF-8.
|
||
|
.TP
|
||
|
+.B \-a
|
||
|
+Use any ip protocol for address resolution.
|
||
|
+.TP
|
||
|
.B \-c
|
||
|
Set the \fBCc:\fR header.
|
||
|
.TP
|
||
|
@@ -115,4 +124,4 @@
|
||
|
.nh
|
||
|
<lbc@members.fsf.org>.
|
||
|
.SH SEE ALSO
|
||
|
-.BR "bacula-dir" "(8) "
|
||
|
\ No newline at end of file
|
||
|
+.BR "bacula-dir" "(8) "
|
||
|
--- src/tools/bsmtp.c.old 2012-06-28 16:52:03.000000000 +0200
|
||
|
+++ src/tools/bsmtp.c 2012-07-10 14:39:27.967318985 +0200
|
||
|
@@ -85,6 +85,12 @@
|
||
|
#define MAXSTRING 254
|
||
|
#endif
|
||
|
|
||
|
+enum resolv_type {
|
||
|
+ RESOLV_PROTO_ANY,
|
||
|
+ RESOLV_PROTO_IPV4,
|
||
|
+ RESOLV_PROTO_IPV6
|
||
|
+};
|
||
|
+
|
||
|
static FILE *sfp;
|
||
|
static FILE *rfp;
|
||
|
|
||
|
@@ -97,6 +103,7 @@
|
||
|
static int mailport = 25;
|
||
|
static char my_hostname[MAXSTRING];
|
||
|
static bool content_utf8 = false;
|
||
|
+static resolv_type default_resolv_type = RESOLV_PROTO_IPV4;
|
||
|
|
||
|
/*
|
||
|
* Take input that may have names and other stuff and strip
|
||
|
@@ -185,7 +192,12 @@
|
||
|
fprintf(stderr,
|
||
|
_("\n"
|
||
|
"Usage: %s [-f from] [-h mailhost] [-s subject] [-c copy] [recipient ...]\n"
|
||
|
+" -4 forces bsmtp to use IPv4 addresses only.\n"
|
||
|
+#ifdef HAVE_IPV6
|
||
|
+" -6 forces bsmtp to use IPv6 addresses only.\n"
|
||
|
+#endif
|
||
|
" -8 set charset to UTF-8\n"
|
||
|
+" -a use any ip protocol for address resolution\n"
|
||
|
" -c set the Cc: field\n"
|
||
|
" -d <nn> set debug level to <nn>\n"
|
||
|
" -dt print a timestamp in debug output\n"
|
||
|
@@ -277,6 +289,11 @@
|
||
|
struct hostent *hp;
|
||
|
struct sockaddr_in sin;
|
||
|
#endif
|
||
|
+#ifdef HAVE_IPV6
|
||
|
+ const char *options = "468ac:d:f:h:r:s:l:?";
|
||
|
+#else
|
||
|
+ const char *options = "48ac:d:f:h:r:s:l:?";
|
||
|
+#endif
|
||
|
|
||
|
setlocale(LC_ALL, "en_US");
|
||
|
bindtextdomain("bacula", LOCALEDIR);
|
||
|
@@ -285,11 +302,26 @@
|
||
|
my_name_is(argc, argv, "bsmtp");
|
||
|
maxlines = 0;
|
||
|
|
||
|
- while ((ch = getopt(argc, argv, "8c:d:f:h:r:s:l:?")) != -1) {
|
||
|
+ while ((ch = getopt(argc, argv, options)) != -1) {
|
||
|
switch (ch) {
|
||
|
+ case '4':
|
||
|
+ default_resolv_type = RESOLV_PROTO_IPV4;
|
||
|
+ break;
|
||
|
+
|
||
|
+#ifdef HAVE_IPV6
|
||
|
+ case '6':
|
||
|
+ default_resolv_type = RESOLV_PROTO_IPV6;
|
||
|
+ break;
|
||
|
+#endif
|
||
|
+
|
||
|
case '8':
|
||
|
content_utf8 = true;
|
||
|
break;
|
||
|
+
|
||
|
+ case 'a':
|
||
|
+ default_resolv_type = RESOLV_PROTO_ANY;
|
||
|
+ break;
|
||
|
+
|
||
|
case 'c':
|
||
|
Dmsg1(20, "cc=%s\n", optarg);
|
||
|
cc_addr = optarg;
|
||
|
@@ -430,16 +462,31 @@
|
||
|
lookup_host:
|
||
|
#ifdef HAVE_GETADDRINFO
|
||
|
memset(&hints, 0, sizeof(struct addrinfo));
|
||
|
- hints.ai_family = AF_UNSPEC;
|
||
|
+ switch (default_resolv_type) {
|
||
|
+ case RESOLV_PROTO_ANY:
|
||
|
+ hints.ai_family = AF_UNSPEC;
|
||
|
+ break;
|
||
|
+ case RESOLV_PROTO_IPV4:
|
||
|
+ hints.ai_family = AF_INET;
|
||
|
+ break;
|
||
|
+#ifdef HAVE_IPV6
|
||
|
+ case RESOLV_PROTO_IPV6:
|
||
|
+ hints.ai_family = AF_INET6;
|
||
|
+ break;
|
||
|
+#endif
|
||
|
+ default:
|
||
|
+ hints.ai_family = AF_UNSPEC;
|
||
|
+ break;
|
||
|
+ }
|
||
|
hints.ai_socktype = SOCK_STREAM;
|
||
|
- hints.ai_protocol = IPPROTO_TCP;
|
||
|
+ hints.ai_protocol = 0;
|
||
|
hints.ai_flags = 0;
|
||
|
snprintf(mail_port, sizeof(mail_port), "%d", mailport);
|
||
|
|
||
|
if ((res = getaddrinfo(mailhost, mail_port, &hints, &ai)) != 0) {
|
||
|
Pmsg2(0, _("Error unknown mail host \"%s\": ERR=%s\n"),
|
||
|
mailhost, gai_strerror(res));
|
||
|
- if (!strcasecmp(mailhost, "localhost")) {
|
||
|
+ if (strcasecmp(mailhost, "localhost")) {
|
||
|
Pmsg0(0, _("Retrying connection using \"localhost\".\n"));
|
||
|
mailhost = "localhost";
|
||
|
goto lookup_host;
|