################################################## ### Ruleset 4 -- Final Output Post-rewriting ### ################################################## S4 R$* <@> $@ handle <> and list:; # strip trailing dot off possibly canonical name R$* < @ $+ . > $* $1 < @ $2 > $3 # eliminate internal code -- should never get this far! R$* < @ *LOCAL* > $* $1 < @ $j > $2 # externalize local domain info R$* < $+ > $* $1 $2 $3 defocus R@ $+ : @ $+ : $+ @ $1 , @ $2 : $3 canonical R@ $* $@ @ $1 ... and exit # UUCP must always be presented in old form R$+ @ $- . UUCP $2!$1 u@h.UUCP => h!u # delete duplicate local names R$+ % $=w @ $=w $1 @ $2 u%host@host => u@host ############################################################## ### Ruleset 97 -- recanonicalize and call ruleset zero ### ### (used for recursive calls) ### ############################################################## S97 R$* $: $>3 $1 R$* $@ $>0 $1 ########################################################################### ### Ruleset 5 -- special rewriting after aliases have been expanded ### ########################################################################### S5 # deal with plussed users so aliases work nicely R$+ + * $#local $@ $&h $: $1 R$+ + $* $#local $@ + $2 $: $1 + * # prepend an empty "forward host" on the front R$+ $: <> $1 # send unrecognized local users to a relay host #R< > $+ $: < $L . > $( user $1 $) look up user #R< $* > $+ <> $* $: < > $2 $3 found; strip $L #R< $* . > $+ $: < $1 > $2 strip extra dot # see if we have a relay or a hub R< > $+ $: < $H > $1 try hub R< > $+ $: < $R > $1 try relay R< > $+ $: < > < $1 $(dequote "" $&h $) > nope, restore +detail R< > < $+ + $* > $* < > < $1 > + $2 $3 find the user part R< > < $+ > + $* $#local $@ $2 $: @ $1 strip the extra + R< > < $+ > $@ $1 no +detail R$+ $: $1 $(dequote "" $&h $) add +detail back in R< local : $* > $* $: $>95 < local : $1 > $2 no host extension R< error : $* > $* $: $>95 < error : $1 > $2 no host extension R< $- : $+ > $+ $: $>95 < $1 : $2 > $3 < @ $2 > R< $+ > $+ $@ $>95 < $1 > $2 < @ $1 > ################################################################### ### Ruleset 90 -- try domain part of mailertable entry ### ################################################################### ################################################################### ### Ruleset 95 -- canonify mailer:[user@]host syntax to triple ### ################################################################### S95 R< > $* $@ $1 strip off null relay R< error : $- $+ > $* $#error $@ $( dequote $1 $) $: $2 R< local : $* > $* $>CanonLocal < $1 > $2 R< $- : $+ @ $+ > $*<$*>$* $# $1 $@ $3 $: $2<@$3> use literal user R< $- : $+ > $* $# $1 $@ $2 $: $3 try qualified mailer R< $=w > $* $@ $2 delete local host R< $+ > $* $#$N $@ $1 $: $2 use unqualified mailer ################################################################### ### Ruleset CanonLocal -- canonify local: syntax ### ################################################################### SCanonLocal # strip trailing dot from any host name that may appear R< $* > $* < @ $* . > $: < $1 > $2 < @ $3 > # handle local: syntax -- use old user, either with or without host R< > $* < @ $* > $* $#local $@ $1@$2 $: $1 R< > $+ $#local $@ $1 $: $1 # handle local:user@host syntax -- ignore host part R< $+ @ $+ > $* < @ $* > $: < $1 > $3 < @ $4 > # handle local:user syntax R< $+ > $* <@ $* > $* $#local $@ $2@$3 $: $1 R< $+ > $* $#local $@ $2 $: $1 ################################################################### ### Ruleset 93 -- convert header names to masqueraded form ### ################################################################### S93 # handle generics database #R$+ < @ $=G . > $: < $1@$2 > $1 < @ $2 . > @ mark #R$+ < @ *LOCAL* > $: < $1@$j > $1 < @ *LOCAL* > @ mark #R< $+ > $+ < $* > @ $: < $(generics $1 $: $) > $2 < $3 > #R< > $+ < @ $+ > $: < $(generics $1 $: $) > $1 < @ $2 > #R< $* @ $* > $* < $* > $@ $>3 $1 @ $2 found qualified #R< $+ > $* < $* > $: $>3 $1 @ *LOCAL* found unqualified #R< > $* $: $1 not found # special case the users that should be exposed R$=E < @ *LOCAL* > $@ $1 < @ $j . > leave exposed R$=E < @ $=M . > $@ $1 < @ $2 . > R$=E < @ $=w . > $@ $1 < @ $2 . > # handle domain-specific masquerading R$* < @ $=M . > $* $: $1 < @ $2 . @ $M > $3 convert masqueraded doms R$* < @ $=w . > $* $: $1 < @ $2 . @ $M > $3 R$* < @ *LOCAL* > $* $: $1 < @ $j . @ $M > $2 R$* < @ $+ @ > $* $: $1 < @ $2 > $3 $M is null R$* < @ $+ @ $+ > $* $: $1 < @ $3 . > $4 $M is not null ################################################################### ### Ruleset 94 -- convert envelope names to masqueraded form ### ################################################################### S94 #R$+ $@ $>93 $1 R$* < @ *LOCAL* > $* $: $1 < @ $j . > $2 ################################################################### ### Ruleset 98 -- local part of ruleset zero (can be null) ### ################################################################### S98 # addresses sent to foo@host.REDIRECT will give a 551 error code R$* < @ $+ .REDIRECT. > $: $1 < @ $2 . REDIRECT . > < ${opMode} > R$* < @ $+ .REDIRECT. > $: $1 < @ $2 . REDIRECT. > R$* < @ $+ .REDIRECT. > < $- > $# error $@ 5.1.1 $: "551 User has moved; please try " <$1@$2> Scheck_mail R$* $: $>check_rbl $1 # don't check these R<$*@$=w> $@ ok shortcut # idea from Steven Schultz R<> $: <$n @ $(dequote "" $&{client_name} $) > # remove at least the dot... R<$*@$*.> <$1@$2> R$* $: $>3 $1 canonify R$- $@ ok # no host without a . in the FQHN ? R$*<@$->$* $#error $@ 5.1.8 $: 551 invalid host name $2, check your configuration. # lookup IP address (reverse mapping available?) #R$*<@[$-.$-.$-.$-]>$* $: $1 < @ $[ [ $2.$3.$4.$5 ] $] > $6 # copy the result of the lookup R$* $:$1 $| $1 # now remove the dot R$* $| $*<@$*.>$* $: $1 $| $2<@$3>$4 # and check the database R$* $| $*<@$*>$* $: $1 $| $>junk $2<@$3> # match: return given error code (rhs of map) R$* $| $*<@$*@JUNK>$* $#error $@ 5.7.1 $: $3 # restore original value (after canonicalization by ruleset 3) R$* $| $* $: $1 # this is dangerous! no real name # (see RFC 1123,sections 5.2.2 and 5.2.18) #R$*<@$*$~P>$* $#error $@ 4.1.8 $: 451 unresolvable host name $2$3, check your setup. # # Envelope sender rewriting # S10 R<@> $n errors to mailer-daemon R$+ $: $>50 $1 add local domain if needed R$* $: $>94 $1 do masquerading # # Envelope recipient rewriting # S20 R$+ < @ $* > $: $1 strip host part # # Header sender rewriting # S30 R<@> $n errors to mailer-daemon R$+ $: $>50 $1 add local domain if needed R$* $: $>93 $1 do masquerading # # Header recipient rewriting # S40 R$+ $: $>50 $1 add local domain if needed #R$* $: $>93 $1 do all-masquerading # # Common code to add local domain name (only if always-add-domain) # S50 R$* < @ $* > $* $@ $1 < @ $2 > $3 already fully qualified R$+ $@ $1 < @ *LOCAL* > add local qualification # # envelope sender rewriting # S11 R$+ $: $>51 $1 sender/recipient common R$* :; <@> $@ list:; special case R$* $: $>61 $1 qualify unqual'ed names R$+ $: $>94 $1 do masquerading # # envelope recipient rewriting -- # also header recipient if not masquerading recipients # S21 R$+ $: $>51 $1 sender/recipient common R$+ $: $>61 $1 qualify unqual'ed names # # header sender and masquerading header recipient rewriting # S31 R$+ $: $>51 $1 sender/recipient common R:; <@> $@ list:; special case # do special header rewriting R$* <@> $* $@ $1 <@> $2 pass null host through R< @ $* > $* $@ < @ $1 > $2 pass route-addr through R$* $: $>61 $1 qualify unqual'ed names R$+ $: $>93 $1 do masquerading # # convert pseudo-domain addresses to real domain addresses # S51 # pass s through R< @ $+ > $* $@ < @ $1 > $2 resolve # output fake domains as user%fake@relay # do UUCP heuristics; note that these are shared with UUCP mailers R$+ < @ $+ .UUCP. > $: < $2 ! > $1 convert to UUCP form R$+ < @ $* > $* $@ $1 < @ $2 > $3 not UUCP form # leave these in .UUCP form to avoid further tampering R< $&h ! > $- ! $+ $@ $2 < @ $1 .UUCP. > R< $&h ! > $-.$+ ! $+ $@ $3 < @ $1.$2 > R< $&h ! > $+ $@ $1 < @ $&h .UUCP. > R< $+ ! > $+ $: $1 ! $2 < @ $Y > use UUCP_RELAY R$+ < @ $+ : $+ > $@ $1 < @ $3 > strip mailer: part R$+ < @ > $: $1 < @ *LOCAL* > if no UUCP_RELAY # # common sender and masquerading recipient rewriting # S61 R$* < @ $* > $* $@ $1 < @ $2 > $3 already fully qualified R$+ $@ $1 < @ *LOCAL* > add local qualification # # relay mailer header masquerading recipient rewriting # S71 R$+ $: $>61 $1 R$+ $: $>93 $1