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