-diff -urN snapshot-20011114.orig/makedefs snapshot-20011114/makedefs
---- snapshot-20011114.orig/makedefs Sun Nov 4 16:03:32 2001
-+++ snapshot-20011114/makedefs Thu Nov 15 11:26:21 2001
+diff -durN -x '*~' -x '*.orig' postfix-2.0.16.orig/makedefs postfix-2.0.16/makedefs
+--- postfix-2.0.16.orig/makedefs 2003-01-23 14:45:02.000000000 +0100
++++ postfix-2.0.16/makedefs 2005-01-07 18:25:30.197331464 +0100
@@ -52,6 +52,21 @@
SYSTEM=`(uname -s) 2>/dev/null`
RELEASE=`(uname -r) 2>/dev/null`
case "$VERSION" in
dcosx*) SYSTEM=$VERSION;;
-@@ -284,6 +299,26 @@
+@@ -318,6 +333,26 @@
: ${CC='gcc $(WARN)'} ${OPT='-O'} ${DEBUG='-g'} ${AWK=awk}
+ ;;
+linux)
+ CCARGS="$CCARGS -DINET6 -D__ss_family=ss_family"
-+ if test -f /usr/include/libinet6/netinet/ip6.h -a \
-+ -f /usr/lib/libinet6.a; then
++ if test -f /usr/include/libinet6/netinet/ip6.h
++ then
+ CCARGS="$CCARGS -I/usr/include/libinet6 -DUSAGI_LIBINET6"
+ SYSLIBS="$SYSLIBS -linet6"
+ fi
export SYSTYPE AR ARFL RANLIB SYSLIBS CC OPT DEBUG AWK OPTS
sed 's/ / /g' <<EOF
-diff -urN snapshot-20011114.orig/src/dns/dns_lookup.c snapshot-20011114/src/dns/dns_lookup.c
---- snapshot-20011114.orig/src/dns/dns_lookup.c Sun Feb 4 19:16:20 2001
-+++ snapshot-20011114/src/dns/dns_lookup.c Thu Nov 15 11:26:21 2001
-@@ -132,6 +132,9 @@
- } DNS_REPLY;
-
- #define INET_ADDR_LEN 4 /* XXX */
-+#ifdef INET6
-+#define INET6_ADDR_LEN 16
-+#endif
-
- /* dns_query - query name server and pre-parse the reply */
-
-@@ -337,6 +340,19 @@
- memcpy(temp, pos, fixed->length);
- data_len = fixed->length;
- break;
-+#ifdef INET6
-+ case T_AAAA:
-+ if (fixed->length != INET6_ADDR_LEN) {
-+ msg_warn("extract_answer: bad IPv6 address length: %d", fixed->length);
-+ return (0);
-+ }
-+ if (fixed->length > sizeof(temp))
-+ msg_panic("dns_get_rr: length %d > DNS_NAME_LEN",
-+ fixed->length);
-+ memcpy(temp, pos, fixed->length);
-+ data_len = fixed->length;
-+ break;
-+#endif
- case T_TXT:
- data_len = MIN2(pos[0] + 1, MIN2(fixed->length + 1, sizeof(temp)));
- for (src = pos + 1, dst = (unsigned char *) (temp);
-diff -urN snapshot-20011114.orig/src/global/Makefile.in snapshot-20011114/src/global/Makefile.in
---- snapshot-20011114.orig/src/global/Makefile.in Thu Nov 15 11:25:48 2001
-+++ snapshot-20011114/src/global/Makefile.in Thu Nov 15 11:30:12 2001
+diff -durN -x '*~' -x '*.orig' postfix-2.0.16.orig/src/global/Makefile.in postfix-2.0.16/src/global/Makefile.in
+--- postfix-2.0.16.orig/src/global/Makefile.in 2005-01-07 18:22:25.286442192 +0100
++++ postfix-2.0.16/src/global/Makefile.in 2005-01-07 18:25:30.198331312 +0100
@@ -19,7 +19,7 @@
timed_ipc.c tok822_find.c tok822_node.c tok822_parse.c \
tok822_resolve.c tok822_rewrite.c tok822_tree.c xtext.c bounce_log.c \
flush_clnt.c mail_conf_time.c mbox_conf.c mbox_open.c abounce.c \
-- verp_sender.c pfixtls.c
-+ verp_sender.c pfixtls.c wildcard_inet_addr.c
+- verp_sender.c match_parent_style.c mime_state.c header_token.c \
++ verp_sender.c match_parent_style.c mime_state.c header_token.c wildcard_inet_addr.c\
+ strip_addr.c virtual8_maps.c hold_message.c dict_proxy.c mail_dict.c \
+ pfixtls.c
OBJS = been_here.o bounce.o canon_addr.o cleanup_strerror.o clnt_stream.o \
- debug_peer.o debug_process.o defer.o deliver_completed.o \
- deliver_flock.o deliver_pass.o deliver_request.o domain_list.o \
-@@ -40,7 +40,7 @@
+@@ -42,7 +42,7 @@
timed_ipc.o tok822_find.o tok822_node.o tok822_parse.o \
tok822_resolve.o tok822_rewrite.o tok822_tree.o xtext.o bounce_log.o \
flush_clnt.o mail_conf_time.o mbox_conf.o mbox_open.o abounce.o \
-- verp_sender.o pfixtls.o
-+ verp_sender.o pfixtls.o wildcard_inet_addr.o
+- verp_sender.o match_parent_style.o mime_state.o header_token.o \
++ verp_sender.o match_parent_style.o mime_state.o header_token.o wildcard_inet_addr.o\
+ strip_addr.o virtual8_maps.o hold_message.o dict_proxy.o mail_dict.o \
+ pfixtls.o
HDRS = been_here.h bounce.h canon_addr.h cleanup_user.h clnt_stream.h \
- config.h debug_peer.h debug_process.h defer.h deliver_completed.h \
- deliver_flock.h deliver_pass.h deliver_request.h domain_list.h \
-@@ -56,7 +56,8 @@
- recipient_list.h record.h resolve_clnt.h resolve_local.h \
+@@ -61,7 +61,7 @@
rewrite_clnt.h sent.h smtp_stream.h split_addr.h string_list.h \
sys_exits.h timed_ipc.h tok822.h xtext.h bounce_log.h flush_clnt.h \
-- mbox_conf.h mbox_open.h abounce.h qmqp_proto.h verp_sender.h pfixtls.h
-+ mbox_conf.h mbox_open.h abounce.h qmqp_proto.h verp_sender.h \
-+ pfixtls.h wildcard_inet_addr.h
+ mbox_conf.h mbox_open.h abounce.h qmqp_proto.h verp_sender.h \
+- match_parent_style.h quote_flags.h mime_state.h header_token.h \
++ match_parent_style.h quote_flags.h mime_state.h header_token.h wildcard_inet_addr.h\
+ lex_822.h strip_addr.h virtual8_maps.h hold_message.h dict_proxy.h \
+ mail_dict.h pfixtls.h
TESTSRC = rec2stream.c stream2rec.c recdump.c
- WARN = -W -Wformat -Wimplicit -Wmissing-prototypes \
- -Wparentheses -Wstrict-prototypes -Wswitch -Wuninitialized \
-diff -urN snapshot-20011114.orig/src/global/mynetworks.c snapshot-20011114/src/global/mynetworks.c
---- snapshot-20011114.orig/src/global/mynetworks.c Sun Feb 25 02:46:07 2001
-+++ snapshot-20011114/src/global/mynetworks.c Thu Nov 15 11:26:21 2001
-@@ -50,6 +50,11 @@
+diff -durN -x '*~' -x '*.orig' postfix-2.0.16.orig/src/global/mynetworks.c postfix-2.0.16/src/global/mynetworks.c
+--- postfix-2.0.16.orig/src/global/mynetworks.c 2001-02-25 02:46:07.000000000 +0100
++++ postfix-2.0.16/src/global/mynetworks.c 2005-01-07 18:32:30.872379136 +0100
+@@ -50,6 +50,12 @@
#include <vstring.h>
#include <inet_addr_list.h>
#include <name_mask.h>
+#include <netinet/in.h>
+#include <netdb.h>
+#endif
++#include <string.h>
/* Global library. */
-@@ -75,6 +80,9 @@
+@@ -75,6 +81,9 @@
const char *mynetworks(void)
{
static VSTRING *result;
if (result == 0) {
char *myname = "mynetworks";
-@@ -87,6 +95,9 @@
+@@ -87,6 +96,13 @@
int junk;
int i;
int mask_style;
+#ifdef INET6
+ struct sockaddr *sa;
++ struct sockaddr_in6 *addr6;
++ struct sockaddr_in6 *mask6;
++ struct in6_addr net6;
++ int j;
+#endif
mask_style = name_mask("mynetworks mask style", mask_styles,
var_mynetworks_style);
-@@ -96,8 +107,18 @@
+@@ -96,8 +112,45 @@
my_mask_list = own_inet_mask_list();
for (i = 0; i < my_addr_list->used; i++) {
+#ifdef INET6
+ sa = (struct sockaddr *)&my_addr_list->addrs[i];
-+ if (sa->sa_family != AF_INET) {
-+ vstring_sprintf_append(result, "XAATODOmynetworks ");
++ if (sa->sa_family == AF_INET6) {
++ addr6 = (struct sockaddr_in6 *)sa;
++ mask6 = (struct sockaddr_in6 *)&my_mask_list->addrs[i];
++
++ switch (mask_style) {
++ case MASK_STYLE_CLASS:
++ /* treat as subnet for IPv6 */
++ case MASK_STYLE_SUBNET:
++ for (j=0; j<16; j++)
++ net6.s6_addr[j] = addr6->sin6_addr.s6_addr[j] & mask6->sin6_addr.s6_addr[j];
++ for(shift=128; shift>0; shift--)
++ if ((mask6->sin6_addr.s6_addr[(shift-1) / 8]) & (0x80 >> ((shift-1) % 8)))
++ break;
++ break;
++ case MASK_STYLE_HOST:
++ memcpy (&net6, &(addr6->sin6_addr), sizeof(net6));
++ shift=128;
++ break;
++ default:
++ msg_panic("unknown mynetworks mask style: %s",
++ var_mynetworks_style);
++ }
++ inet_ntop(AF_INET6, &net6, hbuf, sizeof(hbuf));
++ if (!shift)
++ msg_warn("%s: skipped network with zero mask: [%s/0]", myname, hbuf);
++ else
++ vstring_sprintf_append(result, "[%s/%d] ", hbuf, shift);
++ continue;
++ } else if (sa->sa_family != AF_INET) {
+ continue;
+ }
+ addr = ntohl(((struct sockaddr_in *)sa)->sin_addr.s_addr);
switch (mask_style) {
-@@ -119,8 +140,15 @@
+@@ -119,8 +172,15 @@
mask = IN_CLASSD_NET;
shift = IN_CLASSD_NSHIFT;
} else {
}
break;
-diff -urN snapshot-20011114.orig/src/global/own_inet_addr.c snapshot-20011114/src/global/own_inet_addr.c
---- snapshot-20011114.orig/src/global/own_inet_addr.c Tue Jul 31 20:38:29 2001
-+++ snapshot-20011114/src/global/own_inet_addr.c Thu Nov 15 11:26:21 2001
-@@ -39,6 +39,10 @@
+@@ -146,6 +206,18 @@
+ var_mynetworks_style);
+ }
+ net.s_addr = htonl(addr & mask);
++ if (shift == BITS_PER_ADDR) {
++#ifdef INET6
++ if (getnameinfo(sa, SA_LEN(sa), hbuf, sizeof(hbuf), NULL, 0,
++ NI_NUMERICHOST))
++ strncpy(hbuf, "???", sizeof(hbuf));
++ msg_warn("%s: skipped network with zero mask: %s/0", myname, hbuf);
++#else
++ msg_warn("%s: skipped network with zero mask: %s/0",
++ myname, inet_ntoa(my_addr_list->addrs[i]));
++#endif
++ continue;
++ }
+ vstring_sprintf_append(result, "%s/%d ",
+ inet_ntoa(net), BITS_PER_ADDR - shift);
+ }
+diff -durN -x '*~' -x '*.orig' postfix-2.0.16.orig/src/global/own_inet_addr.c postfix-2.0.16/src/global/own_inet_addr.c
+--- postfix-2.0.16.orig/src/global/own_inet_addr.c 2002-10-25 01:19:19.000000000 +0200
++++ postfix-2.0.16/src/global/own_inet_addr.c 2005-01-07 18:25:30.198331312 +0100
+@@ -50,6 +50,10 @@
#include <netinet/in.h>
#include <arpa/inet.h>
#include <string.h>
#ifdef STRCASECMP_IN_STRINGS_H
#include <strings.h>
-@@ -101,10 +105,11 @@
+@@ -113,10 +117,11 @@
*/
else {
bufp = hosts = mystrdup(var_inet_interfaces);
myfree(hosts);
/*
-@@ -121,15 +126,39 @@
+@@ -133,15 +138,39 @@
msg_fatal("could not find any active network interfaces");
for (nvirtual = 0; nvirtual < addr_list->used; nvirtual++) {
for (nlocal = 0; /* see below */ ; nlocal++) {
}
}
inet_addr_list_free(&local_addrs);
-@@ -139,6 +168,42 @@
+@@ -151,6 +180,42 @@
/* own_inet_addr - is this my own internet address */
int own_inet_addr(struct in_addr * addr)
{
int i;
-@@ -149,8 +214,8 @@
+@@ -161,8 +226,8 @@
for (i = 0; i < addr_list.used; i++)
if (addr->s_addr == addr_list.addrs[i].s_addr)
return (1);
/* own_inet_addr_list - return list of addresses */
-diff -urN snapshot-20011114.orig/src/global/own_inet_addr.h snapshot-20011114/src/global/own_inet_addr.h
---- snapshot-20011114.orig/src/global/own_inet_addr.h Sat Feb 24 02:25:32 2001
-+++ snapshot-20011114/src/global/own_inet_addr.h Thu Nov 15 11:26:21 2001
-@@ -15,11 +15,18 @@
+@@ -213,6 +278,45 @@
+
+ /* proxy_inet_addr - is this my proxy internet address */
+
++#ifdef INET6
++int proxy_inet_addr(struct sockaddr * addr)
++{
++ int i;
++ char *p, *q;
++ int l;
++ struct sockaddr *sa;
++
++ if (*var_proxy_interfaces == 0)
++ return (0);
++
++ if (proxy_list.used == 0)
++ proxy_inet_addr_init(&proxy_list);
++
++ for (i = 0; i < proxy_list.used; i++) {
++ sa = (struct sockaddr *)&proxy_list.addrs[i];
++ if (addr->sa_family != sa->sa_family)
++ continue;
++ switch (addr->sa_family) {
++ case AF_INET:
++ p = (char *)&((struct sockaddr_in *)addr)->sin_addr;
++ q = (char *)&((struct sockaddr_in *)&addr_list.addrs[i])->sin_addr;
++ l = sizeof(struct in_addr);
++ break;
++ case AF_INET6:
++ /* XXX scope */
++ p = (char *)&((struct sockaddr_in6 *)addr)->sin6_addr;
++ q = (char *)&((struct sockaddr_in6 *)&addr_list.addrs[i])->sin6_addr;
++ l = sizeof(struct in6_addr);
++ break;
++ default:
++ continue;
++ }
++ if (memcmp(p, q, l) == 0)
++ return (1);
++ }
++ return (0);
++}
++#else
+ int proxy_inet_addr(struct in_addr * addr)
+ {
+ int i;
+@@ -228,6 +332,7 @@
+ return (1);
+ return (0);
+ }
++#endif
+
+ /* proxy_inet_addr_list - return list of addresses */
+
+diff -durN -x '*~' -x '*.orig' postfix-2.0.16.orig/src/global/own_inet_addr.h postfix-2.0.16/src/global/own_inet_addr.h
+--- postfix-2.0.16.orig/src/global/own_inet_addr.h 2002-10-25 01:07:05.000000000 +0200
++++ postfix-2.0.16/src/global/own_inet_addr.h 2005-01-07 18:25:30.199331160 +0100
+@@ -15,14 +15,25 @@
* System library.
*/
#include <netinet/in.h>
+#endif
extern struct INET_ADDR_LIST *own_inet_addr_list(void);
extern struct INET_ADDR_LIST *own_inet_mask_list(void);
++#ifdef INET6
++extern int proxy_inet_addr(struct sockaddr *);
++#else
+ extern int proxy_inet_addr(struct in_addr *);
++#endif
+ extern struct INET_ADDR_LIST *proxy_inet_addr_list(void);
-diff -urN snapshot-20011114.orig/src/global/peer_name.c snapshot-20011114/src/global/peer_name.c
---- snapshot-20011114.orig/src/global/peer_name.c Sun Jan 28 16:23:02 2001
-+++ snapshot-20011114/src/global/peer_name.c Thu Nov 15 11:26:21 2001
+ /* LICENSE
+diff -durN -x '*~' -x '*.orig' postfix-2.0.16.orig/src/global/peer_name.c postfix-2.0.16/src/global/peer_name.c
+--- postfix-2.0.16.orig/src/global/peer_name.c 2001-01-28 16:23:02.000000000 +0100
++++ postfix-2.0.16/src/global/peer_name.c 2005-01-07 18:25:30.199331160 +0100
@@ -69,12 +69,32 @@
PEER_NAME *peer_name(int sock)
{
case AF_UNSPEC:
case AF_UNIX:
peer.type = PEER_TYPE_LOCAL;
-diff -urN snapshot-20011114.orig/src/global/peer_name.h snapshot-20011114/src/global/peer_name.h
---- snapshot-20011114.orig/src/global/peer_name.h Fri Dec 11 19:55:32 1998
-+++ snapshot-20011114/src/global/peer_name.h Thu Nov 15 11:26:21 2001
+diff -durN -x '*~' -x '*.orig' postfix-2.0.16.orig/src/global/peer_name.h postfix-2.0.16/src/global/peer_name.h
+--- postfix-2.0.16.orig/src/global/peer_name.h 1998-12-11 19:55:32.000000000 +0100
++++ postfix-2.0.16/src/global/peer_name.h 2005-01-07 18:25:30.199331160 +0100
@@ -22,6 +22,9 @@
#define PEER_TYPE_UNKNOWN 0
#define PEER_TYPE_INET 1
extern PEER_NAME *peer_name(int);
-diff -urN snapshot-20011114.orig/src/global/resolve_local.c snapshot-20011114/src/global/resolve_local.c
---- snapshot-20011114.orig/src/global/resolve_local.c Mon Apr 26 00:05:42 1999
-+++ snapshot-20011114/src/global/resolve_local.c Thu Nov 15 11:26:21 2001
-@@ -42,6 +42,7 @@
+diff -durN -x '*~' -x '*.orig' postfix-2.0.16.orig/src/global/resolve_local.c postfix-2.0.16/src/global/resolve_local.c
+--- postfix-2.0.16.orig/src/global/resolve_local.c 2002-10-25 01:21:20.000000000 +0200
++++ postfix-2.0.16/src/global/resolve_local.c 2005-01-07 18:25:30.199331160 +0100
+@@ -43,6 +43,7 @@
#include <netinet/in.h>
#include <arpa/inet.h>
#include <string.h>
#ifndef INADDR_NONE
#define INADDR_NONE 0xffffffff
-@@ -78,7 +79,12 @@
+@@ -80,7 +81,12 @@
{
char *saved_addr = mystrdup(addr);
char *dest;
int len;
#define RETURN(x) { myfree(saved_addr); return(x); }
-@@ -108,9 +114,25 @@
+@@ -118,9 +124,25 @@
if (*dest == '[' && dest[len - 1] == ']') {
dest++;
dest[len -= 2] = 0;
+ }
+#else
if ((ipaddr.s_addr = inet_addr(dest)) != INADDR_NONE
- && own_inet_addr(&ipaddr))
+ && (own_inet_addr(&ipaddr) || proxy_inet_addr(&ipaddr)))
RETURN(1);
+#endif
}
/*
-diff -urN snapshot-20011114.orig/src/global/wildcard_inet_addr.c snapshot-20011114/src/global/wildcard_inet_addr.c
---- snapshot-20011114.orig/src/global/wildcard_inet_addr.c Thu Jan 1 01:00:00 1970
-+++ snapshot-20011114/src/global/wildcard_inet_addr.c Thu Nov 15 11:26:21 2001
+diff -durN -x '*~' -x '*.orig' postfix-2.0.16.orig/src/global/wildcard_inet_addr.c postfix-2.0.16/src/global/wildcard_inet_addr.c
+--- postfix-2.0.16.orig/src/global/wildcard_inet_addr.c 1970-01-01 01:00:00.000000000 +0100
++++ postfix-2.0.16/src/global/wildcard_inet_addr.c 2005-01-07 18:25:30.200331008 +0100
@@ -0,0 +1,82 @@
+/* System library. */
+
+
+ return (&addr_list);
+}
-diff -urN snapshot-20011114.orig/src/global/wildcard_inet_addr.h snapshot-20011114/src/global/wildcard_inet_addr.h
---- snapshot-20011114.orig/src/global/wildcard_inet_addr.h Thu Jan 1 01:00:00 1970
-+++ snapshot-20011114/src/global/wildcard_inet_addr.h Thu Nov 15 11:26:21 2001
+diff -durN -x '*~' -x '*.orig' postfix-2.0.16.orig/src/global/wildcard_inet_addr.h postfix-2.0.16/src/global/wildcard_inet_addr.h
+--- postfix-2.0.16.orig/src/global/wildcard_inet_addr.h 1970-01-01 01:00:00.000000000 +0100
++++ postfix-2.0.16/src/global/wildcard_inet_addr.h 2005-01-07 18:25:30.200331008 +0100
@@ -0,0 +1,36 @@
+#ifndef _WILDCARD_INET_ADDR_H_INCLUDED_
+#define _WILDCARD_INET_ADDR_H_INCLUDED_
+/*--*/
+
+#endif
-diff -urN snapshot-20011114.orig/src/master/master_ent.c snapshot-20011114/src/master/master_ent.c
---- snapshot-20011114.orig/src/master/master_ent.c Tue May 1 00:45:54 2001
-+++ snapshot-20011114/src/master/master_ent.c Thu Nov 15 11:26:21 2001
-@@ -284,8 +284,13 @@
- inet_addr_host(MASTER_INET_ADDRLIST(serv), host);
+diff -durN -x '*~' -x '*.orig' postfix-2.0.16.orig/src/master/master_ent.c postfix-2.0.16/src/master/master_ent.c
+--- postfix-2.0.16.orig/src/master/master_ent.c 2003-06-18 21:19:46.000000000 +0200
++++ postfix-2.0.16/src/master/master_ent.c 2005-01-07 18:35:28.571364784 +0100
+@@ -92,6 +92,7 @@
+ #include <mail_proto.h>
+ #include <mail_params.h>
+ #include <own_inet_addr.h>
++#include <wildcard_inet_addr.h>
+
+ /* Local stuff. */
+
+@@ -307,8 +308,13 @@
+ inet_addr_list_uniq(MASTER_INET_ADDRLIST(serv));
serv->listen_fd_count = MASTER_INET_ADDRLIST(serv)->used;
- } else if (strcasecmp(var_inet_interfaces, DEF_INET_INTERFACES) == 0) {
+ } else if (strcasecmp(saved_interfaces, DEF_INET_INTERFACES) == 0) {
+#ifdef INET6
-+ MASTER_INET_ADDRLIST(serv) = wildcard_inet_addr_list();
-+ serv->listen_fd_count = MASTER_INET_ADDRLIST(serv)->used;
++ MASTER_INET_ADDRLIST(serv) = wildcard_inet_addr_list();
++ serv->listen_fd_count = MASTER_INET_ADDRLIST(serv)->used;
+#else
MASTER_INET_ADDRLIST(serv) = 0; /* wild-card */
serv->listen_fd_count = 1;
+#endif
} else {
MASTER_INET_ADDRLIST(serv) = own_inet_addr_list(); /* virtual */
- serv->listen_fd_count = MASTER_INET_ADDRLIST(serv)->used;
-diff -urN snapshot-20011114.orig/src/master/master_listen.c snapshot-20011114/src/master/master_listen.c
---- snapshot-20011114.orig/src/master/master_listen.c Tue May 1 00:47:57 2001
-+++ snapshot-20011114/src/master/master_listen.c Thu Nov 15 11:26:21 2001
+ inet_addr_list_uniq(MASTER_INET_ADDRLIST(serv));
+diff -durN -x '*~' -x '*.orig' postfix-2.0.16.orig/src/master/master_listen.c postfix-2.0.16/src/master/master_listen.c
+--- postfix-2.0.16.orig/src/master/master_listen.c 2001-05-01 00:47:57.000000000 +0200
++++ postfix-2.0.16/src/master/master_listen.c 2005-01-07 18:25:30.201330856 +0100
@@ -64,13 +64,22 @@
#include "master.h"
}
break;
default:
-diff -urN snapshot-20011114.orig/src/qmgr/qmgr_message.c snapshot-20011114/src/qmgr/qmgr_message.c
---- snapshot-20011114.orig/src/qmgr/qmgr_message.c Sat Jul 14 15:08:57 2001
-+++ snapshot-20011114/src/qmgr/qmgr_message.c Thu Nov 15 11:26:21 2001
-@@ -472,7 +472,11 @@
- * every front-ent program.
- */
- if ((at = strrchr(recipient->address, '@')) != 0
-+#ifdef INET6
-+ && (at + 1)[strspn(at + 1, "[]0123456789.:abcdef")] != 0
-+#else
- && (at + 1)[strspn(at + 1, "[]0123456789.")] != 0
-+#endif
- && valid_hostname(at + 1, DONT_GRIPE) == 0) {
- qmgr_bounce_recipient(message, recipient,
- "bad host/domain syntax: \"%s\"", at + 1);
-diff -urN snapshot-20011114.orig/src/smtp/Makefile.in snapshot-20011114/src/smtp/Makefile.in
---- snapshot-20011114.orig/src/smtp/Makefile.in Thu Nov 15 11:25:48 2001
-+++ snapshot-20011114/src/smtp/Makefile.in Thu Nov 15 11:26:21 2001
-@@ -140,6 +140,7 @@
+diff -durN -x '*~' -x '*.orig' postfix-2.0.16.orig/src/smtp/Makefile.in postfix-2.0.16/src/smtp/Makefile.in
+--- postfix-2.0.16.orig/src/smtp/Makefile.in 2005-01-07 18:22:25.253447208 +0100
++++ postfix-2.0.16/src/smtp/Makefile.in 2005-01-07 18:25:30.201330856 +0100
+@@ -144,6 +144,7 @@
smtp_connect.o: ../../include/mail_params.h
smtp_connect.o: ../../include/own_inet_addr.h
smtp_connect.o: ../../include/dns.h
smtp_connect.o: smtp.h
smtp_connect.o: ../../include/argv.h
smtp_connect.o: ../../include/deliver_request.h
-diff -urN snapshot-20011114.orig/src/smtp/smtp_addr.c snapshot-20011114/src/smtp/smtp_addr.c
---- snapshot-20011114.orig/src/smtp/smtp_addr.c Sun Jul 8 17:05:26 2001
-+++ snapshot-20011114/src/smtp/smtp_addr.c Thu Nov 15 11:26:21 2001
+diff -durN -x '*~' -x '*.orig' postfix-2.0.16.orig/src/smtp/smtp_addr.c postfix-2.0.16/src/smtp/smtp_addr.c
+--- postfix-2.0.16.orig/src/smtp/smtp_addr.c 2002-10-25 01:03:11.000000000 +0200
++++ postfix-2.0.16/src/smtp/smtp_addr.c 2005-01-07 18:25:30.201330856 +0100
@@ -134,18 +134,68 @@
static void smtp_print_addr(char *what, DNS_RR *addr_list)
{
}
/*
-diff -urN snapshot-20011114.orig/src/smtp/smtp_connect.c snapshot-20011114/src/smtp/smtp_connect.c
---- snapshot-20011114.orig/src/smtp/smtp_connect.c Thu Nov 15 11:25:48 2001
-+++ snapshot-20011114/src/smtp/smtp_connect.c Thu Nov 15 11:26:21 2001
+@@ -273,12 +400,36 @@
+ */
+ self = proxy_inet_addr_list();
+ for (addr = addr_list; addr; addr = addr->next) {
+- for (i = 0; i < self->used; i++)
++ for (i = 0; i < self->used; i++) {
++#ifdef INET6
++ sa = (struct sockaddr *)&self->addrs[i];
++ switch(addr->type) {
++ case T_AAAA:
++ /* XXX scope */
++ if (sa->sa_family != AF_INET6)
++ break;
++ if (memcmp(&((struct sockaddr_in6 *)sa)->sin6_addr,
++ addr->data, sizeof(struct in6_addr)) == 0) {
++ return(addr);
++ }
++ break;
++ case T_A:
++ if (sa->sa_family != AF_INET)
++ break;
++ if (memcmp(&((struct sockaddr_in *)sa)->sin_addr,
++ addr->data, sizeof(struct in_addr)) == 0) {
++ return(addr);
++ }
++ break;
++ }
++#else
+ if (INADDRP(addr->data)->s_addr == self->addrs[i].s_addr) {
+ if (msg_verbose)
+ msg_info("%s: found at pref %d", myname, addr->pref);
+ return (addr);
+ }
++#endif
++ }
+ }
+
+ /*
+diff -durN -x '*~' -x '*.orig' postfix-2.0.16.orig/src/smtp/smtp_connect.c postfix-2.0.16/src/smtp/smtp_connect.c
+--- postfix-2.0.16.orig/src/smtp/smtp_connect.c 2005-01-07 18:22:25.254447056 +0100
++++ postfix-2.0.16/src/smtp/smtp_connect.c 2005-01-07 18:25:30.202330704 +0100
@@ -81,6 +81,7 @@
/* System library. */
#include <timed_connect.h>
+#include <get_port.h>
#include <stringops.h>
-
- /* Global library. */
-@@ -133,19 +135,45 @@
+ #include <host_port.h>
+ #include <sane_connect.h>
+@@ -135,19 +137,45 @@
VSTRING *why)
{
char *myname = "smtp_connect_addr";
msg_warn("%s: skip address with length %d", myname, addr->data_len);
smtp_errno = SMTP_RETRY;
return (0);
-@@ -154,17 +182,39 @@
+@@ -156,17 +184,39 @@
/*
* Initialize.
*/
sin.sin_addr.s_addr = inet_addr(var_smtp_bind_addr);
if (sin.sin_addr.s_addr == INADDR_NONE)
msg_fatal("%s: bad %s parameter: %s",
-@@ -173,6 +223,25 @@
+@@ -175,6 +225,25 @@
msg_warn("%s: bind %s: %m", myname, inet_ntoa(sin.sin_addr));
if (msg_verbose)
msg_info("%s: bind %s", myname, inet_ntoa(sin.sin_addr));
}
/*
-@@ -180,8 +249,17 @@
+@@ -182,8 +251,17 @@
* the mail appears to come from the "right" machine address.
*/
else if ((addr_list = own_inet_addr_list())->used == 1) {
if (!IN_CLASSA(inaddr)
|| !(((inaddr & IN_CLASSA_NET) >> IN_CLASSA_NSHIFT) == IN_LOOPBACKNET)) {
if (bind(sock, (struct sockaddr *) & sin, sizeof(sin)) < 0)
-@@ -189,30 +267,85 @@
+@@ -191,30 +269,85 @@
if (msg_verbose)
msg_info("%s: bind %s", myname, inet_ntoa(sin.sin_addr));
}
+ !(res->ai_addrlen == loopback->ai_addrlen &&
+ memcmp(res->ai_addr, loopback->ai_addr, res->ai_addrlen) == 0)) {
+ if (bind(sock, res->ai_addr, res->ai_addrlen) < 0)
-+ msg_warn("%s: bind %s: %m", myname, hbufl);
++ msg_warn("%s: bind %s: %m", myname, hbufl);
+ if (msg_verbose)
-+ msg_info("%s: bind %s", myname, hbufl);
++ msg_info("%s: bind %s", myname, hbufl);
+ }
+ if (res)
+ freeaddrinfo(res);
+ switch (addr->type) {
+#ifdef INET6
+ case T_AAAA:
-+ /* XXX scope unfriendly */
-+ memset(sin6, 0, sizeof(*sin6));
-+ sin6->sin6_port = port;
-+ sin6->sin6_family = AF_INET6;
-+ salen = sizeof(*sin6);
-+ memcpy(&sin6->sin6_addr, addr->data, sizeof(sin6->sin6_addr));
-+ inet_ntop(AF_INET6, &sin6->sin6_addr, hbuf, sizeof(hbuf));
-+ break;
++ /* XXX scope unfriendly */
++ memset(sin6, 0, sizeof(*sin6));
++ sin6->sin6_port = port;
++ sin6->sin6_family = AF_INET6;
++ salen = sizeof(*sin6);
++ memcpy(&sin6->sin6_addr, addr->data, sizeof(sin6->sin6_addr));
++ inet_ntop(AF_INET6, &sin6->sin6_addr, hbuf, sizeof(hbuf));
++ break;
+#endif
+ default: /* T_A */
-+ memset(sin, 0, sizeof(*sin));
-+ sin->sin_port = port;
-+ sin->sin_family = AF_INET;
-+ salen = sizeof(*sin);
-+ memcpy(&sin->sin_addr, addr->data, sizeof(sin->sin_addr));
-+ inet_ntop(AF_INET, &sin->sin_addr, hbuf, sizeof(hbuf));
-+ break;
++ memset(sin, 0, sizeof(*sin));
++ sin->sin_port = port;
++ sin->sin_family = AF_INET;
++ salen = sizeof(*sin);
++ memcpy(&sin->sin_addr, addr->data, sizeof(sin->sin_addr));
++ inet_ntop(AF_INET, &sin->sin_addr, hbuf, sizeof(hbuf));
++ break;
+ }
+#ifdef HAS_SA_LEN
+ sa->sa_len = salen;
non_blocking(sock, BLOCKING);
errno = saved_errno;
} else {
-- conn_stat = connect(sock, (struct sockaddr *) & sin, sizeof(sin));
+- conn_stat = sane_connect(sock, (struct sockaddr *) & sin, sizeof(sin));
+ conn_stat = connect(sock, sa, salen);
}
if (conn_stat < 0) {
smtp_errno = SMTP_RETRY;
close(sock);
return (0);
-@@ -222,8 +355,8 @@
+@@ -224,8 +357,8 @@
* Skip this host if it takes no action within some time limit.
*/
if (read_wait(sock, var_smtp_helo_tmout) < 0) {
smtp_errno = SMTP_RETRY;
close(sock);
return (0);
-@@ -234,8 +367,8 @@
- */
+@@ -237,7 +370,7 @@
stream = vstream_fdopen(sock, O_RDWR);
if ((ch = VSTREAM_GETC(stream)) == VSTREAM_EOF) {
-- vstring_sprintf(why, "connect to %s[%s]: server dropped connection",
+ vstring_sprintf(why, "connect to %s[%s]: server dropped connection without sending the initial greeting",
- addr->name, inet_ntoa(sin.sin_addr));
-+ vstring_sprintf(why, "connect to %s [%s]: server dropped connection",
+ addr->name, hbuf);
smtp_errno = SMTP_RETRY;
vstream_fclose(stream);
return (0);
-@@ -247,7 +380,7 @@
+@@ -249,7 +382,7 @@
*/
if (ch == '4' && var_smtp_skip_4xx_greeting) {
vstring_sprintf(why, "connect to %s[%s]: server refused mail service",
smtp_errno = SMTP_RETRY;
vstream_fclose(stream);
return (0);
-@@ -258,12 +391,12 @@
+@@ -260,12 +393,12 @@
*/
if (ch == '5' && var_smtp_skip_5xx_greeting) {
vstring_sprintf(why, "connect to %s[%s]: server refused mail service",
}
/* smtp_connect_host - direct connection to host */
-@@ -273,7 +406,7 @@
- SMTP_SESSION *session = 0;
- DNS_RR *addr_list;
- DNS_RR *addr;
--
-+
- /*
- * Try each address in the specified order until we find one that works.
- * The addresses belong to the same A record, so we have no information
-@@ -380,6 +513,7 @@
- msg_fatal("unknown service: %s/%s", service, protocol);
- *portp = sp->s_port;
- }
-+
- return (buf);
- }
-
-diff -urN snapshot-20011114.orig/src/smtp/smtp_unalias.c snapshot-20011114/src/smtp/smtp_unalias.c
---- snapshot-20011114.orig/src/smtp/smtp_unalias.c Thu Sep 28 19:06:09 2000
-+++ snapshot-20011114/src/smtp/smtp_unalias.c Thu Nov 15 11:26:21 2001
+diff -durN -x '*~' -x '*.orig' postfix-2.0.16.orig/src/smtp/smtp_unalias.c postfix-2.0.16/src/smtp/smtp_unalias.c
+--- postfix-2.0.16.orig/src/smtp/smtp_unalias.c 2000-09-28 19:06:09.000000000 +0200
++++ postfix-2.0.16/src/smtp/smtp_unalias.c 2005-01-07 18:25:30.202330704 +0100
@@ -86,7 +86,11 @@
if ((result = htable_find(cache, name)) == 0) {
fqdn = vstring_alloc(10);
vstring_strcpy(fqdn, name);
htable_enter(cache, name, result = vstring_export(fqdn));
}
-diff -urN snapshot-20011114.orig/src/smtpd/smtpd_check.c snapshot-20011114/src/smtpd/smtpd_check.c
---- snapshot-20011114.orig/src/smtpd/smtpd_check.c Thu Nov 15 11:25:48 2001
-+++ snapshot-20011114/src/smtpd/smtpd_check.c Thu Nov 15 11:42:22 2001
-@@ -871,7 +871,11 @@
- msg_info("%s: %s", myname, name);
-
- dns_status = dns_lookup_types(name, 0, (DNS_RR **) 0, (VSTRING *) 0,
-- (VSTRING *) 0, T_A, T_MX, 0);
-+ (VSTRING *) 0, T_A, T_MX,
-+#ifdef INET6
-+ T_AAAA,
-+#endif
-+ 0);
- if (dns_status != DNS_OK)
- return (smtpd_check_reject(state, MAIL_ERROR_POLICY,
- "%d <%s>: %s odrzucony/rejected: Host not found",
-@@ -893,7 +897,11 @@
- msg_info("%s: %s", myname, name);
-
- dns_status = dns_lookup_types(name, 0, (DNS_RR **) 0, (VSTRING *) 0,
-- (VSTRING *) 0, T_A, T_MX, 0);
-+ (VSTRING *) 0, T_A, T_MX,
-+#ifdef INET6
-+ T_AAAA,
-+#endif
-+ 0);
- if (dns_status != DNS_OK)
- return (smtpd_check_reject(state, MAIL_ERROR_POLICY,
- "%d <%s>: %s odrzucony/rejected: Domain not found",
-@@ -1122,6 +1130,49 @@
-
- static int has_my_addr(const char *host)
+diff -durN -x '*~' -x '*.orig' postfix-2.0.16.orig/src/smtpd/smtpd_check.c postfix-2.0.16/src/smtpd/smtpd_check.c
+--- postfix-2.0.16.orig/src/smtpd/smtpd_check.c 2005-01-07 18:22:25.302439760 +0100
++++ postfix-2.0.16/src/smtpd/smtpd_check.c 2005-01-07 18:25:30.218328272 +0100
+@@ -1393,6 +1393,49 @@
+ static int has_my_addr(SMTPD_STATE *state, const char *host,
+ const char *reply_name, const char *reply_class)
{
+#ifdef INET6
+ char *myname = "has_my_addr";
char *myname = "has_my_addr";
struct in_addr addr;
char **cpp;
-@@ -1157,6 +1208,7 @@
+@@ -1431,6 +1474,7 @@
msg_info("%s: host %s: no match", myname, host);
return (NOPE);
}
/* i_am_mx - is this machine listed as MX relay */
-@@ -1759,11 +1811,16 @@
- int dns_status = DNS_FAIL;
+@@ -2015,11 +2059,28 @@
+ #define CHK_ADDR_RETURN(x,y) { *found = y; return(x); }
+
+ addr = STR(vstring_strcpy(error_text, address));
+-
++#ifdef INET6
++ if (strncmp(addr, "::ffff:", 7) == 0 && msg_verbose)
++ msg_info("%s: %s v6 addr in v4 compat-mode, "
++ "converted to v4 for map checking compatibility (%s)", \
++ myname, addr, addr+7);
++#endif
++
+ if ((dict = dict_handle(table)) == 0)
+ msg_panic("%s: dictionary not found: %s", myname, table);
+ do {
+ if (flags == 0 || (flags & dict->flags) != 0) {
++#ifdef INET6
++ if (strncmp(addr, "::ffff:", 7) == 0) {
++ /* try if ::ffff: formati is present in map, if not, try
++ traditional IPv4 format striping :ffff: part */
++ if ((value = dict_get(dict, addr)) != 0 || \
++ (value = dict_get(dict, addr+7)) != 0)
++ CHK_ADDR_RETURN(check_table_result(state, table, value, address,
++ reply_name, reply_class,
++ def_acl), FOUND);
++ } else
++#endif
+ if ((value = dict_get(dict, addr)) != 0)
+ CHK_ADDR_RETURN(check_table_result(state, table, value, address,
+ reply_name, reply_class,
+@@ -2579,16 +2640,32 @@
+ VSTRING *query;
int i;
- int result;
-+ struct in_addr a;
- VSTRING *why;
+ SMTPD_RBL_STATE *rbl;
++#ifdef INET6
++ struct in_addr a;
++#else
++ struct in6_addr a;
++#endif
if (msg_verbose)
- msg_info("%s: %s", myname, state->addr);
+ msg_info("%s: %s %s", myname, reply_class, addr);
+- /*
+- * IPv4 only for now
+- */
+-#ifdef INET6
++#ifndef INET6
+ /* IPv4 only for now */
-+ if (inet_pton(AF_INET, state->addr, &a) != 1)
-+ return SMTPD_CHECK_DUNNO;
-+
+ if (inet_pton(AF_INET, addr, &a) != 1)
+ return SMTPD_CHECK_DUNNO;
++ octets = argv_split(state->addr, ".");
++#else
++ /* IPv4 and IPv6-mapped IPv4 only for now */
++ if (inet_pton(AF_INET, state->addr, &a) == 1)
++ octets = argv_split(state->addr, ".");
++ else {
++ struct in6_addr a6;
++ if (inet_pton(AF_INET6, state->addr, &a6) != 1)
++ return SMTPD_CHECK_DUNNO;
++ if (!IN6_IS_ADDR_V4MAPPED(&a6) || (strrchr(state->addr,':') == NULL))
++ return SMTPD_CHECK_DUNNO;
++ octets = argv_split(strrchr(state->addr,':')+1, ".");
++ }
+ #endif
+
/*
- * IPv4 only for now
- */
-diff -urN snapshot-20011114.orig/src/smtpd/smtpd_peer.c snapshot-20011114/src/smtpd/smtpd_peer.c
---- snapshot-20011114.orig/src/smtpd/smtpd_peer.c Thu Jul 5 22:09:47 2001
-+++ snapshot-20011114/src/smtpd/smtpd_peer.c Thu Nov 15 11:26:21 2001
+diff -durN -x '*~' -x '*.orig' postfix-2.0.16.orig/src/smtpd/smtpd_peer.c postfix-2.0.16/src/smtpd/smtpd_peer.c
+--- postfix-2.0.16.orig/src/smtpd/smtpd_peer.c 2002-08-22 19:50:51.000000000 +0200
++++ postfix-2.0.16/src/smtpd/smtpd_peer.c 2005-01-07 18:25:30.205330248 +0100
@@ -63,6 +63,15 @@
#include <netdb.h>
#include <string.h>
/* Application-specific. */
#include "smtpd.h"
-@@ -102,16 +106,23 @@
+@@ -102,21 +106,28 @@
void smtpd_peer_init(SMTPD_STATE *state)
{
+ sa = (struct sockaddr *)&ss;
+ len = sizeof(ss);
+ /*
+ * Avoid suprious complaints from Purify on Solaris.
+ */
+- memset((char *) &sin, 0, len);
++ memset((char *) sa, 0, len);
+
/*
* Look up the peer address information.
*/
errno = 0;
}
-@@ -127,18 +138,51 @@
+@@ -132,23 +143,56 @@
/*
* Look up and "verify" the client hostname.
*/
+ state->peer_code = (error == EAI_AGAIN ? 4 : 5);
+#else
state->peer_code = (h_errno == TRY_AGAIN ? 4 : 5);
-- } else if (!valid_hostname(hp->h_name, DONT_GRIPE)) {
+- } else if (valid_hostaddr(hp->h_name, DONT_GRIPE)) {
+#endif
++ } else if (valid_hostaddr(hbuf, DONT_GRIPE)) {
+ msg_warn("numeric result %s in address->name lookup for %s",
+- hp->h_name, state->addr);
++ hbuf, state->addr);
+ state->name = mystrdup("unknown");
+ state->peer_code = 5;
+- } else if (!valid_hostname(hp->h_name, DONT_GRIPE)) {
+ } else if (!valid_hostname(hbuf, DONT_GRIPE)) {
state->name = mystrdup("unknown");
state->peer_code = 5;
state->peer_code = 2;
/*
-@@ -150,16 +194,31 @@
+@@ -160,16 +204,31 @@
state->peer_code = code; \
}
for (i = 0; /* void */ ; i++) {
if (hp->h_addr_list[i] == 0) {
msg_warn("%s: address not listed for hostname %s",
-@@ -167,12 +226,11 @@
+@@ -177,12 +236,11 @@
REJECT_PEER_NAME(state, 5);
break;
}
}
}
-diff -urN snapshot-20011114.orig/src/smtpstone/smtp-sink.c snapshot-20011114/src/smtpstone/smtp-sink.c
---- snapshot-20011114.orig/src/smtpstone/smtp-sink.c Sun Nov 4 15:21:34 2001
-+++ snapshot-20011114/src/smtpstone/smtp-sink.c Thu Nov 15 11:26:21 2001
-@@ -508,7 +508,7 @@
+diff -durN -x '*~' -x '*.orig' postfix-2.0.16.orig/src/smtpstone/smtp-sink.c postfix-2.0.16/src/smtpstone/smtp-sink.c
+--- postfix-2.0.16.orig/src/smtpstone/smtp-sink.c 2003-09-13 02:46:56.000000000 +0200
++++ postfix-2.0.16/src/smtpstone/smtp-sink.c 2005-01-07 18:25:30.205330248 +0100
+@@ -607,7 +607,7 @@
} else {
if (strncmp(argv[optind], "inet:", 5) == 0)
argv[optind] += 5;
}
/*
-Binary files snapshot-20011114.orig/src/util/.inet_addr_list.h.rej.swp and snapshot-20011114/src/util/.inet_addr_list.h.rej.swp differ
-diff -urN snapshot-20011114.orig/src/util/Makefile.in snapshot-20011114/src/util/Makefile.in
---- snapshot-20011114.orig/src/util/Makefile.in Thu Nov 15 11:25:48 2001
-+++ snapshot-20011114/src/util/Makefile.in Thu Nov 15 11:26:21 2001
-@@ -5,6 +5,7 @@
- dict_nisplus.c dict_open.c dir_forest.c doze.c environ.c \
- events.c exec_command.c fifo_listen.c fifo_trigger.c file_limit.c \
- find_inet.c fsspace.c fullname.c get_domainname.c get_hostname.c \
-+ get_port.c \
- htable.c inet_addr_host.c inet_addr_list.c inet_addr_local.c \
- inet_connect.c inet_listen.c inet_trigger.c inet_util.c \
- line_wrap.c lowercase.c lstat_as.c mac_parse.c make_dirs.c \
-@@ -31,6 +32,7 @@
- dict_nisplus.o dict_open.o dir_forest.o doze.o environ.o \
- events.o exec_command.o fifo_listen.o fifo_trigger.o file_limit.o \
- find_inet.o fsspace.o fullname.o get_domainname.o get_hostname.o \
-+ get_port.o \
- htable.o inet_addr_host.o inet_addr_list.o inet_addr_local.o \
- inet_connect.o inet_listen.o inet_trigger.o inet_util.o \
- line_wrap.o lowercase.o lstat_as.o mac_parse.o make_dirs.o \
-@@ -55,6 +57,7 @@
- dict_dbm.h dict_env.h dict_ht.h dict_ldap.h dict_mysql.h \
- dict_ni.h dict_nis.h dict_nisplus.h dir_forest.h events.h \
- exec_command.h find_inet.h fsspace.h fullname.h get_domainname.h \
-+ get_port.h \
- get_hostname.h htable.h inet_addr_host.h inet_addr_list.h \
- inet_addr_local.h inet_util.h iostuff.h line_wrap.h listen.h lstat_as.h \
- mac_parse.h make_dirs.h match_list.h match_ops.h msg.h msg_output.h \
-@@ -667,6 +670,7 @@
+diff -durN -x '*~' -x '*.orig' postfix-2.0.16.orig/src/util/Makefile.in postfix-2.0.16/src/util/Makefile.in
+--- postfix-2.0.16.orig/src/util/Makefile.in 2005-01-07 18:22:25.293441128 +0100
++++ postfix-2.0.16/src/util/Makefile.in 2005-01-07 18:25:30.209329640 +0100
+@@ -8,7 +8,7 @@
+ dict_tcp.c dict_unix.c dir_forest.c doze.c duplex_pipe.c \
+ environ.c events.c exec_command.c fifo_listen.c fifo_trigger.c \
+ file_limit.c find_inet.c fsspace.c fullname.c get_domainname.c \
+- get_hostname.c hex_quote.c htable.c inet_addr_host.c \
++ get_hostname.c get_port.c hex_quote.c htable.c inet_addr_host.c \
+ inet_addr_list.c inet_addr_local.c inet_connect.c inet_listen.c \
+ inet_trigger.c inet_util.c intv.c line_wrap.c lowercase.c \
+ lstat_as.c mac_expand.c mac_parse.c make_dirs.c match_list.c \
+@@ -37,7 +37,7 @@
+ dict_tcp.o dict_unix.o dir_forest.o doze.o duplex_pipe.o \
+ environ.o events.o exec_command.o fifo_listen.o fifo_trigger.o \
+ file_limit.o find_inet.o fsspace.o fullname.o get_domainname.o \
+- get_hostname.o hex_quote.o htable.o inet_addr_host.o \
++ get_hostname.o get_port.o hex_quote.o htable.o inet_addr_host.o \
+ inet_addr_list.o inet_addr_local.o inet_connect.o inet_listen.o \
+ inet_trigger.o inet_util.o intv.o line_wrap.o lowercase.o \
+ lstat_as.o mac_expand.o mac_parse.o make_dirs.o match_list.o \
+@@ -62,7 +62,7 @@
+ dict_ht.h dict_ldap.h dict_mysql.h dict_ni.h dict_nis.h \
+ dict_nisplus.h dict_pcre.h dict_pgsql.h dict_regexp.h dict_static.h dict_tcp.h \
+ dict_unix.h dir_forest.h events.h exec_command.h find_inet.h \
+- fsspace.h fullname.h get_domainname.h get_hostname.h hex_quote.h \
++ fsspace.h fullname.h get_domainname.h get_hostname.h get_port.h hex_quote.h \
+ htable.h inet_addr_host.h inet_addr_list.h inet_addr_local.h \
+ inet_util.h intv.h iostuff.h line_wrap.h listen.h lstat_as.h \
+ mac_expand.h mac_parse.h make_dirs.h match_list.h match_ops.h \
+@@ -785,6 +785,7 @@
get_domainname.o: mymalloc.h
get_domainname.o: get_hostname.h
get_domainname.o: get_domainname.h
get_hostname.o: get_hostname.c
get_hostname.o: sys_defs.h
get_hostname.o: mymalloc.h
-@@ -783,6 +787,7 @@
+@@ -911,6 +912,7 @@
match_list.o: stringops.h
match_list.o: argv.h
match_list.o: dict.h
+match_list.o: inet_util.h
+ match_list.o: match_ops.h
match_list.o: match_list.h
match_ops.o: match_ops.c
- match_ops.o: sys_defs.h
-diff -urN snapshot-20011114.orig/src/util/get_port.c snapshot-20011114/src/util/get_port.c
---- snapshot-20011114.orig/src/util/get_port.c Thu Jan 1 01:00:00 1970
-+++ snapshot-20011114/src/util/get_port.c Thu Nov 15 11:26:21 2001
+diff -durN -x '*~' -x '*.orig' postfix-2.0.16.orig/src/util/get_port.c postfix-2.0.16/src/util/get_port.c
+--- postfix-2.0.16.orig/src/util/get_port.c 1970-01-01 01:00:00.000000000 +0100
++++ postfix-2.0.16/src/util/get_port.c 2005-01-07 18:25:30.206330096 +0100
@@ -0,0 +1,65 @@
+/*++
+/* NAME
+ /* return empty string */
+ return NULL;
+}
-diff -urN snapshot-20011114.orig/src/util/get_port.h snapshot-20011114/src/util/get_port.h
---- snapshot-20011114.orig/src/util/get_port.h Thu Jan 1 01:00:00 1970
-+++ snapshot-20011114/src/util/get_port.h Thu Nov 15 11:26:21 2001
+diff -durN -x '*~' -x '*.orig' postfix-2.0.16.orig/src/util/get_port.h postfix-2.0.16/src/util/get_port.h
+--- postfix-2.0.16.orig/src/util/get_port.h 1970-01-01 01:00:00.000000000 +0100
++++ postfix-2.0.16/src/util/get_port.h 2005-01-07 18:25:30.206330096 +0100
@@ -0,0 +1,28 @@
+#ifndef _GET_PORT_H_INCLUDED_
+#define _GET_PORT_H_INCLUDED_
+/*--*/
+
+#endif
-diff -urN snapshot-20011114.orig/src/util/inet_addr_host.c snapshot-20011114/src/util/inet_addr_host.c
---- snapshot-20011114.orig/src/util/inet_addr_host.c Fri Dec 11 19:55:35 1998
-+++ snapshot-20011114/src/util/inet_addr_host.c Thu Nov 15 11:26:21 2001
-@@ -38,7 +38,10 @@
+diff -durN -x '*~' -x '*.orig' postfix-2.0.16.orig/src/util/inet_addr_host.c postfix-2.0.16/src/util/inet_addr_host.c
+--- postfix-2.0.16.orig/src/util/inet_addr_host.c 1998-12-11 19:55:35.000000000 +0100
++++ postfix-2.0.16/src/util/inet_addr_host.c 2005-01-07 18:28:55.469125408 +0100
+@@ -38,7 +38,11 @@
#include <sys_defs.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
+#include <stdlib.h>
+#include <string.h>
++#include <unistd.h>
#ifndef INADDR_NONE
#define INADDR_NONE 0xffffffff
-@@ -48,15 +51,47 @@
+@@ -48,15 +52,47 @@
#include <inet_addr_list.h>
#include <inet_addr_host.h>
if ((addr.s_addr = inet_addr(hostname)) != INADDR_NONE) {
inet_addr_list_append(addr_list, &addr);
} else {
-@@ -65,9 +100,12 @@
+@@ -65,9 +101,12 @@
inet_addr_list_append(addr_list,
(struct in_addr *) * hp->h_addr_list++);
}
#ifdef TEST
#include <msg.h>
-@@ -78,6 +116,8 @@
+@@ -78,6 +117,8 @@
{
INET_ADDR_LIST addr_list;
int i;
msg_vstream_init(argv[0], VSTREAM_ERR);
-@@ -89,8 +129,12 @@
+@@ -89,8 +130,12 @@
if (inet_addr_host(&addr_list, *argv) == 0)
msg_fatal("not found: %s", *argv);
vstream_fflush(VSTREAM_OUT);
}
inet_addr_list_free(&addr_list);
-diff -urN snapshot-20011114.orig/src/util/inet_addr_list.c snapshot-20011114/src/util/inet_addr_list.c
---- snapshot-20011114.orig/src/util/inet_addr_list.c Tue Jul 31 20:13:41 2001
-+++ snapshot-20011114/src/util/inet_addr_list.c Thu Nov 15 11:26:21 2001
+diff -durN -x '*~' -x '*.orig' postfix-2.0.16.orig/src/util/inet_addr_list.c postfix-2.0.16/src/util/inet_addr_list.c
+--- postfix-2.0.16.orig/src/util/inet_addr_list.c 2001-07-31 20:13:41.000000000 +0200
++++ postfix-2.0.16/src/util/inet_addr_list.c 2005-01-07 18:25:30.207329944 +0100
@@ -51,6 +51,13 @@
#include <arpa/inet.h>
#include <stdlib.h>
void inet_addr_list_append(INET_ADDR_LIST *list, struct in_addr * addr)
{
char *myname = "inet_addr_list_append";
-@@ -83,6 +117,7 @@
+@@ -83,15 +117,22 @@
sizeof(*list->addrs) * list->size);
list->addrs[list->used++] = *addr;
}
/* inet_addr_list_comp - compare addresses */
-diff -urN snapshot-20011114.orig/src/util/inet_addr_list.h snapshot-20011114/src/util/inet_addr_list.h
---- snapshot-20011114.orig/src/util/inet_addr_list.h Tue Jul 31 19:56:47 2001
-+++ snapshot-20011114/src/util/inet_addr_list.h Thu Nov 15 11:48:02 2001
+ static int inet_addr_list_comp(const void *a, const void *b)
+ {
++#ifdef INET6
++ if(((struct sockaddr*)a)->sa_family != ((struct sockaddr*)b)->sa_family)
++ return ( ((struct sockaddr*)a)->sa_family - ((struct sockaddr*)b)->sa_family );
++ return memcmp(a,b,SA_LEN((struct sockaddr*)a));
++#else
+ const struct in_addr *a_addr = (const struct in_addr *) a;
+ const struct in_addr *b_addr = (const struct in_addr *) b;
+
+ return (a_addr->s_addr - b_addr->s_addr);
++#endif
+ }
+
+ /* inet_addr_list_uniq - weed out duplicates */
+diff -durN -x '*~' -x '*.orig' postfix-2.0.16.orig/src/util/inet_addr_list.h postfix-2.0.16/src/util/inet_addr_list.h
+--- postfix-2.0.16.orig/src/util/inet_addr_list.h 2001-07-31 19:56:47.000000000 +0200
++++ postfix-2.0.16/src/util/inet_addr_list.h 2005-01-07 18:25:30.207329944 +0100
@@ -16,19 +16,38 @@
*/
#include <netinet/in.h>
/* LICENSE
/* .ad
-diff -urN snapshot-20011114.orig/src/util/inet_addr_local.c snapshot-20011114/src/util/inet_addr_local.c
---- snapshot-20011114.orig/src/util/inet_addr_local.c Sun Feb 25 19:20:19 2001
-+++ snapshot-20011114/src/util/inet_addr_local.c Thu Nov 15 11:26:21 2001
+diff -durN -x '*~' -x '*.orig' postfix-2.0.16.orig/src/util/inet_addr_local.c postfix-2.0.16/src/util/inet_addr_local.c
+--- postfix-2.0.16.orig/src/util/inet_addr_local.c 2001-02-25 19:20:19.000000000 +0100
++++ postfix-2.0.16/src/util/inet_addr_local.c 2005-01-07 18:25:30.207329944 +0100
@@ -47,6 +47,13 @@
#endif
#include <errno.h>
/* Utility library. */
-@@ -78,18 +85,98 @@
+@@ -78,18 +85,104 @@
int inet_addr_local(INET_ADDR_LIST *addr_list, INET_ADDR_LIST *mask_list)
{
+ char *myname = "inet_addr_local";
+ struct ifaddrs *ifap, *ifa;
+ int initial_count = addr_list->used;
-+ struct sockaddr *sa;
++ struct sockaddr *sa, *sam;
+#ifdef INET6
+#ifdef __KAME__
+ struct sockaddr_in6 addr6;
+#endif
+#else
-+ void *addr;
++ void *addr,*addrm;
+#endif
+
+ if (getifaddrs(&ifap) < 0)
+ msg_fatal("%s: getifaddrs: %m", myname);
+
+ for (ifa = ifap; ifa; ifa = ifa->ifa_next) {
-+ if (! (ifa->ifa_flags & IFF_RUNNING))
++ if ((!(ifa->ifa_flags & IFF_RUNNING)) || (ifa->ifa_addr == NULL) || (ifa->ifa_netmask == NULL))
+ continue;
+ sa = ifa->ifa_addr;
++ sam = ifa->ifa_netmask;
+ switch (ifa->ifa_addr->sa_family) {
+ case AF_INET:
+#ifndef INET6
+ addr = (void *)&((struct sockaddr_in *)ifa->ifa_addr)->sin_addr;
++ addrm = (void *)&((struct sockaddr_in *)ifa->ifa_netmask)->sin_addr;
+#endif
+ break;
+#ifdef INET6
+
+#ifdef INET6
+ inet_addr_list_append(addr_list, sa);
++ if (mask_list != NULL)
++ inet_addr_list_append(mask_list, sam);
+#else
+ inet_addr_list_append(addr_list, (struct in_addr *)addr);
++ if (mask_list != NULL)
++ inet_addr_list_append(mask_list, (struct in_addr *)addrm);
+#endif
+ }
+
/*
* Get the network interface list. XXX The socket API appears to have no
-@@ -126,10 +213,15 @@
+@@ -126,10 +219,15 @@
*/
the_end = (struct ifreq *) (ifc.ifc_buf + ifc.ifc_len);
for (ifr = ifc.ifc_req; ifr < the_end;) {
if (mask_list) {
ifr_mask = (struct ifreq *) mymalloc(IFREQ_SIZE(ifr));
memcpy((char *) ifr_mask, (char *) ifr, IFREQ_SIZE(ifr));
-@@ -141,11 +233,61 @@
+@@ -141,11 +239,70 @@
}
}
}
+ addr6.sin6_addr.s6_addr[2] = addr6.sin6_addr.s6_addr[3] = 0;
+ }
+#endif
-+ if (!(IN6_IS_ADDR_UNSPECIFIED(&addr6.sin6_addr)))
++ if (!(IN6_IS_ADDR_UNSPECIFIED(&addr6.sin6_addr))) {
+ inet_addr_list_append(addr_list, (struct sockaddr *)&addr6);
++ if (mask_list) {
++#error "mask_list for IPv6 without libinet6 not done yet (error to avoid open-relay)"
++ /* TODO: how to get netmask here? */
++ }
++ }
+ }
+#endif
ifr = NEXT_INTERFACE(ifr);
+ if (!gaierror) {
+ for (res = res0; res; res = res->ai_next) {
+ inet_addr_list_append(addr_list, res->ai_addr);
++ if (mask_list) {
++#error "mask_list for IPv6 without libinet6 not done yet (error to avoid open-relay)"
++ /* TODO: calculate netmask basing on plen */
++ }
+ }
+ freeaddrinfo(res0);
+ }
}
#ifdef TEST
-@@ -158,6 +300,8 @@
+@@ -158,6 +315,8 @@
INET_ADDR_LIST addr_list;
INET_ADDR_LIST mask_list;
int i;
msg_vstream_init(argv[0], VSTREAM_ERR);
-@@ -172,8 +316,17 @@
+@@ -172,8 +331,17 @@
msg_warn("found only one active network interface");
for (i = 0; i < addr_list.used; i++) {
}
vstream_fflush(VSTREAM_OUT);
inet_addr_list_free(&addr_list);
-diff -urN snapshot-20011114.orig/src/util/inet_connect.c snapshot-20011114/src/util/inet_connect.c
---- snapshot-20011114.orig/src/util/inet_connect.c Mon Nov 20 19:06:31 2000
-+++ snapshot-20011114/src/util/inet_connect.c Thu Nov 15 11:26:21 2001
+diff -durN -x '*~' -x '*.orig' postfix-2.0.16.orig/src/util/inet_connect.c postfix-2.0.16/src/util/inet_connect.c
+--- postfix-2.0.16.orig/src/util/inet_connect.c 2003-09-13 03:04:12.000000000 +0200
++++ postfix-2.0.16/src/util/inet_connect.c 2005-01-07 18:25:30.208329792 +0100
@@ -55,6 +55,9 @@
#include <string.h>
#include <unistd.h>
/* Utility library. */
-@@ -73,7 +76,12 @@
+@@ -74,7 +77,12 @@
char *buf;
char *host;
char *port;
int sock;
/*
-@@ -81,14 +89,58 @@
+@@ -82,14 +90,58 @@
* the local host.
*/
buf = inet_parse(addr, &host, &port);
/*
* Create a client socket.
*/
-@@ -121,4 +173,5 @@
+@@ -122,4 +174,5 @@
}
return (sock);
}
+#endif
}
-diff -urN snapshot-20011114.orig/src/util/inet_listen.c snapshot-20011114/src/util/inet_listen.c
---- snapshot-20011114.orig/src/util/inet_listen.c Mon Nov 20 19:06:32 2000
-+++ snapshot-20011114/src/util/inet_listen.c Thu Nov 15 11:26:21 2001
+diff -durN -x '*~' -x '*.orig' postfix-2.0.16.orig/src/util/inet_listen.c postfix-2.0.16/src/util/inet_listen.c
+--- postfix-2.0.16.orig/src/util/inet_listen.c 2003-09-13 01:50:50.000000000 +0200
++++ postfix-2.0.16/src/util/inet_listen.c 2005-01-07 18:25:30.208329792 +0100
@@ -6,7 +6,7 @@
/* SYNOPSIS
/* #include <listen.h>
non_blocking(sock, block_mode);
if (listen(sock, backlog) < 0)
msg_fatal("listen: %m");
-diff -urN snapshot-20011114.orig/src/util/listen.h snapshot-20011114/src/util/listen.h
---- snapshot-20011114.orig/src/util/listen.h Mon Mar 22 02:57:11 1999
-+++ snapshot-20011114/src/util/listen.h Thu Nov 15 11:26:21 2001
+diff -durN -x '*~' -x '*.orig' postfix-2.0.16.orig/src/util/listen.h postfix-2.0.16/src/util/listen.h
+--- postfix-2.0.16.orig/src/util/listen.h 1999-03-22 02:57:11.000000000 +0100
++++ postfix-2.0.16/src/util/listen.h 2005-01-07 18:25:30.208329792 +0100
@@ -20,7 +20,7 @@
* Listener external interface.
*/
extern int fifo_listen(const char *, int, int);
extern int stream_listen(const char *, int, int);
-diff -urN snapshot-20011114.orig/src/util/match_list.c snapshot-20011114/src/util/match_list.c
---- snapshot-20011114.orig/src/util/match_list.c Mon Nov 20 19:06:32 2000
-+++ snapshot-20011114/src/util/match_list.c Thu Nov 15 11:26:21 2001
-@@ -107,7 +107,7 @@
+diff -durN -x '*~' -x '*.orig' postfix-2.0.16.orig/src/util/match_list.c postfix-2.0.16/src/util/match_list.c
+--- postfix-2.0.16.orig/src/util/match_list.c 2001-11-20 21:07:15.000000000 +0100
++++ postfix-2.0.16/src/util/match_list.c 2005-01-07 18:25:30.209329640 +0100
+@@ -118,7 +118,7 @@
list = match_list_parse(list, vstring_str(buf));
if (vstream_fclose(fp))
msg_fatal("%s: read file %s: %m", myname, pattern);
for (cp = pattern; *cp == '!'; cp++)
/* void */ ;
if (dict_handle(pattern) == 0)
-diff -urN snapshot-20011114.orig/src/util/match_ops.c snapshot-20011114/src/util/match_ops.c
---- snapshot-20011114.orig/src/util/match_ops.c Mon Sep 6 03:02:14 1999
-+++ snapshot-20011114/src/util/match_ops.c Thu Nov 15 11:26:21 2001
-@@ -70,6 +70,307 @@
+diff -durN -x '*~' -x '*.orig' postfix-2.0.16.orig/src/util/match_ops.c postfix-2.0.16/src/util/match_ops.c
+--- postfix-2.0.16.orig/src/util/match_ops.c 2003-04-14 16:44:19.000000000 +0200
++++ postfix-2.0.16/src/util/match_ops.c 2005-01-07 18:25:30.210329488 +0100
+@@ -81,6 +81,308 @@
#include <match_ops.h>
#include <stringops.h>
+#ifdef INET6
+/*
-+ * $Id$
++ * $Id$
+ *
-+ * This program is free software; you can redistribute it and/or
-+ * modify it under the terms of the GNU General Public License
-+ * as published by the Free Software Foundation; either version
-+ * 2 of the License, or (at your option) any later version.
++ * This program is free software; you can redistribute it and/or
++ * modify it under the terms of the GNU General Public License
++ * as published by the Free Software Foundation; either version
++ * 2 of the License, or (at your option) any later version.
++ *
++ * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru>
+ *
-+ * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru>
-+ *
+ * Modifications:
-+ * Artur Frysiak <wiget@pld.org.pl>
-+ * Arkadiusz Mi¶kiewicz <misiek@pld.org.pl>
++ * Artur Frysiak <wiget@pld.org.pl>
++ * Arkadiusz Mi¶kiewicz <misiek@pld.org.pl>
+ */
+
+#include <stdio.h>
+#include <arpa/inet.h>
+#include <resolv.h>
+
-+#ifndef AF_DECnet
-+#define AF_DECnet 12
++#ifndef AF_DECnet
++#define AF_DECnet 12
+#endif
+
-+#ifndef PF_PACKET
-+#define PF_PACKET 17
++#ifndef PF_PACKET
++#define PF_PACKET 17
+#endif
+
+typedef struct
+{
-+ unsigned char family;
-+ unsigned char bytelen;
-+ signed short bitlen;
-+ unsigned int data[4];
++ unsigned char family;
++ unsigned char bytelen;
++ signed short bitlen;
++ unsigned int data[4];
+} inet_prefix;
+
+/* prototypes */
+int matches(char *, char *);
+int inet_addr_match(inet_prefix *, inet_prefix *, int);
+int mask_match(char *, char *, char *);
-+
++
+int get_integer(int *val, char *arg, int base)
+{
-+ long res;
-+ char *ptr;
-+
-+ if (!arg || !*arg)
-+ return -1;
-+ res = strtol(arg, &ptr, base);
-+ if (!ptr || ptr == arg || *ptr || res > INT_MAX || res < INT_MIN)
-+ return -1;
-+ *val = res;
-+ return 0;
++ long res;
++ char *ptr;
++
++ if (!arg || !*arg)
++ return -1;
++ res = strtol(arg, &ptr, base);
++ if (!ptr || ptr == arg || *ptr || res > INT_MAX || res < INT_MIN)
++ return -1;
++ *val = res;
++ return 0;
+}
+
+int get_addr_1(inet_prefix *addr, char *name, int family)
+{
-+ char *cp;
-+ unsigned char *ap = (unsigned char*)addr->data;
-+ int i;
-+
-+ memset(addr, 0, sizeof(*addr));
-+
-+ if (strcmp(name, "default") == 0 || strcmp(name, "any") == 0) {
-+ if (family == AF_DECnet)
-+ return -1;
-+ addr->family = family;
-+ addr->bytelen = (family == AF_INET6 ? 16 : 4);
-+ addr->bitlen = -1;
-+ return 0;
-+ }
-+
-+ if (strchr(name, ':')) {
-+ addr->family = AF_INET6;
-+ if (family != AF_UNSPEC && family != AF_INET6)
-+ return -1;
-+ if (inet_pton(AF_INET6, name, addr->data) <= 0)
-+ return -1;
-+ addr->bytelen = 16;
-+ addr->bitlen = -1;
-+ return 0;
-+ }
-+ addr->family = AF_INET;
-+ if (family != AF_UNSPEC && family != AF_INET)
-+ return -1;
-+ addr->bytelen = 4;
-+ addr->bitlen = -1;
-+ for (cp = name, i = 0; *cp; cp++) {
-+ if (*cp <= '9' && *cp >= '0') {
-+ ap[i] = 10*ap[i] + (*cp-'0');
-+ continue;
-+ }
-+ if (*cp == '.' && ++i <= 3)
-+ continue;
-+ return -1;
-+ }
-+ return 0;
++ char *cp;
++ unsigned char *ap = (unsigned char*)addr->data;
++ int i;
++
++ memset(addr, 0, sizeof(*addr));
++
++ if (strcmp(name, "default") == 0 || strcmp(name, "any") == 0) {
++ if (family == AF_DECnet)
++ return -1;
++ addr->family = family;
++ addr->bytelen = (family == AF_INET6 ? 16 : 4);
++ addr->bitlen = -1;
++ return 0;
++ }
++
++ if (strchr(name, ':')) {
++ addr->family = AF_INET6;
++ if (family != AF_UNSPEC && family != AF_INET6)
++ return -1;
++ if (inet_pton(AF_INET6, name, addr->data) <= 0)
++ return -1;
++ addr->bytelen = 16;
++ addr->bitlen = -1;
++ return 0;
++ }
++ addr->family = AF_INET;
++ if (family != AF_UNSPEC && family != AF_INET)
++ return -1;
++ addr->bytelen = 4;
++ addr->bitlen = -1;
++ for (cp = name, i = 0; *cp; cp++) {
++ if (*cp <= '9' && *cp >= '0') {
++ ap[i] = 10*ap[i] + (*cp-'0');
++ continue;
++ }
++ if (*cp == '.' && ++i <= 3)
++ continue;
++ return -1;
++ }
++ return 0;
+}
+
+int get_prefix_1(inet_prefix *dst, char *arg, int family)
+{
-+ int err;
-+ unsigned plen;
-+ char *slash;
-+
-+ memset(dst, 0, sizeof(*dst));
-+
-+ if (strcmp(arg, "default") == 0 || strcmp(arg, "any") == 0) {
-+ if (family == AF_DECnet)
-+ return -1;
-+ dst->family = family;
-+ dst->bytelen = 0;
-+ dst->bitlen = 0;
-+ return 0;
-+ }
-+
-+ slash = strchr(arg, '/');
-+ if (slash)
-+ *slash = 0;
-+ err = get_addr_1(dst, arg, family);
-+ if (err == 0) {
-+ switch(dst->family) {
-+ case AF_INET6:
-+ dst->bitlen = 128;
-+ break;
-+ case AF_DECnet:
-+ dst->bitlen = 16;
-+ break;
-+ default:
-+ case AF_INET:
-+ dst->bitlen = 32;
-+ }
-+ if (slash) {
-+ if (get_integer(&plen, slash+1, 0) || plen > dst->bitlen) {
-+ err = -1;
-+ goto done;
-+ }
-+ dst->bitlen = plen;
-+ }
-+ }
++ int err;
++ unsigned plen;
++ char *slash;
++
++ memset(dst, 0, sizeof(*dst));
++
++ if (strcmp(arg, "default") == 0 || strcmp(arg, "any") == 0) {
++ if (family == AF_DECnet)
++ return -1;
++ dst->family = family;
++ dst->bytelen = 0;
++ dst->bitlen = 0;
++ return 0;
++ }
++
++ slash = strchr(arg, '/');
++ if (slash)
++ *slash = 0;
++ err = get_addr_1(dst, arg, family);
++ if (err == 0) {
++ switch(dst->family) {
++ case AF_INET6:
++ dst->bitlen = 128;
++ break;
++ case AF_DECnet:
++ dst->bitlen = 16;
++ break;
++ default:
++ case AF_INET:
++ dst->bitlen = 32;
++ }
++ if (slash) {
++ if (get_integer(&plen, slash+1, 0) || plen > dst->bitlen) {
++ err = -1;
++ goto done;
++ }
++ dst->bitlen = plen;
++ }
++ }
+done:
-+ if (slash)
-+ *slash = '/';
-+ return err;
++ if (slash)
++ *slash = '/';
++ return err;
+}
+
+int get_addr(inet_prefix *dst, char *arg, int family)
+{
+#ifdef AF_PACKET
-+ if (family == AF_PACKET)
-+ return -1;
++ if (family == AF_PACKET)
++ return -1;
+#endif
-+ if (get_addr_1(dst, arg, family))
-+ return -1;
-+ return 0;
++ if (get_addr_1(dst, arg, family))
++ return -1;
++ return 0;
+}
+
+int get_prefix(inet_prefix *dst, char *arg, int family)
+{
+#ifdef AF_PACKET
-+ if (family == AF_PACKET)
-+ return -1;
++ if (family == AF_PACKET)
++ return -1;
+#endif
-+ if (get_prefix_1(dst, arg, family))
-+ return -1;
-+ return 0;
++ if (get_prefix_1(dst, arg, family))
++ return -1;
++ return 0;
+}
+
+unsigned int get_addr32(char *name)
+{
-+ inet_prefix addr;
-+ if (get_addr_1(&addr, name, AF_INET))
-+ return -1;
-+ return addr.data[0];
++ inet_prefix addr;
++ if (get_addr_1(&addr, name, AF_INET))
++ return -1;
++ return addr.data[0];
+}
+
+int matches(char *cmd, char *pattern)
+{
-+ int len = strlen(cmd);
-+ if (len > strlen(pattern))
-+ return -1;
-+ return memcmp(pattern, cmd, len);
++ int len = strlen(cmd);
++ if (len > strlen(pattern))
++ return -1;
++ return memcmp(pattern, cmd, len);
+}
+
+int inet_addr_match(inet_prefix *a, inet_prefix *b, int bits)
+{
-+ unsigned int *a1 = a->data;
-+ unsigned int *a2 = b->data;
-+ int words = bits >> 0x05;
++ unsigned int *a1 = a->data;
++ unsigned int *a2 = b->data;
++ int words = bits >> 0x05;
+
-+ bits &= 0x1f;
++ bits &= 0x1f;
+
-+ if (words)
-+ if (memcmp(a1, a2, words << 2))
-+ return -1;
++ if (words)
++ if (memcmp(a1, a2, words << 2))
++ return -1;
+
-+ if (bits) {
-+ unsigned int w1, w2;
-+ unsigned int mask;
++ if (bits) {
++ unsigned int w1, w2;
++ unsigned int mask;
+
-+ w1 = a1[words];
-+ w2 = a2[words];
++ w1 = a1[words];
++ w2 = a2[words];
+
-+ mask = htonl((0xffffffff) << (0x20 - bits));
++ mask = htonl((0xffffffff) << (0x20 - bits));
+
-+ if ((w1 ^ w2) & mask)
-+ return 1;
-+ }
++ if ((w1 ^ w2) & mask)
++ return 1;
++ }
+
-+ return 0;
++ return 0;
+}
+
+/* zero if matches */
+int mask_match(char *network, char *cprefix, char *address)
+{
-+ inet_prefix *inetwork;
-+ inet_prefix *iaddress;
-+ int ret, prefix;
-+
-+ if (!(network && address && cprefix))
-+ return -1;
-+ prefix = strtol(cprefix, (char **)NULL, 10);
-+ if ((prefix < 0) || (prefix > 128))
-+ return -1;
-+ if ((strlen(network) == 0) || (strlen(address) == 0))
-+ return -1;
-+
-+ inetwork = malloc(sizeof(inet_prefix));
-+ iaddress = malloc(sizeof(inet_prefix));
-+
-+ if ((get_addr(iaddress, address, AF_UNSPEC) >= 0)
-+ && (get_addr(inetwork, network, AF_UNSPEC) >= 0))
-+ ret = inet_addr_match(inetwork, iaddress, prefix);
-+ else
-+ ret = -1;
-+ free(inetwork);
-+ free(iaddress);
-+
-+ /* 1 if matches */
-+ /* return (!ret); */
-+ /* 0 if matches */
-+ return ret;
++ inet_prefix *inetwork;
++ inet_prefix *iaddress;
++ int ret, prefix;
++
++ if (!(network && address && cprefix))
++ return -1;
++ prefix = strtol(cprefix, (char **)NULL, 10);
++ if ((prefix < 0) || (prefix > 128))
++ return -1;
++ if ((strlen(network) == 0) || (strlen(address) == 0))
++ return -1;
++
++ inetwork = malloc(sizeof(inet_prefix));
++ iaddress = malloc(sizeof(inet_prefix));
++
++ if ((get_addr(iaddress, address, AF_UNSPEC) >= 0)
++ && (get_addr(inetwork, network, AF_UNSPEC) >= 0))
++ ret = inet_addr_match(inetwork, iaddress, prefix);
++ else
++ ret = -1;
++ free(inetwork);
++ free(iaddress);
++
++ /* 1 if matches */
++ /* return (!ret); */
++ /* 0 if matches */
++ return ret;
+}
+
+/*
-+ * masked_match() - universal for IPv4 and IPv6
++ * masked_match() - universal for IPv4 and IPv6 - 1 if matches
+ */
+int masked_match(net_tok, mask_tok, string)
-+char *net_tok;
-+char *mask_tok;
-+char *string;
++char *net_tok;
++char *mask_tok;
++char *string;
+{
+#ifdef INET6
-+ struct in6_addr in6[2];
-+ char v4addr[2][INET_ADDRSTRLEN];
-+ char newmask[6];
-+ int plen;
++ struct in6_addr in6[2];
++ char v4addr[2][INET_ADDRSTRLEN];
++ char newmask[6];
++ int plen;
+#endif
+
-+ /* Check for NULL */
-+ if (!(net_tok && mask_tok && string))
-+ return 1;
++ /* Check for NULL */
++ if (!(net_tok && mask_tok && string))
++ return 0; /* doesn't match!!! */
+
-+ /* If IPv6 mapped convert to native-IPv4 */
++ /* If IPv6 mapped convert to native-IPv4 */
+#ifdef INET6
-+ if (inet_pton(AF_INET6, net_tok, &in6[0]) == 1 &&
-+ inet_pton(AF_INET6, string, &in6[1]) == 1 &&
-+ IN6_IS_ADDR_V4MAPPED(&in6[0]) && IN6_IS_ADDR_V4MAPPED(&in6[1])) {
-+ plen = atoi(mask_tok);
-+ if (32 < plen && plen < 129) {
-+ sprintf(newmask, "%d", plen - 96);
-+ mask_tok = newmask;
-+ }
++ if (inet_pton(AF_INET6, net_tok, &in6[0]) == 1 &&
++ inet_pton(AF_INET6, string, &in6[1]) == 1 &&
++ IN6_IS_ADDR_V4MAPPED(&in6[0]) && IN6_IS_ADDR_V4MAPPED(&in6[1])) {
++ plen = atoi(mask_tok);
++ if (32 < plen && plen < 129) {
++ sprintf(newmask, "%d", plen - 96);
++ mask_tok = newmask;
++ }
+
-+ (void)inet_ntop(AF_INET, &in6[0].s6_addr[12], v4addr[0],
-+ sizeof(v4addr[0]));
-+ net_tok = v4addr[0];
-+ (void)inet_ntop(AF_INET, &in6[1].s6_addr[12], v4addr[1],
-+ sizeof(v4addr[1]));
-+ string = v4addr[1];
-+ }
++ (void)inet_ntop(AF_INET, &in6[0].s6_addr[12], v4addr[0],
++ sizeof(v4addr[0]));
++ net_tok = v4addr[0];
++ (void)inet_ntop(AF_INET, &in6[1].s6_addr[12], v4addr[1],
++ sizeof(v4addr[1]));
++ string = v4addr[1];
++ }
+#endif
-+ return (!mask_match(net_tok, mask_tok, string));
++ return (!mask_match(net_tok, mask_tok, string));
+}
+#endif
++
+
/* match_string - match a string literal */
- int match_string(const char *string, const char *pattern)
-@@ -158,6 +459,7 @@
+ int match_string(int unused_flags, const char *string, const char *pattern)
+@@ -177,6 +479,7 @@
return (0);
}
/* match_parse_mask - parse net/mask pattern */
static int match_parse_mask(const char *pattern, unsigned long *net_bits,
-@@ -178,28 +480,55 @@
- myfree(saved_pattern);
+@@ -198,28 +501,55 @@
return (mask != 0);
}
-+#endif
++#endif
/* match_hostaddr - match host by address */
- int match_hostaddr(const char *addr, const char *pattern)
+ int match_hostaddr(int unused_flags, const char *addr, const char *pattern)
{
char *myname = "match_hostaddr";
+#ifdef INET6
unsigned long mask_bits;
unsigned long net_bits;
unsigned long addr_bits;
+ struct in_addr net_addr;
+#endif
if (msg_verbose)
+ escl = strchr(patternx,'[');
+ escr = strrchr(patternx,']');
+ if (escl && escr) {
-+ *escr = 0;
-+ sprintf(patternx, "%s%s", escl + 1, escr + 1);
-+ pattern = patternx;
++ *escr = 0;
++ sprintf(patternx, "%s%s", escl + 1, escr + 1);
++ pattern = patternx;
+ }
+#endif
-+
++
/*
* Try dictionary lookup. This can be case insensitive. XXX Probably
* should also try again after stripping least significant octets.
+#else
+ if (strchr(pattern, ':') != 0)
+#endif
-+ {
++ {
if (dict_lookup(pattern, addr) != 0)
return (1);
if (dict_errno != 0)
-@@ -210,6 +539,12 @@
+@@ -230,6 +560,12 @@
/*
* Try an exact match with the host address.
*/
+#ifdef INET6
+ if (inet_pton(AF_INET6, addr, &in6) == 1 && IN6_IS_ADDR_V4MAPPED(&in6)) {
-+ (void)inet_ntop(AF_INET, &in6.s6_addr[12], v4addr, sizeof(v4addr));
-+ addr = v4addr;
++ (void)inet_ntop(AF_INET, &in6.s6_addr[12], v4addr, sizeof(v4addr));
++ addr = v4addr;
+ }
+#endif
if (strcasecmp(addr, pattern) == 0) {
return (1);
}
-@@ -218,6 +553,20 @@
+@@ -238,6 +574,20 @@
* In a net/mask pattern, the mask is specified as the number of bits of
* the network part.
*/
+ mask = split_at(network, '/');
+
+ if (masked_match(network, mask, (char *)addr)) {
-+ myfree(network);
-+ myfree(patternx);
-+ return (1);
++ myfree(network);
++ myfree(patternx);
++ return (1);
+ } else {
-+ myfree(network);
-+ myfree(patternx);
++ myfree(network);
++ myfree(patternx);
+ }
+#else
-+
++
if (match_parse_mask(pattern, &net_bits, &mask_shift)) {
addr_bits = inet_addr(addr);
if (addr_bits == INADDR_NONE)
-@@ -225,5 +574,6 @@
- mask_bits = htonl((0xffffffff) << (BITS_PER_ADDR - mask_shift));
- return ((addr_bits & mask_bits) == (net_bits & mask_bits));
+@@ -252,5 +602,6 @@
+ pattern, inet_ntoa(net_addr), mask_shift);
+ }
}
+#endif
return (0);
}
-diff -urN snapshot-20011114.orig/src/util/sys_defs.h snapshot-20011114/src/util/sys_defs.h
---- snapshot-20011114.orig/src/util/sys_defs.h Thu Nov 15 11:25:48 2001
-+++ snapshot-20011114/src/util/sys_defs.h Thu Nov 15 11:26:21 2001
-@@ -68,6 +68,10 @@
+diff -durN -x '*~' -x '*.orig' postfix-2.0.16.orig/src/util/sys_defs.h postfix-2.0.16/src/util/sys_defs.h
+--- postfix-2.0.16.orig/src/util/sys_defs.h 2005-01-07 18:22:25.289441736 +0100
++++ postfix-2.0.16/src/util/sys_defs.h 2005-01-07 18:25:30.211329336 +0100
+@@ -73,6 +73,10 @@
#define DEF_MAILBOX_LOCK "flock, dotlock"
#endif
/*
* UNIX on MAC.
*/
-diff -urN snapshot-20011114.orig/src/util/valid_hostname.c snapshot-20011114/src/util/valid_hostname.c
---- snapshot-20011114.orig/src/util/valid_hostname.c Sun Jan 28 15:10:18 2001
-+++ snapshot-20011114/src/util/valid_hostname.c Thu Nov 15 11:26:21 2001
-@@ -47,6 +47,13 @@
+diff -durN -x '*~' -x '*.orig' postfix-2.0.16.orig/src/util/valid_hostname.c postfix-2.0.16/src/util/valid_hostname.c
+--- postfix-2.0.16.orig/src/util/valid_hostname.c 2002-12-20 02:33:41.000000000 +0100
++++ postfix-2.0.16/src/util/valid_hostname.c 2005-01-07 18:25:30.211329336 +0100
+@@ -53,6 +53,13 @@
#include <string.h>
#include <ctype.h>
/* Utility library. */
#include "msg.h"
-@@ -103,7 +110,23 @@
+@@ -109,7 +116,23 @@
msg_warn("%s: misplaced hyphen: %.100s", myname, name);
return (0);
}
if (gripe)
msg_warn("%s: invalid character %d(decimal): %.100s",
myname, ch, name);
-@@ -135,6 +158,9 @@
+@@ -141,6 +164,9 @@
int byte_count = 0;
int byte_val = 0;
int ch;
#define BYTES_NEEDED 4
-@@ -147,6 +173,17 @@
- return (0);
+@@ -166,6 +192,17 @@
+ return (1);
}
+#ifdef INET6