dhcp-manager: strip hostname sent by internal DHCP client

The dhclient DHCP backend strips the domain part from the hostname
option sent to server; for consistency among different backends
uniform the internal client to do the same.
This commit is contained in:
Beniamino Galvani
2015-10-19 10:42:29 +02:00
parent aa22b2d87f
commit c09b12240e

View File

@@ -629,7 +629,17 @@ ip4_start (NMDhcpClient *client, const char *dhcp_anycast_addr, const char *last
hostname = nm_dhcp_client_get_hostname (client); hostname = nm_dhcp_client_get_hostname (client);
if (hostname) { if (hostname) {
r = sd_dhcp_client_set_hostname (priv->client4, hostname); char *prefix, *dot;
prefix = strdup (hostname);
dot = strchr (prefix, '.');
/* get rid of the domain */
if (dot)
*dot = '\0';
r = sd_dhcp_client_set_hostname (priv->client4, prefix);
free (prefix);
if (r < 0) { if (r < 0) {
nm_log_warn (LOGD_DHCP4, "(%s): failed to set DHCP hostname (%d)", iface, r); nm_log_warn (LOGD_DHCP4, "(%s): failed to set DHCP hostname (%d)", iface, r);
goto error; goto error;