summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBeniamino Galvani <bgalvani@redhat.com>2015-10-19 10:42:29 +0200
committerBeniamino Galvani <bgalvani@redhat.com>2015-11-23 16:31:08 +0100
commitc09b12240eccd57bb1279e44a55cd76712aa8c0c (patch)
tree00bd9c53dbcb1c642aee2784b3759e7d4ae5f619
parentaa22b2d87f28ed491fec3f1b40fc9d7b3042b926 (diff)
downloadNetworkManager-c09b12240eccd57bb1279e44a55cd76712aa8c0c.tar.gz
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.
-rw-r--r--src/dhcp-manager/nm-dhcp-systemd.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/dhcp-manager/nm-dhcp-systemd.c b/src/dhcp-manager/nm-dhcp-systemd.c
index 7bafc7209e..41ce28478d 100644
--- a/src/dhcp-manager/nm-dhcp-systemd.c
+++ b/src/dhcp-manager/nm-dhcp-systemd.c
@@ -629,7 +629,17 @@ ip4_start (NMDhcpClient *client, const char *dhcp_anycast_addr, const char *last
hostname = nm_dhcp_client_get_hostname (client);
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) {
nm_log_warn (LOGD_DHCP4, "(%s): failed to set DHCP hostname (%d)", iface, r);
goto error;