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.20 (Berkeley) 03/08/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 and list syntax (translate to <@> special case) 308R$@ $@ <@> 309R$*:;$* $@ $1 ;: <@> 310 311# basic textual canonicalization -- note RFC733 heuristic here 312R$*<$*>$*<$*>$* <$2>$3$4$5 strip multiple <> <> 313R$*<$*<$+>$*>$* <$3>$5 2-level <> nesting 314R$*<>$* $@ <@> MAIL FROM:<> case 315R$*<$+>$* $2 basic RFC821/822 parsing 316 317# make sure <@a,@b,@c:user@d> syntax is easy to parse -- undone later 318R@ $+ , $+ @ $1 : $2 change all "," to ":" 319 320# localize and dispose of route-based addresses 321R@ $+ : $+ $@ $>6 < @$1 > : $2 handle <route-addr> 322 323# find focus for list syntax 324R $+ : $* ; @ $+ $@ $>6 $1 : $2 ; < @ $3 > list syntax 325R $+ : $* ; $@ $1 : $2; list syntax 326 327# find focus for @ syntax addresses 328R$+ @ $+ $: $1 < @ $2 > focus on domain 329R$+ < $+ @ $+ > $1 $2 < @ $3 > move gaze right 330R$+ < @ $+ > $@ $>6 $1 < @ $2 > already canonical 331 332ifdef(`_NO_UUCP_', `dnl', 333`# convert old-style addresses to a domain-based address 334R$- ! $+ $@ $>6 $2 < @ $1 .UUCP > resolve uucp names 335R$+ . $- ! $+ $@ $>6 $3 < @ $1 . $2 > domain uucps 336R$+ ! $+ $@ $>6 $2 < @ $1 .UUCP > uucp subdomains') 337 338# if we have % signs, take the rightmost one 339R$* % $* $1 @ $2 First make them all @s. 340R$* @ $* @ $* $1 % $2 @ $3 Undo all but the last. 341R$* @ $* $@ $>6 $1 < @ $2 > Insert < > and finish 342 343# else we must be a local name 344 345 346############################################### 347### Ruleset 6 -- bottom half of ruleset 3 ### 348############################################### 349 350# At this point, everything should be in a "local_part<@domain>extra" format. 351S6 352 353# handle special cases for local names 354R$* < @ $=w > $* $: $1 < @ $j . > $3 no domain at all 355R$* < @ $=w . UUCP > $* $: $1 < @ $j . > $3 .UUCP domain 356undivert(2)dnl 357 358ifdef(`UUCP_RELAY', 359`# pass UUCP addresses straight through 360R$* < @ $+ . UUCP > $* $@ $1 < @ $2 . UUCP > $3', 361`# if really UUCP, handle it immediately 362ifdef(`_CLASS_U_', 363`R$* < @ $=U . UUCP > $* $@ $1 < @ $2 . UUCP > $3', `dnl') 364ifdef(`_CLASS_V_', 365`R$* < @ $=V . UUCP > $* $@ $1 < @ $2 . UUCP > $3', `dnl') 366ifdef(`_CLASS_W_', 367`R$* < @ $=W . UUCP > $* $@ $1 < @ $2 . UUCP > $3', `dnl') 368ifdef(`_CLASS_X_', 369`R$* < @ $=X . UUCP > $* $@ $1 < @ $2 . UUCP > $3', `dnl') 370ifdef(`_CLASS_Y_', 371`R$* < @ $=Y . UUCP > $* $@ $1 < @ $2 . UUCP > $3', `dnl') 372 373# try UUCP traffic as a local address 374R$* < @ $+ . UUCP > $* $: $1 < @ $[ $2 $] . UUCP > $3 375ifdef(`_OLD_SENDMAIL_', 376`R$* < @ $+ . $+ . UUCP > $* $@ $1 < @ $2 . $3 . > $4', 377`R$* < @ $+ . . UUCP > $* $@ $1 < @ $2 . > $3')') 378 379# pass to name server to make hostname canonical 380R$* < @ $* $~. > $* $: $1 < @ $[ $2 $3 $] > $4 381 382# handle possible alternate names 383R$* < @ $=w . $m . > $* $: $1 < @ $j . > $3 384R$* < @ $=w . $m > $* $: $1 < @ $j . > $3 385undivert(8)dnl 386 387# if this is the local hostname, make sure we treat is as canonical 388R$* < @ $j > $* $: $1 < @ $j . > $2 389 390 391################################################## 392### Ruleset 4 -- Final Output Post-rewriting ### 393################################################## 394S4 395 396R$*<@> $@ $1 handle <> and list:; 397 398# resolve numeric addresses to name if possible 399R$* < @ [ $+ ] > $* $: $1 < @ $[ [$2] $] > $3 lookup numeric internet addr 400 401# strip trailing dot off possibly canonical name 402R$* < @ $+ . > $* $1 < @ $2 > $3 403 404# externalize local domain info 405R$* < $+ > $* $1 $2 $3 defocus 406R@ $+ : @ $+ : $+ @ $1 , @ $2 : $3 <route-addr> canonical 407R@ $* $@ @ $1 ... and exit 408 409ifdef(`_NO_UUCP_', `dnl', 410`# UUCP must always be presented in old form 411R$+ @ $- . UUCP $2!$1 u@h.UUCP => h!u') 412 413# delete duplicate local names 414R$+ % $=w @ $=w $1 @ $j u%host@host => u@host 415 416 417 418############################################################# 419### Ruleset 7 -- recanonicalize and call ruleset zero ### 420### (used for recursive calls) ### 421############################################################# 422 423S7 424R$* $: $>3 $1 425R$* $@ $>0 $1 426 427 428###################################### 429### Ruleset 0 -- Parse Address ### 430###################################### 431 432S0 433 434R<@> $#local $: <> special case error msgs 435 436ifdef(`_MAILER_smtp_', 437`# handle numeric address spec 438R$* < @ [ $+ ] > $* $: $1 < @ $[ [$2] $] > $3 numeric internet addr 439R$* < @ [ $+ ] > $* $#smtp $@ [$2] $: $1 @ [$2] $3 numeric internet spec', 440`dnl') 441 442# now delete the local info -- note $=O to find characters that cause forwarding 443R$* < @ > $* $@ $>7 $1 user@ => user 444R< @ $j . > : $* $@ $>7 $1 @here:... -> ... 445R$* $=O $* < @ $j . > $@ $>7 $1 $2 $3 ...@here -> ... 446 447# short circuit local delivery so forwarded email works 448ifdef(`_LOCAL_NOT_STICKY_', 449`R$=L < @ $j . > $#local $: @ $1 special local names 450R$+ < @ $j . > $#local $: $1 dispose directly', 451`R$+ < @ $j . > $: $1 < @ $j @ $H > first try hub 452ifdef(`_OLD_SENDMAIL_', 453`R$+ < $+ @ $-:$+ > $# $3 $@ $4 $: $1 < $2 > yep .... 454R$+ < $+ @ $+ > $#smtp $@ $3 $: $1 < $2 > yep .... 455R$+ < $+ @ > $#local $: $1 nope, local address', 456`R$+ < $+ @ $+ > $#local $: $1 yep .... 457R$+ < $+ @ > $#local $: @ $1 nope, local address')') 458undivert(3)dnl 459undivert(4)dnl 460 461# resolve remotely connected UUCP links (if any) 462ifdef(`_CLASS_V_', 463`R$* < @ $=V . UUCP > $* $#smtp $@ $V $: <@ $V> : $1 @ $2.UUCP $3', 464 `dnl') 465ifdef(`_CLASS_W_', 466`R$* < @ $=W . UUCP > $* $#smtp $@ $W $: <@ $W> : $1 @ $2.UUCP $3', 467 `dnl') 468ifdef(`_CLASS_X_', 469`R$* < @ $=X . UUCP > $* $#smtp $@ $X $: <@ $X> : $1 @ $2.UUCP $3', 470 `dnl') 471 472# resolve fake top level domains by forwarding to other hosts 473ifdef(`BITNET_RELAY', 474`R$*<@$+.BITNET>$* $#smtp $@ $B $: $1 <@$2.BITNET> $3 user@host.BITNET', 475 `dnl') 476ifdef(`CSNET_RELAY', 477`R$*<@$+.CSNET>$* $#smtp $@ $C $: $1 <@$2.CSNET> $3 user@host.CSNET', 478 `dnl') 479ifdef(`_MAILER_fax_', 480`R$+ < @ $+ .FAX > $#fax $@ $2 $: $1 user@host.FAX', 481`ifdef(`FAX_RELAY', 482`R$*<@$+.FAX>$* $#smtp $@ $F $: $1 <@$2.FAX> $3 user@host.FAX', 483 `dnl')') 484 485ifdef(`UUCP_RELAY', 486`# forward non-local UUCP traffic to our UUCP relay 487R$*<@$*.UUCP>$* $#smtp $@ $Y $: <@ $Y> : $1 @ $2.UUCP $3 uucp mail', 488`ifdef(`_MAILER_uucp_', 489`# forward other UUCP traffic straight to UUCP 490R< @ $+ .UUCP > : $+ $#uucp $@ $1 $: $1:$2 @host.UUCP:... 491R$+ < @ $+ .UUCP > $#uucp $@ $2 $: $1 user@host.UUCP', 492 `dnl')') 493 494ifdef(`_LOCAL_RULES_', 495`# figure out what should stay in our local mail system 496undivert(1)', 497`ifdef(`_MAILER_smtp_', 498`# deal with other remote names 499R$* < @ $* > $* $#smtp $@ $2 $: $1 < @ $2 > $3 user@host.domain')') 500ifdef(`SMART_HOST', ` 501# pass names that still have a host to a smarthost 502R$* < @ $* > $* $: < $S > $1 < @ $2 > $3 glue on smarthost name 503R<$-:$+> $* < @$* > $* $# $1 $@ $2 $: $3 < @ $4 > $5 if non-null, use it 504R<$+> $* < @$* > $* $#suucp $@ $1 $: $2 < @ $3 > $4 if non-null, use it 505R<> $* < @ $* > $* $1 < @ $2 > $3 else strip off gunk', 506`ifdef(`_LOCAL_RULES_', ` 507# reject messages that have host names we do not understand 508R$* < @ $* > $* $#error $@ NOHOST $: Unrecognized host name $2', 509`dnl')') 510ifdef(`_MAILER_USENET_', ` 511# addresses sent to net.group.USENET will get forwarded to a newsgroup 512R$+ . USENET $# usenet $: $1') 513 514ifdef(`_OLD_SENDMAIL_', 515`# forward remaining names to local relay, if any 516R$=L $#local $: $1 special local names 517R$+ $: $1 < @ $R > append relay 518R$+ < @ > $: $1 < @ $H > no relay, try hub 519R$+ < @ > $#local $: $1 no relay or hub: local 520R$+ < @ $j > $#local $: $1 we are relay/hub: local 521R$+ < @ $-:$+ > $# $2 $@ $3 $: $1 deliver to relay/hub 522R$+ < @ $+ > $#smtp $@ $2 $: $1 deliver to relay/hub', 523`# handle locally delivered names 524R$=L $#local $: @ $1 special local names 525R$+ $#local $: $1 regular local names 526 527########################################################################### 528### Ruleset 5 -- special rewriting after aliases have been expanded ### 529### (new sendmail only) ### 530########################################################################### 531 532S5 533 534ifdef(`_MAILER_smtp_', 535`R$+ $: $1 < @ $R > 536R$+ < @ > $: $1 < @ $H > no relay, try hub 537R$+ < @ $j > $@ $1 we are relay/hub: local 538R$+ < @ $-:$+ > $# $2 $@ $3 $: $1 send to relay or hub 539R$+ < @ $+ > $#smtp $@ $2 $: $1 send to relay or hub')') 540# 541###################################################################### 542###################################################################### 543##### 544`##### MAILER DEFINITIONS' 545##### 546###################################################################### 547###################################################################### 548undivert(7)dnl 549