I do something a little different.  I have a script called whitelist
that adds the domain or email to the local.cf file for me.  The script
is called /usr/local/sbin/whitelist.  I created a soft link from there
to /usr/local/sbin/blacklist so I can maintain a single file.  

Here's the script.  If you know perl, you'll figure it out.

Note to "real" perl programmers:  please don't laugh.  I'm a network
admin not a perl guru.  It could probably be written in two lines but it
does the job for me.

#!/usr/bin/perl

# This program appends a new white list or black list domain name to
the local.cf file.

if ($#ARGV < 0 ) {die "Usage: $0 domain-name-or-email\n"};

# do_white is true (1) if we are doing a whitelist command
# It is false (0) if we executed blacklist.
$do_white = 0;

$indx = index($0,"whitelist");

if ($indx > 0) {$do_white = 1;}

# Is this a complete email address or an entire domain?
# wildcard contains "*" if we find an @ in the domain name.  If this
# is not the case, we do not add a wildcard (*) to the domain to
# be white/black listed so wildcard is a null string.
$wildcard = "";

$indx = index($ARGV[0],"@");

if ($indx <= 0) {$wildcard = "*";}

# Use the .test file for testing
# $cf_file='/etc/mail/spamassassin/local.cf.test';
$cf_file='/etc/mail/spamassassin/local.cf';

# Let's make the insertion string so it's ready when we need it
if ($do_white) { $ins_string = "whitelist_from\t\t$wildcard$ARGV[0]
\n"; }
else { $ins_string = "blacklist_from\t\t$wildcard$ARGV[0] \n"; }

print "Adding $ins_string to $cf_file ...";

open(FILE, ">>$cf_file") || die "Can't open $cf_file";

print FILE "$ins_string";

close(FILE);

print "\nDone.\n";

print "Don't forget to run 'service spamd restart'.\n"


=========================================

Someday I will link this up to a cgi script and push out updates via
Netscape.  Like Godot, that will
be here tomorrow...

-Michael

>>> "Steve Thomas" <[EMAIL PROTECTED]> 11/20/02 06:01PM >>>
Yes. If you use spamd/spamc, be sure to restart after the change is
made.

| -----Original Message-----
| From: Scott Henderson @ Bunzl Phoenix
| [mailto:[EMAIL PROTECTED]] 
| Sent: Wednesday, November 20, 2002 2:25 PM
| To: 'Steve Thomas'; [EMAIL PROTECTED] 
| Subject: RE: [SAtalk] RE: how to whitelist a mail server by name or
IP
| address?
| 
| 
| OK, and this should go in /etc/mail/spamassassin/local.cf, right?
| 
| >| I can sure try that, thanks.  And to do this by mail server 
| name, I would
| >| just replace the IP address stuff with /servername/    right?
| 
| >Yep - make sure to escape any periods or dashes (put a backslash 
| >in front of it), as they're special characters.
| 


-------------------------------------------------------
This SF.net email is sponsored by: The Sourceforge Network Survey
Take Our Survey and You Could Win a $500 Gift Certificate!
http://ugamsolutions.com/psurvey/osdn/SourceForge/index_sourceforge.htm

_______________________________________________
Spamassassin-talk mailing list
[EMAIL PROTECTED] 
https://lists.sourceforge.net/lists/listinfo/spamassassin-talk


-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
Spamassassin-talk mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/spamassassin-talk

Reply via email to