SOURCES: postgrey_clients_dump (NEW) - show "learned" clients from...
undefine
undefine at pld-linux.org
Fri Jan 12 01:26:46 CET 2007
Author: undefine Date: Fri Jan 12 00:26:46 2007 GMT
Module: SOURCES Tag: HEAD
---- Log message:
- show "learned" clients from postgrey
- initital from debian
- adapted by Michal 'lipek' Lipka <lipek at lipek.pl>
---- Files affected:
SOURCES:
postgrey_clients_dump (NONE -> 1.1) (NEW)
---- Diffs:
================================================================
Index: SOURCES/postgrey_clients_dump
diff -u /dev/null SOURCES/postgrey_clients_dump:1.1
--- /dev/null Fri Jan 12 01:26:46 2007
+++ SOURCES/postgrey_clients_dump Fri Jan 12 01:26:40 2007
@@ -0,0 +1,57 @@
+#!/usr/bin/perl -w
+
+# written by David Schweikert and adapted to Debian by Adrian von Bidder
+# adapted to PLD Linux Distribution Michał Lipka
+# this script is in the public domain
+#
+# This script will output all clients that were automatically whitelisted
+# by postgrey's --auto-whitelist-clients option.
+# Set the default number of mails your to fit your needs (generally it
+# should be the same as N i --auto-whitelist-clients=N)
+
+use BerkeleyDB;
+use Socket;
+
+my $dbdir = '/var/spool/postfix/postgrey/';
+my $mails = 5;
+
+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 >= $mails or next;
+ my $host = resolv($key);
+ print "$host [$key] ($c)\n";
+ }
+}
+
+main;
+
+# vim: sw=4
================================================================
More information about the pld-cvs-commit
mailing list