From 2d0a465e3eb0b596e62032b1b5f4f5b07982be12 Mon Sep 17 00:00:00 2001 From: in2 Date: Sun, 8 Feb 2004 04:07:25 +0000 Subject: for virus mail git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@1511 63ad8ddf-47c3-0310-b6dd-a9e9d9715204 --- util/filtermail.pl | 50 +++++++++++++++++++------------------------------- 1 file changed, 19 insertions(+), 31 deletions(-) diff --git a/util/filtermail.pl b/util/filtermail.pl index c7a728f7..ad349b1c 100644 --- a/util/filtermail.pl +++ b/util/filtermail.pl @@ -1,44 +1,32 @@ #!/usr/bin/perl -if( -e '/usr/bin/mktemp' ){ - $fn = `/usr/bin/mktemp -q /tmp/filtermail.XXXXXXXX`; -} -else{ - $fn = `/bin/mktemp -q /tmp/filtermail.XXXXXXXX`; -} -chomp $fn; +# $Id$ +$SaveNoRelay = 0; $bbsuid = $ARGV[0]; undef @ARGV; -open FH, ">$fn"; +$msg = ''; $norelay = 0; + while( <> ){ - print FH $_; -# if( ($bbsuid) = $_ =~ /for \<(\w+)\.bbs\@ptt/ ){ -# } - if( /^Content-Type:/i ){ - $norelay = 1 if( (/multipart/i && !/report/i) || /html/ ); - last; - } -} -while( <> ){ - print FH $_; + $msg .= $_; + + $norelay = 1 + if( (/^Content-Type:/i && + ((/multipart/i && !/report/i) || /html/)) || + /Content-Type: audio\/x-wav; name=\".*.exe\"/ ); } -close FH; -if( !$norelay ){ - open FH, "<$fn"; - open OUT, "|/home/bbs/bin/realbbsmail $bbsuid"; - while( ){ - print OUT $_; +if( $norelay ){ + if( $SaveNoRelay ){ + $fn = `/usr/bin/mktemp -q /tmp/norelay.XXXXXXXX`; + open FH, ">$fn"; + print FH $msg; + close FH; } - close FH; - close OUT; - unlink $fn; } else{ - $to = substr($fn, rindex($fn, '/') + 1); - #`/bin/mv $fn /tmp/norelay/$to`; - unlink $fn; + open OUT, "|/home/bbs/bin/realbbsmail $bbsuid"; + print OUT $msg; + close OUT; } - -- cgit v1.2.3