Non-working attempt at config file for relay exemption

This commit is contained in:
Scott Kitterman 2018-07-26 03:06:18 -04:00
commit 652e07ced7

View file

@ -78,8 +78,9 @@ my $VERBOSE = 0;
my $DEFAULT_RESPONSE = 'DUNNO';
# Read in exempt domains list
# Read in exemption lists
my $exempt_domains = get_exempt_domains( "/etc/postfix/exempt_spf_domains" );
my $relay_addresses = get_exempt_address("/etc/postfix/exempt_spf_addresses");
#
# Syslogging options for verbose mode and for fatal errors.
@ -97,11 +98,6 @@ use constant localhost_addresses => map(
qw( 127.0.0.0/8 ::ffff:127.0.0.0/104 ::1 )
); # Does Postfix ever say "client_address=::ffff:<ipv4-address>"?
use constant relay_addresses => map(
NetAddr::IP->new($_),
qw( )
); # add addresses to qw ( ) above separated by spaces using CIDR notation.
# Fully qualified hostname, if available, for use in authentication results
# headers now provided by the localhost and whitelist checks.
my $host = hostname_long;
@ -195,6 +191,7 @@ while (<STDIN>) {
# ----------------------------------------------------------
# handler: domain exemption
# ----------------------------------------------------------
sub get_exempt_domains {
my ( $file ) = @_;
@ -255,6 +252,38 @@ sub exempt_localhost {
# handler: relay exemption
# ----------------------------------------------------------
sub get_exempt_address {
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 );
#$list => map(
# NetAddr::IP->new($_),
# qw( $text )
#); # add addresses to qw ( ) above separated by spaces using CIDR notation.
foreach my $addr ( split( /[\s,]+/, $text ) ) {
map(
NetAddr::IP->new($list),
qw( $addr )
);
}
return $list;
}
sub exempt_relay {
my %options = @_;
my $attr = $options{attr};