Path: utzoo!attcan!uunet!aplcen!uakari.primate.wisc.edu!zaphod.mps.ohio-state.edu!uwm.edu!bionet!arisia!roo!zany.EuroPARC.Xerox.COM!lovstran From: Lovstrand.EuroPARC@Xerox.COM (Lennart Lovstrand) Newsgroups: comp.mail.sendmail Subject: Re: The algorithm for rewriting rules Message-ID: <423@roo.UUCP> Date: 6 Jun 90 15:53:58 GMT References: <1990May31.152505.28721@sun.soe.clarkson.edu> <1990Jun5.173609.15672@fts1.uucp> Sender: news@parc.xerox.com Organization: Rank Xerox EuroPARC, Cambridge, UK. Lines: 85 In article <1990Jun5.173609.15672@fts1.uucp> michael@fts1.uucp (Michael Richardson) writes: > My experience with ruleset 3 is that an address like: > > Joe Blow > > is turned into: > jb<@foo.bar.com> > > In the case of the To:/From: addresses, obviously we want to > keep the "comment" [striping out () comments and replacing them > is fairly easy] intact, while still rewriting the address portion. > This is confounded by the existance of multiple addresses. Don't worry, the comment part of each header address is extracted by crackaddr() {in headers.c} and then tucked away in the the header structure. Both header and envelope addresses are independently parsed by prescan() {in parseaddr.c}, which removes comments but retains angle brackets. This is then rewritten by a sequence of calls to rewrite(). The headers are finally recomposed by splicing the rewritten address back in to its comment context. Or in other words (pictures, diagrams, whatever): # # From chapter 42 of: # "Sendmail and other mysteries explained in twenty minutes or less" # # Section 11: How addresses /really/ are parsed. # # ENVELOPE ADDRESSES # Called from parseaddr() with the raw envelope address as supplied on the # command line or given in the SMTP MAIL FROM:/RCPT TO: command. # "bar.baz.org!foo" => prescan() => "bar" "." "baz" "." "org" "!" "foo" => rewrite(3, 0) => $# "tcp" $@ "baz" "." org" $: "foo" "@" "bar" "." "baz" "." "org" => buildaddr() -> rewrite(2, [mailer specific if IDA], 4) => "foo" "@" "bar" "." "baz" "." "org" => cataddr() => "foo@bar.baz.org" # # HEADER ADDRESSES # Called from putheader() -> commaize() -> remotename() with the value of # header fields such as From:, To:, Resent-Reply-To:, etc. # "Jan Foo (SysOp)" => crackaddr() => "Jan Foo <$g> (SysOp)" # # Note the use of the $g macro # # And at the same time (well, almost): # "Jan Foo (SysOp)" => prescan() => "" => rewrite(3, 1/2 [or 5/6 if IDA], [mailer specific if IDA], 4) => "foo" "@" "bar" "." "baz" "." "org" => cataddr() => "foo@bar.baz.org" # # Finally, with both results above: # => expand() => "Jan Foo (SysOp)" # # And we're back to what we started from, voila! # Of course, the addresses would change rather substantially if the source and destination mailers were on two completely different networks, but I think you get the gist. Exactly what you see as the result of rewrite(3, 0) is also up to grabs: standard UCB sendmail will enclose the immediate destination address in angle brackets; IDA sendmail will append a dot after the atsign and make sure that there is nothing after the domain. -- --Lennart R _A _ N_ K Rank Xerox EuroPARC, 61 Regent St \/ |_ |_) | | \/ Cambridge, CB2 1AB, United Kingdom /\ |_ | \ |_| /\ QOTW: "Missing keyboard; hit F1 to continue." E u r o P A R C