Jinterface question

Per Bohlin per.bohlin@REDACTED
Wed Feb 23 11:14:00 CET 2000


I sent a question about the same thing before christmas.
Never got any answer though.

I patched my code in order to avoid the authority checks that 
are done. The original message follows.

/Per

> Subject: 
>                jinterface questions
>          Date: 
>                Mon, 20 Dec 1999 10:10:42 +0100
>          From: 
>                Per Bohlin <per.bohlin@REDACTED>
>  Organization: 
>                Ericsson Telecom
>            To: 
>                Erlang Questions <erlang-questions@REDACTED>
> 
> 
> 
> 
> I tried to experiment a little bit with
> JInterface starting with making a hidden connection 
> from a Java node to an Erlang Node.
> 
> When doing this with the open source distribution
> on my Home-PC with Windows 98
> and JDK 1.2 downloaded from javasoft.com
> I did not succeed.
> 
> The erlang side refuses to accept the connection.
> Error printout: ** Connection attempt from disallowed node ... 
>  
> On the Java side I get an authorization exception
> 
> I have found that there are some handshaking going on where 
> a random number is sent from Erlang to Java. Some calculations
> are made on this number on both sides. The result is sent from Java to
> erlang and the results are compared. 
> They are not identical so Erlang stops the connection.
> 
> Doing the same thing at work with OTP-R6 on Sun/Solaris
> works fine.
>  
> I have now patched both dist_util.erl in the kernel source and 
> OtpConnection.java in jinterface so that the tests are avoided. 
> This seem to work, but I guess that is not the way to solve it.
> What shall I do to make it work properly? 
>  
> 
> I also have a question about the functionallity of JInterface.
> At first I thought that it provided the same functionallity to JAVA
> that you get to C when using erl_interface.
> 
> I've used erl_interface a bit in a User Interface tool where
> C++ objects are represented with Erlang PID's. 
> When receiving messages from erlang a dictionary is used to keep
> track of which object to transfer the message to based on the pid
> that the message is sent to. So effectivly the erlang side can send 
> messages to C++ objects (represening windows) 
> as if they where Erlang processes.
> 
> In JInterface it is possible to create Erlang PIDs on the java side.
> But, I have not found any way of getting the PID that the Erlang message 
> was sent to. The messages just ends up in the
> OtpConnection.receive
> without reference to the PID that the message was sent to.
> 
> Is there a way to find the PID that the message was sent to?
> (And possibly also the PID of the process that the message was sent
> from,
> I don't need it but it is there in erl_interface)
> 
> Thanks
> 
> /Per Bohlin

Richard Carlsson wrote:
> 
> On 22 Feb 2000, Gordon Beaton wrote:
> 
> > On 22 Feb 2000 18:16:16 GMT, Richard Carlsson wrote:
> > > >   java -DOtpConnection.trace=4 MyClass ...
> > >
> > > Did that. Even inserted some print statements in the Java code and
> > > recompiled to see what was going on.
> >
> > Perhaps you could post the trace output so we can see what is going
> > on too?
> 
> Here it is. The printout of "self.cookie() ->" is my own addition,
> done just before the exception is thrown
> 
> -> LOOKUP (r4) foo@REDACTED
> <- PORT 55098
> -> MD5 CONNECT TO harpo.it.uu.se:55098
> -> HANDSHAKE sendName flags=4 dist=5 local=pp_client@REDACTED
> <- HANDSHAKE recvStatus (ok) local=pp_client@REDACTED
> <- HANDSHAKE recvChallenge from=foo@REDACTED challenge=218089577
> local=pp_client@REDACTED
> -> HANDSHAKE sendChallengeReply challenge=-437147855
> digest=283f393f3f3f3f683f73304a3f3f3157 local=pp_client@REDACTED
> self.cookie() -> GNGHONVCOKHWGENSXJFF
> com.ericsson.otp.erlang.OtpAuthException: Peer authentication error.
> 
> --------
> 
> An on the Erlang side:
> 
> =ERROR REPORT==== 23-Feb-2000::10:15:59 ===
> ** Connection attempt from disallowed node 'pp_client@REDACTED' **
> 
> (foo@REDACTED)1> erlang:get_cookie().
> 'GNGHONVCOKHWGENSXJFF'
> (foo@REDACTED)2> auth:get_cookie('pp_client@REDACTED').
> 'GNGHONVCOKHWGENSXJFF'
> (foo@REDACTED)1>
> 
> --------
> 
> Just to check that it is at all possible to connect to that node,
> I start another Erlang node, initially using a different cookie:
> 
> Erlang (BEAM) emulator version 4.9.1 [source]
> 
> Eshell V4.9.1  (abort with ^G)
> (bar@REDACTED)1> erlang:get_cookie().
> 'LCGCVEJOKLRRXDWZOIZY'
> (bar@REDACTED)2> auth:get_cookie('foo@REDACTED').
> 'LCGCVEJOKLRRXDWZOIZY'
> (bar@REDACTED)3> net_adm:ping('foo@REDACTED').
> pang
> (bar@REDACTED)4> erlang:set_cookie('foo@REDACTED',
> 'GNGHONVCOKHWGENSXJFF').
> true
> (bar@REDACTED)5> net_adm:ping('foo@REDACTED').
> pong
> (bar@REDACTED)6>
> 
> At the first `ping' attempt, the original node responded just like in the
> Java case:
> 
> =ERROR REPORT==== 23-Feb-2000::10:20:22 ===
> ** Connection attempt from disallowed node 'bar@REDACTED' **
> 
> but after I manually set the cookie, the connection worked just fine,
> so that Jinterface cannot connect appears rather strange.
> 
> --------
> 
> One thing in OtpConnection.java that I could not help but notice:
> 
>   // This is nooo good as a challenge,
>   // XXX fix me.
>   static private int genChallenge() {
>     return random.nextInt();
>   }
> 
> although whether it can be the source of this error, I can't tell.
> 
>         /Richard Carlsson
> 
> Richard Carlsson (richardc@REDACTED)   (This space intentionally left blank.)
> E-mail: Richard.Carlsson@REDACTED      WWW: http://www.csd.uu.se/~richardc/




More information about the erlang-questions mailing list