Index: /trunk/dports/mail/sqlgrey/Portfile
===================================================================
--- /trunk/dports/mail/sqlgrey/Portfile	(revision 98804)
+++ /trunk/dports/mail/sqlgrey/Portfile	(revision 98805)
@@ -28,5 +28,5 @@
 checksums           sha1    2359577af0149394d1181e12007f013478148423 \
                     rmd160  0404df3987ceb4732e73fee09388454995754c1c
-
+patch.pre_args      -p1
 patchfiles          patch-Makefile.diff \
                     patch-etc-sqlgrey.conf.diff \
@@ -39,5 +39,5 @@
 
 post-patch {
-    reinplace "s|@@PREFIX@@|${prefix}|g" \
+    reinplace "s|@PREFIX@|${prefix}|g" \
         ${worksrcpath}/etc/sqlgrey.conf \
         ${worksrcpath}/sqlgrey \
@@ -45,13 +45,13 @@
         ${worksrcpath}/tester.pl \
         ${worksrcpath}/Makefile
-    reinplace "s|@@DESTROOT@@|${destroot}|g" \
+    reinplace "s|@DESTROOT@|${destroot}|g" \
         ${worksrcpath}/Makefile
-    reinplace "s|@@NAME@@|${name}|g" \
+    reinplace "s|@NAME@|${name}|g" \
         ${worksrcpath}/etc/sqlgrey.conf \
         ${worksrcpath}/sqlgrey
-    reinplace "s|@@SQLGREYUSER@@|${sqlgreyuser}|g" \
+    reinplace "s|@SQLGREYUSER@|${sqlgreyuser}|g" \
         ${worksrcpath}/etc/sqlgrey.conf \
         ${worksrcpath}/sqlgrey
-    reinplace "s|@@SQLGREYGROUP@@|${sqlgreygroup}|g" \
+    reinplace "s|@SQLGREYGROUP@|${sqlgreygroup}|g" \
         ${worksrcpath}/etc/sqlgrey.conf \
         ${worksrcpath}/sqlgrey
@@ -70,12 +70,13 @@
     set gid [existsgroup ${sqlgreygroup}]
     adduser ${sqlgreyuser} gid=${gid} realname=${name}
-    move ${destroot}${prefix}/etc/sqlgrey/sqlgrey.conf ${destroot}${prefix}/etc/sqlgrey/sqlgrey.conf.example
+    move ${destroot}${prefix}/etc/${name}/sqlgrey.conf ${destroot}${prefix}/etc/${name}/sqlgrey.conf.example
+    xinstall -m 755 -d ${destroot}${prefix}/share/doc/${name}
     xinstall -m 0664 -W ${worksrcpath} FAQ HOWTO README.DBCLUSTER README.DISCRIMINATION README.OPTINOUT README.PERF \
-        ${destroot}${prefix}/etc/sqlgrey
+        ${destroot}${prefix}/share/doc/${name}
 }
 
 post-activate {
-    touch ${prefix}/etc/sqlgrey/clients_fqdn_whitelist.local
-    touch ${prefix}/etc/sqlgrey/clients_ip_whitelist.local
+    touch ${prefix}/etc/${name}/clients_fqdn_whitelist.local
+    touch ${prefix}/etc/${name}/clients_ip_whitelist.local
 }
 
@@ -94,4 +95,8 @@
 }
 
+variant table_names description {Make table names configurable} {
+    patchfiles-append   patch-table-names.diff
+}
+
 livecheck.version   ${version}
 livecheck.regex     "(?!${name}).*${name}-((?!${extract.suffix}).*)${extract.suffix}"
Index: /trunk/dports/mail/sqlgrey/files/patch-Makefile.diff
===================================================================
--- /trunk/dports/mail/sqlgrey/files/patch-Makefile.diff	(revision 98804)
+++ /trunk/dports/mail/sqlgrey/files/patch-Makefile.diff	(revision 98805)
@@ -1,16 +1,16 @@
---- Makefile.orig	2010-05-17 11:36:13.000000000 -0700
-+++ Makefile	2010-05-17 11:36:17.000000000 -0700
+--- a/Makefile	2012-08-24 18:05:39.000000000 -0700
++++ b/Makefile	2012-08-24 18:06:42.000000000 -0700
 @@ -1,10 +1,10 @@
  INSTALL = install
 -ETCDIR = $(ROOTDIR)/etc
-+ETCDIR = @@DESTROOT@@@@PREFIX@@/etc
++ETCDIR = @DESTROOT@@PREFIX@/etc
  CONFDIR = $(ETCDIR)/sqlgrey
 -SBINDIR = $(ROOTDIR)/usr/sbin
 -BINDIR = $(ROOTDIR)/usr/bin
-+SBINDIR = @@DESTROOT@@@@PREFIX@@/sbin
-+BINDIR = @@DESTROOT@@@@PREFIX@@/bin
++SBINDIR = @DESTROOT@@PREFIX@/sbin
++BINDIR = @DESTROOT@@PREFIX@/bin
  INITDIR = $(ETCDIR)/init.d
 -MANDIR = $(ROOTDIR)/usr/share/man/man1
-+MANDIR = @@DESTROOT@@@@PREFIX@@/share/man/man1
++MANDIR = @DESTROOT@@PREFIX@/share/man/man1
  
  VERSION := $(shell cat VERSION)
Index: /trunk/dports/mail/sqlgrey/files/patch-etc-sqlgrey.conf.diff
===================================================================
--- /trunk/dports/mail/sqlgrey/files/patch-etc-sqlgrey.conf.diff	(revision 98804)
+++ /trunk/dports/mail/sqlgrey/files/patch-etc-sqlgrey.conf.diff	(revision 98805)
@@ -1,4 +1,4 @@
---- etc/sqlgrey.conf.orig	2010-05-17 12:32:55.000000000 -0700
-+++ etc/sqlgrey.conf	2010-05-17 12:33:08.000000000 -0700
+--- a/etc/sqlgrey.conf	2012-08-24 18:05:39.000000000 -0700
++++ b/etc/sqlgrey.conf	2012-08-24 18:08:37.000000000 -0700
 @@ -7,7 +7,7 @@
  # - SQLgrey uses a specific config file when called with -f <conf_file>
@@ -6,5 +6,5 @@
  ## Configuration files
 -# conf_dir = /etc/sqlgrey
-+# conf_dir = @@PREFIX@@/etc/sqlgrey
++# conf_dir = @PREFIX@/etc/sqlgrey
  
  ## Log level
@@ -16,6 +16,6 @@
 -# user = sqlgrey
 -# group = sqlgrey
-+# user = @@SQLGREYUSER@@
-+# group = @@SQLGREYGROUP@@
++# user = @SQLGREYUSER@
++# group = @SQLGREYGROUP@
  
  ## Socket
@@ -26,5 +26,5 @@
  # where to store the process PID
 -# pidfile = /var/run/sqlgrey.pid
-+# pidfile = @@PREFIX@@/var/run/@@NAME@@/sqlgrey.pid
++# pidfile = @PREFIX@/var/run/@NAME@/sqlgrey.pid
  
  ## Greylisting delays
Index: /trunk/dports/mail/sqlgrey/files/patch-sqlgrey-logstats.pl.diff
===================================================================
--- /trunk/dports/mail/sqlgrey/files/patch-sqlgrey-logstats.pl.diff	(revision 98804)
+++ /trunk/dports/mail/sqlgrey/files/patch-sqlgrey-logstats.pl.diff	(revision 98805)
@@ -1,7 +1,7 @@
---- sqlgrey-logstats.pl.orig	2010-05-17 11:55:47.000000000 -0700
-+++ sqlgrey-logstats.pl	2010-05-17 11:55:50.000000000 -0700
+--- a/sqlgrey-logstats.pl	2012-08-24 18:05:39.000000000 -0700
++++ b/sqlgrey-logstats.pl	2012-08-24 18:06:53.000000000 -0700
 @@ -1,4 +1,4 @@
 -#!/usr/bin/perl -w
-+#!@@PREFIX@@/bin/perl -w
++#!@PREFIX@/bin/perl -w
  
  # sqlgrey: a postfix greylisting policy server using an SQL backend
Index: /trunk/dports/mail/sqlgrey/files/patch-sqlgrey.diff
===================================================================
--- /trunk/dports/mail/sqlgrey/files/patch-sqlgrey.diff	(revision 98804)
+++ /trunk/dports/mail/sqlgrey/files/patch-sqlgrey.diff	(revision 98805)
@@ -1,7 +1,7 @@
---- sqlgrey.orig	2010-05-17 12:40:48.000000000 -0700
-+++ sqlgrey	2010-05-17 12:40:52.000000000 -0700
+--- a/sqlgrey	2012-08-24 18:05:39.000000000 -0700
++++ b/sqlgrey	2012-08-24 18:07:09.000000000 -0700
 @@ -1,4 +1,4 @@
 -#!/usr/bin/perl -w
-+#!@@PREFIX@@/bin/perl -w
++#!@PREFIX@/bin/perl -w
  
  # sqlgrey: a postfix greylisting policy server using an SQL backend
@@ -13,11 +13,11 @@
 -$dflt{user}               = 'sqlgrey';
 -$dflt{group}              = 'sqlgrey';
-+$dflt{user}               = '@@SQLGREYUSER@@';
-+$dflt{group}              = '@@SQLGREYGROUP@@';
++$dflt{user}               = '@SQLGREYUSER@';
++$dflt{group}              = '@SQLGREYGROUP@';
  $dflt{inet}               = '2501';
 -$dflt{pidfile}            = '/var/run/sqlgrey.pid';
 -$dflt{conf_dir}           = '/etc/sqlgrey';
-+$dflt{pidfile}            = '@@PREFIX@@/var/run/@@NAME@@/sqlgrey.pid';
-+$dflt{conf_dir}           = '@@PREFIX@@/etc/sqlgrey';
++$dflt{pidfile}            = '@PREFIX@/var/run/@NAME@/sqlgrey.pid';
++$dflt{conf_dir}           = '@PREFIX@/etc/sqlgrey';
  $dflt{reconnect_delay}    = 5;            # 5 minutes
  $dflt{max_connect_age}    = 24;           # 24 hours
@@ -28,5 +28,5 @@
  # Default configuration file
 -my $config_file              = '/etc/sqlgrey/sqlgrey.conf';
-+my $config_file              = '@@PREFIX@@/etc/sqlgrey/sqlgrey.conf';
++my $config_file              = '@PREFIX@/etc/sqlgrey/sqlgrey.conf';
  
  # whitelist files
@@ -37,5 +37,5 @@
  	# 'warning: Filehandle STDERR reopened as FILE only \
 -	# for input at /usr/bin/sqlgrey line 717, <FILE> line 57'
-+	# for input at @@PREFIX@@/bin/sqlgrey line 717, <FILE> line 57'
++	# for input at @PREFIX@/bin/sqlgrey line 717, <FILE> line 57'
  	open(STDIN,'</dev/null');
  	open(STDOUT,'>/dev/null');
@@ -46,5 +46,5 @@
   -f, --configfile=FILE      read config from FILE
 -                            (default /etc/sqlgrey/sqlgrey.conf)
-+                            (default @@PREFIX@@/etc/sqlgrey/sqlgrey.conf)
++                            (default @PREFIX@/etc/sqlgrey/sqlgrey.conf)
                              expecting config_param=value lines,
                              - spaces are ignored,
@@ -52,9 +52,9 @@
  
 -See the default config file at /etc/sqlgrey/sqlgrey.conf for runtime parameters.
-+See the default config file at @@PREFIX@@/etc/sqlgrey/sqlgrey.conf for runtime parameters.
++See the default config file at @PREFIX@/etc/sqlgrey/sqlgrey.conf for runtime parameters.
  If you got sqlgrey from sources, read the HOWTO file in the compressed archive.
  If it came prepackaged, look into the documentation tree for this file:
 -/usr/share/doc/sqlgrey-<version>/ on most Linux distributions for example.
-+@@PREFIX@@/share/doc/sqlgrey-<version>/ on most Linux distributions for example.
++@PREFIX@/share/doc/sqlgrey-<version>/ on most Linux distributions for example.
  
  =head1 DESCRIPTION
@@ -65,5 +65,5 @@
  Start by adding check_policy_service after reject_unauth_destination in
 -/etc/postfix/main.cf :
-+@@PREFIX@@/etc/postfix/main.cf :
++@PREFIX@/etc/postfix/main.cf :
  
   smtpd_recipient_restrictions =
@@ -74,5 +74,5 @@
  
 -/etc/postfix/sqlgrey_recipient_access:
-+@@PREFIX@@/etc/postfix/sqlgrey_recipient_access:
++@PREFIX@/etc/postfix/sqlgrey_recipient_access:
    i_like_spam@ee.ethz.ch                OK
  
@@ -84,6 +84,6 @@
 -       check_client_access    hash:/etc/postfix/sqlgrey_client_access
 -       check_recipient_access hash:/etc/postfix/sqlgrey_recipient_access
-+       check_client_access    hash:@@PREFIX@@/etc/postfix/sqlgrey_client_access
-+       check_recipient_access hash:@@PREFIX@@/etc/postfix/sqlgrey_recipient_access
++       check_client_access    hash:@PREFIX@/etc/postfix/sqlgrey_client_access
++       check_recipient_access hash:@PREFIX@/etc/postfix/sqlgrey_recipient_access
         check_policy_service inet:127.0.0.1:10023
  
Index: /trunk/dports/mail/sqlgrey/files/patch-table-names.diff
===================================================================
--- /trunk/dports/mail/sqlgrey/files/patch-table-names.diff	(revision 98805)
+++ /trunk/dports/mail/sqlgrey/files/patch-table-names.diff	(revision 98805)
@@ -0,0 +1,968 @@
+diff -ur a/etc/sqlgrey.conf b/etc/sqlgrey.conf
+--- a/etc/sqlgrey.conf	2011-11-30 07:53:59.000000000 -0800
++++ b/etc/sqlgrey.conf	2011-11-30 08:01:06.000000000 -0800
+@@ -142,6 +142,17 @@
+ # Valid options: on/off. If set to 'on', clustering will be enabled.
+ # db_cluster = on
+ 
++## Database table names
++# db_table_temp = temp
++# db_table_connect = connect
++# db_table_from_awl = from_awl
++# db_table_domain_awl = domain_awl
++# db_table_optin_domain = optin_domain
++# db_table_optin_email = optin_email
++# db_table_optout_domain = optout_domain
++# db_table_optout_email = optout_email
++# db_table_config = config
++
+ #
+ # Comma seperated list of read-only db-servers.
+ # read_hosts= slave-db-1.test.com, slave-db-2.test.com ,slave-db-3.test.com
+Only in b: patch-etc-sqlgrey.conf.diff
+Only in b: patch-sqlgrey.diff
+diff -ur a/sqlgrey b/sqlgrey
+--- a/sqlgrey	2011-11-30 07:53:59.000000000 -0800
++++ b/sqlgrey	2011-11-30 07:57:46.000000000 -0800
+@@ -43,16 +43,6 @@
+ 
+ my $DB_VERSION = 3;
+ 
+-# Table names
+-my $connect       = 'connect';
+-my $from_awl      = 'from_awl';
+-my $domain_awl    = 'domain_awl';
+-my $optin_domain  = 'optin_domain';
+-my $optin_email   = 'optin_email';
+-my $optout_domain = 'optout_domain';
+-my $optout_email  = 'optout_email';
+-my $config        = 'config';
+-
+ # defaults
+ my %dflt;
+ $dflt{loglevel}           = 2; # used for $dflt{log} entries in read_conffile()
+@@ -76,6 +66,15 @@
+ $dflt{db_pass}            = '';
+ $dflt{db_prepare_cache}   = 0;
+ $dflt{db_cluster}	  = 'off';
++$dflt{db_table_temp}          = 'temp';
++$dflt{db_table_connect}       = 'connect';
++$dflt{db_table_from_awl}      = 'from_awl';
++$dflt{db_table_domain_awl}    = 'domain_awl';
++$dflt{db_table_optin_domain}  = 'optin_domain';
++$dflt{db_table_optin_email}   = 'optin_email';
++$dflt{db_table_optout_domain} = 'optout_domain';
++$dflt{db_table_optout_email}  = 'optout_email';
++$dflt{db_table_config}        = 'config';
+ $dflt{prepend}            = 1;
+ $dflt{greymethod}         = 'smart';
+ $dflt{optmethod}          = 'none'; # or 'optin' or 'optout'
+@@ -393,34 +392,34 @@
+ sub database_setup($) {
+     my $self = shift;
+     # AWL and connect tables checks
+-    if (! $self->table_exists($from_awl)) {
++    if (! $self->table_exists($self->{sqlgrey}{db_table_from_awl})) {
+ 	$self->create_from_awl_table();
+ 	$self->create_from_awl_indexes();
+     }
+-    if (! $self->table_exists($domain_awl)) {
++    if (! $self->table_exists($self->{sqlgrey}{db_table_domain_awl})) {
+ 	$self->create_domain_awl_table();
+ 	$self->create_domain_awl_indexes();
+     }
+-    if (! $self->table_exists($connect)) {
++    if (! $self->table_exists($self->{sqlgrey}{db_table_connect})) {
+ 	$self->create_connect_table();
+ 	$self->create_connect_indexes();
+     }
+     # optin/out tables checks
+-    if (! $self->table_exists($optin_domain)) {
++    if (! $self->table_exists($self->{sqlgrey}{db_table_optin_domain})) {
+ 	$self->create_optin_domain_table();
+     }
+-    if (! $self->table_exists($optin_email)) {
++    if (! $self->table_exists($self->{sqlgrey}{db_table_optin_email})) {
+ 	$self->create_optin_email_table();
+     }
+-    if (! $self->table_exists($optout_domain)) {
++    if (! $self->table_exists($self->{sqlgrey}{db_table_optout_domain})) {
+ 	$self->create_optout_domain_table();
+     }
+-    if (! $self->table_exists($optout_email)) {
++    if (! $self->table_exists($self->{sqlgrey}{db_table_optout_email})) {
+ 	$self->create_optout_email_table();
+     }
+ 
+     # config table check
+-    if (! $self->table_exists($config)) {
++    if (! $self->table_exists($self->{sqlgrey}{db_table_config})) {
+ 	$self->create_config_table();
+ 	$self->setconfig('version',$DB_VERSION);
+     }
+@@ -446,10 +445,10 @@
+     my $self = shift;
+     my $param = shift;
+ 
+-    my $sth = $self->prepare_cached("SELECT value FROM $config " .
++    my $sth = $self->prepare_cached("SELECT value FROM $self->{sqlgrey}{db_table_config} " .
+ 				    'WHERE parameter = ?');
+     if (!defined $sth or !$sth->execute($param)) {
+-	$self->mylog('dbaccess', 0, "error: couldn't access $config table: $DBI::errstr");
++	$self->mylog('dbaccess', 0, "error: couldn't access $self->{sqlgrey}{db_table_config} table: $DBI::errstr");
+ 	return undef;
+ 	#$self->mydie('getconfig error',
+ 	#	     'Can\'t continue: config table unreadable');
+@@ -473,10 +472,10 @@
+     my $param = shift;
+     my $value = shift;
+ 
+-    my $sth = $self->prepare_cached("SELECT value FROM $config " .
++    my $sth = $self->prepare_cached("SELECT value FROM $self->{sqlgrey}{db_table_config} " .
+ 				    'WHERE parameter = ?');
+     if (!defined $sth or !$sth->execute($param)) {
+-	$self->mylog('dbaccess', 0, "error: couldn't access $config table: $DBI::errstr");
++	$self->mylog('dbaccess', 0, "error: couldn't access $self->{sqlgrey}{db_table_config} table: $DBI::errstr");
+ 	$self->mydie('setconfig error',
+ 		     'Can\'t continue: config table unreadable');
+     }
+@@ -496,7 +495,7 @@
+     my $old_value = shift;
+ 
+ 
+-    my $affected_rows = $self->do("UPDATE $config SET value = " .
++    my $affected_rows = $self->do("UPDATE $self->{sqlgrey}{db_table_config} SET value = " .
+                                   $self->quote($value) .
+                                   ' WHERE parameter = ' .
+                                   $self->quote($param) .
+@@ -513,7 +512,7 @@
+     my $param = shift;
+     my $value = shift;
+ 
+-    return $self->do("INSERT INTO $config (parameter, value) VALUES(" .
++    return $self->do("INSERT INTO $self->{sqlgrey}{db_table_config} (parameter, value) VALUES(" .
+ 		     $self->quote($param) . ',' .
+ 		     $self->quote($value) . ')');
+ }
+@@ -522,7 +521,7 @@
+     my $self = shift;
+ 
+     # No config table -> version 0
+-    if (! $self->table_exists("$config")) {
++    if (! $self->table_exists("$self->{sqlgrey}{db_table_connect}")) {
+ 	return 0;
+     }
+ 
+@@ -561,101 +560,101 @@
+     ## can we detect SQLite 3+ ?
+ 
+     # connect
+-    $self->mylog('dbaccess', 2, "$connect table: renaming ip_addr to src");
++    $self->mylog('dbaccess', 2, "$self->{sqlgrey}{db_table_connect} table: renaming ip_addr to src");
+     if ($self->SQLite()) {
+-	$self->create_connect_table('temp');
+-	$self->do('INSERT INTO temp (sender_name, sender_domain, ' .
++	$self->create_connect_table($self->{sqlgrey}{db_table_temp});
++	$self->do('INSERT INTO ' . $self->{sqlgrey}{db_table_temp} . ' (sender_name, sender_domain, ' .
+ 		  'src, rcpt, first_seen) ' .
+ 		  'SELECT sender_name, sender_domain, ip_addr, ' .
+ 		  'rcpt, first_seen ' .
+-		  "FROM $connect");
+-	$self->drop_table($connect);
++		  "FROM $self->{sqlgrey}{db_table_connect}");
++	$self->drop_table($self->{sqlgrey}{db_table_connect});
+     } else {
+-	$self->do("ALTER TABLE $connect RENAME TO $connect" . 'old');
++	$self->do("ALTER TABLE $self->{sqlgrey}{db_table_connect} RENAME TO $self->{sqlgrey}{db_table_connect}" . 'old');
+     }
+     $self->create_connect_table();
+     if ($self->SQLite()) {
+-	$self->do("INSERT INTO $connect (sender_name, sender_domain, " .
++	$self->do("INSERT INTO $self->{sqlgrey}{db_table_connect} (sender_name, sender_domain, " .
+ 		  'src, rcpt, first_seen) ' .
+ 		  'SELECT sender_name, sender_domain, src, ' .
+ 		  'rcpt, first_seen ' .
+-		  'FROM temp');
+-	$self->drop_table('temp');
++		  'FROM ' . $self->{sqlgrey}{db_table_temp});
++	$self->drop_table($self->{sqlgrey}{db_table_temp});
+     } else {
+-	$self->do("INSERT INTO $connect (sender_name, sender_domain, " .
++	$self->do("INSERT INTO $self->{sqlgrey}{db_table_connect} (sender_name, sender_domain, " .
+ 		  'src, rcpt, first_seen) ' .
+ 		  'SELECT sender_name, sender_domain, ip_addr, ' .
+ 		  'rcpt, first_seen ' .
+-		  "FROM $connect" . 'old');
+-	$self->drop_table("$connect" . 'old');
++		  "FROM $self->{sqlgrey}{db_table_connect}" . 'old');
++	$self->drop_table("$self->{sqlgrey}{db_table_connect}" . 'old');
+     }
+-    $self->mylog('dbaccess', 2, "$connect table: adding indexes");
++    $self->mylog('dbaccess', 2, "$self->{sqlgrey}{db_table_connect} table: adding indexes");
+     $self->create_connect_indexes();
+ 
+     # from_awl
+-    $self->mylog('dbaccess', 2, "$from_awl: renaming host_ip to src, adding first_seen");
++    $self->mylog('dbaccess', 2, "$self->{sqlgrey}{db_table_from_awl}: renaming host_ip to src, adding first_seen");
+     if ($self->SQLite()) {
+-	$self->create_from_awl_table('temp');
+-	$self->do('INSERT INTO temp (sender_name, sender_domain, ' .
++	$self->create_from_awl_table($self->{sqlgrey}{db_table_temp});
++	$self->do('INSERT INTO ' . $self->{sqlgrey}{db_table_temp} . ' (sender_name, sender_domain, ' .
+ 		  'src, last_seen, first_seen) ' .
+ 		  'SELECT sender_name, sender_domain, host_ip, last_seen, last_seen ' .
+-		  "FROM $from_awl");
+-	$self->drop_table($from_awl);
++		  "FROM $self->{sqlgrey}{db_table_from_awl}");
++	$self->drop_table($self->{sqlgrey}{db_table_from_awl});
+     } else {
+-	$self->do("ALTER TABLE $from_awl RENAME TO $from_awl" . 'old');
++	$self->do("ALTER TABLE $self->{sqlgrey}{db_table_from_awl} RENAME TO $self->{sqlgrey}{db_table_from_awl}" . 'old');
+     }
+     if ($self->PostgreSQL()) { # we need to remove the pkey constraint
+-	$self->do("ALTER TABLE $from_awl" . 'old DROP CONSTRAINT ' .
++	$self->do("ALTER TABLE $self->{sqlgrey}{db_table_from_awl}" . 'old DROP CONSTRAINT ' .
+ 		  'from_awl_pkey');
+     }
+     $self->create_from_awl_table();
+     if ($self->SQLite()) {
+-	$self->do("INSERT INTO $from_awl (sender_name, sender_domain, " .
++	$self->do("INSERT INTO $self->{sqlgrey}{db_table_from_awl} (sender_name, sender_domain, " .
+ 		  'src, last_seen, first_seen) ' .
+ 		  'SELECT sender_name, sender_domain, src, last_seen, last_seen ' .
+-		  'FROM temp');
+-	$self->drop_table('temp');
++		  'FROM ' . $self->{sqlgrey}{db_table_temp});
++	$self->drop_table($self->{sqlgrey}{db_table_temp});
+     } else {
+-	$self->do("INSERT INTO $from_awl (sender_name, sender_domain, " .
++	$self->do("INSERT INTO $self->{sqlgrey}{db_table_from_awl} (sender_name, sender_domain, " .
+ 		  'src, last_seen, first_seen) ' .
+ 		  'SELECT sender_name, sender_domain, host_ip, last_seen, last_seen ' .
+-		  "FROM $from_awl" . 'old');
+-	$self->drop_table("$from_awl" . 'old');
++		  "FROM $self->{sqlgrey}{db_table_from_awl}" . 'old');
++	$self->drop_table("$self->{sqlgrey}{db_table_from_awl}" . 'old');
+     }
+-    $self->mylog('dbaccess', 2, "$from_awl: adding indexes");
++    $self->mylog('dbaccess', 2, "$self->{sqlgrey}{db_table_from_awl}: adding indexes");
+     $self->create_from_awl_indexes();
+ 
+     # domain_awl
+-    $self->mylog('dbaccess', 2, "$domain_awl: renaming host_ip to src, adding first_seen");
++    $self->mylog('dbaccess', 2, "$self->{sqlgrey}{db_table_domain_awl}: renaming host_ip to src, adding first_seen");
+     if ($self->SQLite()) {
+-	$self->create_domain_awl_table('temp');
+-	$self->do('INSERT INTO temp (sender_domain, ' .
++	$self->create_domain_awl_table($self->{sqlgrey}{db_table_temp});
++	$self->do('INSERT INTO ' . $self->{sqlgrey}{db_table_temp} . ' (sender_domain, ' .
+ 		  'src, last_seen, first_seen) ' .
+ 		  'SELECT sender_domain, host_ip, last_seen, last_seen ' .
+-		  "FROM $domain_awl");
+-	$self->drop_table($domain_awl);
++		  "FROM $self->{sqlgrey}{db_table_domain_awl}");
++	$self->drop_table($self->{sqlgrey}{db_table_domain_awl});
+     } else {
+-	$self->do("ALTER TABLE $domain_awl RENAME TO $domain_awl" . 'old');
++	$self->do("ALTER TABLE $self->{sqlgrey}{db_table_domain_awl} RENAME TO $self->{sqlgrey}{db_table_domain_awl}" . 'old');
+     }
+     if ($self->PostgreSQL()) { # we need to remove the pkey constraint
+-	$self->do("ALTER TABLE $domain_awl" . 'old DROP CONSTRAINT ' .
++	$self->do("ALTER TABLE $self->{sqlgrey}{db_table_domain_awl}" . 'old DROP CONSTRAINT ' .
+ 		  'domain_awl_pkey');
+     }
+     $self->create_domain_awl_table();
+     if ($self->SQLite()) {
+-	$self->do("INSERT INTO $domain_awl (sender_domain, " .
++	$self->do("INSERT INTO $self->{sqlgrey}{db_table_domain_awl} (sender_domain, " .
+ 		  'src, last_seen, first_seen) ' .
+ 		  'SELECT sender_domain, src, last_seen, last_seen ' .
+-		  'FROM temp');
+-	$self->drop_table('temp');
++		  'FROM ' . $self->{sqlgrey}{db_table_temp});
++	$self->drop_table($self->{sqlgrey}{db_table_temp});
+     } else {
+-	$self->do("INSERT INTO $domain_awl (sender_domain, src, " .
++	$self->do("INSERT INTO $self->{sqlgrey}{db_table_domain_awl} (sender_domain, src, " .
+ 		  'last_seen, first_seen) ' .
+ 		  'SELECT sender_domain, host_ip, last_seen, last_seen ' .
+-		  "FROM $domain_awl" . 'old');
+-	$self->do("DROP TABLE $domain_awl" . 'old');
++		  "FROM $self->{sqlgrey}{db_table_domain_awl}" . 'old');
++	$self->do("DROP TABLE $self->{sqlgrey}{db_table_domain_awl}" . 'old');
+     }
+-    $self->mylog('dbaccess', 2, "$domain_awl: adding indexes");
++    $self->mylog('dbaccess', 2, "$self->{sqlgrey}{db_table_domain_awl}: adding indexes");
+     $self->create_domain_awl_indexes();
+ 
+     # Update our schema
+@@ -670,101 +669,101 @@
+     ## can we detect SQLite 3+ ?
+ 
+     # connect
+-    $self->mylog('dbaccess', 2, "$connect: making room for IPv6 in src");
++    $self->mylog('dbaccess', 2, "$self->{sqlgrey}{db_table_connect}: making room for IPv6 in src");
+     if ($self->SQLite()) {
+-	$self->create_connect_table('temp');
+-	$self->do('INSERT INTO temp (sender_name, sender_domain, ' .
++	$self->create_connect_table($self->{sqlgrey}{db_table_temp});
++	$self->do('INSERT INTO ' . $self->{sqlgrey}{db_table_temp} . ' (sender_name, sender_domain, ' .
+ 		  'src, rcpt, first_seen) ' .
+ 		  'SELECT sender_name, sender_domain, src, ' .
+ 		  'rcpt, first_seen ' .
+-		  "FROM $connect");
+-	$self->drop_table($connect);
++		  "FROM $self->{sqlgrey}{db_table_connect}");
++	$self->drop_table($self->{sqlgrey}{db_table_connect});
+     } else {
+-	$self->do("ALTER TABLE $connect RENAME TO $connect" . 'old');
++	$self->do("ALTER TABLE $self->{sqlgrey}{db_table_connect} RENAME TO $self->{sqlgrey}{db_table_connect}" . 'old');
+     }
+     $self->create_connect_table();
+     if ($self->SQLite()) {
+-	$self->do("INSERT INTO $connect (sender_name, sender_domain, " .
++	$self->do("INSERT INTO $self->{sqlgrey}{db_table_connect} (sender_name, sender_domain, " .
+ 		  'src, rcpt, first_seen) ' .
+ 		  'SELECT sender_name, sender_domain, src, ' .
+ 		  'rcpt, first_seen ' .
+-		  'FROM temp');
+-	$self->drop_table('temp');
++		  'FROM ' . $self->{sqlgrey}{db_table_temp});
++	$self->drop_table($self->{sqlgrey}{db_table_temp});
+     } else {
+-	$self->do("INSERT INTO $connect (sender_name, sender_domain, " .
++	$self->do("INSERT INTO $self->{sqlgrey}{db_table_connect} (sender_name, sender_domain, " .
+ 		  'src, rcpt, first_seen) ' .
+ 		  'SELECT sender_name, sender_domain, src, ' .
+ 		  'rcpt, first_seen ' .
+-		  "FROM $connect" . 'old');
+-	$self->drop_table("$connect" . 'old');
++		  "FROM $self->{sqlgrey}{db_table_connect}" . 'old');
++	$self->drop_table("$self->{sqlgrey}{db_table_connect}" . 'old');
+     }
+-    $self->mylog('dbaccess', 2, "$connect: adding indexes");
++    $self->mylog('dbaccess', 2, "$self->{sqlgrey}{db_table_connect}: adding indexes");
+     $self->create_connect_indexes();
+ 
+     # from_awl
+-    $self->mylog('dbaccess', 2, "$from_awl: making room for IPv6 in src");
++    $self->mylog('dbaccess', 2, "$self->{sqlgrey}{db_table_from_awl}: making room for IPv6 in src");
+     if ($self->SQLite()) {
+-	$self->create_from_awl_table('temp');
+-	$self->do('INSERT INTO temp (sender_name, sender_domain, ' .
++	$self->create_from_awl_table($self->{sqlgrey}{db_table_temp});
++	$self->do('INSERT INTO ' . $self->{sqlgrey}{db_table_temp} . ' (sender_name, sender_domain, ' .
+ 		  'src, last_seen, first_seen) ' .
+ 		  'SELECT sender_name, sender_domain, src, last_seen, last_seen ' .
+-		  "FROM $from_awl");
+-	$self->drop_table($from_awl);
++		  "FROM $self->{sqlgrey}{db_table_from_awl}");
++	$self->drop_table($self->{sqlgrey}{db_table_from_awl});
+     } else {
+-	$self->do("ALTER TABLE $from_awl RENAME TO $from_awl" . 'old');
++	$self->do("ALTER TABLE $self->{sqlgrey}{db_table_from_awl} RENAME TO $self->{sqlgrey}{db_table_from_awl}" . 'old');
+     }
+     if ($self->PostgreSQL()) { # we need to remove the pkey constraint
+-	$self->do("ALTER TABLE $from_awl" . 'old DROP CONSTRAINT ' .
++	$self->do("ALTER TABLE $self->{sqlgrey}{db_table_from_awl}" . 'old DROP CONSTRAINT ' .
+ 		  'from_awl_pkey');
+     }
+     $self->create_from_awl_table();
+     if ($self->SQLite()) {
+-	$self->do("INSERT INTO $from_awl (sender_name, sender_domain, " .
++	$self->do("INSERT INTO $self->{sqlgrey}{db_table_from_awl} (sender_name, sender_domain, " .
+ 		  'src, last_seen, first_seen) ' .
+ 		  'SELECT sender_name, sender_domain, src, last_seen, last_seen ' .
+-		  'FROM temp');
+-	$self->drop_table('temp');
++		  'FROM ' . $self->{sqlgrey}{db_table_temp});
++	$self->drop_table($self->{sqlgrey}{db_table_temp});
+     } else {
+-	$self->do("INSERT INTO $from_awl (sender_name, sender_domain, " .
++	$self->do("INSERT INTO $self->{sqlgrey}{db_table_from_awl} (sender_name, sender_domain, " .
+ 		  'src, last_seen, first_seen) ' .
+ 		  'SELECT sender_name, sender_domain, src, last_seen, last_seen ' .
+-		  "FROM $from_awl" . 'old');
+-	$self->drop_table($from_awl . 'old');
++		  "FROM $self->{sqlgrey}{db_table_from_awl}" . 'old');
++	$self->drop_table($self->{sqlgrey}{db_table_from_awl} . 'old');
+     }
+-    $self->mylog('dbaccess', 2, "$from_awl: adding indexes");
++    $self->mylog('dbaccess', 2, "$self->{sqlgrey}{db_table_from_awl}: adding indexes");
+     $self->create_from_awl_indexes();
+ 
+     # domain_awl
+-    $self->mylog('dbaccess', 2, "$domain_awl: making room for IPv6 in src");
++    $self->mylog('dbaccess', 2, "$self->{sqlgrey}{db_table_domain_awl}: making room for IPv6 in src");
+     if ($self->SQLite()) {
+-	$self->create_domain_awl_table('temp');
+-	$self->do('INSERT INTO temp (sender_domain, ' .
++	$self->create_domain_awl_table($self->{sqlgrey}{db_table_temp});
++	$self->do('INSERT INTO ' . $self->{sqlgrey}{db_table_temp} . ' (sender_domain, ' .
+ 		  'src, last_seen, first_seen) ' .
+ 		  'SELECT sender_domain, src, last_seen, first_seen ' .
+-		  "FROM $domain_awl");
+-	$self->drop_table($domain_awl);
++		  "FROM $self->{sqlgrey}{db_table_domain_awl}");
++	$self->drop_table($self->{sqlgrey}{db_table_domain_awl});
+     } else {
+-	$self->do("ALTER TABLE $domain_awl RENAME TO $domain_awl" . 'old');
++	$self->do("ALTER TABLE $self->{sqlgrey}{db_table_domain_awl} RENAME TO $self->{sqlgrey}{db_table_domain_awl}" . 'old');
+     }
+     if ($self->PostgreSQL()) { # we need to remove the pkey constraint
+-	$self->do("ALTER TABLE $domain_awl" . 'old DROP CONSTRAINT ' .
++	$self->do("ALTER TABLE $self->{sqlgrey}{db_table_domain_awl}" . 'old DROP CONSTRAINT ' .
+ 		  'domain_awl_pkey');
+     }
+     $self->create_domain_awl_table();
+     if ($self->SQLite()) {
+-	$self->do("INSERT INTO $domain_awl (sender_domain, " .
++	$self->do("INSERT INTO $self->{sqlgrey}{db_table_domain_awl} (sender_domain, " .
+ 		  'src, last_seen, first_seen) ' .
+ 		  'SELECT sender_domain, src, last_seen, first_seen ' .
+-		  'FROM temp');
+-	$self->drop_table('temp');
++		  'FROM ' . $self->{sqlgrey}{db_table_temp});
++	$self->drop_table($self->{sqlgrey}{db_table_temp});
+     } else {
+-	$self->do("INSERT INTO $domain_awl (sender_domain, src, " .
++	$self->do("INSERT INTO $self->{sqlgrey}{db_table_domain_awl} (sender_domain, src, " .
+ 		  'last_seen, first_seen) ' .
+ 		  'SELECT sender_domain, src, last_seen, first_seen ' .
+-		  "FROM $domain_awl" . 'old');
+-	$self->do("DROP TABLE $domain_awl" . 'old');
++		  "FROM $self->{sqlgrey}{db_table_domain_awl}" . 'old');
++	$self->do("DROP TABLE $self->{sqlgrey}{db_table_domain_awl}" . 'old');
+     }
+-    $self->mylog('dbaccess', 2, "$domain_awl: adding indexes");
++    $self->mylog('dbaccess', 2, "$self->{sqlgrey}{db_table_domain_awl}: adding indexes");
+     $self->create_domain_awl_indexes();
+ 
+     # Update our schema
+@@ -884,7 +883,7 @@
+     my $self = shift;
+     # allow optional table name
+     my $tablename = shift;
+-    $tablename = ! defined $tablename ? $from_awl : $tablename;
++    $tablename = ! defined $tablename ? $self->{sqlgrey}{db_table_from_awl} : $tablename;
+     $self->do("CREATE TABLE $tablename " .
+ 	      '(sender_name varchar(64) NOT NULL, ' .
+ 	      'sender_domain varchar(255) NOT NULL, ' .
+@@ -898,17 +897,17 @@
+ }
+ sub create_from_awl_indexes($) {
+     my $self = shift;
+-    $self->do("CREATE INDEX $from_awl" . '_lseen ' .
+-	     "ON $from_awl (last_seen)")
++    $self->do("CREATE INDEX $self->{sqlgrey}{db_table_from_awl}" . '_lseen ' .
++	     "ON $self->{sqlgrey}{db_table_from_awl} (last_seen)")
+ 	or $self->mydie('create_from_awl_table error',
+-			"couldn't create index on $from_awl (last_seen)");
++			"couldn't create index on $self->{sqlgrey}{db_table_from_awl} (last_seen)");
+ }
+ 
+ sub create_domain_awl_table {
+     my $self = shift;
+     # allow optional table name
+     my $tablename = shift;
+-    $tablename = ! defined $tablename ? $domain_awl : $tablename;
++    $tablename = ! defined $tablename ? $self->{sqlgrey}{db_table_domain_awl} : $tablename;
+     $self->do("CREATE TABLE $tablename " .
+ 	      '(sender_domain varchar(255) NOT NULL, ' .
+ 	      'src varchar(39) NOT NULL, ' .
+@@ -920,17 +919,17 @@
+ }
+ sub create_domain_awl_indexes($) {
+     my $self = shift;
+-    $self->do("CREATE INDEX $domain_awl" . '_lseen ' .
+-	     "ON $domain_awl (last_seen)")
++    $self->do("CREATE INDEX $self->{sqlgrey}{db_table_domain_awl}" . '_lseen ' .
++	     "ON $self->{sqlgrey}{db_table_domain_awl} (last_seen)")
+ 	or $self->mydie('create_domain_awl_table error',
+-			"couldn't create index on $domain_awl (last_seen)");
++			"couldn't create index on $self->{sqlgrey}{db_table_domain_awl} (last_seen)");
+ }
+ 
+ sub create_connect_table {
+     my $self = shift;
+     # allow optional table name
+     my $tablename = shift;
+-    $tablename = ! defined $tablename ? $connect : $tablename;
++    $tablename = ! defined $tablename ? $self->{sqlgrey}{db_table_connect} : $tablename;
+     # Note: no primary key, Mysql can't handle 500+ byte primary keys
+     # connect should not become big enough to make it a problem
+     $self->do("CREATE TABLE $tablename " .
+@@ -944,62 +943,62 @@
+ }
+ sub create_connect_indexes($) {
+     my $self = shift;
+-    $self->do("CREATE INDEX $connect" . '_idx ' .
+-	     "ON $connect (src, sender_domain, sender_name)")
++    $self->do("CREATE INDEX $self->{sqlgrey}{db_table_connect}" . '_idx ' .
++	     "ON $self->{sqlgrey}{db_table_connect} (src, sender_domain, sender_name)")
+ 	or $self->mydie('create_connect_table error',
+-			"couldn't create index on $connect (src, sender_domain, sender_name)");
+-    $self->do("CREATE INDEX $connect" . '_fseen ' .
+-	     "ON $connect (first_seen)")
++			"couldn't create index on $self->{sqlgrey}{db_table_connect} (src, sender_domain, sender_name)");
++    $self->do("CREATE INDEX $self->{sqlgrey}{db_table_connect}" . '_fseen ' .
++	     "ON $self->{sqlgrey}{db_table_connect} (first_seen)")
+ 	or $self->mydie('create_connect_table error',
+-			"couldn't create index on $connect (first_seen)");
++			"couldn't create index on $self->{sqlgrey}{db_table_connect} (first_seen)");
+ }
+ 
+ sub create_config_table($) {
+     my $self = shift;
+-    $self->do("CREATE TABLE $config " .
++    $self->do("CREATE TABLE $self->{sqlgrey}{db_table_config} " .
+ 	      '(parameter varchar(255) NOT NULL, ' .
+ 	      'value varchar(255), ' .
+ 	      'PRIMARY KEY (parameter));')
+         or $self->mydie('create_config_table',
+-			"Couldn't create table $config: $DBI::errstr");
++			"Couldn't create table $self->{sqlgrey}{db_table_config}: $DBI::errstr");
+     # we just created the table: this is the current version
+     $self->setconfig('version', $DB_VERSION);
+ }
+ 
+ sub create_optin_domain_table($) {
+     my $self = shift;
+-    $self->do("CREATE TABLE $optin_domain " .
++    $self->do("CREATE TABLE $self->{sqlgrey}{db_table_optin_domain} " .
+ 	      '(domain varchar(255) NOT NULL, ' .
+ 	      'PRIMARY KEY (domain));')
+ 	or $self->mydie('create_optin_domain_table',
+-			"Couldn't create table $optin_domain: $DBI::errstr");
++			"Couldn't create table $self->{sqlgrey}{db_table_optin_domain}: $DBI::errstr");
+ }
+ 
+ sub create_optin_email_table($) {
+     my $self = shift;
+-    $self->do("CREATE TABLE $optin_email " .
++    $self->do("CREATE TABLE $self->{sqlgrey}{db_table_optin_email} " .
+ 	      '(email varchar(255) NOT NULL, ' .
+ 	      'PRIMARY KEY (email));')
+ 	or $self->mydie('create_optin_email_table',
+-			"Couldn't create table $optin_email: $DBI::errstr");
++			"Couldn't create table $self->{sqlgrey}{db_table_optin_email}: $DBI::errstr");
+ }
+ 
+ sub create_optout_domain_table($) {
+     my $self = shift;
+-    $self->do("CREATE TABLE $optout_domain " .
++    $self->do("CREATE TABLE $self->{sqlgrey}{db_table_optout_domain} " .
+ 	      '(domain varchar(255) NOT NULL, ' .
+ 	      'PRIMARY KEY (domain));')
+ 	or $self->mydie('create_optout_domain_table',
+-			"Couldn't create table $optout_domain: $DBI::errstr");
++			"Couldn't create table $self->{sqlgrey}{db_table_optout_domain}: $DBI::errstr");
+ }
+ 
+ sub create_optout_email_table {
+     my $self = shift;
+-    $self->do("CREATE TABLE $optout_email " .
++    $self->do("CREATE TABLE $self->{sqlgrey}{db_table_optout_email} " .
+ 	      '(email varchar(255) NOT NULL, ' .
+ 	      'PRIMARY KEY (email));')
+ 	or $self->mydie('create_optout_email_table',
+-			"Couldn't create table $optout_email: $DBI::errstr");
++			"Couldn't create table $self->{sqlgrey}{db_table_optout_email}: $DBI::errstr");
+ }
+ 
+ ##########
+@@ -1217,7 +1216,7 @@
+     my ($self, $sender_name, $sender_domain, $host) = @_;
+ 
+     # last_seen less than $self->{sqlgrey}{awl_age} days ago
+-    my $sth = $self->prepare("SELECT 1 FROM $from_awl " .
++    my $sth = $self->prepare("SELECT 1 FROM $self->{sqlgrey}{db_table_from_awl} " .
+ 			     'WHERE sender_name = ? ' .
+ 			     'AND sender_domain = ? ' .
+ 			     'AND src = ? ' .
+@@ -1227,7 +1226,7 @@
+ 			    );
+     if (!defined $sth or !$sth->execute($sender_name, $sender_domain, $host)) {
+ 	$self->db_unavailable();
+-	$self->mylog('dbaccess', 0, "error: couldn't access $from_awl table: $DBI::errstr");
++	$self->mylog('dbaccess', 0, "error: couldn't access $self->{sqlgrey}{db_table_from_awl} table: $DBI::errstr");
+         return 1; # in doubt, accept
+     } else {
+ 	$self->db_available();
+@@ -1244,7 +1243,7 @@
+     my ($self, $sender_domain, $host) = @_;
+ 
+     # last_seen less than $self->{sqlgrey}{awl_age} days ago
+-    my $sth = $self->prepare("SELECT 1 FROM $domain_awl " .
++    my $sth = $self->prepare("SELECT 1 FROM $self->{sqlgrey}{db_table_domain_awl} " .
+ 			     'WHERE sender_domain = ? ' .
+ 			     'AND src = ? ' .
+ 			     'AND last_seen > ' .
+@@ -1253,7 +1252,7 @@
+ 			    );
+     if (!defined $sth or !$sth->execute($sender_domain, $host)) {
+ 	$self->db_unavailable();
+-	$self->mylog('dbaccess', 0, "error: couldn't access $domain_awl table: $DBI::errstr");
++	$self->mylog('dbaccess', 0, "error: couldn't access $self->{sqlgrey}{db_table_domain_awl} table: $DBI::errstr");
+         return 1; # in doubt, accept
+     } else {
+ 	$self->db_available();
+@@ -1272,13 +1271,13 @@
+     my ($self, $sender_name, $sender_domain, $host, $first_seen) = @_;
+ 
+     # delete old entries
+-    $self->do("DELETE FROM $from_awl " .
++    $self->do("DELETE FROM $self->{sqlgrey}{db_table_from_awl} " .
+ 	      'WHERE sender_name = ' . $self->quote($sender_name) .
+ 	      ' AND sender_domain = ' . $self->quote($sender_domain) .
+ 	      ' AND src = ' . $self->quote($host));
+ 
+     # create new entry
+-    $self->do("INSERT INTO $from_awl (sender_name, sender_domain, " .
++    $self->do("INSERT INTO $self->{sqlgrey}{db_table_from_awl} (sender_name, sender_domain, " .
+ 	      'src, first_seen, last_seen) VALUES(' .
+ 	      $self->quote($sender_name) . ',' .
+ 	      $self->quote($sender_domain) . ',' .
+@@ -1290,12 +1289,12 @@
+     my ($self, $sender_domain, $host, $first_seen) = @_;
+ 
+     # delete old entries
+-    $self->do("DELETE FROM $domain_awl " .
++    $self->do("DELETE FROM $self->{sqlgrey}{db_table_domain_awl} " .
+ 	      'WHERE sender_domain = ' . $self->quote($sender_domain) .
+ 	      ' AND src = ' . $self->quote($host));
+ 
+     # create new entry
+-    $self->do("INSERT INTO $domain_awl (sender_domain, src, " .
++    $self->do("INSERT INTO $self->{sqlgrey}{db_table_domain_awl} (sender_domain, src, " .
+ 	      'first_seen, last_seen) VALUES(' .
+ 	      $self->quote($sender_domain) . ',' .
+ 	      $self->quote($host) . ',' .
+@@ -1307,7 +1306,7 @@
+ sub update_from_awl($$$$) {
+     my ($self, $sender_name, $sender_domain, $host) = @_;
+ 
+-    $self->do("UPDATE $from_awl " .
++    $self->do("UPDATE $self->{sqlgrey}{db_table_from_awl} " .
+ 	      'SET last_seen = NOW(), first_seen = first_seen ' .
+ 	      'WHERE sender_name = ' . $self->quote($sender_name) .
+ 	      ' AND sender_domain = ' . $self->quote($sender_domain) .
+@@ -1317,7 +1316,7 @@
+ sub update_domain_awl($$$) {
+     my ($self, $sender_domain, $host) = @_;
+ 
+-    $self->do("UPDATE $domain_awl " .
++    $self->do("UPDATE $self->{sqlgrey}{db_table_domain_awl} " .
+ 	      'SET last_seen = NOW(), first_seen = first_seen ' .
+ 	      'WHERE sender_domain = ' . $self->quote($sender_domain) .
+ 	      ' AND src = ' . $self->quote($host));
+@@ -1327,11 +1326,11 @@
+ sub count_from_awl($$$) {
+     my ($self, $sender_domain, $host) = @_;
+ 
+-    my $sth = $self->prepare_cached("SELECT COUNT(*) FROM $from_awl " .
++    my $sth = $self->prepare_cached("SELECT COUNT(*) FROM $self->{sqlgrey}{db_table_from_awl} " .
+ 				    'WHERE sender_domain = ? AND src = ?');
+     if (!defined $sth or !$sth->execute($sender_domain, $host)) {
+ 	$self->db_unavailable();
+-	$self->mylog('dbaccess', 0, "error: couldn't access $from_awl table: $DBI::errstr");
++	$self->mylog('dbaccess', 0, "error: couldn't access $self->{sqlgrey}{db_table_from_awl} table: $DBI::errstr");
+         return 0; # do as if table is empty
+     } else {
+ 	$self->db_available();
+@@ -1350,11 +1349,11 @@
+ sub count_src_domain_awl($$) {
+     my ($self, $host) = @_;
+ 
+-    my $sth = $self->prepare_cached("SELECT COUNT(*) FROM $domain_awl " .
++    my $sth = $self->prepare_cached("SELECT COUNT(*) FROM $self->{sqlgrey}{db_table_domain_awl} " .
+ 				    'WHERE src = ?');
+     if (!defined $sth or !$sth->execute($host)) {
+ 	$self->db_unavailable();
+-	$self->mylog('dbaccess', 0, "error: couldn't access $domain_awl table: $DBI::errstr");
++	$self->mylog('dbaccess', 0, "error: couldn't access $self->{sqlgrey}{db_table_domain_awl} table: $DBI::errstr");
+         return 0; # do as if table is empty
+     } else {
+ 	$self->db_available();
+@@ -1373,11 +1372,11 @@
+ sub count_src_from_awl($$) {
+     my ($self, $host) = @_;
+ 
+-    my $sth = $self->prepare_cached("SELECT COUNT(*) FROM $from_awl " .
++    my $sth = $self->prepare_cached("SELECT COUNT(*) FROM $self->{sqlgrey}{db_table_from_awl} " .
+ 				    'WHERE src = ?');
+     if (!defined $sth or !$sth->execute($host)) {
+ 	$self->db_unavailable();
+-	$self->mylog('dbaccess', 0, "error: couldn't access $from_awl table: $DBI::errstr");
++	$self->mylog('dbaccess', 0, "error: couldn't access $self->{sqlgrey}{db_table_from_awl} table: $DBI::errstr");
+         return 0; # do as if table is empty
+     } else {
+ 	$self->db_available();
+@@ -1396,11 +1395,11 @@
+ sub count_src_connect($$) {
+     my ($self, $host) = @_;
+ 
+-    my $sth = $self->prepare_cached("SELECT COUNT(*) FROM $connect " .
++    my $sth = $self->prepare_cached("SELECT COUNT(*) FROM $self->{sqlgrey}{db_table_connect} " .
+ 				    'WHERE src = ?');
+     if (!defined $sth or !$sth->execute($host)) {
+ 	$self->db_unavailable();
+-	$self->mylog('dbaccess', 0, "error: couldn't access $connect table: $DBI::errstr");
++	$self->mylog('dbaccess', 0, "error: couldn't access $self->{sqlgrey}{db_table_connect} table: $DBI::errstr");
+         return 0; # do as if table is empty
+     } else {
+ 	$self->db_available();
+@@ -1420,7 +1419,7 @@
+ sub cleanup_from_awl($) {
+     my ($self) = @_;
+ 
+-    my $rows = $self->do("DELETE FROM $from_awl " .
++    my $rows = $self->do("DELETE FROM $self->{sqlgrey}{db_table_from_awl} " .
+                 	 'WHERE last_seen < ' .
+ 	                 $self->past_tstamp($self->{sqlgrey}{awl_age}, 'DAY')
+ 	                );
+@@ -1432,7 +1431,7 @@
+ sub cleanup_domain_awl($) {
+     my ($self) = @_;
+ 
+-    my $rows = $self->do("DELETE FROM $domain_awl " .
++    my $rows = $self->do("DELETE FROM $self->{sqlgrey}{db_table_domain_awl} " .
+ 	                 'WHERE last_seen < ' .
+ 	                 $self->past_tstamp($self->{sqlgrey}{awl_age}, 'DAY')
+ 	                );
+@@ -1443,14 +1442,14 @@
+ 
+ sub delete_domain_from_mail_awl($$$) {
+     my ($self, $domain, $host) = @_;
+-    $self->do("DELETE FROM $from_awl " .
++    $self->do("DELETE FROM $self->{sqlgrey}{db_table_from_awl} " .
+ 	      'WHERE sender_domain = ' . $self->quote($domain) .
+ 	      ' AND src = ' . $self->quote($host));
+ }
+ 
+ sub delete_domain_from_connect($$$) {
+     my ($self, $domain, $host) = @_;
+-    $self->do("DELETE FROM $connect " .
++    $self->do("DELETE FROM $self->{sqlgrey}{db_table_connect} " .
+ 	      'WHERE sender_domain = ' . $self->quote($domain) .
+ 	      ' AND src = ' . $self->quote($host));
+ }
+@@ -1466,12 +1465,12 @@
+ 
+ sub get_first_seen_in_from_awl($$$) {
+     my ($self, $domain, $host) = @_;
+-    my $sth = $self->prepare_cached("SELECT MIN(first_seen) FROM $from_awl " .
++    my $sth = $self->prepare_cached("SELECT MIN(first_seen) FROM $self->{sqlgrey}{db_table_from_awl} " .
+ 				    'WHERE sender_domain = ? AND src = ?');
+ 
+     if (!defined $sth or !$sth->execute($domain, $host)) {
+ 	$self->db_unavailable();
+-	$self->mylog('dbaccess', 0, "error: couldn't access $from_awl table: $DBI::errstr");
++	$self->mylog('dbaccess', 0, "error: couldn't access $self->{sqlgrey}{db_table_from_awl} table: $DBI::errstr");
+         return 0; # do as if table is empty
+     } else {
+ 	$self->db_available();
+@@ -1495,7 +1494,7 @@
+ 
+     # last_seen less than $self->{sqlgrey}{max_connect_age} hours ago
+     # but more than $self->{sqlgrey}{reconnect_delay} minutes ago
+-    my $sth = $self->prepare("SELECT 1 FROM $connect " .
++    my $sth = $self->prepare("SELECT 1 FROM $self->{sqlgrey}{db_table_connect} " .
+ 			     'WHERE sender_name = ? AND sender_domain = ? ' .
+ 			     'AND src = ? AND rcpt = ? ' .
+ 			     'AND first_seen BETWEEN ' .
+@@ -1507,7 +1506,7 @@
+ 			    );
+     if (!defined $sth or !$sth->execute($sender_name, $sender_domain, $addr, $rcpt)) {
+ 	$self->db_unavailable();
+-        $self->mylog('dbaccess', 0, "error: couldn't access $connect table: $DBI::errstr");
++        $self->mylog('dbaccess', 0, "error: couldn't access $self->{sqlgrey}{db_table_connect} table: $DBI::errstr");
+         return 1; # in doubt, accept
+     } else {
+ 	$self->db_available();
+@@ -1525,7 +1524,7 @@
+     my ($self, $sender_name, $sender_domain, $addr, $rcpt) = @_;
+ 
+     # last_seen less than $self->{sqlgrey}{reconnect_delay} minutes ago
+-    my $sth = $self->prepare("SELECT 1 FROM $connect WHERE sender_name = ? " .
++    my $sth = $self->prepare("SELECT 1 FROM $self->{sqlgrey}{db_table_connect} WHERE sender_name = ? " .
+ 			     'AND sender_domain = ? ' .
+ 			     'AND src = ? AND rcpt = ? ' .
+ 			     'AND first_seen >= ' .
+@@ -1534,7 +1533,7 @@
+ 			     );
+     if (!defined $sth or !$sth->execute($sender_name, $sender_domain, $addr, $rcpt)) {
+ 	$self->db_unavailable();
+-        $self->mylog('dbaccess', 0, "error: Couldn't access $connect table: $DBI::errstr");
++        $self->mylog('dbaccess', 0, "error: Couldn't access $self->{sqlgrey}{db_table_connect} table: $DBI::errstr");
+         return 0; # in doubt, accept
+     } else {
+ 	$self->db_available();
+@@ -1552,7 +1551,7 @@
+     my ($self, $sender_name, $sender_domain, $addr, $rcpt) = @_;
+ 
+     # create new entry
+-    $self->do("INSERT INTO $connect (sender_name, sender_domain, " .
++    $self->do("INSERT INTO $self->{sqlgrey}{db_table_connect} (sender_name, sender_domain, " .
+ 	      'src, rcpt, first_seen) ' .
+ 	      'VALUES(' .
+ 	      $self->quote($sender_name) . ',' .
+@@ -1569,9 +1568,9 @@
+     if ($self->MySQL()) {
+         $query = 'SELECT first_seen, SEC_TO_TIME(UNIX_TIMESTAMP(NOW())-' .
+ 	    'UNIX_TIMESTAMP(first_seen)) ' .
+-		"FROM $connect ";
++		"FROM $self->{sqlgrey}{db_table_connect} ";
+     } else {
+-        $query = "SELECT first_seen, now() - first_seen FROM $connect ";
++        $query = "SELECT first_seen, now() - first_seen FROM $self->{sqlgrey}{db_table_connect} ";
+     }
+     $query .= 'WHERE sender_name = ? AND sender_domain = ? ' .
+ 	      'AND src = ? AND rcpt = ?';
+@@ -1600,7 +1599,7 @@
+ 
+     $deverp_sender_name =~ s/#/%/g;
+ 
+-    $self->do("DELETE FROM $connect " .
++    $self->do("DELETE FROM $self->{sqlgrey}{db_table_connect} " .
+ 	      'WHERE src = ' . $self->quote($addr) .
+ 	      ' AND sender_domain = ' . $self->quote($sender_domain) .
+ 	      ' AND sender_name LIKE ' . $self->quote($deverp_sender_name) );
+@@ -1615,7 +1614,7 @@
+         # Print probable SPAM:
+         my $sth = $self->prepare('SELECT sender_name, sender_domain, src, ' .
+ 				 'rcpt, first_seen ' .
+-				 "FROM $connect " .
++				 "FROM $self->{sqlgrey}{db_table_connect} " .
+ 				 'WHERE first_seen < ' .
+ 				 $tstamp);
+         if (defined $sth and $sth->execute()) {
+@@ -1632,7 +1631,7 @@
+ 			 "error: couldn't list detected spam attempts: $DBI::errstr");
+         }
+     }
+-    my $rows = $self->do("DELETE FROM $connect " .
++    my $rows = $self->do("DELETE FROM $self->{sqlgrey}{db_table_connect} " .
+ 	                 'WHERE first_seen < ' .
+ 	                 $tstamp
+ 	                );
+@@ -2011,21 +2010,21 @@
+ sub is_in_optin_domain($$) {
+     my ($self, $domain) = @_;
+ 
+-    my $sth = $self->prepare_cached("SELECT 1 FROM $optin_domain " .
++    my $sth = $self->prepare_cached("SELECT 1 FROM $self->{sqlgrey}{db_table_optin_domain} " .
+ 				    'WHERE domain = ?');
+     if (!defined $sth or !$sth->execute($domain)) {
+ 	$self->db_unavailable();
+-	$self->mylog('dbaccess', 0, "error: couldn't access $optin_domain table: $DBI::errstr");
++	$self->mylog('dbaccess', 0, "error: couldn't access $self->{sqlgrey}{db_table_optin_domain} table: $DBI::errstr");
+         return 0; # in doubt, no greylisting
+     } else {
+ 	$self->db_available();
+     }
+     my $result = $sth->fetchall_arrayref();
+     if ($#$result != 0) {
+-	$self->mylog('optin', 4, "$domain not in $optin_domain");
++	$self->mylog('optin', 4, "$domain not in $self->{sqlgrey}{db_table_optin_domain}");
+ 	return 0; # not a single entry
+     } else {
+-	$self->mylog('optin', 4, "$domain in $optin_domain");
++	$self->mylog('optin', 4, "$domain in $self->{sqlgrey}{db_table_optin_domain}");
+ 	return 1; # one single entry (no multiple entries by design)
+     }
+ }
+@@ -2033,21 +2032,21 @@
+ sub is_in_optin_email($$) {
+     my ($self, $email) = @_;
+ 
+-    my $sth = $self->prepare_cached("SELECT 1 FROM $optin_email " .
++    my $sth = $self->prepare_cached("SELECT 1 FROM $self->{sqlgrey}{db_table_optin_email} " .
+ 				    'WHERE email = ?');
+     if (!defined $sth or !$sth->execute($email)) {
+ 	$self->db_unavailable();
+-	$self->mylog('dbaccess', 0, "error: couldn't access $optin_email table: $DBI::errstr");
++	$self->mylog('dbaccess', 0, "error: couldn't access $self->{sqlgrey}{db_table_optin_email} table: $DBI::errstr");
+         return 0; # in doubt, no greylisting
+     } else {
+ 	$self->db_available();
+     }
+     my $result = $sth->fetchall_arrayref();
+     if ($#$result != 0) {
+-	$self->mylog('optin', 4, "$email not in $optin_email");
++	$self->mylog('optin', 4, "$email not in $self->{sqlgrey}{db_table_optin_email}");
+ 	return 0; # not a single entry
+     } else {
+-	$self->mylog('optin', 4, "$email in $optin_email");
++	$self->mylog('optin', 4, "$email in $self->{sqlgrey}{db_table_optin_email}");
+ 	return 1; # one single entry (no multiple entries by design)
+     }
+ }
+@@ -2055,21 +2054,21 @@
+ sub is_in_optout_domain($$) {
+     my ($self, $domain) = @_;
+ 
+-    my $sth = $self->prepare_cached("SELECT 1 FROM $optout_domain " .
++    my $sth = $self->prepare_cached("SELECT 1 FROM $self->{sqlgrey}{db_table_optout_domain} " .
+ 				    'WHERE domain = ?');
+     if (!defined $sth or !$sth->execute($domain)) {
+ 	$self->db_unavailable();
+-	$self->mylog('dbaccess', 0, "error: couldn't access $optout_domain table: $DBI::errstr");
++	$self->mylog('dbaccess', 0, "error: couldn't access $self->{sqlgrey}{db_table_optout_domain} table: $DBI::errstr");
+         return 1; # in doubt, no greylisting
+     } else {
+ 	$self->db_available();
+     }
+     my $result = $sth->fetchall_arrayref();
+     if ($#$result != 0) {
+-	$self->mylog('optin', 4, "$domain not in $optout_domain");
++	$self->mylog('optin', 4, "$domain not in $self->{sqlgrey}{db_table_optout_domain}");
+ 	return 0; # not a single entry
+     } else {
+-	$self->mylog('optin', 4, "$domain in $optout_domain");
++	$self->mylog('optin', 4, "$domain in $self->{sqlgrey}{db_table_optout_domain}");
+ 	return 1; # one single entry (no multiple entries by design)
+     }
+ }
+@@ -2077,21 +2076,21 @@
+ sub is_in_optout_email($$) {
+     my ($self, $email) = @_;
+ 
+-    my $sth = $self->prepare_cached("SELECT 1 FROM $optout_email " .
++    my $sth = $self->prepare_cached("SELECT 1 FROM $self->{sqlgrey}{db_table_optout_email} " .
+ 				    'WHERE email = ?');
+     if (!defined $sth or !$sth->execute($email)) {
+ 	$self->db_unavailable();
+-	$self->mylog('dbaccess', 0, "error: couldn't access $optin_email table: $DBI::errstr");
++	$self->mylog('dbaccess', 0, "error: couldn't access $self->{sqlgrey}{db_table_optin_email} table: $DBI::errstr");
+         return 1; # in doubt, no greylisting
+     } else {
+ 	$self->db_available();
+     }
+     my $result = $sth->fetchall_arrayref();
+     if ($#$result != 0) {
+-	$self->mylog('optin', 4, "$email not in $optout_email");
++	$self->mylog('optin', 4, "$email not in $self->{sqlgrey}{db_table_optout_email}");
+ 	return 0; # not a single entry
+     } else {
+-	$self->mylog('optin', 4, "$email in $optout_email");
++	$self->mylog('optin', 4, "$email in $self->{sqlgrey}{db_table_optout_email}");
+ 	return 1; # one single entry (no multiple entries by design)
+     }
+ }
+@@ -2642,6 +2641,15 @@
+ 	    db_user         => $dflt{db_user},
+             db_pass         => $dflt{db_pass},
+ 	    db_available    => 1, # used to trigger e-mails
++            db_table_temp          => $dflt{db_table_temp},
++            db_table_connect       => $dflt{db_table_connect},
++            db_table_from_awl      => $dflt{db_table_from_awl},
++            db_table_domain_awl    => $dflt{db_table_domain_awl},
++            db_table_optin_domain  => $dflt{db_table_optin_domain},
++            db_table_optin_email   => $dflt{db_table_optin_email},
++            db_table_optout_domain => $dflt{db_table_optout_domain},
++            db_table_optout_email  => $dflt{db_table_optout_email},
++            db_table_config        => $dflt{db_table_config},
+ 	    clean_method    => $dflt{clean_method},
+ 	    prepend         => $dflt{prepend},
+ 	    greymethod      => $dflt{greymethod},
Index: /trunk/dports/mail/sqlgrey/files/patch-tester.pl.diff
===================================================================
--- /trunk/dports/mail/sqlgrey/files/patch-tester.pl.diff	(revision 98804)
+++ /trunk/dports/mail/sqlgrey/files/patch-tester.pl.diff	(revision 98805)
@@ -1,7 +1,7 @@
---- tester.pl.orig	2010-05-17 11:57:50.000000000 -0700
-+++ tester.pl	2010-05-17 11:58:00.000000000 -0700
+--- a/tester.pl	2012-08-24 18:05:39.000000000 -0700
++++ b/tester.pl	2012-08-24 18:06:30.000000000 -0700
 @@ -1,4 +1,4 @@
 -#!/usr/bin/perl
-+#!@@PREFIX@@/bin/perl
++#!@PREFIX@/bin/perl
  
  # Tester for SQLgrey
