home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / mail / sendmail / uk-sendmail2.1 / Rules.a / rules.m4 < prev    next >
Encoding:
Text File  |  1988-11-18  |  6.8 KB  |  223 lines

  1. ###############################################################################
  2. ###############################################################################
  3. #####
  4. #####    @(#)rules.m4    UK-2.1 sendmail configuration        18/11/88
  5. #####
  6. #####        The rulesets
  7. #####
  8. ###############################################################################
  9. ###############################################################################
  10.  
  11. ###############################################
  12. #  Ruleset 0  --  Select mailer to be used    #
  13. ###############################################
  14. S0
  15.  
  16. # strip local domain name(s)
  17. R$+@$J            $>3$1            process local part
  18.  
  19. ifdef(`NEWSNAME',
  20. `#  compare local-part with newsgroup names 
  21. R$+            $:$>18$1        newsgroups in local-part')
  22.  
  23. # local mail
  24. R$-            $#local$:<$1>        local mail - maybe aliased
  25. R~$-            $#binmail$:<$1>        local mail - no aliasing
  26.  
  27. #
  28. # convert domain address into "<address>host.network" triple
  29. #
  30. R$+@$+            $:$>16$1@$2        routing and address conversion
  31.  
  32. #
  33. # select mailer
  34. #
  35.  
  36. # note that address part ($u) is returned as "<address>"; the brackets are
  37. # subsequently removed in ruleset 4 (or 3 in the case of the smtp channel).
  38. # Such addresses can then be ignored by the header rulesets which are called
  39. # in BSD4.3 based sendmail.
  40.  
  41. ifdef(`ETHERNAME',
  42. `R<$+>$+.ether        $#ether$@$2$:<$1>    local ethernet mail')
  43. ifdef(`TCPNAME',
  44. `R<$+>$+.tcp        $#tcp$@$2$:<$1>        internet mail
  45. R$+@[$+]        $#tcp$@[$2]$:<$1>    pass domain literals to tcp')
  46. ifdef(`UUCPNAME',
  47. `R<~$+>$+.uucp        <\\~$1>$2.uucp        band-aid for uuxqt
  48. R<$+>$+.uucp        $#uucp$@$2$:<$1>    external uucp mail')
  49. ifdef(`JANETNAME',
  50. `R<$+>$+.janet        $#niftp$@$2$:<$1>    janet mail')
  51. ifdef(`NEWSNAME',
  52. `ifdef(`NEWSRELAYED',`',
  53. `R<$+>news        $#news$:<$1>        network news')')
  54. ifdef(`CSNETNAME',
  55. `R<$+>$+.csnet        $#pmdf$@$2$:<$1>    csnet mail')
  56. ifdef(`DECNETNAME',
  57. `R<$+@$+>$+.decnet    $#mail11$@$3$:<$1>    decnet mail')
  58. ifdef(`XEROXNAME',
  59. `R<$+>$+.xerox        $#xerox$@$2$:<$1>    xerox mail')
  60.  
  61. R<$+>error        $#error$:Local Domain Unknown
  62. R<$+>$+            $#error$:Configuration Error
  63.  
  64. # anything else with an "@" in is an error
  65. R$+@$+            $#error$:Domain Unknown
  66.  
  67. # anything else - e.g. filenames, pipes etc goes to local mailer
  68. R$+            $#local$:<$1>        local
  69.  
  70.  
  71. ###############################################
  72. #  Ruleset 1  --  Sender Field Pre-rewriting  #
  73. ###############################################
  74. S1
  75. R$+@$J            $@$1            strip local domain name
  76.  
  77.  
  78. ##################################################
  79. #  Ruleset 2  --  Recipient Field Pre-rewriting  #
  80. ##################################################
  81. S2
  82. R$+@$J            $@$1            strip local domain name
  83.  
  84.  
  85. ##########################################
  86. #  Ruleset 3  --  Name Canonicalisation  #
  87. ##########################################
  88. S3
  89.  
  90. #  handle special cases
  91. R$-            $@$1            return "user"
  92. R~$-            $@~$1            return "~ user"
  93.  
  94. #  basic textual canonicalisation
  95. R$*<$*>$*        $2            basic RFC 822 parsing
  96. R$+\ at\ $+        $1@$2            " at " -> "@" for RFC 822
  97. R$+%$+            $1@$2            convert '%'s to '@'s
  98. R$+@$+@$+        $1%$2@$3        then reduce to only one '@'
  99.  
  100. #  Address conversions.
  101. R@$+:$+            $:$>5@$1:$2        RFC822 to Percent form
  102. R$+::$+            $1!$2            decnet to uucp form
  103. R$+!$+            $:$>7$1!$2        uucp to Percent form
  104. ifdef(`NRSFORMAT',
  105. `R$+@$+.$+        $:$>13$1@$2.$3        NRS ordering to 822 ordering')
  106.  
  107. #  Domain name expansion.
  108. ifdef(`NAMESERVER',
  109. `R$+@$+            $:$1@$[$2$]        canonical name from nameserver')
  110. R$+@$+            $:$>11$1@$2        expand incomplete domain names
  111. R$+@$+            $:$>10$1@$2        do domain name aliases
  112.  
  113. R$+@$+            $:$>15$1@$2        standardise local domain name
  114.  
  115. ###############################################
  116. #  Ruleset 4  --  Final Output Post-rewriting #
  117. ###############################################
  118.  
  119. #  header rewriting is done in the per-mailer rulesets.
  120.  
  121. S4
  122. R<$+>            $:$1            remove brackets from $u addr
  123. R$+@$+            $@$1@$2            already ok
  124.  
  125. #  this ensures that $u has at least one '@' in (if percent style)
  126. R$+%$+            $1@$2            convert '%'s to '@'s
  127. R$+@$+@$+        $1%$2@$3        then reduce to only one '@'
  128.  
  129.  
  130. ########################################################
  131. #  Ruleset 5  --  RFC source routing -> Percent style  #
  132. ########################################################
  133.  
  134. #
  135. #  convert a routed address in RFC822 form to Percent form
  136. #  e.g. @ucl-cs.arpa,@kcl-cs.uucp:jim@hwcs.uucp  ->
  137. #                    jim%hwcs.uucp%kcl-cs.uucp@ucl-cs.arpa
  138. #
  139. S5
  140.  
  141. R$+,$+            $1:$2            @a,@b,@c:u%d -> @a:@b:@c:u%d
  142. R$*@$*            $1%$2            @a:@b:@c:u@d -> %a:%b:%c:u%d
  143.  
  144. R%$+:$+            $:$2@$1            %a:%b:%c:u%d -> %b:%c:u%d@a
  145. R%$+:$+@$+        $2@$1@$3        %b:%c:u%d@a  -> u%d@c@b@a
  146. R$+@$+@$+        $1%$2@$3        u%d@c@b@a    -> u%d%c%b@a
  147.  
  148. ifdef(`TCPNAME',`
  149. ##############################################################
  150. #  Ruleset 6  --  Percent style source routing -> RFC style  #
  151. ##############################################################
  152.  
  153. #
  154. #  convert a routed address in the Percent form to RFC822 form
  155. #  e.g.    jim%hwcs.uucp%kcl-cs.uucp@ucl-cs.arpa  ->
  156. #                @ucl-cs.arpa,@kcl-cs.uucp:jim@hwcs.uucp
  157. #    BEWARE!
  158. #    This ruleset is only safe to use for transport addr in SMTP headers
  159. #    because we cannot determine whether to add brackets and a phrase
  160. #
  161. S6
  162.  
  163. R$+@$+            $1%$2            u%d%c%b@a    -> u%d%c%b%a
  164. R$+%$+%$+        $:@$3:$1@$2        u%d%c%b%a    -> @c%b%a:u@d
  165. R$+%$+:$+        @$2:$1:$3        @c%b%a:u%d   -> @a:@b:@c:u@d
  166. R$+:$+:$+        $1,$2:$3        @a:@b:@c:u@d -> @a,@b,@c:u@d
  167. ')
  168.  
  169. ###############################################################
  170. #  Ruleset 7  --  uucp style source routing -> Percent style  #
  171. ###############################################################
  172.  
  173. #
  174. #  convert an address in uucp form to Percent form
  175. #  e.g. kcl-cs.uucp!hwcs.uucp!jim -> jim%hwcs.uucp@kcl-cs.uucp
  176. #
  177. #  also converts mixed addresses, giving '@' and '%' priority over '!'
  178. #  e.g. hwcs!jim%kcl-cs.uucp@ucl-cs.arpa -> jim%hwcs%kcl-cs.uucp@ucl-cs.arpa
  179. #
  180. S7
  181.  
  182. # handle mixed addresses (with '!'s, '@'s and maybe '%'s in)
  183. R$+!$+%$+        $1!$2@$3        c!d!u%b@a -> c!d!u@b@a
  184. R$+!$+@$+        $2@$1@$3        c!d!u@b@a -> u@d@c@b@a
  185.  
  186. # handle pure uucp addresses
  187. R$+!$+            $:$2@$1            a!b!c!d!u -> b!c!d!u@a
  188. R$+!$+@$+        $2@$1@$3        b!c!d!u@a -> u@d@c@b@a
  189.  
  190. R$+@$+@$+        $1%$2@$3        u@d@c@b@a -> u%d%c%b@a
  191.  
  192. ###############################################################
  193. #  Ruleset 8  --  Percent style to uucp style source routing  #
  194. ###############################################################
  195.  
  196. #
  197. #  convert a Percent style address to uucp (domain1!domain2!user) form
  198. #  e.g. jim%hwcs.uucp@kcl-cs.uucp -> kcl-cs.uucp!hwcs.uucp!jim
  199. #
  200. S8
  201.  
  202. R$+%$+            $1@$2            u%d%c%b@a -> u@d@c@b@a
  203. R$+@$+            $:$2!$1            u@d@c@b@a -> d@c@b@a!u
  204. R$+@$+!$+        $2!$1!$3        d@c@b@a!u -> a!b!c!d!u
  205.  
  206. ifdef(`NRSFORMAT',`
  207. #####################################################
  208. #  Ruleset 9  --  NRS <-> RFC822 domain conversion  #
  209. #####################################################
  210.  
  211. #
  212. # swap the order of the sub-domains around.
  213. # e.g. steve@uk.ac.ucl-cs.44d => steve@44d.ucl-cs.ac.uk
  214. #
  215. # this assumes that no colons will appear in the rhs of the domain address
  216. #
  217. S9
  218.  
  219. R$*@$+.$+        $1@$2:$3        u@a.b.c.d -> u@a:b:c:d
  220. R$*@$-:$+        $:$1@$3.$2        u@a:b:c:d -> u@b:c:d.a
  221. R$*@$-:$+.$+        $1@$3.$2.$4        u@b:c:d.a -> u@d.c.b.a
  222. ')
  223.