From b019883a9a001da856de9629c5d35ca4646b197c Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Thu, 17 Jul 2025 18:30:30 +0200 Subject: [PATCH] core: accept hostnames longer than 64 characters from DNS lookup When resolving the system hostname from DNS lookup, we use nm_utils_validate_hostname() which checks that the result is a valid hostname. A valid hostname is at most 64 characters on Linux. Anything longer is discarded. However, the reverse DNS lookup doesn't return a hostname, it returns a DNS name. The DNS name can have multiple labels, each limited to 63 characters. The maximum length of the DNS name is 253 characters. If the result is longer than 64 characters because it has multiple labels, we should still accept it, provided that it is a valid DNS name. Then when setting the hostname in the system, only the first label will be kept. https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/2243 Resolves: https://issues.redhat.com/browse/RHEL-104357 --- src/core/devices/nm-device.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/devices/nm-device.c b/src/core/devices/nm-device.c index c30d01814c..fd0eb7dba6 100644 --- a/src/core/devices/nm-device.c +++ b/src/core/devices/nm-device.c @@ -18690,7 +18690,7 @@ hostname_dns_lookup_callback(GObject *source, GAsyncResult *result, gpointer use gboolean valid; resolver->hostname = g_steal_pointer(&output); - valid = nm_utils_validate_hostname(resolver->hostname); + valid = nm_sd_dns_name_is_valid(resolver->hostname); _LOGD(LOGD_DNS, "hostname-from-dns: ipv%c resolver %s: lookup successful for %s, result %s%s%s%s",