diff -Nur smeserver-qpsmtpd-2.4.0/root/etc/e-smith/templates/var/service/qpsmtpd/config/relayclients/60myAppliances smeserver-qpsmtpd-2.4.0.bz8704/root/etc/e-smith/templates/var/service/qpsmtpd/config/relayclients/60myAppliances --- smeserver-qpsmtpd-2.4.0/root/etc/e-smith/templates/var/service/qpsmtpd/config/relayclients/60myAppliances 1970-01-01 01:00:00.000000000 +0100 +++ smeserver-qpsmtpd-2.4.0.bz8704/root/etc/e-smith/templates/var/service/qpsmtpd/config/relayclients/60myAppliances 2014-12-03 00:42:56.346024376 +0100 @@ -0,0 +1,37 @@ +{ + use esmith::util::network qw( isValidIP ); + use Net::IPv4Addr qw( ipv4_in_network ); + + my @relayclients = split /[,:]/, ${qpsmtpd}{UnauthenticatedRelayClients} || ''; + return "# No relay clients are defined" unless (scalar @relayclients); + + foreach my $relayclients (@relayclients) + { + #start to find the local network range + my $ndb = esmith::NetworksDB->open_ro(); + my @localAccess; + + foreach ($ndb->local_access_spec()) + { + # If there's a / in the network string + # then convert to CIDR notation + if (m!/!) + { + my ($ip,$bits) = Net::IPv4Addr::ipv4_parse($_); + push (@localAccess,"$ip/$bits"); + } + } + + foreach my $localAccess (@localAccess) + { + if (isValidIP($relayclients) && ipv4_in_network ("$localAccess",$relayclients)) + { + $OUT .= "$relayclients\n"; + } + else + { + $OUT .= "## $relayclients is not an IP or not in the localnetwork\n"; + } + } + } +}