mirror of
https://github.com/webmin/webmin.git
synced 2026-03-20 16:50:24 +00:00
Better host clash checking
This commit is contained in:
@@ -38,3 +38,4 @@ When applying the configuration fails with an error mentioning a line in the con
|
||||
---- Changes since 1.510 ----
|
||||
Added support for multi-value options, thanks to a patch from Luke Suchocki.
|
||||
Also added support for multi-value options within a bracketed expression.
|
||||
Hostname, IP address and MAC address clashes are now only checked for in the same shared network.
|
||||
|
||||
@@ -593,6 +593,32 @@ local ($sr, $hr) = &get_subnets_and_hosts();
|
||||
return @{$hr};
|
||||
}
|
||||
|
||||
sub get_host_shared_network
|
||||
{
|
||||
local ($h) = @_;
|
||||
local $shar;
|
||||
while($h) {
|
||||
if ($h->{'name'} eq 'shared-network') {
|
||||
return $h;
|
||||
}
|
||||
$h = $h->{'parent'};
|
||||
}
|
||||
return undef;
|
||||
}
|
||||
|
||||
sub get_my_shared_network_hosts
|
||||
{
|
||||
local ($h) = @_;
|
||||
local $shar = &get_host_shared_network($h);
|
||||
local @rv;
|
||||
foreach my $oh (&get_hosts()) {
|
||||
if (&get_host_shared_network($oh) eq $shar) {
|
||||
push(@rv, $oh);
|
||||
}
|
||||
}
|
||||
return @rv;
|
||||
}
|
||||
|
||||
# hash that links objtypes shortcuts with object names
|
||||
%obj_names2types = qw(host hst group grp subnet sub shared-network sha);
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ else {
|
||||
# Check for a hostname clash
|
||||
if (($in{'new'} || $in{'name'} ne $host->{'values'}->[0]) &&
|
||||
$access{'uniq_hst'}) {
|
||||
foreach $h (&get_hosts()) {
|
||||
foreach $h (&get_my_shared_network_hosts($npar)) {
|
||||
&error("$text{'eacl_np'} $text{'eacl_uniq'}")
|
||||
if (lc($h->{'values'}->[0]) eq lc($in{'name'}));
|
||||
}
|
||||
@@ -68,7 +68,7 @@ else {
|
||||
: &find("hardware", $host->{'members'});
|
||||
if ((!$oldhard || $in{'hardware'} ne $oldhard->{'values'}->[1])
|
||||
&& $access{'uniq_hst'}) {
|
||||
foreach $h (&get_hosts()) {
|
||||
foreach $h (&get_my_shared_network_hosts($npar)) {
|
||||
$chard = &find("hardware", $h->{'members'});
|
||||
&error("$text{'eacl_np'} $text{'eacl_uniqh'}")
|
||||
if ($chard && lc($chard->{'values'}->[1]) eq lc($in{'hardware'}));
|
||||
@@ -96,7 +96,7 @@ else {
|
||||
if ((!$oldfixed ||
|
||||
$in{'fixed-address'} ne $oldfixed->{'values'}->[0])
|
||||
&& $access{'uniq_hst'}) {
|
||||
foreach $h (&get_hosts()) {
|
||||
foreach $h (&get_my_shared_network_hosts($npar)) {
|
||||
$cfixed = &find("fixed-address",
|
||||
$h->{'members'});
|
||||
&error("$text{'eacl_np'} $text{'eacl_uniqi'}")
|
||||
|
||||
Reference in New Issue
Block a user