Erlang/OTP Forums

Author Message

<  Erlang patches mailing list  ~  jinterface patch - connect to epmd using the loopback addres

Guest
Posted: Sat Jan 12, 2008 2:00 pm Reply with quote
Guest
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:

--- 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@erlang.org
http://www.erlang.org/mailman/listinfo/erlang-patches
Post recived from mailinglist
Guest
Posted: Tue Jan 15, 2008 11:13 am Reply with quote
Guest
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@erlang.org
> http://www.erlang.org/mailman/listinfo/erlang-patches

--

/ Raimo Niskanen, Erlang/OTP, Ericsson AB
_______________________________________________
erlang-patches mailing list
erlang-patches@erlang.org
http://www.erlang.org/mailman/listinfo/erlang-patches
Post recived from mailinglist

Display posts from previous:  

All times are GMT
Page 1 of 1
This forum is locked: you cannot post, reply to, or edit topics.

Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum