From 4187d8df073367ae48b57d134cb8e214f6fdcab2 Mon Sep 17 00:00:00 2001 From: Jamie Cameron Date: Fri, 29 Aug 2008 18:41:00 +0000 Subject: [PATCH] Handle short DHCP hostnames --- dhcp-dns/delete.cgi | 5 +++++ dhcp-dns/module.info | 2 +- dhcp-dns/save.cgi | 6 +++++- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/dhcp-dns/delete.cgi b/dhcp-dns/delete.cgi index 4404cd746..c2d5d0195 100644 --- a/dhcp-dns/delete.cgi +++ b/dhcp-dns/delete.cgi @@ -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); diff --git a/dhcp-dns/module.info b/dhcp-dns/module.info index f1b2d9cac..79988f2d2 100644 --- a/dhcp-dns/module.info +++ b/dhcp-dns/module.info @@ -1,4 +1,4 @@ desc=DHCP and DNS Hosts category=servers depends=bind8 dhcpd net -version=1.4 +version=1.5 diff --git a/dhcp-dns/save.cgi b/dhcp-dns/save.cgi index 2bca1e33b..c4caf61ad 100644 --- a/dhcp-dns/save.cgi +++ b/dhcp-dns/save.cgi @@ -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; }