From 575c129428e0af0b35ae2f8c23d566b84bdb205d Mon Sep 17 00:00:00 2001 From: Daniel Berteaud Date: Tue, 3 Sep 2019 10:18:52 +0200 Subject: [PATCH] Fix externalSSLAccess with netmask < 32 GLPI #38307 --- .../var/lib/lemonldap-ng/conf/lmConf/025localnet | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/root/etc/e-smith/templates/var/lib/lemonldap-ng/conf/lmConf/025localnet b/root/etc/e-smith/templates/var/lib/lemonldap-ng/conf/lmConf/025localnet index cbf0da7..fd76a08 100644 --- a/root/etc/e-smith/templates/var/lib/lemonldap-ng/conf/lmConf/025localnet +++ b/root/etc/e-smith/templates/var/lib/lemonldap-ng/conf/lmConf/025localnet @@ -1,42 +1,39 @@ { my $reg = '$ipAddr =~ /^'; -my $count = 0; # Build a regexp to check if the client IP # is part of a local network # Then, we can easily use this macro to restrict # access to local networks on some applications +my @net = (); foreach my $net ($n->networks){ my $addr = $net->key; my $mask = $net->prop('Mask') || '255.255.255.255'; - $reg .= '|' if ($count > 0); foreach (esmith::util::computeAllLocalNetworkPrefixes($addr,$mask)){ - $reg .= "($_)"; - $count++; + push @net, "($_)"; } } +$reg .= join('|', @net); $reg .= '/'; $reg =~ s/\./\\\./g; $conf->{'macros'}->{'localAccess'} = '(' . $reg . ") ? '1':'0'"; $reg = '$ipAddr =~ /^'; -$count = 0; +@net = (); # Do the same for extenal SSL access - foreach my $net (split(/[;,]/,(${'httpd-admin'}{'ValidFrom'} || ''))){ my ($addr,$mask) = split(/\//,$net); - $reg .= '|' if ($count > 0); foreach (esmith::util::computeAllLocalNetworkPrefixes($addr,$mask)){ - $reg .= "($_)"; - $count++; + push @net, "($_)"; } } +$reg .= join('|', @net); $reg .= '/'; $reg =~ s/\./\\\./g;