2
0
mirror of https://github.com/vdukhovni/postfix synced 2025-08-30 13:48:06 +00:00

postfix-1.1.11-20020610

This commit is contained in:
Wietse Venema
2002-06-10 00:00:00 -05:00
committed by Viktor Dukhovni
parent 14c13568bd
commit 866561e747
74 changed files with 877 additions and 290 deletions

View File

@@ -6598,9 +6598,9 @@ Apologies for any names omitted.
with unread data according to ioctl FIONREAD. Incredible.
Diagnosis by Max Pashkov. File: smtp/smtp-sink.c.
Weirdstuff: sender-based routing. This will become more
Weird feature: sender-based routing. This will become more
useful once per-address transport map entries are done.
File: src/qmgr/qmgr_message.c.
File: src/*qmgr/qmgr_message.c.
20020605
@@ -6609,6 +6609,20 @@ Apologies for any names omitted.
addresses in message headers. The limit is expressed as a
number of tokens. File: global/tok822_parse.c
20020608
Feature: user@domain transport map lookup, based on code
by Scott Cotton, from several years ago. Adding this code
now was much less painful than it was in the past. Files:
global/strip_addr.c, trivial-rewrite/transport.c.
20020610
Cleanup: making user@domain transport map lookups work with
sender-based routing was a bit tricky, because the null
address must be handled sensibly. Files: global/resolve_clnt.c,
trivial-rewrite/resolve.c. It ain't perfect yet, but close.
Open problems:
Medium: old maildrop files are no longer readable by the

View File

@@ -18,7 +18,7 @@ makefiles Makefiles:
done;
rm -f Makefile; (set -e; $(SHELL) makedefs && cat Makefile.in) >Makefile
update printfck:
update printfck tests:
set -e; for i in $(DIRS); do \
(set -e; echo "[$$i]"; cd $$i; $(MAKE) $(OPTS) $@ MAKELEVEL=) || exit 1; \
done

View File

@@ -12,6 +12,31 @@ snapshot release). Patches change the patchlevel and the release
date. Snapshots change only the release date, unless they include
the same bugfixes as a patch release.
Incompatible changes with Postfix snapshot 1.1.11-20020610
==========================================================
Regexp-based transport maps now see the entire recipient address
instead of only the destination domain name.
Major changes with Postfix snapshot 1.1.11-20020610
===================================================
A bizarre feature, sender-based routing, that could be useful in
combination with user@domain address lookups in the transport map.
An actually useful feature, user@domain address lookups in the
transport map. This feature also understands address extensions.
Transport maps still support lookup keys in the form of domain
names, but only with non-regexp tables. Specify <> in order to
match the null address. More in the transport(5) manual page.
Together with sender-based routing, and a dual Postfix setup.
user@domain transport map lookups could fulfill people's wishes to
have multiple SMTP personalities for sending and receiving mail,
including bounce processing. Details will have to be hammered out
by users, as Wietse is now completely tied up by other business
for the next three weeks.
Incompatible changes with Postfix snapshot 1.1.11-20020528
==========================================================

View File

@@ -66,10 +66,10 @@ fork_delay = 1s
#
header_size_limit = 102400
# The header_address_token_limit limits the amount of memory and CPU
# that Postfix will spend while rewriting addresses in message headers.
# The limit is expressed as a token count. Tokens beyond the limit are
# discarded.
# The header_address_token_limit limits the amount of memory that
# Postfix will spend while rewriting addresses in message headers.
# The limit is expressed as a token count. Tokens beyond the limit
# are discarded.
#
header_address_token_limit = 10240

View File

@@ -8,7 +8,7 @@
#
# DESCRIPTION
# The optional transport table specifies a mapping from
# domain hierarchies to message delivery transports and/or
# email addresses to message delivery transports and/or
# relay hosts. The mapping is used by the trivial-rewrite(8)
# daemon.
#
@@ -26,7 +26,8 @@
# Alternatively, the table can be provided as a regular-
# expression map where patterns are given as regular expres-
# sions. In that case, the lookups are done in a slightly
# different way as described below.
# different way as described in the section titled "REGULAR
# EXPRESSION TABLES".
#
# TABLE FORMAT
# The format of the transport table is as follows:
@@ -65,6 +66,14 @@
# networked tables such as NIS, LDAP or SQL, patterns are
# tried in the order as listed below:
#
# user+extension@domain transport:nexthop
# Mail for user+extension@domain is delivered through
# transport to nexthop.
#
# user@domain transport:nexthop
# Mail for user@domain is delivered through transport
# to nexthop.
#
# domain transport:nexthop
# Mail for domain is delivered through transport to
# nexthop.
@@ -77,6 +86,11 @@
# ting. Otherwise, a domain name matches itself and
# its subdomains.
#
# NOTE
# The special pattern <> represents the null address, and
# the special pattern * represents any address (i.e. it
# functions as the wild-card pattern).
#
# EXAMPLES
# In order to deliver internal mail directly, while using a
# mail relay for all other mail, specify a null entry for

View File

@@ -118,8 +118,7 @@ machine. The default is to receive mail for the machine itself.
You can specify zero or more domain names, <i>/file/name</i> patterns
and/or <i>type:name</i> lookup tables, separated by whitespace
and/or commas. A <i>/file/name</i> is replaced by its contents;
<i>type:name</i> requests that a table lookup is done, typically
from a <a href="rewrite.html#virtual">virtual</a> database.
<i>type:name</i> requests that a table lookup is done.
<p>

View File

@@ -9,7 +9,7 @@ TRANSPORT(5) TRANSPORT(5)
<b>DESCRIPTION</b>
The optional <b>transport</b> table specifies a mapping from
domain hierarchies to message delivery transports and/or
email addresses to message delivery transports and/or
relay hosts. The mapping is used by the <a href="trivial-rewrite.8.html"><b>trivial-rewrite</b>(8)</a>
daemon.
@@ -27,7 +27,8 @@ TRANSPORT(5) TRANSPORT(5)
Alternatively, the table can be provided as a regular-
expression map where patterns are given as regular expres-
sions. In that case, the lookups are done in a slightly
different way as described below.
different way as described in the section titled "REGULAR
EXPRESSION TABLES".
<b>TABLE</b> <b>FORMAT</b>
The format of the transport table is as follows:
@@ -66,6 +67,14 @@ TRANSPORT(5) TRANSPORT(5)
networked tables such as NIS, LDAP or SQL, patterns are
tried in the order as listed below:
<i>user+extension@domain</i> <i>transport</i>:<i>nexthop</i>
Mail for <i>user+extension@domain</i> is delivered through
<i>transport</i> to <i>nexthop</i>.
<i>user@domain</i> <i>transport</i>:<i>nexthop</i>
Mail for <i>user@domain</i> is delivered through <i>transport</i>
to <i>nexthop</i>.
<i>domain</i> <i>transport</i>:<i>nexthop</i>
Mail for <i>domain</i> is delivered through <i>transport</i> to
<i>nexthop</i>.
@@ -78,6 +87,11 @@ TRANSPORT(5) TRANSPORT(5)
ting. Otherwise, a domain name matches itself and
its subdomains.
<b>NOTE</b>
The special pattern &lt;&gt; represents the null address, and
the special pattern <b>*</b> represents any address (i.e. it
functions as the wild-card pattern).
<b>EXAMPLES</b>
In order to deliver internal mail directly, while using a
mail relay for all other mail, specify a null entry for

View File

@@ -133,6 +133,9 @@ TRIVIAL-REWRITE(8) TRIVIAL-REWRITE(8)
List of tables with <i>domain</i> to (<i>transport,</i> <i>nexthop</i>)
mappings.
<b>transport</b><i>_</i><b>null</b><i>_</i><b>address</b><i>_</i><b>lookup</b><i>_</i><b>key</b>
Lookup key to be used for the null address.
<b>SEE</b> <b>ALSO</b>
<a href="master.8.html">master(8)</a> process manager
syslogd(8) system logging

View File

@@ -12,8 +12,8 @@ format of Postfix transport table
.SH DESCRIPTION
.ad
.fi
The optional \fBtransport\fR table specifies a mapping from domain
hierarchies to message delivery transports and/or relay hosts. The
The optional \fBtransport\fR table specifies a mapping from email
addresses to message delivery transports and/or relay hosts. The
mapping is used by the \fBtrivial-rewrite\fR(8) daemon.
Normally, the \fBtransport\fR table is specified as a text file
@@ -28,7 +28,8 @@ or SQL, the same lookups are done as for ordinary indexed files.
Alternatively, the table can be provided as a regular-expression
map where patterns are given as regular expressions. In that case,
the lookups are done in a slightly different way as described below.
the lookups are done in a slightly different way as described
in the section titled "REGULAR EXPRESSION TABLES".
.SH TABLE FORMAT
.na
.nf
@@ -64,6 +65,13 @@ can also be used with IP addresses instead of hostnames.
With lookups from indexed files such as DB or DBM, or from networked
tables such as NIS, LDAP or SQL, patterns are tried in the order as
listed below:
.IP "\fIuser+extension@domain transport\fR:\fInexthop\fR"
Mail for \fIuser+extension@domain\fR is delivered through
\fItransport\fR to
\fInexthop\fR.
.IP "\fIuser@domain transport\fR:\fInexthop\fR"
Mail for \fIuser@domain\fR is delivered through \fItransport\fR to
\fInexthop\fR.
.IP "\fIdomain transport\fR:\fInexthop\fR"
Mail for \fIdomain\fR is delivered through \fItransport\fR to
\fInexthop\fR.
@@ -73,6 +81,15 @@ Mail for any subdomain of \fIdomain\fR is delivered through
string \fBtransport_maps\fR is not listed in the
\fBparent_domain_matches_subdomains\fR configuration setting.
Otherwise, a domain name matches itself and its subdomains.
.PP
.SH NOTE
.na
.nf
.ad
.fi
The special pattern \fB<>\fR represents the null address, and the
special pattern \fB*\fR represents any address (i.e. it functions
as the wild-card pattern).
.SH EXAMPLES
.na
.nf

View File

@@ -127,6 +127,8 @@ to the destination's mail exchanger.
.IP \fBtransport_maps\fR
List of tables with \fIdomain\fR to (\fItransport, nexthop\fR)
mappings.
.IP \fBtransport_null_address_lookup_key\fR
Lookup key to be used for the null address.
.SH SEE ALSO
.na
.nf

View File

@@ -6,8 +6,8 @@
# SYNOPSIS
# \fBpostmap /etc/postfix/transport\fR
# DESCRIPTION
# The optional \fBtransport\fR table specifies a mapping from domain
# hierarchies to message delivery transports and/or relay hosts. The
# The optional \fBtransport\fR table specifies a mapping from email
# addresses to message delivery transports and/or relay hosts. The
# mapping is used by the \fBtrivial-rewrite\fR(8) daemon.
#
# Normally, the \fBtransport\fR table is specified as a text file
@@ -22,7 +22,8 @@
#
# Alternatively, the table can be provided as a regular-expression
# map where patterns are given as regular expressions. In that case,
# the lookups are done in a slightly different way as described below.
# the lookups are done in a slightly different way as described
# in the section titled "REGULAR EXPRESSION TABLES".
# TABLE FORMAT
# .ad
# .fi
@@ -56,6 +57,13 @@
# With lookups from indexed files such as DB or DBM, or from networked
# tables such as NIS, LDAP or SQL, patterns are tried in the order as
# listed below:
# .IP "\fIuser+extension@domain transport\fR:\fInexthop\fR"
# Mail for \fIuser+extension@domain\fR is delivered through
# \fItransport\fR to
# \fInexthop\fR.
# .IP "\fIuser@domain transport\fR:\fInexthop\fR"
# Mail for \fIuser@domain\fR is delivered through \fItransport\fR to
# \fInexthop\fR.
# .IP "\fIdomain transport\fR:\fInexthop\fR"
# Mail for \fIdomain\fR is delivered through \fItransport\fR to
# \fInexthop\fR.
@@ -65,6 +73,13 @@
# string \fBtransport_maps\fR is not listed in the
# \fBparent_domain_matches_subdomains\fR configuration setting.
# Otherwise, a domain name matches itself and its subdomains.
# .PP
# NOTE
# .ad
# .fi
# The special pattern \fB<>\fR represents the null address, and the
# special pattern \fB*\fR represents any address (i.e. it functions
# as the wild-card pattern).
# EXAMPLES
# .ad
# .fi

View File

@@ -25,6 +25,8 @@ Makefile: Makefile.in
test: $(TESTPROG)
tests: test
update: ../../libexec/$(PROG)
../../libexec/$(PROG): $(PROG)

View File

@@ -29,6 +29,8 @@ Makefile: Makefile.in
test: $(TESTPROG)
tests: test
update: ../../libexec/$(PROG)
../../libexec/$(PROG): $(PROG)

View File

@@ -142,12 +142,10 @@ void cleanup_map11_tree(CLEANUP_STATE *state, TOK822 *tree,
* checking in one place, instead of having error handling code all over
* the place.
*/
#define NO_TOKEN_LIMIT 0
tok822_externalize(temp, tree->head, TOK822_STR_DEFL);
cleanup_map11_external(state, temp, maps, propagate);
tok822_free_tree(tree->head);
tree->head = tok822_scan(STR(temp), &tree->tail, NO_TOKEN_LIMIT);
tree->head = tok822_scan(STR(temp), &tree->tail);
vstring_free(temp);
}

View File

@@ -151,12 +151,10 @@ void cleanup_masquerade_tree(TOK822 *tree, ARGV *masq_domains)
{
VSTRING *temp = vstring_alloc(100);
#define NO_TOKEN_LIMIT 0
tok822_externalize(temp, tree->head, TOK822_STR_DEFL);
cleanup_masquerade_external(temp, masq_domains);
tok822_free_tree(tree->head);
tree->head = tok822_scan(STR(temp), &tree->tail, NO_TOKEN_LIMIT);
tree->head = tok822_scan(STR(temp), &tree->tail);
vstring_free(temp);
}

View File

@@ -170,7 +170,8 @@ static void cleanup_rewrite_sender(CLEANUP_STATE *state, HEADER_OPTS *hdr_opts,
* sender addresses, and regenerate the header line. Finally, pipe the
* result through the header line folding routine.
*/
tree = tok822_parse(vstring_str(header_buf) + strlen(hdr_opts->name) + 1,
tree = tok822_parse_limit(vstring_str(header_buf)
+ strlen(hdr_opts->name) + 1,
var_token_limit);
addr_list = tok822_grep(tree, TOK822_ADDR);
for (tpp = addr_list; *tpp; tpp++) {
@@ -222,7 +223,8 @@ static void cleanup_rewrite_recip(CLEANUP_STATE *state, HEADER_OPTS *hdr_opts,
* recipient addresses, and regenerate the header line. Finally, pipe the
* result through the header line folding routine.
*/
tree = tok822_parse(vstring_str(header_buf) + strlen(hdr_opts->name) + 1,
tree = tok822_parse_limit(vstring_str(header_buf)
+ strlen(hdr_opts->name) + 1,
var_token_limit);
addr_list = tok822_grep(tree, TOK822_ADDR);
for (tpp = addr_list; *tpp; tpp++) {
@@ -501,8 +503,6 @@ static void cleanup_header_done_callback(void *context)
/*
* Add a missing (Resent-)From: header.
*/
#define NO_TOKEN_LIMIT 0
if ((state->headers_seen & (1 << (state->resent[0] ?
HDR_RESENT_FROM : HDR_FROM))) == 0) {
quote_822_local(state->temp1, *state->sender ?
@@ -511,7 +511,7 @@ static void cleanup_header_done_callback(void *context)
state->resent, vstring_str(state->temp1));
if (*state->sender && state->fullname && *state->fullname) {
vstring_sprintf(state->temp1, "(%s)", state->fullname);
token = tok822_parse(vstring_str(state->temp1), NO_TOKEN_LIMIT);
token = tok822_parse(vstring_str(state->temp1));
vstring_strcat(state->temp2, " ");
tok822_externalize(state->temp2, token, TOK822_STR_NONE);
tok822_free_tree(token);

View File

@@ -80,12 +80,10 @@ void cleanup_rewrite_tree(TOK822 *tree)
VSTRING *dst = vstring_alloc(100);
VSTRING *src = vstring_alloc(100);
#define NO_TOKEN_LIMIT 0
tok822_externalize(src, tree->head, TOK822_STR_DEFL);
cleanup_rewrite_external(dst, STR(src));
tok822_free_tree(tree->head);
tree->head = tok822_scan(STR(dst), &tree->tail, NO_TOKEN_LIMIT);
tree->head = tok822_scan(STR(dst), &tree->tail);
vstring_free(dst);
vstring_free(src);
}

View File

@@ -24,6 +24,8 @@ Makefile: Makefile.in
test: $(TESTPROG)
tests: test
$(LIB): $(OBJS)
$(AR) $(ARFL) $(LIB) $?
$(RANLIB) $(LIB)

View File

@@ -8,7 +8,7 @@ WARN = -W -Wformat -Wimplicit -Wmissing-prototypes \
-Wunused
DEFS = -I. -I$(INC_DIR) -D$(SYSTYPE)
CFLAGS = $(DEBUG) $(OPT) $(DEFS)
TESTPROG= quote_821_local error_unalias
TESTPROG=
PROG = error
INC_DIR = ../../include
LIBS = ../../lib/libmaster.a ../../lib/libglobal.a ../../lib/libutil.a
@@ -23,6 +23,8 @@ Makefile: Makefile.in
test: $(TESTPROG)
tests: test
update: ../../libexec/$(PROG)
../../libexec/$(PROG): $(PROG)

View File

@@ -23,6 +23,8 @@ Makefile: Makefile.in
test: $(TESTPROG)
tests: test
update: ../../libexec/$(PROG)
../../libexec/$(PROG): $(PROG)

View File

@@ -19,7 +19,8 @@ SRCS = been_here.c bounce.c canon_addr.c cleanup_strerror.c clnt_stream.c \
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 match_parent_style.c mime_state.c header_token.c
verp_sender.c match_parent_style.c mime_state.c header_token.c \
strip_addr.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 +41,8 @@ OBJS = been_here.o bounce.o canon_addr.o cleanup_strerror.o clnt_stream.o \
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 match_parent_style.o mime_state.o header_token.o
verp_sender.o match_parent_style.o mime_state.o header_token.o \
strip_addr.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 \
@@ -58,7 +60,7 @@ HDRS = been_here.h bounce.h canon_addr.h cleanup_user.h clnt_stream.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 \
match_parent_style.h quote_flags.h mime_state.h header_token.h \
lex_822.h
lex_822.h strip_addr.h
TESTSRC = rec2stream.c stream2rec.c recdump.c
WARN = -W -Wformat -Wimplicit -Wmissing-prototypes \
-Wparentheses -Wstrict-prototypes -Wswitch -Wuninitialized \
@@ -71,7 +73,7 @@ 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
quote_821_local mail_conf_time mime_state strip_addr
LIBS = ../../lib/libutil.a
LIB_DIR = ../../lib
@@ -219,7 +221,13 @@ mime_state: $(LIB) $(LIBS)
$(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: $(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
tok822_test: tok822_parse tok822_parse.in tok822_parse.ref
./tok822_parse <tok822_parse.in >tok822_parse.tmp
@@ -251,6 +259,11 @@ mime_trunc: mime_state mime_trunc.in mime_trunc.ref
diff mime_trunc.ref mime_trunc.tmp
rm -f mime_trunc.tmp
tok822_limit_test: tok822_parse tok822_limit.in tok822_limit.ref
./tok822_parse <tok822_limit.in >tok822_limit.tmp
diff tok822_limit.ref tok822_limit.tmp
rm -f tok822_limit.tmp
printfck: $(OBJS) $(PROG)
rm -rf printfck
mkdir printfck
@@ -259,6 +272,10 @@ 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)
@@ -512,7 +529,7 @@ mail_addr_find.o: ../../include/stringops.h
mail_addr_find.o: ../../include/vstring.h
mail_addr_find.o: ../../include/mymalloc.h
mail_addr_find.o: mail_params.h
mail_addr_find.o: split_addr.h
mail_addr_find.o: strip_addr.h
mail_addr_find.o: mail_addr_find.h
mail_addr_find.o: maps.h
mail_addr_find.o: resolve_local.h
@@ -1070,6 +1087,11 @@ string_list.o: ../../include/sys_defs.h
string_list.o: ../../include/match_list.h
string_list.o: string_list.h
string_list.o: ../../include/match_ops.h
strip_addr.o: strip_addr.c
strip_addr.o: ../../include/sys_defs.h
strip_addr.o: ../../include/mymalloc.h
strip_addr.o: split_addr.h
strip_addr.o: strip_addr.h
sys_exits.o: sys_exits.c
sys_exits.o: ../../include/sys_defs.h
sys_exits.o: ../../include/msg.h

View File

@@ -78,9 +78,7 @@ ARGV *mail_addr_crunch(const char *string, const char *extension)
* the result to external (quoted) form. Optionally apply the extension
* to each address found.
*/
#define NO_TOKEN_LIMIT 0
tree = tok822_parse(string, NO_TOKEN_LIMIT);
tree = tok822_parse(string);
addr_list = tok822_grep(tree, TOK822_ADDR);
for (tpp = addr_list; *tpp; tpp++) {
tok822_externalize(extern_addr, tpp[0]->head, TOK822_STR_DEFL);

View File

@@ -81,7 +81,7 @@
/* Global library. */
#include <mail_params.h>
#include <split_addr.h>
#include <strip_addr.h>
#include <mail_addr_find.h>
#include <resolve_local.h>
@@ -97,7 +97,6 @@ const char *mail_addr_find(MAPS *path, const char *address, char **extp)
const char *result;
char *ratsign = 0;
char *full_key;
char *extent;
char *bare_key;
char *saved_ext;
@@ -108,21 +107,7 @@ const char *mail_addr_find(MAPS *path, const char *address, char **extp)
if (*var_rcpt_delim == 0) {
bare_key = saved_ext = 0;
} else {
bare_key = mystrdup(full_key);
if ((ratsign = strrchr(bare_key, '@')) != 0)
*ratsign = 0;
if ((extent = split_addr(bare_key, *var_rcpt_delim)) != 0) {
extent -= 1;
*extent = *var_rcpt_delim; /* XXX this is unclean */
saved_ext = mystrdup(extent); /* XXX maybe omit delimiter ? */
if (ratsign != 0) {
*ratsign = '@';
memmove(extent, ratsign, strlen(ratsign) + 1);
}
} else {
myfree(bare_key);
bare_key = saved_ext = 0;
}
bare_key = strip_addr(full_key, &saved_ext, *var_rcpt_delim);
}
/*

View File

@@ -1558,6 +1558,10 @@ extern bool var_strict_encoding;
#define DEF_SENDER_ROUTING 0
extern bool var_sender_routing;
#define VAR_XPORT_NULL_KEY "transport_null_address_lookup_key"
#define DEF_XPORT_NULL_KEY "<>"
extern char *var_xport_null_key;
/* LICENSE
/* .ad
/* .fi

View File

@@ -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 "20020605"
#define MAIL_RELEASE_DATE "20020610"
#define VAR_MAIL_VERSION "mail_version"
#define DEF_MAIL_VERSION "1.1.11-" MAIL_RELEASE_DATE

View File

@@ -133,7 +133,7 @@ void resolve_clnt_query(const char *addr, RESOLVE_REPLY *reply)
/*
* Peek at the cache.
*/
if (strcmp(addr, STR(last_addr)) == 0) {
if (*addr && strcmp(addr, STR(last_addr)) == 0) {
vstring_strcpy(reply->transport, STR(last_reply.transport));
vstring_strcpy(reply->nexthop, STR(last_reply.nexthop));
vstring_strcpy(reply->recipient, STR(last_reply.recipient));
@@ -179,7 +179,7 @@ void resolve_clnt_query(const char *addr, RESOLVE_REPLY *reply)
STR(reply->nexthop), STR(reply->recipient));
if (STR(reply->transport)[0] == 0)
msg_warn("%s: null transport result for: <%s>", myname, addr);
else if (STR(reply->recipient)[0] == 0)
else if (STR(reply->recipient)[0] == 0 && *addr != 0)
msg_warn("%s: null recipient result for: <%s>", myname, addr);
else
break;

View File

@@ -0,0 +1,211 @@
/*++
/* NAME
/* strip_addr 3
/* SUMMARY
/* strip extension from full or localpart-only address
/* SYNOPSIS
/* #include <strip_addr.h>
/*
/* char *strip_addr(address, extension, delimiter)
/* const char *address;
/* char **extension;
/* int delimiter;
/* DESCRIPTION
/* strip_addr() takes an address and either returns a null
/* pointer when the address contains no address extension,
/* or returns a copy of the address without address extension.
/* The caller is expected to pass the copy to myfree().
/*
/* Arguments:
/* .IP address
/* Address localpart or user@domain form.
/* .IP extension
/* A null pointer, or the address of a pointer that is set to
/* the address of a dynamic memory copy of the address extension
/* that had to be chopped off.
/* The copy includes the recipient address delimiter.
/* The caller is expected to pass the copy to myfree().
/* .IP delimiter
/* Recipient address delimiter.
/* SEE ALSO
/* split_addr(3) strip extension from localpart
/* LICENSE
/* .ad
/* .fi
/* The Secure Mailer license must be distributed with this software.
/* AUTHOR(S)
/* Wietse Venema
/* IBM T.J. Watson Research
/* P.O. Box 704
/* Yorktown Heights, NY 10598, USA
/*--*/
/* System library. */
#include <sys_defs.h>
#include <string.h>
/* Utility library. */
#include <mymalloc.h>
/* Global library. */
#include <split_addr.h>
#include <strip_addr.h>
/* strip_addr - strip extension from address */
char *strip_addr(const char *full, char **extension, int delimiter)
{
char *ratsign;
char *extent;
char *saved_ext;
char *stripped;
/*
* A quick test to eliminate inputs without delimiter anywhere.
*/
if (delimiter == 0 || strchr(full, delimiter) == 0) {
stripped = saved_ext = 0;
} else {
stripped = mystrdup(full);
if ((ratsign = strrchr(stripped, '@')) != 0)
*ratsign = 0;
if ((extent = split_addr(stripped, delimiter)) != 0) {
extent -= 1;
if (extension) {
*extent = delimiter;
saved_ext = mystrdup(extent);
*extent = 0;
} else
saved_ext = 0;
if (ratsign != 0) {
*ratsign = '@';
memmove(extent, ratsign, strlen(ratsign) + 1);
}
} else {
myfree(stripped);
stripped = saved_ext = 0;
}
}
if (extension)
*extension = saved_ext;
return (stripped);
}
#ifdef TEST
#include <msg.h>
#include <mail_params.h>
char *var_double_bounce_sender = DEF_DOUBLE_BOUNCE;
int main(int unused_argc, char **unused_argv)
{
char *extension;
char *stripped;
int delim = '-';
/*
* Incredible. This function takes only three arguments, and the tests
* already take more lines of code than the code being tested.
*/
stripped = strip_addr("foo", (char **) 0, 0);
if (stripped != 0)
msg_panic("strip_addr botch 1");
stripped = strip_addr("foo", &extension, 0);
if (stripped != 0)
msg_panic("strip_addr botch 2");
if (extension != 0)
msg_panic("strip_addr botch 3");
stripped = strip_addr("foo", (char **) 0, delim);
if (stripped != 0)
msg_panic("strip_addr botch 4");
stripped = strip_addr("foo", &extension, delim);
if (stripped != 0)
msg_panic("strip_addr botch 5");
if (extension != 0)
msg_panic("strip_addr botch 6");
stripped = strip_addr("foo@bar", (char **) 0, 0);
if (stripped != 0)
msg_panic("strip_addr botch 7");
stripped = strip_addr("foo@bar", &extension, 0);
if (stripped != 0)
msg_panic("strip_addr botch 8");
if (extension != 0)
msg_panic("strip_addr botch 9");
stripped = strip_addr("foo@bar", (char **) 0, delim);
if (stripped != 0)
msg_panic("strip_addr botch 10");
stripped = strip_addr("foo@bar", &extension, delim);
if (stripped != 0)
msg_panic("strip_addr botch 11");
if (extension != 0)
msg_panic("strip_addr botch 12");
stripped = strip_addr("foo-ext", (char **) 0, 0);
if (stripped != 0)
msg_panic("strip_addr botch 13");
stripped = strip_addr("foo-ext", &extension, 0);
if (stripped != 0)
msg_panic("strip_addr botch 14");
if (extension != 0)
msg_panic("strip_addr botch 15");
stripped = strip_addr("foo-ext", (char **) 0, delim);
if (stripped == 0)
msg_panic("strip_addr botch 16");
msg_info("wanted: foo-ext -> %s", "foo");
msg_info("strip_addr foo-ext -> %s", stripped);
myfree(stripped);
stripped = strip_addr("foo-ext", &extension, delim);
if (stripped == 0)
msg_panic("strip_addr botch 17");
if (extension == 0)
msg_panic("strip_addr botch 18");
msg_info("wanted: foo-ext -> %s %s", "foo", "-ext");
msg_info("strip_addr foo-ext -> %s %s", stripped, extension);
myfree(stripped);
myfree(extension);
stripped = strip_addr("foo-ext@bar", (char **) 0, 0);
if (stripped != 0)
msg_panic("strip_addr botch 19");
stripped = strip_addr("foo-ext@bar", &extension, 0);
if (stripped != 0)
msg_panic("strip_addr botch 20");
if (extension != 0)
msg_panic("strip_addr botch 21");
stripped = strip_addr("foo-ext@bar", (char **) 0, delim);
if (stripped == 0)
msg_panic("strip_addr botch 22");
msg_info("wanted: foo-ext@bar -> %s", "foo@bar");
msg_info("strip_addr foo-ext@bar -> %s", stripped);
myfree(stripped);
stripped = strip_addr("foo-ext@bar", &extension, delim);
if (stripped == 0)
msg_panic("strip_addr botch 23");
if (extension == 0)
msg_panic("strip_addr botch 24");
msg_info("wanted: foo-ext@bar -> %s %s", "foo@bar", "-ext");
msg_info("strip_addr foo-ext@bar -> %s %s", stripped, extension);
myfree(stripped);
myfree(extension);
return (0);
}
#endif

View File

@@ -0,0 +1,29 @@
#ifndef _STRIP_ADDR_H_INCLUDED_
#define _STRIP_ADDR_H_INCLUDED_
/*++
/* NAME
/* strip_addr 3h
/* SUMMARY
/* strip extension from full address
/* SYNOPSIS
/* #include <strip_addr.h>
/* DESCRIPTION
/* .nf
/* External interface. */
extern char *strip_addr(const char *, char **, int);
/* LICENSE
/* .ad
/* .fi
/* The Secure Mailer license must be distributed with this software.
/* AUTHOR(S)
/* Wietse Venema
/* IBM T.J. Watson Research
/* P.O. Box 704
/* Yorktown Heights, NY 10598, USA
/*--*/
#endif

View File

@@ -0,0 +1,8 @@
unknown: wanted: foo-ext -> foo
unknown: strip_addr foo-ext -> foo
unknown: wanted: foo-ext -> foo -ext
unknown: strip_addr foo-ext -> foo -ext
unknown: wanted: foo-ext@bar -> foo@bar
unknown: strip_addr foo-ext@bar -> foo@bar
unknown: wanted: foo-ext@bar -> foo@bar -ext
unknown: strip_addr foo-ext@bar -> foo@bar -ext

View File

@@ -74,12 +74,15 @@ extern TOK822 **tok822_grep(TOK822 *, int);
/*
* tok822_parse.c
*/
extern TOK822 *tok822_scan(const char *, TOK822 **, int);
extern TOK822 *tok822_scan_limit(const char *, TOK822 **, int);
extern TOK822 *tok822_scan_addr(const char *);
extern TOK822 *tok822_parse(const char *, int);
extern TOK822 *tok822_parse_limit(const char *, int);
extern VSTRING *tok822_externalize(VSTRING *, TOK822 *, int);
extern VSTRING *tok822_internalize(VSTRING *, TOK822 *, int);
#define tok822_scan(cp, ptr) tok822_scan_limit((cp), (ptr), 0)
#define tok822_parse(cp) tok822_parse_limit((cp), 0)
#define TOK822_STR_NONE (0)
#define TOK822_STR_WIPE (1<<0)
#define TOK822_STR_TERM (1<<1)

View File

@@ -0,0 +1 @@
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22

View File

@@ -0,0 +1,91 @@
>>>1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22<<<
Parse tree:
address
atom "1"
OP ","
address
atom "2"
OP ","
address
atom "3"
OP ","
address
atom "4"
OP ","
address
atom "5"
OP ","
address
atom "6"
OP ","
address
atom "7"
OP ","
address
atom "8"
OP ","
address
atom "9"
OP ","
address
atom "10"
OP ","
address
atom "11"
OP ","
address
atom "12"
OP ","
address
atom "13"
OP ","
address
atom "14"
OP ","
address
atom "15"
OP ","
address
atom "16"
OP ","
address
atom "17"
OP ","
address
atom "18"
OP ","
address
atom "19"
OP ","
address
atom "20"
Internalized:
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20
Externalized, no newlines inserted:
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20
Externalized, newlines inserted:
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20

View File

@@ -6,15 +6,22 @@
/* SYNOPSIS
/* #include <tok822.h>
/*
/* TOK822 *tok822_scan(str, tailp, limit)
/* TOK822 *tok822_scan_limit(str, tailp, limit)
/* const char *str;
/* TOK822 **tailp;
/* int limit;
/*
/* TOK822 *tok822_parse(str, limit)
/* TOK822 *tok822_scan(str, tailp)
/* const char *str;
/* TOK822 **tailp;
/*
/* TOK822 *tok822_parse_limit(str, limit)
/* const char *str;
/* int limit;
/*
/* TOK822 *tok822_parse(str)
/* const char *str;
/*
/* TOK822 *tok822_scan_addr(str)
/* const char *str;
/*
@@ -38,6 +45,8 @@
/* tok822_scan() converts the external-form string in \fIstr\fR
/* to a linear token list. The \fItailp\fR argument is a null pointer
/* or receives the pointer value of the last result list element.
/*
/* tok822_scan_limit() implements tok822_scan(), which is a macro.
/* The \fIlimit\fR argument is either zero or an upper bound on the
/* number of tokens produced.
/*
@@ -45,6 +54,8 @@
/* \fIstr\fR to the corresponding token tree. The parser is permissive
/* and will not throw away information that it does not understand.
/* The parser adds missing commas between addresses.
/*
/* tok822_parse_limit() implements tok822_parse(), which is a macro.
/* The \fIlimit\fR argument is either zero or an upper bound on the
/* number of tokens produced.
/*
@@ -320,9 +331,9 @@ static int tok822_append_space(TOK822 *tp)
return (NON_OPERATOR(tp) && NON_OPERATOR(next));
}
/* tok822_scan - tokenize string */
/* tok822_scan_limit - tokenize string */
TOK822 *tok822_scan(const char *str, TOK822 **tailp, int tok_count_limit)
TOK822 *tok822_scan_limit(const char *str, TOK822 **tailp, int tok_count_limit)
{
TOK822 *head = 0;
TOK822 *tail = 0;
@@ -372,9 +383,9 @@ TOK822 *tok822_scan(const char *str, TOK822 **tailp, int tok_count_limit)
return (head);
}
/* tok822_parse - translate external string to token tree */
/* tok822_parse_limit - translate external string to token tree */
TOK822 *tok822_parse(const char *str, int tok_count_limit)
TOK822 *tok822_parse_limit(const char *str, int tok_count_limit)
{
TOK822 *head;
TOK822 *tail;
@@ -390,7 +401,7 @@ TOK822 *tok822_parse(const char *str, int tok_count_limit)
* token list that contains all tokens, we can always convert back to
* string form.
*/
if ((first_token = tok822_scan(str, &last_token, tok_count_limit)) == 0)
if ((first_token = tok822_scan_limit(str, &last_token, tok_count_limit)) == 0)
return (0);
/*
@@ -547,7 +558,7 @@ TOK822 *tok822_scan_addr(const char *addr)
{
TOK822 *tree = tok822_alloc(TOK822_ADDR, (char *) 0);
tree->head = tok822_scan(addr, &tree->tail, 0);
tree->head = tok822_scan(addr, &tree->tail);
return (tree);
}
@@ -598,7 +609,7 @@ int main(int unused_argc, char **unused_argv)
}
if (!isatty(vstream_fileno(VSTREAM_IN)))
vstream_printf(">>>%s<<<\n\n", vstring_str(buf));
list = tok822_parse(vstring_str(buf), TEST_TOKEN_LIMIT);
list = tok822_parse_limit(vstring_str(buf), TEST_TOKEN_LIMIT);
vstream_printf("Parse tree:\n");
tok822_print(list, 0);
vstream_printf("\n");

View File

@@ -53,8 +53,6 @@ TOK822 *tok822_rewrite(TOK822 *addr, const char *how)
* the result. Shipping external form is much simpler than shipping parse
* trees.
*/
#define NO_TOKEN_LIMIT 0
tok822_externalize(input_ext_form, addr->head, TOK822_STR_DEFL);
if (msg_verbose)
msg_info("tok822_rewrite: input: %s", vstring_str(input_ext_form));
@@ -62,8 +60,7 @@ TOK822 *tok822_rewrite(TOK822 *addr, const char *how)
if (msg_verbose)
msg_info("tok822_rewrite: result: %s", vstring_str(canon_ext_form));
tok822_free_tree(addr->head);
addr->head = tok822_scan(vstring_str(canon_ext_form), &addr->tail,
NO_TOKEN_LIMIT);
addr->head = tok822_scan(vstring_str(canon_ext_form), &addr->tail);
vstring_free(input_ext_form);
vstring_free(canon_ext_form);

View File

@@ -12,7 +12,7 @@ WARN = -W -Wformat -Wimplicit -Wmissing-prototypes \
-Wunused
DEFS = -I. -I$(INC_DIR) -D$(SYSTYPE)
CFLAGS = $(DEBUG) $(OPT) $(DEFS)
TESTPROG= quote_821_local
TESTPROG=
PROG = lmtp
INC_DIR = ../../include
LIBS = ../../lib/libmaster.a ../../lib/libglobal.a ../../lib/libdns.a ../../lib/libutil.a
@@ -27,6 +27,8 @@ Makefile: Makefile.in
test: $(TESTPROG)
tests: test
update: ../../libexec/$(PROG)
../../libexec/$(PROG): $(PROG)
@@ -49,9 +51,6 @@ clean:
tidy: clean
quote_821_local: quote_821_local.c $(LIBS)
$(CC) $(CFLAGS) -DTEST -o $@ $@.c $(LIBS) $(SYSLIBS)
depend: $(MAKES)
(sed '1,/^# do not edit/!d' Makefile.in; \
set -e; for i in [a-z][a-z0-9]*.c; do \

View File

@@ -29,6 +29,8 @@ Makefile: Makefile.in
test: $(TESTPROG)
tests: test
update: ../../libexec/$(PROG)
../../libexec/$(PROG): $(PROG)

View File

@@ -177,9 +177,7 @@ int deliver_token_string(LOCAL_STATE state, USER_ATTR usr_attr,
if (msg_verbose)
msg_info("deliver_token_string: %s", string);
#define NO_TOKEN_LIMIT 0
tree = tok822_parse(string, NO_TOKEN_LIMIT);
tree = tok822_parse(string);
for (addr = tree; addr != 0; addr = addr->next) {
if (addr->type == TOK822_ADDR) {
if (addr_count)

View File

@@ -35,6 +35,8 @@ $(PROG): $(OBJS) $(LIBS)
test: $(TESTPROG)
tests: test
$(LIB): $(LIB_OBJ)
$(AR) $(ARFL) $(LIB) $?
$(RANLIB) $(LIB)

View File

@@ -29,6 +29,8 @@ Makefile: Makefile.in
test: $(TESTPROG)
tests: test
update: ../../libexec/n$(PROG)
../../libexec/n$(PROG): $(PROG)

View File

@@ -654,6 +654,11 @@ static void qmgr_message_resolve(QMGR_MESSAGE *message)
if (!STREQ(recipient->address, STR(reply.recipient)))
UPDATE(recipient->address, STR(reply.recipient));
}
if (recipient->address[0] == 0) {
qmgr_bounce_recipient(message, recipient,
"null recipient address");
continue;
}
/*
* XXX The nexthop destination is also used as lookup key for the

View File

@@ -23,6 +23,8 @@ Makefile: Makefile.in
test: $(TESTPROG)
tests: test
update: ../../libexec/$(PROG)
../../libexec/$(PROG): $(PROG)

View File

@@ -8,7 +8,7 @@ WARN = -W -Wformat -Wimplicit -Wmissing-prototypes \
-Wunused
DEFS = -I. -I$(INC_DIR) -D$(SYSTYPE)
CFLAGS = $(DEBUG) $(OPT) $(DEFS)
TESTPROG= quote_821_local pipe_unalias
TESTPROG=
PROG = pipe
INC_DIR = ../../include
LIBS = ../../lib/libmaster.a ../../lib/libglobal.a ../../lib/libutil.a
@@ -23,6 +23,8 @@ Makefile: Makefile.in
test: $(TESTPROG)
tests: test
update: ../../libexec/$(PROG)
../../libexec/$(PROG): $(PROG)

View File

@@ -23,7 +23,7 @@ Makefile: Makefile.in
update: ../../bin/$(PROG)
test: test1 test2
tests: test1 test2
test1: $(PROG) map.in map-abc1.ref map-ghi1.ref map-ABC1.ref
./$(PROG) map.in

View File

@@ -249,10 +249,7 @@ static void postalias(char *map_type, char *path_name, int postalias_flags,
* Tokenize the input, so that we do the right thing when a quoted
* localpart contains special characters such as "@", ":" and so on.
*/
#define NO_TOKEN_LIMIT 0
if ((tok_list = tok822_scan(STR(line_buffer), (TOK822 **) 0,
NO_TOKEN_LIMIT)) == 0)
if ((tok_list = tok822_scan(STR(line_buffer), (TOK822 **) 0)) == 0)
continue;
/*

View File

@@ -23,6 +23,8 @@ Makefile: Makefile.in
test: $(TESTPROG)
tests: test
update: ../../bin/$(PROG)
../../bin/$(PROG): $(PROG)

View File

@@ -33,6 +33,8 @@ Makefile: Makefile.in
test: $(TESTPROG)
tests: test
update: ../../bin/$(PROG) $(SAMPLES)
../../bin/$(PROG): $(PROG)

View File

@@ -23,6 +23,8 @@ Makefile: Makefile.in
test: $(TESTPROG)
tests: test
update: ../../bin/$(PROG)
../../bin/$(PROG): $(PROG)

View File

@@ -24,6 +24,8 @@ Makefile: Makefile.in
test: $(TESTPROG)
tests: test
update: ../../bin/$(PROG)
../../bin/$(PROG): $(PROG)

View File

@@ -23,6 +23,8 @@ Makefile: Makefile.in
test: $(TESTPROG)
tests: test
update: ../../bin/$(PROG)
../../bin/$(PROG): $(PROG)

View File

@@ -23,6 +23,8 @@ Makefile: Makefile.in
test: $(TESTPROG)
tests: test
update: ../../bin/$(PROG)
../../bin/$(PROG): $(PROG)

View File

@@ -24,6 +24,8 @@ Makefile: Makefile.in
test: $(TESTPROG)
tests: test
update: ../../bin/$(PROG)
../../bin/$(PROG): $(PROG)

View File

@@ -26,7 +26,7 @@ update: ../../bin/$(PROG)
../../bin/$(PROG): $(PROG)
cp $(PROG) ../../bin
test: test1 test2
tests: test1 test2
test1: $(PROG) map.in map-abc1.ref map-ghi1.ref map-ABC1.ref
./$(PROG) map.in

View File

@@ -23,6 +23,8 @@ Makefile: Makefile.in
test: $(TESTPROG)
tests: test
update: ../../bin/$(PROG)
../../bin/$(PROG): $(PROG)

View File

@@ -23,6 +23,8 @@ Makefile: Makefile.in
test: $(TESTPROG)
tests: test
update: ../../bin/$(PROG)
../../bin/$(PROG): $(PROG)

View File

@@ -27,6 +27,8 @@ Makefile: Makefile.in
test: $(TESTPROG)
tests: test
update: ../../libexec/$(PROG)
../../libexec/$(PROG): $(PROG)

View File

@@ -534,6 +534,11 @@ static void qmgr_message_resolve(QMGR_MESSAGE *message)
if (!STREQ(recipient->address, STR(reply.recipient)))
UPDATE(recipient->address, STR(reply.recipient));
}
if (recipient->address[0] == 0) {
qmgr_bounce_recipient(message, recipient,
"null recipient address");
continue;
}
/*
* XXX The nexthop destination is also used as lookup key for the

View File

@@ -8,7 +8,7 @@ WARN = -W -Wformat -Wimplicit -Wmissing-prototypes \
-Wunused
DEFS = -I. -I$(INC_DIR) -D$(SYSTYPE)
CFLAGS = $(DEBUG) $(OPT) $(DEFS)
TESTPROG= qmqpd_token qmqpd_check
TESTPROG=
PROG = qmqpd
INC_DIR = ../../include
LIBS = ../../lib/libmaster.a ../../lib/libglobal.a ../../lib/libdns.a ../../lib/libutil.a
@@ -23,6 +23,8 @@ Makefile: Makefile.in
test: $(TESTPROG)
tests: test
update: ../../libexec/$(PROG)
../../libexec/$(PROG): $(PROG)
@@ -64,8 +66,6 @@ depend: $(MAKES)
done) | grep -v '[.][o][:][ ][/]' >$$$$ && mv $$$$ Makefile.in
@$(EXPORT) make -f Makefile.in Makefile 1>&2
tests:
# do not edit below this line - it is generated by 'make depend'
qmqpd.o: qmqpd.c
qmqpd.o: ../../include/sys_defs.h

View File

@@ -23,6 +23,8 @@ Makefile: Makefile.in
test: $(TESTPROG)
tests: test
update: ../../bin/$(PROG)
../../bin/$(PROG): $(PROG)

View File

@@ -379,10 +379,8 @@ static void enqueue(const int flags, const char *encoding, const char *sender,
* pickup would not be able to run chrooted, and it may not be desirable
* to use login names at all.
*/
#define NO_TOKEN_LIMIT 0
if (sender != 0) {
tree = tok822_parse(sender, NO_TOKEN_LIMIT);
tree = tok822_parse(sender);
for (naddr = 0, tp = tree; tp != 0; tp = tp->next)
if (tp->type == TOK822_ADDR)
naddr++, tok822_internalize(buf, tp->head, TOK822_STR_DEFL);
@@ -435,7 +433,7 @@ static void enqueue(const int flags, const char *encoding, const char *sender,
rec_fputs(dst, REC_TYPE_VERP, verp_delims);
if (recipients) {
for (cpp = recipients; *cpp != 0; cpp++) {
tree = tok822_parse(*cpp, NO_TOKEN_LIMIT);
tree = tok822_parse(*cpp);
for (tp = tree; tp != 0; tp = tp->next) {
if (tp->type == TOK822_ADDR) {
tok822_internalize(buf, tp->head, TOK822_STR_DEFL);

View File

@@ -23,6 +23,8 @@ Makefile: Makefile.in
test: $(TESTPROG)
tests: test
update: ../../libexec/$(PROG)
../../libexec/$(PROG): $(PROG)

View File

@@ -27,6 +27,8 @@ Makefile: Makefile.in
test: $(TESTPROG)
tests: test
update: ../../libexec/$(PROG)
../../libexec/$(PROG): $(PROG)

View File

@@ -196,7 +196,7 @@ smtpd_check.o: ../../include/mail_conf.h
smtpd_check.o: ../../include/maps.h
smtpd_check.o: ../../include/mail_addr_find.h
smtpd_check.o: ../../include/match_parent_style.h
smtpd_check.o: ../../include/split_addr.h
smtpd_check.o: ../../include/strip_addr.h
smtpd_check.o: smtpd.h
smtpd_check.o: ../../include/mail_stream.h
smtpd_check.o: smtpd_sasl_glue.h

View File

@@ -591,17 +591,15 @@ static char *extract_addr(SMTPD_STATE *state, SMTPD_TOKEN *arg,
* XXX We have only one address parser, written according to the rules of
* RFC 822. That standard differs subtly from RFC 821.
*/
#define NO_TOKEN_LIMIT 0
if (msg_verbose)
msg_info("%s: input: %s", myname, STR(arg->vstrval));
if (STR(arg->vstrval)[0] == '<'
&& STR(arg->vstrval)[LEN(arg->vstrval) - 1] == '>') {
junk = mystrndup(STR(arg->vstrval) + 1, LEN(arg->vstrval) - 2);
tree = tok822_parse(junk, NO_TOKEN_LIMIT);
tree = tok822_parse(junk);
myfree(junk);
} else
tree = tok822_parse(STR(arg->vstrval), NO_TOKEN_LIMIT);
tree = tok822_parse(STR(arg->vstrval));
/*
* Find trouble.

View File

@@ -78,9 +78,17 @@ mail bad-sender@ok.domain
recipient_restrictions hash:./smtpd_check_access
# Expect: REJECT
rcpt reject@dunno.domain
# Expect: REJECT
recipient_delimiter +
rcpt reject+ext@dunno.domain
recipient_delimiter |
# Expect: OK
rcpt ok@dunno.domain
# Expect: OK
recipient_delimiter +
rcpt ok+ext@dunno.domain
recipient_delimiter |
# Expect: OK
rcpt anyone@dunno.domain
# Expect: OK
rcpt bad-sender@dunno.domain

View File

@@ -121,10 +121,25 @@ OK
>>> rcpt reject@dunno.domain
./smtpd_check: reject: RCPT from bar.duno.com[44.33.44.33]: 554 <reject@dunno.domain>: Recipient address rejected: Access denied; from=<bad-sender@ok.domain> to=<reject@dunno.domain>
554 <reject@dunno.domain>: Recipient address rejected: Access denied
>>> # Expect: REJECT
>>> recipient_delimiter +
OK
>>> rcpt reject+ext@dunno.domain
./smtpd_check: reject: RCPT from bar.duno.com[44.33.44.33]: 554 <reject+ext@dunno.domain>: Recipient address rejected: Access denied; from=<bad-sender@ok.domain> to=<reject+ext@dunno.domain>
554 <reject+ext@dunno.domain>: Recipient address rejected: Access denied
>>> recipient_delimiter |
OK
>>> # Expect: OK
>>> rcpt ok@dunno.domain
OK
>>> # Expect: OK
>>> recipient_delimiter +
OK
>>> rcpt ok+ext@dunno.domain
OK
>>> recipient_delimiter |
OK
>>> # Expect: OK
>>> rcpt anyone@dunno.domain
OK
>>> # Expect: OK

View File

@@ -290,7 +290,7 @@
#include <maps.h>
#include <mail_addr_find.h>
#include <match_parent_style.h>
#include <split_addr.h>
#include <strip_addr.h>
/* Application-specific. */
@@ -1717,7 +1717,6 @@ static int check_mail_access(SMTPD_STATE *state, const char *table,
int status;
char *local_at;
char *bare_addr;
char *bare_ext;
char *bare_at;
if (msg_verbose)
@@ -1745,19 +1744,7 @@ static int check_mail_access(SMTPD_STATE *state, const char *table,
if (*var_rcpt_delim == 0) {
bare_addr = 0;
} else {
bare_addr = mystrdup(addr);
if ((bare_at = strrchr(bare_addr, '@')) != 0)
*bare_at = 0;
if ((bare_ext = split_addr(bare_addr, *var_rcpt_delim)) != 0) {
if (bare_at != 0) {
*bare_at = '@';
memmove(bare_ext - 1, bare_at, strlen(bare_at) + 1);
bare_at = bare_ext - 1;
}
} else {
myfree(bare_addr);
bare_addr = 0;
}
bare_addr = strip_addr(addr, (char **) 0, *var_rcpt_delim);
}
#define CHECK_MAIL_ACCESS_RETURN(x) \
@@ -1824,6 +1811,7 @@ static int check_mail_access(SMTPD_STATE *state, const char *table,
* Look up user@ if the address has an extension. XXX Same problem here.
*/
if (bare_addr) {
bare_at = strrchr(bare_addr, '@');
local_at = (bare_at ? mystrndup(bare_addr, bare_at + 1 - bare_addr) :
mystrdup(bare_addr));
status = check_access(state, table, local_at, PARTIAL, found,
@@ -2623,6 +2611,7 @@ char *var_perm_mx_networks;
char *var_par_dom_match;
char *var_smtpd_null_key;
char *var_smtpd_snd_auth_maps;
char *var_double_bounce_sender;
typedef struct {
char *name;
@@ -2648,6 +2637,7 @@ static STRING_TABLE string_table[] = {
VAR_PAR_DOM_MATCH, DEF_PAR_DOM_MATCH, &var_par_dom_match,
VAR_SMTPD_SND_AUTH_MAPS, DEF_SMTPD_SND_AUTH_MAPS, &var_smtpd_snd_auth_maps,
VAR_SMTPD_NULL_KEY, DEF_SMTPD_NULL_KEY, &var_smtpd_null_key,
VAR_DOUBLE_BOUNCE, DEF_DOUBLE_BOUNCE, &var_double_bounce_sender,
0,
};
@@ -2812,10 +2802,10 @@ void resolve_clnt_free(RESOLVE_REPLY *reply)
vstring_free(reply->recipient);
}
#ifdef USE_SASL_AUTH
bool var_smtpd_sasl_enable = 0;
#ifdef USE_SASL_AUTH
/* smtpd_sasl_connect - stub */
void smtpd_sasl_connect(SMTPD_STATE *state)

View File

@@ -34,6 +34,8 @@ qmqp-source: qmqp-source.o $(LIBS)
test: $(TESTPROG)
tests: test
update: ../../bin/smtp-source ../../bin/smtp-sink ../../bin/qmqp-source
../../bin/smtp-source: smtp-source

View File

@@ -23,6 +23,8 @@ Makefile: Makefile.in
test: $(TESTPROG)
tests: test
update: ../../libexec/$(PROG)
../../libexec/$(PROG): $(PROG)

View File

@@ -28,6 +28,8 @@ Makefile: Makefile.in
test: $(TESTPROG)
tests: test
$(BIN_DIR)/$(PROG): $(PROG)
cp $(PROG) $@
@@ -109,6 +111,7 @@ transport.o: ../../include/split_at.h
transport.o: ../../include/dict.h
transport.o: ../../include/vstream.h
transport.o: ../../include/argv.h
transport.o: ../../include/strip_addr.h
transport.o: ../../include/mail_params.h
transport.o: ../../include/maps.h
transport.o: ../../include/match_parent_style.h

View File

@@ -134,13 +134,10 @@ void resolve_addr(char *addr, VSTRING *channel, VSTRING *nexthop,
/*
* A lone empty string becomes the postmaster.
*/
#define NO_TOKEN_LIMIT 0
if (tree->head == tree->tail && tree->head->type == TOK822_QSTRING
&& VSTRING_LEN(tree->head->vstr) == 0) {
tok822_free(tree->head);
tree->head = tok822_scan(MAIL_ADDR_POSTMASTER, &tree->tail,
NO_TOKEN_LIMIT);
tree->head = tok822_scan(MAIL_ADDR_POSTMASTER, &tree->tail);
rewrite_tree(REWRITE_CANON, tree);
}
@@ -196,10 +193,9 @@ void resolve_addr(char *addr, VSTRING *channel, VSTRING *nexthop,
if (saved_domain) {
tok822_sub_append(tree, saved_domain);
saved_domain = 0;
} else {
} else if (tree->head) {
tok822_sub_append(tree, tok822_alloc('@', (char *) 0));
tok822_sub_append(tree, tok822_scan(var_myhostname, (TOK822 **) 0,
NO_TOKEN_LIMIT));
tok822_sub_append(tree, tok822_scan(var_myhostname, (TOK822 **) 0));
}
}
tok822_internalize(nextrcpt, tree, TOK822_STR_DEFL);
@@ -247,7 +243,7 @@ void resolve_addr(char *addr, VSTRING *channel, VSTRING *nexthop,
* transport maps cannot return zero-length hostnames.
*/
if (*var_transport_maps)
transport_lookup(strrchr(STR(nextrcpt), '@') + 1, channel, nexthop);
transport_lookup(STR(nextrcpt), channel, nexthop);
/*
* Clean up.

View File

@@ -151,12 +151,9 @@ void rewrite_tree(char *unused_ruleset, TOK822 *tree)
/*
* Append missing @origin
*/
#define NO_TOKEN_LIMIT 0
else if (var_append_at_myorigin != 0) {
domain = tok822_sub_append(tree, tok822_alloc('@', (char *) 0));
tok822_sub_append(tree, tok822_scan(var_myorigin, (TOK822 **) 0,
NO_TOKEN_LIMIT));
tok822_sub_append(tree, tok822_scan(var_myorigin, (TOK822 **) 0));
}
}
@@ -168,8 +165,7 @@ void rewrite_tree(char *unused_ruleset, TOK822 *tree)
&& tok822_find_type(domain, TOK822_DOMLIT) == 0
&& tok822_find_type(domain, '.') == 0) {
tok822_sub_append(tree, tok822_alloc('.', (char *) 0));
tok822_sub_append(tree, tok822_scan(var_mydomain, (TOK822 **) 0,
NO_TOKEN_LIMIT));
tok822_sub_append(tree, tok822_scan(var_mydomain, (TOK822 **) 0));
}
/*

View File

@@ -8,13 +8,13 @@
/*
/* void transport_init()
/*
/* int transport_lookup(domain, channel, nexthop)
/* const char *domain;
/* int transport_lookup(address, channel, nexthop)
/* const char *address;
/* VSTRING *channel;
/* VSTRING *nexthop;
/* DESCRIPTION
/* This module implements access to the table that maps transport
/* domains to (channel, nexthop) tuples.
/* user@domain addresses to (channel, nexthop) tuples.
/*
/* transport_init() performs initializations that should be
/* done before the process enters the chroot jail, and
@@ -28,6 +28,7 @@
/* should be tried again.
/* SEE ALSO
/* maps(3), multi-dictionary search
/* strip_addr(3), strip extension from address
/* transport(5), format of transport map
/* FILES
/* /etc/postfix/transport*
@@ -60,6 +61,7 @@
/* Global library. */
#include <strip_addr.h>
#include <mail_params.h>
#include <maps.h>
#include <match_parent_style.h>
@@ -104,11 +106,24 @@ void transport_wildcard_init(void)
}
}
/* check_maps_find - map lookup with extreme prejudice */
static const char *check_maps_find(MAPS *maps, const char *key, int flags)
{
const char *value;
if ((value = maps_find(maps, key, flags)) == 0 && dict_errno != 0)
msg_fatal("transport table lookup problem.");
return (value);
}
/* transport_lookup - map a transport domain */
int transport_lookup(const char *domain, VSTRING *channel, VSTRING *nexthop)
int transport_lookup(const char *addr, VSTRING *channel, VSTRING *nexthop)
{
char *low_domain = lowercase(mystrdup(domain));
char *full_addr = lowercase(mystrdup(*addr ? addr : var_xport_null_key));
char *stripped_addr = 0;
char *ratsign = 0;
const char *name;
const char *next;
const char *value;
@@ -119,51 +134,102 @@ int transport_lookup(const char *domain, VSTRING *channel, VSTRING *nexthop)
#define FULL 0
#define PARTIAL DICT_FLAG_FIXED
int maps_flag = FULL;
#define STRNE strcmp
#define DISCARD_EXTENSION ((char **) 0)
if (transport_path == 0)
msg_panic("transport_lookup: missing initialization");
if (STRNE(full_addr, var_xport_null_key) && STRNE(full_addr, "*"))
if ((ratsign = strrchr(full_addr, '@')) == 0)
msg_panic("transport_lookup: bad address: \"%s\"", full_addr);
/*
* Look up the full address with the FULL flag to include regexp maps in
* the query.
*/
if ((value = check_maps_find(transport_path, full_addr, FULL)) != 0) {
found = 1;
}
/*
* If this is a special address such as <> or *, not user@domain, then we
* are done now.
*/
else if (ratsign == 0) {
found = 0;
}
/*
* If the full address did not match, and there is an address extension,
* look up the stripped address with the PARTIAL flag to avoid matching
* partial lookup keys with regular expressions.
*/
else if ((stripped_addr = strip_addr(full_addr, DISCARD_EXTENSION,
*var_rcpt_delim)) != 0
&& (value = check_maps_find(transport_path, stripped_addr,
PARTIAL)) != 0) {
found = 1;
}
/*
* If the full and stripped address lookup fails, try domain name lookup.
*
* Keep stripping domain components until nothing is left or until a
* matching entry is found.
*
* If the entry specifies no nexthop host and/or delivery channel, do not
* change caller-provided information.
*
* If we find no match, then return the wildcard entry, if any.
*
* After checking the full name, check for .upper.domain, to distinguish
* between the upper domain and it's decendants, ala sendmail and tcp
* wrappers.
* After checking the full domain name, check for .upper.domain, to
* distinguish between the parent domain and it's decendants, a la
* sendmail and tcp wrappers.
*
* Before changing the DB lookup result, make a copy first, in order to
* avoid DB cache corruption.
*
* Specify if a key is partial or full, to avoid matching partial keys with
* regular expressions.
* Specify that the lookup key is partial, to avoid matching partial keys
* with regular expressions.
*/
for (name = low_domain; /* void */ ; name = next) {
if ((value = maps_find(transport_path, name, maps_flag)) != 0) {
saved_value = mystrdup(value);
if ((host = split_at(saved_value, ':')) != 0 && *host != 0)
vstring_strcpy(nexthop, host);
if (*(transport = saved_value) != 0)
vstring_strcpy(channel, transport);
myfree(saved_value);
else if (found == 0) {
for (name = ratsign + 1; /* void */ ; name = next) {
if ((value = maps_find(transport_path, name, PARTIAL)) != 0) {
found = 1;
break;
} else if (dict_errno != 0) {
msg_fatal("transport table lookup problem");
}
if ((next = strchr(name + 1, '.')) == 0)
break;
if (transport_match_parent_style == MATCH_FLAG_PARENT)
next++;
maps_flag = PARTIAL;
}
myfree(low_domain);
}
/*
* XXX user+ext@ and user@ lookups for domains that resolve locally?
*/
/*
* We found an answer in the transport table. Use the results to
* override transport and/or next-hop information.
*/
if (found == 1) {
saved_value = mystrdup(value);
if ((host = split_at(saved_value, ':')) != 0 && *host != 0) {
#if 0
if (strchr(host, '@'))
vstring_strcpy(recipient, host);
else
#endif
vstring_strcpy(nexthop, host);
}
if (*(transport = saved_value) != 0)
vstring_strcpy(channel, transport);
myfree(saved_value);
}
/*
* Clean up.
*/
myfree(full_addr);
if (stripped_addr)
myfree(stripped_addr);
/*
* Fall back to the wild-card entry.

View File

@@ -111,6 +111,8 @@
/* .IP \fBtransport_maps\fR
/* List of tables with \fIdomain\fR to (\fItransport, nexthop\fR)
/* mappings.
/* .IP \fBtransport_null_address_lookup_key\fR
/* Lookup key to be used for the null address.
/* SEE ALSO
/* master(8) process manager
/* syslogd(8) system logging
@@ -174,6 +176,7 @@ bool var_append_at_myorigin;
bool var_percent_hack;
char *var_local_transport;
int var_resolve_dequoted;
char *var_xport_null_key;
/* rewrite_service - read request and send reply */
@@ -239,6 +242,7 @@ int main(int argc, char **argv)
static CONFIG_STR_TABLE str_table[] = {
VAR_TRANSPORT_MAPS, DEF_TRANSPORT_MAPS, &var_transport_maps, 0, 0,
VAR_LOCAL_TRANSPORT, DEF_LOCAL_TRANSPORT, &var_local_transport, 0, 0,
VAR_XPORT_NULL_KEY, DEF_XPORT_NULL_KEY, &var_xport_null_key, 1, 0,
0,
};
static CONFIG_BOOL_TABLE bool_table[] = {

View File

@@ -23,6 +23,8 @@ Makefile: Makefile.in
test: $(TESTPROG)
tests: test
update: ../../libexec/$(PROG)
../../libexec/$(PROG): $(PROG)