[comp.mail.sendmail] rulesets after resolved in ruleset 0

barnett@crdgw1.crd.ge.com (Bruce Barnett) (03/15/89)

A simple question. After ruleset 0 resolves an address
into a mailer, host, user triplet, what exactly is passed to
the sender/recipient rulesets? Is it just the user part?
Or the entire triplet?

Say I have a UUCP address, and I want to see how the address is re-written.
Say  the recipient ruleset for the UUCP mailer is 25. I would think
that I could test this by using debug mode and giving it
	> 0,25,4 user@machine.UUCP

I seem to have a conceptual problem, because the debugger tells me:
rewrite: ruleset  4   input: "^V" "uucpmailer" "^W" "machine" "^X" "user"

Now this implies the ^V ( or $# ) is passed to the other rulesets.
Is this true?  Would I have problems if my UUCP mailer is called UUCP,
and the domain is called UUCP?

If my assumption is wrong, how DO I test the rulesets for converting
a local address into a pure UUCP address?

What rulesets do the SMTP envelope go through? I think envelope is the
correct word. I mean the RCPT TO: <user@machine> and MAIL FROM: < >
lines. I don't mean the IDA sendmail, but the old beast.

--
	Bruce G. Barnett 	barnett@ge-crd.ARPA, barnett@steinmetz.ge.com
				uunet!steinmetz!barnett

gandalf@csli.STANFORD.EDU (Juergen Wagner) (03/15/89)

In article <44@crdgw1.crd.ge.com> barnett@crdgw1.crd.ge.com (Bruce Barnett) writes:
>A simple question. After ruleset 0 resolves an address
>into a mailer, host, user triplet, what exactly is passed to
>the sender/recipient rulesets?

It is just the user part. The order is

	3, 0, 2, mailer-specific, 4

#0 produces the triple <mailer,host,user> of which 'user' is passed
on to #2.

>Say I have a UUCP address, and I want to see how the address is re-written.
>Say  the recipient ruleset for the UUCP mailer is 25. I would think
>that I could test this by using debug mode and giving it
>	> 0,25,4 user@machine.UUCP

No. This will pass the entire triple to #4. To check out how an address gets
rewritten, retype the user part, and pass it to #2, the mailer-specific
ruleset, and to #4. (or use -bv with debugging flags)

-- 
Juergen Wagner		   			gandalf@csli.stanford.edu
						 wagner@arisia.xerox.com

mikel@teraida.UUCP (Mikel Lechner) (03/16/89)

In article <44@crdgw1.crd.ge.com> barnett@crdgw1.crd.ge.com (Bruce Barnett) writes:
 >> A simple question. After ruleset 0 resolves an address
 >> into a mailer, host, user triplet, what exactly is passed to
 >> the sender/recipient rulesets? Is it just the user part?
 >> Or the entire triplet?

Only the user part of the triplet is passed to the recipient rulesets.

 >> Say I have a UUCP address, and I want to see how the address is re-written.
 >> Say  the recipient ruleset for the UUCP mailer is 25. I would think
 >> that I could test this by using debug mode and giving it
 >> 	> 0,25,4 user@machine.UUCP

Here's an example:  Let the rewrite rule for your UUCP mailer be 26.
Then after ruleset 0 determines selects this UUCP mailer the "From:",
"To:", and recipient lines are rewritten.  The "From:" line is passed
through 3,1,26,4.  The "To:" line is passed through 3,2,25,4.  The
user part of the triplet (the recipient) is passed through 3,2,25,4.

This means that the recipient address goes through the canonicalization,
etc. twice.  You might think of it as being passed through rulesets
3,0,3,2,25,4.  But as stated above only the user part of the triplet
gets passed from ruleset 0 to the second occurance of ruleset 3.

Unfortunately, you cannot give 0,2,25,4 directly to the sendmail debuger.
If you do, the subsequent rulesets get the mailer and host part of the
triplet, which just confuses things.  You have to do the second pass
throught the rulesets manually.

These comments are based on my experience with sendmail under SunOS 3.2
and 4.0.

Mikel Lechner			UUCP:  {decwrl,sun}!teraida!mikel
Teradyne EDA			Phone: (408) 980-5200
5155 Old Ironsides Drive
Santa Clara, Ca 95054

avolio@decuac.dec.com (Frederick M. Avolio) (03/16/89)

a
Standard Rulesets  (I *think* this is current)

From (envelope)	3, 1, 4, 3, 1, S, 4
To (envelope)	3, 0, 4
From:		3, 1, S, 4
To:, Cc:	3, 2, R, 4

Fred

barnett@crdgw1.crd.ge.com (Bruce Barnett) (03/16/89)

In article <2615@decuac.DEC.COM>, avolio@decuac (Frederick M. Avolio) writes:
>a
>Standard Rulesets  (I *think* this is current)
>
>From (envelope)	3, 1, 4, 3, 1, S, 4
>To (envelope)	3, 0, 4
>From:		3, 1, S, 4
>To:, Cc:	3, 2, R, 4

Thanks Fred. I just want you to know that I have a similar message from you
in ALL of my sendmail files.

I did fix a problem that caused the question, but I still want to make sure
that I understand the sequences of the rules.

The reason is that I want to automate my test suite for sendmail
which I am including in the Ease 2.1 package. It's just a simple
hack, but for people struggling with sendmail files, it should
be useful. It also gives me a way to see if a change in the ruleset
breaks any addresses I use.


I have an input file that looks like this:

0	user@localmachine
0	user@some.domain
0	machine!user%a.edu@b.com
etc.
And it outputs, in tbl(1) format, five fields:

ruleset 	address 	mailer 	host 	user


Now I want to include rulesets for all of the above cases, including
each mailer (decnet, local ethernet, Internet, UUCP, smail, etc.)

I know the debug option (sendmail -bt -d21.12) always calls ruleset 3 to
start.  Therefore from your note I believe the proper way to test
each address is to use the combinations:

From (Envelope):	1,4,3,1,S,4	user@local
To (Envelope):		0,4		user@local
From:			1,S,4		user@local
To:, Cc:		2,R,4		user@local

Assuming I pick the correct rules for R and S, will this
test each of the above cases?

I need to get the correct incantations to test the SunOS, Ultrix, and
Berkeley/Ida sendmails, if possible. Am I on the right track?

And how is the UUCP From_ line controlled?

--
	Bruce G. Barnett 	barnett@ge-crd.ARPA, barnett@steinmetz.ge.com
				uunet!steinmetz!barnett

parmelee@wayback.cs.cornell.edu (Larry Parmelee) (03/17/89)

Ruleset processing for Sendmail 5.61  (I actually traced this out
for sendmail 5.59, but I've looked at 5.61 close enough to be 99.9%
certain it hasn't changed).  Enjoy.  (If you saw my first posting of
this, this is an update with a couple corrections/clarifications.)
-Larry Parmelee
parmelee@cs.cornell.edu

EF -> 3,0,2,r,4 -> (Save "@domains" for ruleset "D".)
EF -> 3,1,4 -> ($f) -> 3,D,1,S,4 -> ($g) -> New EF

ET -> 3,0,2,R,4 -> A/F -> SMTP delivery ? Yes: -> 3,D,2,R,4 -> New ET
 ^                  v                      No: -> New ET
 +--- <------ <-----+

MF -> 3,D,1,S,4 -> New MF
MT -> 3,D,2,R,4 -> New MT

A/F == Aliasing and .forward file processing for Local addresses
($?) == Definition of $? macro.

EF == Envelope "From:" address
ET == Envelope "To:" address
MF == Message From-type addresses
MT == Message To-type addresse

R == Mailer (determined per ET) "Recipient" ruleset
r == Mailer (determined from EF) "Recipient" ruleset
S == Mailer (determined per ET) "Sender" ruleset
D == Application of "@Domains" saved from the EF, if EF mailer flag 'C'
     is given and the address doesn't already have @domains applied.

Message headers associated with From-type addresses:
	Errors-To:	Resent-From:		Return-Receipt-To:
        From:		Resent-Reply-To:	Sender:
	Reply-To:	Resent-Sender:

Message headers associated with To-type addresses:
	To:		Cc:		Bcc:
	Resent-To:	Resent-Cc:	Resent-Bcc:

Approximate High-level sendmail ruleset processing algorithm:
The actual process is a bit more complicated;  Showing that here
would only confuse things...
 1.) Process EF for "@domains" and upto ($f).
 2.) Process all ETs upto the A/F point (including additional ETs
     resulting from the A/F processing of the local addresses)
     producing a list of ET address 3-tuples; (mailer, host, user).
 3.) Foreach ET address 3-tuple:
      a.) Define $h and $u macros:  host -> ($h), user ->($u)
      b.) Finish EF processing from $f yielding New EF for this ET.
      c.) Finish ET processing for this tuple yielding New ET.
      d.) Connect to mailer.
      e.) Do MF/MT processing as the message is written to the mailer.

Notes:
 1.) After ruleset 0 processing, only the "user" part is passed on
     to the other rulesets for further re-writing.
 2.) It is often useful to think of a "mailer" as the network or transport
     mechanism being chosen for the next hop the message will take.

-LCParmelee <parmelee@cs.cornell.edu> 16-Mar-89 sendmail:5.61

msir@uhura.cc.rochester.edu (Mark Sirota) (03/24/89)

> I know the debug option (sendmail -bt -d21.12) always calls ruleset 3 to
> start.  Therefore from your note I believe the proper way to test
> each address is to use the combinations:
>
> From (Envelope):	1,4,3,1,S,4	user@local
> To (Envelope):	0,4		user@local
> From:			1,S,4		user@local
> To:, Cc:		2,R,4		user@local
>
> Assuming I pick the correct rules for R and S, will this
> test each of the above cases?

Two comments:  The "-d21.12" on the command line is just a nicety which
provides you with more specific output; the sendmail -bt is the important
part.

Secondly, calling rulesets after S0 from sendmail -bt won't do quite what
you want it to do.  The problem is that S0 resolves to something like

$# tcp $@ host $: user < @ host >

And if you pass that into S4, it won't necessarily behave right.  You have
to explicitly pass only the $: portion.  So the sequence for To: (Envelope)
is more like this.  (Note that this takes advantage of the IDA feature
that -bt does not automatically call S3 first.  It's more challenging
without this.

	% /usr/lib/sendmail -bt
	> 3,0 user@host
	rewrite: ruleset  3   input: "user" "@" "host"
	rewrite: ruleset  3 returns: "user" "<" "@" "host" ">"
	rewrite: ruleset  0   input: "user" "<" "@" "host" ">"
	rewrite: ruleset  0 returns: $# "tcp" $@ "host" $: "user" "<" "@" "host" ">"
	> 2,n,4 user<@host>
	...

You get the idea.
-- 
Mark Sirota - University of Rochester, Rochester, NY
 Internet: msir@cc.rochester.edu
 Bitnet:   msir_ss@uordbv.bitnet
 UUCP:     ...!rochester!ur-cc!msir

steve@raspail.cdcnet.cdc.com (Steve Schonberger) (03/25/89)

In article <1181@ur-cc.UUCP>, msir@uhura.cc.rochester.edu (Mark Sirota) writes:
> [...]               (Note that this takes advantage of the IDA feature
> that -bt does not automatically call S3 first.  It's more challenging
> without this.

A simple way to avoid calling S3 first with plain sendmail is to do this
in your test configuration file:

	S3
	S49
	# what's usually in S3 follows

This causes S3 to become a do-nothing rule, and calling a do-nothing S3
first is as good as not doing S3.  If you want to do S3 for real, just
ask for S49 instead, until you get the configuration working, when you
can remove the S49 line.  (There's no magic significance about 49, that's
just the highest rule number my copy of sendmail allows.)

	Steve Schonberger	steve@raspail.cdcnet.cdc.com