File 1765-inet_res-fix-edns0-unit-test.patch of Package erlang
From 215a0c44d15f60f38bcca676de628b4b6bdaa74a Mon Sep 17 00:00:00 2001
From: Alexander Clouter <alex@digriz.org.uk>
Date: Thu, 20 Apr 2023 09:26:51 +0100
Subject: [PATCH 05/10] inet_res: fix edns0 unit test
Most calls to inet_res:resolve are missing 'nameservers' which
means the request goes to your local resolver which may route
single labels to LLMNR (eg. systemd-resolved). Also as Ericsson
did not buy the TLD 'otptest' these are not publically usable.
Also, inet_res:getbyname() does not accept options and we are
not going to hijack the inet_res main resolver, so remove it.
---
lib/kernel/test/inet_res_SUITE.erl | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/lib/kernel/test/inet_res_SUITE.erl b/lib/kernel/test/inet_res_SUITE.erl
index 95ebeaefa1..062857ee92 100644
--- a/lib/kernel/test/inet_res_SUITE.erl
+++ b/lib/kernel/test/inet_res_SUITE.erl
@@ -1055,6 +1055,7 @@ check_msg(#{}, []) -> false. % At least one has to be ok
edns0(Config) when is_list(Config) ->
?P("begin"),
NS = ns(Config),
+ Opts = [{nameservers,[NS]},verbose],
Domain = "otptest",
Filler = "-5678901234567890123456789012345678.",
MXs = lists:sort([{10,"mx."++Domain},
@@ -1068,12 +1069,9 @@ edns0(Config) when is_list(Config) ->
false = inet_db:res_option(edns), % ASSERT
true = inet_db:res_option(udp_payload_size) >= 1280, % ASSERT
%% These will fall back to TCP
- MXs = lists:sort(inet_res:lookup(Domain, in, mx, [{nameservers,[NS]},verbose])),
+ MXs = lists:sort(inet_res:lookup(Domain, in, mx, Opts)),
%%
- {ok,#hostent{h_addr_list=As}} = inet_res:getbyname(Domain++".", mx),
- MXs = lists:sort(As),
- %%
- {ok,Msg1} = inet_res:resolve(Domain, in, mx),
+ {ok,Msg1} = inet_res:resolve(Domain, in, mx, Opts),
MXs = lists:sort(inet_res_filter(inet_dns:msg(Msg1, anlist), in, mx)),
%% There should be no OPT record in the answer
[] = [RR || RR <- inet_dns:msg(Msg1, arlist),
@@ -1084,7 +1082,7 @@ edns0(Config) when is_list(Config) ->
%% Use EDNS - should not need to fall back to TCP
%% there is no way to tell from the outside.
%%
- {ok,Msg2} = inet_res:resolve(Domain, in, mx, [{edns,0}]),
+ {ok,Msg2} = inet_res:resolve(Domain, in, mx, [{edns,0}|Opts]),
MXs = lists:sort(inet_res_filter(inet_dns:msg(Msg2, anlist), in, mx)),
Buf2 = inet_dns:encode(Msg2),
{ok,Msg2} = inet_dns:decode(Buf2),
--
2.35.3