mirror of
https://github.com/systemd/systemd.git
synced 2024-11-05 23:51:28 +03:00
libsystemd-network: use domain validation instead of hostname validation for dhcp domain option
previously hostname_is_valid was used to validate domain names, which would silently drop perfectly valid dns names that were longer than a single dns label.
This commit is contained in:
parent
df6cfeeff7
commit
37de250906
@ -32,6 +32,7 @@
|
||||
#include "dhcp-lease-internal.h"
|
||||
#include "sd-dhcp-lease.h"
|
||||
#include "network-internal.h"
|
||||
#include "dns-domain.h"
|
||||
|
||||
int sd_dhcp_lease_get_address(sd_dhcp_lease *lease, struct in_addr *addr) {
|
||||
assert_return(lease, -EINVAL);
|
||||
@ -504,9 +505,18 @@ int dhcp_lease_parse_options(uint8_t code, uint8_t len, const uint8_t *option,
|
||||
if (e)
|
||||
*e = 0;
|
||||
|
||||
if (!hostname_is_valid(domainname) || is_localhost(domainname))
|
||||
if (is_localhost(domainname))
|
||||
break;
|
||||
|
||||
r = dns_name_is_valid(domainname);
|
||||
if (r <= 0) {
|
||||
if (r < 0)
|
||||
log_error_errno(r, "Failed to validate domain name: %s: %m", domainname);
|
||||
if (r == 0)
|
||||
log_warning("Domain name is not valid, ignoring: %s", domainname);
|
||||
break;
|
||||
}
|
||||
|
||||
free(lease->domainname);
|
||||
lease->domainname = domainname;
|
||||
domainname = NULL;
|
||||
|
@ -30,6 +30,7 @@
|
||||
#include "networkd-netdev.h"
|
||||
#include "networkd-link.h"
|
||||
#include "network-internal.h"
|
||||
#include "dns-domain.h"
|
||||
|
||||
static int network_load_one(Manager *manager, const char *filename) {
|
||||
_cleanup_network_free_ Network *network = NULL;
|
||||
@ -466,11 +467,16 @@ int config_parse_domains(const char *unit,
|
||||
STRV_FOREACH(domain, *domains) {
|
||||
if (is_localhost(*domain))
|
||||
log_syntax(unit, LOG_ERR, filename, line, EINVAL, "'localhost' domain names may not be configured, ignoring assignment: %s", *domain);
|
||||
else if (!hostname_is_valid(*domain)) {
|
||||
if (!streq(*domain, "*"))
|
||||
log_syntax(unit, LOG_ERR, filename, line, EINVAL, "domain name is not valid, ignoring assignment: %s", *domain);
|
||||
else {
|
||||
r = dns_name_is_valid(*domain);
|
||||
if (r <= 0 && !streq(*domain, "*")) {
|
||||
if (r < 0)
|
||||
log_error_errno(r, "Failed to validate domain name: %s: %m", *domain);
|
||||
if (r == 0)
|
||||
log_warning("Domain name is not valid, ignoring assignment: %s", *domain);
|
||||
} else
|
||||
continue;
|
||||
}
|
||||
|
||||
strv_remove(*domains, *domain);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user