dhcp: dhclient: Allow unqualified fqdn.fqdn for DHCPv6

ISC dhclient will always append the zero label to the fqdn.fqdn option.

The dhcp-options(5) suggest that it's perfectly fine to have an
unqualified name.

"... This can be a fully-qualified domain name, or a single label. ..."

The ISC dhcpd will ignore this trailing zero label and do DDNS
regardless.

https://bugzilla.gnome.org/show_bug.cgi?id=761467
This commit is contained in:
Jonas Jonsson
2017-04-05 11:13:20 +02:00
committed by Beniamino Galvani
parent bd805b7e49
commit f5d29e6f61
3 changed files with 5 additions and 8 deletions

View File

@@ -168,10 +168,7 @@ add_ip4_config (GString *str, GBytes *client_id, const char *hostname, const cha
static void static void
add_hostname6 (GString *str, const char *hostname) add_hostname6 (GString *str, const char *hostname)
{ {
/* dhclient only supports the fqdn.fqdn for DHCPv6 and requires a fully- if (hostname) {
* qualified name for this option, so we must require one here too.
*/
if (hostname && strchr (hostname, '.')) {
g_string_append_printf (str, FQDN_FORMAT "\n", hostname); g_string_append_printf (str, FQDN_FORMAT "\n", hostname);
g_string_append (str, g_string_append (str,
"send fqdn.server-update on;\n"); "send fqdn.server-update on;\n");

View File

@@ -203,9 +203,6 @@ merge_dhclient_config (NMDhcpDhclient *self,
} }
} }
if (is_ip6 && hostname && !strchr (hostname, '.'))
_LOGW ("hostname is not a FQDN, it will be ignored");
new = nm_dhcp_dhclient_create_config (iface, is_ip6, client_id, anycast_addr, hostname, fqdn, orig_path, orig, out_new_client_id); new = nm_dhcp_dhclient_create_config (iface, is_ip6, client_id, anycast_addr, hostname, fqdn, orig_path, orig, out_new_client_id);
g_assert (new); g_assert (new);
success = g_file_set_contents (conf_file, new, -1, error); success = g_file_set_contents (conf_file, new, -1, error);

View File

@@ -440,6 +440,9 @@ test_override_hostname6 (void)
static const char *nonfqdn_hostname6_expected = \ static const char *nonfqdn_hostname6_expected = \
"# Created by NetworkManager\n" "# Created by NetworkManager\n"
"\n" "\n"
"send fqdn.fqdn \"blahblah\"; # added by NetworkManager\n"
"send fqdn.server-update on;\n"
"\n"
"also request dhcp6.name-servers;\n" "also request dhcp6.name-servers;\n"
"also request dhcp6.domain-search;\n" "also request dhcp6.domain-search;\n"
"also request dhcp6.client-id;\n" "also request dhcp6.client-id;\n"
@@ -448,7 +451,7 @@ static const char *nonfqdn_hostname6_expected = \
static void static void
test_nonfqdn_hostname6 (void) test_nonfqdn_hostname6 (void)
{ {
/* Non-FQDN hostname can't be used with dhclient */ /* Non-FQDN hostname can now be used with dhclient */
test_config (NULL, nonfqdn_hostname6_expected, test_config (NULL, nonfqdn_hostname6_expected,
TRUE, "blahblah", TRUE, "blahblah",
NULL, NULL, NULL, NULL,