mirror of
https://github.com/duncs/clusterssh.git
synced 2025-06-30 08:44:17 +00:00
Fix '-l <username>' option (SF bug 3380675)
'-l <username>' had stopped working again - fix and test
This commit is contained in:
parent
5acf4a5b8b
commit
61acdf3815
2 changed files with 9 additions and 70 deletions
3
Changes
3
Changes
|
@ -1,3 +1,6 @@
|
||||||
|
????-??-?? Duncan Ferguson <duncan_ferguson@user.sf.net> - v4.00_11
|
||||||
|
* Fix '-l <username>' option (SF bug 3380675)
|
||||||
|
|
||||||
2011-07-08 Duncan Ferguson <duncan_ferguson@user.sf.net> - v4.00_10
|
2011-07-08 Duncan Ferguson <duncan_ferguson@user.sf.net> - v4.00_10
|
||||||
* Fix 'uninitialised error' message
|
* Fix 'uninitialised error' message
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ package App::ClusterSSH;
|
||||||
use 5.008.004;
|
use 5.008.004;
|
||||||
use warnings;
|
use warnings;
|
||||||
use strict;
|
use strict;
|
||||||
use version; our $VERSION = version->new('4.00_10');
|
use version; our $VERSION = version->new('4.00_11');
|
||||||
|
|
||||||
use Carp;
|
use Carp;
|
||||||
|
|
||||||
|
@ -379,6 +379,7 @@ sub check_config() {
|
||||||
$config{window_tiling} = "no" if $options{'no-tile'};
|
$config{window_tiling} = "no" if $options{'no-tile'};
|
||||||
|
|
||||||
$config{user} = $options{username} if ( $options{username} );
|
$config{user} = $options{username} if ( $options{username} );
|
||||||
|
$config{port} = $options{port} if ( $options{port} );
|
||||||
|
|
||||||
$config{mstr} = $options{master} if ( $options{master} );
|
$config{mstr} = $options{master} if ( $options{master} );
|
||||||
|
|
||||||
|
@ -978,74 +979,6 @@ sub setup_helper_script() {
|
||||||
logmsg( 2, "Helper script done" );
|
logmsg( 2, "Helper script done" );
|
||||||
}
|
}
|
||||||
|
|
||||||
sub split_hostname {
|
|
||||||
my ($connect_string) = @_;
|
|
||||||
|
|
||||||
my ( $server, $username, $port );
|
|
||||||
|
|
||||||
logmsg( 3, 'split_hostname: connect_string=' . $connect_string );
|
|
||||||
|
|
||||||
$username = $config{user} if ( $config{user} );
|
|
||||||
|
|
||||||
if ( $connect_string =~ s/^(.*)@// ) {
|
|
||||||
$username = $1;
|
|
||||||
}
|
|
||||||
|
|
||||||
# cope with IPv6 addresses
|
|
||||||
|
|
||||||
# check for correct syntax of using [<IPv6 address>]
|
|
||||||
# See http://tools.ietf.org/html/rfc2732 for more details
|
|
||||||
if ( $connect_string =~ m/^\[([\w:%]+)\](?::(\d+))?$/xsm ) {
|
|
||||||
logmsg( 3, 'connect_string contains IPv6 address' );
|
|
||||||
$server = $1;
|
|
||||||
$port = $2;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
|
|
||||||
my $colon_count = $connect_string =~ tr/://;
|
|
||||||
|
|
||||||
# See if there are exactly 7 colons - if so, assume pure IPv6
|
|
||||||
if ( $colon_count == 7 ) {
|
|
||||||
$server = $connect_string;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
|
|
||||||
# if more than 1 but less than 8 colons and last octect is
|
|
||||||
# numbers only, warn about ambiguity
|
|
||||||
if ( $colon_count > 1
|
|
||||||
&& $colon_count < 8
|
|
||||||
&& $connect_string =~ m/:(\d+)$/ )
|
|
||||||
{
|
|
||||||
our $seen_error;
|
|
||||||
warn 'Potentially ambiguous IPv6 address/port definition: ',
|
|
||||||
$connect_string, $/;
|
|
||||||
warn 'Assuming it is an IPv6 address only.', $/;
|
|
||||||
$server = $connect_string;
|
|
||||||
if ( !$seen_error ) {
|
|
||||||
warn '*** See documenation for more information.', $/;
|
|
||||||
$seen_error = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
|
|
||||||
# split out port from end of connect string
|
|
||||||
# could have an invalid IPv6 address here, but the connect
|
|
||||||
# method will warn if it cannot connect anyhow
|
|
||||||
# However, this also catchs IPv4 addresses, possibly with ports
|
|
||||||
( $server, $port )
|
|
||||||
= $connect_string =~ m/^([\w%.-]+)(?::(\d+))?$/xsm;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$port ||= defined $options{port} ? $options{port} : q{};
|
|
||||||
$username ||= q{};
|
|
||||||
|
|
||||||
logmsg( 3, "username=$username, server=$server, port=$port" );
|
|
||||||
|
|
||||||
return ( $username, $server, $port );
|
|
||||||
}
|
|
||||||
|
|
||||||
sub open_client_windows(@) {
|
sub open_client_windows(@) {
|
||||||
foreach (@_) {
|
foreach (@_) {
|
||||||
next unless ($_);
|
next unless ($_);
|
||||||
|
@ -1053,11 +986,12 @@ sub open_client_windows(@) {
|
||||||
my $server_object = App::ClusterSSH::Host->parse_host_string($_);
|
my $server_object = App::ClusterSSH::Host->parse_host_string($_);
|
||||||
|
|
||||||
my $username = $server_object->get_username();
|
my $username = $server_object->get_username();
|
||||||
|
$username = $config{user} if ( $config{user} );
|
||||||
my $port = $server_object->get_port();
|
my $port = $server_object->get_port();
|
||||||
|
$port = $config{port} if ( $config{port} );
|
||||||
my $server = $server_object->get_hostname();
|
my $server = $server_object->get_hostname();
|
||||||
my $master = $server_object->get_master();
|
my $master = $server_object->get_master();
|
||||||
|
|
||||||
#my ( $username, $server, $port ) = split_hostname($_);
|
|
||||||
my $given_server_name = $server_object->get_givenname();
|
my $given_server_name = $server_object->get_givenname();
|
||||||
|
|
||||||
# see if we can find the hostname - if not, drop it
|
# see if we can find the hostname - if not, drop it
|
||||||
|
@ -1075,6 +1009,8 @@ sub open_client_windows(@) {
|
||||||
#next; # Debian bug 499935 - ignore warnings about hostname resolution
|
#next; # Debian bug 499935 - ignore warnings about hostname resolution
|
||||||
}
|
}
|
||||||
|
|
||||||
|
logmsg( 3, "username=$username, server=$server, port=$port" );
|
||||||
|
|
||||||
my $color = '';
|
my $color = '';
|
||||||
if ( $config{terminal_colorize} ) {
|
if ( $config{terminal_colorize} ) {
|
||||||
my $c = pick_color($server);
|
my $c = pick_color($server);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue