Fix externalSSLAccess with netmask < 32

GLPI #38307
tags/smeserver-lemonldap-ng-0.2.19-1
Daniel Berteaud 5 years ago
parent e70ce66b40
commit 575c129428
  1. 15
      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;

Loading…
Cancel
Save