Project

General

Profile

Bug #159

"." in hostname creates invalid dhcpd.conf

Added by Chris Buechler over 9 years ago. Updated over 9 years ago.

Status:
Resolved
Priority:
Normal
Assignee:
-
Category:
DHCP Server
Target version:
Start date:
11/17/2009
Due date:
% Done:

100%

Estimated time:
Affected Version:
2.0
Affected Architecture:

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.

Associated revisions

Revision 07ab4926 (diff)
Added by Scott Ullrich over 9 years ago

Update fieldname, it should be hostname and not host Ticket #159

Revision 1420c055 (diff)
Added by Scott Ullrich over 9 years ago

Update fieldname, it should be hostname and not host Ticket #159

Revision 46c5b763 (diff)
Added by Pierre POMES over 9 years ago

Fix hostname checking when entering a dhcp static mapping and replace "." with "_" when writing "host-name" option in dhcpd.conf. Resolves #159

History

#1 Updated by Pierre POMES over 9 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.

#2 Updated by Chris Buechler over 9 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'.

#3 Updated by Pierre POMES over 9 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

#4 Updated by Pierre POMES over 9 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 ?

#5 Updated by Chris Buechler over 9 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.

#6 Updated by Pierre POMES over 9 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.

#7 Updated by Chris Buechler over 9 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.

#8 Updated by Pierre POMES over 9 years ago

Ok, I misunderstood, sorry. It's clear now ;-)

#9 Updated by Pierre POMES over 9 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 "_".

#10 Updated by Pierre POMES over 9 years ago

  • Status changed from New to Resolved
  • % Done changed from 0 to 100

#11 Updated by Chris Buechler over 9 years ago

this is good now, thanks!

Also available in: Atom PDF