Module: tools Branch: master Commit: f486603d9079ce1905e8241d4794d06180489745 URL: http://source.winehq.org/git/tools.git/?a=commit;h=f486603d9079ce1905e8241d4...
Author: Francois Gouget fgouget@codeweavers.com Date: Tue Dec 11 17:46:00 2012 +0100
testbot/TestAgent: Add global configuration options for the SSH tunneling.
This makes it possible to use other SSH keys than just id_dsa. This also makes it possible to disable SSH tunneling entirely or to hardcode the SSH tunnel to use instead of using whatever VirtURI specifies.
---
testbot/lib/WineTestBot/Config.pm | 8 ++++---- testbot/lib/WineTestBot/ConfigLocalTemplate.pl | 21 +++++++++++++++++++++ testbot/lib/WineTestBot/VMs.pm | 22 ++++++++++++---------- testbot/scripts/TestAgent | 20 +++++++++++--------- 4 files changed, 48 insertions(+), 23 deletions(-)
diff --git a/testbot/lib/WineTestBot/Config.pm b/testbot/lib/WineTestBot/Config.pm index 9a16fe6..8d96c36 100644 --- a/testbot/lib/WineTestBot/Config.pm +++ b/testbot/lib/WineTestBot/Config.pm @@ -32,8 +32,8 @@ use vars qw (@ISA @EXPORT @EXPORT_OK $UseSSL $LogDir $DataDir $BinDir $BuildTimeout $ReconfigTimeout $OverheadTimeout $TagPrefix $ProjectName $PatchesMailingList $PatchResultsEMail $LDAPServer $LDAPBindDN $LDAPSearchBase $LDAPSearchFilter - $LDAPRealNameAttribute $LDAPEMailAttribute $AgentPort - $JobPurgeDays $JobArchiveDays $WebHostName); + $LDAPRealNameAttribute $LDAPEMailAttribute $AgentPort $Tunnel + $TunnelDefaults $JobPurgeDays $JobArchiveDays $WebHostName);
require Exporter; @ISA = qw(Exporter); @@ -44,8 +44,8 @@ require Exporter; $SingleTimeout $BuildTimeout $ReconfigTimeout $OverheadTimeout $TagPrefix $ProjectName $PatchesMailingList $PatchResultsEMail $LDAPServer $LDAPBindDN $LDAPSearchBase $LDAPSearchFilter - $LDAPRealNameAttribute $LDAPEMailAttribute $AgentPort - $JobPurgeDays $JobArchiveDays $WebHostName); + $LDAPRealNameAttribute $LDAPEMailAttribute $AgentPort $Tunnel + $TunnelDefaults $JobPurgeDays $JobArchiveDays $WebHostName); @EXPORT_OK = qw($DbDataSource $DbUsername $DbPassword);
if ($::RootDir !~ m=^/=) diff --git a/testbot/lib/WineTestBot/ConfigLocalTemplate.pl b/testbot/lib/WineTestBot/ConfigLocalTemplate.pl index 06afb77..38e6a3a 100644 --- a/testbot/lib/WineTestBot/ConfigLocalTemplate.pl +++ b/testbot/lib/WineTestBot/ConfigLocalTemplate.pl @@ -83,4 +83,25 @@ $WineTestBot::Config::LDAPEMailAttribute = undef; # The port the VM agents are listening on $WineTestBot::Config::AgentPort = undef;
+# This specifies if and how to do SSH tunneling. +# - If unset then tunneling is automatic based on the VM's VirtURI setting. +# - If set to an SSH URI, then tunneling is performed using these parameters. +# - Any other setting disables SSH tunneling. In particular to disable +# tunneling for SSH VirtURIs it is recommended to set this to 'never'. +$Tunnel = undef; + +# If set this specifies the SSH tunnel parameters to be used for the +# TestAgent connection. This is mostly useful for parameters that cannot be +# specified through the SSH URI, like the key filenames. Listed below are +# the supported settings. For a full reference, see the Net::SSH2::auth() +# documentation. Note though that interactive methods are disabled. +# - username +# - password +# - publickey +# - privatekey +# - hostname +# - local_username +$WineTestBot::Config::TunnelDefaults = undef; + + 1; diff --git a/testbot/lib/WineTestBot/VMs.pm b/testbot/lib/WineTestBot/VMs.pm index a42fb12..2d1c1fd 100644 --- a/testbot/lib/WineTestBot/VMs.pm +++ b/testbot/lib/WineTestBot/VMs.pm @@ -361,17 +361,19 @@ sub _GetTunnel($) { my ($self) = @_;
- # Auto-detect the SSH settings based on the libvirt URI - my $VirtURI = $self->VirtURI; - if ($VirtURI =~ s/^[a-z]++(?:ssh|libssh2):/ssh:/) + # Use either the tunnel specified in the configuration file + # or autodetect the settings based on the VM's VirtURI setting. + my $URI = $Tunnel || $self->VirtURI; + + if ($URI =~ s/^(?:[a-z]++)?(?:ssh|libssh2):/ssh:/) { - my $URI = URI->new($VirtURI); - my $TunnelInfo = { - sshhost => $URI->host, - sshport => $URI->port, - username => $URI->userinfo, - }; - return $TunnelInfo; + my $ParsedURI = URI->new($URI); + + my %TunnelInfo = %$TunnelDefaults; + $TunnelInfo{sshhost} = $ParsedURI->host; + $TunnelInfo{sshport} = $ParsedURI->port; + $TunnelInfo{username} = $ParsedURI->userinfo; + return %TunnelInfo; }
return undef; diff --git a/testbot/scripts/TestAgent b/testbot/scripts/TestAgent index 6d241b5..f72531c 100755 --- a/testbot/scripts/TestAgent +++ b/testbot/scripts/TestAgent @@ -53,7 +53,7 @@ my ($Cmd, $Hostname, $LocalFilename, $ServerFilename, @Rm); my (@Run, $RunIn, $RunOut, $RunErr); my $SendFlags = 0; my $RunFlags = 0; -my ($Port, $ConnectTimeout, $Timeout, $Tunnel); +my ($Port, $ConnectTimeout, $Timeout, $TunnelOpt); my $Usage;
sub check_opt_val($$) @@ -95,7 +95,7 @@ while (@ARGV) } elsif ($arg eq "--tunnel") { - $Tunnel = check_opt_val($arg, $Tunnel); + $TunnelOpt = check_opt_val($arg, $TunnelOpt); } elsif ($arg eq "--sendfile-exe") { @@ -189,9 +189,9 @@ if (!defined $Usage) $Usage = 2; } $AgentPort = $Port if (defined $Port); - if (defined $Tunnel and $Tunnel !~ /^ssh:/) + if ($TunnelOpt and $TunnelOpt !~ /^ssh:/) { - error("only SSH proxies are supported\n"); + error("only SSH tunnels are supported\n"); $Usage = 2; } } @@ -239,13 +239,15 @@ if (defined $Usage) exit 0; }
+$TunnelOpt = $Tunnel if (!defined $TunnelOpt); my $TunnelInfo; -if (defined $Tunnel) +if ($TunnelOpt) { - my $URI = URI->new($Tunnel); - $TunnelInfo = {sshhost => $URI->host, - sshport => $URI->port, - username => $URI->userinfo}; + my $ParsedURI = URI->new($TunnelOpt); + %$TunnelInfo = %$TunnelDefaults; + $TunnelInfo->{sshhost} = $ParsedURI->host; + $TunnelInfo->{sshport} = $ParsedURI->port; + $TunnelInfo->{username} = $ParsedURI->userinfo; }
my $TA = TestAgent->new($Hostname, $AgentPort, $TunnelInfo);