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