From f41f41506c209ccc58734bdb4ebc8337b04a1286 Mon Sep 17 00:00:00 2001 From: Mathieu Trudel-Lapierre Date: Tue, 4 Dec 2012 12:21:24 -0600 Subject: [PATCH] dhcp: ensure hostname is sent to the DHCP server for default wired connections For the default wired connection (or any connection that doesn't have an IPv4 setting, which means "auto"), the hostname should always be sent to the DHCP server to register in DNS. --- src/dhcp-manager/nm-dhcp-manager.c | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/src/dhcp-manager/nm-dhcp-manager.c b/src/dhcp-manager/nm-dhcp-manager.c index c17dc80fa6..995bff4797 100644 --- a/src/dhcp-manager/nm-dhcp-manager.c +++ b/src/dhcp-manager/nm-dhcp-manager.c @@ -450,6 +450,7 @@ nm_dhcp_manager_start_ip4 (NMDHCPManager *self, NMDHCPManagerPrivate *priv; NMDHCPClient *client = NULL; const char *hostname = NULL; + gboolean send_hostname = TRUE; g_return_val_if_fail (self, NULL); g_return_val_if_fail (NM_IS_DHCP_MANAGER (self), NULL); @@ -464,22 +465,23 @@ nm_dhcp_manager_start_ip4 (NMDHCPManager *self, g_return_val_if_fail (strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_AUTO) == 0, NULL); } - /* If we're asked to send the hostname to DHCP server, and the hostname - * isn't specified, and a hostname provider is registered: use that - */ - if (nm_setting_ip4_config_get_dhcp_send_hostname (s_ip4)) { + send_hostname = nm_setting_ip4_config_get_dhcp_send_hostname (s_ip4); + if (send_hostname) hostname = nm_setting_ip4_config_get_dhcp_hostname (s_ip4); + } - /* If we're supposed to send the hostname to the DHCP server but - * the user didn't specify one, use the persistent hostname. - */ - if (!hostname && priv->hostname_provider) { - hostname = nm_hostname_provider_get_hostname (priv->hostname_provider); - if ( hostname - && (!strcmp (hostname, "localhost.localdomain") || - !strcmp (hostname, "localhost6.localdomain6"))) - hostname = NULL; - } + if (send_hostname) { + /* If we're supposed to send the hostname to the DHCP server but + * the user didn't specify one, then use the hostname from the + * hostname provider if there is one, otherwise use the persistent + * hostname. + */ + if (!hostname && priv->hostname_provider) { + hostname = nm_hostname_provider_get_hostname (priv->hostname_provider); + if ( hostname + && (!strcmp (hostname, "localhost.localdomain") || + !strcmp (hostname, "localhost6.localdomain6"))) + hostname = NULL; } }