home *** CD-ROM | disk | FTP | other *** search
/ The Hacker's Encyclopedia 1998 / hackers_encyclopedia.iso / hacking / internet / sendmai2.txt < prev    next >
Encoding:
Text File  |  2003-06-11  |  11.8 KB  |  366 lines

  1. ###############################################################################
  2. ###                                                                         ###
  3. ###            sendmail configuration for generic complex host              ###
  4. ###                with both UUCP and Internet connections                  ###
  5. ###                                                                         ###
  6. ###            Erik E. Fair <fair@ucbarpa.berkeley.edu>                     ###
  7. ###                                                                         ###
  8. ###############################################################################
  9.  
  10. # Our local domain ($D is added to $w [hostname] for official name in base.m4)
  11. DDARPA
  12.  
  13. # All the names we are known by (put all the names & nick names on the next
  14. # line, separated by spaces. If you need another line, begin it with "Cw")
  15. Cw
  16.  
  17. # Our UUCP name
  18. DU$w
  19.  
  20. # the list of UUCP hosts that we speak to (same rules as Cw, use the
  21. # output of the "uuname" command; also, when you add or delete a host
  22. # from the L.sys, don't forget to add or delete it here)
  23. CU
  24.  
  25. ###############################################################################
  26. ###   baseline definitions that sendmail needs to operate                   ###
  27. ###############################################################################
  28.  
  29. ##########################
  30. ###   Special macros   ###
  31. ##########################
  32.  
  33. DV25
  34.  
  35. # my official hostname
  36. Dj$w.$D
  37. # my name (the name on mailer bounces)
  38. DnMAILER-DAEMON
  39. # UNIX header format
  40. DlFrom $g $d
  41. # delimiter (operator) characters
  42. Do.:%@!^/[]
  43. # format of a total name
  44. Dq$?x$x <$g>$|$g$.
  45. # SMTP login message
  46. De$j Sendmail $v/$V ready at $b
  47.  
  48. ###################
  49. ###   Options   ###
  50. ###################
  51.  
  52. # we have full sendmail support here
  53. Oa
  54. # location of alias file
  55. OA/usr/lib/aliases
  56. # default delivery mode (deliver in background)
  57. Odbackground
  58. # (don't) connect to "expensive" mailers
  59. #Oc
  60. # temporary file mode
  61. OF0600
  62. # default GID
  63. Og1
  64. # location of help file
  65. OH/usr/lib/sendmail.hf
  66. # log level
  67. OL9
  68. # Send to me too (even if I'm in an alias expansion)
  69. Om
  70. # default messages to old style
  71. Oo
  72. # queue directory
  73. OQ/usr/spool/mqueue
  74. # read timeout -- violates protocols (timeout an SMTP idle for 2 hours)
  75. Or2h
  76. # status file
  77. OS/usr/lib/sendmail.st
  78. # queue up everything before starting transmission
  79. Os
  80. # default timeout interval (returns undelivered mail after 3 days)
  81. OT3d
  82. # time zone names (V6 only)
  83. OtPST,PDT
  84. # default UID
  85. Ou1
  86. # encrypted wizard's password (for the undocumented "wiz" SMTP command)
  87. OWnot-likely
  88. # rebuild the aliasfile automagically
  89. #OD
  90. # maximum load average before queueing mail
  91. Ox10
  92. # maximum load average before rejecting connections
  93. OX15
  94.  
  95. ###############################
  96. ###   Message precedences   ###
  97. ###############################
  98.  
  99. Pfirst-class=0
  100. Pspecial-delivery=100
  101. Pbulk=-60
  102. Pjunk=-100
  103.  
  104. #########################
  105. ###   Trusted users   ###
  106. #########################
  107.  
  108. Troot
  109. Tdaemon
  110. Tnews
  111. Tuucp
  112.  
  113. #############################
  114. ###   Format of headers   ###
  115. #############################
  116.  
  117. H?P?Return-Path: <$g>
  118. HReceived: $?sfrom $s$. by $j$?r with $r$. ($v/$V-eef)
  119.     id $i; $b
  120. H?D?Date: $a
  121. H?F?From: $q
  122. H?x?Full-Name: $x
  123. H?M?Message-Id: <$t.$i@$j>
  124. HSubject:
  125. H?D?Resent-Date: $a
  126. H?F?Resent-From: $q
  127. H?M?Resent-Message-Id: <$t.$i@$j>
  128.  
  129.  
  130. ###############################################################################
  131. #        RULESET ZERO PREAMBLE                                         #
  132. ###############################################################################
  133.  
  134. S0
  135.  
  136. # first make canonical
  137. R$*<$*>$*        $1$2$3                defocus
  138. R$+            $:$>3$1                make canonical
  139.  
  140. # handle special cases.....
  141. R@            $#local$:$n            handle <> form
  142. R$*<@[$+]>$*        $#tcp$@[$2]$:$1@[$2]$3        numeric internet spec
  143.  
  144. # now delete the local info
  145. R$*<$*$=w.UUCP>$*    $1<$2>$4            thishost
  146. R$*<$*$=w.$D>$*        $1<$2>$4            thishost
  147. R$*<$*$=w>$*        $1<$2>$4            thishost
  148. R$*<$*.>$*        $1<$2>$3            drop trailing dot
  149. R<@>:$*            $@$>0$1                retry after route strip
  150. R$*<@>            $@$>0$1                strip null trash & retry
  151.  
  152. # return uucp mail that looks like decvax!ittvax!marsvax! since it
  153. # will be rejected at the final site with no username on it
  154. R$*!<@$-.UUCP>        $#error$:Destination address truncated
  155.  
  156.  
  157.  
  158. ###############################################################################
  159. ###   Machine dependent part of ruleset zero (where we decide what to do)   ###
  160. ###############################################################################
  161.  
  162. # resolve UUCP links to hosts known to this machine
  163. R$*<@$=U.UUCP>$*    $#uucp$@$2$:$1            resolve local uucp
  164.  
  165. # special case violation of RFC822 for hybrid bang/at addresses
  166. # if uucphost!user@arpahost, forward to uucphost if we speak to it.
  167. R$=U!$+<@$+>$*        $#uucp$@$1$:$2@$3$4
  168.  
  169. # resolve various and sundry other unofficial networks
  170. R$*<@$+.MAILNET>$*    $#tcp$@mit-multics.arpa$:$1@$2.MAILNET$3    MAILNET
  171. R$*<@$+.BITNET>$*    $#tcp$@cunyvm.cuny.edu$:$1@$2.BITNET$3        BITNET
  172. R$*<@$+.MFENET>$*    $#tcp$@nmfecc.arpa$:$1@$2.MFENET$3        MFENET
  173. R$*<@$+.CSNET>$*    $#tcp$@relay.cs.net$:$1@$2.CSNET$3        CSNET
  174.  
  175.  
  176.  
  177. # when all else fails, look up the whole name in the host table
  178. R$*<@$+>$*        $#tcp$@$2$:$1@$2$3            user@domain
  179.  
  180. # remaining names must be local
  181. R@            $n                    fix magic token
  182. R$+            $#local$:$1                everything else
  183.  
  184. ###############################################################################
  185. ###   End of ruleset zero                                                   ###
  186. ###############################################################################
  187.  
  188. ###########################
  189. #  Name Canonicalization  #
  190. ###########################
  191. S3
  192.  
  193. # handle "from:<>" special case
  194. R<>            $@@                resolve into magic token
  195.  
  196. # basic textual canonicalization
  197. R$*<$*<$*<$+>$*>$*>$*    $4                3-level <> nesting
  198. R$*<$*<$+>$*>$*        $3                2-level <> nesting
  199. R$*<$+>$*        $2                basic RFC821/822 parsing
  200. R$+ at $+        $1@$2                "at" -> "@" for RFC 822
  201. R$*<$*>$*        $1$2$3                in case recursive
  202.  
  203. # make sure <@a,@b,@c:user@d> syntax is easy to parse -- undone later
  204. R@$+,$+            @$1:$2                change all "," to ":"
  205.  
  206. # localize and dispose of domain-based addresses
  207. R@$+:$+            $@$>6<@$1>:$2            handle <route-addr>
  208.  
  209. # more miscellaneous cleanup
  210. R$+            $:$>8$1                host dependent cleanup
  211. R$+:$*;@$+        $@$1:$2;@$3            list syntax
  212. R$+@$+            $:$1<@$2>            focus on domain
  213. R$+<$+@$+>        $1$2<@$3>            move gaze right
  214. R$+<@$+>        $@$>6$1<@$2>            already canonical
  215.  
  216. # convert old-style addresses to a domain-based address
  217. R$+^$+            $1!$2                convert ^ to !
  218. R$+!$+            $@$>9$1!$2            uucp name hackery
  219. R$+%$+            $:$>5$1%$2            user%host%host
  220. R$+<@$+>        $@$>6$1<@$2>            canonical
  221.  
  222. # Given multiple %'s change rightmost % to @.
  223. S5
  224. R$*<$*>$*        $1$2$3                defocus
  225. R$*%$*            $1@$2                First make them all @'s.
  226. R$*@$*@$*        $1%$2@$3            Undo all but the last.
  227. R$*@$*            $@$1<@$2>            Put back the brackets.
  228.  
  229. ###############################################################################
  230. ####   Assorted name hackery to make things simple for people              ####
  231. ###############################################################################
  232.  
  233. # here we look for addresses of the form: user%host.domain@gateway
  234. # and strip off the gateway name (for the ones that we know)
  235.  
  236. S6
  237.  
  238. # conventional percent format
  239.  
  240. R$+%$+.MAILNET<@mit-multics.arpa>    $>5$1<%$2.MAILNET>    strip
  241. R$+%$+.MFENET<@nmfecc.arpa>        $>5$1<%$2.MFENET>    strip
  242. R$+%$+.BITNET<@cunyvm.cuny.edu>        $>5$1<%$2.BITNET>    strip
  243. R$+%$+.CSNET<@relay.cs.net>        $>5$1<%$2.CSNET>    strip
  244.  
  245. # regulation route-addr format
  246.  
  247. R<@mit-multics.arpa>:$+@$+.MAILNET    $1<@$2.MAILNET>        strip
  248. R<@nmfecc.arpa>:$+@$+.MFENET        $1<@$2.MFENET>        strip
  249. R<@cunyvm.cuny.edu>:$+@$+.BITNET    $1<@$2.BITNET>        strip
  250. R<@relay.cs.net>:$+@$+.CSNET        $1<@$2.CSNET>        strip
  251.  
  252. # mung up names for the outside world - called from tcp mailer
  253.  
  254. S7
  255. R$+@$+.MAILNET        $1%$2.MAILNET@mit-multics.arpa    user@host.MAILNET
  256. R$+@$+.MFENET        $1%$2.MFENET@nmfecc.arpa    user@host.MFENET
  257. R$+@$+.BITNET        $1%$2.BITNET@cunyvm.cuny.edu    user@host.BITNET
  258. R$+@$+.CSNET        $1%$2.CSNET@relay.cs.net    user@host.CSNET
  259.  
  260. ###############################################################################
  261. ####   UUCP address hackery                                                ####
  262. ###############################################################################
  263.  
  264. S9
  265. R$+!$=w!$+        $3                collapse loops
  266. R$-.$+!$+        $@$>6$3<@$1.$2>            do.main!user
  267. R$-!$+            $@$>6$2<@$1.UUCP>        host!user
  268.  
  269. ################################
  270. #  Sender Field Pre-rewriting  #
  271. ################################
  272. S1
  273. R$*<$*>$*        $1$2$3                defocus
  274.  
  275. ###################################
  276. #  Recipient Field Pre-rewriting  #
  277. ###################################
  278. S2
  279. R$*<$*>$*        $1$2$3                defocus
  280.  
  281. ###################################
  282. #  Final Output Post-rewriting    #
  283. #  Standard Domain-based version  #
  284. ###################################
  285. S4
  286. R@            $n                handle <> error addr
  287.  
  288. # externalize local domain info
  289. R@$+:$+:$+        $@@$1,$2:$3            <route-addr> canonical
  290.  
  291. # UUCP must always be presented in old form
  292. R$+@$-.UUCP        $2!$1                u@h.UUCP => h!u
  293.  
  294. ###############################################################################
  295. ###   Local, and Program Mailer specifications                              ###
  296. ###############################################################################
  297.  
  298. # Nota Bene: what mailer flags you use depends upon what version of /bin/mail
  299. # you have:
  300. #
  301. # 4th Berkeley Software Distribution (4.1 BSD or later)
  302. Mlocal, P=/bin/mail, F=SlsDFMPpmnxr, S=10, R=20, A=mail -d $u
  303. #
  304. # USG UNIX (System III, System V, Xenix 3.0 or later)
  305. # Mlocal, P=/bin/mail, F=SlsDFMPpmnx, S=10, R=20, A=mail $u
  306. #
  307. # Also, if you are using System V, you should get the Berkeley version of
  308. # /bin/mail as soon as you can and junk the one you've got: it doesn't
  309. # believe in sendmail, so the wrong thing will happen when someone types
  310. # mail user@host (i.e. it will attempt local delivery, rather than call
  311. # sendmail)
  312.  
  313. Mprog, P=/bin/sh, F=lsDFMpxehu, S=10, R=20, A=sh -c $u
  314.  
  315. S10
  316.  
  317. S20
  318.  
  319.  
  320. ###############################################################################
  321. ####    IP/TCP/SMTP mailer (going out to internet land)                    ####
  322. ###############################################################################
  323.  
  324. Mtcp,    P=[IPC], F=AmnDFMpueXLC, S=14, R=14, A=IPC $h, E=\r\n
  325.  
  326. S14
  327. R$*@[$+]$*        $@$1@[$2]$3        already ok (inet addr spec)
  328. R@$+@$+            $@@$1@$2        already ok (route-addr)
  329. R$+@$=X.UUCP        $2!$1@$X        fix remote UUCP
  330. R$+@$=Y.UUCP        $2!$1@$Y        fix remote UUCP
  331. R$+@$=Z.UUCP        $2!$1@$Z        fix remote UUCP
  332. R$+@$-.UUCP        $2!$1@$j        undo local UUCP hack
  333. R$+@$+            $@$>7$1@$2        fix up names for the internet
  334. R$+            $@$1@$j            add our official host name
  335.  
  336. ###############################################################################
  337. ####   UUCP mailer (bangland)                                              ####
  338. ###############################################################################
  339.  
  340. # if none of your UUCP neighbors are 4.1 BSD sites, add an "m" after "F="
  341. # this will cause multiple recipients on the same remote host to be done
  342. # in the same uux command (i.e. one letter sent for "n" recipients)
  343. #
  344. # if you want uucico to be invoked immediately after a letter is queued
  345. # (i.e. initiate the phone call immediately) remove the "-r" flag in the
  346. # uux command line.
  347.  
  348. Muucp,    P=/usr/bin/uux, F=sDFMxhuU, S=13, R=23, M=100000,
  349.     A=uux - -r $h!rmail ($u)
  350.  
  351. S13
  352. R$+@$-.UUCP        $2!$1                u@host.UUCP => host!u
  353. R$=w!$+            $2                zap dups
  354. R@$+@$+            $@$U!@$1@$2            ugh, route-addrs
  355. # unfortunately, I have to resolve route-addrs before this rule, because
  356. # it is so general that it matches them too, with disastrous results. - EEF
  357. R$+@$-.$+        $2.$3!$1            uucpize address
  358. R$+            $:$U!$1                stick on our host name
  359.  
  360. S23
  361. # nothing here because bangland mailers are supposed to rewrite these headers
  362. # relative to the sender by themselves anyway.
  363.  
  364.  
  365.  
  366.