📄 proto.m4
字号:
Plist=-30Pbulk=-60Pjunk=-100###################### Trusted users ######################TrootTdaemonTuucp########################## Format of headers ##########################H?P?Return-Path: $gHReceived: $?sfrom $s $.$?_($?s$|from $.$_) $.by $j ($v/$Z)$?r with $r$. id $i$?u for $u$.; $bH?D?Resent-Date: $aH?D?Date: $aH?F?Resent-From: $qH?F?From: $qH?x?Full-Name: $xHSubject:# HPosted-Date: $a# H?l?Received-Date: $bH?M?Resent-Message-Id: <$t.$i@$j>H?M?Message-Id: <$t.$i@$j>####################################################################################################################################################### REWRITING RULES#################################################################################################################################################undivert(9)dnl############################################## Rulset 3 -- Name Canonicalization ##############################################S3# handle null input (translate to <@> special case)R$@ $@ <@># basic textual canonicalization -- note RFC733 heuristic hereR$*<$*>$*<$*>$* $2$3<$4>$5 strip multiple <> <>R$*<$*<$+>$*>$* <$3>$5 2-level <> nestingR$*<>$* $@ <@> MAIL FROM:<> caseR$*<$+>$* $2 basic RFC821/822 parsing# handle list:; syntax as special caseR$*:;$* $@ $1 :; <@># make sure <@a,@b,@c:user@d> syntax is easy to parse -- undone laterR@ $+ , $+ @ $1 : $2 change all "," to ":"# localize and dispose of route-based addressesR@ $+ : $+ $@ $>_SET_96_ < @$1 > : $2 handle <route-addr># find focus for list syntaxR $+ : $* ; @ $+ $@ $>_SET_96_ $1 : $2 ; < @ $3 > list syntaxR $+ : $* ; $@ $1 : $2; list syntax# find focus for @ syntax addressesR$+ @ $+ $: $1 < @ $2 > focus on domainR$+ < $+ @ $+ > $1 $2 < @ $3 > move gaze rightR$+ < @ $+ > $@ $>_SET_96_ $1 < @ $2 > already canonical# do some sanity checkingR$* < @ $* : $* > $* $1 < @ $2 $3 > $4 nix colons in addrsifdef(`_NO_UUCP_', `dnl',`# convert old-style addresses to a domain-based addressR$- ! $+ $@ $>_SET_96_ $2 < @ $1 .UUCP > resolve uucp namesR$+ . $- ! $+ $@ $>_SET_96_ $3 < @ $1 . $2 > domain uucpsR$+ ! $+ $@ $>_SET_96_ $2 < @ $1 .UUCP > uucp subdomains')# if we have % signs, take the rightmost oneR$* % $* $1 @ $2 First make them all @s.R$* @ $* @ $* $1 % $2 @ $3 Undo all but the last.R$* @ $* $@ $>_SET_96_ $1 < @ $2 > Insert < > and finish# else we must be a local name################################################### Ruleset _SET_96_ -- bottom half of ruleset 3 #################################################### At this point, everything should be in a "local_part<@domain>extra" format.S`'_SET_96_# handle special cases for local namesR$* < @ localhost > $* $: $1 < @ $j . > $2 no domain at allR$* < @ localhost . $m > $* $: $1 < @ $j . > $2 local domainifdef(`_NO_UUCP_', `dnl',`R$* < @ localhost . UUCP > $* $: $1 < @ $j . > $2 .UUCP domain')R$* < @ [ $+ ] > $* $: $1 < @@ [ $2 ] > $3 mark [a.b.c.d]R$* < @@ $=w > $* $: $1 < @ $j . > $3 self-literalR$* < @@ $+ > $* $@ $1 < @ $2 > $3 canon IP addrifdef(`DOMAIN_TABLE', `# look up unqualified domains in the domain tableR$* < @ $- > $* $: $1 < @ $(domaintable $2 $) > $3',`dnl')undivert(2)dnlifdef(`_NO_UUCP_', `dnl',`ifdef(`UUCP_RELAY',`# pass UUCP addresses straight throughR$* < @ $+ . UUCP > $* $@ $1 < @ $2 . UUCP . > $3',`# if really UUCP, handle it immediatelyifdef(`_CLASS_U_',`R$* < @ $=U . UUCP > $* $@ $1 < @ $2 . UUCP . > $3', `dnl')ifdef(`_CLASS_V_',`R$* < @ $=V . UUCP > $* $@ $1 < @ $2 . UUCP . > $3', `dnl')ifdef(`_CLASS_W_',`R$* < @ $=W . UUCP > $* $@ $1 < @ $2 . UUCP . > $3', `dnl')ifdef(`_CLASS_X_',`R$* < @ $=X . UUCP > $* $@ $1 < @ $2 . UUCP . > $3', `dnl')ifdef(`_CLASS_Y_',`R$* < @ $=Y . UUCP > $* $@ $1 < @ $2 . UUCP . > $3', `dnl')# try UUCP traffic as a local addressR$* < @ $+ . UUCP > $* $: $1 < @ $[ $2 $] . UUCP . > $3ifdef(`_OLD_SENDMAIL_',`R$* < @ $+ . $+ . UUCP . > $* $@ $1 < @ $2 . $3 . > $4',`R$* < @ $+ . . UUCP . > $* $@ $1 < @ $2 . > $3')')')ifdef(`_NO_CANONIFY_', `dnl',`# pass to name server to make hostname canonicalR$* < @ $* $~P > $* $: $1 < @ $[ $2 $3 $] > $4')# local host aliases and pseudo-domains are always canonicalR$* < @ $=w > $* $: $1 < @ $2 . > $3R$* < @ $* $=P > $* $: $1 < @ $2 $3 . > $4R$* < @ $* . . > $* $1 < @ $2 . > $3# if this is the local hostname, make sure we treat is as canonicalR$* < @ $j > $* $: $1 < @ $j . > $2##################################################### Ruleset 4 -- Final Output Post-rewriting #####################################################S4R$*<@> $@ $1 handle <> and list:;# strip trailing dot off possibly canonical nameR$* < @ $+ . > $* $1 < @ $2 > $3# externalize local domain infoR$* < $+ > $* $1 $2 $3 defocusR@ $+ : @ $+ : $+ @ $1 , @ $2 : $3 <route-addr> canonicalR@ $* $@ @ $1 ... and exitifdef(`_NO_UUCP_', `dnl',`# UUCP must always be presented in old formR$+ @ $- . UUCP $2!$1 u@h.UUCP => h!u')# delete duplicate local namesR$+ % $=w @ $=w $1 @ $j u%host@host => u@host################################################################# Ruleset _SET_97_ -- recanonicalize and call ruleset zero ###### (used for recursive calls) #################################################################S`'_SET_97_R$* $: $>3 $1R$* $@ $>0 $1######################################### Ruleset 0 -- Parse Address #########################################S0R<@> $#_LOCAL_ $: <> special case error msgsR$* : $* ; $#error $@ USAGE $: "list:; syntax illegal for recipient addresses"R<@ $+> $#error $@ USAGE $: "user address required"R<$* : $* > $#error $@ USAGE $: "colon illegal in host name part"ifdef(`_MAILER_smtp_',`# handle numeric address specR$* < @ [ $+ ] > $* $: $>_SET_98_ $1 < @ [ $2 ] > $3 numeric internet specR$* < @ [ $+ ] > $* $#_SMTP_ $@ [$2] $: $1 < @ [$2] > $3 still numeric: send', `dnl')# now delete the local info -- note $=O to find characters that cause forwardingR$* < @ > $* $@ $>_SET_97_ $1 user@ => userR< @ $=w . > : $* $@ $>_SET_97_ $2 @here:... -> ...R$* $=O $* < @ $=w . > $@ $>_SET_97_ $1 $2 $3 ...@here -> ...# handle local hacksR$* $: $>_SET_98_ $1# short circuit local delivery so forwarded email worksifdef(`_LOCAL_NOT_STICKY_',`R$=L < @ $=w . > $#_LOCAL_ $: @ $1 special local namesR$+ < @ $=w . > $#_LOCAL_ $: $1 dispose directly',`R$+ < @ $=w . > $: $1 < @ $2 . @ $H > first try hubifdef(`_OLD_SENDMAIL_',`R$+ < $+ @ $-:$+ > $# $3 $@ $4 $: $1 < $2 > yep ....R$+ < $+ @ $+ > $#relay $@ $3 $: $1 < $2 > yep ....R$+ < $+ @ > $#_LOCAL_ $: $1 nope, local address',`R$+ < $+ @ $+ > $#_LOCAL_ $: $1 yep ....R$+ < $+ @ > $#_LOCAL_ $: @ $1 nope, local address')')ifdef(`MAILER_TABLE',`# not local -- try mailer table lookupR$* <@ $+ > $* $: < $2 > $1 < @ $2 > $3 extract host nameR< $+ . > $* $: < $1 > $2 strip trailing dotR< $+ > $* $: < $(mailertable $1 $) > $2 lookupR< $- : $+ > $* $# $1 $@ $2 $: $3 check -- resolved?R< $+ > $* $: $>90 <$1> $2 try domain',`dnl')undivert(4)dnlifdef(`_NO_UUCP_', `dnl',`# resolve remotely connected UUCP links (if any)ifdef(`_CLASS_V_',`R$* < @ $=V . UUCP . > $* $: $>_SET_95_ < $V > $1 <@$2.UUCP.> $3', `dnl')ifdef(`_CLASS_W_',`R$* < @ $=W . UUCP . > $* $: $>_SET_95_ < $W > $1 <@$2.UUCP.> $3', `dnl')ifdef(`_CLASS_X_',`R$* < @ $=X . UUCP . > $* $: $>_SET_95_ < $X > $1 <@$2.UUCP.> $3', `dnl')')# resolve fake top level domains by forwarding to other hostsifdef(`BITNET_RELAY',`R$*<@$+.BITNET.>$* $: $>_SET_95_ < $B > $1 <@$2.BITNET.> $3 user@host.BITNET', `dnl')ifdef(`_MAILER_pop_',`R$+ < @ POP. > $#pop $: $1 user@POP', `dnl')ifdef(`_MAILER_fax_',`R$+ < @ $+ .FAX. > $#fax $@ $2 $: $1 user@host.FAX',`ifdef(`FAX_RELAY',`R$*<@$+.FAX.>$* $: $>_SET_95_ < $F > $1 <@$2.FAX.> $3 user@host.FAX', `dnl')')ifdef(`UUCP_RELAY',`# forward non-local UUCP traffic to our UUCP relayR$*<@$*.UUCP.>$* $: $>_SET_95_ < $Y > $1 <@$2.UUCP.> $3 uucp mail',`ifdef(`_MAILER_uucp_',`# forward other UUCP traffic straight to UUCPR$* < @ $+ .UUCP. > $* $#uucp $@ $2 $: $1 < @ $2 .UUCP. > $3 user@host.UUCP', `dnl')')ifdef(`_MAILER_usenet_', `# addresses sent to net.group.USENET will get forwarded to a newsgroupR$+ . USENET $#usenet $: $1', `dnl')ifdef(`_LOCAL_RULES_',`# figure out what should stay in our local mail systemundivert(1)', `dnl')# pass names that still have a host to a smarthost (if defined)R$* < @ $* > $* $: $>_SET_95_ < $S > $1 < @ $2 > $3 glue on smarthost name# deal with other remote namesifdef(`_MAILER_smtp_',`R$* < @$* > $* $#_SMTP_ $@ $2 $: $1 < @ $2 > $3 user@host.domain',`R$* < @$* > $* $#error $@NOHOST $: Unrecognized host name $2')ifdef(`_OLD_SENDMAIL_',`# forward remaining names to local relay, if anyR$=L $#_LOCAL_ $: $1 special local namesR$+ $: $>_SET_95_ < $R > $1 try relayR$+ $: $>_SET_95_ < $H > $1 try hubR$+ $#_LOCAL_ $: $1 no relay or hub: local',`# if this is quoted, strip the quotes and try againR$+ $: $(dequote $1 $) strip quotesR$+ $=O $+ $@ $>_SET_97_ $1 $2 $3 try again# handle locally delivered namesR$=L $#_LOCAL_ $: @ $1 special local namesR$+ $#_LOCAL_ $: $1 regular local names############################################################################## Ruleset 5 -- special rewriting after aliases have been expanded ###### (new sendmail only) ##############################################################################S5# see if we have a relay or a hubR$+ $: < $R > $1 try relayR< > $+ $: < $H > $1 try hubR< > $+ $@ $1 nope, give upR< $- : $+ > $+ $: $>_SET_95_ < $1 : $2 > $3 < @ $2 >R< $+ > $+ $@ $>_SET_95_ < $1 > $2 < @ $1 >')ifdef(`MAILER_TABLE',`###################################################################### Ruleset 90 -- try domain part of mailertable entry ###### (new sendmail only) ######################################################################S90R$* <$- . $+ > $* $: $1$2 < $(mailertable .$3 $@ $1$2 $@ $2 $) > $4R$* <$- : $+ > $* $# $2 $@ $3 $: $4 check -- resolved?R$* < . $+ > $* $@ $>90 $1 . <$2> $3 no -- strip & try againR$* < $* > $* $: < $(mailertable . $@ $1$2 $) > $3 try "."R<$- : $+ > $* $# $1 $@ $2 $: $3 "." found?R< $* > $* $@ $2 no mailertable match',`dnl')###################################################################### Ruleset _SET_95_ -- canonify mailer:host syntax to triple ######################################################################S`'_SET_95_R< > $* $@ $1 strip off null relayR< $- : $+ > $* $# $1 $@ $2 $: $3 try qualified mailerR< $=w > $* $@ $2 delete local hostR< $+ > $* $#_RELAY_ $@ $1 $: $2 use unqualified mailer###################################################################### Ruleset _SET_98_ -- local part of ruleset zero (can be null) ######################################################################S`'_SET_98_undivert(3)dnl##################################################################################################################################################`##### MAILER DEFINITIONS'#################################################################################################################################################undivert(7)dnl
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -