[Greylist-users] License; script for adding black and whitelists; two new whitelist entries

Tim Freeman tim at fungible.com
Sat Nov 22 08:00:06 PST 2003

Relaydelay doesn't say it's available under a license.  Good choices
would be the BSD license (if you want to let other people make it into
a paying product) or the GPL (if you don't).  If you do the BSD
license, be aware that the version *without* the advertising clause is
more standard than the one with the advertising clause.  The problem
with the advertising clause is that the required advertising builds up
onerously if many small packages are combined into one big one.

I think that in the absence of a license, the default is that anyone
can download the software from you because you published it, but
nobody can give it to anyone else.  That way it can't be distributed
by Debian or Red Hat, unless you strike a deal with one of them.

If you take contributions of code from other people, and those people
retain copyright on their contributions, then changing the license is
a nuisance because you have to get a consensus from all the copyright
holders, or drop the contributions from people who aren't part of the
consensus.  Best to put it under the license you want soon, before you
get many contributions.

There's a script below for reading the blacklist_ip.txt or
whitelist_ip.txt files to the database.  I hereby release it into the
public domain; you can take it if you want, and put it under whatever
license you want.  Becuse it's in the public domain, this copy isn't
covered by copyright, so it isn't part of the problem I talked about
in the previous paragraph.

I also added two more whitelist entries:

66.218.66       # Yahoo groups has unique senders   # Bogofilter-dev mailing list has unique senders.

Tim Freeman                                                  tim at fungible.com
GPG public key fingerprint ECDF 46F8 3B80 BB9E 575D  7180 76DF FE00 34B1 5C78 
Your levity is good.  It relieves tension and fear of death.  -- Terminator 3

P. S. This is add-list.pl:

#!/usr/bin/perl -w
use DBI;
use strict;

# Version: 0.01
# Programmer: Tim Freeman <tim at fungible.com>

my $conffile = "/etc/mail/relaydelay.conf";
my $verbose;
my $milter_filter_name;
my $milter_socket_connection;
my $maximum_milter_threads;
my $relaydelay_pid_file;
my $delay_mail_secs;
my $auto_record_life_secs;
my $update_record_life;
my $update_record_life_secs;
my $check_wildcard_relay_ip;
my $check_wildcard_rcpt_to;
my $tempfail_messages_after_data_phase;
my $do_relay_lookup_by_subnet;
my $enable_relay_name_updates;
my $check_envelope_address_format;
my $pass_mail_when_db_unavail;
my $reverse_mail_tracking;
my $reverse_mail_life_secs;
my $database_type;
my $database_name;
my $database_host;
my $database_port;
my $database_user;
my $database_pass;

sub usage () {
    die << "EOM";
Usage: $0 [[-whitelist|-blacklist] yyyy-mm-dd hh:mm:ss|-delete] < list

Add the IP addresses listed in one of the .txt files that comes with
relaydelay to the database.

Reads $conffile for database passwords.

With -whitelist, the given IP\'s are whitelisted until the given date.
With -blacklist, the given IP\'s are blacklisted until the given date.

With -delete, the given IP\'s are deleted from the database.  Do this
first if you want to change the dates on the whitelists or the
blacklists, or you accidentally blacklisted your whitelist.

For example:

   $0 -whitelist 9999-12-31 23:59:59 < whitelist_ip.txt


# Unfortunately, this strategy for reading the configuration file
# requires that each perl statement in the config file is on one line.
sub readconf () {
    open (INFILE, "<$conffile") || die "Can't read $conffile: $!";
    for (;;) {
	my $line = <INFILE>;
	last unless defined $line;
	eval $line;
	if ($@ ne '') {
	    die "Error evaluating this line from $conffile:\n$line\n$@" ;
    close (INFILE) || die "Can't close $conffile: $!";

sub docmd ($$) {
    my ($dbh, $cmd) = @_;
    print "Doing $cmd\n" if $verbose;

sub main () {
    my $foundarg = 0;
    if (0 == @ARGV || $ARGV[0] =~ m!help!i) {
	usage ();
    readconf (); 
    my $dsn = "DBI:$database_type:database=$database_name:".
    my $dbh = DBI->connect($dsn, $database_user, $database_pass, 
			   { PrintError => 0, RaiseError => 1 });
    die "$DBI::errstr\n" unless($dbh);
    for (;;) {
	my $line = <STDIN>;
	last unless defined $line;
	chomp $line;
	if ($line !~ m!^\s*(\d+(\.\d+)*)?\s*(\#.*)?$!) {
	    die "Syntax error at $line";
	my $ip = $1;
	if (! $ip) {
	    print "Skipping blank line $line\n" if $verbose;
	print "Found ip $ip.\n" if $verbose;
	my $didsomething = 0;
	if ($ARGV[0] eq "-delete") {
	    $didsomething = 1;
	    docmd ($dbh, "delete from relaytofrom where relay_ip = '$ip'");
	} else {
	    usage () unless 3 == @ARGV;
	    my $date = "$ARGV[1] $ARGV[2]";
	    if ($ARGV[0] eq "-blacklist") {
		$didsomething = 1;
		docmd ($dbh,
		       "insert into relaytofrom ".
		       "(block_expires, record_expires, create_time, relay_ip) ".
		       "values ('$date', '$date', now(), '$ip')");
	    } elsif ($ARGV[0] eq "-whitelist") {
		$didsomething = 1;
		docmd ($dbh,
		       "insert into relaytofrom ".
		       "(relay_ip, record_expires, create_time) ".
		       "values ('$ip', '$date', now())");
	if (!$didsomething) {
	    usage ();

main ();

More information about the Greylist-users mailing list