From 46c5b763ef26269b50d303fc62793c58a42eefb1 Mon Sep 17 00:00:00 2001 From: pierrepomes Date: Fri, 27 Nov 2009 16:57:48 -0500 Subject: [PATCH] Fix hostname checking when entering a dhcp static mapping and replace "." with "_" when writing "host-name" option in dhcpd.conf. Resolves #159 --- etc/inc/services.inc | 1 + usr/local/www/services_dhcp_edit.php | 10 ++++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/etc/inc/services.inc b/etc/inc/services.inc index 0622fe3b6e..3969efafc1 100644 --- a/etc/inc/services.inc +++ b/etc/inc/services.inc @@ -341,6 +341,7 @@ EOD; if ($sm['hostname']) { $dhhostname = str_replace(" ", "_", $sm['hostname']); + $dhhostname = str_replace(".", "_", $dhhostname); $dhcpdconf .= " option host-name {$dhhostname};\n"; } diff --git a/usr/local/www/services_dhcp_edit.php b/usr/local/www/services_dhcp_edit.php index 1124e8fe3f..e6870821cc 100755 --- a/usr/local/www/services_dhcp_edit.php +++ b/usr/local/www/services_dhcp_edit.php @@ -109,8 +109,14 @@ if ($_POST) { /* normalize MAC addresses - lowercase and convert Windows-ized hyphenated MACs to colon delimited */ $_POST['mac'] = strtolower(str_replace("-", ":", $_POST['mac'])); - if (($_POST['hostname'] && !is_hostname($_POST['hostname']))) { - $input_errors[] = "A valid host name must be specified."; + if ($_POST['hostname']) { + if (!is_hostname($_POST['hostname'])) { + $input_errors[] = "A valid host name must be specified."; + } else { + if (strpos($_POST['hostname'],'.')) { + $input_errors[] = "A valid hostname is specified, but the domain name part should be omitted"; + } + } } if (($_POST['ipaddr'] && !is_ipaddr($_POST['ipaddr']))) { $input_errors[] = "A valid IP address must be specified.";