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:
@@ -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);
|
||||
|
Reference in New Issue
Block a user