Skip Menu |
 

This queue is for tickets about the Net-SSH-Perl CPAN distribution.

Report information
The Basics
Id: 6725
Status: resolved
Priority: 0/
Queue: Net-SSH-Perl

People
Owner: Nobody in particular
Requestors: matt [...] katipo.co.nz
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 1.25
Fixed in: (no value)

Attachments


Subject: BindAddress functionality not implemented
Download (untitled) / with headers
text/plain 219b
We really would like to see BindAddress support in this library so that we don't have to maintain local patches to all installations. I have attached a patch that implements it in version 1.25. Regards, Matthew Hunt.
Download bind_address.patch
text/x-diff 1.6k
--- ./Perl.pm Wed Feb 11 16:48:02 2004 +++ ./Perl.pm Wed Feb 11 16:51:00 2004 @@ -223,10 +223,19 @@ if ($ssh->{config}->get('privileged')) { my $p; my $proto = getprotobyname('tcp'); + my $addr = $ssh->{config}->get('bind_address'); + my $paddr; + if ($addr) { + my $iaddr = inet_aton($addr); + $paddr = sockaddr_in($p, $iaddr); + } + else { + $paddr = sockaddr_in($p, INADDR_ANY); + } for ($p = 1023; $p > 512; $p--) { socket($sock, AF_INET, SOCK_STREAM, $proto) || croak "Net::SSH: Can't create socket: $!"; - last if bind($sock, sockaddr_in($p, INADDR_ANY)); + last if bind($sock, $paddr); if ($! =~ /Address already in use/i) { close($sock); next; @@ -239,6 +248,16 @@ else { socket($sock, AF_INET, SOCK_STREAM, 0) || croak "Net::SSH: Can't create socket: $!"; + + my $addr = $ssh->{config}->get('bind_address'); + if ($addr) { + my $iaddr = inet_aton($addr); + my $paddr; + for (my $p = 10000; $p < 65535; $p++) { + $paddr = sockaddr_in($p, $iaddr); + last if bind($sock, $paddr); + } + } } $sock; } --- ./Perl/Config.pm Wed Feb 11 16:48:10 2004 +++ ./Perl/Config.pm Wed Feb 11 16:47:03 2004 @@ -8,6 +8,7 @@ use Carp qw( croak ); %DIRECTIVES = ( + BindAddress => [ \&_set_str, 'bind_address' ], Host => [ \&_host ], BatchMode => [ \&_batch_mode ], ChallengeResponseAuthentication => [ \&_set_str, 'auth_ch_res' ],
Download (untitled) / with headers
text/plain 203b
Thanks for the patch. I made a few modifications (factored out the two port-searching loops and fixed a problem where you set the port outside the loop rather than inside). This change will be in 1.27.


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.