mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-02-07 00:30:32 +01:00
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:
parent
c09b12240e
commit
dbbb08eb01
1 changed files with 9 additions and 2 deletions
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue