Commit 2da4d54a authored by Beniamino Galvani's avatar Beniamino Galvani

dhcp: ignore hostname when invalid

The hostname used for DHCP can be the one obtained from the hostnamed
service and is not guaranteed to be valid, at least with systemd
239. Instead of sending an invalid DHCP option to the server or
failing due to later checks in clients, ignore the hostname and log a
warning when it is invalid.
parent 38f942e0
Pipeline #71348 failed with stages
in 44 minutes and 18 seconds
......@@ -17,6 +17,7 @@
#include <stdio.h>
#include "nm-glib-aux/nm-dedup-multi.h"
#include "systemd/nm-sd-utils-shared.h"
#include "nm-config.h"
#include "NetworkManagerUtils.h"
......@@ -252,6 +253,17 @@ client_start (NMDhcpManager *self,
g_return_val_if_reached (NULL) ;
if (hostname) {
if ( (hostname_use_fqdn && !nm_sd_dns_name_is_valid (hostname))
|| (!hostname_use_fqdn && !nm_sd_hostname_is_valid (hostname, FALSE))) {
nm_log_warn (LOGD_DHCP , "dhcp%c: %s '%s' is invalid, will be ignored",
nm_utils_addr_family_to_char (addr_family),
hostname_use_fqdn ? "FQDN" : "hostname",
hostname = NULL;
nm_assert (g_bytes_get_size (hwaddr) == g_bytes_get_size (bcast_hwaddr));
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment