Организация и администрирование почтовых и файловых серверов Internet



              

Схема 3.3. Правила



Схема 3.3. Правила




При получении почтового сообщения адреса, указанные в полях To, From, Cc, преобразуются в соответствии с правилами преобразования.

###################################################################### ###################################################################### ##### ##### REWRITING RULES ##### ###################################################################### ###################################################################### ########################################### ### Rulset 3 - Name Canonicalization ### ########################################### S3 # handle null input (translate to <@> special case) R$@ $@ <@> # basic textual canonicalization -- note RFC733 heuristic here R$*<$*>$*<$*>$* $2$3<$4>$5 strip multiple <> <> R$*<$*<$+>$*>$* <$3>$5 2-level <> nesting R$*<>$* $@ <@> MAIL FROM:<> case R$*<$+>$* $2 basic RFC821/822 parsing # handle list:; syntax as special case R$*:;$* $@ $1 :; <@> # make sure <@a,@b,@c:user@d> syntax is easy to parse -- undone later R@ $+ , $+ @ $1 : $2 change all "," to ":" # localize and dispose of route-based addresses R@ $+ : $+ $@ $>96 < @$1 > : $2 handle <route-addr> # find focus for list syntax R $+ : $* ; @ $+ $@ $>96 $1 : $2 ; < @ $3 > list syntax R $+ : $* ; $@ $1 : $2; list syntax # find focus for @ syntax addresses R$+ @ $+ $: $1 < @ $2 > focus on domain R$+ < $+ @ $+ > $1 $2 < @ $3 > move gaze right R$+ < @ $+ > $@ $>96 $1 < @ $2 > already canonical # do some sanity checking R$* < @ $* : $* > $* $1 < @ $2 $3 > $4 nix colons in addrs # convert old-style addresses to a domain-based address R$- ! $+ $@ $>96 $2 < @ $1 .UUCP > resolve uucp names R$+ . $- ! $+ $@ $>96 $3 < @ $1 . $2 > domain uucps R$+ ! $+ $@ $>96 $2 < @ $1 .UUCP > uucp subdomains # if we have % signs, take the rightmost one R$* % $* $1 @ $2 First make them all @s. R$* @ $* @ $* $1 % $2 @ $3 Undo all but the last. R$* @ $* $@ $>96 $1 < @ $2 > Insert < > and finish # else we must be a local name ################################################ ### Ruleset 96 - bottom half of ruleset 3 ### ################################################ # At this point, everything should be in a "local_part<@domain>extra" format. S96 # handle special cases for local names R$* < @ localhost > $* $: $1 < @ $j . > $2 no domain at all R$* < @ localhost . $m > $* $: $1 < @ $j . > $2 local domain R$* < @ localhost . UUCP > $* $: $1 < @ $j . > $2 .UUCP domain R$* < @ [ $+ ] > $* $: $1 < @@ [ $2 ] > $3 mark [a.b.c.d] R$* < @@ $=w > $* $: $1 < @ $j . > $3 self-literal R$* < @@ $+ > $* $@ $1 < @ $2 > $3 canon IP addr # pass UUCP addresses straight through R$* < @ $+ . UUCP > $* $@ $1 < @ $2 . UUCP . > $3 # pass to name server to make hostname canonical R$* < @ $* $~P > $* $: $1 < @ $[ $2 $3 $] > $4 # local host aliases and pseudo-domains are always canonical R$* < @ $=w > $* $: $1 < @ $2 . > $3 R$* < @ $* $=P > $* $: $1 < @ $2 $3 . > $4 R$* < @ $* . . > $* $1 < @ $2 . > $3 # if this is the local hostname, make sure we treat is as canonical R$* < @ $j > $* $: $1 < @ $j . > $2 ################################################## ### Ruleset 4 - Final Output Post-rewriting ### ################################################## S4 R$*<@> $@ $1 handle <> and list:; # strip trailing dot off possibly canonical name R$* < @ $+ . > $* $1 < @ $2 > $3 # externalize local domain info R$* < $+ > $* $1 $2 $3 defocus R@ $+ : @ $+ : $+ @ $1 , @ $2 : $3 <route-addr> 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 @ $j u%host@host => u@host ############################################################## ### Ruleset 97 - recanonicalize and call ruleset zero ### ### (used for recursive calls) ### ############################################################## S97 R$* $: $>3 $1 R$* $@ $>0 $1 ###################################### ### Ruleset 0 - Parse Address ### ###################################### S0 R<@> $#local $: <> special case error msgs R$* : $* ; $#error $@ USAGE $: "list:; syntax illegal for recipient addresses" R<@ $+> $#error $@ USAGE $: "user address required" R<$* : $* > $#error $@ USAGE $: "colon illegal in host name part" # handle numeric address spec R$* < @ [ $+ ] > $* $: $>98 $1 < @ [ $2 ] > $3 numeric internet spec R$* < @ [ $+ ] > $* $#smtp $@ [$2] $: $1 < @ [$2] > $3 still numeric: send # now delete the local info -- note $=O to find characters that cause forwarding R$* < @ > $* $@ $>97 $1 user@ => user R< @ $=w . > : $* $@ $>97 $2 @here:... -> ... R$* $=O $* < @ $=w . > $@ $>97 $1 $2 $3 ...@here -> ... # handle local hacks R$* $: $>98 $1 # short circuit local delivery so forwarded email works R$+ < @ $=w . > $: $1 < @ $2 . @ $H > first try hub R$+ < $+ @ $+ > $#local $: $1 yep .... R$+ < $+ @ > $#local $: @ $1 nope, local address # resolve remotely connected UUCP links (if any) # resolve fake top level domains by forwarding to other hosts R$*<@$+.BITNET.>$* $: $>95 < $B > $1 <@$2.BITNET.> $3 user@host.BITNET # forward non-local UUCP traffic to our UUCP relay R$*<@$*.UUCP.>$* $: $>95 < $Y > $1 <@$2.UUCP.> $3 uucp mail # pass names that still have a host to a smarthost (if defined) R$* < @ $* > $* $: $>95 < $S > $1 < @ $2 > $3 glue on smarthost name # deal with other remote names R$* < @$* > $* $#smtp $@ $2 $: $1 < @ $2 > $3 user@host.domain # if this is quoted, strip the quotes and try again R$+ $: $(dequote $1 $) strip quotes R$+ $=O $+ $@ $>97 $1 $2 $3 try again # handle locally delivered names R$=L $#local $: @ $1 special local names R$+ $#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 hub R$+ $: < $R > $1 try relay R< > $+ $: < $H > $1 try hub R< > $+ $@ $1 nope, give up R< $- : $+ > $+ $: $>95 < $1 : $2 > $3 < @ $2 > R< $+ > $+ $@ $>95 < $1 > $2 < @ $1 > ################################################################### ### Ruleset 95 - canonify mailer:host syntax to triple ### ################################################################### S95 R< > $* $@ $1 strip off null relay R< $- : $+ > $* $# $1 $@ $2 $: $3 try qualified mailer R< $=w > $* $@ $2 delete local host R< $+ > $* $#relay $@ $1 $: $2 use unqualified mailer ################################################################### ### Ruleset 98 - local part of ruleset zero (can be null) ### ################################################################### S98

За секцией преобразования адресов следует секция определения программ рассылки почты. В ней определяется локальная программа рассылки (mail), программа рассылки для выполнения (sh) и программа рассылки по SMTP.

################################################## ### Local and Program Mailer specification ### ################################################## Mlocal, P=/usr/libexec/mail.local, F=lsDFMrmn, S=10, R=20/40, A=mail -d $u Mprog, P=/bin/sh, F=lsDFMeu, S=10, R=20/40, D=$z:/, A=sh -c $u S10 R<@> $n errors to mailer-daemon R$+ $: $>40 $1 S20 R$+ < @ $* > $: $1 strip host part S40 ##################################### ### SMTP Mailer specification ### ##################################### Msmtp, P=[IPC], F=mDFMuX, S=11/31, R=21, E=\r\n, L=990, A=IPC $h Mesmtp, P=[IPC], F=mDFMuXa, S=11/31, R=21, E=\r\n, L=990, A=IPC $h Mrelay, P=[IPC], F=mDFMuXa, S=11/31, R=61, E=\r\n, L=2040, A=IPC $h

Затем идут правила определения локального преобразования адресов для конкретных программ рассылки, в частности набор правил S11.

# envelope sender and masquerading recipient rewriting # S11 R$+ $: $>51 $1 sender/recipient common R$* :; <@> $@ $1:; list:; special case R$* $@ $>61 $1 qualify unqual'ed names

В секции программ рассылки мы в нашем примере не указали еще одну важную возможность - рассылку по протоколу UUCP:

Мuucp, P=/usr/bin/uux, F=DFMhuU, S=13, R=23, M=100000, A=uux - -r -z -a$f -gC $h!rmail

Естественно, что правила преобразования адресов S13 и R23 должны быть описаны в файле настроек sendmail.









Содержание  Назад  Вперед