[erlang-patches] jinterface patch - connect to epmd using the loopback address

Raimo Niskanen raimo+erlang-patches@REDACTED
Tue Jan 15 12:11:43 CET 2008


On Sat, Jan 12, 2008 at 10:53:55PM +0900, Artur Matos wrote:
> Hi,
> 
> In the current jinterface implementation, OtpEpmd.publishPort(node)  
> connects to the local epmd using the
> host's current IP address instead of the loopback  address (127.0.0.1).
> 
> If the host is connected to the internet with a static IP address,  
> this will make
> the connection to epmd go through the host's firewall, at least in  
> Mac OS X. Besides being
> a waste of resources, this forces the user to have the  epmd port  
> open (creating an unnecessary security risk),
> and seems inconsistent with Erlang semantics. For example, in my  
> machine, If I invoke
> "erl -sname blah" in my shell, Erlang connects to epmd without  
> requiring its port to be open (but I have only started
> using Erlang quite recently, so please correct me if I am wrong).
> 
> Anyway, the following patch fixes this problem.
> The patched version works perfectly in Mac OS X, and should behave  
> the same in other platforms, but I didn't test it with any other OS:
> 

Thank you for your patch. I have now checked the behaviour for
Erlang itself as well as erl_interface, and it seems Jinterface
is alone in error. Your patch will probably be accepted
as it is, I will just check that it does not break any
test cases and that you have not missed any places
needing the same change. (The Jinterface code is
well structured, so I do not think so)



> --- OtpEpmd.java.orig       2000-08-22 21:01:24.000000000 +0900
> +++ OtpEpmd.java  2008-01-12 21:51:30.000000000 +0900
> @@ -137,7 +137,7 @@
>       Socket s = null;
> 
>       try {
> -      s = new Socket(InetAddress.getLocalHost(),epmdPort);
> +      s = new Socket(InetAddress.getByName("localhost"),epmdPort);
>         OtpOutputStream obuf = new OtpOutputStream();
>         obuf.write2BE(node.alive().length() + 1);
>         obuf.write1(stopReq);
> @@ -289,7 +289,7 @@
> 
>       try {
>         OtpOutputStream obuf = new OtpOutputStream();
> -      s = new Socket(InetAddress.getLocalHost(),epmdPort);
> +      s = new Socket(InetAddress.getByName("localhost"),epmdPort);
> 
>         obuf.write2BE(node.alive().length() + 3);
> 
> @@ -349,7 +349,7 @@
> 
>       try {
>         OtpOutputStream obuf = new OtpOutputStream();
> -      s = new Socket(InetAddress.getLocalHost(),epmdPort);
> +      s = new Socket(InetAddress.getByName("localhost"),epmdPort);
> 
>         obuf.write2BE(node.alive().length() + 13);
> 
> 
> 
> 
> Artur
> 
> _______________________________________________
> erlang-patches mailing list
> erlang-patches@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-patches

-- 

/ Raimo Niskanen, Erlang/OTP, Ericsson AB



More information about the erlang-patches mailing list