From 8343a356bb4d2f91f135a1e52e0902f9f1100a3b Mon Sep 17 00:00:00 2001 From: Matthias Andree Date: Mon, 7 Aug 2006 10:23:24 +0000 Subject: Support user@example.org (full-address) mappings for multidrop on the left-hand side of mappings. svn path=/branches/BRANCH_6-3/; revision=4885 --- transact.c | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) (limited to 'transact.c') diff --git a/transact.c b/transact.c index f29fa5b9..88a5aacf 100644 --- a/transact.c +++ b/transact.c @@ -55,18 +55,33 @@ int mytimeout; /* value of nonreponse timeout */ struct msgblk msgblk; static int accept_count, reject_count; +/** add given address to xmit_names if it exactly matches a full address + * \returns nonzero if matched */ +static int map_address(const char *addr, struct query *ctl, struct idlist **xmit_names) +{ + const char *lname; + + lname = idpair_find(&ctl->localnames, addr); + if (lname) { + if (outlevel >= O_DEBUG) + report(stdout, GT_("mapped address %s to local %s\n"), addr, lname); + save_str(xmit_names, lname, XMIT_ACCEPT); + accept_count++; + } + return lname != NULL; +} + +/** add given name to xmit_names if it matches declared localnames */ static void map_name(const char *name, struct query *ctl, struct idlist **xmit_names) -/* add given name to xmit_names if it matches declared localnames */ /* name: name to map */ /* ctl: list of permissible aliases */ /* xmit_names: list of recipient names parsed out */ { const char *lname; - int off = 0; - - lname = idpair_find(&ctl->localnames, name+off); + + lname = idpair_find(&ctl->localnames, name); if (!lname && ctl->wildcard) - lname = name+off; + lname = name; if (lname != (char *)NULL) { @@ -119,6 +134,11 @@ static void find_server_names(const char *hdr, if ((atsign = strchr((char *)cp, '@'))) { struct idlist *idp; + /* try to match full address first, this takes + * precedence over localdomains and alias mappings */ + if (map_address(cp, ctl, xmit_names)) + goto nomap; + /* * Does a trailing segment of the hostname match something * on the localdomains list? If so, save the whole name -- cgit v1.2.3