Host IP, hostname and MAC clash checking
authorJamie Cameron <jcameron@webmin.com>
Mon, 14 Apr 2008 07:24:49 +0000 (07:24 +0000)
committerJamie Cameron <jcameron@webmin.com>
Mon, 14 Apr 2008 07:24:49 +0000 (07:24 +0000)
dhcpd/CHANGELOG
dhcpd/defaultacl
dhcpd/lang/en
dhcpd/save_host.cgi

index 5977110..4af4755 100644 (file)
@@ -19,3 +19,5 @@ Changed the Module Config PID file setting to allow None to be selected, which t
 Added a field on the Client Options page for the DHCP server identifier.
 ---- Changes since 1.370 ----
 Fixed a bug that causes hosts to be deleted when searching for them!
+---- Changes since 1.410 ----
+Clashes between hosts with the same IP address, MAC address or hostname are no longer allowed by default - but this can be changed on the DHCP Server access control page in the Webmin User's module.
index 5197f31..197c53f 100644 (file)
@@ -10,9 +10,9 @@ w_hst=1
 c_grp=1
 r_grp=1
 w_grp=1
-uniq_hst=0
-uniq_sub=0
-uniq_sha=0
+uniq_hst=1
+uniq_sub=1
+uniq_sha=1
 smode=0
 hide=1
 per_hst_acls=0
index 13224ad..d1d5023 100644 (file)
@@ -369,6 +369,8 @@ eacl_pin=add new shared networks
 eacl_pun=edit shared network
 eacl_psn=select shared network
 eacl_uniq=create duplicates
+eacl_uniqh=create hosts with duplicate hardware addresses
+eacl_uniqi=create hosts with duplicate IP addresses
 eacl_pdl=delete leases
 eacl_psl=view leases
 eacl_pglob=edit global options
index 09ae139..bb1f7f8 100755 (executable)
@@ -62,13 +62,26 @@ else {
        $host->{'values'} = [ $in{'name'} ];
 
        if ($in{'hardware'}) {
+               # Check for hardware clash
+               $oldhard = $in{'new'} ? undef
+                                     : &find("hardware", $host->{'members'});
+               if ((!$oldhard || $in{'hardward'} ne $oldhard->{'values'}->[1])
+                   && $access{'uniq_hst'}) {
+                       foreach $h (&get_hosts()) {
+                               $chard = &find("hardware", $h->{'members'});
+                               &error("$text{'eacl_np'} $text{'eacl_uniqh'}")
+                                       if ($chard && lc($chard->{'values'}->[1]) eq lc($in{'hardware'}));
+                               }
+                       }
+
                # Convert from Windows / Cisco formats
                $in{'hardware'} =~ s/-/:/g;
                if ($in{'hardware'} =~ /^([0-9a-f]{2})([0-9a-f]{2}).([0-9a-f]{2})([0-9a-f]{2}).([0-9a-f]{2})([0-9a-f]{2}).([0-9a-f]{2})([0-9a-f]{2})$/) {
                        $in{'hardware'} = "$1:$2:$3:$4:$5:$6";
                        }
                $in{'hardware'} =~ /^([0-9a-f]{1,2}:)*[0-9a-f]{1,2}$/i ||
-                       &error(&text('shost_invalidhwa',$in{'hardware'},$in{'hardware_type'}) );
+                       &error(&text('shost_invalidhwa', $in{'hardware'},
+                                    $in{'hardware_type'}) );
                @hard = ( { 'name' => 'hardware',
                            'values' => [ $in{'hardware_type'},
                                          $in{'hardware'} ] } );
@@ -76,6 +89,21 @@ else {
        &save_directive($host, 'hardware', \@hard);
 
        if ($in{'fixed-address'}) {
+               # Check for IP clash
+               $oldfixed = $in{'new'} ? undef
+                             : &find("fixed-address", $host->{'members'});
+               if ((!$oldfixed ||
+                   $in{'fixed-address'} ne $oldfixed->{'values'}->[0])
+                   && $access{'uniq_hst'}) {
+                       foreach $h (&get_hosts()) {
+                               $cfixed = &find("fixed-address",
+                                               $h->{'members'});
+                               &error("$text{'eacl_np'} $text{'eacl_uniqi'}")
+                                       if ($cfixed && lc($cfixed->{'values'}->[0]) eq lc($in{'fixed-address'}));
+                               }
+                       }
+
+               # Save IP address
                if ($in{'fixed-address'} !~ /^[\w\s\.\-,]+$/ ||
                    $in{'fixed-address'} =~ /(^|[\s,])[-_]/ ||
                    $in{'fixed-address'} =~ /\.([\s,\.]|$)/ ||