1 |
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 |
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 |
2 |
--- 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/root/etc/e-smith/templates/var/service/qpsmtpd/config/relayclients/60myAppliances 1970-01-01 01:00:00.000000000 +0100 |
3 |
+++ 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 |
+++ smeserver-qpsmtpd-2.4.0.bz8704/root/etc/e-smith/templates/var/service/qpsmtpd/config/relayclients/60myAppliances 2014-12-04 00:41:19.363852378 +0100 |
4 |
@@ -0,0 +1,35 @@ |
@@ -0,0 +1,37 @@ |
5 |
+{ |
+{ |
6 |
+ use esmith::util::network qw( isValidIP ); |
+ use esmith::util::network qw(isValidIP); |
7 |
+ use Net::IPv4Addr qw( ipv4_in_network ); |
+ use Net::IPv4Addr qw(ipv4_in_network ipv4_parse); |
|
+ my $ndb = esmith::NetworksDB->open_ro(); |
|
8 |
+ |
+ |
9 |
+ #start to find the local network range |
+ my $relayclients = ${qpsmtpd}{UnauthenticatedRelayClients} || return; |
10 |
+ my $localAccess = ''; |
+ my @relayclients = split /[,:]/, $relayclients; |
|
+ 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"; |
|
|
+ } |
|
|
+ } |
|
11 |
+ |
+ |
12 |
+ my @relayclients = split /[,:]/, ${qpsmtpd}{RelayClients} || ''; |
+ my $ndb = esmith::NetworksDB->open_ro(); |
13 |
+ |
+ |
14 |
+ return "# No relay clients are defined" unless (scalar @relayclients); |
+ sub convert_to_cidr |
15 |
|
+ { |
16 |
|
+ $_ = shift; |
17 |
|
+ return "$_/32" unless m!/!; |
18 |
|
+ my ($ip,$bits) = ipv4_parse($_); |
19 |
|
+ return "$ip/$bits"; |
20 |
|
+ } |
21 |
+ |
+ |
22 |
+ foreach my $relayclients (@relayclients) |
+ my @localAccess = map { |
23 |
|
+ convert_to_cidr($_) |
24 |
|
+ } $ndb->local_access_spec(); |
25 |
|
+ |
26 |
|
+ foreach my $relayclient (@relayclients) |
27 |
|
+ { |
28 |
|
+ if (!isValidIP($relayclient)) |
29 |
+ { |
+ { |
30 |
+ if ( (isValidIP($relayclients) && ipv4_in_network ("$localAccess",$relayclients) ) || ($relayclients eq $localAccess)) |
+ $OUT .= "## $relayclient is not an IP\n"; |
|
+ { |
|
|
+ $OUT .= "$relayclients\n"; |
|
|
+ } |
|
|
+ else |
|
|
+ { |
|
|
+ $OUT .= "## $relayclients is not an IP or in the localnetwork\n"; |
|
|
+ } |
|
31 |
+ } |
+ } |
32 |
+ |
+ elsif (grep { ipv4_in_network($_, $relayclient) } @localAccess) |
33 |
|
+ { |
34 |
|
+ $OUT .= "$relayclient\n"; |
35 |
|
+ } |
36 |
|
+ else |
37 |
|
+ { |
38 |
|
+ $OUT .= "## $relayclient is not in any local network\n"; |
39 |
|
+ } |
40 |
|
+ } |
41 |
+} |
+} |