| 1 | package Net::SSH::Any::OS::_Base; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | 3 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 3 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||
| 6 | 3 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | 3 | our @CARP_NOT = ('Net::SSH::Any::Backend::_Cmd'); | |||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||
| 9 | 3 | ▶ | use POSIX (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | 3 | ▶ | use Net::SSH::Any::Util qw($debug _debug _array_or_scalar_to_list); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | 3 | ▶ | use Net::SSH::Any::Constants qw(:error); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||
| 13 | 0 | ▶ | sub loaded { 1 } # helper method to ensure the module has been correctly loaded | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
loaded: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||
| 15 | 0 | ▶ | sub setenv { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
setenv: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 16 | 0 | my ($any, $key, $value) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 17 | # FIXME: this fails on threaded perls on Windows. | ||||||||||||||||||||||||||||||||||||||||||
| 18 | 0 | $ENV{$key} = $value; | |||||||||||||||||||||||||||||||||||||||||
| 19 | 0 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 20 | } | ||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||
| 22 | 0 | ▶ | sub pty { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pty: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 23 | 0 | my $any = shift; | |||||||||||||||||||||||||||||||||||||||||
| 24 | 0 | ▶ | $any->_load_module('IO::Pty') or return; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 25 | 0 | IO::Pty->new; | |||||||||||||||||||||||||||||||||||||||||
| 26 | } | ||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||
| 28 | 0 | ▶ | sub export_handler { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
export_handler: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 29 | 0 | my ($any, $file) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 30 | 0 | my $fn = fileno $file; | |||||||||||||||||||||||||||||||||||||||||
| 31 | 0 | ▶ | return $fn if $fn >= 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 32 | () | ||||||||||||||||||||||||||||||||||||||||||
| 33 | 0 | } | |||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||
| 35 | 0 | ▶ | sub set_file_inherit_flag { 1 } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_file_inherit_flag: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||
| 37 | 0 | ▶ | sub has_working_socketpair { } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
has_working_socketpair: not called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||
| 39 | 0 | ▶ | sub io3_check_and_clean_data { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
io3_check_and_clean_data: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 40 | 0 | my ($any, $in, $data) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 41 | 0 | ▶ | my @data = grep { defined and length } _array_or_scalar_to_list $data; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
defined $_ && length $_
MC/DC0%0/2
defined $_ && length $_
defined $_
length $_
Truth table0%0/3
A && B
A= defined $_B= length $_
| |||||||||||||||||||||||||||||||||||||||||||
| 42 | 0 | ▶ | if (@data and not $in) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
@data and not $in
MC/DC0%0/2
@data and not $in
@data
not $in
Truth table0%0/3
A and not(B)
A= @dataB= not $in
| |||||||||||||||||||||||||||||||||||||||||||
| 43 | 0 | croak "remote input channel is not defined but data is available for sending" | |||||||||||||||||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||||||||||||||||
| 45 | \@data | ||||||||||||||||||||||||||||||||||||||||||
| 46 | 0 | } | |||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||
| 48 | 5 | ▶ | sub current_user { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
current_user: called CC=2 SCAR=7.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 49 | 5 | my $any = shift; | |||||||||||||||||||||||||||||||||||||||||
| 50 | 5 | local ($SIG{__DIE__}, $@); | |||||||||||||||||||||||||||||||||||||||||
| 51 | 0 | ▶ | eval { (getpwuid $<)[0] } // eval { getlogin() } | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
eval {
do {
(getpwuid $<)[0]
}
} // eval {
do {
getlogin
}
}
MC/DC0%0/2
eval {
do {
(getpwuid $<)[0]
}
} // eval {
do {
getlogin
}
}
eval {
do {
(getpwuid $<)[0]
}
}
eval {
do {
getlogin
}
}
Truth table33%1/3
A // B
A= eval {
do {
(getpwuid $<)[0]
}
}B= eval {
do {
getlogin
}
}
| |||||||||||||||||||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||
| 54 | 0 | ▶ | sub interactive_login { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
interactive_login: not called CC=40 SCAR=74.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 55 | 0 | my ($any, $pty, $proc) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 56 | 0 | my $opts = $any->{be_opts}; # FIXME. This shouldn't be here! | |||||||||||||||||||||||||||||||||||||||||
| 57 | 0 | my $user = $opts->{user}; | |||||||||||||||||||||||||||||||||||||||||
| 58 | 0 | my $password = $opts->{password}; | |||||||||||||||||||||||||||||||||||||||||
| 59 | 0 | my $password_prompt = $opts->{password_prompt}; | |||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | my $asks_username_at_login = $opts->{asks_username_at_login}; | |||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | ▶ | if (defined $password_prompt) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | ▶ | unless (ref $password_prompt eq 'Regexp') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | $password_prompt = quotemeta $password_prompt; | |||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | $password_prompt = qr/$password_prompt\s*$/i; | |||||||||||||||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | ▶ | if ($asks_username_at_login) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 70 | 0 | ▶ | croak "ask_username_at_login set but user was not given" unless defined $user; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 71 | 0 | ▶ | croak "ask_username_at_login set can not be used with a custom password prompt" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 72 | if defined $password_prompt; | ||||||||||||||||||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | local ($ENV{SSH_ASKPASS}, $ENV{SSH_AUTH_SOCK}); | |||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||
| 77 | 0 | my $rv = ''; | |||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | vec($rv, fileno($pty), 1) = 1; | |||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | my $buffer = ''; | |||||||||||||||||||||||||||||||||||||||||
| 80 | 0 | my $at = 0; | |||||||||||||||||||||||||||||||||||||||||
| 81 | 0 | my $password_sent; | |||||||||||||||||||||||||||||||||||||||||
| 82 | 0 | my $start_time = time; | |||||||||||||||||||||||||||||||||||||||||
| 83 | 0 | while(1) { | |||||||||||||||||||||||||||||||||||||||||
| 84 | 0 | ▶ | if ($any->{_timeout}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 85 | 0 | ▶ | $debug and $debug & 1024 and _debug "checking timeout, max: $any->{_timeout}, ellapsed: " . (time - $start_time); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$Net::SSH::Any::OS::_Base::debug and $Net::SSH::Any::OS::_Base::debug & 1024
MC/DC0%0/2
$Net::SSH::Any::OS::_Base::debug and $Net::SSH::Any::OS::_Base::debug & 1024
$Net::SSH::Any::OS::_Base::debug
$Net::SSH::Any::OS::_Base::debug & 1024
Truth table0%0/3
A and B
A= $Net::SSH::Any::OS::_Base::debugB= $Net::SSH::Any::OS::_Base::debug & 1024
| |||||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | ▶ | if (time - $start_time > $any->{_timeout}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | $any->_set_error(SSHA_TIMEOUT_ERROR, "timed out while login"); | |||||||||||||||||||||||||||||||||||||||||
| 88 | 0 | $any->_wait_ssh_proc($proc, 0, 1); | |||||||||||||||||||||||||||||||||||||||||
| 89 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||||||||||
| 93 | 0 | ▶ | unless ($any->_os_check_proc($proc)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 94 | 0 | my $err = ($proc->{rc} >> 8); | |||||||||||||||||||||||||||||||||||||||||
| 95 | 0 | $any->_set_error(SSHA_CONNECTION_ERROR, | |||||||||||||||||||||||||||||||||||||||||
| 96 | "slave process exited unexpectedly with error code $err"); | ||||||||||||||||||||||||||||||||||||||||||
| 97 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||
| 100 | 0 | ▶ | $debug and $debug & 1024 and _debug "waiting for data from the pty to become available"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$Net::SSH::Any::OS::_Base::debug and $Net::SSH::Any::OS::_Base::debug & 1024
MC/DC0%0/2
$Net::SSH::Any::OS::_Base::debug and $Net::SSH::Any::OS::_Base::debug & 1024
$Net::SSH::Any::OS::_Base::debug
$Net::SSH::Any::OS::_Base::debug & 1024
Truth table0%0/3
A and B
A= $Net::SSH::Any::OS::_Base::debugB= $Net::SSH::Any::OS::_Base::debug & 1024
| |||||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||
| 102 | 0 | my $rv1 = $rv; | |||||||||||||||||||||||||||||||||||||||||
| 103 | 0 | ▶ | select($rv1, undef, undef, 1) > 0 or next; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 104 | 0 | ▶ | if (my $bytes = sysread($pty, $buffer, 4096, length $buffer)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 105 | 0 | ▶ | $debug and $debug & 1024 and _debug "$bytes bytes readed from pty"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$Net::SSH::Any::OS::_Base::debug and $Net::SSH::Any::OS::_Base::debug & 1024
MC/DC0%0/2
$Net::SSH::Any::OS::_Base::debug and $Net::SSH::Any::OS::_Base::debug & 1024
$Net::SSH::Any::OS::_Base::debug
$Net::SSH::Any::OS::_Base::debug & 1024
Truth table0%0/3
A and B
A= $Net::SSH::Any::OS::_Base::debugB= $Net::SSH::Any::OS::_Base::debug & 1024
| |||||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | ▶ | if ($buffer =~ /^The authenticity of host/mi or | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$buffer =~ /^The authenticity of host/im or $buffer =~ /^Warning: the \S+ host key for/im
MC/DC0%0/2
$buffer =~ /^The authenticity of host/im or $buffer =~ /^Warning: the \S+ host key for/im
$buffer =~ /^The authenticity of host/im
$buffer =~ /^Warning: the \S+ host key for/im
Truth table0%0/3
A or B
A= $buffer =~ /^The authenticity of host/imB= $buffer =~ /^Warning: the \S+ host key for/im
| |||||||||||||||||||||||||||||||||||||||||||
| 108 | $buffer =~ /^Warning: the \S+ host key for/mi) { | ||||||||||||||||||||||||||||||||||||||||||
| 109 | 0 | $any->_set_error(SSHA_CONNECTION_ERROR, | |||||||||||||||||||||||||||||||||||||||||
| 110 | "the authenticity of the target host can't be established, " . | ||||||||||||||||||||||||||||||||||||||||||
| 111 | "the remote host public key is probably not present on the " . | ||||||||||||||||||||||||||||||||||||||||||
| 112 | "'~/.ssh/known_hosts' file"); | ||||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | $any->_wait_ssh_proc($proc, 0, 1); | |||||||||||||||||||||||||||||||||||||||||
| 114 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 115 | } | ||||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | ▶ | if ($password_sent) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 117 | 0 | ▶ | $debug and $debug & 1024 and _debug "looking for password ok"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$Net::SSH::Any::OS::_Base::debug and $Net::SSH::Any::OS::_Base::debug & 1024
MC/DC0%0/2
$Net::SSH::Any::OS::_Base::debug and $Net::SSH::Any::OS::_Base::debug & 1024
$Net::SSH::Any::OS::_Base::debug
$Net::SSH::Any::OS::_Base::debug & 1024
Truth table0%0/3
A and B
A= $Net::SSH::Any::OS::_Base::debugB= $Net::SSH::Any::OS::_Base::debug & 1024
| |||||||||||||||||||||||||||||||||||||||||||
| 118 | 0 | ▶ | last if substr($buffer, $at) =~ /\n$/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||||||||||||||||
| 120 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 121 | 0 | ▶ | $debug and $debug & 1024 and _debug "looking for user/password prompt"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$Net::SSH::Any::OS::_Base::debug and $Net::SSH::Any::OS::_Base::debug & 1024
MC/DC0%0/2
$Net::SSH::Any::OS::_Base::debug and $Net::SSH::Any::OS::_Base::debug & 1024
$Net::SSH::Any::OS::_Base::debug
$Net::SSH::Any::OS::_Base::debug & 1024
Truth table0%0/3
A and B
A= $Net::SSH::Any::OS::_Base::debugB= $Net::SSH::Any::OS::_Base::debug & 1024
| |||||||||||||||||||||||||||||||||||||||||||
| 122 | 0 | ▶ | my $re = ( defined $password_prompt | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 123 | ? $password_prompt | ||||||||||||||||||||||||||||||||||||||||||
| 124 | : qr/(user|name|login)?[:?]\s*$/i ); | ||||||||||||||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||||||||||||||
| 126 | 0 | ▶ | $debug and $debug & 1024 and _debug "matching against $re"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$Net::SSH::Any::OS::_Base::debug and $Net::SSH::Any::OS::_Base::debug & 1024
MC/DC0%0/2
$Net::SSH::Any::OS::_Base::debug and $Net::SSH::Any::OS::_Base::debug & 1024
$Net::SSH::Any::OS::_Base::debug
$Net::SSH::Any::OS::_Base::debug & 1024
Truth table0%0/3
A and B
A= $Net::SSH::Any::OS::_Base::debugB= $Net::SSH::Any::OS::_Base::debug & 1024
| |||||||||||||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||||||||||||
| 128 | 0 | ▶ | if (substr($buffer, $at) =~ $re) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 129 | 0 | ▶ | if ($asks_username_at_login and | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$asks_username_at_login and $asks_username_at_login ne "auto" || defined $1
$asks_username_at_login ne "auto" or defined $1
MC/DC0%0/3
$asks_username_at_login and $asks_username_at_login ne "auto" || defined $1
$asks_username_at_login
$asks_username_at_login ne "auto"
defined $1
Truth table0%0/4
A and B or C
A= $asks_username_at_loginB= $asks_username_at_login ne "auto"C= defined $1
| |||||||||||||||||||||||||||||||||||||||||||
| 130 | ($asks_username_at_login ne 'auto' or defined $1)) { | ||||||||||||||||||||||||||||||||||||||||||
| 131 | 0 | ▶ | $debug and $debug & 1024 and _debug "sending username"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$Net::SSH::Any::OS::_Base::debug and $Net::SSH::Any::OS::_Base::debug & 1024
MC/DC0%0/2
$Net::SSH::Any::OS::_Base::debug and $Net::SSH::Any::OS::_Base::debug & 1024
$Net::SSH::Any::OS::_Base::debug
$Net::SSH::Any::OS::_Base::debug & 1024
Truth table0%0/3
A and B
A= $Net::SSH::Any::OS::_Base::debugB= $Net::SSH::Any::OS::_Base::debug & 1024
| |||||||||||||||||||||||||||||||||||||||||||
| 132 | 0 | print $pty "$user\n"; | |||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | undef $asks_username_at_login; | |||||||||||||||||||||||||||||||||||||||||
| 134 | } | ||||||||||||||||||||||||||||||||||||||||||
| 135 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | ▶ | $debug and $debug & 1024 and _debug "sending password"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$Net::SSH::Any::OS::_Base::debug and $Net::SSH::Any::OS::_Base::debug & 1024
MC/DC0%0/2
$Net::SSH::Any::OS::_Base::debug and $Net::SSH::Any::OS::_Base::debug & 1024
$Net::SSH::Any::OS::_Base::debug
$Net::SSH::Any::OS::_Base::debug & 1024
Truth table0%0/3
A and B
A= $Net::SSH::Any::OS::_Base::debugB= $Net::SSH::Any::OS::_Base::debug & 1024
| |||||||||||||||||||||||||||||||||||||||||||
| 137 | 0 | print $pty "$password\n"; | |||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | $password_sent = 1; | |||||||||||||||||||||||||||||||||||||||||
| 139 | } | ||||||||||||||||||||||||||||||||||||||||||
| 140 | 0 | $at = length $buffer; | |||||||||||||||||||||||||||||||||||||||||
| 141 | } | ||||||||||||||||||||||||||||||||||||||||||
| 142 | } | ||||||||||||||||||||||||||||||||||||||||||
| 143 | } | ||||||||||||||||||||||||||||||||||||||||||
| 144 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | ▶ | $debug and $debug & 1024 and _debug "no data available from pty, delaying until next read"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$Net::SSH::Any::OS::_Base::debug and $Net::SSH::Any::OS::_Base::debug & 1024
MC/DC0%0/2
$Net::SSH::Any::OS::_Base::debug and $Net::SSH::Any::OS::_Base::debug & 1024
$Net::SSH::Any::OS::_Base::debug
$Net::SSH::Any::OS::_Base::debug & 1024
Truth table0%0/3
A and B
A= $Net::SSH::Any::OS::_Base::debugB= $Net::SSH::Any::OS::_Base::debug & 1024
| |||||||||||||||||||||||||||||||||||||||||||
| 146 | 0 | sleep 0.02; | |||||||||||||||||||||||||||||||||||||||||
| 147 | } | ||||||||||||||||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||||||||||||||||
| 149 | } | ||||||||||||||||||||||||||||||||||||||||||
| 150 | 0 | ▶ | $debug and $debug & 1024 and _debug "password authentication done"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$Net::SSH::Any::OS::_Base::debug and $Net::SSH::Any::OS::_Base::debug & 1024
MC/DC0%0/2
$Net::SSH::Any::OS::_Base::debug and $Net::SSH::Any::OS::_Base::debug & 1024
$Net::SSH::Any::OS::_Base::debug
$Net::SSH::Any::OS::_Base::debug & 1024
Truth table0%0/3
A and B
A= $Net::SSH::Any::OS::_Base::debugB= $Net::SSH::Any::OS::_Base::debug & 1024
| |||||||||||||||||||||||||||||||||||||||||||
| 151 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 152 | } | ||||||||||||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||||||||||||
| 154 | 40 | ▶ | sub validate_cmd { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
validate_cmd: called CC=8 SCAR=30.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 155 | 40 | my ($any, $cmd) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 156 | 40 | ▶ | if (defined $cmd and -x $cmd and -f $cmd) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%3/6
defined $cmd and -x $cmd and -f $cmd
defined $cmd and -x $cmd
MC/DC0%0/3
defined $cmd and -x $cmd and -f $cmd
defined $cmd
-x $cmd
-f $cmd
Truth table50%2/4
A and B and C
A= defined $cmdB= -x $cmdC= -f $cmd
| |||||||||||||||||||||||||||||||||||||||||||
| 157 | 0 | ▶ | $debug and $debug & 1024 and _debug "file $cmd found to be executable"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$Net::SSH::Any::OS::_Base::debug and $Net::SSH::Any::OS::_Base::debug & 1024
MC/DC0%0/2
$Net::SSH::Any::OS::_Base::debug and $Net::SSH::Any::OS::_Base::debug & 1024
$Net::SSH::Any::OS::_Base::debug
$Net::SSH::Any::OS::_Base::debug & 1024
Truth table0%0/3
A and B
A= $Net::SSH::Any::OS::_Base::debugB= $Net::SSH::Any::OS::_Base::debug & 1024
| |||||||||||||||||||||||||||||||||||||||||||
| 158 | 0 | return $cmd; | |||||||||||||||||||||||||||||||||||||||||
| 159 | } | ||||||||||||||||||||||||||||||||||||||||||
| 160 | 40 | ▶ | $debug and $debug & 1024 and _debug "file ", $cmd, " is not executable or not found"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$Net::SSH::Any::OS::_Base::debug and $Net::SSH::Any::OS::_Base::debug & 1024
MC/DC0%0/2
$Net::SSH::Any::OS::_Base::debug and $Net::SSH::Any::OS::_Base::debug & 1024
$Net::SSH::Any::OS::_Base::debug
$Net::SSH::Any::OS::_Base::debug & 1024
Truth table33%1/3
A and B
A= $Net::SSH::Any::OS::_Base::debugB= $Net::SSH::Any::OS::_Base::debug & 1024
| |||||||||||||||||||||||||||||||||||||||||||
| 161 | () | ||||||||||||||||||||||||||||||||||||||||||
| 162 | 40 | } | |||||||||||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||||||||||||
| 164 | 0 | ▶ | sub find_cmd_by_app {} | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
find_cmd_by_app: not called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||||||||||||||||
| 166 | 0 | ▶ | sub wait_proc { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
wait_proc: not called CC=11 SCAR=48.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 167 | 0 | my ($any, $proc, $timeout, $force_kill) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 168 | 0 | my $delay = 0.1; | |||||||||||||||||||||||||||||||||||||||||
| 169 | 0 | my $deadline; | |||||||||||||||||||||||||||||||||||||||||
| 170 | 0 | ▶ | $deadline = time + $timeout | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$force_kill and defined $timeout
MC/DC0%0/2
$force_kill and defined $timeout
$force_kill
defined $timeout
Truth table0%0/3
A and B
A= $force_killB= defined $timeout
| |||||||||||||||||||||||||||||||||||||||||||
| 171 | if $force_kill and defined $timeout; | ||||||||||||||||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||||||||||||||||
| 173 | 0 | while (1) { | |||||||||||||||||||||||||||||||||||||||||
| 174 | 0 | ▶ | if (defined $deadline) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 175 | 0 | ▶ | $any->_os_check_proc($proc) or last; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 176 | 0 | my $remaining = $deadline - time; | |||||||||||||||||||||||||||||||||||||||||
| 177 | 0 | ▶ | if ($remaining <= 0) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 178 | 0 | ▶ | $debug and $debug & 1024 and _debug "killing SSH slave, pid: $proc->{pid}"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$Net::SSH::Any::OS::_Base::debug and $Net::SSH::Any::OS::_Base::debug & 1024
MC/DC0%0/2
$Net::SSH::Any::OS::_Base::debug and $Net::SSH::Any::OS::_Base::debug & 1024
$Net::SSH::Any::OS::_Base::debug
$Net::SSH::Any::OS::_Base::debug & 1024
Truth table0%0/3
A and B
A= $Net::SSH::Any::OS::_Base::debugB= $Net::SSH::Any::OS::_Base::debug & 1024
| |||||||||||||||||||||||||||||||||||||||||||
| 179 | 0 | kill TERM => $proc->{pid}; | |||||||||||||||||||||||||||||||||||||||||
| 180 | 0 | $any->_or_set_error(SSHA_TIMEOUT_ERROR, "slave command timed out"); | |||||||||||||||||||||||||||||||||||||||||
| 181 | } | ||||||||||||||||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||||||||||||||||
| 183 | 0 | ▶ | $debug and $debug & 1024 and | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$Net::SSH::Any::OS::_Base::debug and $Net::SSH::Any::OS::_Base::debug & 1024
MC/DC0%0/2
$Net::SSH::Any::OS::_Base::debug and $Net::SSH::Any::OS::_Base::debug & 1024
$Net::SSH::Any::OS::_Base::debug
$Net::SSH::Any::OS::_Base::debug & 1024
Truth table0%0/3
A and B
A= $Net::SSH::Any::OS::_Base::debugB= $Net::SSH::Any::OS::_Base::debug & 1024
| |||||||||||||||||||||||||||||||||||||||||||
| 184 | _debug "waiting for slave cmd, timeout: $timeout, remaining: $remaining, delay: $delay"; | ||||||||||||||||||||||||||||||||||||||||||
| 185 | } | ||||||||||||||||||||||||||||||||||||||||||
| 186 | # There is a (harmless) race condition here. We try to | ||||||||||||||||||||||||||||||||||||||||||
| 187 | # minimize it by keeping the 'waitpid' and 'select' calls | ||||||||||||||||||||||||||||||||||||||||||
| 188 | # together and limiting the sleep time to 1s max: | ||||||||||||||||||||||||||||||||||||||||||
| 189 | 0 | ▶ | $any->_os_check_proc($proc, !defined($deadline)) or last; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 190 | 0 | select(undef, undef, undef, $delay); | |||||||||||||||||||||||||||||||||||||||||
| 191 | } | ||||||||||||||||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||||||||||||||||
| 193 | 0 | not $any->{_error}; | |||||||||||||||||||||||||||||||||||||||||
| 194 | } | ||||||||||||||||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||||||||||||||||
| 196 | 0 | ▶ | sub native_rc { undef } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
native_rc: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||||||||||||||||
| 198 | # $any->_os_check_proc($proc, $wait) | ||||||||||||||||||||||||||||||||||||||||||
| 199 | # Checks wether the given process is still running. | ||||||||||||||||||||||||||||||||||||||||||
| 200 | # Args: | ||||||||||||||||||||||||||||||||||||||||||
| 201 | # $wait: if true, waits until the process exits | ||||||||||||||||||||||||||||||||||||||||||
| 202 | 0 | ▶ | sub check_proc { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
check_proc: not called CC=10 SCAR=47.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 203 | 0 | my ($any, $proc, $wait) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 204 | 0 | my $pid = $proc->{pid}; | |||||||||||||||||||||||||||||||||||||||||
| 205 | 0 | $? = 0; | |||||||||||||||||||||||||||||||||||||||||
| 206 | 0 | ▶ | my $r = CORE::waitpid($pid, ($wait ? 0 : POSIX::WNOHANG())); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||||||||||||||||
| 208 | # FIXME: we assume that all POSIX OSs return 0 when the process is | ||||||||||||||||||||||||||||||||||||||||||
| 209 | # still running. That may be wrong! | ||||||||||||||||||||||||||||||||||||||||||
| 210 | 0 | ▶ | if ($r == $pid) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 211 | 0 | $proc->{rc} = $?; | |||||||||||||||||||||||||||||||||||||||||
| 212 | 0 | ▶ | my $native_rc = $any->_os_native_rc($proc) // $?; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$any->_os_native_rc($proc) // $?
MC/DC0%0/2
$any->_os_native_rc($proc) // $?
$any->_os_native_rc($proc)
$?
Truth table0%0/3
A // B
A= $any->_os_native_rc($proc)B= $?
| |||||||||||||||||||||||||||||||||||||||||||
| 213 | 0 | ▶ | $debug and $debug & 1024 and _debug "process $pid exited with code $?, native: $native_rc"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$Net::SSH::Any::OS::_Base::debug and $Net::SSH::Any::OS::_Base::debug & 1024
MC/DC0%0/2
$Net::SSH::Any::OS::_Base::debug and $Net::SSH::Any::OS::_Base::debug & 1024
$Net::SSH::Any::OS::_Base::debug
$Net::SSH::Any::OS::_Base::debug & 1024
Truth table0%0/3
A and B
A= $Net::SSH::Any::OS::_Base::debugB= $Net::SSH::Any::OS::_Base::debug & 1024
| |||||||||||||||||||||||||||||||||||||||||||
| 214 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 215 | } | ||||||||||||||||||||||||||||||||||||||||||
| 216 | elsif ($r <= 0) { | ||||||||||||||||||||||||||||||||||||||||||
| 217 | 0 | ▶ | if ($r < 0) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 218 | 0 | ▶ | if ($! != Errno::EINTR()) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 219 | 0 | ▶ | if ($! == Errno::ECHILD()) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 220 | 0 | $any->_or_set_error(SSHA_REMOTE_CMD_ERROR, "child process $pid does not exist", $!); | |||||||||||||||||||||||||||||||||||||||||
| 221 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 222 | } | ||||||||||||||||||||||||||||||||||||||||||
| 223 | 0 | _warn("Internal error: unexpected error (" . ($!+0) . | |||||||||||||||||||||||||||||||||||||||||
| 224 | ": $!) from waitpid($pid) = $r. Report it, please!"); | ||||||||||||||||||||||||||||||||||||||||||
| 225 | } | ||||||||||||||||||||||||||||||||||||||||||
| 226 | } | ||||||||||||||||||||||||||||||||||||||||||
| 227 | } | ||||||||||||||||||||||||||||||||||||||||||
| 228 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 229 | 0 | _warn("internal error: spurious process $r exited"); | |||||||||||||||||||||||||||||||||||||||||
| 230 | } | ||||||||||||||||||||||||||||||||||||||||||
| 231 | 0 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 232 | } | ||||||||||||||||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||||||||||||||||
| 234 | 3 | 1; | |||||||||||||||||||||||||||||||||||||||||