X-Git-Url: http://git.jankratochvil.net/?a=blobdiff_plain;f=PerlMail%2FConfig.pm;h=52bc3f852a9bcc9b961a80f663873a456a626515;hb=refs%2Fheads%2Flace;hp=14c57b8e256c1afc67b24a7d357cfa2fdf6f3fe6;hpb=08516d525371be043040d27483c62e8e84e06751;p=PerlMail.git diff --git a/PerlMail/Config.pm b/PerlMail/Config.pm index 14c57b8..52bc3f8 100644 --- a/PerlMail/Config.pm +++ b/PerlMail/Config.pm @@ -40,11 +40,12 @@ use vars qw(@ISA @EXPORT); ); require Mail::Alias; +use Carp qw(confess cluck); BEGIN { - for (qw(headerhas store headeris did dnsbl store_muttrc_alternates Received_for parts_linear mime_type - body_first is_multipart mimehead mimebody spamassassin clamscan header_remap lmtp_deliver)) { + for (qw(headerhas writeto store headeris did dnsbl store_muttrc_alternates Received_for parts_linear mime_type + body_first body_simple is_multipart mimehead mimebody spamassassin clamscan header_remap)) { eval 'sub '.$_.' { return ::'.$_.'(@_); }'; } } @@ -70,17 +71,6 @@ our $MaxBodySMS=0x1000; our @SMSwebRcpt=qw(420 602 431329); # Some WWW::SMS modules require username: our $SMSwebRcpt_username="lace2"; -our $lmtp_admin="cyrus"; -our $lmtp_pwd; -{ - local *F; - open F,"$HOME/priv/lmtp.${lmtp_admin}.pwd" or die; - $lmtp_pwd=; - chomp $lmtp_pwd; - close F or die; - } -our $lmtp_user_from="lace"; -our $lmtp_user_to="lacemail"; our $clamscan_waitpid_timeout=3; @@ -89,7 +79,7 @@ our $clamscan_waitpid_timeout=3; # Global system lock for exclusive $DB_table access: our $Lock_pathname="/tmp/PerlMail.lock"; # 'workstation' hostname and port. Hostname may be dyndns: -our $PeerAddr="exuhome.dyn.jankratochvil.net.:852"; +our $PeerAddr="kashome.dyn.jankratochvil.net.:852"; #our $PeerAddr="127.0.0.1:2852"; # 15sec is NOT enough as the remote peer must complete mail store: our $Socket_timeout=7600; @@ -217,7 +207,7 @@ our @h_from=( # 'bell' =>Bell sound. # 'sms=\d+'=>Send SMS by WWW::SMS with specified maximum # of parts our %audit_profile=( - "btw" =>[], + "btw" =>["syslog"], "silent"=>["=btw" ,"did"], "log" =>["=silent","syslog"], "bell" =>["=log" ,"bell"], @@ -258,6 +248,23 @@ our @dnsbl_whitelist=( "213.151.87.16", # posta.dobnet.cz: 16.87.151.213.relays.ordb.org ); +sub dolist +{ + my($list)=@_; + + my $mailed=0; + for my $alias ("",qw(admin bounces confirm join leave owner request subscribe unsubscribe)) { + my $head=$list.($alias?"-$alias":""); + my $mail=$head.'@jankratochvil.net'; + if (headerhas("To",$mail)||headerhas("Cc",$mail)) { + writeto "|/usr/lib64/mailman/mail/lace/mailmanlace ".($alias||"post")." $list"; + ###writeto "|/usr/sbin/sendmail $head".'@localhost.localdomain'; + $mailed++; + } + } + return $mailed; +} + our $Audit; # imported our $procmailFROM_MAILER; # imported our $store_ignorenewmail; # imported @@ -276,9 +283,22 @@ sub audit || headerhas "From",'' ); + return if did sub { store "=spy","log" if headeris "From",''; }; + + return if did sub { store "=hotelgatespam","log" if headeris("To",''); }; + + # whitelist + my $whitelist; + $whitelist||=headeris("From",''); + $whitelist||=headeris("From",''); + $whitelist||=headeris("From",''); + $whitelist||=headeris("From",''); + $whitelist||=headeris("From",''); + # spam honeypots return if did sub { local $_; + return if $whitelist; # Do not local $store_file as it is our-imported $store_profile="silent"; store "=spam" if grep /^\Qshort\@k332.feld.cvut.cz\E/i,Received_for(); @@ -290,6 +310,24 @@ sub audit store "=spam" if headeris "From",''; store "=spam" if headeris "From",''; store "=spam" if headeris "From",''; + store "=spam" if headeris "From",''; + store "=spam" if headeris "From",''; + store "=spam" if headeris "From",''; + store "=spam" if headeris "From",''; + store "=spam" if $Audit->subject() eq "Virus intercepted" + && body_simple()=~/^A message sent from\s.*\sto\s.*\scontained .* and has not been delivered[.]$/; + store "=spam" if headeris "From",''; + store "=spam" if headeris "From",''; + store "=spam" if headeris "From",''; + store "=spam" if headeris "To" ,''; + # Whitelist - HTML. + return if headeris("From",''); + for my $header (qw(To Cc)) { + store "=spam" if headerhas $header,''; + store "=spam" if headerhas $header,''; + store "=spam" if headerhas $header,''; + store "=spam" if headerhas $header,''; + } { # weak detection: files with text/html w/o text/plain are usually a spam my @types_linear=map({ mime_type($_); } parts_linear()); @@ -299,17 +337,57 @@ sub audit }; $store_profile=undef(); + my %mailman=( + ''=>"=caperr", + ''=>"=caperr", + ''=>"=caperr", + '<4c-admin@>'=>"=4cerr", + ); + return if did sub { + if (!did sub { + while ((my($mailaddr,$folder)=each(%mailman))) { + (my $maillistaddr=$mailaddr)=~s/-admin/-list$&/; + store $folder,"log" if (headeris("From",'')&&headeris("To",$mailaddr)) + || headeris("From",$maillistaddr) + || headeris("To",$maillistaddr) + || headeris("From",$mailaddr); + } + }) { + store "=cap","bell" if headeris "List-Id" ,''; + store "=capd","bell" if headeris "List-Id" ,''; + store "=capann","bell" if headeris "List-Id" ,''; + store "=4c","bell" if headeris "List-Id" ,'<4c-list.vellum.cz>'; + } + }; + + { + my $mailed=0; + if ($Audit->header()!~/for <(?:4c|vmezihori1XXX)-(?:admin|owner|bounces)@/) { + for my $list qw(vmezihori1) { + $mailed+=dolist $list; + } + } + # return if $mailed; + } + # spam detection return if did sub { + # It is too expensive to scan the huge =caperr announcements by spamassassin(1). + return if $whitelist; +### return if headeris("From",qr/^captive-[a-z]*@/); + return if headeris("From",''); # Do not local $store_file as it is our-imported $store_profile="log"; local $_; - store "=spam".";virus=$_" if $_=clamscan(); +### store "=spam".";virus=$_" if $_=clamscan(); store "=spam".";spamassassin".($_ eq 1 ? "" : "=$_") if $_=spamassassin(); - store "=spam".";$_" if $_=dnsbl '.relays.ordb.org.' ,1; # all hosts +# Down? +### store "=spam".";$_" if $_=dnsbl '.relays.ordb.org.' ,1; # all hosts +if (0) { store "=spam".";$_" if $_=dnsbl '.blackholes.mail-abuse.org.' ,1; # all hosts # we don't check all hosts as they can be "dialup" category, FIXME: check for it # store "=spam".";$_" if $_=dnsbl '.blackholes.five-ten-sg.com.',0; # just first +} # I don't send viruses but viruses propagate mails of mine store "=spam".";ravmd" if headeris "X-Mailer",'ravmd/8.3.2'; store "=spam".';short@ucw.cz+MAILER' if $isFROM_MAILER && headeris("To",''); @@ -319,23 +397,28 @@ sub audit brandenburg.rz.fhtw-berlin.de forum.gofeminin.de service.spiegel.de + www.aufenthaltstitel.de + www.berlinonline.de www.deutschlandchronik.de www.heise.de www.leverkusener-aufbruch.com + www.libasoli.de www.mjoelnirsseite.de www.npd-nrw.net www.npd.de www.rp-online.de www.spiegel.de www.taz.de + www.unserforum.com + www.zdf.de )); my $found; - $found=1 if /^\s*Lese selbst:\n/; while (m{http://([^/]+)/}g) { do { $found=1; next; } if $sites{$1}; $found=0; last; } + $found=1 if /^\s*Lese selbst:\n/s; store "=spam".';german-news' if $found; } }; @@ -379,13 +462,15 @@ sub audit ); - store "=gsm" if headeris "Sender" ,''; + store "=gsm" if headeris "X-BeenThere",''; store "=gsmpand" if headeris "List-Post",''; store "=9kc","log" if headeris "List-Post",''; store "=9kcd","log" if headeris "List-Post",''; } $store_profile=undef(); + return if headeris "From" ,''; + # lists store "=mozillabug","log" if headeris "From" ,''; store "=9ku","log" if headeris "List-Id" ,'<9000.listman.net>'; @@ -427,8 +512,13 @@ sub audit store "=linux-input","log" if headeris "List-Post",''; store "=strom","bell" if headeris "List-Post",''; store "=netinfo","log" if headeris "Sender" ,''; - store "=saintmj","log" if headeris "From" ,''; + store "=saintmj","log" if headeris "From" ,''; + store "=saintmj","log" if headeris "From" ,''; store "=saintmj","log" if headeris "From" ,''; + store "=saintjk","log" if headeris "From" ,''; + store "=saintjk","log" if (headeris("From" ,'') + || headeris("From" ,'')) + && headeris("To" ,''); store "=4cerr","bell" if headeris "From" ,''; store "=4c","sms" if headeris "List-Post",'<4cinfo@atrey.karlin.mff.cuni.cz>'; store "=slashdot","bell" if headeris "From" ,''; @@ -442,36 +532,23 @@ sub audit store "=autoconf","log" if headeris "List-Id" ,''; store "=autoconfpat","log" if headeris "List-Id" ,''; store "=hurd","log" if headeris "List-Id" ,''; - my %mailman=( - ''=>"=caperr", - ''=>"=caperr", - ''=>"=caperr", - '<4c-admin@>'=>"=4cerr", - ); - if (!did sub { - while ((my($mailaddr,$folder)=each(%mailman))) { - (my $maillistaddr=$mailaddr)=~s/-admin/-list$&/; - store $folder,"log" if (headeris("From",'')&&headeris("To",$mailaddr)) - || headeris("From",$maillistaddr) - || headeris("To",$maillistaddr) - || headeris("From",$mailaddr); - } - }) { - store "=cap","bell" if headeris "List-Id" ,''; - store "=capd","bell" if headeris "List-Id" ,''; - store "=capann","bell" if headeris "List-Id" ,''; - store "=4c","bell" if headeris "List-Id" ,'<4c-list.vellum.cz>'; - } + store "=gccbug","silent" if headeris "List-Post",''; + store "=gccann","log" if headeris "List-Post",''; + store "=gcc","silent" if headeris "List-Post",''; + store "=gccpat","silent" if headeris "List-Post",''; store "=ntfsann","silent" if headeris "List-Id" ,''; store "=ntfsd","silent" if headeris "List-Id" ,''; store "=orbit","silent" if headeris "List-Id" ,''; - store "=kand","log" if headeris "List-Id" ,''; + store "=kannel","log" if headeris "List-Id" ,''; + store "=kanneld","log" if headeris "List-Id" ,''; store "=mailmand","silent" if headeris "List-Id" ,''; store "=asterisk-perl","log" if headeris "List-Post",''; store "=i4l","silent" if headeris "List-Id" ,''; - store "=glibc","silent" if headeris "Mailing-List",qr/\b\Qlibc-alpha-help\E@\Qsources.redhat.com\E\b/; + store "=glibc","silent" if headeris "List-Post",''; store "=fedann","bell" if headeris "List-Id" ,''; + store "=fedpkg","bell" if headeris "List-Id" ,''; store "=fedtools","log" if headeris "List-Id" ,''; + store "=fedd","log" if headeris "List-Id" ,''; store "=bashbug","log" if headeris "List-Id" ,''; store "=zaurus","silent" if headeris "List-Id" ,''; store "=zaurusann","log" if headeris "List-Id" ,''; @@ -486,23 +563,72 @@ sub audit store "=www-sms","log" if headeris "List-Id" ,''; store "=httpdd","log" if headeris "list-post",''; store "=mms2log","log" if headeris "Return-Path",''; - store "=hotelgatelog","log" if headeris "Return-Path",''; + store "=hotelgatelog","log" if headeris("Return-Path",'') + # `SMART error' should not be matched. + && headeris("Subject" ,qr/^(?:Cron|Anacron|LogWatch) /); store "=imja","log" if headeris "List-Id" ,''; + store "=wince","log" if headeris "List-Post",''; + store "=mysqlperl","log" if headeris "List-Id" ,''; + store "=whiteann","log" if headeris "List-Id" ,''; + store "=white","log" if headeris "List-Id" ,''; + store "=centos","log" if headeris "List-Id" ,''; + store "=modperldoc","log" if headeris "List-Id" ,''; + store "=qemud","log" if headeris "List-Id" ,''; + store "=diamond","log" if headeris "X-Replicator-Inst",'"www.diamondcard.us"'; + store "=soap","log" if headeris "Sender" ,''; + store "=nagiosd","log" if headeris "List-Id" ,''; + store "=nagios","log" if headeris "List-Id" ,''; + store "=grub","log" if headeris "List-Id" ,''; + store "=gdb","log" if headeris "Mailing-List",'contact gdb-help@sourceware.org; run by ezmlm'; + store "=gdbpr","log" if headeris "Mailing-List",'contact gdb-prs-help@sourceware.org; run by ezmlm'; + store "=gdbpat","log" if headeris "Mailing-List",'contact gdb-patches-help@sourceware.org; run by ezmlm'; + store "=gdbann","log" if headeris "Mailing-List",'contact gdb-announce-help@sourceware.org; run by ezmlm'; + store "=binutils","log" if headeris "Mailing-List",'contact binutils-help@sourceware.org; run by ezmlm'; + store "=binutilsbug","log" if headeris "List-Id" ,''; + store "=4c","bell" if headeris "List-Id" ,'<4c.jankratochvil.net>'; + store "=dup","log" if headeris "List-Id" ,''; + store "=dupbug","log" if headeris "List-Id" ,''; + store "=sue","log" if headeris "Subject" ,'Cron $HOME/secure/sue'; + store "=linkedin","log" if headeris "From" ,''; # Petr Koutecky does not mark his Stuff store "=koutecky","log" if headeris "Return-Path",''; store "=koutecky","log" if headeris "Return-Path",''; store "=koutecky","log" if headeris "Return-Path",''; + store "=koutecky","log" if headeris "Return-Path",''; + + store "=host0log","log" if headeris("From" ,'') + && headeris("Return-Path",''); + store "=host1log","log" if headeris("From" ,'') + && headeris("Return-Path",''); + + if (headeris("To" ,'') + && headeris("Return-Path",'')) { + if (body_simple()=~/^SIP request received from .* for 2143$/o) { + store "=callme","log"; + } else { + store "=call","log"; + } + } - if (($isFROM_MAILER && !did) || !did) { - lmtp_deliver $lmtp_admin,$lmtp_pwd,$lmtp_user_from,$lmtp_user_to; + { + my $mailed=0; + if ($Audit->header()!~/for <(?:4c|vmezihori1)-(?:admin|owner|bounces)@/) { + for my $list qw(mailman 4c) { + $mailed+=dolist $list; + } } + # return if $mailed; + } - store "=errm","bell" if $isFROM_MAILER && !did(); + store "=errm","bell" if $isFROM_MAILER && !did() + # qr/daemon@/ makes $isFROM_MAILER positive. + && !headeris("From",''); if (!did) { store "==","sms"; - spamassassin "$HOME/bin/sa-learn --ham"; +# FIXME: What to do with it? +### spamassassin "sa-learn --ham"; } }