Various debian additions to the original postgrey, to adapt the package to
debian user/group and other things, see the patch for more comments, the patch
was written by Adrian von Bidder

Index: postgrey/README
===================================================================
--- postgrey.orig/README
+++ postgrey/README
@@ -20,7 +20,7 @@ Documentation
 
 See POD documentation in postgrey. Execute:
 
-  perldoc postgrey
+  man postgrey
 
 See also Postgrey's homepage:
 
Index: postgrey/README.exim
===================================================================
--- postgrey.orig/README.exim
+++ postgrey/README.exim
@@ -12,7 +12,7 @@ able to talk to the Postgrey daemon, whi
 in Exim's config file:
 
  defer log_message = greylisted host $sender_host_address
-       set acl_m0  = request=smtpd_access_policy\nprotocol_state=RCPT\nprotocol_name=${uc:$received_protocol}\nhelo_name=$sender_helo_name\nclient_address=$sender_host_address\nclient_name=$sender_host_name\nsender=$sender_address\nrecipient=$local_part@$domain\n\n
+       set acl_m0  = request=smtpd_access_policy\nprotocol_state=RCPT\nprotocol_name=${uc:$received_protocol}\nhelo_name=$sender_helo_name\nclient_address=$sender_host_address\nclient_name=$sender_host_name\nsender=$sender_address\nrecipient=$local_part@$domain\ninstance=$sender_host_address/$sender_address/$local_part@$domain\n\n
        set acl_m0  = ${sg{${readsocket{/var/run/postgrey}{$acl_m0}{5s}{}{action=DUNNO}}}{action=}{}}
        message     = ${sg{$acl_m0}{^\\w+\\s*}{}}
        condition   = ${if eq{${uc:${substr{0}{5}{$acl_m0}}}}{DEFER}{true}{false}}
Index: postgrey/contrib/postgrey_clients_dump
===================================================================
--- /dev/null
+++ postgrey/contrib/postgrey_clients_dump
@@ -0,0 +1,54 @@
+#!/usr/bin/perl -w
+
+# written by David Schweikert and adapted to Debian by Adrian von Bidder
+# this script is in the public domain
+#
+# This script will output all clients that were automatically whitelisted
+# by postgrey's --auto-whitelist-clients option. The default number of
+# mails required (5) is hardcoded below!
+
+use BerkeleyDB;
+use Socket;
+
+my $dbdir = '/var/lib/postgrey';
+
+sub resolv($) {
+    my $host = shift;
+    my $iaddr = inet_aton($host);
+    return gethostbyaddr($iaddr, AF_INET) || $host;
+}
+
+sub dbopen($)
+{
+    my ($dbdir) = @_;
+    my %db;
+
+    my $dbenv = BerkeleyDB::Env->new(
+	-Home     => $dbdir,
+	-Flags    => DB_INIT_TXN|DB_INIT_MPOOL|DB_INIT_LOG,
+    ) or die "ERROR: can't open DB environment: $!\n";
+
+    tie(%db, 'BerkeleyDB::Btree',
+	-Filename => "postgrey_clients.db",
+	-Flags    => DB_RDONLY,
+	-Env      => $dbenv,
+    ) or die "ERROR: can't open database $dbdir/postgrey_clients.db: $!\n";
+
+    return \%db;
+}
+
+sub main()
+{
+    # go through the database
+    my $db = dbopen($dbdir);
+    while (my ($key, $value) = each %$db) {
+	my ($c,$l) = split(/,/,$value);
+	$c >= 5 or next;
+	my $host = resolv($key);
+	print "$host ($c)\n";
+    }
+}
+
+main;
+
+# vim: sw=4
Index: postgrey/contrib/postgreyreport
===================================================================
--- postgrey.orig/contrib/postgreyreport
+++ postgrey/contrib/postgreyreport
@@ -24,7 +24,7 @@ select((select(STDOUT), $| = 1)[0]); 	#
 # default options, override via command line
 my %opt = ( 	
 	user 			=> 'postgrey',
-	dbdir 			=> '/var/spool/postfix/postgrey',
+	dbdir 			=> '/var/lib/postgrey',
 	delay			=> 300,
 	return_string		=> 'Greylisted',	# match on this string
 
@@ -594,7 +594,7 @@ B<postgreyreport> [I<options>...]
      --version		      display version and exit
 
      --user=USER              run as USER (default: postgrey)
-     --dbdir=PATH             find db files in PATH (default: /var/spool/postfix/postgrey)
+     --dbdir=PATH             find db files in PATH (default: /var/lib/postgrey)
      --delay=N                report triplets that did not try again after N seconds (default: 300)
      --greylist-text=TXT      text to match on for greylist maillog lines
 
Index: postgrey/postgrey
===================================================================
--- postgrey.orig/postgrey
+++ postgrey/postgrey
@@ -23,8 +23,8 @@ use vars qw(@ISA);
 @ISA = qw(Net::Server::Multiplex);
 
 my $VERSION = '1.35';
-my $DEFAULT_DBDIR = '/var/spool/postfix/postgrey';
-my $CONFIG_DIR = '/etc/postfix';
+my $DEFAULT_DBDIR = '/var/lib/postgrey';
+my $CONFIG_DIR = '/etc/postgrey';
 
 sub cidr_parse($)
 {
@@ -596,7 +596,7 @@ sub main()
             port             => [ $opt{inet} ? $opt{inet} : $opt{unix}."|unix" ],
             proto            => $opt{inet} ? 'tcp' : 'unix',
             user             => $opt{user} || 'postgrey',
-            group            => $opt{group} || 'nogroup',
+            group            => $opt{group} || 'postgrey',
             dbdir            => $opt{dbdir} || $DEFAULT_DBDIR,
             setsid           => $opt{daemonize} ? 1 : undef,
             pid_file         => $opt{daemonize} ? $opt{pidfile} : undef,
@@ -620,10 +620,11 @@ sub main()
             greylist_action  => $opt{'greylist-action'} || 'DEFER_IF_PERMIT',
             greylist_text    => $opt{'greylist-text'} || 'Greylisted, see http://postgrey.schweikert.ch/help/%r.html',
             whitelist_clients_files    => $opt{'whitelist-clients'} ||
-                [ "$CONFIG_DIR/postgrey_whitelist_clients" ,
-                  "$CONFIG_DIR/postgrey_whitelist_clients.local" ],
+                [ "$CONFIG_DIR/whitelist_clients" ,
+                  "$CONFIG_DIR/whitelist_clients.local" ],
             whitelist_recipients_files => $opt{'whitelist-recipients'} ||
-                [ "$CONFIG_DIR/postgrey_whitelist_recipients" ],
+                [ "$CONFIG_DIR/whitelist_recipients" ,
+                  "$CONFIG_DIR/whitelist_recipients.local" ],
             privacy => defined $opt{'privacy'},
             hostname => defined $opt{hostname} ? $opt{hostname} : hostname,
             exim => defined $opt{'exim'},
@@ -805,8 +806,8 @@ B<postgrey> [I<options>...]
  -d, --daemonize         run in the background
      --pidfile=PATH      put daemon pid into this file
      --user=USER         run as USER (default: postgrey)
-     --group=GROUP       run as group GROUP (default: nogroup)
-     --dbdir=PATH        put db files in PATH (default: /var/spool/postfix/postgrey)
+     --group=GROUP       run as group GROUP (default: postgrey)
+     --dbdir=PATH        put db files in PATH (default: /var/lib/postgrey)
      --delay=N           greylist for N seconds (default: 300)
      --max-age=N         delete entries older than N days since the last time
                          that they have been seen (default: 35)
@@ -820,8 +821,8 @@ B<postgrey> [I<options>...]
      --privacy           store data using one-way hash functions
      --hostname=NAME     set the hostname (default: `hostname`)
      --exim              don't reuse a socket for more than one query (exim compatible)
-     --whitelist-clients=FILE     default: /etc/postfix/postgrey_whitelist_clients
-     --whitelist-recipients=FILE  default: /etc/postfix/postgrey_whitelist_recipients
+     --whitelist-clients=FILE     default: /etc/postgrey/whitelist_clients
+     --whitelist-recipients=FILE  default: /etc/postgrey/whitelist_recipients
      --auto-whitelist-clients=N   whitelist host after first successful delivery
                                   N is the minimal count of mails before a client is 
                                   whitelisted (turned on by default with value 5)
@@ -831,8 +832,9 @@ B<postgrey> [I<options>...]
                                   default: X-Greylist: delayed <seconds> seconds by postgrey-<version> at <server>; <date>
 
  Note that the --whitelist-x options can be specified multiple times,
- and that per default /etc/postfix/postgrey_whitelist_clients.local is
- also read, so that you can put there local entries.
+ and that per default /etc/postgrey/whitelist_clients.local and
+ /etc/postgrey/whitelist_recipients.local are also read, so that you can put
+ there local entries.
 
 =head1 DESCRIPTION
 
@@ -858,7 +860,7 @@ doing lookups in the database.
 =item *
 
 Create a C<postgrey> user and the directory where to put the database I<dbdir>
-(default: C</var/spool/postfix/postgrey>)
+(default: C</var/lib/postgrey>)
 
 =item *
 
@@ -881,12 +883,12 @@ Put something like this in /etc/main.cf:
 
 =item *
 
-Install the provided postgrey_whitelist_clients and
-postgrey_whitelist_recipients in /etc/postfix.
+Install the provided whitelist_clients and whitelist_recipients in
+/etc/postgrey.
 
 =item *
 
-Put in /etc/postfix/postgrey_whitelist_recipients users that do not want
+Put in /etc/postgrey/whitelist_recipients users that do not want
 greylisting.
 
 =back
@@ -897,9 +899,10 @@ Whitelists allow you to specify client a
 which no greylisting should be done. Per default postgrey will read the
 following files:
 
- /etc/postfix/postgrey_whitelist_clients
- /etc/postfix/postgrey_whitelist_clients.local
- /etc/postfix/postgrey_whitelist_recipients
+ /etc/postgrey/whitelist_clients
+ /etc/postgrey/whitelist_clients.local
+ /etc/postgrey/whitelist_recipients
+ /etc/postgrey/whitelist_recipients.local
 
 You can specify alternative paths with the --whitelist-x options.
 
Index: postgrey/postgrey_whitelist_recipients
===================================================================
--- postgrey.orig/postgrey_whitelist_recipients
+++ postgrey/postgrey_whitelist_recipients
@@ -1,6 +1,6 @@
 # postgrey whitelist for mail recipients
 # --------------------------------------
-# put this file in /etc/postfix or specify its path
+# put this file in /etc/postgrey or specify its path
 # with --whitelist-recipients=xxx
 
 postmaster@
Index: postgrey/postgrey_whitelist_clients
===================================================================
--- postgrey.orig/postgrey_whitelist_clients
+++ postgrey/postgrey_whitelist_clients
@@ -1,10 +1,17 @@
 # postgrey whitelist for mail client hostnames
 # --------------------------------------------
-# put this file in /etc/postfix or specify its path
+# put this file in /etc/postgrey or specify its path
 # with --whitelist-clients=xxx
 #
 # postgrey version: 1.35, build date: 2014-06-11
 
+# Debian-specific additions
+# I *know* they run real mail queues, so greylisting only creates
+# bigger load for them.
+debconf.org
+debian.org
+spi-inc.org
+
 # greylisting.org: Southwest Airlines (unique sender, no retry)
 southwest.com
 # greylisting.org: isp.belgacom.be (wierd retry pattern)
