From 8d40d03a2c1fc1b2fcfd7453c0ea91e476a82ee1 Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Tue, 19 Oct 2021 20:34:47 +0200 Subject: [PATCH] dhcp: honor the send_hostname property --- src/core/dhcp/nm-dhcp-client.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/core/dhcp/nm-dhcp-client.c b/src/core/dhcp/nm-dhcp-client.c index 8b9e724968..484ec34e72 100644 --- a/src/core/dhcp/nm-dhcp-client.c +++ b/src/core/dhcp/nm-dhcp-client.c @@ -1012,8 +1012,10 @@ config_init(NMDhcpClientConfig *config, const NMDhcpClientConfig *src) } if (config->hostname) { - if ((config->use_fqdn && !nm_sd_dns_name_is_valid(config->hostname)) - || (!config->use_fqdn && !nm_sd_hostname_is_valid(config->hostname, FALSE))) { + if (!config->send_hostname) { + nm_clear_g_free((gpointer *) &config->hostname); + } else if ((config->use_fqdn && !nm_sd_dns_name_is_valid(config->hostname)) + || (!config->use_fqdn && !nm_sd_hostname_is_valid(config->hostname, FALSE))) { nm_log_warn(LOGD_DHCP, "dhcp%c: %s '%s' is invalid, will be ignored", nm_utils_addr_family_to_char(config->addr_family),