divert(-1) # # Copyright (c) 1998 Claus Assmann # # In short: you can do whatever you want with this, but don't blame me! # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # # define(`SM89')dnl this is for sendmail 8.9 ifdef(`_CHECK_MAP_TYPE_',`',`define(`_CHECK_MAP_TYPE_',`dbm')')dnl ifdef(`_ALLOW_SOME_',`define(`_CHECK_DOMAINMAP_REQ_',`1')') divert(0) VERSIONID(`@(#)chk-rcpt.m4 0.2.1 (Claus Assmann) 1998-11-17') ifdef(`_ALLOW_SOME_',`dnl include(_CF_DIR_`'hack/junk.m4) dnl',`dnl') PUSHDIVERT(6) ifdef(`_SPAM_FRIENDS_',dnl # file containing addresses which receive all mail without filtering F{SpamFriends} ifelse(_SPAM_FRIENDS_, `', `/etc/mail/SpamFriends', `_SPAM_FRIENDS_'),`dnl') ifdef(`_MAP_SPAM_FRIENDS_',dnl # map containing addresses which receive all mail without filtering Kspam_friends ifelse(_MAP_SPAM_FRIENDS_, `', `_CHECK_MAP_TYPE_ -a@SPAMFRIEND /etc/mail/spam_friends', `_MAP_SPAM_FRIENDS_'),`dnl') ifdef(`_SPAM_HATERS_',dnl # map containing addresses which want to have mail filtering Kspam_haters ifelse(_SPAM_HATERS_, `', `_CHECK_MAP_TYPE_ -a@SPAMHATER /etc/mail/spam_haters', `_SPAM_HATERS_'),`dnl') ifdef(`_ALLOW_SOME_',dnl # list of domains and addresses which can send mail through # our relay if they appear in MAIL FROM: Kallow ifelse(_ALLOW_SOME_, `', `_CHECK_MAP_TYPE_ -a@MATCH /etc/mail/allow', `_ALLOW_SOME_'),`dnl') ifdef(`_POPAUTH_',`# use map for authentification via POP Kpopauth ifelse(_POPAUTH_,`',`_CHECK_MAP_TYPE_ -o -m -a@MATCH /etc/mail/popauth',`_POPAUTH_')',`dnl') ifdef(`_LOCAL_ONLY_',`# use class for users who can send only local mail F{LocalOnly} ifelse(_LOCAL_ONLY_, `', `/etc/mail/LocalOnly', `_LOCAL_ONLY_')',`dnl') POPDIVERT LOCAL_RULESETS ifdef(`_CHECK_MAIL_IN_RCPT_',`SLocal_check_mail # override now, call it later as Basic_ R$* $@ $# OK',`dnl') ifdef(`_CHECK_RELAY_IN_RCPT_',`SLocal_check_relay # override now, call it later as Basic_ R$* $@ $# OK',`dnl') ifdef(`_CHECK_MAIL_IN_RCPT_',`define(`_CHECK_RCPT_IN_RCPT_',`1')',`ifdef(`_CHECK_RELAY_IN_RCPT_',`define(`_CHECK_RCPT_IN_RCPT_',`1')',`dnl')') ifdef(`_CHECK_RCPT_IN_RCPT_',`Scheckrcpt',`SLocal_check_rcpt ifdef(`_SPAM_FRIENDS_',`# allow some local addresses; use only legal syntax R<$={SpamFriends}@$=w> $@ ifdef(`_FRIEND_STORAGE_', `$(friend YES $)', `$# OK') R<$={SpamFriends}> $@ ifdef(`_FRIEND_STORAGE_', `$(friend YES $)', `$# OK')',`dnl') ifdef(`_MAP_SPAM_FRIENDS_',`# allow some local addresses; use only legal syntax R<$+@$+> $: <$(spam_friends @$2 $:$1@$2 $)> R<$+@SPAMFRIEND> $@ ifdef(`_FRIEND_STORAGE_', `$(friend YES $)', `$# OK') R<$+@$=w> $: <$(spam_friends $1 $) @ $2> R<$+@SPAMFRIEND@$=w> $@ ifdef(`_FRIEND_STORAGE_', `$(friend YES $)', `$# OK')',`dnl')') ifdef(`_LOCAL_ONLY_',`# if local_only sender: no remote recipient R$+ $: $1 $| <@> $>canon $&f R$+ $| <@> $={LocalOnly}<@$=w> $: $1 $| R$+ $| <@> $* $: $1 R<$*@$=w> $| $: <$1@$2> R$+ $| $# error $@ NOUSER $: 553 External Recipient Forbidden.',`dnl') ifdef(`_POPAUTH_',`# authentification via POP R$+ $: $&{client_addr} $| $1 R$+ $| $* $: $(popauth $1 $) $| $2 OK if from a POP-authed address ifdef(`_POPAUTH2_',`R$-.$-.$-.$- $| $* $: $(popauth $1.$2.$3 $) $| $5 OK if from a POP-authed subnet',`dnl') R$+@MATCH $| $* $@ $# OK R$+ $| $* $: $2 undo damage',`dnl') ifdef(`_ALLOW_SOME_',`dnl R$* $: $1 $| $>3 $&f # compare it with an "allowed" domain or address R$* $| $*<@$*.>$* $: $1 $| $>DomainMap $2<@$3>@allow # match: ok R$* $| $*<@$*@MATCH>$* $@ $# OK',`dnl') ifdef(`_RELAY_ACCESS_FROM_',`dnl # compare sender with an "allowed" domain or address (RELAY) R$* $: $1 $| $>Parse0 $>3 $&f R$* $| $+<@$+.> $1 $| $2<@$3> R$* $| $+<@$+> $: $1 $| $(access $2@$3 $: $2<@$3> $) R$* $| RELAY $# OK match full from address ifdef(`_RELAY_ACCESS_FROM_DOMAIN_',`dnl R$* $| $+<@$+> $: $1 $| $>LookUpDomain <$3> <$2<@$3>> R$* $| $# OK match from domain',`dnl') R$* $| $* $: $1 undo damage',`dnl ifdef(`_RELAY_ACCESS_FROM_DOMAIN_',`dnl errprint(`HACK "chk-rcpt" _RELAY_ACCESS_FROM_DOMAIN_ requires _RELAY_ACCESS_FROM_ ') ',`dnl')') ifdef(`_SPAM_HATERS_',`R$+ $@ <$1@LOCALNAME>',`dnl') ifdef(`_CHECK_RCPT_IN_RCPT_',` SLocal_check_rcpt ifdef(`_SPAM_FRIENDS_',`# allow some local addresses; use only legal syntax R<$={SpamFriends}@$=w> $@ ifdef(`_FRIEND_STORAGE_', `$(friend YES $)', `$# OK') R<$={SpamFriends}> $@ ifdef(`_FRIEND_STORAGE_', `$(friend YES $)', `$# OK')',`dnl') ifdef(`_MAP_SPAM_FRIENDS_',`# allow some local addresses; use only legal syntax R<$+@$=w> $: <$(spam_friends $1 $) @ $2> R<$+@SPAMFRIEND@$=w> $@ ifdef(`_FRIEND_STORAGE_', `$(friend YES $)', `$# OK')',`dnl') # call the rulesets R$* $: $>checkrcpt $1 ifdef(`_SPAM_HATERS_',`dnl R<$+ + $* @ LOCALNAME> $: <@> $(spam_haters $1 $) R<$+ @ LOCALNAME> $: <@> $(spam_haters $1 $) R<@> $*@SPAMHATER $: ifdef(`_FRIEND_STORAGE_', `$(friend NO $)', `is_hater') R<@> $* $@ no_hater_stop_the_check', `dnl') ifdef(`_CHECK_MAIL_IN_RCPT_',`dnl R$* $: <$&f> R<<$*>> <$1> strip superfluous < > R<$*> $: $>Basic_check_mail <$1> ifdef(`_ACCEPT_SOME_',`dnl R<$*@$*@ACCEPT> $@ ACCEPT',`dnl')',`dnl') ifdef(`_CHECK_RELAY_IN_RCPT_',`dnl R$* $: $>Basic_check_relay $&{client_name} $| $&{client_addr}',`dnl')',`dnl') ifdef(`_LOCAL_ONLY_',`# canonify address: user<@domain>; if no domain: add $j Scanon R$+ $: $>3 $1 R $*<@$*.>$* $1<@$2>$3 R $*<@$*>$* $@ $1<@$2>$3 R $* $@ $1<@$j>',`dnl') divert(0)