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.40 (Berkeley) 05/24/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$* < @ localhost > $* $: $1 < @ $j . > $2 no domain at all 384R$* < @ localhost . $m > $* $: $1 < @ $j . > $2 local domain 385ifdef(`_NO_UUCP_', `dnl', 386`R$* < @ localhost . UUCP > $* $: $1 < @ $j . > $2 .UUCP domain') 387undivert(2)dnl 388 389ifdef(`_NO_UUCP_', `dnl', 390`ifdef(`UUCP_RELAY', 391`# pass UUCP addresses straight through 392R$* < @ $+ . UUCP > $* $@ $1 < @ $2 . UUCP > $3', 393`# if really UUCP, handle it immediately 394ifdef(`_CLASS_U_', 395`R$* < @ $=U . UUCP > $* $@ $1 < @ $2 . UUCP > $3', `dnl') 396ifdef(`_CLASS_V_', 397`R$* < @ $=V . UUCP > $* $@ $1 < @ $2 . UUCP > $3', `dnl') 398ifdef(`_CLASS_W_', 399`R$* < @ $=W . UUCP > $* $@ $1 < @ $2 . UUCP > $3', `dnl') 400ifdef(`_CLASS_X_', 401`R$* < @ $=X . UUCP > $* $@ $1 < @ $2 . UUCP > $3', `dnl') 402ifdef(`_CLASS_Y_', 403`R$* < @ $=Y . UUCP > $* $@ $1 < @ $2 . UUCP > $3', `dnl') 404 405# try UUCP traffic as a local address 406R$* < @ $+ . UUCP > $* $: $1 < @ $[ $2 $] . UUCP > $3 407ifdef(`_OLD_SENDMAIL_', 408`R$* < @ $+ . $+ . UUCP > $* $@ $1 < @ $2 . $3 . > $4', 409`R$* < @ $+ . . UUCP > $* $@ $1 < @ $2 . > $3')') 410') 411ifdef(`_NO_CANONIFY_', `dnl', 412`# pass to name server to make hostname canonical 413R$* < @ $* $~P > $* $: $1 < @ $[ $2 $3 $] > $4 414') 415undivert(8)dnl 416 417# if this is the local hostname, make sure we treat is as canonical 418R$* < @ $j > $* $: $1 < @ $j . > $2 419 420 421################################################## 422### Ruleset 4 -- Final Output Post-rewriting ### 423################################################## 424S4 425 426R$*<@> $@ $1 handle <> and list:; 427 428# resolve numeric addresses to name if possible 429R$* < @ [ $+ ] > $* $: $1 < @ $[ [$2] $] > $3 lookup numeric internet addr 430 431# strip trailing dot off possibly canonical name 432R$* < @ $+ . > $* $1 < @ $2 > $3 433 434# externalize local domain info 435R$* < $+ > $* $1 $2 $3 defocus 436R@ $+ : @ $+ : $+ @ $1 , @ $2 : $3 <route-addr> canonical 437R@ $* $@ @ $1 ... and exit 438 439ifdef(`_NO_UUCP_', `dnl', 440`# UUCP must always be presented in old form 441R$+ @ $- . UUCP $2!$1 u@h.UUCP => h!u') 442 443# delete duplicate local names 444R$+ % $=w @ $=w $1 @ $j u%host@host => u@host 445 446 447 448############################################################# 449### Ruleset 7 -- recanonicalize and call ruleset zero ### 450### (used for recursive calls) ### 451############################################################# 452 453S7 454R$* $: $>3 $1 455R$* $@ $>0 $1 456 457 458###################################### 459### Ruleset 0 -- Parse Address ### 460###################################### 461 462S0 463 464R<@> $#local $: <> special case error msgs 465R$*:;<@> $#error $@ USAGE $: "list:; syntax illegal for recipient addresses" 466 467ifdef(`_MAILER_smtp_', 468`# handle numeric address spec 469R$* < @ [ $+ ] > $* $: $1 < @ $[ [$2] $] > $3 numeric internet addr 470R$* < @ [ $+ ] > $* $#smtp $@ [$2] $: $1 @ [$2] $3 numeric internet spec', 471`dnl') 472 473# now delete the local info -- note $=O to find characters that cause forwarding 474R$* < @ > $* $@ $>7 $1 user@ => user 475R< @ $j . > : $* $@ $>7 $1 @here:... -> ... 476R$* $=O $* < @ $j . > $@ $>7 $1 $2 $3 ...@here -> ... 477ifdef(`MAILER_TABLE', 478` 479# try mailer table lookup 480R$* < @ $+ > $* $: $1 < @ $(mailertable $2 $) > $3 481R$* < @ $-:$+ > $* $# $2 $@ $3 $: $1 < @ $3 > $4 found a match', 482`dnl') 483 484# short circuit local delivery so forwarded email works 485ifdef(`_LOCAL_NOT_STICKY_', 486`R$=L < @ $j . > $#local $: @ $1 special local names 487R$+ < @ $j . > $#local $: $1 dispose directly', 488`R$+ < @ $j . > $: $1 < @ $j @ $H > first try hub 489ifdef(`_OLD_SENDMAIL_', 490`R$+ < $+ @ $-:$+ > $# $3 $@ $4 $: $1 < $2 > yep .... 491R$+ < $+ @ $+ > $#relay $@ $3 $: $1 < $2 > yep .... 492R$+ < $+ @ > $#local $: $1 nope, local address', 493`R$+ < $+ @ $+ > $#local $: $1 yep .... 494R$+ < $+ @ > $#local $: @ $1 nope, local address')') 495undivert(3)dnl 496undivert(4)dnl 497 498# resolve remotely connected UUCP links (if any) 499ifdef(`_CLASS_V_', 500`R$* < @ $=V . UUCP > $* $#smtp $@ $V $: <@ $V> : $1 @ $2.UUCP $3', 501 `dnl') 502ifdef(`_CLASS_W_', 503`R$* < @ $=W . UUCP > $* $#smtp $@ $W $: <@ $W> : $1 @ $2.UUCP $3', 504 `dnl') 505ifdef(`_CLASS_X_', 506`R$* < @ $=X . UUCP > $* $#smtp $@ $X $: <@ $X> : $1 @ $2.UUCP $3', 507 `dnl') 508 509# resolve fake top level domains by forwarding to other hosts 510ifdef(`BITNET_RELAY', 511`R$*<@$+.BITNET>$* $#smtp $@ $B. $: $1 <@$2.BITNET> $3 user@host.BITNET', 512 `dnl') 513ifdef(`CSNET_RELAY', 514`R$*<@$+.CSNET>$* $#smtp $@ $C. $: $1 <@$2.CSNET> $3 user@host.CSNET', 515 `dnl') 516ifdef(`_MAILER_fax_', 517`R$+ < @ $+ .FAX > $#fax $@ $2 $: $1 user@host.FAX', 518`ifdef(`FAX_RELAY', 519`R$*<@$+.FAX>$* $#smtp $@ $F. $: $1 <@$2.FAX> $3 user@host.FAX', 520 `dnl')') 521 522ifdef(`UUCP_RELAY', 523`# forward non-local UUCP traffic to our UUCP relay 524R$*<@$*.UUCP>$* $#smtp $@ $Y. $: <@ $Y> : $1 @ $2.UUCP $3 uucp mail', 525`ifdef(`_MAILER_uucp_', 526`# forward other UUCP traffic straight to UUCP 527R< @ $+ .UUCP > : $+ $#uucp $@ $1 $: $2 @host.UUCP:... 528R$+ < @ $+ .UUCP > $#uucp $@ $2 $: $1 user@host.UUCP', 529 `dnl')') 530 531ifdef(`_LOCAL_RULES_', 532`# figure out what should stay in our local mail system 533undivert(1)', 534`ifdef(`_MAILER_smtp_', 535`# deal with other remote names 536R$* < @ $* > $* $#smtp $@ $2 $: $1 < @ $2 > $3 user@host.domain')') 537ifdef(`SMART_HOST', ` 538# pass names that still have a host to a smarthost 539R$* < @ $* > $* $: < $S > $1 < @ $2 > $3 glue on smarthost name 540R<$-:$+> $* < @$* > $* $# $1 $@ $2 $: $3 < @ $4 > $5 if non-null, use it 541R<$+> $* < @$* > $* $#suucp $@ $1 $: $2 < @ $3 > $4 if non-null, use it 542R<> $* < @ $* > $* $1 < @ $2 > $3 else strip off gunk', 543`ifdef(`_LOCAL_RULES_', ` 544# reject messages that have host names we do not understand 545R$* < @ $* > $* $#error $@ NOHOST $: Unrecognized host name $2', 546`dnl')') 547ifdef(`_MAILER_USENET_', ` 548# addresses sent to net.group.USENET will get forwarded to a newsgroup 549R$+ . USENET $# usenet $: $1') 550 551ifdef(`_OLD_SENDMAIL_', 552`# forward remaining names to local relay, if any 553R$=L $#local $: $1 special local names 554R$+ $: $1 < @ $R > append relay 555R$+ < @ > $: $1 < @ $H > no relay, try hub 556R$+ < @ > $#local $: $1 no relay or hub: local 557R$+ < @ $j > $#local $: $1 we are relay/hub: local 558R$+ < @ $-:$+ > $# $2 $@ $3 $: $1 deliver to relay/hub 559R$+ < @ $+ > $#relay $@ $2 $: $1 deliver to relay/hub', 560 561`# if this is quoted, strip the quotes and try again 562R$+ $: $(dequote $1 $) strip quotes 563R$* $=O $* $@ $>7 $1 $2 $3 try again 564 565# handle locally delivered names 566R$=L $#local $: @ $1 special local names 567R$+ $#local $: $1 regular local names 568 569########################################################################### 570### Ruleset 5 -- special rewriting after aliases have been expanded ### 571### (new sendmail only) ### 572########################################################################### 573 574S5 575 576# see if we have a relay or a hub 577R$+ $: $1 < @ $R > 578R$+ < @ > $: $1 < @ $H > no relay, try hub 579R$+ < @ $j > $@ $1 we are relay/hub: local 580R$+ < @ $-:$+ > $# $2 $@ $3 $: $1 send to relay or hub 581ifdef(`_MAILER_smtp_', 582`R$+ < @ $+ > $#relay $@ $2 $: $1 send to relay or hub')') 583# 584###################################################################### 585###################################################################### 586##### 587`##### MAILER DEFINITIONS' 588##### 589###################################################################### 590###################################################################### 591undivert(7)dnl 592