Hi,

I've run into an issue with the IPv6 support in postfix when it is
set up to deliver to a literal IPv6 address in the transport table.
It looks like 'smtpd' will only accept IPv6 address literals in RFC
2821 format while 'smtp' will only accept IPv6 address literals in
the unadorned form (without the ipv6: prefix).

The (minimalist) patch below my sig appears to fix the issue, but
I suspect a better fix would be to refactor the various places in
the code that handle address literals to rationalize things a bit more.


Sarathy
[email protected]
-----------------------------------8<-----------------------------------
Index: postfix-2.8.1-RC1/src/global/valid_mailhost_addr.c
--- postfix-2.8.1-RC1/src/global/valid_mailhost_addr.c.~1~      Wed Feb 23 
17:33:00 2011
+++ postfix-2.8.1-RC1/src/global/valid_mailhost_addr.c  Wed Feb 23 17:33:00 2011
@@ -68,12 +68,6 @@
 
 #include <valid_mailhost_addr.h>
 
-/* Application-specific. */
-
-#define IPV6_COL_LEN       (sizeof(IPV6_COL) - 1)
-#define HAS_IPV6_COL(str)  (strncasecmp((str), IPV6_COL, IPV6_COL_LEN) == 0)
-#define SKIP_IPV6_COL(str) (HAS_IPV6_COL(str) ? (str) + IPV6_COL_LEN : (str))
-
 /* valid_mailhost_addr - validate RFC 2821 numerical address form */
 
 const char *valid_mailhost_addr(const char *addr, int gripe)
Index: postfix-2.8.1-RC1/src/global/valid_mailhost_addr.h
--- postfix-2.8.1-RC1/src/global/valid_mailhost_addr.h.~1~      Wed Feb 23 
17:33:00 2011
+++ postfix-2.8.1-RC1/src/global/valid_mailhost_addr.h  Wed Feb 23 17:33:00 2011
@@ -15,11 +15,7 @@
   * Utility library.
   */
 #include <valid_hostname.h>
-
- /*
-  * External interface
-  */
-#define IPV6_COL               "IPv6:" /* RFC 2821 */
+#include <host_port.h>
 
 extern const char *valid_mailhost_addr(const char *, int);
 extern int valid_mailhost_literal(const char *, int);
Index: postfix-2.8.1-RC1/src/util/host_port.c
--- postfix-2.8.1-RC1/src/util/host_port.c.~1~  Wed Feb 23 17:33:00 2011
+++ postfix-2.8.1-RC1/src/util/host_port.c      Wed Feb 23 17:33:00 2011
@@ -22,6 +22,8 @@
 /*
 /*     When def_service is not null, and def_host is null:
 /*
+/*             [IPv6:host]:port, [IPv6:host]:, [IPV6:host]
+/*
 /*             [host]:port, [host]:, [host]
 /*
 /*             host:port, host:, host
@@ -106,7 +108,9 @@
      * [host]:port, [host]:, [host].
      */
     if (*cp == '[') {
-       *host = ++cp;
+       ++cp;
+       /* skip past RFC2821 IPv6: prefix, if any */
+       *host = cp = SKIP_IPV6_COL(cp);
        if ((cp = split_at(cp, ']')) == 0)
            return ("missing \"]\"");
        if (*cp && *cp++ != ':')
Index: postfix-2.8.1-RC1/src/util/host_port.h
--- postfix-2.8.1-RC1/src/util/host_port.h.~1~  Wed Feb 23 17:33:00 2011
+++ postfix-2.8.1-RC1/src/util/host_port.h      Wed Feb 23 17:33:00 2011
@@ -12,6 +12,10 @@
 /* .nf
 
  /* External interface. */
+#define IPV6_COL               "IPv6:" /* RFC 2821 */
+#define IPV6_COL_LEN       (sizeof(IPV6_COL) - 1)
+#define HAS_IPV6_COL(str)  (strncasecmp((str), IPV6_COL, IPV6_COL_LEN) == 0)
+#define SKIP_IPV6_COL(str) (HAS_IPV6_COL(str) ? (str) + IPV6_COL_LEN : (str))
 
 extern const char *host_port(char *, char **, char *, char **, char *);
 
End of Patch.

Reply via email to