dhcp-manager: strip hostname sent by dhcpcd

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

View File

@@ -63,8 +63,9 @@ ip4_start (NMDhcpClient *client, const char *dhcp_anycast_addr, const char *last
GPtrArray *argv = NULL;
pid_t pid = -1;
GError *error = NULL;
char *pid_contents = NULL, *binary_name, *cmd_str;
char *pid_contents = NULL, *binary_name, *cmd_str, *dot;
const char *iface, *dhcpcd_path, *hostname;
gs_free char *prefix = NULL;
g_return_val_if_fail (priv->pid_file == NULL, FALSE);
@@ -113,8 +114,14 @@ ip4_start (NMDhcpClient *client, const char *dhcp_anycast_addr, const char *last
hostname = nm_dhcp_client_get_hostname (client);
if (hostname) {
prefix = strdup (hostname);
dot = strchr (prefix, '.');
/* get rid of the domain */
if (dot)
*dot = '\0';
g_ptr_array_add (argv, (gpointer) "-h"); /* Send hostname to DHCP server */
g_ptr_array_add (argv, (gpointer) hostname );
g_ptr_array_add (argv, (gpointer) prefix);
}
g_ptr_array_add (argv, (gpointer) iface);