Can I submit a patch to the code?
I have written a patch to the script centered around excluding domains from SPF validation. I have found some domains have incorrect SPF records and trying to get them fixed is not possible. As a result, I want to exclude them. Unfortunately this may not be able to be fixed in the "smtpd_
diff -u postfix-
--- postfix-
+++ postfix-
@@ -64,6 +64,10 @@
code => \&exempt_relay
},
{
+ name => 'exempt_domains',
+ code => \&exempt_domains
+ },
+ {
name => 'sender_
code => \&sender_
}
@@ -73,6 +77,9 @@
my $DEFAULT_RESPONSE = 'DUNNO';
+# Read in exempt domains list
+my $exempt_domains = get_exempt_domains( "/etc/postfix/
+
#
# Syslogging options for verbose mode and for fatal errors.
# NOTE: comment out the $syslog_socktype line if syslogging does not
@@ -185,6 +192,50 @@
}
# -------
+# handler: domain exemption
+# -------
+sub get_exempt_domains {
+ my ( $file ) = @_;
+
+ my $list = {};
+
+ # Return nothing if file not found
+ if ( ! -r $file ) {
+ return $list;
+ }
+
+ # Read the file into one variable, split on space or comma (or all)
+ open ( FILE, $file ) or die "Can't open $file: $!\n";
+ my $text = "";
+ while ( my $tmp = <FILE> ) {
+ $text .= $tmp;
+ }
+ close( FILE );
+
+ foreach my $domain ( split( /[\s,]+/, $text ) ) {
+ $list->{$domain} = 1;
+ }
+
+ return $list;
+}
+
+sub exempt_domains {
+ my %options = @_;
+ my $attr = $options{attr};
+
+ my $domain = ( split( /\@/, $attr->{sender} ) )[1];
+ return 'DUNNO' if ( ( ! defined( $domain ) ) or ( $domain eq '' ) );
+
+ # Check the domain against our list of ignored domains
+ if ( defined( $exempt_
+ return "PREPEND Authentication-
+ "(SPF exempted by policy)";
+ }
+
+ return 'DUNNO';
+}
+
+# -------
# handler: localhost exemption
# -------
Question information
- Language:
- English Edit question
- Status:
- Solved
- Assignee:
- No assignee Edit question
- Solved by:
- Scott Kitterman
- Solved:
- Last query:
- Last reply: