Various changes
authorJamie Cameron <jcameron@webmin.com>
Mon, 14 Jan 2008 23:49:16 +0000 (23:49 +0000)
committerJamie Cameron <jcameron@webmin.com>
Mon, 14 Jan 2008 23:49:16 +0000 (23:49 +0000)
dhcp-dns/dhcp-dns-lib.pl
dhcp-dns/index.cgi
dhcp-dns/module.info
dhcp-dns/save.cgi

index 6d9112c..8b8b187 100644 (file)
@@ -122,27 +122,24 @@ $rv .= &ui_hidden("indom", $indom);
 
 # Fixed IP address
 local $fixed = &dhcpd::find("fixed-address", $h->{'members'});
+$rv .= &ui_hidden("oldip", $fixed->{'values'}->[0]) if ($fixed);
+local @subnets = $new ? &list_dhcp_subnets() : ( );
 $rv .= &ui_table_row($text{'form_ip'},
-       &ui_textbox("ip", $fixed ? $fixed->{'values'}->[0] : undef, 20));
-
-# Subnet for new host
-if ($new) {
-       local @subnets = &list_dhcp_subnets();
-       if (@subnets) {
-               $rv .= &ui_table_row($text{'form_subnet'},
+       &ui_textbox("ip", $fixed ? $fixed->{'values'}->[0] : undef, 20).
+       (@subnets ? " ".$text{'form_subnet'}." ".
                        &ui_select("subnet", $subnets[0]->{'values'}->[0],
                          [ [ undef, $text{'form_nosubnet'} ],
-                           map { [ $_->{'values'}->[0] ] } @subnets ]));
-               }
-       }
+                           map { [ $_->{'values'}->[0] ] } @subnets ]) : ""));
 
 # MAC address
 local $hard = &dhcpd::find("hardware", $h->{'members'});
+$rv .= &ui_hidden("oldmac", $hard->{'values'}->[0]) if ($hard);
 $rv .= &ui_table_row($text{'form_mac'},
-       &ui_select("media", $hard ? $hard->{'values'}->[0] : "ethernet",
-                  [ [ "ethernet", $text{'form_ethernet'} ],
-                    [ "token-ring", $text{'form_tr'} ],
-                    [ "fddi", $text{'form_fddi'} ] ], 1, 0, 1).
+#      &ui_select("media", $hard ? $hard->{'values'}->[0] : "ethernet",
+#                 [ [ "ethernet", $text{'form_ethernet'} ],
+#                   [ "token-ring", $text{'form_tr'} ],
+#                   [ "fddi", $text{'form_fddi'} ] ], 1, 0, 1).
+        &ui_hidden("media", $hard ? $hard->{'values'}->[0] : "ethernet").
        &ui_textbox("mac", $hard ? $hard->{'values'}->[1] : undef, 20));
 
 $rv .= &ui_table_end();
index 7caf4e7..68e245f 100644 (file)
@@ -35,8 +35,7 @@ print &ui_hidden_end();
 if (@hosts) {
        @tds = ( "width=5" );
        print &ui_form_start("delete.cgi");
-       @links = ( &select_all_link("d", 1),
-                  &select_invert_link("d", 1) );
+       @links = ( &select_invert_link("d", 1) );
        print &ui_links_row(\@links);
        print &ui_columns_start([ "",
                                  $text{'index_host'},
index 67c3685..dd85d9c 100644 (file)
@@ -1,4 +1,4 @@
 desc=DHCP and DNS Hosts
 category=servers
 depends=bind8 dhcpd
-version=1.0
+version=1.1
index e900365..6ade386 100644 (file)
@@ -48,16 +48,28 @@ else {
                $in{'host'} .= '.'.$config{'domain'};
                }
        if ($in{'new'} || $in{'host'} ne $in{'old'}) {
-               # Check for clash
+               # Check for hostname clash
                ($clash) = grep { $_->{'values'}->[0] eq $in{'host'} } @hosts;
                $clash && &error($text{'save_eclash'});
                }
        $host->{'values'} = [ $in{'host'} ];
+
        &check_ipaddress($in{'ip'}) || &error($text{'save_eip'});
+       if ($in{'new'} || $in{'ip'} ne $in{'oldip'}) {
+               # Check for IP clash
+               ($clash) = grep { my $f = &dhcpd::find("fixed-address", $_->{'members'}); $f->{'values'}->[0] eq $in{'ip'} } @hosts;
+               $clash && &error($text{'save_eclaship'});
+               }
        &dhcpd::save_directive($host, 'fixed-address',
                        [ { 'name' => 'fixed-address',
                            'values' => [ $in{'ip'} ] } ]);
+
        $in{'mac'} =~ /^[a-f0-9:]+$/i || &error($text{'save_emac'});
+       if ($in{'new'} || $in{'mac'} ne $in{'oldmac'}) {
+               # Check for MAC clash
+               ($clash) = grep { my $h = &dhcpd::find("hardware", $_->{'members'}); $h->{'values'}->[1] eq $in{'mac'} } @hosts;
+               $clash && &error($text{'save_eclaship'});
+               }
        &dhcpd::save_directive($host, 'hardware',
                        [ { 'name' => 'hardware',
                            'values' => [ $in{'media'}, $in{'mac'} ] } ]);