1divert(-1) 2# 3# Copyright (c) 1983 Eric P. Allman 4# Copyright (c) 1988 The Regents of the University of California. 5# All rights reserved. 6# 7# %sccs.include.redist.sh% 8# 9divert(0) 10 11VERSIONID(`@(#)proto.m4 6.16 (Berkeley) 03/03/93') 12 13MAILER(local)dnl 14 15ifdef(`_OLD_SENDMAIL_', `dnl', 16`# level 4 config file format 17V4') 18 19################## 20# local info # 21################## 22 23Cwlocalhost 24ifdef(`USE_CW_FILE', 25`# file containing names of hosts for which we receive email 26CONCAT(`Fw', confCW_FILE)', `dnl') 27 28ifdef(`UUCP_RELAY', 29`# UUCP relay host 30CONCAT(DY, UUCP_RELAY) 31 32')dnl 33ifdef(`BITNET_RELAY', 34`# BITNET relay host 35CONCAT(DB, BITNET_RELAY) 36 37')dnl 38ifdef(`CSNET_RELAY', 39`# CSNET relay host 40CONCAT(DC, CSNET_RELAY) 41 42')dnl 43ifdef(`FAX_RELAY', 44`# FAX relay host 45CONCAT(DF, FAX_RELAY) 46 47')dnl 48ifdef(`SMART_HOST', 49`# "Smart" UUCP relay host 50CONCAT(DS, SMART_HOST) 51 52')dnl 53# who I send unqualified names to (null means deliver locally) 54CONCAT(DR, ifdef(`LOCAL_RELAY', LOCAL_RELAY)) 55 56# who gets all local email traffic ($R has precedence for unqualified names) 57CONCAT(DH, ifdef(`MAIL_HUB', MAIL_HUB)) 58 59# my official hostname ($w or $w.$D) 60CONCAT(Dj$w, ifdef(`NEED_DOMAIN', .$D)) 61 62# who I masquerade as (can be $j) 63CONCAT(DM, ifdef(`MASQUERADE_NAME', MASQUERADE_NAME, $j)) 64 65# class L: names that should be delivered locally, even if we have a relay 66# class E: names that should be exposed as from this host, even if we masquerade 67CLroot 68CEroot 69undivert(5)dnl 70 71# operators that cannot be in local usernames (i.e., network indicators) 72CO @ % ifdef(`_NO_UUCP_', `', `!') 73 74# a class with just dot (for identifying canonical names) 75C.. 76 77 78###################### 79# Special macros # 80###################### 81 82# SMTP initial login message 83CONCAT(De, confSMTP_LOGIN_MSG) 84 85# UNIX initial From header format 86CONCAT(Dl, confFROM_LINE) 87 88# my name for error messages 89CONCAT(Dn, confMAILER_NAME) 90 91# delimiter (operator) characters 92CONCAT(Do, confOPERATORS) 93 94# format of a total name 95CONCAT(Dq, ifdef(`confFROM_HEADER', confFROM_HEADER, 96 ifdef(`_OLD_SENDMAIL_', `$g$?x ($x)$.', `$?x$x <$g>$|$g$.'))) 97include(`../m4/version.m4') 98 99############### 100# Options # 101############### 102 103# preserve 8 bits on message body on input? 104CONCAT(O8, confEIGHT_BIT_INPUT) 105 106# wait (in minutes) for alias file rebuild 107CONCAT(Oa, confALIAS_WAIT) 108 109# location of alias file 110CONCAT(OA, ifdef(`ALIAS_FILE', ALIAS_FILE, /etc/aliases)) 111 112# minimum number of free blocks on filesystem 113CONCAT(Ob, confMIN_FREE_BLOCKS) 114 115# substitution for space (blank) characters 116CONCAT(OB, confBLANK_SUB) 117 118# connect to "expensive" mailers on initial submission? 119CONCAT(Oc, confCON_EXPENSIVE) 120 121# checkpoint queue runs after every N successful deliveries 122CONCAT(OC, confCHECKPOINT_INTERVAL) 123 124# default delivery mode 125CONCAT(Od, confDELIVERY_MODE) 126 127# automatically rebuild the alias database? 128CONCAT(OD, confAUTO_REBUILD) 129 130# error message header/file */ 131ifdef(`confERROR_MESSAGE', 132 concat(OE, confERROR_MESSAGE), 133 #OE/etc/sendmail.oE) 134 135# error mode 136ifdef(`confERROR_MODE', 137 concat(Oe, confERROR_MODE), 138 #Oep) 139 140# save Unix-style "From_" lines at top of header? 141CONCAT(Of, confSAVE_FROM_LINES) 142 143# temporary file mode 144CONCAT(OF, confTEMP_FILE_MODE) 145 146# match recipients against GECOS field? 147CONCAT(OG, confMATCH_GECOS) 148 149# default GID 150CONCAT(Og, confDEF_GROUP_ID) 151 152# maximum hop count 153CONCAT(Oh, confMAX_HOP) 154 155# location of help file 156CONCAT(OH, ifdef(`HELP_FILE', HELP_FILE, /usr/lib/sendmail.hf)) 157 158# ignore dots as terminators in incoming messages? 159CONCAT(Oi, confIGNORE_DOTS) 160 161# Insist that the BIND name server be running to resolve names 162ifdef(`confBIND_OPTS', 163 CONCAT(OI, confBIND_OPTS), 164 #OI) 165 166# Forward file search path 167ifdef(`confFORWARD_PATH', 168 CONCAT(OJ, confFORWARD_PATH), 169 #OJ/var/forward/$u:$z/.forward.$w:$z/.forward) 170 171# open connection cache size 172CONCAT(Ok, confMCI_CACHE_SIZE) 173 174# open connection cache timeout 175CONCAT(OK, confMCI_CACHE_TIMEOUT) 176 177# log level 178CONCAT(OL, confLOG_LEVEL) 179 180# send to me too, even in an alias expansion? 181CONCAT(Om, confME_TOO) 182 183# verify RHS in newaliases? 184CONCAT(On, confCHECK_ALIASES) 185 186# default messages to old style headers if no special punctuation? 187CONCAT(Oo, confOLD_STYLE_HEADERS) 188 189# privacy flags 190CONCAT(Op, confPRIVACY_FLAGS) 191 192# who (if anyone) should get extra copies of error messages 193ifdef(`confCOPY_ERRORS_TO', 194 CONCAT(OP, confCOPY_ERRORS_TO), 195 #OPPostmaster) 196 197# slope of queue-only function 198ifdef(`confQUEUE_FACTOR', 199 CONCAT(Oq, confQUEUE_FACTOR), 200 #Oq600000) 201 202# queue directory 203CONCAT(OQ, ifdef(`QUEUE_DIR', QUEUE_DIR, /var/spool/mqueue)) 204 205# read timeout -- now OK per RFC 1123 section 5.3.2 206ifdef(`confREAD_TIMEOUT', 207 CONCAT(Or, confREAD_TIMEOUT), 208 #Ordatablock=10m) 209 210# queue up everything before forking? 211CONCAT(Os, confSAFE_QUEUE) 212 213# status file 214CONCAT(OS, ifdef(`STATUS_FILE', STATUS_FILE, /etc/sendmail.st)) 215 216# default message timeout interval 217CONCAT(OT, confMESSAGE_TIMEOUT) 218 219# time zone handling: 220# if undefined, use system default 221# if defined but null, use TZ envariable passed in 222# if defined and non-null, use that info 223ifelse(confTIME_ZONE, `USE_SYSTEM', `#Ot', 224 confTIME_ZONE, `USE_TZ', `', 225 `CONCAT(Ot, confTIME_ZONE)') 226 227# default UID 228CONCAT(Ou, confDEF_USER_ID) 229 230# list of locations of user database file (null means no lookup) 231CONCAT(OU, ifdef(`USERDB_SPEC', `USERDB_SPEC')) 232 233# load average at which we just queue messages 234CONCAT(Ox, confQUEUE_LA) 235 236# load average at which we refuse connections 237CONCAT(OX, confREFUSE_LA) 238 239# work recipient factor 240ifdef(`confWORK_RECIPIENT_FACTOR', 241 CONCAT(Oy, confWORK_RECIPIENT_FACTOR), 242 #Oy30000) 243 244# deliver each queued job in a separate process? 245CONCAT(OY, confSEPARATE_PROC) 246 247# work class factor 248ifdef(`confWORK_CLASS_FACTOR', 249 CONCAT(Oz, confWORK_CLASS_FACTOR), 250 #Oz1800) 251 252# work time factor 253ifdef(`confWORK_TIME_FACTOR', 254 CONCAT(OZ, confWORK_TIME_FACTOR), 255 #OZ90000) 256 257########################### 258# Message precedences # 259########################### 260 261Pfirst-class=0 262Pspecial-delivery=100 263Plist=-30 264Pbulk=-60 265Pjunk=-100 266 267##################### 268# Trusted users # 269##################### 270 271Troot 272Tdaemon 273Tuucp 274 275######################### 276# Format of headers # 277######################### 278 279H?P?Return-Path: <$?<$<$|$g$.> 280HReceived: $?sfrom $s $.by $j ($v/$Z) id $i; $b 281H?D?Resent-Date: $a 282H?D?Date: $a 283H?F?Resent-From: $q 284H?F?From: $q 285H?x?Full-Name: $x 286HSubject: 287# HPosted-Date: $a 288# H?l?Received-Date: $b 289H?M?Resent-Message-Id: <$t.$i@$j> 290H?M?Message-Id: <$t.$i@$j> 291undivert(6)dnl 292# 293###################################################################### 294###################################################################### 295##### 296##### REWRITING RULES 297##### 298###################################################################### 299###################################################################### 300 301 302########################################### 303### Rulset 3 -- Name Canonicalization ### 304########################################### 305S3 306 307# handle null input (translate to <> special case) 308R$@ $@ <> 309 310# basic textual canonicalization -- note RFC733 heuristic here 311R$*<$*>$*<$*>$* <$2>$3$4$5 strip multiple <> <> 312R$*<$*<$+>$*>$* <$3>$5 2-level <> nesting 313R$*<>$* $@ <> MAIL FROM:<> case 314R$*<$+>$* $2 basic RFC821/822 parsing 315 316# make sure <@a,@b,@c:user@d> syntax is easy to parse -- undone later 317R@ $+ , $+ @ $1 : $2 change all "," to ":" 318 319# localize and dispose of route-based addresses 320R@ $+ : $+ $@ $>6 < @$1 > : $2 handle <route-addr> 321 322# find focus for list syntax 323R $+ : $* ; @ $+ $@ $>6 $1 : $2 ; < @ $3 > list syntax 324R $+ : $* ; $@ $1 : $2; list syntax 325 326# find focus for @ syntax addresses 327R$+ @ $+ $: $1 < @ $2 > focus on domain 328R$+ < $+ @ $+ > $1 $2 < @ $3 > move gaze right 329R$+ < @ $+ > $@ $>6 $1 < @ $2 > already canonical 330 331ifdef(`_NO_UUCP_', `dnl', 332`# convert old-style addresses to a domain-based address 333R$- ! $+ $@ $>6 $2 < @ $1 .UUCP > resolve uucp names 334R$+ . $- ! $+ $@ $>6 $3 < @ $1 . $2 > domain uucps 335R$+ ! $+ $@ $>6 $2 < @ $1 .UUCP > uucp subdomains') 336 337# if we have % signs, take the rightmost one 338R$* % $* $1 @ $2 First make them all @s. 339R$* @ $* @ $* $1 % $2 @ $3 Undo all but the last. 340R$* @ $* $@ $>6 $1 < @ $2 > Insert < > and finish 341 342# else we must be a local name 343 344 345############################################### 346### Ruleset 6 -- bottom half of ruleset 3 ### 347############################################### 348 349# At this point, everything should be in a "local_part<@domain>extra" format. 350S6 351 352# handle special cases for local names 353R$* < @ $=w > $* $: $1 < @ $j . > $3 no domain at all 354R$* < @ $=w . UUCP > $* $: $1 < @ $j . > $3 .UUCP domain 355undivert(2)dnl 356 357ifdef(`UUCP_RELAY', 358`# pass UUCP addresses straight through 359R$* < @ $+ . UUCP > $* $@ $1 < @ $2 . UUCP > $3', 360`# if really UUCP, handle it immediately 361ifdef(`_CLASS_U_', 362`R$* < @ $=U . UUCP > $* $@ $1 < @ $2 . UUCP > $3', `dnl') 363ifdef(`_CLASS_V_', 364`R$* < @ $=V . UUCP > $* $@ $1 < @ $2 . UUCP > $3', `dnl') 365ifdef(`_CLASS_W_', 366`R$* < @ $=W . UUCP > $* $@ $1 < @ $2 . UUCP > $3', `dnl') 367ifdef(`_CLASS_X_', 368`R$* < @ $=X . UUCP > $* $@ $1 < @ $2 . UUCP > $3', `dnl') 369ifdef(`_CLASS_Y_', 370`R$* < @ $=Y . UUCP > $* $@ $1 < @ $2 . UUCP > $3', `dnl') 371 372# try UUCP traffic as a local address 373R$* < @ $+ . UUCP > $* $: $1 < @ $[ $2 $] . UUCP > $3 374ifdef(`_OLD_SENDMAIL_', 375`R$* < @ $+ . $+ . UUCP > $* $@ $1 < @ $2 . $3 . > $4', 376`R$* < @ $+ . . UUCP > $* $@ $1 < @ $2 . > $3')') 377 378# pass to name server to make hostname canonical 379R$* < @ $* $~. > $* $: $1 < @ $[ $2 $3 $] > $4 380 381# handle possible alternate names 382R$* < @ $=w . $m . > $* $: $1 < @ $j . > $3 383R$* < @ $=w . $m > $* $: $1 < @ $j . > $3 384undivert(8)dnl 385 386# if this is the local hostname, make sure we treat is as canonical 387R$* < @ $j > $* $: $1 < @ $j . > $2 388 389 390################################################## 391### Ruleset 4 -- Final Output Post-rewriting ### 392################################################## 393S4 394 395R<> $@ handle <> error addr 396 397# resolve numeric addresses to name if possible 398R$* < @ [ $+ ] > $* $: $1 < @ $[ [$2] $] > $3 lookup numeric internet addr 399 400# strip trailing dot off possibly canonical name 401R$* < @ $+ . > $* $1 < @ $2 > $3 402 403# externalize local domain info 404R$* < $+ > $* $1 $2 $3 defocus 405R@ $+ : @ $+ : $+ @ $1 , @ $2 : $3 <route-addr> canonical 406R@ $* $@ @ $1 ... and exit 407 408ifdef(`_NO_UUCP_', `dnl', 409`# UUCP must always be presented in old form 410R$+ @ $- . UUCP $2!$1 u@h.UUCP => h!u') 411 412# delete duplicate local names 413R$+ % $=w @ $=w $1 @ $j u%host@host => u@host 414 415 416 417############################################################# 418### Ruleset 7 -- recanonicalize and call ruleset zero ### 419### (used for recursive calls) ### 420############################################################# 421 422S7 423R$* $: $>3 $1 424R$* $@ $>0 $1 425 426 427###################################### 428### Ruleset 0 -- Parse Address ### 429###################################### 430 431S0 432 433R<> $#local $: <> special case error msgs 434 435ifdef(`_MAILER_smtp_', 436`# handle numeric address spec 437R$* < @ [ $+ ] > $* $: $1 < @ $[ [$2] $] > $3 numeric internet addr 438R$* < @ [ $+ ] > $* $#smtp $@ [$2] $: $1 @ [$2] $3 numeric internet spec', 439`dnl') 440 441# now delete the local info -- note $=O to find characters that cause forwarding 442R< @ $j . > : $* $@ $>7 $1 @here:... -> ... 443R$* $=O $* < @ $j . > $@ $>7 $1 $2 $3 ...@here -> ... 444 445# short circuit local delivery so forwarded email works 446R$+ < @ $j . > $: $1 < @ $j @ $H > first try hub 447ifdef(`_OLD_SENDMAIL_', 448`R$+ < $+ @ $-:$+ > $# $3 $@ $4 $: $1 < $2 > yep .... 449R$+ < $+ @ $+ > $#smtp $@ $3 $: $1 < $2 > yep .... 450R$+ < $+ @ > $#local $: $1 nope, local address', 451`R$+ < $+ @ $+ > $#local $: $1 yep .... 452R$+ < $+ @ > $#local $: @ $1 nope, local address') 453undivert(3)dnl 454undivert(4)dnl 455 456# resolve remotely connected UUCP links (if any) 457ifdef(`_CLASS_V_', 458`R$* < @ $=V . UUCP > $* $#smtp $@ $V $: <@ $V> : $1 @ $2.UUCP $3', 459 `dnl') 460ifdef(`_CLASS_W_', 461`R$* < @ $=W . UUCP > $* $#smtp $@ $W $: <@ $W> : $1 @ $2.UUCP $3', 462 `dnl') 463ifdef(`_CLASS_X_', 464`R$* < @ $=X . UUCP > $* $#smtp $@ $X $: <@ $X> : $1 @ $2.UUCP $3', 465 `dnl') 466 467# resolve fake top level domains by forwarding to other hosts 468ifdef(`BITNET_RELAY', 469`R$*<@$+.BITNET>$* $#smtp $@ $B $: $1 <@$2.BITNET> $3 user@host.BITNET', 470 `dnl') 471ifdef(`CSNET_RELAY', 472`R$*<@$+.CSNET>$* $#smtp $@ $C $: $1 <@$2.CSNET> $3 user@host.CSNET', 473 `dnl') 474ifdef(`_MAILER_fax_', 475`R$+ < @ $+ .FAX > $#fax $@ $2 $: $1 user@host.FAX', 476`ifdef(`FAX_RELAY', 477`R$*<@$+.FAX>$* $#smtp $@ $F $: $1 <@$2.FAX> $3 user@host.FAX', 478 `dnl')') 479 480ifdef(`UUCP_RELAY', 481`# forward non-local UUCP traffic to our UUCP relay 482R$*<@$*.UUCP>$* $#smtp $@ $Y $: <@ $Y> : $1 @ $2.UUCP $3 uucp mail', 483`ifdef(`_MAILER_uucp_', 484`# forward other UUCP traffic straight to UUCP 485R< @ $+ .UUCP > : $+ $#uucp $@ $1 $: $1:$2 @host.UUCP:... 486R$+ < @ $+ .UUCP > $#uucp $@ $2 $: $1 user@host.UUCP', 487 `dnl')') 488 489ifdef(`_LOCAL_RULES_', 490`# figure out what should stay in our local mail system 491undivert(1)', 492`ifdef(`_MAILER_smtp_', 493`# deal with other remote names 494R$* < @ $* > $* $#smtp $@ $2 $: $1 < @ $2 > $3 user@host.domain')') 495ifdef(`SMART_HOST', ` 496# pass names that still have a host to a smarthost 497R$* < @ $* > $* $: < $S > $1 < @ $2 > $3 glue on smarthost name 498R<$-:$+> $* < @$* > $* $# $1 $@ $2 $: $3 < @ $4 > $5 if non-null, use it 499R<$+> $* < @$* > $* $#suucp $@ $1 $: $2 < @ $3 > $4 if non-null, use it 500R<> $* < @ $* > $* $1 < @ $2 > $3 else strip off gunk', 501`ifdef(`_LOCAL_RULES_', ` 502# reject messages that have host names we do not understand 503R$* < @ $* > $* $#error $@ NOHOST $: Unrecognized host name $2', 504`dnl')') 505ifdef(`_MAILER_USENET_', ` 506# addresses sent to net.group.USENET will get forwarded to a newsgroup 507R$+ . USENET $# usenet $: $1') 508 509ifdef(`_OLD_SENDMAIL_', 510`# forward remaining names to local relay, if any 511R$=L $#local $: $1 special local names 512R$+ $: $1 < @ $R > append relay 513R$+ < @ > $: $1 < @ $H > no relay, try hub 514R$+ < @ > $#local $: $1 no relay or hub: local 515R$+ < @ $j > $#local $: $1 we are relay/hub: local 516R$+ < @ $-:$+ > $# $2 $@ $3 $: $1 deliver to relay/hub 517R$+ < @ $+ > $#smtp $@ $2 $: $1 deliver to relay/hub', 518`# handle locally delivered names 519R$=L $#local $: @ $1 special local names 520R$+ $#local $: $1 regular local names 521 522########################################################################### 523### Ruleset 5 -- special rewriting after aliases have been expanded ### 524### (new sendmail only) ### 525########################################################################### 526 527S5 528 529ifdef(`_MAILER_smtp_', 530`R$+ $: $1 < @ $R > 531R$+ < @ > $: $1 < @ $H > no relay, try hub 532R$+ < @ $j > $@ $1 we are relay/hub: local 533R$+ < @ $-:$+ > $# $2 $@ $3 $: $1 send to relay or hub 534R$+ < @ $+ > $#smtp $@ $2 $: $1 send to relay or hub')') 535# 536###################################################################### 537###################################################################### 538##### 539`##### MAILER DEFINITIONS' 540##### 541###################################################################### 542###################################################################### 543undivert(7)dnl 544