File 0757-inet_config-Tolerate-atoms-as-inetrc-kernel-argument.patch of Package erlang

From d1ddd9ae97aa2da334e15910bd1d31a2e32c3492 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?John=20H=C3=B6gberg?= <john@erlang.org>
Date: Fri, 4 Oct 2024 15:30:31 +0200
Subject: [PATCH] inet_config: Tolerate atoms as `inetrc` kernel argument

Many RabbitMQ users provided atoms instead of strings as the
`inetrc` file path because of an error in their documentation. This
was tolerated by accident until atom filename support was removed
from erl_prim_loader.

We did the latter for good reason, but tolerating this specifically
in inet_config is no big deal.
---
 lib/kernel/src/inet_config.erl | 20 +++++++++-----------
 1 file changed, 9 insertions(+), 11 deletions(-)

diff --git a/lib/kernel/src/inet_config.erl b/lib/kernel/src/inet_config.erl
index 0d8b862f34..f352afbc69 100644
--- a/lib/kernel/src/inet_config.erl
+++ b/lib/kernel/src/inet_config.erl
@@ -426,17 +426,15 @@ valid_type(win32) ->             true;
 valid_type(_) ->                 false.
 
 read_inetrc() ->
-   case application:get_env(inetrc) of
-       {ok,File} ->
-	   try_get_rc(File);
-       _ ->
-	   case os:getenv("ERL_INETRC") of
-	       false ->
-		   {nofile,[]};
-	       File ->
-		   try_get_rc(File)
-	   end
-   end.
+    File = case application:get_env(inetrc) of
+               {ok, Value} when is_list(Value) -> Value;
+               {ok, Value} when is_atom(Value) -> atom_to_list(Value);
+               undefined -> os:getenv("ERL_INETRC")
+           end,
+    case is_list(File) of
+        true -> try_get_rc(File);
+        false -> {nofile,[]}
+    end.
 
 try_get_rc(File) ->
     case get_rc(File) of
-- 
2.43.0

openSUSE Build Service is sponsored by