File 0906-Call-gethostbyname-only-AFTER-ERL_INETRC-has-been-re.patch of Package erlang
From 7c82d2b94f4f069fb310993fc49043e4c916323a Mon Sep 17 00:00:00 2001
From: Dominic Letz <dominic@diode.io>
Date: Mon, 3 Mar 2025 13:05:44 +0000
Subject: [PATCH] Call gethostbyname only AFTER ERL_INETRC has been read.
---
lib/kernel/src/inet_config.erl | 60 +++++++++++++++++-----------------
1 file changed, 30 insertions(+), 30 deletions(-)
diff --git a/lib/kernel/src/inet_config.erl b/lib/kernel/src/inet_config.erl
index 6524ec29ae..09df6b1c7d 100644
--- a/lib/kernel/src/inet_config.erl
+++ b/lib/kernel/src/inet_config.erl
@@ -58,36 +58,6 @@ init() ->
OsType = os:type(),
do_load_resolv(OsType, erl_dist_mode()),
- case OsType of
- {unix,Type} ->
- if Type =:= linux ->
- %% It may be the case that the domain name was not set
- %% because the hostname was short. But NOW we can look it
- %% up and get the long name and the domain name from it.
-
- %% FIXME: The second call to set_hostname will insert
- %% a duplicate entry in the search list.
-
- case inet_db:res_option(domain) of
- "" ->
- case inet:gethostbyname(inet_db:gethostname()) of
- {ok,#hostent{h_name = []}} ->
- ok;
- {ok,#hostent{h_name = HostName}} ->
- set_hostname({ok,HostName});
- _ ->
- ok
- end;
- _ ->
- ok
- end;
- true -> ok
- end,
- add_dns_lookup(inet_db:res_option(lookup));
- _ ->
- ok
- end,
-
%% Read inetrc file, if it exists.
{RcFile,CfgFiles,CfgList} = read_rc(),
@@ -133,6 +103,36 @@ init() ->
_ -> ok
end;
_ -> ok
+ end,
+
+ case OsType of
+ {unix,Type} ->
+ if Type =:= linux ->
+ %% It may be the case that the domain name was not set
+ %% because the hostname was short. But NOW we can look it
+ %% up and get the long name and the domain name from it.
+
+ %% FIXME: The second call to set_hostname will insert
+ %% a duplicate entry in the search list.
+
+ case inet_db:res_option(domain) of
+ "" ->
+ case inet:gethostbyname(inet_db:gethostname()) of
+ {ok,#hostent{h_name = []}} ->
+ ok;
+ {ok,#hostent{h_name = HostName}} ->
+ set_hostname({ok,HostName});
+ _ ->
+ ok
+ end;
+ _ ->
+ ok
+ end;
+ true -> ok
+ end,
+ add_dns_lookup(inet_db:res_option(lookup));
+ _ ->
+ ok
end.
--
2.43.0