From 330ffa18b5aa1c31d68c0a39e8860db5ad24384f Mon Sep 17 00:00:00 2001 From: Wietse Venema Date: Thu, 18 Jul 2002 00:00:00 -0500 Subject: [PATCH] postfix-1.1.11-20020718 --- postfix/HISTORY | 7 ++++ postfix/src/global/Makefile.in | 26 ++++++++++---- postfix/src/global/mail_version.h | 2 +- postfix/src/global/virtual8.in | 8 +++++ postfix/src/global/virtual8.ref | 8 +++++ postfix/src/global/virtual8_map | 3 ++ postfix/src/global/virtual8_maps_find.c | 45 ++++++++++++++++++++++--- 7 files changed, 88 insertions(+), 11 deletions(-) create mode 100644 postfix/src/global/virtual8.in create mode 100644 postfix/src/global/virtual8.ref create mode 100644 postfix/src/global/virtual8_map diff --git a/postfix/HISTORY b/postfix/HISTORY index c22ea59cf..4b9df80ed 100644 --- a/postfix/HISTORY +++ b/postfix/HISTORY @@ -6700,6 +6700,13 @@ Apologies for any names omitted. Jun-ichiro itojun Hagino, IIJ labs. Files: smtpd/smtpd_check.c, dns/dns_lookup.c. +20020718 + + Bugfix: unnecessary lookups for extended addresses by the + virtual8_maps_find() routine. Victor Duchovni. His patch + did not work, nor did my own, but the present version should + be OK. File: global/virtual8_maps_find.c. + Open problems: Medium: should permit_mx_backup defer delivery if DNS diff --git a/postfix/src/global/Makefile.in b/postfix/src/global/Makefile.in index 536e31319..9b3cba78d 100644 --- a/postfix/src/global/Makefile.in +++ b/postfix/src/global/Makefile.in @@ -73,7 +73,8 @@ TESTPROG= domain_list dot_lockfile mail_addr_crunch mail_addr_find \ mail_addr_map mail_date maps mynetworks mypwd namadr_list \ off_cvt quote_822_local rec2stream recdump resolve_clnt \ resolve_local rewrite_clnt stream2rec string_list tok822_parse \ - quote_821_local mail_conf_time mime_state strip_addr + quote_821_local mail_conf_time mime_state strip_addr \ + virtual8_maps_find LIBS = ../../lib/libutil.a LIB_DIR = ../../lib @@ -226,8 +227,13 @@ strip_addr: $(LIB) $(LIBS) $(CC) -DTEST $(CFLAGS) -o $@ $@.c $(LIB) $(LIBS) $(SYSLIBS) mv junk $@.o +virtual8_maps_find: $(LIB) $(LIBS) + mv $@.o junk + $(CC) -DTEST $(CFLAGS) -o $@ $@.c $(LIB) $(LIBS) $(SYSLIBS) + mv junk $@.o + tests: tok822_test mime_test mime_nest mime_8bit mime_dom mime_trunc \ - strip_addr_test tok822_limit_test + strip_addr_test tok822_limit_test virtual8_test tok822_test: tok822_parse tok822_parse.in tok822_parse.ref ./tok822_parse tok822_parse.tmp @@ -264,6 +270,18 @@ tok822_limit_test: tok822_parse tok822_limit.in tok822_limit.ref diff tok822_limit.ref tok822_limit.tmp rm -f tok822_limit.tmp +strip_addr_test: strip_addr strip_addr.ref + ./strip_addr 2>strip_addr.tmp + diff strip_addr.ref strip_addr.tmp + rm -f strip_addr.tmp + +virtual8_test: virtual8_maps_find virtual8_map virtual8.in virtual8.ref \ + ../postmap/postmap + ../postmap/postmap hash:virtual8_map + ./virtual8_maps_find virtual8.tmp + diff virtual8.ref virtual8.tmp + rm -f virtual8.tmp virtual8_map.db + printfck: $(OBJS) $(PROG) rm -rf printfck mkdir printfck @@ -272,10 +290,6 @@ printfck: $(OBJS) $(PROG) set -e; for i in *.c; do printfck -f .printfck $$i >printfck/$$i; done cd printfck; make "INC_DIR=../../../include" `cd ..; ls *.o` -strip_addr_test: strip_addr strip_addr.ref - ./strip_addr 2>strip_addr.tmp - diff strip_addr.ref strip_addr.tmp - rm -f strip_addr.tmp lint: lint $(DEFS) $(SRCS) $(LINTFIX) diff --git a/postfix/src/global/mail_version.h b/postfix/src/global/mail_version.h index e9bdf9882..c277fb3ac 100644 --- a/postfix/src/global/mail_version.h +++ b/postfix/src/global/mail_version.h @@ -20,7 +20,7 @@ * Patches change the patchlevel and the release date. Snapshots change the * release date only, unless they include the same bugfix as a patch release. */ -#define MAIL_RELEASE_DATE "20020717" +#define MAIL_RELEASE_DATE "20020718" #define VAR_MAIL_VERSION "mail_version" #define DEF_MAIL_VERSION "1.1.11-" MAIL_RELEASE_DATE diff --git a/postfix/src/global/virtual8.in b/postfix/src/global/virtual8.in new file mode 100644 index 000000000..d030a94e7 --- /dev/null +++ b/postfix/src/global/virtual8.in @@ -0,0 +1,8 @@ +aaa@domain.tld +aaa+xxx@domain.tld +bbb@domain.tld +bbb+yyy@domain.tld +ccc@domain.tld +ccc+zzz@domain.tld +aaa@domain.ttt +aaa+bbb@domain.ttt diff --git a/postfix/src/global/virtual8.ref b/postfix/src/global/virtual8.ref new file mode 100644 index 000000000..0e9c19c84 --- /dev/null +++ b/postfix/src/global/virtual8.ref @@ -0,0 +1,8 @@ +aaa@domain.tld -> aaa +aaa+xxx@domain.tld -> aaa +bbb@domain.tld -> bbb +bbb+yyy@domain.tld -> bbb +ccc@domain.tld -> catchall +ccc+zzz@domain.tld -> catchall +aaa@domain.ttt -> (none) +aaa+bbb@domain.ttt -> (none) diff --git a/postfix/src/global/virtual8_map b/postfix/src/global/virtual8_map new file mode 100644 index 000000000..f0231d5e5 --- /dev/null +++ b/postfix/src/global/virtual8_map @@ -0,0 +1,3 @@ +@domain.tld catchall +aaa@domain.tld aaa +bbb@domain.tld bbb diff --git a/postfix/src/global/virtual8_maps_find.c b/postfix/src/global/virtual8_maps_find.c index 9df97b5e5..0d50c9647 100644 --- a/postfix/src/global/virtual8_maps_find.c +++ b/postfix/src/global/virtual8_maps_find.c @@ -63,7 +63,7 @@ const char *virtual8_maps_find(MAPS *maps, const char *recipient) { const char *ratsign; const char *result; - char *bare; + char *bare = 0; /* * Look up the address minus the optional extension. This is done first, @@ -81,9 +81,11 @@ const char *virtual8_maps_find(MAPS *maps, const char *recipient) /* * Look up the full address. */ - result = maps_find(maps, recipient, DICT_FLAG_FIXED); - if (result != 0 || dict_errno != 0) - return (result); + if (bare == 0) { + result = maps_find(maps, recipient, DICT_FLAG_FIXED); + if (result != 0 || dict_errno != 0) + return (result); + } /* * Look up the @domain catch-all. @@ -92,3 +94,38 @@ const char *virtual8_maps_find(MAPS *maps, const char *recipient) return (0); return (maps_find(maps, ratsign, DICT_FLAG_FIXED)); } + +#ifdef TEST + +#include +#include +#include + +#define STR(x) vstring_str(x) + +int main(int argc, char **argv) +{ + VSTRING *buffer; + MAPS *maps; + const char *result; + + if (argc != 2) + msg_fatal("usage: %s mapname", argv[0]); + + var_rcpt_delim = "+"; + var_double_bounce_sender = DEF_DOUBLE_BOUNCE; + + maps = maps_create("testmap", argv[1], DICT_FLAG_LOCK); + buffer = vstring_alloc(1); + + while (vstring_fgets_nonl(buffer, VSTREAM_IN)) { + result = virtual8_maps_find(maps, STR(buffer)); + vstream_printf("%s -> %s\n", STR(buffer), result ? result : "(none)"); + vstream_fflush(VSTREAM_OUT); + } + maps_free(maps); + vstring_free(buffer); + return (0); +} + +#endif