diff options
Diffstat (limited to 'src/dhcp/nm-dhcp-systemd.c')
-rw-r--r-- | src/dhcp/nm-dhcp-systemd.c | 41 |
1 files changed, 20 insertions, 21 deletions
diff --git a/src/dhcp/nm-dhcp-systemd.c b/src/dhcp/nm-dhcp-systemd.c index 7067275bc3..96be65ae1c 100644 --- a/src/dhcp/nm-dhcp-systemd.c +++ b/src/dhcp/nm-dhcp-systemd.c @@ -580,7 +580,7 @@ ip4_start (NMDhcpClient *client, const char *dhcp_anycast_addr, const char *last const uint8_t *client_id = NULL; size_t client_id_len = 0; struct in_addr last_addr = { 0 }; - const char *hostname, *fqdn; + const char *hostname; int r, i; gboolean success = FALSE; guint16 arp_type; @@ -687,29 +687,28 @@ ip4_start (NMDhcpClient *client, const char *dhcp_anycast_addr, const char *last hostname = nm_dhcp_client_get_hostname (client); if (hostname) { - char *prefix, *dot; + if (nm_dhcp_client_get_use_fqdn (client)) { + r = sd_dhcp_client_set_hostname (priv->client4, hostname); + if (r < 0) { + _LOGW ("failed to set DHCP FQDN (%d)", r); + goto error; + } + } else { + char *prefix, *dot; - prefix = strdup (hostname); - dot = strchr (prefix, '.'); - /* get rid of the domain */ - if (dot) - *dot = '\0'; + 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); + r = sd_dhcp_client_set_hostname (priv->client4, prefix); + free (prefix); - if (r < 0) { - _LOGW ("failed to set DHCP hostname (%d)", r); - goto error; - } - } - - fqdn = nm_dhcp_client_get_fqdn (client); - if (fqdn) { - r = sd_dhcp_client_set_hostname (priv->client4, fqdn); - if (r < 0) { - _LOGW ("failed to set DHCP FQDN (%d)", r); - goto error; + if (r < 0) { + _LOGW ("failed to set DHCP hostname (%d)", r); + goto error; + } } } |