🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.mail.sendmail
Article #95

SUMMARY $: prefix on RHS

#95
From: Anthony A. Sako
Date: Fri, 07 Aug 1992 17:02
84 lines
3507 bytes
Thanks to everyone who responded to my question, and extra
thanks for taking the time to provide examples ...

In quick summary, a rule is applied to a name, over and
over, as long as the LHS matches ... unless the RHS has a
prefix of $:, $# or $@.


Here are the responses to my original posting -

**********************************************************************
>  I have a question about the $: prefix on the RHS, and about how
>sendmail parses names in general. My documentation says that the
>$: prefix "... causes rule to terminate immediately, which limits
>a rule to one application".
>
>  Does this mean that rules are applied more than once to a name
>as it passes through a ruleset ? i.e. after a rule is applied, is
>the result from the RHS compared to the LHS again ? or does it
>drop down to the next rule in the ruleset ?
>
>  Thanks in advance for any insight.
>
>  I'm at a remote site, and don't get on often enough, so would
>you please mail response to aas@lanl.gov.
>

Rules are executed so long as the LHS matches the string in question.  For
example the rule:

R$+             $1                      silly rule that brings a machine down

will go into an infinite loop as every string matches the LHS.  Similarly,
most sendmail "subroutine" rulesets are usually called once.  Since the norm
is to apply the RHS as long as the string matches the LHS, two RHS "prefixes"
were created.  $: causes the rule to be applied once.  $@ causes the rule to
be applied once and returns from the ruleset.

An application for the repeating rule is the ARPAnet kludge.  A valid address
in this format takes the form:  user%site4%site3%site2@site1.  This is
equivalent to the following bangpath:  site1!site2!site3!site4!user.  The 
address can be turned into a bang path with the following rules (I think):

R$+%$+@$+       $:$3!$2!$1      Put the first site in front and user on back
R$+!$+%$+!$+    $1!$3!$2!$4     Turn all the sites around

Note that the first rule is executed once.

Hope this helps.

-- 
Bert Medley                             medley@synercom.hounix.org      [work]
                                        bert@medley.ssdl.com            [home]


**********************************************************************
From: gfoster@darpa.mil



Your assumption is correct, LHS matching and RHS substitution is
applied over and over again for each rule until the LHS match fails
unless one of $: or $# is present. This is explained in Section 5.2.4
of the "Sendmail Installation and Operation Guide, Ver. 5.11 for
Sendmail 5.61," page 19 in the PostScript formatted version I have. 

For example, this rule will result in an endless loop:

R$+     $1

This rule will execute exactly once (and do nothing):

R$+     $:$1

Glen Foster

**********************************************************************

From: Neil W Rickert <rickert@cs.niu.edu>


  Yes. Without $: (or $@ or $#) a rule is applied repeatedly until
it fails to match. If you are not careful in designing rules, this
can cause infinite loops.
Technical Details
Message-ID: <1992Aug7.170236.21269@newshost.lanl.gov>
Path: arc1-ca.pugleaf.net!sparky!uunet!gatech!destroyer!caen!hellgate.utah.edu!lanl!beta.lanl.gov!aas

Show Full Headers
Complete Article Headers
Newsgroups: comp.mail.sendmail
Path: arc1-ca.pugleaf.net!sparky!uunet!gatech!destroyer!caen!hellgate.utah.edu!lanl!beta.lanl.gov!aas
From: aas@beta.lanl.gov (Anthony A. Sako)
Subject: SUMMARY $: prefix on RHS
Message-ID: <1992Aug7.170236.21269@newshost.lanl.gov>
Sender: news@newshost.lanl.gov
Organization: Los Alamos National Laboratory
Date: Fri, 7 Aug 1992 17:02:36 GMT
Lines: 84