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-02 22:03:55.241508287 +0100 @@ -0,0 +1,35 @@ +{ + use esmith::util::network qw( isValidIP ); + use Net::IPv4Addr qw( ipv4_in_network ); + my $ndb = esmith::NetworksDB->open_ro(); + + #start to find the local network range + 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($_); + $localAccess .= "$ip/$bits"; + } + } + + my @relayclients = split /[,:]/, ${qpsmtpd}{RelayClients} || ''; + + return "# No relay clients are defined" unless (scalar @relayclients); + + foreach my $relayclients (@relayclients) + { + if ( (isValidIP($relayclients) && ipv4_in_network ("$localAccess",$relayclients) ) || ($relayclients eq $localAccess)) + { + $OUT .= "$relayclients\n"; + } + else + { + $OUT .= "## $relayclients is not an IP or in the localnetwork\n"; + } + } + +}