Handle short DHCP hostnames
authorJamie Cameron <jcameron@webmin.com>
Fri, 29 Aug 2008 18:41:00 +0000 (18:41 +0000)
committerJamie Cameron <jcameron@webmin.com>
Fri, 29 Aug 2008 18:41:00 +0000 (18:41 +0000)
dhcp-dns/delete.cgi
dhcp-dns/module.info
dhcp-dns/save.cgi

index 4404cd7..c2d5d01 100644 (file)
@@ -20,6 +20,11 @@ foreach $d (@d) {
                }
        ($fn, $recs) = &get_dns_zone();
        ($old) = grep { lc($_->{'name'}) eq lc($d).'.' } @$recs;
+       if (!$old) {
+               # Search by hostname only
+               ($old) = grep { lc($_->{'name'}) eq
+                               lc($d).'.'.lc($config{'domain'}).'.' } @$recs;
+               }
        if ($old) {
                &bind8::delete_record($fn, $old);
                &bind8::bump_soa_record($fn, $recs);
index f1b2d9c..79988f2 100644 (file)
@@ -1,4 +1,4 @@
 desc=DHCP and DNS Hosts
 category=servers
 depends=bind8 dhcpd net
-version=1.4
+version=1.5
index 2bca1e3..c4caf61 100644 (file)
@@ -7,11 +7,15 @@ require './dhcp-dns-lib.pl';
 @hosts = &list_dhcp_hosts();
 ($fn, $recs) = &get_dns_zone();
 if (!$in{'new'}) {
-       # Get existing host object
+       # Get existing host object and DNS record
        ($host) = grep { $_->{'values'}->[0] eq $in{'old'} } @hosts;
        $host || &error($text{'edit_egone'});
        $oldpar = $host->{'parent'};
        ($old) = grep { lc($_->{'name'}) eq lc($in{'old'}).'.' } @$recs;
+       if (!$old) {
+               ($old) = grep { lc($_->{'name'}) eq
+                       lc($in{'old'}).'.'.lc($config{'domain'}).'.' } @$recs;
+               }
        if ($in{'subnet'} eq $in{'oldsubnet'}) {
                $par = $oldpar;
                }