summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBeniamino Galvani <bgalvani@redhat.com>2019-10-17 17:40:29 +0200
committerBeniamino Galvani <bgalvani@redhat.com>2019-10-17 18:05:20 +0200
commit2da4d54ac3e58b94a915d1fd0c488610b855c6fa (patch)
tree75ed92ccb77169e1d043c5f5bf760d18bb28e4a9
parent38f942e0386462f95aa95cb8162393e4a53ada1a (diff)
downloadNetworkManager-2da4d54ac3e58b94a915d1fd0c488610b855c6fa.tar.gz
dhcp: ignore hostname when invalidbg/dhcp-invalid-hostname
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. https://bugzilla.redhat.com/show_bug.cgi?id=1744427
-rw-r--r--src/dhcp/nm-dhcp-manager.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/dhcp/nm-dhcp-manager.c b/src/dhcp/nm-dhcp-manager.c
index a27f5572bb..2458f6c616 100644
--- a/src/dhcp/nm-dhcp-manager.c
+++ b/src/dhcp/nm-dhcp-manager.c
@@ -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);
+ hostname = NULL;
+ }
+ }
+
nm_assert (g_bytes_get_size (hwaddr) == g_bytes_get_size (bcast_hwaddr));
priv = NM_DHCP_MANAGER_GET_PRIVATE (self);