trunk/postfix-policyd-spf-perl

* use version;
* Bumped version number to 1.08.1.
* Purely cosmetic code clean-up.
* Added svn properties:
  svn:mime-type = text/x-perl
  svn:keywords  = "Author Date Id Rev URL"
  svn:eol-style = native

trunk/README
* Bumped version number to 1.08.1.
* Added Scott Kitterman to copyright statement.
* Updated website URL.

trunk/INSTALL
* Added version Perl module to list of run-time requirements.

trunk/INSTALL
trunk/LICENSE
* Added svn properties:
  svn:mime-type = text/plain
  svn:keywords  = "Author Date Id Rev URL"
  svn:eol-style = native

trunk/CHANGES
trunk/debian/changelog
* Described changes for 1.08.1 release.

trunk/debian/control
* New maintainer: Scott Kitterman <scott@kitterman.com>
* Priority: extra (was: optional)
* Removed Build-Depends-Indep: perl, as there really is no need for it.
* Depends: libversion-perl

trunk/debian/copyright
* Updated for 1.08.1 release.
This commit is contained in:
Julian Mehnle 2007-01-10 20:00:57 +00:00
commit 01e939ac3d
7 changed files with 130 additions and 88 deletions

16
CHANGES
View file

@ -4,6 +4,22 @@
# ! = Changed something significant, or removed a feature
# * = Fixed a bug, or made a minor improvement
--- 1.08.1 (2007-01-10 21:00)
postfix-policyd-spf-perl:
* Minor and purely cosmetic code clean-up.
Miscellaneous:
* Updated README file with new website URL and copyright.
* Added LICENSE file as an explicit copy of the GPLv2.
Debian:
* New maintainer: Scott Kitterman <scott@kitterman.com>
* Priority: extra (was: optional)
* Removed Build-Depends-Indep: perl, as there really is no need for it.
* Depends: libversion-perl
* Updated debian/copyright.
--- 1.08 (2006-06-17 20:00)
* Added Debian package control files.

View file

@ -5,6 +5,7 @@ The following Perl version and packages are required for running
postfix-policyd-spf-perl:
Perl 5.6
version
Mail::SPF::Query
Installing
@ -30,5 +31,5 @@ Installing
4. Restart Postfix.
# $Id: README 167 2005-01-17 18:26:45Z julian $
# $Id$
# vim:tw=79

7
README
View file

@ -1,8 +1,9 @@
postfix-policyd-spf-perl 1.08
postfix-policyd-spf-perl 1.08.1
A Postfix SMTPd policy server for SPF checking
(C) 2003-2004 Meng Weng Wong <mengwong@pobox.com>
(C) 2007 Scott Kitterman <scott@kitterman.com>
2003-2004 Meng Weng Wong <mengwong@pobox.com>
Contributions by various members of the SPF project
<http://new.openspf.org/Implementations>
<http://www.openspf.org/Software#postfix-policyd-spf-perl>
==============================================================================
postfix-policyd-spf-perl is a Postfix SMTPd policy daemon for SPF checking.

18
debian/changelog vendored
View file

@ -1,3 +1,21 @@
postfix-policyd-spf-perl (1.08.1) unstable; urgency=low
Debian:
* New maintainer: Scott Kitterman <scott@kitterman.com>
* Priority: extra (was: optional)
* Removed Build-Depends-Indep: perl, as there really is no need for it.
* Depends: libversion-perl
* Updated debian/copyright.
postfix-policyd-spf-perl:
* Minor and purely cosmetic code clean-up.
Miscellaneous:
* Updated README file with new website URL and copyright.
* Added LICENSE file as an explicit copy of the GPLv2.
-- Scott Kitterman <scott@kitterman.com> Wed, 10 Jan 2007 21:00:00 +0000
postfix-policyd-spf-perl (1.08) unstable; urgency=low
* Initial release as a Debian package.

7
debian/control vendored
View file

@ -1,14 +1,13 @@
Source: postfix-policyd-spf-perl
Section: mail
Priority: optional
Maintainer: Julian Mehnle <julian@mehnle.net>
Priority: extra
Maintainer: Scott Kitterman <scott@kitterman.com>
Build-Depends: debhelper (>= 5)
Build-Depends-Indep: perl (>= 5.6)
Standards-Version: 3.7.2
Package: postfix-policyd-spf-perl
Architecture: all
Depends: libmail-spf-query-perl
Depends: libversion-perl, libmail-spf-query-perl
Recommends: postfix
Description: pure-Perl Postfix policy daemon for SPF checking
postfix-policyd-spf-perl is a Postfix SMTPd policy daemon for SPF checking.

9
debian/copyright vendored
View file

@ -1,13 +1,14 @@
This is the Debian package for postfix-policyd-spf-perl, which is available
from <http://new.openspf.org/Implementations>.
from <http://www.openspf.org/Software#postfix-policyd-spf-perl>.
(C) 2003-2004 Meng Weng Wong <mengwong@pobox.com>
(C) 2007 Scott Kitterman <scott@kitterman.com>
2003-2004 Meng Weng Wong <mengwong@pobox.com>
Contributions by various members of the SPF project
Julian Mehnle is the maintainer of the Debian package.
Scott Kitterman is the maintainer of the Debian package.
This is free software; you can redistribute it and/or modify it under the terms
of the GNU General Public License (version 2 or later).
On Debian systems, the complete text of the GPL v2 can be found here:
/usr/share/common-licenses/GPL-2
/usr/share/common-licenses/GPL-2

View file

@ -3,9 +3,9 @@
# postfix-policyd-spf-perl
# http://www.openspf.org/source/software/postfix-policyd-spf-perl/
# version 1.08
# $Id: postfix-policyd-spf 147 2006-03-14 21:51:58Z julian $
# $Id$
our $VERSION = '1.08';
use version; our $VERSION = qv('1.08.1');
use strict;
@ -44,10 +44,10 @@ my $syslog_ident = "postfix/policy-spf";
# Log an error and abort.
#
sub fatal_exit {
syslog(err => "fatal_exit: @_");
syslog(warning => "fatal_exit: @_");
syslog(info => "fatal_exit: @_");
die "fatal: @_";
syslog(err => "fatal_exit: @_");
syslog(warning => "fatal_exit: @_");
syslog(info => "fatal_exit: @_");
die "fatal: @_";
}
#
@ -71,92 +71,98 @@ openlog $syslog_ident, $syslog_options, $syslog_facility;
#
my %attr;
while (<STDIN>) {
chomp;
if (/=/) { my ($k, $v) = split (/=/, $_, 2); $attr{$k} = $v; next }
elsif (length) { syslog(warning => sprintf("warning: ignoring garbage: %.100s", $_)); next; }
if ($VERBOSE) {
for (sort keys %attr) {
syslog(debug => "Attribute: %s=%s", $_, $attr{$_});
chomp;
if (/=/) { my ($k, $v) = split (/=/, $_, 2); $attr{$k} = $v; next }
elsif (length) { syslog(warning => sprintf("warning: ignoring garbage: %.100s", $_)); next; }
if ($VERBOSE) {
for (sort keys %attr) {
syslog(debug => "Attribute: %s=%s", $_, $attr{$_});
}
}
}
fatal_exit ("unrecognized request type: '$attr{request}'") unless $attr{request} eq "smtpd_access_policy";
my $action = $DEFAULT_RESPONSE;
my %responses;
foreach my $handler (@HANDLERS) {
no strict 'refs';
my $response = $handler->(attr=>\%attr);
syslog(debug => "handler %s: %s", $handler, $response);
if ($response and $response !~ /^dunno/i) {
syslog(info => "handler %s: %s is decisive.", $handler, $response);
$action = $response; last;
fatal_exit("unrecognized request type: '$attr{request}'") unless $attr{request} eq "smtpd_access_policy";
my $action = $DEFAULT_RESPONSE;
my %responses;
foreach my $handler (@HANDLERS) {
no strict 'refs';
my $response = $handler->(attr=>\%attr);
syslog(debug => "handler %s: %s", $handler, $response);
if ($response and $response !~ /^dunno/i) {
syslog(info => "handler %s: %s is decisive.", $handler, $response);
$action = $response; last;
}
}
}
syslog(info => "decided action=%s", $action);
print STDOUT "action=$action\n\n";
%attr = ();
syslog(info => "decided action=%s", $action);
print STDOUT "action=$action\n\n";
%attr = ();
}
# ----------------------------------------------------------
# plugin: SPF
# ----------------------------------------------------------
sub sender_permitted_from {
local %_ = @_;
my %attr = %{ $_{attr} };
my $query = eval { new Mail::SPF::Query (ip =>$attr{client_address},
sender=>$attr{sender},
helo =>$attr{helo_name}) };
if ($@) {
syslog(info => "%s: Mail::SPF::Query->new(%s, %s, %s) failed: %s",
$attr{queue_id}, $attr{client_address}, $attr{sender}, $attr{helo_name}, $@);
return "DUNNO";
}
my ($result, $smtp_comment, $header_comment) = $query->result();
syslog(info => "%s: SPF %s: smtp_comment=%s, header_comment=%s",
$attr{queue_id}, $result, $smtp_comment, $header_comment);
if ($result eq "fail") { return "REJECT $smtp_comment"; }
elsif ($result eq "error") { return "DEFER_IF_PERMIT $smtp_comment"; }
else { return "PREPEND Received-SPF: $result ($header_comment)"; }
local %_ = @_;
my %attr = %{ $_{attr} };
my $query = eval {
Mail::SPF::Query->new(
ip => $attr{client_address},
sender => $attr{sender},
helo => $attr{helo_name}
)
};
if ($@) {
syslog(
info => "%s: Mail::SPF::Query->new(%s, %s, %s) failed: %s",
$attr{queue_id}, $attr{client_address}, $attr{sender}, $attr{helo_name}, $@
);
return "DUNNO";
}
my ($result, $smtp_comment, $header_comment) = $query->result();
syslog(
info => "%s: SPF %s: smtp_comment=%s, header_comment=%s",
$attr{queue_id}, $result, $smtp_comment, $header_comment
);
if ($result eq "fail") { return "REJECT $smtp_comment"; }
elsif ($result eq "error") { return "DEFER_IF_PERMIT $smtp_comment"; }
else { return "PREPEND Received-SPF: $result ($header_comment)"; }
}
# ----------------------------------------------------------
# plugin: testing
# ----------------------------------------------------------
sub testing {
local %_ = @_;
my %attr = %{ $_{attr} };
if (lc address_stripped($attr{sender}) eq
lc address_stripped($attr{recipient})
and
$attr{recipient} =~ /policyblock/) {
syslog(info => "%s: testing: will block as requested", $attr{queue_id});
return "REJECT smtpd-policy blocking $attr{recipient}";
}
else {
syslog(info => "%s: testing: stripped sender=%s, stripped rcpt=%s",
$attr{queue_id},
address_stripped($attr{sender}),
address_stripped($attr{recipient}),
);
local %_ = @_;
my %attr = %{ $_{attr} };
}
return "DUNNO";
if (
lc(address_stripped($attr{sender})) eq lc(address_stripped($attr{recipient})) and
$attr{recipient} =~ /policyblock/
) {
syslog(info => "%s: testing: will block as requested", $attr{queue_id});
return "REJECT smtpd-policy blocking $attr{recipient}";
}
else {
syslog(
info => "%s: testing: stripped sender=%s, stripped rcpt=%s",
$attr{queue_id},
address_stripped($attr{sender}),
address_stripped($attr{recipient}),
);
}
return "DUNNO";
}
# my $foo = address_stripped('foo+bar@baz.com'); # returns 'foo@baz.com'
sub address_stripped {
# my $foo = localpart_lhs('foo+bar@baz.com'); # returns 'foo@baz.com'
my $string = shift;
for ($string) {
s/[+-].*\@/\@/;
}
return $string;
my $string = shift;
$string =~ s/[+-].*\@/\@/;
return $string;
}