resolve: lift limits on search domains count or length

glibc 2.26 lifted restrictions on search domains count or length to
unlimited. This has also been backported to 2.17 in some distributions (RHEL 7
and derivatives). Other softwares may have their own limits for search domains,
but we should not restrict what is written out any more.

https://sourceware.org/legacy-ml/libc-announce/2017/msg00001.html
This commit is contained in:
Dimitri John Ledkov 2020-08-07 12:47:09 +01:00 committed by Zbigniew Jędrzejewski-Szmek
parent 170a8c365b
commit 1c7466aa2e
2 changed files with 1 additions and 44 deletions

View file

@ -231,7 +231,6 @@ static void write_resolv_conf_server(DnsServer *s, FILE *f, unsigned *count) {
static void write_resolv_conf_search(
OrderedSet *domains,
FILE *f) {
unsigned length = 0, count = 0;
Iterator i;
char *domain;
@ -241,15 +240,6 @@ static void write_resolv_conf_search(
fputs("search", f);
ORDERED_SET_FOREACH(domain, domains, i) {
if (++count > MAXDNSRCH) {
fputs("\n# Too many search domains configured, remaining ones ignored.", f);
break;
}
length += strlen(domain) + 1;
if (length > 256) {
fputs("\n# Total length of all search domains is too long, remaining ones ignored.", f);
break;
}
fputc(' ', f);
fputs(domain, f);
}

View file

@ -917,40 +917,7 @@ Domains= one two three four five six seven eight nine ten''')
if ' one' in contents:
break
time.sleep(0.1)
self.assertRegex(contents, 'search .*one two three four')
self.assertNotIn('seven\n', contents)
self.assertIn('# Too many search domains configured, remaining ones ignored.\n', contents)
def test_search_domains_too_long(self):
# we don't use this interface for this test
self.if_router = None
name_prefix = 'a' * 60
self.write_network('test.netdev', '''\
[NetDev]
Name=dummy0
Kind=dummy
MACAddress=12:34:56:78:9a:bc''')
self.write_network('test.network', '''\
[Match]
Name=dummy0
[Network]
Address=192.168.42.100/24
DNS=192.168.42.1
Domains={p}0 {p}1 {p}2 {p}3 {p}4'''.format(p=name_prefix))
self.start_unit('systemd-networkd')
for timeout in range(50):
with open(RESOLV_CONF) as f:
contents = f.read()
if ' one' in contents:
break
time.sleep(0.1)
self.assertRegex(contents, 'search .*{p}0 {p}1 {p}2'.format(p=name_prefix))
self.assertIn('# Total length of all search domains is too long, remaining ones ignored.', contents)
self.assertRegex(contents, 'search .*one two three four five six seven eight nine ten')
def test_dropin(self):
# we don't use this interface for this test