| 1 | #################################################################### | ||||||||||||||||||||||||||||||||||
| 2 | # | ||||||||||||||||||||||||||||||||||
| 3 | # This file was generated using XDR::Parse version v1.0.1 | ||||||||||||||||||||||||||||||||||
| 4 | # and LibVirt version v12.9.0 | ||||||||||||||||||||||||||||||||||
| 5 | # | ||||||||||||||||||||||||||||||||||
| 6 | # Don't edit this file, use the source template instead | ||||||||||||||||||||||||||||||||||
| 7 | # | ||||||||||||||||||||||||||||||||||
| 8 | # ANY CHANGES HERE WILL BE LOST ! | ||||||||||||||||||||||||||||||||||
| 9 | # | ||||||||||||||||||||||||||||||||||
| 10 | #################################################################### | ||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||
| 13 | 1 | ▶ | use v5.26; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 14 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 15 | 1 | ▶ | use experimental 'signatures'; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 16 | 1 | ▶ | use Future::AsyncAwait; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 17 | 1 | ▶ | use Object::Pad ':experimental(inherit_field)'; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||
| 19 | class Sys::Async::Virt::Connection::SSH v0.6.9; | ||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||
| 21 | 1 | inherit Sys::Async::Virt::Connection::Process; | |||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||
| 23 | 1 | ▶ | use Carp qw(croak); | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 24 | 1 | ▶ | use Log::Any qw($log); | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||
| 26 | 1 | ▶ | use Protocol::Sys::Virt::UNIXSocket v12.9.0; # imports socket_path | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 27 | 1 | ▶ | use Protocol::Sys::Virt::URI v12.9.0; # imports parse_url | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||
| 29 | field $_socket :reader :param = undef; | ||||||||||||||||||||||||||||||||||
| 30 | 0 | ▶ | field $_readonly :reader :param; | ||||||||||||||||||||||||||||||||
|
Subroutine
readonly: not called CC=1 SCAR=2.6
Subroutine
socket: not called CC=1 SCAR=2.6
Pod
undocumented
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||
| 32 | 0 | ▶ | sub shell_escape($val) { | ||||||||||||||||||||||||||||||||
|
Subroutine
shell_escape: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 33 | 0 | ▶ | if ($val !~ m/[\s!"'`$<>#&*?;\\\[\]{}()~|^]/) { # no shell chars | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 34 | 0 | return $val; | |||||||||||||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||
| 37 | 0 | return (q|'| . ($val =~ s/'/'\\''/gr) . q|'|); | |||||||||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||
| 40 | 1 | my $nc_proxy = | |||||||||||||||||||||||||||||||||
| 41 | q{if %1$s -q 2>&1 | grep "requires an argument" >/dev/null 2>&1; } . | ||||||||||||||||||||||||||||||||||
| 42 | q{then A=-q0; } . | ||||||||||||||||||||||||||||||||||
| 43 | q{else A=; } . | ||||||||||||||||||||||||||||||||||
| 44 | q{fi; } . | ||||||||||||||||||||||||||||||||||
| 45 | q{%1$s $A -U %2$s}; | ||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||
| 47 | 1 | my $native_proxy = | |||||||||||||||||||||||||||||||||
| 48 | q{virt-ssh-helper %s}; | ||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||
| 50 | 1 | my $auto_proxy = | |||||||||||||||||||||||||||||||||
| 51 | q{if which virt-ssh-helper >/dev/null 2>&1; } . | ||||||||||||||||||||||||||||||||||
| 52 | q{then %s; } . | ||||||||||||||||||||||||||||||||||
| 53 | q{else %s; } . | ||||||||||||||||||||||||||||||||||
| 54 | q{fi}; | ||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||
| 56 | 0 | ▶ | method _command( $url ) { | ||||||||||||||||||||||||||||||||
|
Subroutine
_command: not called CC=15 SCAR=54.8
| |||||||||||||||||||||||||||||||||||
| 57 | 0 | my %c = parse_url( $url ); | |||||||||||||||||||||||||||||||||
| 58 | 0 | my @args = ('-e', 'none'); | |||||||||||||||||||||||||||||||||
| 59 | 0 | ▶ | push @args, ('-p', $c{port}) if $c{port}; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 60 | 0 | ▶ | push @args, ('-l', $c{username}) if $c{username}; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 61 | 0 | ▶ | push @args, ('-i', $c{query}->{keyfile}) if $c{query}->{keyfile}; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 62 | 0 | ▶ | push @args, ('-o', 'StrictHostKeyChecking=no') if $c{query}->{no_verify}; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 63 | 0 | ▶ | push @args, ('-T') if $c{query}->{no_tty}; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||
| 65 | 0 | my $remote_cmd; | |||||||||||||||||||||||||||||||||
| 66 | 0 | ▶ | my $proxy_mode = $c{query}->{proxy} // 'auto'; | ||||||||||||||||||||||||||||||||
|
Condition0%0/2
$c{"query"}{"proxy"} // "auto"
MC/DC0%0/1
$c{"query"}{"proxy"} // "auto"
$c{"query"}{"proxy"}
Truth table0%0/2
A
A= $c{"query"}{"proxy"}
| |||||||||||||||||||||||||||||||||||
| 67 | my $socket_path = $_socket // $c{query}->{socket} // | ||||||||||||||||||||||||||||||||||
| 68 | socket_path(readonly => $_readonly, | ||||||||||||||||||||||||||||||||||
| 69 | hypervisor => $c{hypervisor}, | ||||||||||||||||||||||||||||||||||
| 70 | mode => $c{query}->{mode}, | ||||||||||||||||||||||||||||||||||
| 71 | 0 | ▶ | type => $c{type}); | ||||||||||||||||||||||||||||||||
|
Condition0%0/6
($_socket // $c{"query"}{"socket"}) // socket_path("readonly", $_readonly, "hypervisor", $c{"hypervisor"}, "mode", $c{"query"}{"mode"}, "type", $c{"type"})
$_socket // $c{"query"}{"socket"}
MC/DC0%0/3
($_socket // $c{"query"}{"socket"}) // socket_path("readonly", $_readonly, "hypervisor", $c{"hypervisor"}, "mode", $c{"query"}{"mode"}, "type", $c{"type"})
$_socket
$c{"query"}{"socket"}
socket_path("readonly", $_readonly, "hypervisor", $c{"hypervisor"}, "mode", $c{"query"}{"mode"}, "type", $c{"type"})
Truth table0%0/4
A // B // C
A= $_socketB= $c{"query"}{"socket"}C= socket_path("readonly", $_readonly, "hypervisor", $c{"hypervisor"}, "mode", $c{"query"}{"mode"}, "type", $c{"type"})
| |||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||
| 73 | my $nc_command = sprintf($nc_proxy, | ||||||||||||||||||||||||||||||||||
| 74 | 0 | ▶ | $c{query}->{netcat} // 'nc', | ||||||||||||||||||||||||||||||||
|
Condition0%0/2
$c{"query"}{"netcat"} // "nc"
MC/DC0%0/1
$c{"query"}{"netcat"} // "nc"
$c{"query"}{"netcat"}
Truth table0%0/2
A
A= $c{"query"}{"netcat"}
| |||||||||||||||||||||||||||||||||||
| 75 | $socket_path); | ||||||||||||||||||||||||||||||||||
| 76 | 0 | my $native_command = 'virt-ssh-helper '; | |||||||||||||||||||||||||||||||||
| 77 | 0 | ▶ | $native_command .= '-r ' if $_readonly; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||
| 79 | # $c{proxy} is the URL to use on the proxy | ||||||||||||||||||||||||||||||||||
| 80 | 0 | $native_command .= shell_escape($c{proxy}); | |||||||||||||||||||||||||||||||||
| 81 | 0 | ▶ | if ($proxy_mode eq 'netcat') { | ||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||
| 82 | 0 | $remote_cmd = sprintf(q|sh -c %s|, shell_escape($nc_command)); | |||||||||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||||||||
| 84 | elsif ($proxy_mode eq 'native') { | ||||||||||||||||||||||||||||||||||
| 85 | 0 | $remote_cmd = $native_command; | |||||||||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||||||||
| 87 | elsif ($proxy_mode eq 'auto') { | ||||||||||||||||||||||||||||||||||
| 88 | 0 | $remote_cmd = sprintf(q|sh -c %s|, | |||||||||||||||||||||||||||||||||
| 89 | shell_escape(sprintf($auto_proxy, | ||||||||||||||||||||||||||||||||||
| 90 | $native_command, | ||||||||||||||||||||||||||||||||||
| 91 | $nc_command))); | ||||||||||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||||||||
| 93 | else { | ||||||||||||||||||||||||||||||||||
| 94 | 0 | croak $log->fatal( "Unknown proxy mode '$proxy_mode'" ); | |||||||||||||||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||
| 97 | 0 | $log->trace("SSH remote command: $remote_cmd"); | |||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||
| 99 | 0 | ▶ | my $local_cmd = $c{query}->{command} // 'ssh'; | ||||||||||||||||||||||||||||||||
|
Condition0%0/2
$c{"query"}{"command"} // "ssh"
MC/DC0%0/1
$c{"query"}{"command"} // "ssh"
$c{"query"}{"command"}
Truth table0%0/2
A
A= $c{"query"}{"command"}
| |||||||||||||||||||||||||||||||||||
| 100 | 0 | my @cmd = ($local_cmd, @args, '--', $c{host}, $remote_cmd); | |||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||
| 102 | 0 | return @cmd; | |||||||||||||||||||||||||||||||||
| 103 | 1 | } | |||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||||
| 105 | 0 | ▶ | method is_secure() { | ||||||||||||||||||||||||||||||||
|
Subroutine
is_secure: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 106 | 0 | return 1; | |||||||||||||||||||||||||||||||||
| 107 | 1 | } | |||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||
| 109 | 1 | 1; | |||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||
| 112 | __END__ | ||||||||||||||||||||||||||||||||||