From: short <> Date: Sat, 18 Oct 2003 20:29:46 +0000 (+0000) Subject: Fixed separated namespaces. X-Git-Tag: bp_lace~37 X-Git-Url: http://git.jankratochvil.net/?p=PerlMail.git;a=commitdiff_plain;h=b6cafe7d7201a41899b65acbf286dbb1fce72501 Fixed separated namespaces. --- diff --git a/PerlMail/Config.pm b/PerlMail/Config.pm index 08aa57d..9bec452 100644 --- a/PerlMail/Config.pm +++ b/PerlMail/Config.pm @@ -33,17 +33,20 @@ use vars qw(@ISA @EXPORT); $Lock_pathname $PeerAddr $Socket_timeout $DB_table $DBI_database $DBI_user $DBI_pwd $sendmail_orig @addr_addon &FromAddress @h_rcpt @h_from %audit_profile @sms_squeezes @alternates_host @dnsbl_whitelist + + $Audit $is_pgp $opt_F $procmailFROM_MAILER $store_ignore $store_ignorenewmail + $store_profile ); require Mail::Alias; -sub headerhas; -sub store; -sub headeris; -sub did; -sub dnsbl; -sub store_muttrc_alternates; +BEGIN { + for (qw(headerhas store headeris did dnsbl store_muttrc_alternates Received_for parts_linear mime_type + body_first mimehead razor2 header_remap)) { + eval 'sub '.$_.' { return ::'.$_.'(@_); }'; + } + } # perlmail-accept & perlmail-sendmail @@ -176,6 +179,7 @@ our $store_profile; # imported our $store_ignore; # imported sub audit { + $store_profile=undef(); # TODO: storage? # never spawn new mail if FROM_MAILER @@ -190,7 +194,8 @@ sub audit # spam honeypots return if did sub { local $_; - local $store_profile="silent"; + # 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(); # TODO: foreign violation of RFC 822 section 4.4.4, Subject:.*Automatick.+odpov.+v.+nep.+tomnosti store "=spam" if headeris "From",''; @@ -207,15 +212,19 @@ sub audit } store "=spam" if ($_=mimehead(body_first())->mime_attr("Content-Type.charset")) && /^big5/i; }; + $store_profile=undef(); # spam detection return if did sub { - local $store_profile="silent"; + # Do not local $store_file as it is our-imported + $store_profile="silent"; local $_; store "=spam".($_ eq 1 ? "" : ";$_") if $_=razor2(); }; + $store_profile=undef(); return if did sub { - local $store_profile="silent"; + # Do not local $store_file as it is our-imported + $store_profile="silent"; local $_; store "=spam" .";$_","log" if $_=dnsbl '.relays.ordb.org.' ,1; # all hosts store "=spam" .";$_","log" if $_=dnsbl '.blackholes.mail-abuse.org.' ,1; # all hosts @@ -224,6 +233,7 @@ sub audit # I don't send viruses but viruses propagate mails of mine store "=spam" if headeris "X-Mailer",'ravmd/8.3.2'; }; + $store_profile=undef(); # special delivery store "=err","bell" and return if headerhas \&Received_for,''; @@ -245,7 +255,8 @@ sub audit # nasty public lists with $store_ignore { - local $store_profile="log"; + # Do not local $store_file as it is our-imported + $store_profile="log"; local $store_ignore; $store_ignore="smsmail" if 1==$Audit->body() && length(join "",$Audit->body())<180; # SMS mail $store_ignore="sms OS" if $Audit->subject()=~/^Email pro: /; # "^Email pro: gsm@sh\.cvut\.cz$"; @@ -267,6 +278,7 @@ sub audit store "=9kc","log" if headeris "List-Post",''; store "=9kcd","log" if headeris "List-Post",''; } + $store_profile=undef(); # lists store "=mozillabug","log" if headeris "From" ,''; diff --git a/perlmail-accept b/perlmail-accept index 967a758..7771802 100755 --- a/perlmail-accept +++ b/perlmail-accept @@ -71,8 +71,7 @@ use URI::Escape 'uri_escape'; require WWW::SMS; -our($Message,$Audit,@AuditStored,$store_ignore,$store_ignorenewmail,$store_profile,$DoBell); -our(%audit_profile,@sms_squeezes,@alternates_host,@dnsbl_whitelist); # imported +our($Message,@AuditStored,$DoBell); my %alternates_host; # from @alternates_host my %dnsbl_whitelist; # from @dnsbl_whitelist @@ -81,7 +80,7 @@ my %dnsbl_whitelist; # from @dnsbl_whitelist our $procmailTO_ =qr'^((Original-)?(Resent-)?(To|Cc|Bcc)|(X-Envelope|Apparently(-Resent)?)-To):(.*[^-a-zA-Z0-9_.])?'mio; our $procmailTO =qr'^((Original-)?(Resent-)?(To|Cc|Bcc)|(X-Envelope|Apparently(-Resent)?)-To):(.*[^a-zA-Z])?'mio; our $procmailFROM_DAEMON=qr'^(Mailing-List:|Precedence:.*(junk|bulk|list)|To: Multiple recipients of |(((Resent-)?(From|Sender)|X-Envelope-From):|>?From )([^>]*[^(.%@a-z0-9])?(Post(ma?(st(e?r)?|n)|office)|(send)?Mail(er)?|daemon|m(mdf|ajordomo)|n?uucp|LIST(SERV|proc)|NETSERV|o(wner|ps)|r(e(quest|sponse)|oot)|b(ounce|bs\.smtp)|echo|mirror|s(erv(ices?|er)|mtp(error)?|ystem)|A(dmin(istrator)?|MMGR|utoanswer))(([^).!:a-z0-9][-_a-z0-9]*)?[%@> ][^<)]*(\(.*\).*)?)?$([^>]|$))'mio; -our $procmailFROM_MAILER=qr'^(((Resent-)?(From|Sender)|X-Envelope-From):|>?From )[^>]*\b(Post(ma(st(er)?|n)|office)|(send)?Mail(er)?|daemon|mmdf|n?uucp|ops|r(esponse|oot)|(bbs\.)?smtp(error)?|s(erv(ices?|er)|ystem)|A(dmin(istrator)?|MMGR))(([^).!:a-z0-9][-_a-z0-9]*)?[%@> ][^<)]*(\(.*\).*)?)?$([^>]|$)'mio; +$procmailFROM_MAILER=qr'^(((Resent-)?(From|Sender)|X-Envelope-From):|>?From )[^>]*\b(Post(ma(st(er)?|n)|office)|(send)?Mail(er)?|daemon|mmdf|n?uucp|ops|r(esponse|oot)|(bbs\.)?smtp(error)?|s(erv(ices?|er)|ystem)|A(dmin(istrator)?|MMGR))(([^).!:a-z0-9][-_a-z0-9]*)?[%@> ][^<)]*(\(.*\).*)?)?$([^>]|$)'mio; # perl-5.8.0 does not cope w/original FROM_MAILER on the third '?' character # Thus we did '([^>]*[^(.%@a-z0-9])?' -> '[^>]*\b', I hope it is somehow similiar # original FROM_MAILER =qr'^(((Resent-)?(From|Sender)|X-Envelope-From):|>?From )([^>]*[^(.%@a-z0-9])?(Post(ma(st(er)?|n)|office)|(send)?Mail(er)?|daemon|mmdf|n?uucp|ops|r(esponse|oot)|(bbs\.)?smtp(error)?|s(erv(ices?|er)|ystem)|A(dmin(istrator)?|MMGR))(([^).!:a-z0-9][-_a-z0-9]*)?[%@> ][^<)]*(\(.*\).*)?)?$([^>]|$)'mio; @@ -442,7 +441,7 @@ sub write_message { my($folder)=@_; - return if $opt_dry; + return 1 if $opt_dry; # simulate OK local *F; open F,">>$folder" or do { warn "Append \"$folder\": $!"; return 0; }; { @@ -467,7 +466,9 @@ my($message)=@_; local $_=$_; my $save_=$_; local $Message=$message; - local $Audit=Mail::Audit->new( + # Cannot call 'local' for our-imported variable: + my $Audit_save=$Audit; + $Audit=Mail::Audit->new( "emergency"=>"$Mail/emergency", "data"=>[map("$_\n",split("\n",$message))], "log"=>"$HOME/.perlmail.log", @@ -478,6 +479,8 @@ my($message)=@_; write_message("$Mail/input") or die; PerlMail::Config::audit(); warn 'Corrupted $_, repaired' if defined($save_)!=defined($_) || (defined($_) && $save_ ne $_); + # restore: + $Audit=$Audit_save; } # utility functions: diff --git a/perlmail-sendmail b/perlmail-sendmail index c84847d..5ea95ab 100755 --- a/perlmail-sendmail +++ b/perlmail-sendmail @@ -59,8 +59,7 @@ my $opt_b; my $opt_Q; my $opt_q; my $opt_t; -our $opt_f; -our $opt_F; # from PerlMail::Config; +our $opt_f; # not exported, just for local() my $opt_perlmail_dry_run; my @ARGV_save=@ARGV; # for non-bm mode die if !Getopt::Long::GetOptions( @@ -126,7 +125,6 @@ my $from_headername; } # to be utilized later by &FromAddress -our $is_pgp; # from PerlMail::Config; $is_pgp=(1 && do { local $_=$head->mime_attr("Content-Type"); $_ && ~m#^multipart/(?:signed|encrypted)$#; } && do { local $_=$head->mime_attr("Content-Type.protocol"); $_ && ~m#^application/pgp\b#; }