#!/usr/bin/perl -w # # Copyright 2005 Ketil Froyn # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # This script should be called like dspam itself, but without the # --signature parameter. It will read stdin and look for dspam # signatures in the body and header of an email (!DSPAM:...! tags # and X-DSPAM-Signature: header elements). It will call dspam # once for each unique signature found. It should be a drop-in # replacement for dspam where you have: # dspam --source=error --class=spam # or similar. # # $Id: dspam-sigs.pl 4 2005-01-25 00:05:24Z ketil $ use strict; my $dspam_args=join " ", @ARGV; my $dspam_sig = "[a-f0-9]{20,32}"; my %sigs; while () { chomp; if (/^X-DSPAM-Signature:\s+($dspam_sig)\s*$/) { addsig($1); } if (/!DSPAM:($dspam_sig)!/) { addsig($1); } } sub addsig { my ($sig)=@_; return unless $sig; unless (exists $sigs{$sig}) { $sigs{$sig} = 1; my $res = system("dspam $dspam_args --signature=$sig"); if ($res != 0) { print "error $res: $sig\n"; } else { print "ok: $sig\n"; } } }