[comp.mail.sendmail] Idempotence of S3

ylee@csl.dl.nec.com (Ying-Da Lee) (04/13/91)

(Sorry to be so decadent as to follow up on my own posting; I kept
forgetting one important point.)

(Neil)>> I do not know of anything in sendmail that requires S3 be idempotent.

(Me)>That's my point.  It bothers me to see bold assertion that
(Me)>'S3 is supposed to be idempotent' without supporting evidence.
(Me)>I have seen no such requirement either in documentation or in
(Me)>actual practice.

If S3 is supposed to be idempotent, let's make sure it is so.
If not, then the practice of an unconditional invocation of S3
at the beginning of S0 'just to be safe' can land you in deep
water instead.


	Ying-Da Lee			(214)518-3490
	C&C Software Development Lab
	NEC America			(214)518-3990 (FAX)
	ylee@csl.dl.nec.com
	uunet!necbsd!ylee


P.S.
Just out of curiosity, how many people do have idempotent S3?
To find out, start your sendmail with -bt, then enter

3 some@mail.address

If you have an idempotent S3, the two output lines marked with
'ruleset 3 returns:' will be identical.  

avolio@decuac.DEC.COM (Frederick M. Avolio) (04/13/91)

Shoot.  I have never even heard or read the word "idempotent" until
just now.

vixie@pa.dec.com (Paul Vixie) (04/16/91)

In article <1991Apr12.213421.22457@decuac.dec.com> Fred said:
# Shoot.  I have never even heard or read the word "idempotent" until
# just now.

Idempotent means, roughly, that doing it N times is the same as doing it
1 time, for all N>1.  In the case of S3, this is usually accomplished by
bailing out near the top if the <brackets> are already there, as in:

S3
...
R$+<@$+>$+		$@$1<@$2>$3		bail out
...

I have rarely encountered S3's that hurt you if you ran them N>1 times.
Where I have encountered them, I have changed them.  I'm not sure where
I read that S3 was supposed to be idempotent, but I did read it somewhere
and it seems intuitively correct that it should work that way.  

It also lets me call S3 on my way out of other rulesets, even in cases
where I don't know quite what the hell I'm sending in.

Btw, my Webster server didn't know about idempotency either.

Cheers,
-- 
Paul Vixie
DEC Western Research Lab	<vixie@pa.dec.com>	<paul@vixie.sf.ca.us>
Palo Alto, California, USA	...!decwrl!vixie	...!vixie!paul

rickert@mp.cs.niu.edu (Neil Rickert) (04/16/91)

In article <1991Apr16.065813.24921@pa.dec.com> vixie@pa.dec.com (Paul Vixie) writes:
>Idempotent means, roughly, that doing it N times is the same as doing it
>1 time, for all N>1.  In the case of S3, this is usually accomplished by
>bailing out near the top if the <brackets> are already there, as in:
>
>S3
>...
>R$+<@$+>$+		$@$1<@$2>$3		bail out
>...
 That rule looks like a great idea.  I think I will try it out.  Let me
get that message with

To: John Smith <@BITNET.GATEWAY:SMITH@NODE> 555-1212

 and I will just feed it to 'sendmail' with the '-t' operand, and see
what happens.

-- 
=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=
  Neil W. Rickert, Computer Science               <rickert@cs.niu.edu>
  Northern Illinois Univ.
  DeKalb, IL 60115                                   +1-815-753-6940

ylee@csl.dl.nec.com (Ying-Da Lee) (04/16/91)

In article <1991Apr16.065813.24921@pa.dec.com> vixie@pa.dec.com (Paul Vixie) writes:
>I have rarely encountered S3's that hurt you if you ran them N>1 times.

Neither Sun's, nor UCB's, Ultrix's, Neils's, or mine for that matter,
has idempotent S3.

>Where I have encountered them, I have changed them.  I'm not sure where
>I read that S3 was supposed to be idempotent, but I did read it somewhere
>and it seems intuitively correct that it should work that way.  

What is the particular nature of S3 that would make it intuitively
correct to be idempotent?

Essentially S3 takes an address and puts <> around the portion of
focus to aid other rulesets in further processing.  I can't see
how any part of this would philosophically require it to be
idempotent.  From a practical point of view, since S3 is applied
at least once on each and every address in the header, it should
be particularly important to make it lean and clean.  Adding rule
or rules to it for the sole purpose of making it idempotent is a
bad idea bacause

1) it introduces unnecessary processing in S3, and
2) it encourages unnecessary invocation of S3 ("just to be safe",
   or "it won't hurt").

I suspect the practice of spurious invocation of S3 near the top
of S0 started out as a mistake and, once it was in, it stays in
because of the peculiar mystique of sendmail.cf.  The idempotence
requirement, if it exists, seems more likely a rationalization for
such practice after the fact.

Why don't the basic principles of good programming
apply in sendmail.cf?  It IS programming, isn't it?

	Ying-Da Lee			(214)518-3490
	C&C Software Development Lab
	NEC America			(214)518-3990 (FAX)
	ylee@csl.dl.nec.com
	uunet!necbsd!ylee
	

palkovic@linac.fnal.gov (John Palkovic) (04/17/91)

>>>>> Regarding Re: Idempotence of S3 (Was Re: IBM Do It Again); you said:

> Shoot.  I have never even heard or read the word "idempotent" until
> just now.

I first heard about it in modern algebra class. If you have a ring, an
idempotent is an element x such that x^2 = x. E.g., in the ring of
integers, 1 is an idempotent. So how did a nice mathematical term like
"idempotent" come to be part of sendmail jargon?

-John
--
palkovic@linac.fnal.gov || {royko,tellab5,simon}!linac!palkovic

vixie@pa.dec.com (Paul Vixie) (04/17/91)

In article <1991Apr16.165044.21308@csl.dl.nec.com> ylee@csl.dl.nec.com said:
# Why don't the basic principles of good programming
# apply in sendmail.cf?  It IS programming, isn't it?

No.  It is configuration.  Like TECO, you can do Towers of Hanoi in
sendmail.cf if you are patient enough.  But there are better languages
if programming is your goal, and the tool you are misusing will suck
the blood of every maintainer who follows you.
-- 
Paul Vixie
DEC Western Research Lab	<vixie@pa.dec.com>	<paul@vixie.sf.ca.us>
Palo Alto, California, USA	...!decwrl!vixie	...!vixie!paul

ylee@csl.dl.nec.com (Ying-Da Lee) (04/17/91)

In article <1991Apr16.213322.18417@pa.dec.com> vixie@pa.dec.com (Paul Vixie) writes:
>In article <1991Apr16.165044.21308@csl.dl.nec.com> ylee@csl.dl.nec.com said:
># Why don't the basic principles of good programming
># apply in sendmail.cf?  It IS programming, isn't it?
>
>No.  It is configuration.  Like TECO, you can do Towers of Hanoi in
>sendmail.cf if you are patient enough.  But there are better languages
>if programming is your goal, and the tool you are misusing will suck
>the blood of every maintainer who follows you.

Well, Paul, it would have added a great deal more weight to
your response if you could answer the questions or dispute the
reasoning that lead to those two lines in my posting.

Remember, Paul, you are the one who declared "S3 is supposed to
be idempotent" without any supporting evidence to start with.
Why should questions of "why?" and "where is it documented?" get
you so agitated?
	
	Ying-Da Lee			(214)518-3490
	C&C Software Development Lab
	NEC America			(214)518-3990 (FAX)
	ylee@csl.dl.nec.com
	uunet!necbsd!ylee

hubcap@hubcap.clemson.edu (System Janitor) (04/17/91)

 * Shoot.  I have never even heard or read the word "idempotent" until
 * just now.

Me neither, so I looked it up. Wasn't there, but ``idem'' was:

   Something previously mentioned

Sounds like the right root word...

Also, here's my vote for the sendmail configuration language being a real
programming language, and good programming rules apply. 

-Mike

Craig_Everhart@TRANSARC.COM (04/17/91)

My belief is that lots of S0's start by invoking S3 because people are
lazy in their recursive use of S0.  That is, it's common in S0 to
recognize an outermost domain as local, to strip off that outermost
domain, and recurse to determine whether the next-outermost domain (if
any) was local, or UUCP, or whatever.

But you don't have to recurse by calling S0 directly from S0.  You can
do the right thing by allocating some other ruleset, say S9, and having
it call S3 and then S0 itself:
  S9
  # First, make it canonical
  R$*<$*>$*		$1$2$3		defocus
  R$+			$:$>3$1		make canonical (find outer host name)
  R$*			$@$>0$1	and return the result of S0

Then your S0 can ``recurse'' by calling S9.  (The first ruleset may or
may not be necessary, depending on how you invoke it from S0.)

Now, the last time I looked, when Sendmail gets a
	To: foo bar <baz@ola> (comment)
header, it has hard code to strip that down to ``baz@ola'' before
handing it to ruleset 3, leaving something like ``foo bar <$g>
(comment)'' in a buffer somewhere so it knows how to merge the output of
the rulesets back into a mail header.  Thus, you shouldn't have to deal
with the ``foo bar'' or ``(comment)'' parts of an address at all.

		Craig

vixie@pa.dec.com (Paul Vixie) (04/19/91)

In article <1991Apr16.223723.25275@csl.dl.nec.com> ylee@csl.dl.nec.com said:
# Well, Paul, it would have added a great deal more weight to
# your response if you could answer the questions or dispute the
# reasoning that lead to those two lines in my posting.

I'm sure I answered everything I saw reason to answer.  Read over your
questions and see if you can understand why their tone precluded any
need for a reply.  (These are my last public words on this thread; if
you want to know more, send me e-mail.)

# Remember, Paul, you are the one who declared "S3 is supposed to
# be idempotent" without any supporting evidence to start with.
# Why should questions of "why?" and "where is it documented?" get
# you so agitated?

I've been trying to avoid agitation.  I can see that I should have
stopped earlier.  Good day, sir.

Cheers,
-- 
Paul Vixie
DEC Western Research Lab	<vixie@pa.dec.com>	<paul@vixie.sf.ca.us>
Palo Alto, California, USA	...!decwrl!vixie	...!vixie!paul

ylee@csl.dl.nec.com (Ying-Da Lee) (04/19/91)

In article <1991Apr19.075822.17462@pa.dec.com> vixie@pa.dec.com (Paul Vixie) writes:
>
>I'm sure I answered everything I saw reason to answer.

In plainer words:  You haven't the foggiest idea how to answer
any of my questions.

>  Read over your
>questions and see if you can understand why their tone precluded any
>need for a reply.

Oh we are talking about 'tone' now, are we?  Let's see, the harshest
words I have used prior to this posting were:

  It bothers me to see bold assertion that
  'S3 is supposed to be idempotent' without supporting evidence.

Those are hardly the match of Paul's refined rhetorics, such as this
piece of gem: 

    No.  It is configuration.  Like TECO, you can do Towers of Hanoi in
    sendmail.cf if you are patient enough.  But there are better languages
    if programming is your goal, and the tool you are misusing will suck
    the blood of every maintainer who follows you.

How delightful!  How dare I disagree with such an exalted expert
as Paul Vixie!  Obviously a supreme offense in 'misusing' the tool,
hereby convicted with no need of supporting evidences.  And don't
miss the poetry of 'suck the blood' part either.

Listen, Paul:  Everybody makes mistakes sometimes.  I made one earlier,
Neil pointed it out and I said Yup, Neil is abosultely right.

What is the big deal?  And who is Paul Vixie and where did he acquire
this Papal Infallibility?  I have been trying to say you were wrong
without ridiculing you or your opinions, but you obviously don't
know that there's a difference.  Well, you do now.

>  (These are my last public words on this thread; if
>you want to know more, send me e-mail.)

Good, you are too old to go on nya-nya-nya-ing in public.  If you are
a masochist looking for a fix, we can do it in private e-mail.

	Ying-Da Lee			(214)518-3490
	C&C Software Development Lab
	NEC America			(214)518-3990 (FAX)
	ylee@csl.dl.nec.com
	uunet!necbsd!ylee

kyle@uunet.UU.NET (Kyle Jones) (04/21/91)

ylee@csl.dl.nec.com (Ying-Da Lee) writes:
 > I suspect the practice of spurious invocation of S3 near the top
 > of S0 started out as a mistake and, once it was in, it stays in
 > because of the peculiar mystique of sendmail.cf.  The idempotence
 > requirement, if it exists, seems more likely a rationalization for
 > such practice after the fact.
 > 
 > Why don't the basic principles of good programming
 > apply in sendmail.cf?  It IS programming, isn't it?

You answered your own question.  For most people it's not
programming at all--- more likely it's taking an existing
configuration, no matter how rotten that config file might be,
and tweaking it until things start working.  This explains why
there are some many convoluted sendmail.cf files out there.  Lots
can be simplified, but not without considerable work.  Most
people would rather be doing just about anything else.