From: Matt S Trout Date: Sat, 26 Nov 2011 19:59:12 +0000 (+0000) Subject: allow local domain socket connects X-Git-Tag: v0.001002~11 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=a1cbf366ebe50a33878df88ffa56c72baa64061d;p=scpubgit%2FTak.git allow local domain socket connects --- diff --git a/lib/Tak/ConnectorService.pm b/lib/Tak/ConnectorService.pm index 15e39bf..50d8a25 100644 --- a/lib/Tak/ConnectorService.pm +++ b/lib/Tak/ConnectorService.pm @@ -1,6 +1,7 @@ package Tak::ConnectorService; use IPC::Open2; +use IO::Socket::UNIX; use IO::All; use Tak::Router; use Tak::Client; @@ -20,13 +21,15 @@ sub handle_create { die [ mistake => "No target supplied to create" ] unless $on; my $log_level = $args{log_level}||'info'; my ($kid_in, $kid_out, $kid_pid) = $self->_open($on, $log_level); - $kid_in->print($Tak::STDIONode::DATA, "__END__\n") unless $on eq '-'; - # Need to get a handshake to indicate STDIOSetup has finished - # messing around with file descriptors, otherwise we can severely - # confuse things by sending before the dup. - my $up = <$kid_out>; - die [ failure => "Garbled response from child: $up" ] - unless $up eq "Ssyshere\n"; + unless ($on =~ /^\.?\//) { + $kid_in->print($Tak::STDIONode::DATA, "__END__\n") unless $on eq '-'; + # Need to get a handshake to indicate STDIOSetup has finished + # messing around with file descriptors, otherwise we can severely + # confuse things by sending before the dup. + my $up = <$kid_out>; + die [ failure => "Garbled response from child: $up" ] + unless $up eq "Ssyshere\n"; + } my $connection = Tak::ConnectionService->new( read_fh => $kid_out, write_fh => $kid_in, listening_service => Tak::Router->new @@ -49,6 +52,10 @@ sub _open { my $kid_pid = IPC::Open2::open2(my $kid_out, my $kid_in, 'tak-stdio-node', '-', @args) or die "Couldn't open2 child: $!"; return ($kid_in, $kid_out, $kid_pid); + } elsif ($on =~ /^\.?\//) { # ./foo or /foo + my $sock = IO::Socket::UNIX->new($on) + or die "Couldn't open socket ${on}: $!"; + return ($sock, $sock, 'UNIX'); } my $ssh = $self->ssh->{$on} ||= Net::OpenSSH->new($on); $ssh->error and