I would strongly recommend against doing it this way -- it will certainly break when the whitelist DB format changes. I would instead recommend useing the SA classes and invoking DBBasedAddrList->remove_entry() -- that method will continue to work even if the storage format changes.
C On Sun, 2002-03-03 at 22:34, Daniel Quinlan wrote: > Rob McMillin <[EMAIL PROTECTED]> writes: > > > The problem is exactly that -R doesn't work for me. I wrote a quick > > script to delete everything in the dbm: > > -R was too inconvenient for me, so I wrote this. I have only tested > it against SA 2.01. It may eat your whitelist or some other bad thing > could happen, so back your whitelist up before experimenting with it. > > It seems like spammers can get into your auto-whitelist too easily. > > I am using perl 5.6.1. > > ------- start of cut text -------------- > #!/usr/bin/perl > > # whitelist - manipulate spamassassin 2.01 whitelist > # > # Copyright (C) 2002 Daniel Quinlan <[EMAIL PROTECTED]> > # > # 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 > > use warnings; > use Fcntl; > use AnyDBM_File ; > use Getopt::Std; > > my $prog = $0; > my $db = $ENV{HOME} . "/.spamassassin/auto-whitelist"; > > $prog =~ s@.*/@@; > > getopts("cdhls:"); > use vars qw( %h $opt_c $opt_d $opt_h $opt_l $opt_s ) ; > > tie (%h, "AnyDBM_File", $db, O_RDWR|O_CREAT|O_EXCL, 0600) > or die "Cannot open file $db: $!\n"; > > if ($opt_l) { > &list_whitelist; > } > elsif ($opt_d) { > &delete_addresses; > } > elsif ($opt_s) { > &set_addresses; > } > elsif ($opt_c) { > &clean_addresses; > } > elsif ($opt_h) { > usage(0); > } > usage(1); > > untie %h; > > sub usage { > my $status = shift; > > my $out = $status ? STDERR : STDOUT; > print $out <<EOF; > usage: $prog [options] [addresses ...] > > whitelist - manipulate spamassassin auto-whitelist > > BACKUP YOUR WHITELIST BEFORE RUNNING THIS PROGRAM > > -c remove all suspicious/malformed addresses from auto-whitelist > -d remove addresses from auto-whitelist > -h print this help > -l list auto-whitelist > -s N set count of addresses to N > > EOF > exit($status); > } > > sub set_addresses { > my $k; > > die "$prog: illegal setting: $opt_s\n" if $opt_s !~ /^-?\d+$/; > foreach $k (@ARGV) { > if (defined($h{$k})) { > $h{$k} = $opt_s; > } > } > exit(0); > } > > sub delete_addresses { > my $k; > > foreach $k (@ARGV) { > if (defined($h{$k})) { > print "deleting $k\n"; > delete $h{$k}; > } > } > exit(0); > } > > sub clean_addresses { > my $k; > > foreach $k (keys %h) { > if (length($k) > 80 || $k =~ /[^A-Za-z0-9._\@+-]/) { > print "deleting $k\n"; > delete $h{$k}; > } > } > exit(0); > } > > sub list_whitelist { > my $k; > my $v; > > while (($k, $v) = each %h) { > print "$k\t$v\n"; > } > exit(0); > } > ------- end ---------------------------- > > _______________________________________________ > Spamassassin-talk mailing list > [EMAIL PROTECTED] > https://lists.sourceforge.net/lists/listinfo/spamassassin-talk > > _______________________________________________ Spamassassin-talk mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/spamassassin-talk