[Netmail-cvs] netmail spamd.raw,1.2,1.3
Brought to you by:
pascal666
From: <net...@li...> - 2004-06-24 08:14:30
|
Update of /cvsroot/netmail/netmail In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21166 Modified Files: spamd.raw Log Message: Add -flag option Index: spamd.raw =================================================================== RCS file: /cvsroot/netmail/netmail/spamd.raw,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- spamd.raw 21 Jun 2004 06:31:41 -0000 1.2 +++ spamd.raw 24 Jun 2004 08:14:21 -0000 1.3 @@ -110,6 +110,7 @@ 'c' => \$opt{'create-prefs'}, 'daemonize!' => \$opt{'daemonize'}, 'd' => \$opt{'daemonize'}, + 'flag|f' => \$opt{'flag'}, 'help|h' => \$opt{'help'}, 'ip-address|i=s' => \$opt{'ip-address'}, 'max-children|m=i' => \$opt{'max-children'}, @@ -471,7 +472,23 @@ sub check { my $id = $_[1]; local ($_); - until ($client->getline =~ /^6021 /) {}; + $client->getline; + my @envelope; + while ($_ = $client->getline) { + last if /^6021 /; + if (/SpamAssassin/) { + print $client "QDONE\n"; + $_ = $client->getline; + unless (/^1000 /) { + protocol_error ($_); + return 1; + } + $client->close; + return; + } + push(@envelope, $_); + } + print $client "QRETR $id MESSAGE\n"; $_ = $client->getline; unless (/^2023 /) { @@ -499,11 +516,67 @@ my $mail = Mail::SpamAssassin::NoMailAudit->new ( data => \@msglines ); + undef @msglines; # Now use copy-on-writed (hopefully) SA object my $status = $spamtest->check($mail); if ($status->is_spam) { + if ($opt{'flag'}) { + print $client "QINFO $id\n"; + $_ = $client->getline; + unless (/^2001 /) { + protocol_error ($_); + return 1; + } + @_ = split; + my $header_length = $_[3]; + my $body_length = $_[4]; + print $client "QCREA\n"; + $_ = $client->getline; + unless (/^1000 /) { + protocol_error ($_); + return 1; + } + print $client "QADDQ $id 0 $header_length\n"; + $_ = $client->getline; + unless (/^1000 /) { + protocol_error ($_); + return 1; + } + print $client "QSTOR MESSAGE 17\n"; + print $client "X-Spam-Flag: YES\n"; + $_ = $client->getline; + unless (/^1000 /) { + protocol_error ($_); + return 1; + } + print $client "QADDQ $id $header_length $body_length\n"; + $_ = $client->getline; + unless (/^1000 /) { + protocol_error ($_); + return 1; + } + foreach (@envelope) { + print $client "QSTOR RAW $_"; + $_ = $client->getline; + unless (/^1000 /) { + protocol_error ($_); + return 1; + } + } + print $client "QSTOR RAW SpamAssassin\n"; + unless (/^1000 /) { + protocol_error ($_); + return 1; + } + print $client "QRUN\n"; + $_ = $client->getline; + unless (/^1000 /) { + protocol_error ($_); + return 1; + } + } print $client "QDELE $id\n"; $_ = $client->getline; unless (/^1000 /) { @@ -1050,6 +1123,7 @@ -C path, --configpath=path Path for default config files --siteconfigpath=path Path for site configs (def: /etc/mail/spamassassin) -d, --daemonize Daemonize + -f, --flag Set a flag in the message header instead of deleting it -h, --help Print usage message. -i ipaddr, --ip-address=ipaddr IP NMAP is on (default: 127.0.0.1) -m num, --max-children num Allow maximum num children @@ -1129,6 +1203,10 @@ Detach from starting process and run in background (daemonize). +=item B<-f>, B<--flag> + +Add "X-Spam-Flag: YES" to the message header of spam instead of deleting it. + =item B<-h>, B<--help> Print a brief help message, then exit without further action. |