From 01e939ac3d3cc1c74f14a69aec5c6afef987efa5 Mon Sep 17 00:00:00 2001 From: Julian Mehnle <> Date: Wed, 10 Jan 2007 20:00:57 +0000 Subject: [PATCH] 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 * 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. --- CHANGES | 16 ++++ INSTALL | 3 +- README | 7 +- debian/changelog | 18 +++++ debian/control | 7 +- debian/copyright | 9 ++- postfix-policyd-spf-perl | 158 ++++++++++++++++++++------------------- 7 files changed, 130 insertions(+), 88 deletions(-) diff --git a/CHANGES b/CHANGES index 25ddd84..f4d352a 100644 --- a/CHANGES +++ b/CHANGES @@ -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 + * 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. diff --git a/INSTALL b/INSTALL index 1f057e9..cbdd598 100644 --- a/INSTALL +++ b/INSTALL @@ -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 diff --git a/README b/README index 98a0e71..7f9c403 100644 --- a/README +++ b/README @@ -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 +(C) 2007 Scott Kitterman + 2003-2004 Meng Weng Wong Contributions by various members of the SPF project - + ============================================================================== postfix-policyd-spf-perl is a Postfix SMTPd policy daemon for SPF checking. diff --git a/debian/changelog b/debian/changelog index 63b4f20..364aa3a 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,21 @@ +postfix-policyd-spf-perl (1.08.1) unstable; urgency=low + + Debian: + * New maintainer: Scott Kitterman + * 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 Wed, 10 Jan 2007 21:00:00 +0000 + postfix-policyd-spf-perl (1.08) unstable; urgency=low * Initial release as a Debian package. diff --git a/debian/control b/debian/control index f1c9337..00a6fca 100644 --- a/debian/control +++ b/debian/control @@ -1,14 +1,13 @@ Source: postfix-policyd-spf-perl Section: mail -Priority: optional -Maintainer: Julian Mehnle +Priority: extra +Maintainer: Scott Kitterman 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. diff --git a/debian/copyright b/debian/copyright index 2f5d76e..7b59635 100644 --- a/debian/copyright +++ b/debian/copyright @@ -1,13 +1,14 @@ This is the Debian package for postfix-policyd-spf-perl, which is available -from . +from . -(C) 2003-2004 Meng Weng Wong +(C) 2007 Scott Kitterman + 2003-2004 Meng Weng Wong 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 diff --git a/postfix-policyd-spf-perl b/postfix-policyd-spf-perl index 1d5f4bb..b31eddf 100755 --- a/postfix-policyd-spf-perl +++ b/postfix-policyd-spf-perl @@ -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 () { - 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; }