Bug #159
closed"." in hostname creates invalid dhcpd.conf
100%
Description
Creating a reservation with a FQDN results in an invalid dhcpd.conf.
php: /services_dhcp.php: The command '/usr/local/sbin/dhcpd user dhcpd -group _dhcp -chroot /var/dhcpd -cf /var/dhcpd/etc/dhcpd.conf em1' returned exit code '1', the output was 'Internet Systems Consortium DHCP Server V3.0.7 Copyright 2004-2008 Internet Systems Consortium. All rights reserved. For info, please visit http://www.isc.org/sw/dhcp/ /var/dhcpd/etc/dhcpd.conf line 30: semicolon expected. option host-name blah. ^ Configuration file errors encountered - exiting'
The dhcpd.conf line is:
option host-name blah.blah.com;
That's an incorrect configuration, but 1.2.x accepts it and does work fine with such a configuration, so this will break some installs on upgrade.
Updated by Pierre POMES about 15 years ago
I am working on it, two targets :
- make sure the 2.0 gui does not allow to enter fqdn reservation.
- during the upgrade from 1.2.x, strip domain part from fqdn reservation.
Updated by Chris Buechler about 15 years ago
The first part is good.
On the second, I would prefer to avoid changing people's configuration. If they already have a FQDN in the config, assuming it's the periods that are hosing dhcpd, just strip the periods before writing out that field in dhcpd.conf. i.e. if they have blah.blah.com in there just make it blahblahcom. Then the input validation would prevent them from saving any changes to that reservation on 2.0, which is fine.
One reason being there's no telling what some people may have in their configuration. If someone has host.example.com, host.example.net, and host.example.org, if you strip the domain you're left with three with just 'host'.
Updated by Pierre POMES almost 15 years ago
Hi,
My cloned repo is updated with the first part. For the second one, you are right, I will follow your advices, and request a merge once it will be ok.
There is another issue in services_dhcp_edit.php, affecting all pfsense versions: the host name verification is done on $_POST['host'], however the field name in the HTML form is 'hostname'. This means you can easily break the dhcp server config because the hostname is not verified at all. I guess this needs to be fixed en RELENG_1_2 ?
Pierre
Updated by Pierre POMES almost 15 years ago
Question for the dhcp server config upgrade: may it be an option to change version number from 6.0 to 6.1 (etc/inc/global.inc), so that an upgrade function "upgrade_060_061" (etc/inc/upgrade.inc) can handle dhcp server config upgrades ?
Updated by Chris Buechler almost 15 years ago
why does the config need to be upgraded?
By the way - Scott fixed the hostname verification in RELENG_1_2 yesterday, thanks for that.
Updated by Pierre POMES almost 15 years ago
why does the config need to be upgraded?
As you mentionned in earlier post of this tickets, the '.' in static mappings should be removed when upgrading from 1.2 to 2.0 (blah.blah.com should me rewritten to blahblahcom). Otherwise, dhcp server won't start after the upgrade. That's why I propose to wrote an upgrade function.
Updated by Chris Buechler almost 15 years ago
Oh, I didn't mean changing the actual entries in the config.xml. Just when they're written out from the config.xml to the dhcpd.conf, strip them then. We prefer to avoid changing configurations as much as possible since that can potentially introduce serious bugs.
Updated by Pierre POMES almost 15 years ago
Ok, I misunderstood, sorry. It's clear now ;-)
Updated by Pierre POMES almost 15 years ago
I finally applied the same subsitution already done for " " (replaced by "_") when creating dhcpd.conf (goal was to preserve the same behaviour for substitution). So "." are also replaced with "_".
Updated by Pierre POMES almost 15 years ago
- Status changed from New to Resolved
- % Done changed from 0 to 100
Applied in changeset 46c5b763ef26269b50d303fc62793c58a42eefb1.