|
|
Ruleset check_mailNewer versions of sendmail have the ability to do some checking on the address of the incomming message's origniator, in the ruleset «check_mail». I have twisted a little bit on the hints given by Claus Aßmann and Paul Vixie.This ruleset will read three Berkeley DB-files.
In my myhost.mc file I have put these statements:
LOCAL_CONFIG
#
Kspamdomains hash /local/lib/mail/spamdomains
Kspamusers hash /local/lib/mail/spamusers
Kspamrelays hash /local/lib/mail/spamrelays
LOCAL_RULE_0
Scheck_mail
# First lookup user in spamusers.db
R<$*> $: $(spamusers $1 $) <spammer@domain>
R<$*.> $: $(spamusers $1 $) <spammer@domain.>
R$*. $: $(spamusers $1 $) spammer@domain.
R$* $: $(spamusers $1 $) spammer@domain
RSPAM $#error $: 451 Dont want your spam
# check for valid domain name (incompatible with DeliveryMode=defer)
R$* $: > $>3 $1 make domain canonical
R<?> $* < @ $+ . > $: $2 keep domain
R<?> $* < @ $+ > $#error $: 451 Domain must resolve
# lookup if resolvable domain is unwanted
R$*.$-.$- $: $2.$3 two rightmost domains
R$* $: $(spamdomains $1 $) spamdomain
RSPAM $#error $: 451 Dont want your junkmail
# also deny spamrelayers (heavy)
R$* $: $(spamrelays $&{client_name} $)
RSPAM $#error $: 451 Your site is relaying spam
All tables define one address or domain on each line, to generate the DB-maps I run this extract of my Makefile, generating all the db's out of the cute IDA xaliases!
DBEXT= db
SPAMPARSE= bin/spamparse
SPAM_U= spamusers
SPAM_D= spamdomains
SPAM_R= spamrelays
all: files
files: $(SPAM_U).$(DBEXT) $(SPAM_D).$(DBEXT) $(SPAM_R).$(DBEXT)
$(SPAM_U).$(DBEXT): $(SPAM_U)
$(SPAMPARSE) $(SPAM_U)
$(SPAM_R).$(DBEXT): $(SPAM_R)
$(SPAMPARSE) $(SPAM_R)
$(SPAM_D).$(DBEXT): $(SPAM_D)
$(SPAMPARSE) $(SPAM_D)
The Makefile calls this little perlscript, spamparse (of course both perl and sendmail should have been compiled with -ldb).
#!/share/bin/perl
umask 022;
exit unless -f $ARGV[0];
$MAP=$ARGV[0];
use DB_File;
use Fcntl;
tie (%S,DB_File,"$MAP.DB",O_RDWR|O_CREAT,0644) or die;
open(F,"$MAP");
while(<F>) {
next if /^#/;
chop;
$S{$_}="SPAM";
}
close F;
untie %S;
rename "$MAP.DB","$MAP.db";
exit(0);
If you dont have resources to tie up the spamming machines, you could change errorcode 451 to 551 in the lines beginning with «RSPAM». Actually we dont accept mail from mailaddresses with only numbers on the LHS anymore... You might also have a look at my PP hacks |
Sist oppdatert 17/8-97 av hmk
|