Skip to content

Commit

Permalink
Fix hostname checking when entering a dhcp static mapping and replace…
Browse files Browse the repository at this point in the history
… "." with "_" when writing "host-name" option in dhcpd.conf. Resolves #159
  • Loading branch information
pierrepomes committed Nov 27, 2009
1 parent 64fba8e commit 46c5b76
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions etc/inc/services.inc
Expand Up @@ -341,6 +341,7 @@ EOD;

if ($sm['hostname']) {
$dhhostname = str_replace(" ", "_", $sm['hostname']);
$dhhostname = str_replace(".", "_", $dhhostname);
$dhcpdconf .= " option host-name {$dhhostname};\n";
}

Expand Down
10 changes: 8 additions & 2 deletions usr/local/www/services_dhcp_edit.php
Expand Up @@ -109,8 +109,14 @@ function staticmaps_sort($ifgui) {
/* 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.";
Expand Down

0 comments on commit 46c5b76

Please sign in to comment.