Don't set default user name in configuration file

Setting the default username in the config file will override ssh settings, which is generally not what is wanted.  Show the option in generated config files but commented out.
This commit is contained in:
Duncan Ferguson 2013-03-08 07:58:39 +00:00
parent d187797699
commit 402f6c34a9
4 changed files with 29 additions and 12 deletions

View file

@ -1,6 +1,7 @@
????-??-?? Duncan Ferguson <duncan_ferguson@user.sf.net> - v4.02__00
????-??-?? Duncan Ferguson <duncan_ferguson@user.sf.net> - v4.01_05
- New option (-m, --unique-servers) to remove repeated servers when openeing terminals (Thanks to Oliver Meissner)
- Drop MYMETA.yml and .json files from the distribution
- Do not set default user name to prevent overriding ssh configuration
2013-02-26 Duncan Ferguson <duncan_ferguson@user.sf.net> - v4.01_04
- Fixed 'ccon' not calling the correct command (Sf bug 3605002)

View file

@ -616,7 +616,7 @@ sub open_client_windows(@) {
my $server_object = App::ClusterSSH::Host->parse_host_string($_);
my $username = $server_object->get_username();
$username = $self->config->{user} if ( $self->config->{user} );
$username = $self->config->{user} if ( !$username && $self->config->{user} );
my $port = $server_object->get_port();
$port = $self->config->{port} if ( $self->config->{port} );
my $server = $server_object->get_hostname();

View file

@ -17,8 +17,12 @@ use App::ClusterSSH::Cluster;
my $clusters;
my %old_clusters;
my @app_specific = (qw/ command title comms method /);
my %default_config = (
my @app_specific = (qw/ command title comms method /);
# list of config items to not write out when writing the default config
my @ignore_default_config = (qw/ user /);
my %default_config = (
terminal => "xterm",
terminal_args => "",
terminal_title_opt => "-T",
@ -83,7 +87,8 @@ my %default_config = (
send_menu_xml_file => $ENV{HOME} . '/.csshrc_send_menu',
user => $ENV{LOGNAME},
# don't set username here as takes precendence over ssh config
user => '',
);
sub new {
@ -220,7 +225,8 @@ sub parse_config_file {
$self->debug( 3, "Picked up clusters defined in $config_file" );
foreach my $cluster ( sort split / /, $read_config{clusters} ) {
if ( $read_config{$cluster} ) {
$clusters->register_tag( $cluster, split(/ /,$read_config{$cluster}) );
$clusters->register_tag( $cluster,
split( / /, $read_config{$cluster} ) );
$old_clusters{$cluster} = $read_config{$cluster};
delete( $read_config{$cluster} );
}
@ -322,12 +328,14 @@ sub write_user_config_file {
print $fh $_, ' ', join( ' ', $old_clusters{$_} ), $/;
}
close($fh);
} else {
}
else {
croak(
App::ClusterSSH::Exception::Config->throw(
error => $self->loc(
'Unable to write [_1]: [_2]' . $/,
'$HOME/.clusterssh/clusters', $!
'$HOME/.clusterssh/clusters',
$!
),
),
);
@ -336,7 +344,11 @@ sub write_user_config_file {
if ( open( CONFIG, ">", "$ENV{HOME}/.clusterssh/config" ) ) {
foreach ( sort( keys(%$self) ) ) {
print CONFIG "$_=$self->{$_}\n";
my $comment='';
if ( grep /$_/, @ignore_default_config ) {
$comment='#';
}
print CONFIG ${comment},$_,'=',$self->{$_},$/;
}
close(CONFIG);
warn(
@ -439,10 +451,14 @@ sub dump {
print( '# Configuration dump produced by "cssh -u"', $/ );
foreach my $key ( sort keys %$self ) {
my $comment='';
if ( grep /$key/, @app_specific ) {
next;
}
print $key, '=', $self->{$key}, $/;
if ( grep /$key/, @ignore_default_config ) {
$comment='#';
}
print $comment, $key, '=', $self->{$key}, $/;
}
$self->exit if ( !$no_exit );

View file

@ -94,7 +94,7 @@ Readonly::Hash my %default_config => {
debug => 0,
lang => 'en',
user => $ENV{LOGNAME},
user => '',
};
my %expected = %default_config;
is_deeply( $config, \%expected, 'default config is correct' );
@ -528,7 +528,7 @@ terminal_title_opt=-T
unmap_on_redraw=no
use_all_a_records=0
use_hotkeys=yes
user=} . $ENV{LOGNAME} . qq{
#user=
window_tiling=yes
window_tiling_direction=right
};