[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

drb over pipes

Reto Schuettel

3/23/2006 9:43:00 AM

Hi

I'd like to establish a drb connection over ssh, preferably over the
stdin/stdout channels which are provided by ssh itself. Is there a
drb protocol which uses pipes? If not, is it easy to implement?

I've seen that the tcpprotocol uses two connections, this could be
problem, as pipes/stdin/stdout only provide one stream.

At the end of the day I'd like to do something like that:
# ruby client.rb | ssh host 'ruby agent.rb'

Unfortunately using drb's tcp protocol directly isn't really an option in
our environment.

Does anybody have a good idea?

Thanks!

Cheers,
Reto Schüttel


12 Answers

Pete

3/23/2006 9:47:00 AM

0

> Unfortunately using drb's tcp protocol directly isn't really an option in
> our environment.

I would suggest using ssh-tunneling.

That way you have the security of secure shell
and the comfort of tcp sockets.




> --- Ursprüngliche Nachricht ---
> Von: Reto Schuettel <reto-ruby-talk@schuettel.ch>
> An: ruby-talk@ruby-lang.org (ruby-talk ML)
> Betreff: drb over pipes
> Datum: Thu, 23 Mar 2006 18:42:49 +0900
>
> Hi
>
> I'd like to establish a drb connection over ssh, preferably over the
> stdin/stdout channels which are provided by ssh itself. Is there a
> drb protocol which uses pipes? If not, is it easy to implement?
>
> I've seen that the tcpprotocol uses two connections, this could be
> problem, as pipes/stdin/stdout only provide one stream.
>
> At the end of the day I'd like to do something like that:
> # ruby client.rb | ssh host 'ruby agent.rb'
>
> Unfortunately using drb's tcp protocol directly isn't really an option in
> our environment.
>
> Does anybody have a good idea?
>
> Thanks!
>
> Cheers,
> Reto Schüttel
>


Pete

3/23/2006 9:56:00 AM

0

some
links:
http://www.ssh.com/support/documentation/online/ssh/winhelp/32/Tunneling_Expl...
http://www.rzg.mpg.de/networking/tunne...


> --- Ursprüngliche Nachricht ---
> Von: "Peter Ertl" <pertl@gmx.org>
> An: ruby-talk@ruby-lang.org (ruby-talk ML)
> Betreff: Re: drb over pipes
> Datum: Thu, 23 Mar 2006 18:46:54 +0900
>
> > Unfortunately using drb's tcp protocol directly isn't really an option
> in
> > our environment.
>
> I would suggest using ssh-tunneling.
>
> That way you have the security of secure shell
> and the comfort of tcp sockets.
>
>
>
>
> > --- Ursprüngliche Nachricht ---
> > Von: Reto Schuettel <reto-ruby-talk@schuettel.ch>
> > An: ruby-talk@ruby-lang.org (ruby-talk ML)
> > Betreff: drb over pipes
> > Datum: Thu, 23 Mar 2006 18:42:49 +0900
> >
> > Hi
> >
> > I'd like to establish a drb connection over ssh, preferably over the
> > stdin/stdout channels which are provided by ssh itself. Is there a
> > drb protocol which uses pipes? If not, is it easy to implement?
> >
> > I've seen that the tcpprotocol uses two connections, this could be
> > problem, as pipes/stdin/stdout only provide one stream.
> >
> > At the end of the day I'd like to do something like that:
> > # ruby client.rb | ssh host 'ruby agent.rb'
> >
> > Unfortunately using drb's tcp protocol directly isn't really an option
> in
> > our environment.
> >
> > Does anybody have a good idea?
> >
> > Thanks!
> >
> > Cheers,
> > Reto Schüttel
> >
>


Yoann Guillot

3/23/2006 10:02:00 AM

0

On Thu, Mar 23, 2006 at 06:42:49PM +0900, Reto Schuettel wrote:
> Hi
>
> I'd like to establish a drb connection over ssh, preferably over the
> stdin/stdout channels which are provided by ssh itself. Is there a
> drb protocol which uses pipes? If not, is it easy to implement?
>
> I've seen that the tcpprotocol uses two connections, this could be
> problem, as pipes/stdin/stdout only provide one stream.
>
> At the end of the day I'd like to do something like that:
> # ruby client.rb | ssh host 'ruby agent.rb'
>

With drb, the client needs to talk to the agent and vice-versa, so this
command line will never work (the client will talk to the agent, but not the
other way around).

> Unfortunately using drb's tcp protocol directly isn't really an option in
> our environment.
>
> Does anybody have a good idea?

As suggested, tunelling is probably the best/simpler choice.

>
> Thanks!
>
> Cheers,
> Reto Schüttel
>

--
Yoann Guillot


Reto Schuettel

3/23/2006 10:24:00 AM

0

Hi

On Thu, Mar 23, 2006 at 07:01:35PM +0900, Yoann Guillot wrote:
> On Thu, Mar 23, 2006 at 06:42:49PM +0900, Reto Schuettel wrote:
> > At the end of the day I'd like to do something like that:
> > # ruby client.rb | ssh host 'ruby agent.rb'
> >
>
> With drb, the client needs to talk to the agent and vice-versa, so this
> command line will never work (the client will talk to the agent, but not the
> other way around).

A pipe provides two streams (in & out), and tcp does the same. The
question is now if drb really needs two connections (-> 4 streams)?

> > Unfortunately using drb's tcp protocol directly isn't really an option in
> > our environment.
> >
> > Does anybody have a good idea?
>
> As suggested, tunelling is probably the best/simpler choice.

Tunneling may be a solution, although I'd prefer the pipe. Otherwise
there would be a daemon, somewhere listening on localhost:port.

Regards,
Reto Schüttel


Pete

3/23/2006 10:50:00 AM

0

the 'daemon' is just ssh which you already have.
there will be no additional executables when you use tunneling,
just secure shell on port 22 (or whatever). tunneling is configured
in the client and can be allowed/forbidden on the server side.

> --- Ursprüngliche Nachricht ---
> Von: Reto Schuettel <reto-ruby-talk@schuettel.ch>
> An: ruby-talk@ruby-lang.org (ruby-talk ML)
> Betreff: Re: drb over pipes
> Datum: Thu, 23 Mar 2006 19:24:03 +0900
>
> Hi
>
> On Thu, Mar 23, 2006 at 07:01:35PM +0900, Yoann Guillot wrote:
> > On Thu, Mar 23, 2006 at 06:42:49PM +0900, Reto Schuettel wrote:
> > > At the end of the day I'd like to do something like that:
> > > # ruby client.rb | ssh host 'ruby agent.rb'
> > >
> >
> > With drb, the client needs to talk to the agent and vice-versa, so this
> > command line will never work (the client will talk to the agent, but not
> the
> > other way around).
>
> A pipe provides two streams (in & out), and tcp does the same. The
> question is now if drb really needs two connections (-> 4 streams)?
>
> > > Unfortunately using drb's tcp protocol directly isn't really an option
> in
> > > our environment.
> > >
> > > Does anybody have a good idea?
> >
> > As suggested, tunelling is probably the best/simpler choice.
>
> Tunneling may be a solution, although I'd prefer the pipe. Otherwise
> there would be a daemon, somewhere listening on localhost:port.
>
> Regards,
> Reto Schüttel
>


Jonathan Paisley

3/23/2006 12:35:00 PM

0

On Thu, 23 Mar 2006 18:42:49 +0900, Reto Schuettel wrote:


> I'd like to establish a drb connection over ssh, preferably over the
> stdin/stdout channels which are provided by ssh itself. Is there a
> drb protocol which uses pipes? If not, is it easy to implement?
>
> I've seen that the tcpprotocol uses two connections, this could be
> problem, as pipes/stdin/stdout only provide one stream.
>
> At the end of the day I'd like to do something like that:
> # ruby client.rb | ssh host 'ruby agent.rb'

I implemented a quick hack to do this. Hopefully the code below will help

Robert Klemme

3/23/2006 12:56:00 PM

0

Jonathan Paisley wrote:
> On Thu, 23 Mar 2006 18:42:49 +0900, Reto Schuettel wrote:
>
>
>> I'd like to establish a drb connection over ssh, preferably over the
>> stdin/stdout channels which are provided by ssh itself. Is there a
>> drb protocol which uses pipes? If not, is it easy to implement?
>>
>> I've seen that the tcpprotocol uses two connections, this could be
>> problem, as pipes/stdin/stdout only provide one stream.
>>
>> At the end of the day I'd like to do something like that:
>> # ruby client.rb | ssh host 'ruby agent.rb'
>
> I implemented a quick hack to do this. Hopefully the code below will help

The code didn't make it into the newsgroup. I can't detect something
strange about your original message - it's all there on my email
account. This is strange...

Cheers

robert

Jonathan Paisley

3/23/2006 1:05:00 PM

0

On Thu, 23 Mar 2006 21:58:52 +0900, Robert Klemme wrote:

> Jonathan Paisley wrote:
>> I implemented a quick hack to do this. Hopefully the code below will help
>
> The code didn't make it into the newsgroup. I can't detect something
> strange about your original message - it's all there on my email
> account. This is strange...

Very strange. I sent the message to the mailing list, where it has shown
up correctly in the archives [1] and been forwarded correctly as your
email account attests. I guess it must be something broken in the gateway

Reto Schuettel

3/23/2006 6:09:00 PM

0

Hi Peter

On Thu, Mar 23, 2006 at 07:49:56PM +0900, Peter Ertl wrote:
> the 'daemon' is just ssh which you already have.
> there will be no additional executables when you use tunneling,
> just secure shell on port 22 (or whatever). tunneling is configured
> in the client and can be allowed/forbidden on the server side.

Well.. yeah, there's no need for an additional daemon on the outside,
but a daemon at the beginning of the session would be needed (although
it could be shut down shortly later). Eg

$ ssh -L 4444:localhost:4444 'drb.rb drb://localhost:4444'

This would work quite well, but the drb port would be accessible by
local processes.

Reto Schuettel




Reto Schuettel

3/23/2006 6:30:00 PM

0

Hi Jonathan

On Thu, Mar 23, 2006 at 12:34:31PM +0000, Jonathan Paisley wrote:
> I implemented a quick hack to do this. Hopefully the code below will help.
> It's a bit of a mess, but allows you to use a DRb scheme like
> 'drbfd://0,1' which means uses file descriptors 0 and 1 (stdin/stdout) for
> communication.
>
> module DRb

That's great! exactly what I needed.

For the record: My statement in the first mail wasn't completely
correct, the pipe I used in my example is only a 'one-way' thing. But
ssh actually transports three streams/pipes: stdin, stdout and stderr, so this
isn't really a problem.

There's one small problem with your fdsocket, it seems like the drb
server/thread doesn't always terminate itself when the streams get
closed. But I will try to investigate this by myself tomorrow :).

I've appended an example which uses your library. It creates two pipes,
forks, connects the pipes to the stdin/stdout of the child and then execs
the ssh client. The same technique could also be used to communicate
with a child (instead of a unix/tcp socket or a simple plain pipe). IMHO
that's really nice, great work Jonathan!

require 'drb'
require 'fdsocket'

ctprd, ctpwr = IO.pipe
ptcrd, ptcwr = IO.pipe

pid = fork

unless pid
# child
ctprd.close
ptcwr.close

$stdin.reopen( ptcrd )
$stdout.reopen( ctpwr )

exec("ssh", "hostname", "./agent.rb")

exit # child shounld't reach this point
end

# parent
ctpwr.close
ptcrd.close

fd_read = ctprd.fileno
fd_write = ptcwr.fileno

# The URI to connect to
SERVER_URI="drbfd://#{fd_read},#{fd_write}"
DRb.start_service

obj = DRbObject.new_with_uri(SERVER_URI)

[...]


Regards,
Reto Schuettel