OpenSSH.pm

filter: Statementstmt 7.5% 109 / 1451 Branchbran 1.3% 15 / 1088 Conditioncond 0.4% 2 / 456 MC/DCmcdc 0.0% 0 / 270 Subroutinesub 13.4% 17 / 126 Podpod 92.0% 46 / 50 totaltotal 5.4% 189 / 3441 CC 707 SCAR 77.1
CC
707
Cov
4%
open_ex
9506.0
_master_wait
4970.0
_io3
4692.0
CRAP 2238.1
↑ Summary OpenSSH/OSTracer.pm »
1 package Net::OpenSSH;
2  
3 3 our $VERSION = '0.84';
4  
5 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 3 ▶our $debug ||= 0;
Condition50%1/2
our $debug ||= 0
l!l
03
MC/DC0%0/1
our $debug ||= 0
our $debug
Truth table50%1/2
A
A= our $debug
Aresult
11
00
9 3 ▶our $debug_fh ||= \*STDERR;
Condition50%1/2
our $debug_fh ||= \*STDERR
l!l
03
MC/DC0%0/1
our $debug_fh ||= \*STDERR
our $debug_fh
Truth table50%1/2
A
A= our $debug_fh
Aresult
11
00
10  
11 3 our $FACTORY;
12  
13 3 ▶use Carp qw(carp croak);
Subroutine BEGIN: called CC=1 SCAR=0.0
14 3 ▶use POSIX qw(:sys_wait_h);
Subroutine BEGIN: called CC=1 SCAR=0.0
15 3 ▶use Socket;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 3 ▶use File::Spec;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 3 ▶use Cwd ();
Subroutine BEGIN: called CC=1 SCAR=0.0
18 3 ▶use Scalar::Util ();
Subroutine BEGIN: called CC=1 SCAR=0.0
19 3 ▶use Errno ();
Subroutine BEGIN: called CC=1 SCAR=0.0
20 3 ▶use Net::OpenSSH::Constants qw(:error :_state);
Subroutine BEGIN: called CC=1 SCAR=0.0
21 3 ▶use Net::OpenSSH::ModuleLoader;
Subroutine BEGIN: called CC=1 SCAR=0.0
22 3 ▶use Net::OpenSSH::ShellQuoter;
Subroutine BEGIN: called CC=1 SCAR=0.0
23 3 ▶use Digest::MD5;
Subroutine BEGIN: called CC=1 SCAR=0.0
24  
25 3 my $thread_generation = 0;
26  
27 0 ▶sub CLONE { $thread_generation++ };
Subroutine CLONE: not called CC=1 SCAR=6.9
28  
29 0 ▶sub _debug {
Subroutine _debug: not called CC=2 SCAR=17.9
30 0 local ($!, $@);
31 0 ▶ print {$debug_fh} '# ', (map { defined($_) ? $_ : '<undef>' } @_), "\n"
Branch: 1 branch
BranchTrueFalseTotal
defined $_ ? : 0 0 0
32 }
33  
34 0 ▶sub _debug_dump {
Subroutine _debug_dump: not called CC=1 SCAR=6.9
35 0 local ($!, $@);
36 0 require Data::Dumper;
37 0 local $Data::Dumper::Terse = 1;
38 0 local $Data::Dumper::Indent = 0;
39 0 my $head = shift;
40 0 _debug("$head: ", Data::Dumper::Dumper(@_));
41 }
42  
43 0 ▶sub _hexdump {
Subroutine _hexdump: not called CC=3 SCAR=20.8
44 3 ▶ no warnings qw(uninitialized);
Subroutine BEGIN: called CC=1 SCAR=0.0
45 0 my $data = shift;
46 0 ▶ while ($data =~ /(.{1,32})/smg) {
Branch: 1 branch
BranchTrueFalseTotal
if ($data =~ /(.{1,32})/gms) 0 0 0
47 0 my $line=$1;
48 0 my @c= (( map { sprintf "%02x",$_ } unpack('C*', $line)),
49 ((" ") x 32))[0..31];
50 0 ▶ $line=~s/(.)/ my $c=$1; unpack("c",$c)>=32 ? $c : '.' /egms;
Branch: 1 branch
BranchTrueFalseTotal
unpack('c', $c) >= 32 ? : 0 0 0
51 0 print {$debug_fh} "#> ", join(" ", @c, '|', $line), "\n";
52 }
53 }
54  
55 {
56 3 my %good;
57  
58 54 ▶ sub _sub_options {
Subroutine _sub_options: called CC=1 SCAR=0.0
59 54 my $sub = shift;
60 54 $good{__PACKAGE__ . "::$sub"} = { map { $_ => 1 } @_ };
61 }
62  
63 0 ▶ sub _croak_bad_options (\%) {
Subroutine _croak_bad_options: not called CC=4 SCAR=30.0
64 0 my $opts = shift;
65 0 ▶ if (%$opts) {
Branch: 1 branch
BranchTrueFalseTotal
if (%$opts) 0 0 0
66 0 my $sub = (caller 1)[3];
67 0 my $good = $good{$sub};
68 0 ▶ my @keys = grep defined($opts->{$_}), ( $good ? grep !$good->{$_}, keys %$opts : keys %$opts);
Branch: 1 branch
BranchTrueFalseTotal
$good ? : 0 0 0
69 0 ▶ if (@keys) {
Branch: 1 branch
BranchTrueFalseTotal
if (@keys) 0 0 0
70 0 croak "Invalid or bad combination of options ('" . CORE::join("', '", @keys) . "')";
71 }
72 }
73 }
74 }
75  
76 3 ▶sub _croak_scalar_context {
Subroutine _croak_scalar_context: not called CC=2 SCAR=15.1
77 0 my ($sub, $wantarray) = (caller 1)[3, 5];
78 0 ▶ unless ($wantarray) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($wantarray) 0 0 0
79 0 $sub =~ s/^.*:://;
80 0 croak "method '$sub' called in scalar context";
81 }
82 }
83  
84 0 ▶sub _tcroak {
Subroutine _tcroak: not called CC=3 SCAR=24.8
85 0 ▶ if (${^TAINT} > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (${^TAINT} > 0) 0 0 0
86 0 push @_, " while running with -T switch";
87 0 goto &croak;
88 }
89 0 ▶ if (${^TAINT} < 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (${^TAINT} < 0) 0 0 0
90 0 push @_, " while running with -t switch";
91 0 goto &carp;
92 }
93 }
94  
95 0 ▶sub _catch_tainted_args {
Subroutine _catch_tainted_args: not called CC=8 SCAR=42.8
96 0 my $i;
97 0 for (@_) {
98 0 ▶ next unless $i++;
Branch: 1 branch
BranchTrueFalseTotal
unless $i++ 0 0 0
99 0 ▶ if (Scalar::Util::tainted($_)) {
Branch: 2 branches
BranchTrueFalseTotal
if (&Scalar::Util::tainted($_)) { } 0 0 0
elsif (ref $_ eq 'HASH') { } 0 0 0
100 0 my (undef, undef, undef, $subn) = caller 1;
101 0 ▶ my $msg = ( $subn =~ /::([a-z]\w*)$/
Branch: 1 branch
BranchTrueFalseTotal
$subn =~ /::([a-z]\w*)$/ ? : 0 0 0
102 ? "Insecure argument '$_' on '$1' method call"
103 : "Insecure argument '$_' on method call" );
104 0 _tcroak($msg);
105 }
106 elsif (ref($_) eq 'HASH') {
107 0 for (grep Scalar::Util::tainted($_), values %$_) {
108 0 my (undef, undef, undef, $subn) = caller 1;
109 0 ▶ my $msg = ( $subn =~ /::([a-z]\w*)$/
Branch: 1 branch
BranchTrueFalseTotal
$subn =~ /::([a-z]\w*)$/ ? : 0 0 0
110 ? "Insecure argument on '$1' method call"
111 : "Insecure argument on method call" );
112 0 _tcroak($msg);
113 }
114 }
115 }
116 }
117  
118 0 ▶sub _set_error {
Subroutine _set_error: not called CC=6 SCAR=37.4
119 0 my $self = shift;
120 0 ▶ my $code = shift || 0;
Condition0%0/2
shift() || 0
l!l
00
MC/DC0%0/1
shift() || 0
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
121 0 my @extra = grep defined, @_;
122 my $err = $self->{_error} = ( $code
123 0 ▶ ? Scalar::Util::dualvar($code, join(': ', @{$self->{_error_prefix}},
Branch: 2 branches
BranchTrueFalseTotal
$code ? : 0 0 0
@extra ? : 0 0 0
124 (@extra ? @extra : "Unknown error $code")))
125 : 0 );
126 0 ▶ $debug and $debug & 1 and _debug "set_error($code - $err)";
Branch: 1 branch
BranchTrueFalseTotal
$Net::OpenSSH::debug and $Net::OpenSSH::debug & 1 and _debug("set_error($code - $err)") 0 0 0
Condition0%0/3
$Net::OpenSSH::debug and $Net::OpenSSH::debug & 1
!ll&&!rl&&r
000
MC/DC0%0/2
$Net::OpenSSH::debug and $Net::OpenSSH::debug & 1
$Net::OpenSSH::debug $Net::OpenSSH::debug & 1
Truth table0%0/3
A and B
A= $Net::OpenSSH::debugB= $Net::OpenSSH::debug & 1
ABresult
0X0
100
111
127 0 return $err
128 }
129  
130 3 my $check_eval_re = do {
131 3 my $path = quotemeta $INC{"Net/OpenSSH.pm"};
132 3 qr/at $path line \d+.$/
133 };
134  
135 0 ▶sub _check_eval_ok {
Subroutine _check_eval_ok: not called CC=2 SCAR=17.9
136 0 my ($self, $code) = @_;
137 0 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
138 0 my $err = $@;
139 0 $err =~ s/$check_eval_re//;
140 0 $self->_set_error($code, $err);
141 0 return;
142 }
143 1
144 0 }
145  
146 0 ▶sub _or_set_error {
Subroutine _or_set_error: not called CC=2 SCAR=17.9
147 0 my $self = shift;
148 0 ▶ $self->{_error} or $self->_set_error(@_);
Branch: 1 branch
BranchTrueFalseTotal
$self->{"_error"} or $self->_set_error(@_) 0 0 0
149 }
150  
151 0 ▶sub _first_defined { defined && return $_ for @_; return }
Subroutine _first_defined: not called CC=3 SCAR=24.8
Branch: 1 branch
BranchTrueFalseTotal
defined $_ and return $_ 0 0 0
152  
153 0 ▶my $obfuscate = sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
154 # just for the casual observer...
155 0 my $txt = shift;
156 0 ▶ $txt =~ s/(.)/chr(ord($1) ^ 47)/ges
Branch: 1 branch
BranchTrueFalseTotal
if defined $txt 0 0 0
157 if defined $txt;
158 0 $txt;
159 3 };
160  
161 3 my $deobfuscate = $obfuscate;
162  
163 # regexp from Regexp::IPv6
164 3 my $IPv6_re = qr((?-xism::(?::[0-9a-fA-F]{1,4}){0,5}(?:(?::[0-9a-fA-F]{1,4}){1,2}|:(?:(?:25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{1,2})[.](?:25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{1,2})[.](?:25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{1,2})[.](?:25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{1,2})))|[0-9a-fA-F]{1,4}:(?:[0-9a-fA-F]{1,4}:(?:[0-9a-fA-F]{1,4}:(?:[0-9a-fA-F]{1,4}:(?:[0-9a-fA-F]{1,4}:(?:[0-9a-fA-F]{1,4}:(?:[0-9a-fA-F]{1,4}:(?:[0-9a-fA-F]{1,4}|:)|(?::(?:[0-9a-fA-F]{1,4})?|(?:(?:25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{1,2})[.](?:25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{1,2})[.](?:25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{1,2})[.](?:25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{1,2}))))|:(?:(?:(?:25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{1,2})[.](?:25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{1,2})[.](?:25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{1,2})[.](?:25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{1,2}))|[0-9a-fA-F]{1,4}(?::[0-9a-fA-F]{1,4})?|))|(?::(?:(?:25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{1,2})[.](?:25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{1,2})[.](?:25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{1,2})[.](?:25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{1,2}))|:[0-9a-fA-F]{1,4}(?::(?:(?:25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{1,2})[.](?:25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{1,2})[.](?:25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{1,2})[.](?:25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{1,2}))|(?::[0-9a-fA-F]{1,4}){0,2})|:))|(?:(?::[0-9a-fA-F]{1,4}){0,2}(?::(?:(?:25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{1,2})[.](?:25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{1,2})[.](?:25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{1,2})[.](?:25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{1,2}))|(?::[0-9a-fA-F]{1,4}){1,2})|:))|(?:(?::[0-9a-fA-F]{1,4}){0,3}(?::(?:(?:25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{1,2})[.](?:25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{1,2})[.](?:25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{1,2})[.](?:25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{1,2}))|(?::[0-9a-fA-F]{1,4}){1,2})|:))|(?:(?::[0-9a-fA-F]{1,4}){0,4}(?::(?:(?:25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{1,2})[.](?:25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{1,2})[.](?:25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{1,2})[.](?:25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{1,2}))|(?::[0-9a-fA-F]{1,4}){1,2})|:))));
165  
166 19 ▶sub parse_connection_opts {
Subroutine parse_connection_opts: called CC=10 SCAR=23.2
Pod undocumented
167 19 my ($class, $opts) = @_;
168 19 my ($user, $passwd, $ipv6, $host, $port, $host_squared);
169  
170 19 my $target = delete $opts->{host};
171 19 ▶ defined $target or croak "mandatory host argument missing";
Branch: 1 branch
BranchTrueFalseTotal
defined $target or croak("mandatory host argument missing") 19 0 19
172  
173 19 ▶ ($user, $passwd, $ipv6, $host, $port) =
Branch: 1 branch
BranchTrueFalseTotal
() = $target =~ m(^ \s* # space (?: ([^:]+) # username (?::(.*))? # : password \@ # @ )? (?: # host ( # IPv6... \[$IPv6_re(?:\%[^\[\]]*)\] # [IPv6] | # or $IPv6_re # IPv6 ) | # or ([^\[\]\@:]+) # hostname / ipv4 ) (?::([^\@:]+))? # port \s* # space $)xi or croak("bad host/target '${target}' specification") 19 0 19
174 $target =~ m{^
175 \s* # space
176 (?:
177 ([^:]+) # username
178 (?::(.*))? # : password
179 \@ # @
180 )?
181 (?: # host
182 ( # IPv6...
183 \[$IPv6_re(?:\%[^\[\]]*)\] # [IPv6]
184 | # or
185 $IPv6_re # IPv6
186 )
187 | # or
188 ([^\[\]\@:]+) # hostname / ipv4
189 )
190 (?::([^\@:]+))? # port
191 \s* # space
192 $}ix
193 or croak "bad host/target '$target' specification";
194  
195 19 ▶ if (defined $ipv6) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $ipv6) { } 1 18 19
196 1 ($host) = $ipv6 =~ /^\[?(.*?)\]?$/;
197 1 $host_squared = "[$host]";
198 }
199 else {
200 18 $host_squared = $host;
201 }
202  
203 19 ▶ $user = delete $opts->{user} unless defined $user;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $user 1 18 19
204 19 ▶ $port = delete $opts->{port} unless defined $port;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $port 19 0 19
205 19 ▶ $passwd = delete $opts->{passwd} unless defined $passwd;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $passwd 6 13 19
206 19 ▶ $passwd = delete $opts->{password} unless defined $passwd;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $passwd 6 13 19
207  
208 19 ▶ wantarray and return ($host, $port, $user, $passwd, $host_squared);
Branch: 1 branch
BranchTrueFalseTotal
wantarray and return $host, $port, $user, $passwd, $host_squared 0 19 19
209  
210 19 my %r = ( user => $user,
211 password => $passwd,
212 host => $host,
213 host_squared => $host_squared,
214 port => $port );
215 19 ▶ $r{ipv6} = 1 if defined $ipv6;
Branch: 1 branch
BranchTrueFalseTotal
if defined $ipv6 1 18 19
216 19 return \%r;
217 }
218  
219 3 ▶my $sizeof_sun_path = ($^O eq 'linux' ? 108 :
Branch: 3 branches
BranchTrueFalseTotal
$^O eq 'linux' ? : 3 0 3
$^O =~ /bsd/i ? : 0 0 0
$^O eq 'hpux' ? : 0 0 0
220 $^O =~ /bsd/i ? 104 :
221 $^O eq 'hpux' ? 92 : undef);
222  
223 0 ▶sub new {
Subroutine new: not called CC=56 SCAR=80.7
Pod documented
224 0 ▶ ${^TAINT} and &_catch_tainted_args;
Branch: 1 branch
BranchTrueFalseTotal
${^TAINT} and &_catch_tainted_args 0 0 0
225  
226 0 my $class = shift;
227 0 ▶ @_ & 1 and unshift @_, 'host';
Branch: 1 branch
BranchTrueFalseTotal
@_ & 1 and unshift @_, "host" 0 0 0
228  
229 0 ▶ return $FACTORY->($class, @_) if defined $FACTORY;
Branch: 1 branch
BranchTrueFalseTotal
if defined $Net::OpenSSH::FACTORY 0 0 0
230  
231 0 my %opts = @_;
232  
233 0 my $external_master = delete $opts{external_master};
234 # reuse_master is an obsolete alias:
235 0 ▶ $external_master = delete $opts{reuse_master} unless defined $external_master;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $external_master 0 0 0
236  
237 0 ▶ if (not defined $opts{host} and defined $external_master) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $opts{"host"} and defined $external_master) 0 0 0
Condition0%0/3
not defined $opts{"host"} and defined $external_master
!ll&&!rl&&r
000
MC/DC0%0/2
not defined $opts{"host"} and defined $external_master
not defined $opts{"host"} defined $external_master
Truth table0%0/3
not(A) and B
A= not defined $opts{"host"}B= defined $external_master
ABresult
0X0
100
111
238 0 $opts{host} = '0.0.0.0';
239 }
240  
241 0 my ($host, $port, $user, $passwd, $host_squared) = $class->parse_connection_opts(\%opts);
242  
243 0 my ($passphrase, $key_path, $login_handler);
244 0 ▶ unless (defined $passwd) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $passwd) 0 0 0
245 0 $key_path = delete $opts{key_path};
246 0 $passwd = delete $opts{passphrase};
247 0 ▶ if (defined $passwd) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $passwd) { } 0 0 0
248 0 $passphrase = 1;
249 }
250 else {
251 0 $login_handler = delete $opts{login_handler};
252 }
253 }
254  
255 0 my $ssh_version = delete $opts{ssh_version};
256 0 my $batch_mode = delete $opts{batch_mode};
257 0 my $ctl_path = delete $opts{ctl_path};
258 0 my $ctl_dir = delete $opts{ctl_dir};
259 0 my $proxy_command = delete $opts{proxy_command};
260 0 ▶ my $gateway = delete $opts{gateway} unless defined $proxy_command;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $proxy_command 0 0 0
261 0 my $ssh_cmd = _first_defined delete $opts{ssh_cmd}, 'ssh';
262 0 my $rsync_cmd = _first_defined delete $opts{rsync_cmd}, 'rsync';
263 0 my $scp_cmd = delete $opts{scp_cmd};
264 0 my $sshfs_cmd = _first_defined delete $opts{sshfs_cmd}, 'sshfs';
265 my $sftp_server_cmd = _first_defined delete $opts{sftp_server_cmd},
266 0 '/usr/lib/openssh/sftp-server';
267 0 my $timeout = delete $opts{timeout};
268 0 my $kill_ssh_on_timeout = delete $opts{kill_ssh_on_timeout};
269 0 my $strict_mode = _first_defined delete $opts{strict_mode}, 1;
270 0 my $connect = _first_defined delete $opts{connect}, 1;
271 0 my $async = delete $opts{async};
272 0 my $remote_shell = _first_defined delete $opts{remote_shell}, 'POSIX';
273 0 my $expand_vars = delete $opts{expand_vars};
274 0 my $vars = _first_defined delete $opts{vars}, {};
275 0 my $default_encoding = delete $opts{default_encoding};
276 my $default_stream_encoding =
277 0 _first_defined delete $opts{default_stream_encoding}, $default_encoding;
278 my $default_argument_encoding =
279 0 _first_defined delete $opts{default_argument_encoding}, $default_encoding;
280 0 my $forward_agent = delete $opts{forward_agent};
281 0 ▶ $forward_agent and $passphrase and
Branch: 1 branch
BranchTrueFalseTotal
$forward_agent and $passphrase and croak("agent forwarding can not be used when a passphrase has also been given") 0 0 0
Condition0%0/3
$forward_agent and $passphrase
!ll&&!rl&&r
000
MC/DC0%0/2
$forward_agent and $passphrase
$forward_agent $passphrase
Truth table0%0/3
A and B
A= $forward_agentB= $passphrase
ABresult
0X0
100
111
282 croak "agent forwarding can not be used when a passphrase has also been given";
283 0 my $forward_X11 = delete $opts{forward_X11};
284 0 my $passwd_prompt = delete $opts{password_prompt};
285 0 my $master_pty_force = delete $opts{master_pty_force};
286 0 ▶ $passwd_prompt = delete $opts{passwd_prompt} unless defined $passwd_prompt;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $passwd_prompt 0 0 0
287  
288 0 my ($master_opts, @master_opts,
289 $master_stdout_fh, $master_stderr_fh,
290 $master_stdout_discard, $master_stderr_discard,
291 $master_setpgrp);
292 0 ▶ unless ($external_master) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($external_master) 0 0 0
293 ($master_stdout_fh = delete $opts{master_stdout_fh} or
294 0 ▶ $master_stdout_discard = delete $opts{master_stdout_discard});
Branch: 1 branch
BranchTrueFalseTotal
$master_stdout_fh = delete $opts{"master_stdout_fh"} or $master_stdout_discard = delete $opts{"master_stdout_discard"} 0 0 0
295  
296 ($master_stderr_fh = delete $opts{master_stderr_fh} or
297 0 ▶ $master_stderr_discard = delete $opts{master_stderr_discard});
Branch: 1 branch
BranchTrueFalseTotal
$master_stderr_fh = delete $opts{"master_stderr_fh"} or $master_stderr_discard = delete $opts{"master_stderr_discard"} 0 0 0
298  
299 0 $master_opts = delete $opts{master_opts};
300 0 ▶ if (defined $master_opts) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $master_opts) 0 0 0
301 0 ▶ if (ref $master_opts) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $master_opts) { } 0 0 0
302 0 @master_opts = @$master_opts;
303 }
304 else {
305 0 ▶ carp "'master_opts' argument looks like if it should be splited first"
Branch: 1 branch
BranchTrueFalseTotal
if $master_opts =~ /^-\w\s+\S/ 0 0 0
306 if $master_opts =~ /^-\w\s+\S/;
307 0 @master_opts = $master_opts;
308 }
309 }
310 0 $master_setpgrp = delete $opts{master_setpgrp};
311  
312 # when a password/passphrase is given, calling setpgrp is
313 # useless because the process runs attached to a different tty
314 0 ▶ undef $master_setpgrp if $login_handler or defined $passwd;
Branch: 1 branch
BranchTrueFalseTotal
if $login_handler or defined $passwd 0 0 0
Condition0%0/3
$login_handler or defined $passwd
l!l&&r!l&&!r
000
MC/DC0%0/2
$login_handler or defined $passwd
$login_handler defined $passwd
Truth table0%0/3
A or B
A= $login_handlerB= defined $passwd
ABresult
1X1
011
000
315 }
316  
317 0 my $default_ssh_opts = delete $opts{default_ssh_opts};
318 0 ▶ carp "'default_ssh_opts' argument looks like if it should be splited first"
Branch: 1 branch
BranchTrueFalseTotal
if defined $default_ssh_opts and not ref $default_ssh_opts and $default_ssh_opts =~ /^-\w\s+\S/ 0 0 0
Condition0%0/6
defined $default_ssh_opts and not ref $default_ssh_opts and $default_ssh_opts =~ /^-\w\s+\S/
!ll&&!rl&&r
000
defined $default_ssh_opts and not ref $default_ssh_opts
!ll&&!rl&&r
000
MC/DC0%0/3
defined $default_ssh_opts and not ref $default_ssh_opts and $default_ssh_opts =~ /^-\w\s+\S/
defined $default_ssh_opts not ref $default_ssh_opts $default_ssh_opts =~ /^-\w\s+\S/
Truth table0%0/4
A and not(B) and C
A= defined $default_ssh_optsB= not ref $default_ssh_optsC= $default_ssh_opts =~ /^-\w\s+\S/
ABCresult
0XX0
10X0
1100
1111
319 if defined $default_ssh_opts and not ref $default_ssh_opts and $default_ssh_opts =~ /^-\w\s+\S/;
320  
321 0 my ($default_stdout_fh, $default_stderr_fh, $default_stdin_fh,
322 $default_stdout_file, $default_stderr_file, $default_stdin_file,
323 $default_stdout_discard, $default_stderr_discard, $default_stdin_discard);
324  
325 $default_stdout_file = (delete $opts{default_stdout_discard}
326 ? '/dev/null'
327 0 ▶ : delete $opts{default_stdout_file});
Branch: 1 branch
BranchTrueFalseTotal
delete $opts{'default_stdout_discard'} ? : 0 0 0
328 $default_stdout_fh = delete $opts{default_stdout_fh}
329 0 ▶ unless defined $default_stdout_file;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $default_stdout_file 0 0 0
330  
331 $default_stderr_file = (delete $opts{default_stderr_discard}
332 ? '/dev/null'
333 0 ▶ : delete $opts{default_stderr_file});
Branch: 1 branch
BranchTrueFalseTotal
delete $opts{'default_stderr_discard'} ? : 0 0 0
334 $default_stderr_fh = delete $opts{default_stderr_fh}
335 0 ▶ unless defined $default_stderr_file;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $default_stderr_file 0 0 0
336  
337 $default_stdin_file = (delete $opts{default_stdin_discard}
338 ? '/dev/null'
339 0 ▶ : delete $opts{default_stdin_file});
Branch: 1 branch
BranchTrueFalseTotal
delete $opts{'default_stdin_discard'} ? : 0 0 0
340 $default_stdin_fh = delete $opts{default_stdin_fh}
341 0 ▶ unless defined $default_stdin_file;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $default_stdin_file 0 0 0
342  
343 0 _croak_bad_options %opts;
344  
345 0 my @ssh_opts;
346 # TODO: are those options really requiered or just do they eat on
347 # the command line limited length?
348 0 ▶ push @ssh_opts, -l => $user if defined $user;
Branch: 1 branch
BranchTrueFalseTotal
if defined $user 0 0 0
349 0 ▶ push @ssh_opts, -p => $port if defined $port;
Branch: 1 branch
BranchTrueFalseTotal
if defined $port 0 0 0
350  
351 0 my $home = do {
352 0 local ($@, $SIG{__DIE__});
353 0 eval { Cwd::realpath((getpwuid $>)[7]) }
354 };
355  
356 0 ▶ if (${^TAINT}) {
Branch: 1 branch
BranchTrueFalseTotal
if (${^TAINT}) 0 0 0
357 0 ($home) = $home =~ /^(.*)$/;
358 0 ▶ Scalar::Util::tainted($ENV{PATH}) and
Branch: 1 branch
BranchTrueFalseTotal
&Scalar::Util::tainted($ENV{"PATH"}) and _tcroak("Insecure \$ENV{PATH}") 0 0 0
359 _tcroak('Insecure $ENV{PATH}');
360 }
361  
362 0 my $self = { _error => 0,
363 _error_prefix => [],
364 _perl_pid => $$,
365 _thread_generation => $thread_generation,
366 _ssh_version => $ssh_version,
367 _ssh_cmd => $ssh_cmd,
368 _scp_cmd => $scp_cmd,
369 _rsync_cmd => $rsync_cmd,
370 _sshfs_cmd => $sshfs_cmd,
371 _sftp_server_cmd => $sftp_server_cmd,
372 _pid => undef,
373 _host => $host,
374 _host_squared => $host_squared,
375 _user => $user,
376 _port => $port,
377 _passwd => $obfuscate->($passwd),
378 _passwd_prompt => $passwd_prompt,
379 _passphrase => $passphrase,
380 _key_path => $key_path,
381 _login_handler => $login_handler,
382 _timeout => $timeout,
383 _proxy_command => $proxy_command,
384 _gateway_args => $gateway,
385 _kill_ssh_on_timeout => $kill_ssh_on_timeout,
386 _batch_mode => $batch_mode,
387 _home => $home,
388 _forward_agent => $forward_agent,
389 _forward_X11 => $forward_X11,
390 _external_master => $external_master,
391 _default_ssh_opts => $default_ssh_opts,
392 _default_stdin_fh => $default_stdin_fh,
393 _default_stdout_fh => $default_stdout_fh,
394 _default_stderr_fh => $default_stderr_fh,
395 _master_stdout_fh => $master_stdout_fh,
396 _master_stderr_fh => $master_stderr_fh,
397 _master_stdout_discard => $master_stdout_discard,
398 _master_stderr_discard => $master_stderr_discard,
399 _master_setpgrp => $master_setpgrp,
400 _master_pty_force => $master_pty_force,
401 _remote_shell => $remote_shell,
402 _default_stream_encoding => $default_stream_encoding,
403 _default_argument_encoding => $default_argument_encoding,
404 _expand_vars => $expand_vars,
405 _vars => $vars,
406 _master_state => _STATE_START,
407 };
408 0 bless $self, $class;
409  
410 0 $self->_detect_ssh_version;
411  
412 # default file handles are opened so late in order to have the
413 # $self object to report errors
414 0 ▶ $self->{_default_stdout_fh} = $self->_open_file('>', $default_stdout_file)
Branch: 1 branch
BranchTrueFalseTotal
if defined $default_stdout_file 0 0 0
415 if defined $default_stdout_file;
416 0 ▶ $self->{_default_stderr_fh} = $self->_open_file('>', $default_stderr_file)
Branch: 1 branch
BranchTrueFalseTotal
if defined $default_stderr_file 0 0 0
417 if defined $default_stderr_file;
418 0 ▶ $self->{_default_stdin_fh} = $self->_open_file('<', $default_stdin_file)
Branch: 1 branch
BranchTrueFalseTotal
if defined $default_stdin_file 0 0 0
419 if defined $default_stdin_file;
420  
421 0 ▶ if ($self->{_error} == OSSH_SLAVE_PIPE_FAILED) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"_error"} == 3) 0 0 0
422 0 $self->_master_fail($async, "Unable to create default slave stream", $self->{_error});
423 0 return $self;
424 }
425  
426 0 $self->{_ssh_opts} = [$self->_expand_vars(@ssh_opts)];
427 0 $self->{_master_opts} = [$self->_expand_vars(@master_opts)];
428  
429 0 $ctl_path = $self->_expand_vars($ctl_path);
430 0 $ctl_dir = $self->_expand_vars($ctl_dir);
431  
432 0 ▶ if (defined $ctl_path) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $ctl_path) { } 0 0 0
433 0 ▶ if ($external_master) {
Branch: 1 branch
BranchTrueFalseTotal
if ($external_master) { } 0 0 0
434 0 ▶ unless (-S $ctl_path) {
Branch: 1 branch
BranchTrueFalseTotal
unless (-S $ctl_path) 0 0 0
435 0 $self->_master_fail($async, "ctl_path $ctl_path does not point to a socket");
436 0 return $self;
437 }
438 }
439 else {
440 0 ▶ if (-e $ctl_path) {
Branch: 1 branch
BranchTrueFalseTotal
if (-e $ctl_path) 0 0 0
441 0 $self->_master_fail($async, "unable to use ctl_path $ctl_path, a file object already exists there");
442 0 return $self;
443 }
444 }
445 }
446 else {
447 0 ▶ $external_master and croak "external_master is set but ctl_path is not defined";
Branch: 1 branch
BranchTrueFalseTotal
$external_master and croak("external_master is set but ctl_path is not defined") 0 0 0
448  
449 0 ▶ unless (defined $ctl_dir) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $ctl_dir) 0 0 0
450 0 ▶ unless (defined $self->{_home}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->{"_home"}) 0 0 0
451 0 $self->_master_fail($async, "unable to determine home directory for uid $>");
452 0 return $self;
453 }
454  
455 0 $ctl_dir = File::Spec->catdir($self->{_home}, ".libnet-openssh-perl");
456 }
457  
458 0 mkdir $ctl_dir, 0700;
459 0 ▶ unless (-d $ctl_dir) {
Branch: 1 branch
BranchTrueFalseTotal
unless (-d $ctl_dir) 0 0 0
460 0 $self->_master_fail($async, "unable to create ctl_dir $ctl_dir");
461 0 return $self;
462 }
463  
464 0 my $target = join('-', grep defined, $user, $host, $port);
465  
466 0 for (1..10) {
467 0 my $ctl_file = Digest::MD5::md5_hex(sprintf "%s-%d-%d-%d", $target, $$, time, rand 1e6);
468 0 $ctl_path = File::Spec->join($ctl_dir, $ctl_file);
469 0 ▶ last unless -e $ctl_path
Branch: 1 branch
BranchTrueFalseTotal
unless -e $ctl_path 0 0 0
470 }
471 0 ▶ if (-e $ctl_path) {
Branch: 1 branch
BranchTrueFalseTotal
if (-e $ctl_path) 0 0 0
472 0 $self->_master_fail($async, "unable to find unused name for ctl_path inside ctl_dir $ctl_dir");
473 0 return $self;
474 }
475 }
476  
477 0 ▶ if (defined $sizeof_sun_path and length $ctl_path > $sizeof_sun_path) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $sizeof_sun_path and length $ctl_path > $sizeof_sun_path) 0 0 0
Condition0%0/3
defined $sizeof_sun_path and length $ctl_path > $sizeof_sun_path
!ll&&!rl&&r
000
MC/DC0%0/2
defined $sizeof_sun_path and length $ctl_path > $sizeof_sun_path
defined $sizeof_sun_path length $ctl_path > $sizeof_sun_path
Truth table0%0/3
A and B
A= defined $sizeof_sun_pathB= length $ctl_path > $sizeof_sun_path
ABresult
0X0
100
111
478 0 $self->_master_fail($async, "ctl_path $ctl_path is too long (max permissible size for $^O is $sizeof_sun_path)");
479 0 return $self;
480 }
481  
482 0 $ctl_dir = File::Spec->catpath((File::Spec->splitpath($ctl_path))[0,1], "");
483 0 ▶ $debug and $debug & 2 and _debug "ctl_path: $ctl_path, ctl_dir: $ctl_dir";
Branch: 1 branch
BranchTrueFalseTotal
$Net::OpenSSH::debug and $Net::OpenSSH::debug & 2 and _debug("ctl_path: $ctl_path, ctl_dir: $ctl_dir") 0 0 0
Condition0%0/3
$Net::OpenSSH::debug and $Net::OpenSSH::debug & 2
!ll&&!rl&&r
000
MC/DC0%0/2
$Net::OpenSSH::debug and $Net::OpenSSH::debug & 2
$Net::OpenSSH::debug $Net::OpenSSH::debug & 2
Truth table0%0/3
A and B
A= $Net::OpenSSH::debugB= $Net::OpenSSH::debug & 2
ABresult
0X0
100
111
484  
485 0 ▶ if ($strict_mode and !$self->_is_secure_path($ctl_dir)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($strict_mode and not $self->_is_secure_path($ctl_dir)) 0 0 0
Condition0%0/3
$strict_mode and not $self->_is_secure_path($ctl_dir)
!ll&&!rl&&r
000
MC/DC0%0/2
$strict_mode and not $self->_is_secure_path($ctl_dir)
$strict_mode not $self->_is_secure_path($ctl_dir)
Truth table0%0/3
A and not(B)
A= $strict_modeB= not $self->_is_secure_path($ctl_dir)
ABresult
0X0
100
111
486 0 $self->_master_fail($async, "ctl_dir $ctl_dir is not secure");
487 0 return $self;
488 }
489  
490 0 $self->{_ctl_path} = $ctl_path;
491  
492 0 ▶ $self->_master_wait($async) if $connect;
Branch: 1 branch
BranchTrueFalseTotal
if $connect 0 0 0
493  
494 0 $self;
495 }
496  
497 0 ▶sub get_user { shift->{_user} }
Subroutine get_user: not called CC=1 SCAR=6.9
Pod documented
498 0 ▶sub get_host { shift->{_host} }
Subroutine get_host: not called CC=1 SCAR=6.9
Pod documented
499 0 ▶sub get_port { shift->{_port} }
Subroutine get_port: not called CC=1 SCAR=6.9
Pod documented
500 0 ▶sub get_master_pid { shift->{_pid} }
Subroutine get_master_pid: not called CC=1 SCAR=6.9
Pod documented
501 0 ▶sub get_ctl_path { shift->{_ctl_path} }
Subroutine get_ctl_path: not called CC=1 SCAR=6.9
Pod documented
502 0 ▶sub get_expand_vars { shift->{_expand_vars} }
Subroutine get_expand_vars: not called CC=1 SCAR=6.9
Pod documented
503  
504 0 ▶sub get_master_pty_log { shift->{_master_pty_log} }
Subroutine get_master_pty_log: not called CC=1 SCAR=6.9
Pod documented
505  
506 0 ▶sub set_expand_vars {
Subroutine set_expand_vars: not called CC=2 SCAR=17.9
Pod documented
507 0 my $self = shift;
508 0 ▶ $self->{_expand_vars} = (shift(@_) ? 1 : 0);
Branch: 1 branch
BranchTrueFalseTotal
shift @_ ? : 0 0 0
509 }
510  
511 0 ▶sub set_var {
Subroutine set_var: not called CC=3 SCAR=24.8
Pod documented
512 0 ▶ ${^TAINT} and &_catch_tainted_args;
Branch: 1 branch
BranchTrueFalseTotal
${^TAINT} and &_catch_tainted_args 0 0 0
513 0 my $self = shift;
514 0 my $k = shift;
515 0 ▶ $k =~ /^(?:USER|HOST|PORT)$/
Branch: 1 branch
BranchTrueFalseTotal
$k =~ /^(?:USER|HOST|PORT)$/ and croak("internal variable %$k% can not be set") 0 0 0
516 and croak "internal variable %$k% can not be set";
517 0 $self->{_vars}{$k} = shift;
518 }
519  
520 0 ▶sub get_var {
Subroutine get_var: not called CC=3 SCAR=24.8
Pod documented
521 0 my ($self, $k) = @_;
522 my $v = ( $k =~ /^(?:USER|HOST|PORT)$/
523 ? $self->{lc "_$k"}
524 0 ▶ : $self->{_vars}{$k} );
Branch: 1 branch
BranchTrueFalseTotal
$k =~ /^(?:USER|HOST|PORT)$/ ? : 0 0 0
525 0 ▶ (defined $v ? $v : '');
Branch: 1 branch
BranchTrueFalseTotal
defined $v ? : 0 0 0
526 }
527  
528 0 ▶sub _expand_vars {
Subroutine _expand_vars: not called CC=7 SCAR=40.3
529 0 my ($self, @str) = @_;
530 0 ▶ if (ref $self and $self->{_expand_vars}) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $self and $self->{"_expand_vars"}) 0 0 0
Condition0%0/3
ref $self and $self->{"_expand_vars"}
!ll&&!rl&&r
000
MC/DC0%0/2
ref $self and $self->{"_expand_vars"}
ref $self $self->{"_expand_vars"}
Truth table0%0/3
A and B
A= ref $selfB= $self->{"_expand_vars"}
ABresult
0X0
100
111
531 0 for (@str) {
532 0 ▶ s{%(\w*)%}{length ($1) ? $self->get_var($1) : '%'}ge
Branch: 2 branches
BranchTrueFalseTotal
if defined $_ 0 0 0
length $1 ? : 0 0 0
533 if defined $_;
534 }
535 }
536 0 ▶ wantarray ? @str : $str[0]
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
537 }
538  
539 0 ▶sub error { shift->{_error} }
Subroutine error: not called CC=1 SCAR=6.9
Pod documented
540  
541 0 ▶sub die_on_error {
Subroutine die_on_error: not called CC=3 SCAR=24.8
Pod undocumented
542 0 my $ssh = shift;
543 0 ▶ $ssh->{_error} and croak(@_ ? "@_: $ssh->{_error}" : $ssh->{_error});
Branch: 2 branches
BranchTrueFalseTotal
$ssh->{"_error"} and croak(@_ ? qq[@{_}: $ssh->{"_error"}] : $ssh->{"_error"}) 0 0 0
@_ ? : 0 0 0
544 }
545  
546  
547 0 ▶sub _is_secure_path {
Subroutine _is_secure_path: not called CC=13 SCAR=52.0
548 0 my ($self, $path) = @_;
549 0 my @parts = File::Spec->splitdir(Cwd::realpath($path));
550 0 my $home = $self->{_home};
551 0 for my $last (reverse 0..$#parts) {
552 0 my $dir = File::Spec->catdir(@parts[0..$last]);
553 0 ▶ unless (-d $dir) {
Branch: 1 branch
BranchTrueFalseTotal
unless (-d $dir) 0 0 0
554 0 ▶ $debug and $debug & 2 and _debug "$dir is not a directory";
Branch: 1 branch
BranchTrueFalseTotal
$Net::OpenSSH::debug and $Net::OpenSSH::debug & 2 and _debug("$dir is not a directory") 0 0 0
Condition0%0/3
$Net::OpenSSH::debug and $Net::OpenSSH::debug & 2
!ll&&!rl&&r
000
MC/DC0%0/2
$Net::OpenSSH::debug and $Net::OpenSSH::debug & 2
$Net::OpenSSH::debug $Net::OpenSSH::debug & 2
Truth table0%0/3
A and B
A= $Net::OpenSSH::debugB= $Net::OpenSSH::debug & 2
ABresult
0X0
100
111
555 0 return undef;
556 }
557 0 my ($mode, $uid) = (stat $dir)[2, 4];
558 0 ▶ $debug and $debug & 2 and _debug "_is_secure_path(dir: $dir, file mode: $mode, file uid: $uid, euid: $>";
Branch: 1 branch
BranchTrueFalseTotal
$Net::OpenSSH::debug and $Net::OpenSSH::debug & 2 and _debug("_is_secure_path(dir: $dir, file mode: $mode, file uid: $uid, euid: $>") 0 0 0
Condition0%0/3
$Net::OpenSSH::debug and $Net::OpenSSH::debug & 2
!ll&&!rl&&r
000
MC/DC0%0/2
$Net::OpenSSH::debug and $Net::OpenSSH::debug & 2
$Net::OpenSSH::debug $Net::OpenSSH::debug & 2
Truth table0%0/3
A and B
A= $Net::OpenSSH::debugB= $Net::OpenSSH::debug & 2
ABresult
0X0
100
111
559 0 ▶ return undef unless(($uid == $> or $uid == 0 ) and (($mode & 022) == 0 or ($mode & 01000)));
Branch: 1 branch
BranchTrueFalseTotal
unless $uid == $> || $uid == 0 and ($mode & 18) == 0 || $mode & 512 0 0 0
Condition0%0/9
$uid == $> || $uid == 0 and ($mode & 18) == 0 || $mode & 512
!ll&&!rl&&r
000
$uid == $> or $uid == 0
l!l&&r!l&&!r
000
($mode & 18) == 0 or $mode & 512
l!l&&r!l&&!r
000
MC/DC0%0/4
$uid == $> || $uid == 0 and ($mode & 18) == 0 || $mode & 512
$uid == $> $uid == 0 ($mode & 18) == 0 $mode & 512
Truth table0%0/7
A or B and C or D
A= $uid == $>B= $uid == 0C= ($mode & 18) == 0D= $mode & 512
ABCDresult
00XX0
1X000
01000
1X1X1
1X011
011X1
01011
560 0 ▶ return 1 if (defined $home and $home eq $dir);
Branch: 1 branch
BranchTrueFalseTotal
if defined $home and $home eq $dir 0 0 0
Condition0%0/3
defined $home and $home eq $dir
!ll&&!rl&&r
000
MC/DC0%0/2
defined $home and $home eq $dir
defined $home $home eq $dir
Truth table0%0/3
A and B
A= defined $homeB= $home eq $dir
ABresult
0X0
100
111
561 }
562 0 return 1;
563 }
564  
565 3 _sub_options _capture_local_ssh => qw(stderr_to_stdout stderr_discard stderr_fh stderr_file);
566  
567 0 ▶sub _capture_local_ssh {
Subroutine _capture_local_ssh: not called CC=2 SCAR=17.9
568 0 my $self = shift;
569 0 ▶ my %opts = (ref $_[0] eq 'HASH' ? %{shift()} : ());
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] eq 'HASH' ? : 0 0 0
570 0 _croak_bad_options %opts;
571 my (undef, $out, undef, $pid) = $self->open_ex({ %opts,
572 _cmd => 'raw',
573 _no_master_required => 1,
574 stdout_pipe => 1,
575 stdin_discard => 1 },
576 0 $self->{_ssh_cmd}, @_);
577 0 my ($txt) = $self->_io3($out, undef, undef, undef, 10, 'bytes');
578 0 local $self->{_kill_ssh_on_timeout} = 1;
579 0 $self->_waitpid($pid, 10);
580 0 return $txt
581 }
582  
583 0 ▶sub _detect_ssh_version {
Subroutine _detect_ssh_version: not called CC=9 SCAR=45.0
584 0 my $self = shift;
585 0 ▶ if (defined $self->{_ssh_version}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{'_ssh_version'}) { } 0 0 0
586 0 ▶ $debug and $debug & 4 and _debug "ssh version given as $self->{_ssh_version}";
Branch: 1 branch
BranchTrueFalseTotal
$Net::OpenSSH::debug and $Net::OpenSSH::debug & 4 and _debug(qq[ssh version given as $self->{"_ssh_version"}]) 0 0 0
Condition0%0/3
$Net::OpenSSH::debug and $Net::OpenSSH::debug & 4
!ll&&!rl&&r
000
MC/DC0%0/2
$Net::OpenSSH::debug and $Net::OpenSSH::debug & 4
$Net::OpenSSH::debug $Net::OpenSSH::debug & 4
Truth table0%0/3
A and B
A= $Net::OpenSSH::debugB= $Net::OpenSSH::debug & 4
ABresult
0X0
100
111
587 }
588 else {
589 0 my $txt = $self->_capture_local_ssh({stderr_to_stdout => 1}, '-V');
590 0 ▶ if (my ($full, $num) = $txt =~ /^OpenSSH_((\d+\.\d+)\S*)/mi) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = $txt =~ /^OpenSSH_((\d+\.\d+)\S*)/im) { } 0 0 0
591 0 ▶ $debug and $debug & 4 and _debug "OpenSSH version is $full";
Branch: 1 branch
BranchTrueFalseTotal
$Net::OpenSSH::debug and $Net::OpenSSH::debug & 4 and _debug("OpenSSH version is $full") 0 0 0
Condition0%0/3
$Net::OpenSSH::debug and $Net::OpenSSH::debug & 4
!ll&&!rl&&r
000
MC/DC0%0/2
$Net::OpenSSH::debug and $Net::OpenSSH::debug & 4
$Net::OpenSSH::debug $Net::OpenSSH::debug & 4
Truth table0%0/3
A and B
A= $Net::OpenSSH::debugB= $Net::OpenSSH::debug & 4
ABresult
0X0
100
111
592 0 $self->{_ssh_version} = $num;
593 }
594 else {
595 0 $self->{_ssh_version} = 0;
596 0 ▶ $debug and $debug & 4 and _debug "unable to determine version, '$self->{_ssh_cmd} -V', output:\n$txt"
Branch: 1 branch
BranchTrueFalseTotal
$Net::OpenSSH::debug and $Net::OpenSSH::debug & 4 and _debug(qq[unable to determine version, '$self->{"_ssh_cmd"} -V', output:\n$txt]) 0 0 0
Condition0%0/3
$Net::OpenSSH::debug and $Net::OpenSSH::debug & 4
!ll&&!rl&&r
000
MC/DC0%0/2
$Net::OpenSSH::debug and $Net::OpenSSH::debug & 4
$Net::OpenSSH::debug $Net::OpenSSH::debug & 4
Truth table0%0/3
A and B
A= $Net::OpenSSH::debugB= $Net::OpenSSH::debug & 4
ABresult
0X0
100
111
597 }
598 }
599 }
600  
601 0 ▶sub default_ssh_configuration {
Subroutine default_ssh_configuration: not called CC=1 SCAR=6.9
Pod documented
602 0 my $self = shift;
603 $self->_capture_local_ssh('-qG', $self->{_host})
604 0 }
605  
606 0 ▶sub _make_ssh_call {
Subroutine _make_ssh_call: not called CC=5 SCAR=34.0
607 0 my $self = shift;
608 0 ▶ my @before = @{shift || []};
Condition0%0/2
shift() || []
l!l
00
MC/DC0%0/1
shift() || []
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
609 my @args = ($self->{_ssh_cmd}, @before,
610 -S => $self->{_ctl_path},
611 0 ▶ @{$self->{_ssh_opts}}, $self->{_host},
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 0 0 0
612 0 '--',
613 (@_ ? "@_" : ()));
614 0 ▶ $debug and $debug & 8 and _debug_dump 'call args' => \@args;
Branch: 1 branch
BranchTrueFalseTotal
$Net::OpenSSH::debug and $Net::OpenSSH::debug & 8 and _debug_dump("call args", \@args) 0 0 0
Condition0%0/3
$Net::OpenSSH::debug and $Net::OpenSSH::debug & 8
!ll&&!rl&&r
000
MC/DC0%0/2
$Net::OpenSSH::debug and $Net::OpenSSH::debug & 8
$Net::OpenSSH::debug $Net::OpenSSH::debug & 8
Truth table0%0/3
A and B
A= $Net::OpenSSH::debugB= $Net::OpenSSH::debug & 8
ABresult
0X0
100
111
615 0 @args;
616 }
617  
618 0 ▶sub _scp_cmd {
Subroutine _scp_cmd: not called CC=3 SCAR=24.8
619 0 my $self = shift;
620 0 ▶ $self->{_scp_cmd} ||= do {
Condition0%0/3
$self->{"_scp_cmd"} ||= do { my $scp = $self->{"_ssh_cmd"}; $scp =~ s/ssh$/scp/i or croak("scp command name not set"); $scp }
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->{"_scp_cmd"} ||= do { my $scp = $self->{"_ssh_cmd"}; $scp =~ s/ssh$/scp/i or croak("scp command name not set"); $scp }
$self->{"_scp_cmd"} do { my $scp = $self->{"_ssh_cmd"}; $scp =~ s/ssh$/scp/i or croak("scp command name not set"); $scp }
Truth table0%0/3
A ||= B
A= $self->{"_scp_cmd"}B= do { my $scp = $self->{"_ssh_cmd"}; $scp =~ s/ssh$/scp/i or croak("scp command name not set"); $scp }
ABresult
1X1
011
000
621 0 my $scp = $self->{_ssh_cmd};
622 0 ▶ $scp =~ s/ssh$/scp/i or croak "scp command name not set";
Branch: 1 branch
BranchTrueFalseTotal
$scp =~ s/ssh$/scp/i or croak("scp command name not set") 0 0 0
623 0 $scp;
624 }
625 }
626  
627 0 ▶sub _make_scp_call {
Subroutine _make_scp_call: not called CC=5 SCAR=34.0
628 0 my $self = shift;
629 0 ▶ my @before = @{shift || []};
Condition0%0/2
shift() || []
l!l
00
MC/DC0%0/1
shift() || []
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
630 my @args = ($self->_scp_cmd, @before,
631 -o => "ControlPath=$self->{_ctl_path}",
632 -S => $self->{_ssh_cmd},
633 0 ▶ (defined $self->{_port} ? (-P => $self->{_port}) : ()),
Branch: 1 branch
BranchTrueFalseTotal
defined $self->{'_port'} ? : 0 0 0
634 '--', @_);
635  
636 0 ▶ $debug and $debug & 8 and _debug_dump 'scp call args' => \@args;
Branch: 1 branch
BranchTrueFalseTotal
$Net::OpenSSH::debug and $Net::OpenSSH::debug & 8 and _debug_dump("scp call args", \@args) 0 0 0
Condition0%0/3
$Net::OpenSSH::debug and $Net::OpenSSH::debug & 8
!ll&&!rl&&r
000
MC/DC0%0/2
$Net::OpenSSH::debug and $Net::OpenSSH::debug & 8
$Net::OpenSSH::debug $Net::OpenSSH::debug & 8
Truth table0%0/3
A and B
A= $Net::OpenSSH::debugB= $Net::OpenSSH::debug & 8
ABresult
0X0
100
111
637 0 @args;
638 }
639  
640 0 ▶sub _rsync_quote {
Subroutine _rsync_quote: not called CC=4 SCAR=30.0
641 0 my ($self, @args) = @_;
642 0 for (@args) {
643 0 ▶ if (/['"\s]/) {
Branch: 1 branch
BranchTrueFalseTotal
if (/['"\s]/) 0 0 0
644 0 s/"/""/g;
645 0 $_ = qq|"$_"|;
646 }
647 0 s/%/%%/;
648 }
649 0 ▶ wantarray ? @args : join(' ', @args);
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
650 }
651  
652 0 ▶sub _make_rsync_call {
Subroutine _make_rsync_call: not called CC=3 SCAR=24.8
653 0 my $self = shift;
654 0 my $before = shift;
655 my @transport = ($self->{_ssh_cmd}, @$before,
656 0 -S => $self->{_ctl_path});
657 0 my $transport = $self->_rsync_quote(@transport);
658 my @args = ( $self->{_rsync_cmd},
659 0 -e => $transport,
660 @_);
661  
662 0 ▶ $debug and $debug & 8 and _debug_dump 'rsync call args' => \@args;
Branch: 1 branch
BranchTrueFalseTotal
$Net::OpenSSH::debug and $Net::OpenSSH::debug & 8 and _debug_dump("rsync call args", \@args) 0 0 0
Condition0%0/3
$Net::OpenSSH::debug and $Net::OpenSSH::debug & 8
!ll&&!rl&&r
000
MC/DC0%0/2
$Net::OpenSSH::debug and $Net::OpenSSH::debug & 8
$Net::OpenSSH::debug $Net::OpenSSH::debug & 8
Truth table0%0/3
A and B
A= $Net::OpenSSH::debugB= $Net::OpenSSH::debug & 8
ABresult
0X0
100
111
663 0 @args;
664 }
665  
666 0 ▶sub _make_W_option {
Subroutine _make_W_option: not called CC=4 SCAR=30.0
667 0 my $self = shift;
668 0 ▶ if (@_ == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_ == 1) 0 0 0
669 0 my $path = shift;
670 0 ▶ $path = "./$path" unless $path =~ m|/|;
Branch: 1 branch
BranchTrueFalseTotal
unless $path =~ m[/] 0 0 0
671 0 $path =~ s/([\\:])/\\$1/g;
672 0 return "-W$path";
673 }
674 0 ▶ if (@_ == 2) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_ == 2) 0 0 0
675 0 return "-W" . join(':', @_);
676 }
677 0 croak "bad number of arguments for creating a tunnel"
678 }
679  
680 0 ▶sub _make_tunnel_call {
Subroutine _make_tunnel_call: not called CC=4 SCAR=30.0
681 0 my $self = shift;
682 0 ▶ my @before = @{shift||[]};
Condition0%0/2
shift() || []
l!l
00
MC/DC0%0/1
shift() || []
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
683 0 push @before, $self->_make_W_option(@_);
684 0 my @args = $self->_make_ssh_call(\@before);
685 0 ▶ $debug and $debug & 8 and _debug_dump 'tunnel call args' => \@args;
Branch: 1 branch
BranchTrueFalseTotal
$Net::OpenSSH::debug and $Net::OpenSSH::debug & 8 and _debug_dump("tunnel call args", \@args) 0 0 0
Condition0%0/3
$Net::OpenSSH::debug and $Net::OpenSSH::debug & 8
!ll&&!rl&&r
000
MC/DC0%0/2
$Net::OpenSSH::debug and $Net::OpenSSH::debug & 8
$Net::OpenSSH::debug $Net::OpenSSH::debug & 8
Truth table0%0/3
A and B
A= $Net::OpenSSH::debugB= $Net::OpenSSH::debug & 8
ABresult
0X0
100
111
686 0 @args;
687 }
688  
689 0 ▶sub master_exited {
Subroutine master_exited: not called CC=1 SCAR=6.9
Pod documented
690 0 my $self = shift;
691 0 $self->_master_gone(1)
692 }
693  
694 0 ▶sub _master_gone {
Subroutine _master_gone: not called CC=2 SCAR=17.9
695 0 my $self = shift;
696 0 my $async = shift;
697 0 delete $self->{_pid};
698 0 ▶ $self->_master_fail($async, (@_ ? @_ : "master process exited unexpectedly"));
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 0 0 0
699 }
700  
701 3 my @kill_signal = qw(0 0 TERM TERM TERM KILL);
702  
703 0 ▶sub __has_sigchld_handle {
Subroutine __has_sigchld_handle: not called CC=3 SCAR=24.8
704 0 my $h = $SIG{CHLD};
705 0 ▶ defined $h and $h ne 'IGNORE' and $h ne 'DEFAULT'
Branch: 1 branch
BranchTrueFalseTotal
defined $h and $h ne "IGNORE" and $h ne "DEFAULT" 0 0 0
Condition0%0/3
defined $h and $h ne "IGNORE"
!ll&&!rl&&r
000
MC/DC0%0/2
defined $h and $h ne "IGNORE"
defined $h $h ne "IGNORE"
Truth table0%0/3
A and B
A= defined $hB= $h ne "IGNORE"
ABresult
0X0
100
111
706 }
707  
708 0 ▶sub _master_kill {
Subroutine _master_kill: not called CC=24 SCAR=64.0
709 0 my ($self, $async) = @_;
710  
711 0 ▶ if (my $pid = $self->_my_master_pid) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $pid = $self->_my_master_pid) { } 0 0 0
712 0 ▶ $debug and $debug & 32 and _debug '_master_kill: ', $pid;
Branch: 1 branch
BranchTrueFalseTotal
$Net::OpenSSH::debug and $Net::OpenSSH::debug & 32 and _debug("_master_kill: ", $pid) 0 0 0
Condition0%0/3
$Net::OpenSSH::debug and $Net::OpenSSH::debug & 32
!ll&&!rl&&r
000
MC/DC0%0/2
$Net::OpenSSH::debug and $Net::OpenSSH::debug & 32
$Net::OpenSSH::debug $Net::OpenSSH::debug & 32
Truth table0%0/3
A and B
A= $Net::OpenSSH::debugB= $Net::OpenSSH::debug & 32
ABresult
0X0
100
111
713  
714 0 my $now = time;
715 0 ▶ my $start = $self->{_master_kill_start} ||= $now;
Condition0%0/3
$self->{"_master_kill_start"} ||= $now
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->{"_master_kill_start"} ||= $now
$self->{"_master_kill_start"} $now
Truth table0%0/3
A ||= B
A= $self->{"_master_kill_start"}B= $now
ABresult
1X1
011
000
716 0 ▶ $self->{_master_kill_last} ||= $now;
Condition0%0/3
$self->{"_master_kill_last"} ||= $now
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->{"_master_kill_last"} ||= $now
$self->{"_master_kill_last"} $now
Truth table0%0/3
A ||= B
A= $self->{"_master_kill_last"}B= $now
ABresult
1X1
011
000
717 0 ▶ $self->{_master_kill_count} ||= 0;
Condition0%0/2
$self->{"_master_kill_count"} ||= 0
l!l
00
MC/DC0%0/1
$self->{"_master_kill_count"} ||= 0
$self->{"_master_kill_count"}
Truth table0%0/2
A
A= $self->{"_master_kill_count"}
Aresult
11
00
718  
719 0 ▶ local $SIG{CHLD} = sub {} unless $async or __has_sigchld_handle;
Subroutine __ANON__: not called CC=1 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
unless $async or __has_sigchld_handle() 0 0 0
Condition0%0/3
$async or __has_sigchld_handle()
l!l&&r!l&&!r
000
MC/DC0%0/2
$async or __has_sigchld_handle()
$async __has_sigchld_handle()
Truth table0%0/3
A or B
A= $asyncB= __has_sigchld_handle()
ABresult
1X1
011
000
720 0 while (1) {
721 0 ▶ if ($self->{_master_kill_last} < $now) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"_master_kill_last"} < $now) 0 0 0
722 0 $self->{_master_kill_last} = $now;
723 0 my $sig = $kill_signal[$self->{_master_kill_count}++];
724 0 ▶ $sig = 'KILL' unless defined $sig;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $sig 0 0 0
725 0 ▶ $debug and $debug & 32 and _debug "killing master $$ with signal $sig";
Branch: 1 branch
BranchTrueFalseTotal
$Net::OpenSSH::debug and $Net::OpenSSH::debug & 32 and _debug("killing master ${$} with signal $sig") 0 0 0
Condition0%0/3
$Net::OpenSSH::debug and $Net::OpenSSH::debug & 32
!ll&&!rl&&r
000
MC/DC0%0/2
$Net::OpenSSH::debug and $Net::OpenSSH::debug & 32
$Net::OpenSSH::debug $Net::OpenSSH::debug & 32
Truth table0%0/3
A and B
A= $Net::OpenSSH::debugB= $Net::OpenSSH::debug & 32
ABresult
0X0
100
111
726 0 kill $sig, $pid;
727 }
728 0 my $deceased = waitpid($pid, WNOHANG);
729 0 ▶ $debug and $debug & 32 and _debug "waitpid(master: $pid) => pid: $deceased, rc: $!";
Branch: 1 branch
BranchTrueFalseTotal
$Net::OpenSSH::debug and $Net::OpenSSH::debug & 32 and _debug("waitpid(master: $pid) => pid: $deceased, rc: $!") 0 0 0
Condition0%0/3
$Net::OpenSSH::debug and $Net::OpenSSH::debug & 32
!ll&&!rl&&r
000
MC/DC0%0/2
$Net::OpenSSH::debug and $Net::OpenSSH::debug & 32
$Net::OpenSSH::debug $Net::OpenSSH::debug & 32
Truth table0%0/3
A and B
A= $Net::OpenSSH::debugB= $Net::OpenSSH::debug & 32
ABresult
0X0
100
111
730 0 ▶ last if $deceased == $pid or ($deceased < 0 and $! == Errno::ECHILD());
Branch: 1 branch
BranchTrueFalseTotal
if $deceased == $pid or $deceased < 0 and $! == 10 0 0 0
Condition0%0/6
$deceased == $pid or $deceased < 0 and $! == 10
l!l&&r!l&&!r
000
$deceased < 0 and $! == 10
!ll&&!rl&&r
000
MC/DC0%0/3
$deceased == $pid or $deceased < 0 and $! == 10
$deceased == $pid $deceased < 0 $! == 10
Truth table0%0/4
A or B and C
A= $deceased == $pidB= $deceased < 0C= $! == 10
ABCresult
1XX1
0111
00X0
0100
731 0 ▶ if ($self->{_master_kill_count} > 20) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"_master_kill_count"} > 20) 0 0 0
732 # FIXME: remove the hard-coded 20 retries?
733 0 ▶ $debug and $debug & 32 and _debug "unable to kill SSH master process, giving up";
Branch: 1 branch
BranchTrueFalseTotal
$Net::OpenSSH::debug and $Net::OpenSSH::debug & 32 and _debug("unable to kill SSH master process, giving up") 0 0 0
Condition0%0/3
$Net::OpenSSH::debug and $Net::OpenSSH::debug & 32
!ll&&!rl&&r
000
MC/DC0%0/2
$Net::OpenSSH::debug and $Net::OpenSSH::debug & 32
$Net::OpenSSH::debug $Net::OpenSSH::debug & 32
Truth table0%0/3
A and B
A= $Net::OpenSSH::debugB= $Net::OpenSSH::debug & 32
ABresult
0X0
100
111
734 0 last;
735 }
736 0 ▶ return if $async;
Branch: 1 branch
BranchTrueFalseTotal
if $async 0 0 0
737 0 select(undef, undef, undef, 0.2);
738 0 $now = time;
739 }
740 }
741 else {
742 $debug and $debug & 32 and _debug("not killing master SSH (", $self->{_pid}, ") started from " .
743 "process ", $self->{_perl_pid}, "/", $self->{_thread_generation},
744 0 ▶ ", current ", $$, "/", $thread_generation, ")");
Branch: 1 branch
BranchTrueFalseTotal
$Net::OpenSSH::debug and $Net::OpenSSH::debug & 32 and _debug("not killing master SSH (", $self->{"_pid"}, ") started from process ", $self->{"_perl_pid"}, "/", $self->{"_thread_generation"}, ", current ", $$, "/", $thread_generation, ")") 0 0 0
Condition0%0/3
$Net::OpenSSH::debug and $Net::OpenSSH::debug & 32
!ll&&!rl&&r
000
MC/DC0%0/2
$Net::OpenSSH::debug and $Net::OpenSSH::debug & 32
$Net::OpenSSH::debug $Net::OpenSSH::debug & 32
Truth table0%0/3
A and B
A= $Net::OpenSSH::debugB= $Net::OpenSSH::debug & 32
ABresult
0X0
100
111
745 }
746 0 $self->_master_gone($async);
747 }
748  
749 0 ▶sub disconnect {
Subroutine disconnect: not called CC=2 SCAR=17.9
Pod documented
750 0 my ($self, $async) = @_;
751 0 ▶ @_ <= 2 or croak 'Usage: $self->disconnect([$async])';
Branch: 1 branch
BranchTrueFalseTotal
@_ <= 2 or croak("Usage: \$self->disconnect([\$async])") 0 0 0
752 0 $self->_disconnect($async, 1);
753 }
754  
755 0 ▶sub disown_master {
Subroutine disown_master: not called CC=3 SCAR=24.8
Pod documented
756 0 my $self = shift;
757 0 ▶ if (my $pid = $self->_my_master_pid) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $pid = $self->_my_master_pid) 0 0 0
758 0 ▶ if ($self->wait_for_master) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->wait_for_master) 0 0 0
759 0 $self->{_external_master} = 1;
760 0 return $pid;
761 }
762 }
763 0 undef;
764 }
765  
766 0 ▶sub restart {
Subroutine restart: not called CC=5 SCAR=34.0
Pod documented
767 0 my ($self, $async) = @_;
768 0 ▶ $self->{_external_master} and croak "Can restart SSH connection when using external master";
Branch: 1 branch
BranchTrueFalseTotal
$self->{"_external_master"} and croak("Can restart SSH connection when using external master") 0 0 0
769  
770 # user is responsible for calling us in STATE_GONE in async mode
771 0 ▶ $self->_disconnect($async, 1) unless $async;
Branch: 1 branch
BranchTrueFalseTotal
unless $async 0 0 0
772  
773 0 ▶ if ($self->{_master_state} != _STATE_GONE) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"_master_state"} != "_STATE_GONE") 0 0 0
774 0 ▶ croak "restart method called in wrong state (terminate the connection first!)" if $async;
Branch: 1 branch
BranchTrueFalseTotal
if $async 0 0 0
775 0 return $self->_master_fail($async, "Unable to restart SSH session from state $self->{_master_state}")
776 }
777  
778 # These slots should be deleted when exiting the KILLING state but
779 # I like keeping them around for throubleshoting purposes.
780 0 delete $self->{_master_kill_start};
781 0 delete $self->{_master_kill_last};
782 0 delete $self->{_master_kill_count};
783 0 $self->_master_jump_state(_STATE_START, $async);
784 }
785  
786 0 ▶sub _my_master_pid {
Subroutine _my_master_pid: not called CC=5 SCAR=34.0
787 0 my $self = shift;
788 0 ▶ unless ($self->{_external_master}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"_external_master"}) 0 0 0
789 0 my $pid = $self->{_pid};
790 return $pid if
791 0 ▶ $pid and $self->{_perl_pid} == $$ and $self->{_thread_generation} == $thread_generation;
Branch: 1 branch
BranchTrueFalseTotal
if $pid and $self->{"_perl_pid"} == $$ and $self->{"_thread_generation"} == $thread_generation 0 0 0
Condition0%0/6
$pid and $self->{"_perl_pid"} == $$ and $self->{"_thread_generation"} == $thread_generation
!ll&&!rl&&r
000
$pid and $self->{"_perl_pid"} == $$
!ll&&!rl&&r
000
MC/DC0%0/3
$pid and $self->{"_perl_pid"} == $$ and $self->{"_thread_generation"} == $thread_generation
$pid $self->{"_perl_pid"} == $$ $self->{"_thread_generation"} == $thread_generation
Truth table0%0/4
A and B and C
A= $pidB= $self->{"_perl_pid"} == $$C= $self->{"_thread_generation"} == $thread_generation
ABCresult
0XX0
10X0
1100
1111
792 }
793 ()
794 0 }
795  
796 0 ▶sub _disconnect {
Subroutine _disconnect: not called CC=8 SCAR=42.8
797 0 my ($self, $async, $send_ctl) = @_;
798 0 ▶ return if $self->{_master_state} == _STATE_GONE;
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"_master_state"} == "_STATE_GONE" 0 0 0
799  
800 0 ▶ if (!$async and
Branch: 1 branch
BranchTrueFalseTotal
if (not $async and $self->{"_master_state"} == "_STATE_RUNNING" and $send_ctl || $self->_my_master_pid) 0 0 0
Condition0%0/9
not $async and $self->{"_master_state"} == "_STATE_RUNNING" and $send_ctl || $self->_my_master_pid
!ll&&!rl&&r
000
not $async and $self->{"_master_state"} == "_STATE_RUNNING"
!ll&&!rl&&r
000
$send_ctl or $self->_my_master_pid
l!l&&r!l&&!r
000
MC/DC0%0/4
not $async and $self->{"_master_state"} == "_STATE_RUNNING" and $send_ctl || $self->_my_master_pid
not $async $self->{"_master_state"} == "_STATE_RUNNING" $send_ctl $self->_my_master_pid
Truth table0%0/5
not(A) and B and C or D
A= not $asyncB= $self->{"_master_state"} == "_STATE_RUNNING"C= $send_ctlD= $self->_my_master_pid
ABCDresult
0XXX0
10XX0
11000
111X1
11011
801 $self->{_master_state} == _STATE_RUNNING and
802 ($send_ctl or $self->_my_master_pid)) {
803 # we have successfully created the master connection so we
804 # can send control commands:
805 0 ▶ $debug and $debug & 32 and _debug("sending exit control to master");
Branch: 1 branch
BranchTrueFalseTotal
$Net::OpenSSH::debug and $Net::OpenSSH::debug & 32 and _debug("sending exit control to master") 0 0 0
Condition0%0/3
$Net::OpenSSH::debug and $Net::OpenSSH::debug & 32
!ll&&!rl&&r
000
MC/DC0%0/2
$Net::OpenSSH::debug and $Net::OpenSSH::debug & 32
$Net::OpenSSH::debug $Net::OpenSSH::debug & 32
Truth table0%0/3
A and B
A= $Net::OpenSSH::debugB= $Net::OpenSSH::debug & 32
ABresult
0X0
100
111
806 0 $self->_master_ctl('exit');
807 }
808 0 $self->_master_fail($async, 'aborted')
809 }
810  
811 0 ▶sub _check_is_system_fh {
Subroutine _check_is_system_fh: not called CC=4 SCAR=30.0
812 0 my ($name, $fh) = @_;
813 0 ▶ my $fn = fileno(defined $fh ? $fh : $name);
Branch: 1 branch
BranchTrueFalseTotal
defined $fh ? : 0 0 0
814 0 ▶ defined $fn and $fn >= 0 and return;
Branch: 1 branch
BranchTrueFalseTotal
defined $fn and $fn >= 0 and return 0 0 0
Condition0%0/3
defined $fn and $fn >= 0
!ll&&!rl&&r
000
MC/DC0%0/2
defined $fn and $fn >= 0
defined $fn $fn >= 0
Truth table0%0/3
A and B
A= defined $fnB= $fn >= 0
ABresult
0X0
100
111
815 0 croak "child process $name is not a real system file handle";
816 }
817  
818 0 ▶sub _master_redirect {
Subroutine _master_redirect: not called CC=6 SCAR=34.1
819 0 my $self = shift;
820 0 my $uname = uc shift;
821 0 my $name = lc $uname;
822  
823 3 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
824 0 ▶ if ($self->{"_master_${name}_discard"}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($$self{"_master_${name}_discard"}) { } 0 0 0
825 0 open *$uname, '>>', '/dev/null';
826 }
827 else {
828 0 my $fh = $self->{"_master_${name}_fh"};
829 0 ▶ $fh = $self->{"_default_${name}_fh"} unless defined $fh;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $fh 0 0 0
830 0 ▶ if (defined $fh) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $fh) 0 0 0
831 0 _check_is_system_fh $uname => $fh;
832 0 ▶ if (fileno $fh != fileno *$uname) {
Branch: 1 branch
BranchTrueFalseTotal
if (fileno $fh != fileno $uname) 0 0 0
833 0 ▶ open *$uname, '>>&', $fh or POSIX::_exit(255);
Branch: 1 branch
BranchTrueFalseTotal
open $uname, ">>&", $fh or POSIX::_exit(255) 0 0 0
834 }
835 }
836 }
837 }
838  
839 0 ▶sub _waitpid {
Subroutine _waitpid: not called CC=25 SCAR=64.8
840 0 my ($self, $pid, $timeout) = @_;
841 0 $? = 0;
842 0 ▶ if ($pid) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pid) { } 0 0 0
843 0 ▶ $timeout = $self->{_timeout} unless defined $timeout;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $timeout 0 0 0
844  
845 0 my $time_limit;
846 0 ▶ if (defined $timeout and $self->{_kill_ssh_on_timeout}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $timeout and $self->{"_kill_ssh_on_timeout"}) 0 0 0
Condition0%0/3
defined $timeout and $self->{"_kill_ssh_on_timeout"}
!ll&&!rl&&r
000
MC/DC0%0/2
defined $timeout and $self->{"_kill_ssh_on_timeout"}
defined $timeout $self->{"_kill_ssh_on_timeout"}
Truth table0%0/3
A and B
A= defined $timeoutB= $self->{"_kill_ssh_on_timeout"}
ABresult
0X0
100
111
847 0 ▶ $timeout = 0 if $self->{_error} == OSSH_SLAVE_TIMEOUT;
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"_error"} == 4 0 0 0
848 0 $time_limit = time + $timeout;
849 }
850 0 ▶ local $SIG{CHLD} = sub {} unless __has_sigchld_handle;
Subroutine __ANON__: not called CC=1 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
unless __has_sigchld_handle() 0 0 0
851 0 while (1) {
852 0 my $deceased;
853 0 ▶ if (defined $time_limit) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $time_limit) { } 0 0 0
854 0 while (1) {
855 # TODO: we assume that all OSs return 0 when the
856 # process is still running, that may be wrong!
857 0 ▶ $deceased = waitpid($pid, WNOHANG) and last;
Branch: 1 branch
BranchTrueFalseTotal
$deceased = waitpid($pid, 1) and last 0 0 0
858 0 my $remaining = $time_limit - time;
859 0 ▶ if ($remaining <= 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($remaining <= 0) 0 0 0
860 0 ▶ $debug and $debug & 16 and _debug "killing SSH slave, pid: $pid";
Branch: 1 branch
BranchTrueFalseTotal
$Net::OpenSSH::debug and $Net::OpenSSH::debug & 16 and _debug("killing SSH slave, pid: $pid") 0 0 0
Condition0%0/3
$Net::OpenSSH::debug and $Net::OpenSSH::debug & 16
!ll&&!rl&&r
000
MC/DC0%0/2
$Net::OpenSSH::debug and $Net::OpenSSH::debug & 16
$Net::OpenSSH::debug $Net::OpenSSH::debug & 16
Truth table0%0/3
A and B
A= $Net::OpenSSH::debugB= $Net::OpenSSH::debug & 16
ABresult
0X0
100
111
861 0 kill TERM => $pid;
862 0 $self->_or_set_error(OSSH_SLAVE_TIMEOUT, "ssh slave failed", "timed out");
863 }
864 # There is a race condition here. We try to
865 # minimize it keeping the waitpid and the select
866 # together and limiting the sleep time to 1s:
867 0 ▶ my $sleep = ($remaining < 0.1 ? 0.1 : 1);
Branch: 1 branch
BranchTrueFalseTotal
$remaining < 0.1 ? : 0 0 0
868 0 ▶ $debug and $debug & 16 and
Branch: 1 branch
BranchTrueFalseTotal
$Net::OpenSSH::debug and $Net::OpenSSH::debug & 16 and _debug("waiting for slave, timeout: $timeout, remaining: $remaining, sleep: $sleep") 0 0 0
Condition0%0/3
$Net::OpenSSH::debug and $Net::OpenSSH::debug & 16
!ll&&!rl&&r
000
MC/DC0%0/2
$Net::OpenSSH::debug and $Net::OpenSSH::debug & 16
$Net::OpenSSH::debug $Net::OpenSSH::debug & 16
Truth table0%0/3
A and B
A= $Net::OpenSSH::debugB= $Net::OpenSSH::debug & 16
ABresult
0X0
100
111
869 _debug "waiting for slave, timeout: $timeout, remaining: $remaining, sleep: $sleep";
870 0 ▶ $deceased = waitpid($pid, WNOHANG) and last;
Branch: 1 branch
BranchTrueFalseTotal
$deceased = waitpid($pid, 1) and last 0 0 0
871 0 select(undef, undef, undef, $sleep);
872 }
873 }
874 else {
875 0 $deceased = waitpid($pid, 0);
876 }
877 0 ▶ $debug and $debug & 16 and _debug "_waitpid($pid) => pid: $deceased, rc: $?, err: $!";
Branch: 1 branch
BranchTrueFalseTotal
$Net::OpenSSH::debug and $Net::OpenSSH::debug & 16 and _debug("_waitpid($pid) => pid: $deceased, rc: $?, err: $!") 0 0 0
Condition0%0/3
$Net::OpenSSH::debug and $Net::OpenSSH::debug & 16
!ll&&!rl&&r
000
MC/DC0%0/2
$Net::OpenSSH::debug and $Net::OpenSSH::debug & 16
$Net::OpenSSH::debug $Net::OpenSSH::debug & 16
Truth table0%0/3
A and B
A= $Net::OpenSSH::debugB= $Net::OpenSSH::debug & 16
ABresult
0X0
100
111
878 0 ▶ if ($deceased == $pid) {
Branch: 3 branches
BranchTrueFalseTotal
if ($deceased == $pid) { } 0 0 0
elsif ($deceased < 0) { } 0 0 0
elsif ($deceased > 0) { } 0 0 0
879 0 ▶ if ($?) {
Branch: 1 branch
BranchTrueFalseTotal
if ($?) 0 0 0
880 0 my $signal = ($? & 255);
881 0 my $errstr = "child exited with code " . ($? >> 8);
882 0 ▶ $errstr .= ", signal $signal" if $signal;
Branch: 1 branch
BranchTrueFalseTotal
if $signal 0 0 0
883 0 $self->_or_set_error(OSSH_SLAVE_CMD_FAILED, $errstr);
884 0 return undef;
885 }
886 0 return 1;
887 }
888 elsif ($deceased < 0) {
889 # at this point $deceased < 0 and so, $! has a valid error value.
890 0 ▶ next if $! == Errno::EINTR();
Branch: 1 branch
BranchTrueFalseTotal
if $! == 4 0 0 0
891 0 ▶ if ($! == Errno::ECHILD()) {
Branch: 1 branch
BranchTrueFalseTotal
if ($! == 10) 0 0 0
892 0 $self->_or_set_error(OSSH_SLAVE_FAILED, "child process $pid does not exist", $!);
893 return undef
894 0 }
895 0 warn "Internal error: unexpected error (".($!+0).": $!) from waitpid($pid) = $deceased. Report it, please!";
896 }
897 elsif ($deceased > 0) {
898 0 warn "Internal error: spurious process $deceased exited"
899 }
900  
901 # wait a bit before trying again
902 0 select(undef, undef, undef, 0.1);
903 }
904 }
905 else {
906 0 $self->_or_set_error(OSSH_SLAVE_FAILED, "spawning of new process failed");
907 0 return undef;
908 }
909 }
910  
911 0 ▶sub check_master {
Subroutine check_master: not called CC=2 SCAR=17.9
Pod documented
912 0 my $self = shift;
913 0 ▶ @_ and croak 'Usage: $ssh->check_master()';
Branch: 1 branch
BranchTrueFalseTotal
@_ and croak("Usage: \$ssh->check_master()") 0 0 0
914 0 $self->_master_check(0);
915 }
916  
917 0 ▶sub wait_for_master {
Subroutine wait_for_master: not called CC=3 SCAR=24.8
Pod documented
918 0 my ($self, $async) = @_;
919 0 ▶ @_ <= 2 or croak 'Usage: $ssh->wait_for_master([$async])';
Branch: 1 branch
BranchTrueFalseTotal
@_ <= 2 or croak("Usage: \$ssh->wait_for_master([\$async])") 0 0 0
920 $self->{_error} = 0
921 0 ▶ unless $self->{_error} == OSSH_MASTER_FAILED;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"_error"} == 1 0 0 0
922 0 $self->_master_wait($async);
923 }
924  
925 0 ▶sub _master_start {
Subroutine _master_start: not called CC=27 SCAR=66.3
926 0 my ($self, $async) = @_;
927 0 $self->_set_error;
928  
929 0 ▶ my $timeout = int((($self->{_timeout} || 90) + 2)/3);
Condition0%0/2
$self->{'_timeout'} || 90
l!l
00
MC/DC0%0/1
$self->{'_timeout'} || 90
$self->{'_timeout'}
Truth table0%0/2
A
A= $self->{'_timeout'}
Aresult
11
00
930 0 my $ssh_flags= '-2MN';
931 0 ▶ $ssh_flags .= ($self->{_forward_agent} ? 'A' : 'a') if defined $self->{_forward_agent};
Branch: 2 branches
BranchTrueFalseTotal
if defined $self->{"_forward_agent"} 0 0 0
$self->{'_forward_agent'} ? : 0 0 0
932 0 ▶ $ssh_flags .= ($self->{_forward_X11} ? 'X' : 'x');
Branch: 1 branch
BranchTrueFalseTotal
$self->{'_forward_X11'} ? : 0 0 0
933 0 ▶ my @master_opts = (@{$self->{_master_opts}},
Branch: 1 branch
BranchTrueFalseTotal
$self->{'_ssh_version'} >= 5.6 ? : 0 0 0
934 -o => "ServerAliveInterval=$timeout",
935 0 ($self->{_ssh_version} >= 5.6 ? (-o => "ControlPersist=no") : ()),
936 $ssh_flags);
937  
938 0 my ($mpty, $use_pty, $pref_auths);
939 $use_pty = 1 if ( $self->{_master_pty_force} or
940 0 ▶ defined $self->{_login_handler} );
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"_master_pty_force"} or defined $self->{"_login_handler"} 0 0 0
Condition0%0/3
$self->{"_master_pty_force"} or defined $self->{"_login_handler"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->{"_master_pty_force"} or defined $self->{"_login_handler"}
$self->{"_master_pty_force"} defined $self->{"_login_handler"}
Truth table0%0/3
A or B
A= $self->{"_master_pty_force"}B= defined $self->{"_login_handler"}
ABresult
1X1
011
000
941 0 ▶ if (defined $self->{_passwd}) {
Branch: 2 branches
BranchTrueFalseTotal
if (defined $self->{'_passwd'}) { } 0 0 0
elsif ($self->{'_batch_mode'}) { } 0 0 0
942 0 $use_pty = 1;
943 $pref_auths = ($self->{_passphrase}
944 0 ▶ ? 'publickey'
Branch: 1 branch
BranchTrueFalseTotal
$self->{'_passphrase'} ? : 0 0 0
945 : 'keyboard-interactive,password');
946 0 push @master_opts, -o => 'NumberOfPasswordPrompts=1';
947 }
948 elsif ($self->{_batch_mode}) {
949 0 push @master_opts, -o => 'BatchMode=yes';
950 }
951  
952 0 ▶ if (defined $self->{_key_path}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"_key_path"}) 0 0 0
953 0 $pref_auths = 'publickey';
954 0 push @master_opts, -i => $self->{_key_path};
955 }
956  
957 0 my $proxy_command = $self->{_proxy_command};
958  
959 0 my $gateway;
960 0 ▶ if (my $gateway_args = $self->{_gateway_args}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $gateway_args = $self->{"_gateway_args"}) 0 0 0
961 0 ▶ if (ref $gateway_args eq 'HASH') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $gateway_args eq 'HASH') { } 0 0 0
962 0 _load_module('Net::OpenSSH::Gateway');
963 0 my $errors;
964 0 ▶ unless ($gateway = Net::OpenSSH::Gateway->find_gateway(errors => $errors,
Branch: 1 branch
BranchTrueFalseTotal
unless ($gateway = "Net::OpenSSH::Gateway"->find_gateway("errors", $errors, "host", $self->{"_host"}, "port", $self->{"_port"}, %$gateway_args)) 0 0 0
965 host => $self->{_host}, port => $self->{_port},
966 %$gateway_args)) {
967 0 return $self->_master_fail($async, 'Unable to build gateway object', join(', ', @$errors));
968 }
969 }
970 else {
971 0 $gateway = $gateway_args
972 }
973 0 $self->{_gateway} = $gateway;
974 0 ▶ $gateway->before_ssh_connect or
Branch: 1 branch
BranchTrueFalseTotal
$gateway->before_ssh_connect or return $self->_master_fail($async, "Gateway setup failed", join(", ", $gateway->errors)) 0 0 0
975 return $self->_master_fail($async, 'Gateway setup failed', join(', ', $gateway->errors));
976 0 $proxy_command = $gateway->proxy_command;
977 }
978  
979 0 ▶ if (defined $proxy_command) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $proxy_command) 0 0 0
980 0 push @master_opts, -o => "ProxyCommand=$proxy_command";
981 }
982  
983 0 ▶ if ($use_pty) {
Branch: 1 branch
BranchTrueFalseTotal
if ($use_pty) 0 0 0
984 0 _load_module('IO::Pty');
985 0 $self->{_mpty} = $mpty = IO::Pty->new;
986 }
987  
988 0 ▶ push @master_opts, -o => "PreferredAuthentications=$pref_auths"
Branch: 1 branch
BranchTrueFalseTotal
if defined $pref_auths 0 0 0
989 if defined $pref_auths;
990  
991 0 my @call = $self->_make_ssh_call(\@master_opts);
992  
993 0 my $pid = fork;
994 0 ▶ unless ($pid) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($pid) 0 0 0
995 0 ▶ defined $pid
Branch: 1 branch
BranchTrueFalseTotal
defined $pid or return $self->_master_fail($async, "unable to fork ssh master: $!") 0 0 0
996 or return $self->_master_fail($async, "unable to fork ssh master: $!");
997  
998 0 ▶ if ($debug and $debug & 512) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Net::OpenSSH::debug and $Net::OpenSSH::debug & 512) 0 0 0
Condition0%0/3
$Net::OpenSSH::debug and $Net::OpenSSH::debug & 512
!ll&&!rl&&r
000
MC/DC0%0/2
$Net::OpenSSH::debug and $Net::OpenSSH::debug & 512
$Net::OpenSSH::debug $Net::OpenSSH::debug & 512
Truth table0%0/3
A and B
A= $Net::OpenSSH::debugB= $Net::OpenSSH::debug & 512
ABresult
0X0
100
111
999 0 require Net::OpenSSH::OSTracer;
1000 0 Net::OpenSSH::OSTracer->trace;
1001 }
1002  
1003 0 ▶ $mpty->make_slave_controlling_terminal if $mpty;
Branch: 1 branch
BranchTrueFalseTotal
if $mpty 0 0 0
1004  
1005 0 $self->_master_redirect('STDOUT');
1006 0 $self->_master_redirect('STDERR');
1007  
1008 0 ▶ delete $ENV{SSH_ASKPASS} if defined $self->{_passwd};
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{"_passwd"} 0 0 0
1009 0 ▶ delete $ENV{SSH_AUTH_SOCK} if defined $self->{_passphrase};
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{"_passphrase"} 0 0 0
1010  
1011 0 ▶ setpgrp if $self->{_master_setpgrp};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"_master_setpgrp"} 0 0 0
1012  
1013 0 local $SIG{__DIE__};
1014 0 eval { exec @call };
1015 0 POSIX::_exit(255);
1016 }
1017 0 $self->{_pid} = $pid;
1018 0 1;
1019 }
1020  
1021 0 ▶sub _master_check {
Subroutine _master_check: not called CC=8 SCAR=42.8
1022 0 my ($self, $async) = @_;
1023 0 my $error;
1024 0 ▶ if ($async) {
Branch: 1 branch
BranchTrueFalseTotal
if ($async) { } 0 0 0
1025 0 ▶ if (-S $self->{_ctl_path}) {
Branch: 1 branch
BranchTrueFalseTotal
if (-S $self->{"_ctl_path"}) 0 0 0
1026 0 delete $self->{_master_pty_log};
1027 0 return 1
1028 }
1029 0 $error = "master SSH connection broken";
1030 }
1031 else {
1032 0 my $out = $self->_master_ctl('check');
1033 0 $error = $self->{_error};
1034 0 ▶ unless ($error) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($error) 0 0 0
1035 0 my $pid = $self->{_pid};
1036 0 ▶ if ($out =~ /pid=(\d+)/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($out =~ /pid=(\d+)/) { } 0 0 0
1037 0 ▶ if (!$pid or $1 == $pid) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $pid or $1 == $pid) 0 0 0
Condition0%0/3
not $pid or $1 == $pid
l!l&&r!l&&!r
000
MC/DC0%0/2
not $pid or $1 == $pid
not $pid $1 == $pid
Truth table0%0/3
not(A) or B
A= not $pidB= $1 == $pid
ABresult
1X1
011
000
1038 0 delete $self->{_master_pty_log};
1039 0 return 1;
1040 }
1041 0 $error = "bad ssh master at $self->{_ctl_path} socket owned by pid $1 (pid $pid expected)";
1042 }
1043 else {
1044 0 ▶ $error = ($out =~ /illegal option/i
Branch: 1 branch
BranchTrueFalseTotal
$out =~ /illegal option/i ? : 0 0 0
1045 ? 'OpenSSH 4.1 or later required'
1046 : 'unknown error');
1047 }
1048 }
1049 }
1050 0 $self->_master_fail($async, $error);
1051 }
1052  
1053 0 ▶sub _master_fail {
Subroutine _master_fail: not called CC=3 SCAR=24.8
1054 0 my $self = shift;
1055 0 my $async = shift;
1056 0 ▶ if ($self->{_error} != OSSH_MASTER_FAILED) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"_error"} != 1) 0 0 0
1057 0 $self->_set_error(OSSH_MASTER_FAILED, @_);
1058 }
1059 0 ▶ $self->_master_jump_state($self->{_pid} ? _STATE_KILLING : _STATE_GONE, $async);
Branch: 1 branch
BranchTrueFalseTotal
$self->{'_pid'} ? : 0 0 0
1060 }
1061  
1062 0 ▶sub _master_jump_state {
Subroutine _master_jump_state: not called CC=6 SCAR=37.4
1063 0 my ($self, $state, $async) = @_;
1064 0 ▶ $debug and $debug & 4 and _debug "master state jumping from $self->{_master_state} to $state";
Branch: 1 branch
BranchTrueFalseTotal
$Net::OpenSSH::debug and $Net::OpenSSH::debug & 4 and _debug(qq[master state jumping from $self->{"_master_state"} to $state]) 0 0 0
Condition0%0/3
$Net::OpenSSH::debug and $Net::OpenSSH::debug & 4
!ll&&!rl&&r
000
MC/DC0%0/2
$Net::OpenSSH::debug and $Net::OpenSSH::debug & 4
$Net::OpenSSH::debug $Net::OpenSSH::debug & 4
Truth table0%0/3
A and B
A= $Net::OpenSSH::debugB= $Net::OpenSSH::debug & 4
ABresult
0X0
100
111
1065 0 ▶ if ($state == $self->{_master_state} and
Branch: 1 branch
BranchTrueFalseTotal
if ($state == $self->{"_master_state"} and $state != "_STATE_KILLING" and $state != "_STATE_GONE") 0 0 0
Condition0%0/6
$state == $self->{"_master_state"} and $state != "_STATE_KILLING" and $state != "_STATE_GONE"
!ll&&!rl&&r
000
$state == $self->{"_master_state"} and $state != "_STATE_KILLING"
!ll&&!rl&&r
000
MC/DC0%0/3
$state == $self->{"_master_state"} and $state != "_STATE_KILLING" and $state != "_STATE_GONE"
$state == $self->{"_master_state"} $state != "_STATE_KILLING" $state != "_STATE_GONE"
Truth table0%0/4
A and B and C
A= $state == $self->{"_master_state"}B= $state != "_STATE_KILLING"C= $state != "_STATE_GONE"
ABCresult
0XX0
10X0
1100
1111
1066 $state != _STATE_KILLING and
1067 $state != _STATE_GONE) {
1068 0 croak "internal error: state jump to itself ($state)!";
1069 }
1070 0 $self->{_master_state} = $state;
1071 0 return $self->_master_wait($async);
1072 }
1073  
1074 0 ▶sub _master_wait {
Subroutine _master_wait: not called CC=70 SCAR=85.1
1075 0 my ($self, $async) = @_;
1076  
1077 0 my $pid = $self->_my_master_pid;
1078 0 ▶ if ($pid) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pid) 0 0 0
1079 0 my $deceased = waitpid($pid, WNOHANG);
1080 0 ▶ if ($deceased == $pid or ($deceased < 0 and $! == Errno::ECHILD())) {
Branch: 1 branch
BranchTrueFalseTotal
if ($deceased == $pid or $deceased < 0 and $! == 10) 0 0 0
Condition0%0/6
$deceased == $pid or $deceased < 0 and $! == 10
l!l&&r!l&&!r
000
$deceased < 0 and $! == 10
!ll&&!rl&&r
000
MC/DC0%0/3
$deceased == $pid or $deceased < 0 and $! == 10
$deceased == $pid $deceased < 0 $! == 10
Truth table0%0/4
A or B and C
A= $deceased == $pidB= $deceased < 0C= $! == 10
ABCresult
1XX1
0111
00X0
0100
1081 0 ▶ $debug and $debug & 4 and _debug "master $pid exited, rc:", $?,", err: ",$!;
Branch: 1 branch
BranchTrueFalseTotal
$Net::OpenSSH::debug and $Net::OpenSSH::debug & 4 and _debug("master $pid exited, rc:", $?, ", err: ", $!) 0 0 0
Condition0%0/3
$Net::OpenSSH::debug and $Net::OpenSSH::debug & 4
!ll&&!rl&&r
000
MC/DC0%0/2
$Net::OpenSSH::debug and $Net::OpenSSH::debug & 4
$Net::OpenSSH::debug $Net::OpenSSH::debug & 4
Truth table0%0/3
A and B
A= $Net::OpenSSH::debugB= $Net::OpenSSH::debug & 4
ABresult
0X0
100
111
1082 0 return $self->_master_gone($async);
1083 }
1084 }
1085  
1086 0 ▶ if ($self->{_master_state} == _STATE_RUNNING) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"_master_state"} == "_STATE_RUNNING") 0 0 0
1087 0 ▶ return 1 if -S $self->{_ctl_path};
Branch: 1 branch
BranchTrueFalseTotal
if -S $self->{"_ctl_path"} 0 0 0
1088 0 return $self->_master_fail($async, "master SSH connection broken");
1089 }
1090  
1091 0 ▶ if ($self->{_master_state} == _STATE_KILLING) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"_master_state"} == "_STATE_KILLING") 0 0 0
1092 0 ▶ $debug and $debug & 4 and _debug "killing master";
Branch: 1 branch
BranchTrueFalseTotal
$Net::OpenSSH::debug and $Net::OpenSSH::debug & 4 and _debug("killing master") 0 0 0
Condition0%0/3
$Net::OpenSSH::debug and $Net::OpenSSH::debug & 4
!ll&&!rl&&r
000
MC/DC0%0/2
$Net::OpenSSH::debug and $Net::OpenSSH::debug & 4
$Net::OpenSSH::debug $Net::OpenSSH::debug & 4
Truth table0%0/3
A and B
A= $Net::OpenSSH::debugB= $Net::OpenSSH::debug & 4
ABresult
0X0
100
111
1093 0 return $self->_master_kill($async);
1094 }
1095  
1096 0 ▶ if ($self->{_master_state} == _STATE_START) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"_master_state"} == "_STATE_START") 0 0 0
1097 0 ▶ if ($self->{_external_master}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"_external_master"}) 0 0 0
1098 0 ▶ return ($self->_master_jump_state(_STATE_RUNNING, $async) and
Condition0%0/3
$self->_master_jump_state(4, $async) && $self->_master_check($async)
!ll&&!rl&&r
000
MC/DC0%0/2
$self->_master_jump_state(4, $async) && $self->_master_check($async)
$self->_master_jump_state(4, $async) $self->_master_check($async)
Truth table0%0/3
A && B
A= $self->_master_jump_state(4, $async)B= $self->_master_check($async)
ABresult
0X0
100
111
1099 $self->_master_check($async))
1100 }
1101  
1102 0 ▶ $self->_master_start($async) or return;
Branch: 1 branch
BranchTrueFalseTotal
$self->_master_start($async) or return 0 0 0
1103 0 ▶ if ($self->{_mpty}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"_mpty"}) 0 0 0
1104 0 $self->{_wfm_bout} = '';
1105 0 $self->{_master_pty_log} = '';
1106 0 ▶ if (defined $self->{_passwd} or $self->{_login_handler}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"_passwd"} or $self->{"_login_handler"}) 0 0 0
Condition0%0/3
defined $self->{"_passwd"} or $self->{"_login_handler"}
l!l&&r!l&&!r
000
MC/DC0%0/2
defined $self->{"_passwd"} or $self->{"_login_handler"}
defined $self->{"_passwd"} $self->{"_login_handler"}
Truth table0%0/3
A or B
A= defined $self->{"_passwd"}B= $self->{"_login_handler"}
ABresult
1X1
011
000
1107 0 return $self->_master_jump_state(_STATE_LOGIN, $async);
1108 }
1109 }
1110 0 return $self->_master_jump_state(_STATE_AWAITING_MUX, $async);
1111 }
1112  
1113 0 ▶ if ($self->{_master_state} == _STATE_GONE) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"_master_state"} == "_STATE_GONE") 0 0 0
1114 0 ▶ if (my $mpty = delete $self->{_mpty}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $mpty = delete $self->{"_mpty"}) 0 0 0
1115 0 close($mpty)
1116 }
1117 0 return 0;
1118 }
1119 0 ▶ if ($self->{_master_state} == _STATE_STOPPED) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"_master_state"} == "_STATE_STOPPED") 0 0 0
1120 0 return 0;
1121 }
1122  
1123 # At this point we are either in state AWAITIN_MUX or LOGIN
1124  
1125 0 local $self->{_error_prefix} = [@{$self->{_error_prefix}},
1126 "unable to establish master SSH connection"];
1127  
1128 0 ▶ $pid or return $self->_master_gone($async,
Branch: 1 branch
BranchTrueFalseTotal
$pid or return $self->_master_gone($async, "perl process was forked or threaded before SSH connection had been established") 0 0 0
1129 "perl process was forked or threaded before SSH connection had been established");
1130  
1131 0 my $old_tcpgrp;
1132 0 ▶ if ($self->{_master_setpgrp} and not $async and
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"_master_setpgrp"} and not $async and not $self->{"_batch_mode"} and not $self->{"_external_master"}) 0 0 0
Condition0%0/9
$self->{"_master_setpgrp"} and not $async and not $self->{"_batch_mode"} and not $self->{"_external_master"}
!ll&&!rl&&r
000
$self->{"_master_setpgrp"} and not $async and not $self->{"_batch_mode"}
!ll&&!rl&&r
000
$self->{"_master_setpgrp"} and not $async
!ll&&!rl&&r
000
MC/DC0%0/4
$self->{"_master_setpgrp"} and not $async and not $self->{"_batch_mode"} and not $self->{"_external_master"}
$self->{"_master_setpgrp"} not $async not $self->{"_batch_mode"} not $self->{"_external_master"}
Truth table0%0/5
A and not(B) and not(C) and not(D)
A= $self->{"_master_setpgrp"}B= not $asyncC= not $self->{"_batch_mode"}D= not $self->{"_external_master"}
ABCDresult
0XXX0
10XX0
110X0
11100
11111
1133 not $self->{_batch_mode} and not $self->{_external_master}) {
1134 0 $old_tcpgrp = POSIX::tcgetpgrp(0);
1135 0 ▶ if ($old_tcpgrp > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($old_tcpgrp > 0) { } 0 0 0
1136 # let the master process ask for passwords at the TTY
1137 0 POSIX::tcsetpgrp(0, $pid);
1138 }
1139 else {
1140 0 undef $old_tcpgrp;
1141 }
1142 }
1143  
1144 0 my $mpty = $self->{_mpty};
1145 0 my $fnopty;
1146 0 my $rv = '';
1147 0 ▶ if ($mpty and
Branch: 1 branch
BranchTrueFalseTotal
if ($mpty and $self->{"_master_state"} == "_STATE_LOGIN" || $self->{"_master_state"} == "_STATE_AWAITING_MUX") 0 0 0
Condition0%0/6
$mpty and $self->{"_master_state"} == "_STATE_LOGIN" || $self->{"_master_state"} == "_STATE_AWAITING_MUX"
!ll&&!rl&&r
000
$self->{"_master_state"} == "_STATE_LOGIN" or $self->{"_master_state"} == "_STATE_AWAITING_MUX"
l!l&&r!l&&!r
000
MC/DC0%0/3
$mpty and $self->{"_master_state"} == "_STATE_LOGIN" || $self->{"_master_state"} == "_STATE_AWAITING_MUX"
$mpty $self->{"_master_state"} == "_STATE_LOGIN" $self->{"_master_state"} == "_STATE_AWAITING_MUX"
Truth table0%0/4
A and B or C
A= $mptyB= $self->{"_master_state"} == "_STATE_LOGIN"C= $self->{"_master_state"} == "_STATE_AWAITING_MUX"
ABCresult
0XX0
1000
11X1
1011
1148 ( $self->{_master_state} == _STATE_LOGIN or
1149 $self->{_master_state} == _STATE_AWAITING_MUX )) {
1150 0 $fnopty = fileno $mpty;
1151 0 vec($rv, $fnopty, 1) = 1
1152 }
1153  
1154 0 my $timeout = $self->{_timeout};
1155 0 ▶ my $dt = ($async ? 0 : 0.02);
Branch: 1 branch
BranchTrueFalseTotal
$async ? : 0 0 0
1156 0 my $start_time = time;
1157 0 my $error;
1158  
1159 # Loop until the mux socket appears or something goes wrong:
1160 0 while (1) {
1161 0 ▶ $dt *= 1.10 if $dt < 0.2; # adaptative delay
Branch: 1 branch
BranchTrueFalseTotal
if $dt < "0.2" 0 0 0
1162 0 ▶ if (-e $self->{_ctl_path}) {
Branch: 1 branch
BranchTrueFalseTotal
if (-e $self->{"_ctl_path"}) 0 0 0
1163 0 ▶ $debug and $debug & 4 and _debug "file object found at $self->{_ctl_path}";
Branch: 1 branch
BranchTrueFalseTotal
$Net::OpenSSH::debug and $Net::OpenSSH::debug & 4 and _debug(qq[file object found at $self->{"_ctl_path"}]) 0 0 0
Condition0%0/3
$Net::OpenSSH::debug and $Net::OpenSSH::debug & 4
!ll&&!rl&&r
000
MC/DC0%0/2
$Net::OpenSSH::debug and $Net::OpenSSH::debug & 4
$Net::OpenSSH::debug $Net::OpenSSH::debug & 4
Truth table0%0/3
A and B
A= $Net::OpenSSH::debugB= $Net::OpenSSH::debug & 4
ABresult
0X0
100
111
1164 0 last;
1165 }
1166 0 ▶ $debug and $debug & 4 and _debug "file object not yet found at $self->{_ctl_path}, state:", $self->{_master_state};
Branch: 1 branch
BranchTrueFalseTotal
$Net::OpenSSH::debug and $Net::OpenSSH::debug & 4 and _debug(qq[file object not yet found at $self->{"_ctl_path"}, state:], $self->{"_master_state"}) 0 0 0
Condition0%0/3
$Net::OpenSSH::debug and $Net::OpenSSH::debug & 4
!ll&&!rl&&r
000
MC/DC0%0/2
$Net::OpenSSH::debug and $Net::OpenSSH::debug & 4
$Net::OpenSSH::debug $Net::OpenSSH::debug & 4
Truth table0%0/3
A and B
A= $Net::OpenSSH::debugB= $Net::OpenSSH::debug & 4
ABresult
0X0
100
111
1167  
1168 0 ▶ if (defined $timeout and (time - $start_time) > $timeout) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $timeout and time - $start_time > $timeout) 0 0 0
Condition0%0/3
defined $timeout and time - $start_time > $timeout
!ll&&!rl&&r
000
MC/DC0%0/2
defined $timeout and time - $start_time > $timeout
defined $timeout time - $start_time > $timeout
Truth table0%0/3
A and B
A= defined $timeoutB= time - $start_time > $timeout
ABresult
0X0
100
111
1169 0 $error = "login timeout";
1170 0 last;
1171 }
1172  
1173 0 my $deceased = waitpid($pid, WNOHANG);
1174 0 ▶ if ($deceased == $pid or ($deceased < 0 and $! == Errno::ECHILD())) {
Branch: 1 branch
BranchTrueFalseTotal
if ($deceased == $pid or $deceased < 0 and $! == 10) 0 0 0
Condition0%0/6
$deceased == $pid or $deceased < 0 and $! == 10
l!l&&r!l&&!r
000
$deceased < 0 and $! == 10
!ll&&!rl&&r
000
MC/DC0%0/3
$deceased == $pid or $deceased < 0 and $! == 10
$deceased == $pid $deceased < 0 $! == 10
Truth table0%0/4
A or B and C
A= $deceased == $pidB= $deceased < 0C= $! == 10
ABCresult
1XX1
0111
00X0
0100
1175 0 $error = "master process exited unexpectedly";
1176 $error = "bad pass" . ($self->{_passphrase} ? 'phrase' : 'word') . " or $error"
1177 0 ▶ if defined $self->{_passwd};
Branch: 2 branches
BranchTrueFalseTotal
if defined $self->{"_passwd"} 0 0 0
$self->{'_passphrase'} ? : 0 0 0
1178 0 delete $self->{_pid};
1179 0 last;
1180 }
1181  
1182 0 ▶ if ($self->{_login_handler} and $self->{_master_state} == _STATE_LOGIN) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'_login_handler'} and $self->{'_master_state'} == 2) { } 0 0 0
Condition0%0/3
$self->{"_login_handler"} and $self->{"_master_state"} == "_STATE_LOGIN"
!ll&&!rl&&r
000
MC/DC0%0/2
$self->{"_login_handler"} and $self->{"_master_state"} == "_STATE_LOGIN"
$self->{"_login_handler"} $self->{"_master_state"} == "_STATE_LOGIN"
Truth table0%0/3
A and B
A= $self->{"_login_handler"}B= $self->{"_master_state"} == "_STATE_LOGIN"
ABresult
0X0
100
111
1183 0 local ($@, $SIG{__DIE__});
1184 0 ▶ if (eval { $self->{_login_handler}->($self, $mpty, \$self->{_wfm_bout}) }) {
Branch: 1 branch
BranchTrueFalseTotal
if (eval { do { $self->{"_login_handler"}->($self, $mpty, \$self->{"_wfm_bout"}) } }) 0 0 0
1185 0 $self->{_master_state} = _STATE_AWAITING_MUX;
1186 0 next;
1187 }
1188 0 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
1189 0 $error = "custom login handler failed: $@";
1190 0 last;
1191 }
1192 # fallback
1193 }
1194 else {
1195 # we keep reading from mpty even after leaving state
1196 # STATE_LOGIN in order to search for additional password
1197 # prompts.
1198 0 my $rv1 = $rv;
1199 0 my $n = select($rv1, undef, undef, $dt);
1200 0 ▶ if ($n > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($n > 0) 0 0 0
1201 0 ▶ vec($rv1, $fnopty, 1) or die "internal error";
Branch: 1 branch
BranchTrueFalseTotal
vec $rv1, $fnopty, 1 or die "internal error" 0 0 0
1202 0 my $read = sysread($mpty, $self->{_wfm_bout}, 4096, length $self->{_wfm_bout});
1203 0 ▶ if ($read) {
Branch: 1 branch
BranchTrueFalseTotal
if ($read) 0 0 0
1204 0 $self->{_master_pty_log} .= substr($self->{_wfm_bout}, -$read);
1205 0 ▶ if ((my $remove = length($self->{_master_pty_log}) - 4096) > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ((my $remove = length($self->{"_master_pty_log"}) - 4096) > 0) 0 0 0
1206 0 substr($self->{_master_pty_log}, 0, $remove) = ''
1207 }
1208  
1209 0 ▶ if ($self->{_wfm_bout} =~ /The authenticity of host.*can't be established/si) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"_wfm_bout"} =~ /The authenticity of host.*can't be established/is) 0 0 0
1210 0 $error = "the authenticity of the target host can't be established; the remote host " .
1211 "public key is probably not present in the '~/.ssh/known_hosts' file";
1212 0 last;
1213 }
1214  
1215 0 ▶ if ($self->{_wfm_bout} =~ /WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED/si) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"_wfm_bout"} =~ /WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED/is) 0 0 0
1216 0 $error = "the authenticity of the target host can't be established; the remote host " .
1217 "public key doesn't match the one stored locally";
1218 0 last;
1219 }
1220  
1221 0 my $passwd_prompt = _first_defined $self->{_passwd_prompt}, qr/[:?]/;
1222 0 ▶ $passwd_prompt = quotemeta $passwd_prompt unless ref $passwd_prompt;
Branch: 1 branch
BranchTrueFalseTotal
unless ref $passwd_prompt 0 0 0
1223  
1224 0 ▶ if ($self->{_master_state} == _STATE_LOGIN) {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->{'_master_state'} == 2) { } 0 0 0
elsif (length $passwd_prompt and $self->{'_wfm_bout'} =~ /^(.*$passwd_prompt)\s*$/s) { } 0 0 0
1225 0 ▶ if ($self->{_wfm_bout} =~ /^(.*$passwd_prompt)/s) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"_wfm_bout"} =~ /^(.*$passwd_prompt)/s) 0 0 0
1226 0 ▶ $debug and $debug & 4 and _debug "passwd/passphrase requested ($1)";
Branch: 1 branch
BranchTrueFalseTotal
$Net::OpenSSH::debug and $Net::OpenSSH::debug & 4 and _debug("passwd/passphrase requested ($1)") 0 0 0
Condition0%0/3
$Net::OpenSSH::debug and $Net::OpenSSH::debug & 4
!ll&&!rl&&r
000
MC/DC0%0/2
$Net::OpenSSH::debug and $Net::OpenSSH::debug & 4
$Net::OpenSSH::debug $Net::OpenSSH::debug & 4
Truth table0%0/3
A and B
A= $Net::OpenSSH::debugB= $Net::OpenSSH::debug & 4
ABresult
0X0
100
111
1227 0 print $mpty $deobfuscate->($self->{_passwd}) . "\n";
1228 0 $self->{_wfm_bout} = ''; # reset
1229 0 $self->{_master_state} = _STATE_AWAITING_MUX;
1230 }
1231 }
1232 ▶ elsif (length($passwd_prompt) and $self->{_wfm_bout} =~ /^(.*$passwd_prompt)\s*$/s) {
Condition0%0/3
length $passwd_prompt and $self->{"_wfm_bout"} =~ /^(.*$passwd_prompt)\s*$/s
!ll&&!rl&&r
000
MC/DC0%0/2
length $passwd_prompt and $self->{"_wfm_bout"} =~ /^(.*$passwd_prompt)\s*$/s
length $passwd_prompt $self->{"_wfm_bout"} =~ /^(.*$passwd_prompt)\s*$/s
Truth table0%0/3
A and B
A= length $passwd_promptB= $self->{"_wfm_bout"} =~ /^(.*$passwd_prompt)\s*$/s
ABresult
0X0
100
111
1233 0 ▶ $debug and $debug & 4 and _debug "passwd/passphrase requested again ($1)";
Branch: 1 branch
BranchTrueFalseTotal
$Net::OpenSSH::debug and $Net::OpenSSH::debug & 4 and _debug("passwd/passphrase requested again ($1)") 0 0 0
Condition0%0/3
$Net::OpenSSH::debug and $Net::OpenSSH::debug & 4
!ll&&!rl&&r
000
MC/DC0%0/2
$Net::OpenSSH::debug and $Net::OpenSSH::debug & 4
$Net::OpenSSH::debug $Net::OpenSSH::debug & 4
Truth table0%0/3
A and B
A= $Net::OpenSSH::debugB= $Net::OpenSSH::debug & 4
ABresult
0X0
100
111
1234 0 $error = "password authentication failed";
1235 0 last;
1236 }
1237 0 next; # skip delay
1238 }
1239 }
1240 }
1241 0 ▶ return if $async;
Branch: 1 branch
BranchTrueFalseTotal
if $async 0 0 0
1242 0 select(undef, undef, undef, $dt);
1243 }
1244  
1245 0 ▶ if (defined $old_tcpgrp) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $old_tcpgrp) 0 0 0
1246 0 ▶ $debug and $debug & 4 and
Branch: 1 branch
BranchTrueFalseTotal
$Net::OpenSSH::debug and $Net::OpenSSH::debug & 4 and _debug("ssh pid: $pid, pgrp: ", getpgrp $pid, ", \$\$: ", $$, ", tcpgrp: ", POSIX::tcgetpgrp(0), ", old_tcppgrp: ", $old_tcpgrp) 0 0 0
Condition0%0/3
$Net::OpenSSH::debug and $Net::OpenSSH::debug & 4
!ll&&!rl&&r
000
MC/DC0%0/2
$Net::OpenSSH::debug and $Net::OpenSSH::debug & 4
$Net::OpenSSH::debug $Net::OpenSSH::debug & 4
Truth table0%0/3
A and B
A= $Net::OpenSSH::debugB= $Net::OpenSSH::debug & 4
ABresult
0X0
100
111
1247 _debug("ssh pid: $pid, pgrp: ", getpgrp($pid),
1248 ", \$\$: ", $$,
1249 ", tcpgrp: ", POSIX::tcgetpgrp(0),
1250 ", old_tcppgrp: ", $old_tcpgrp);
1251 0 local $SIG{TTOU} = 'IGNORE';
1252 0 POSIX::tcsetpgrp(0, $old_tcpgrp);
1253 }
1254  
1255 0 ▶ if ($error) {
Branch: 1 branch
BranchTrueFalseTotal
if ($error) 0 0 0
1256 0 return $self->_master_fail($async, $error);
1257 }
1258  
1259 0 ▶ $self->_master_jump_state(_STATE_RUNNING, $async)
Branch: 1 branch
BranchTrueFalseTotal
$self->_master_jump_state("_STATE_RUNNING", $async) and $self->_master_check($async) 0 0 0
1260 and $self->_master_check($async);
1261 }
1262  
1263 0 ▶sub _master_ctl {
Subroutine _master_ctl: not called CC=2 SCAR=17.9
1264 0 my $self = shift;
1265 0 ▶ my %opts = (ref $_[0] eq 'HASH' ? %{shift()} : ());
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] eq 'HASH' ? : 0 0 0
1266 0 my $cmd = shift;
1267  
1268 0 local $?;
1269 0 local $self->{_error_prefix} = [@{$self->{_error_prefix}},
1270 "control command failed"];
1271 0 $self->capture({ %opts,
1272 encoding => 'bytes', # don't let the encoding
1273 # stuff get in the way
1274 stdin_discard => 1, tty => 0,
1275 stderr_to_stdout => 1, ssh_opts => [-O => $cmd]});
1276 }
1277  
1278 0 ▶sub stop {
Subroutine stop: not called CC=2 SCAR=17.9
Pod undocumented
1279 0 my ($self, $timeout) = @_;
1280 0 my $pid = $self->{_pid};
1281 0 local $self->{_kill_ssh_on_timeout} = 1;
1282 0 $self->_master_ctl({timeout => $timeout}, 'stop');
1283 0 ▶ unless ($self->{_error}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"_error"}) 0 0 0
1284 0 $self->_set_error(OSSH_MASTER_FAILED, "master stopped");
1285 0 $self->_master_jump_state(_STATE_STOPPED, 1);
1286 }
1287 }
1288  
1289 0 ▶sub _make_pipe {
Subroutine _make_pipe: not called CC=2 SCAR=17.9
1290 0 my $self = shift;
1291 0 my ($r, $w);
1292 0 ▶ if (pipe $r, $w) {
Branch: 1 branch
BranchTrueFalseTotal
if (pipe $r, $w) 0 0 0
1293 0 my $old = select;
1294 0 select $r; $ |= 1;
1295 0 select $w; $ |= 1;
1296 0 select $old;
1297 0 return ($r, $w);
1298 }
1299 0 $self->_set_error(OSSH_SLAVE_PIPE_FAILED, "unable to create pipe: $!");
1300 0 return;
1301 }
1302  
1303 0 ▶sub _remote_quoter {
Subroutine _remote_quoter: not called CC=5 SCAR=34.0
1304 0 my ($self, $remote_shell) = @_;
1305 0 ▶ if (ref $self and (!defined $remote_shell or $remote_shell eq $self->{_remote_shell})) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $self and !defined($remote_shell) || $remote_shell eq $self->{"_remote_shell"}) 0 0 0
Condition0%0/6
ref $self and !defined($remote_shell) || $remote_shell eq $self->{"_remote_shell"}
!ll&&!rl&&r
000
not defined $remote_shell or $remote_shell eq $self->{"_remote_shell"}
l!l&&r!l&&!r
000
MC/DC0%0/3
ref $self and !defined($remote_shell) || $remote_shell eq $self->{"_remote_shell"}
ref $self not defined $remote_shell $remote_shell eq $self->{"_remote_shell"}
Truth table0%0/4
A and not(B) or C
A= ref $selfB= not defined $remote_shellC= $remote_shell eq $self->{"_remote_shell"}
ABCresult
0XX0
1000
11X1
1011
1306 0 ▶ return $self->{remote_quoter} ||= Net::OpenSSH::ShellQuoter->quoter($self->{_remote_shell});
Condition0%0/3
$self->{"remote_quoter"} ||= "Net::OpenSSH::ShellQuoter"->quoter($self->{"_remote_shell"})
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->{"remote_quoter"} ||= "Net::OpenSSH::ShellQuoter"->quoter($self->{"_remote_shell"})
$self->{"remote_quoter"} "Net::OpenSSH::ShellQuoter"->quoter($self->{"_remote_shell"})
Truth table0%0/3
A ||= B
A= $self->{"remote_quoter"}B= "Net::OpenSSH::ShellQuoter"->quoter($self->{"_remote_shell"})
ABresult
1X1
011
000
1307 }
1308 0 Net::OpenSSH::ShellQuoter->quoter($remote_shell);
1309 }
1310  
1311 0 ▶sub _quote_args {
Subroutine _quote_args: not called CC=18 SCAR=58.3
1312 0 my $self = shift;
1313 0 my $opts = shift;
1314 0 ▶ ref $opts eq 'HASH' or die "internal error";
Branch: 1 branch
BranchTrueFalseTotal
ref $opts eq "HASH" or die "internal error" 0 0 0
1315 0 my $quote = delete $opts->{quote_args};
1316 0 my $quote_extended = delete $opts->{quote_args_extended};
1317 0 my $glob_quoting = delete $opts->{glob_quoting};
1318 0 ▶ $quote = (@_ > 1) unless defined $quote;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $quote 0 0 0
1319  
1320 0 ▶ if ($quote) {
Branch: 1 branch
BranchTrueFalseTotal
if ($quote) { } 0 0 0
1321 0 my $remote_shell = delete $opts->{remote_shell};
1322 0 my $quoter = $self->_remote_quoter($remote_shell);
1323 0 ▶ my $quote_method = ($glob_quoting ? 'quote_glob' : 'quote');
Branch: 1 branch
BranchTrueFalseTotal
$glob_quoting ? : 0 0 0
1324 # foo => $quoter
1325 # \foo => $quoter_glob
1326 # \\foo => no quoting at all and disable extended quoting as it is not safe
1327 0 my @quoted;
1328 0 for (@_) {
1329 0 ▶ if (ref $_) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $_) { } 0 0 0
1330 0 ▶ if (ref $_ eq 'SCALAR') {
Branch: 2 branches
BranchTrueFalseTotal
if (ref $_ eq 'SCALAR') { } 0 0 0
elsif (ref $_ eq 'REF' and ref $$_ eq 'SCALAR') { } 0 0 0
1331 0 push @quoted, $quoter->quote_glob($self->_expand_vars($$_));
1332 }
1333 ▶ elsif (ref $_ eq 'REF' and ref $$_ eq 'SCALAR') {
Condition0%0/3
ref $_ eq "REF" and ref $$_ eq "SCALAR"
!ll&&!rl&&r
000
MC/DC0%0/2
ref $_ eq "REF" and ref $$_ eq "SCALAR"
ref $_ eq "REF" ref $$_ eq "SCALAR"
Truth table0%0/3
A and B
A= ref $_ eq "REF"B= ref $$_ eq "SCALAR"
ABresult
0X0
100
111
1334 0 push @quoted, $self->_expand_vars($$$_);
1335 0 undef $quote_extended;
1336 }
1337 else {
1338 0 croak "invalid reference in remote command argument list"
1339 }
1340 }
1341 else {
1342 0 push @quoted, $quoter->$quote_method($self->_expand_vars($_));
1343 }
1344 }
1345  
1346 0 ▶ if ($quote_extended) {
Branch: 1 branch
BranchTrueFalseTotal
if ($quote_extended) 0 0 0
1347 0 my @fragments;
1348 0 ▶ if ( $opts->{stdout_discard} and
Branch: 1 branch
BranchTrueFalseTotal
if ($opts->{'stdout_discard'} and $opts->{'stderr_discard'} || $opts->{'stderr_to_stdout'}) { } 0 0 0
Condition0%0/6
$opts->{"stdout_discard"} and $opts->{"stderr_discard"} || $opts->{"stderr_to_stdout"}
!ll&&!rl&&r
000
$opts->{"stderr_discard"} or $opts->{"stderr_to_stdout"}
l!l&&r!l&&!r
000
MC/DC0%0/3
$opts->{"stdout_discard"} and $opts->{"stderr_discard"} || $opts->{"stderr_to_stdout"}
$opts->{"stdout_discard"} $opts->{"stderr_discard"} $opts->{"stderr_to_stdout"}
Truth table0%0/4
A and B or C
A= $opts->{"stdout_discard"}B= $opts->{"stderr_discard"}C= $opts->{"stderr_to_stdout"}
ABCresult
0XX0
1000
11X1
1011
1349 ( $opts->{stderr_discard} or $opts->{stderr_to_stdout} ) ) {
1350 0 @fragments = ('stdout_and_stderr_discard');
1351 0 ▶ push @fragments, 'stdin_discard' if $opts->{stdin_discard};
Branch: 1 branch
BranchTrueFalseTotal
if $opts->{"stdin_discard"} 0 0 0
1352 }
1353 else {
1354 0 @fragments = grep $opts->{$_}, qw(stdin_discard stdout_discard
1355 stderr_discard stderr_to_stdout);
1356 }
1357 0 push @quoted, $quoter->shell_fragments(@fragments);
1358 }
1359 0 ▶ wantarray ? @quoted : join(" ", @quoted);
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
1360 }
1361 else {
1362 0 ▶ croak "reference found in argument list when argument quoting is disabled"
Branch: 1 branch
BranchTrueFalseTotal
if grep ref($_), @_ 0 0 0
1363 if (grep ref, @_);
1364  
1365 0 my @args = $self->_expand_vars(@_);
1366 0 ▶ wantarray ? @args : join(" ", @args);
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
1367 }
1368 }
1369  
1370 0 ▶sub shell_quote {
Subroutine shell_quote: not called CC=1 SCAR=6.9
Pod documented
1371 0 shift->_quote_args({quote_args => 1}, @_);
1372 }
1373  
1374 0 ▶sub shell_quote_glob {
Subroutine shell_quote_glob: not called CC=1 SCAR=6.9
Pod documented
1375 0 shift->_quote_args({quote_args => 1, glob_quoting => 1}, @_);
1376 }
1377  
1378 0 ▶sub _array_or_scalar_to_list { map { defined($_) ? (ref $_ eq 'ARRAY' ? @$_ : $_ ) : () } @_ }
Subroutine _array_or_scalar_to_list: not called CC=3 SCAR=24.8
Branch: 2 branches
BranchTrueFalseTotal
defined $_ ? : 0 0 0
ref $_ eq 'ARRAY' ? : 0 0 0
1379  
1380 0 ▶sub make_remote_command {
Subroutine make_remote_command: not called CC=20 SCAR=60.4
Pod documented
1381 0 my $self = shift;
1382 0 ▶ $self->wait_for_master or return;
Branch: 1 branch
BranchTrueFalseTotal
$self->wait_for_master or return 0 0 0
1383 0 ▶ my %opts = (ref $_[0] eq 'HASH' ? %{shift()} : ());
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] eq 'HASH' ? : 0 0 0
1384 0 my @ssh_opts = _array_or_scalar_to_list delete $opts{ssh_opts};
1385 0 my $tty = delete $opts{tty};
1386 0 my $ssh_flags = '';
1387 0 ▶ $ssh_flags .= ($tty ? 'qtt' : 'T') if defined $tty;
Branch: 2 branches
BranchTrueFalseTotal
if defined $tty 0 0 0
$tty ? : 0 0 0
1388 0 ▶ if ($self->{_forward_agent}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"_forward_agent"}) 0 0 0
1389 0 ▶ my $forward_always = (($self->{_forward_agent} eq 'always') ? 1 : undef);
Branch: 1 branch
BranchTrueFalseTotal
$self->{'_forward_agent'} eq 'always' ? : 0 0 0
1390 0 my $forward_agent = _first_defined(delete($opts{forward_agent}), $forward_always);
1391 0 ▶ $ssh_flags .= ($forward_agent ? 'A' : 'a') if defined $forward_agent;
Branch: 2 branches
BranchTrueFalseTotal
if defined $forward_agent 0 0 0
$forward_agent ? : 0 0 0
1392 }
1393 0 ▶ if ($self->{_forward_X11}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"_forward_X11"}) 0 0 0
1394 0 my $forward_X11 = delete $opts{forward_X11};
1395 0 ▶ $ssh_flags .= ($forward_X11 ? 'X' : 'x');
Branch: 1 branch
BranchTrueFalseTotal
$forward_X11 ? : 0 0 0
1396 }
1397 0 my $tunnel = delete $opts{tunnel};
1398 0 my (@args);
1399 0 ▶ if ($tunnel) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tunnel) { } 0 0 0
1400 0 push @ssh_opts, $self->_make_W_option(@_);
1401 }
1402 else {
1403 0 my $subsystem = delete $opts{subsystem};
1404 0 ▶ if ($subsystem) {
Branch: 1 branch
BranchTrueFalseTotal
if ($subsystem) 0 0 0
1405 0 push @ssh_opts, '-s';
1406 0 ▶ @_ == 1 or croak "wrong number of arguments for subsystem command";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 1 or croak("wrong number of arguments for subsystem command") 0 0 0
1407 }
1408 0 @args = $self->_quote_args(\%opts, @_);
1409 }
1410 0 _croak_bad_options %opts;
1411  
1412 0 ▶ push @ssh_opts, "-$ssh_flags" if length $ssh_flags;
Branch: 1 branch
BranchTrueFalseTotal
if length $ssh_flags 0 0 0
1413 0 my @call = $self->_make_ssh_call(\@ssh_opts, @args);
1414 0 ▶ if (wantarray) {
Branch: 1 branch
BranchTrueFalseTotal
if (wantarray) { } 0 0 0
1415 0 ▶ $debug and $debug & 16 and _debug_dump make_remote_command => \@call;
Branch: 1 branch
BranchTrueFalseTotal
$Net::OpenSSH::debug and $Net::OpenSSH::debug & 16 and _debug_dump("make_remote_command", \@call) 0 0 0
Condition0%0/3
$Net::OpenSSH::debug and $Net::OpenSSH::debug & 16
!ll&&!rl&&r
000
MC/DC0%0/2
$Net::OpenSSH::debug and $Net::OpenSSH::debug & 16
$Net::OpenSSH::debug $Net::OpenSSH::debug & 16
Truth table0%0/3
A and B
A= $Net::OpenSSH::debugB= $Net::OpenSSH::debug & 16
ABresult
0X0
100
111
1416 0 return @call;
1417 }
1418 else {
1419 0 my $call = join ' ', $self->shell_quote(@call);
1420 0 ▶ $debug and $debug & 16 and _debug_dump 'make_remote_command (quoted)' => $call;
Branch: 1 branch
BranchTrueFalseTotal
$Net::OpenSSH::debug and $Net::OpenSSH::debug & 16 and _debug_dump("make_remote_command (quoted)", $call) 0 0 0
Condition0%0/3
$Net::OpenSSH::debug and $Net::OpenSSH::debug & 16
!ll&&!rl&&r
000
MC/DC0%0/2
$Net::OpenSSH::debug and $Net::OpenSSH::debug & 16
$Net::OpenSSH::debug $Net::OpenSSH::debug & 16
Truth table0%0/3
A and B
A= $Net::OpenSSH::debugB= $Net::OpenSSH::debug & 16
ABresult
0X0
100
111
1421 0 return $call
1422 }
1423 }
1424  
1425 0 ▶sub _open_file {
Subroutine _open_file: not called CC=3 SCAR=24.8
1426 0 my ($self, $default_mode, $name_or_args) = @_;
1427 0 ▶ my ($mode, @args) = (ref $name_or_args
Branch: 1 branch
BranchTrueFalseTotal
ref $name_or_args ? : 0 0 0
1428 ? @$name_or_args
1429 : ($default_mode, $name_or_args));
1430 0 @args = $self->_expand_vars(@args);
1431 0 ▶ if (open my $fh, $mode, @args) {
Branch: 1 branch
BranchTrueFalseTotal
if (open my $fh, $mode, @args) { } 0 0 0
1432 0 return $fh;
1433 }
1434 else {
1435 0 $self->_set_error(OSSH_SLAVE_PIPE_FAILED,
1436 "Unable to open file '$args[0]': $!");
1437 0 return undef;
1438 }
1439 }
1440  
1441 0 ▶sub _fileno_dup_over {
Subroutine _fileno_dup_over: not called CC=4 SCAR=30.0
1442 0 my ($good_fn, $fh) = @_;
1443 0 ▶ if (defined $fh) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $fh) 0 0 0
1444 0 my $fn = fileno $fh;
1445 0 for (1..5) {
1446 0 ▶ $fn >= $good_fn and return $fn;
Branch: 1 branch
BranchTrueFalseTotal
$fn >= $good_fn and return $fn 0 0 0
1447 0 $fn = POSIX::dup($fn);
1448 }
1449 0 POSIX::_exit(255);
1450 }
1451 0 undef;
1452 }
1453  
1454 0 ▶sub _exec_dpipe {
Subroutine _exec_dpipe: not called CC=3 SCAR=24.8
1455 0 my ($self, $cmd, $io, $err) = @_;
1456 0 my $io_fd = _fileno_dup_over(3 => $io);
1457 0 my $err_fd = _fileno_dup_over(3 => $err);
1458 0 POSIX::dup2($io_fd, 0);
1459 0 POSIX::dup2($io_fd, 1);
1460 0 ▶ POSIX::dup2($err_fd, 2) if defined $err_fd;
Branch: 1 branch
BranchTrueFalseTotal
if defined $err_fd 0 0 0
1461 0 ▶ if (ref $cmd) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $cmd) { } 0 0 0
1462 0 exec @$cmd;
1463 }
1464 else {
1465 0 exec $cmd;
1466 }
1467 }
1468  
1469 0 ▶sub _delete_stream_encoding {
Subroutine _delete_stream_encoding: not called CC=1 SCAR=6.9
1470 0 my ($self, $opts) = @_;
1471 _first_defined(delete $opts->{stream_encoding},
1472 $opts->{encoding},
1473 0 $self->{_default_stream_encoding});
1474 }
1475  
1476 0 ▶sub _delete_argument_encoding {
Subroutine _delete_argument_encoding: not called CC=1 SCAR=6.9
1477 0 my ($self, $opts) = @_;
1478 _first_defined(delete $opts->{argument_encoding},
1479 delete $opts->{encoding},
1480 0 $self->{_default_argument_encoding});
1481 }
1482  
1483 0 ▶sub open_ex {
Subroutine open_ex: not called CC=97 SCAR=91.6
Pod documented
1484 0 ▶ ${^TAINT} and &_catch_tainted_args;
Branch: 1 branch
BranchTrueFalseTotal
${^TAINT} and &_catch_tainted_args 0 0 0
1485 0 my $self = shift;
1486 0 ▶ my %opts = (ref $_[0] eq 'HASH' ? %{shift()} : ());
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] eq 'HASH' ? : 0 0 0
1487 0 ▶ unless (delete $opts{_no_master_required}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (delete $opts{"_no_master_required"}) 0 0 0
1488 0 ▶ $self->wait_for_master or return;
Branch: 1 branch
BranchTrueFalseTotal
$self->wait_for_master or return 0 0 0
1489 }
1490  
1491 0 my $ssh_flags = '';
1492 0 my $tunnel = delete $opts{tunnel};
1493 0 my ($cmd, $close_slave_pty, @args);
1494 0 ▶ if ($tunnel) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tunnel) { } 0 0 0
1495 0 @args = @_;
1496 }
1497 else {
1498 0 my $argument_encoding = $self->_delete_argument_encoding(\%opts);
1499 0 my $tty = delete $opts{tty};
1500 0 ▶ $ssh_flags .= ($tty ? 'qtt' : 'T') if defined $tty;
Branch: 2 branches
BranchTrueFalseTotal
if defined $tty 0 0 0
$tty ? : 0 0 0
1501  
1502 0 ▶ $cmd = delete $opts{_cmd} || 'ssh';
Condition0%0/2
delete $opts{'_cmd'} || 'ssh'
l!l
00
MC/DC0%0/1
delete $opts{'_cmd'} || 'ssh'
delete $opts{'_cmd'}
Truth table0%0/2
A
A= delete $opts{'_cmd'}
Aresult
11
00
1503 $opts{quote_args_extended} = 1
1504 0 ▶ if (not defined $opts{quote_args_extended} and $cmd eq 'ssh');
Branch: 1 branch
BranchTrueFalseTotal
if not defined $opts{"quote_args_extended"} and $cmd eq "ssh" 0 0 0
Condition0%0/3
not defined $opts{"quote_args_extended"} and $cmd eq "ssh"
!ll&&!rl&&r
000
MC/DC0%0/2
not defined $opts{"quote_args_extended"} and $cmd eq "ssh"
not defined $opts{"quote_args_extended"} $cmd eq "ssh"
Truth table0%0/3
not(A) and B
A= not defined $opts{"quote_args_extended"}B= $cmd eq "ssh"
ABresult
0X0
100
111
1505 0 @args = $self->_quote_args(\%opts, @_);
1506 0 ▶ $self->_encode_args($argument_encoding, @args) or return;
Branch: 1 branch
BranchTrueFalseTotal
$self->_encode_args($argument_encoding, @args) or return 0 0 0
1507 }
1508  
1509 0 my ($stdinout_socket, $stdinout_dpipe_make_parent);
1510 0 my $stdinout_dpipe = delete $opts{stdinout_dpipe};
1511 0 ▶ if ($stdinout_dpipe) {
Branch: 1 branch
BranchTrueFalseTotal
if ($stdinout_dpipe) { } 0 0 0
1512 0 $stdinout_dpipe_make_parent = delete $opts{stdinout_dpipe_make_parent};
1513 0 $stdinout_socket = 1;
1514 }
1515 else {
1516 0 $stdinout_socket = delete $opts{stdinout_socket};
1517 }
1518  
1519 0 my ($stdin_discard, $stdin_pipe, $stdin_fh, $stdin_file, $stdin_pty,
1520 $stdout_discard, $stdout_pipe, $stdout_fh, $stdout_file, $stdout_pty,
1521 $stderr_discard, $stderr_pipe, $stderr_fh, $stderr_file, $stderr_to_stdout);
1522 0 ▶ unless ($stdinout_socket) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($stdinout_socket) 0 0 0
1523 0 ▶ unless ($stdin_discard = delete $opts{stdin_discard} or
Branch: 1 branch
BranchTrueFalseTotal
unless ($stdin_discard = delete $opts{"stdin_discard"} or $stdin_pipe = delete $opts{"stdin_pipe"} or $stdin_fh = delete $opts{"stdin_fh"} or $stdin_file = delete $opts{"stdin_file"}) 0 0 0
Condition0%0/9
$stdin_discard = delete $opts{"stdin_discard"} or $stdin_pipe = delete $opts{"stdin_pipe"} or $stdin_fh = delete $opts{"stdin_fh"} or $stdin_file = delete $opts{"stdin_file"}
l!l&&r!l&&!r
000
$stdin_discard = delete $opts{"stdin_discard"} or $stdin_pipe = delete $opts{"stdin_pipe"} or $stdin_fh = delete $opts{"stdin_fh"}
l!l&&r!l&&!r
000
$stdin_discard = delete $opts{"stdin_discard"} or $stdin_pipe = delete $opts{"stdin_pipe"}
l!l&&r!l&&!r
000
MC/DC0%0/4
$stdin_discard = delete $opts{"stdin_discard"} or $stdin_pipe = delete $opts{"stdin_pipe"} or $stdin_fh = delete $opts{"stdin_fh"} or $stdin_file = delete $opts{"stdin_file"}
$stdin_discard = delete $opts{"stdin_discard"} $stdin_pipe = delete $opts{"stdin_pipe"} $stdin_fh = delete $opts{"stdin_fh"} $stdin_file = delete $opts{"stdin_file"}
Truth table0%0/5
A or B or C or D
A= $stdin_discard = delete $opts{"stdin_discard"}B= $stdin_pipe = delete $opts{"stdin_pipe"}C= $stdin_fh = delete $opts{"stdin_fh"}D= $stdin_file = delete $opts{"stdin_file"}
ABCDresult
1XXX1
01XX1
001X1
00011
00000
1524 $stdin_pipe = delete $opts{stdin_pipe} or
1525 $stdin_fh = delete $opts{stdin_fh} or
1526 $stdin_file = delete $opts{stdin_file}) {
1527 0 ▶ unless ($tunnel) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($tunnel) 0 0 0
1528 0 ▶ if ($stdin_pty = delete $opts{stdin_pty}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($stdin_pty = delete $opts{"stdin_pty"}) 0 0 0
1529 0 $close_slave_pty = _first_defined delete $opts{close_slave_pty}, 1;
1530 }
1531 }
1532 }
1533  
1534 ( $stdout_discard = delete $opts{stdout_discard} or
1535 $stdout_pipe = delete $opts{stdout_pipe} or
1536 $stdout_fh = delete $opts{stdout_fh} or
1537 $stdout_file = delete $opts{stdout_file} or
1538 0 ▶ (not $tunnel and $stdout_pty = delete $opts{stdout_pty}) );
Branch: 1 branch
BranchTrueFalseTotal
$stdout_discard = delete $opts{"stdout_discard"} or $stdout_pipe = delete $opts{"stdout_pipe"} or $stdout_fh = delete $opts{"stdout_fh"} or $stdout_file = delete $opts{"stdout_file"} or ($tunnel or $stdout_pty = delete $opts{"stdout_pty"}) 0 0 0
Condition0%0/15
($stdout_discard = delete $opts{'stdout_discard'}) || ($stdout_pipe = delete $opts{'stdout_pipe'}) || ($stdout_fh = delete $opts{'stdout_fh'}) || ($stdout_file = delete $opts{'stdout_file'}) || ($tunnel || ($stdout_pty = delete $opts{'stdout_pty'}))
l!l&&r!l&&!r
000
$stdout_discard = delete $opts{"stdout_discard"} or $stdout_pipe = delete $opts{"stdout_pipe"} or $stdout_fh = delete $opts{"stdout_fh"} or $stdout_file = delete $opts{"stdout_file"}
l!l&&r!l&&!r
000
$stdout_discard = delete $opts{"stdout_discard"} or $stdout_pipe = delete $opts{"stdout_pipe"} or $stdout_fh = delete $opts{"stdout_fh"}
l!l&&r!l&&!r
000
$stdout_discard = delete $opts{"stdout_discard"} or $stdout_pipe = delete $opts{"stdout_pipe"}
l!l&&r!l&&!r
000
$tunnel or $stdout_pty = delete $opts{"stdout_pty"}
l!l&&r!l&&!r
000
MC/DC0%0/6
($stdout_discard = delete $opts{'stdout_discard'}) || ($stdout_pipe = delete $opts{'stdout_pipe'}) || ($stdout_fh = delete $opts{'stdout_fh'}) || ($stdout_file = delete $opts{'stdout_file'}) || ($tunnel || ($stdout_pty = delete $opts{'stdout_pty'}))
$stdout_discard = delete $opts{"stdout_discard"} $stdout_pipe = delete $opts{"stdout_pipe"} $stdout_fh = delete $opts{"stdout_fh"} $stdout_file = delete $opts{"stdout_file"} $tunnel $stdout_pty = delete $opts{"stdout_pty"}
Truth table0%0/7
A or B or C or D || E or F
A= $stdout_discard = delete $opts{"stdout_discard"}B= $stdout_pipe = delete $opts{"stdout_pipe"}C= $stdout_fh = delete $opts{"stdout_fh"}D= $stdout_file = delete $opts{"stdout_file"}E= $tunnelF= $stdout_pty = delete $opts{"stdout_pty"}
ABCDEFresult
1XXXXX1
01XXXX1
001XXX1
0001XX1
00001X1
0000011
0000000
1539  
1540 0 ▶ $stdout_pty and !$stdin_pty
Branch: 1 branch
BranchTrueFalseTotal
$stdout_pty and not $stdin_pty and croak("option stdout_pty requires stdin_pty set") 0 0 0
Condition0%0/3
$stdout_pty and not $stdin_pty
!ll&&!rl&&r
000
MC/DC0%0/2
$stdout_pty and not $stdin_pty
$stdout_pty not $stdin_pty
Truth table0%0/3
A and not(B)
A= $stdout_ptyB= not $stdin_pty
ABresult
0X0
100
111
1541 and croak "option stdout_pty requires stdin_pty set";
1542 }
1543  
1544 ( $stderr_discard = delete $opts{stderr_discard} or
1545 $stderr_pipe = delete $opts{stderr_pipe} or
1546 $stderr_fh = delete $opts{stderr_fh} or
1547 $stderr_to_stdout = delete $opts{stderr_to_stdout} or
1548 0 ▶ $stderr_file = delete $opts{stderr_file} );
Branch: 1 branch
BranchTrueFalseTotal
$stderr_discard = delete $opts{"stderr_discard"} or $stderr_pipe = delete $opts{"stderr_pipe"} or $stderr_fh = delete $opts{"stderr_fh"} or $stderr_to_stdout = delete $opts{"stderr_to_stdout"} or $stderr_file = delete $opts{"stderr_file"} 0 0 0
Condition0%0/9
$stderr_discard = delete $opts{"stderr_discard"} or $stderr_pipe = delete $opts{"stderr_pipe"} or $stderr_fh = delete $opts{"stderr_fh"} or $stderr_to_stdout = delete $opts{"stderr_to_stdout"}
l!l&&r!l&&!r
000
$stderr_discard = delete $opts{"stderr_discard"} or $stderr_pipe = delete $opts{"stderr_pipe"} or $stderr_fh = delete $opts{"stderr_fh"}
l!l&&r!l&&!r
000
$stderr_discard = delete $opts{"stderr_discard"} or $stderr_pipe = delete $opts{"stderr_pipe"}
l!l&&r!l&&!r
000
MC/DC0%0/4
$stderr_discard = delete $opts{"stderr_discard"} or $stderr_pipe = delete $opts{"stderr_pipe"} or $stderr_fh = delete $opts{"stderr_fh"} or $stderr_to_stdout = delete $opts{"stderr_to_stdout"}
$stderr_discard = delete $opts{"stderr_discard"} $stderr_pipe = delete $opts{"stderr_pipe"} $stderr_fh = delete $opts{"stderr_fh"} $stderr_to_stdout = delete $opts{"stderr_to_stdout"}
Truth table0%0/5
A or B or C or D
A= $stderr_discard = delete $opts{"stderr_discard"}B= $stderr_pipe = delete $opts{"stderr_pipe"}C= $stderr_fh = delete $opts{"stderr_fh"}D= $stderr_to_stdout = delete $opts{"stderr_to_stdout"}
ABCDresult
1XXX1
01XX1
001X1
00011
00000
1549  
1550 0 my $ssh_opts = delete $opts{ssh_opts};
1551 0 ▶ $ssh_opts = $self->{_default_ssh_opts} unless defined $ssh_opts;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $ssh_opts 0 0 0
1552 0 my @ssh_opts = $self->_expand_vars(_array_or_scalar_to_list $ssh_opts);
1553 0 ▶ if ($self->{_forward_agent}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"_forward_agent"}) 0 0 0
1554 0 ▶ my $forward_always = (($self->{_forward_agent} eq 'always') ? 1 : undef);
Branch: 1 branch
BranchTrueFalseTotal
$self->{'_forward_agent'} eq 'always' ? : 0 0 0
1555 0 my $forward_agent = _first_defined(delete($opts{forward_agent}), $forward_always);
1556 0 ▶ $ssh_flags .= ($forward_agent ? 'A' : 'a') if defined $forward_agent;
Branch: 2 branches
BranchTrueFalseTotal
if defined $forward_agent 0 0 0
$forward_agent ? : 0 0 0
1557 }
1558 0 ▶ if ($self->{_forward_X11}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"_forward_X11"}) 0 0 0
1559 0 my $forward_X11 = delete $opts{forward_X11};
1560 0 ▶ $ssh_flags .= ($forward_X11 ? 'X' : 'x');
Branch: 1 branch
BranchTrueFalseTotal
$forward_X11 ? : 0 0 0
1561 }
1562 0 ▶ if (delete $opts{subsystem}) {
Branch: 1 branch
BranchTrueFalseTotal
if (delete $opts{"subsystem"}) 0 0 0
1563 0 $ssh_flags .= 's';
1564 }
1565  
1566 0 my $setpgrp = delete $opts{setpgrp};
1567 0 ▶ undef $setpgrp if defined $stdin_pty;
Branch: 1 branch
BranchTrueFalseTotal
if defined $stdin_pty 0 0 0
1568  
1569 0 _croak_bad_options %opts;
1570  
1571 0 ▶ if (defined $stdin_file) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $stdin_file) 0 0 0
1572 0 ▶ $stdin_fh = $self->_open_file('<', $stdin_file) or return
Branch: 1 branch
BranchTrueFalseTotal
$stdin_fh = $self->_open_file("<", $stdin_file) or return 0 0 0
1573 }
1574 0 ▶ if (defined $stdout_file) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $stdout_file) 0 0 0
1575 0 ▶ $stdout_fh = $self->_open_file('>', $stdout_file) or return
Branch: 1 branch
BranchTrueFalseTotal
$stdout_fh = $self->_open_file(">", $stdout_file) or return 0 0 0
1576 }
1577 0 ▶ if (defined $stderr_file) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $stderr_file) 0 0 0
1578 0 ▶ $stderr_fh = $self->_open_file('>', $stderr_file) or return
Branch: 1 branch
BranchTrueFalseTotal
$stderr_fh = $self->_open_file(">", $stderr_file) or return 0 0 0
1579 }
1580  
1581 0 my ($rin, $win, $rout, $wout, $rerr, $werr);
1582  
1583 0 ▶ if ($stdinout_socket) {
Branch: 1 branch
BranchTrueFalseTotal
if ($stdinout_socket) { } 0 0 0
1584 0 ▶ unless(socketpair $rin, $win, AF_UNIX, SOCK_STREAM, PF_UNSPEC) {
Branch: 1 branch
BranchTrueFalseTotal
unless (socketpair $rin, $win, 1, 1, 0) 0 0 0
1585 0 $self->_set_error(OSSH_SLAVE_PIPE_FAILED, "socketpair failed: $!");
1586 0 return;
1587 }
1588 0 $wout = $rin;
1589 }
1590 else {
1591 0 ▶ if ($stdin_pipe) {
Branch: 3 branches
BranchTrueFalseTotal
if ($stdin_pipe) { } 0 0 0
elsif ($stdin_pty) { } 0 0 0
elsif (defined $stdin_fh) { } 0 0 0
1592 0 ▶ ($rin, $win) = $self->_make_pipe or return;
Branch: 1 branch
BranchTrueFalseTotal
() = $self->_make_pipe or return 0 0 0
1593 }
1594 elsif ($stdin_pty) {
1595 0 _load_module('IO::Pty');
1596 0 $win = IO::Pty->new;
1597 0 ▶ unless ($win) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($win) 0 0 0
1598 0 $self->_set_error(OSSH_SLAVE_PIPE_FAILED, "unable to allocate pseudo-tty: $!");
1599 0 return;
1600 }
1601 0 $rin = $win->slave;
1602 }
1603 elsif (defined $stdin_fh) {
1604 0 $rin = $stdin_fh;
1605 }
1606 else {
1607 $rin = $self->{_default_stdin_fh}
1608 0 }
1609 0 _check_is_system_fh STDIN => $rin;
1610  
1611 0 ▶ if ($stdout_pipe) {
Branch: 3 branches
BranchTrueFalseTotal
if ($stdout_pipe) { } 0 0 0
elsif ($stdout_pty) { } 0 0 0
elsif (defined $stdout_fh) { } 0 0 0
1612 0 ▶ ($rout, $wout) = $self->_make_pipe or return;
Branch: 1 branch
BranchTrueFalseTotal
() = $self->_make_pipe or return 0 0 0
1613 }
1614 elsif ($stdout_pty) {
1615 0 $wout = $rin;
1616 }
1617 elsif (defined $stdout_fh) {
1618 0 $wout = $stdout_fh;
1619 }
1620 else {
1621 0 $wout = $self->{_default_stdout_fh};
1622 }
1623 0 _check_is_system_fh STDOUT => $wout;
1624 }
1625  
1626 0 ▶ unless ($stderr_to_stdout) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($stderr_to_stdout) 0 0 0
1627 0 ▶ if ($stderr_pipe) {
Branch: 2 branches
BranchTrueFalseTotal
if ($stderr_pipe) { } 0 0 0
elsif (defined $stderr_fh) { } 0 0 0
1628 0 ▶ ($rerr, $werr) = $self->_make_pipe or return;
Branch: 1 branch
BranchTrueFalseTotal
() = $self->_make_pipe or return 0 0 0
1629 }
1630 elsif (defined $stderr_fh) {
1631 0 $werr = $stderr_fh;
1632 }
1633 else {
1634 0 $werr = $self->{_default_stderr_fh};
1635 }
1636 0 _check_is_system_fh STDERR => $werr;
1637 }
1638  
1639 0 ▶ push @ssh_opts, "-$ssh_flags" if length $ssh_flags;
Branch: 1 branch
BranchTrueFalseTotal
if length $ssh_flags 0 0 0
1640  
1641 0 ▶ my @call = ( $tunnel ? $self->_make_tunnel_call(\@ssh_opts, @args) :
Branch: 5 branches
BranchTrueFalseTotal
$tunnel ? : 0 0 0
$cmd eq 'ssh' ? : 0 0 0
$cmd eq 'scp' ? : 0 0 0
$cmd eq 'rsync' ? : 0 0 0
$cmd eq 'raw' ? : 0 0 0
1642 $cmd eq 'ssh' ? $self->_make_ssh_call(\@ssh_opts, @args) :
1643 $cmd eq 'scp' ? $self->_make_scp_call(\@ssh_opts, @args) :
1644 $cmd eq 'rsync' ? $self->_make_rsync_call(\@ssh_opts, @args) :
1645 $cmd eq 'raw' ? @args :
1646 die "Internal error: bad _cmd protocol" );
1647  
1648 0 ▶ $debug and $debug & 16 and _debug_dump open_ex => \@call;
Branch: 1 branch
BranchTrueFalseTotal
$Net::OpenSSH::debug and $Net::OpenSSH::debug & 16 and _debug_dump("open_ex", \@call) 0 0 0
Condition0%0/3
$Net::OpenSSH::debug and $Net::OpenSSH::debug & 16
!ll&&!rl&&r
000
MC/DC0%0/2
$Net::OpenSSH::debug and $Net::OpenSSH::debug & 16
$Net::OpenSSH::debug $Net::OpenSSH::debug & 16
Truth table0%0/3
A and B
A= $Net::OpenSSH::debugB= $Net::OpenSSH::debug & 16
ABresult
0X0
100
111
1649  
1650 0 my $pid = fork;
1651 0 ▶ unless ($pid) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($pid) 0 0 0
1652 0 ▶ unless (defined $pid) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $pid) 0 0 0
1653 0 $self->_set_error(OSSH_SLAVE_FAILED,
1654 "unable to fork new ssh slave: $!");
1655 0 return;
1656 }
1657  
1658 0 ▶ setpgrp if $setpgrp;
Branch: 1 branch
BranchTrueFalseTotal
if $setpgrp 0 0 0
1659  
1660 0 ▶ $stdin_discard and (open $rin, '<', '/dev/null' or POSIX::_exit(255));
Branch: 1 branch
BranchTrueFalseTotal
$stdin_discard and open($rin, "<", "/dev/null") || POSIX::_exit(255) 0 0 0
Condition0%0/6
$stdin_discard && (open($rin, '<', '/dev/null') || POSIX::_exit(255))
!ll&&!rl&&r
000
open $rin, "<", "/dev/null" or POSIX::_exit(255)
l!l&&r!l&&!r
000
MC/DC0%0/3
$stdin_discard && (open($rin, '<', '/dev/null') || POSIX::_exit(255))
$stdin_discard open $rin, "<", "/dev/null" POSIX::_exit(255)
Truth table0%0/4
A && B or C
A= $stdin_discardB= open $rin, "<", "/dev/null"C= POSIX::_exit(255)
ABCresult
0XX0
1000
11X1
1011
1661 0 ▶ $stdout_discard and (open $wout, '>', '/dev/null' or POSIX::_exit(255));
Branch: 1 branch
BranchTrueFalseTotal
$stdout_discard and open($wout, ">", "/dev/null") || POSIX::_exit(255) 0 0 0
Condition0%0/6
$stdout_discard && (open($wout, '>', '/dev/null') || POSIX::_exit(255))
!ll&&!rl&&r
000
open $wout, ">", "/dev/null" or POSIX::_exit(255)
l!l&&r!l&&!r
000
MC/DC0%0/3
$stdout_discard && (open($wout, '>', '/dev/null') || POSIX::_exit(255))
$stdout_discard open $wout, ">", "/dev/null" POSIX::_exit(255)
Truth table0%0/4
A && B or C
A= $stdout_discardB= open $wout, ">", "/dev/null"C= POSIX::_exit(255)
ABCresult
0XX0
1000
11X1
1011
1662 0 ▶ $stderr_discard and (open $werr, '>', '/dev/null' or POSIX::_exit(255));
Branch: 1 branch
BranchTrueFalseTotal
$stderr_discard and open($werr, ">", "/dev/null") || POSIX::_exit(255) 0 0 0
Condition0%0/6
$stderr_discard && (open($werr, '>', '/dev/null') || POSIX::_exit(255))
!ll&&!rl&&r
000
open $werr, ">", "/dev/null" or POSIX::_exit(255)
l!l&&r!l&&!r
000
MC/DC0%0/3
$stderr_discard && (open($werr, '>', '/dev/null') || POSIX::_exit(255))
$stderr_discard open $werr, ">", "/dev/null" POSIX::_exit(255)
Truth table0%0/4
A && B or C
A= $stderr_discardB= open $werr, ">", "/dev/null"C= POSIX::_exit(255)
ABCresult
0XX0
1000
11X1
1011
1663  
1664 0 ▶ if ($stdinout_dpipe) {
Branch: 1 branch
BranchTrueFalseTotal
if ($stdinout_dpipe) 0 0 0
1665 0 my $pid1 = fork;
1666 0 ▶ defined $pid1 or POSIX::_exit(255);
Branch: 1 branch
BranchTrueFalseTotal
defined $pid1 or POSIX::_exit(255) 0 0 0
1667  
1668 0 ▶ unless ($pid1 xor $stdinout_dpipe_make_parent) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($pid1 xor $stdinout_dpipe_make_parent) 0 0 0
Condition0%0/4
$pid1 xor $stdinout_dpipe_make_parent
l&&rl&&!r!l&&r!l&&!r
0000
MC/DC0%0/2
$pid1 xor $stdinout_dpipe_make_parent
$pid1 $stdinout_dpipe_make_parent
Truth table0%0/4
A xor B
A= $pid1B= $stdinout_dpipe_make_parent
ABresult
110
101
011
000
1669 0 eval { $self->_exec_dpipe($stdinout_dpipe, $win, $werr) };
1670 0 POSIX::_exit(255);
1671 }
1672 }
1673  
1674 0 my $rin_fd = _fileno_dup_over(0 => $rin);
1675 0 my $wout_fd = _fileno_dup_over(1 => $wout);
1676 0 my $werr_fd = _fileno_dup_over(2 => $werr);
1677  
1678 0 ▶ if (defined $rin_fd) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $rin_fd) 0 0 0
1679 0 ▶ $win->make_slave_controlling_terminal if $stdin_pty;
Branch: 1 branch
BranchTrueFalseTotal
if $stdin_pty 0 0 0
1680 0 ▶ $rin_fd == 0 or POSIX::dup2($rin_fd, 0) or POSIX::_exit(255);
Branch: 1 branch
BranchTrueFalseTotal
$rin_fd == 0 or POSIX::dup2($rin_fd, 0) or POSIX::_exit(255) 0 0 0
Condition0%0/3
$rin_fd == 0 or POSIX::dup2($rin_fd, 0)
l!l&&r!l&&!r
000
MC/DC0%0/2
$rin_fd == 0 or POSIX::dup2($rin_fd, 0)
$rin_fd == 0 POSIX::dup2($rin_fd, 0)
Truth table0%0/3
A or B
A= $rin_fd == 0B= POSIX::dup2($rin_fd, 0)
ABresult
1X1
011
000
1681 }
1682 0 ▶ if (defined $wout_fd) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $wout_fd) 0 0 0
1683 0 ▶ $wout_fd == 1 or POSIX::dup2($wout_fd, 1) or POSIX::_exit(255);
Branch: 1 branch
BranchTrueFalseTotal
$wout_fd == 1 or POSIX::dup2($wout_fd, 1) or POSIX::_exit(255) 0 0 0
Condition0%0/3
$wout_fd == 1 or POSIX::dup2($wout_fd, 1)
l!l&&r!l&&!r
000
MC/DC0%0/2
$wout_fd == 1 or POSIX::dup2($wout_fd, 1)
$wout_fd == 1 POSIX::dup2($wout_fd, 1)
Truth table0%0/3
A or B
A= $wout_fd == 1B= POSIX::dup2($wout_fd, 1)
ABresult
1X1
011
000
1684 }
1685 0 ▶ if (defined $werr_fd) {
Branch: 2 branches
BranchTrueFalseTotal
if (defined $werr_fd) { } 0 0 0
elsif ($stderr_to_stdout) { } 0 0 0
1686 0 ▶ $werr_fd == 2 or POSIX::dup2($werr_fd, 2) or POSIX::_exit(255);
Branch: 1 branch
BranchTrueFalseTotal
$werr_fd == 2 or POSIX::dup2($werr_fd, 2) or POSIX::_exit(255) 0 0 0
Condition0%0/3
$werr_fd == 2 or POSIX::dup2($werr_fd, 2)
l!l&&r!l&&!r
000
MC/DC0%0/2
$werr_fd == 2 or POSIX::dup2($werr_fd, 2)
$werr_fd == 2 POSIX::dup2($werr_fd, 2)
Truth table0%0/3
A or B
A= $werr_fd == 2B= POSIX::dup2($werr_fd, 2)
ABresult
1X1
011
000
1687 }
1688 elsif ($stderr_to_stdout) {
1689 0 ▶ POSIX::dup2(1, 2) or POSIX::_exit(255);
Branch: 1 branch
BranchTrueFalseTotal
POSIX::dup2(1, 2) or POSIX::_exit(255) 0 0 0
1690 }
1691 0 do { exec @call };
1692 0 POSIX::_exit(255);
1693 }
1694 0 ▶ $win->close_slave() if $close_slave_pty;
Branch: 1 branch
BranchTrueFalseTotal
if $close_slave_pty 0 0 0
1695 0 ▶ undef $win if defined $stdinout_dpipe;
Branch: 1 branch
BranchTrueFalseTotal
if defined $stdinout_dpipe 0 0 0
1696 0 ▶ wantarray ? ($win, $rout, $rerr, $pid) : $pid;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
1697 }
1698  
1699 0 ▶sub pipe_in {
Subroutine pipe_in: not called CC=9 SCAR=45.0
Pod documented
1700 0 ▶ ${^TAINT} and &_catch_tainted_args;
Branch: 1 branch
BranchTrueFalseTotal
${^TAINT} and &_catch_tainted_args 0 0 0
1701 0 my $self = shift;
1702 0 ▶ $self->wait_for_master or return;
Branch: 1 branch
BranchTrueFalseTotal
$self->wait_for_master or return 0 0 0
1703 0 ▶ my %opts = (ref $_[0] eq 'HASH' ? %{shift()} : ());
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] eq 'HASH' ? : 0 0 0
1704 0 my $argument_encoding = $self->_delete_argument_encoding(\%opts);
1705 0 my @args = $self->_quote_args(\%opts, @_);
1706 0 _croak_bad_options %opts;
1707  
1708 0 ▶ $self->_encode_args($argument_encoding, @args) or return;
Branch: 1 branch
BranchTrueFalseTotal
$self->_encode_args($argument_encoding, @args) or return 0 0 0
1709 0 my @call = $self->_make_ssh_call([], @args);
1710 0 ▶ $debug and $debug & 16 and _debug_dump pipe_in => @call;
Branch: 1 branch
BranchTrueFalseTotal
$Net::OpenSSH::debug and $Net::OpenSSH::debug & 16 and _debug_dump("pipe_in", @call) 0 0 0
Condition0%0/3
$Net::OpenSSH::debug and $Net::OpenSSH::debug & 16
!ll&&!rl&&r
000
MC/DC0%0/2
$Net::OpenSSH::debug and $Net::OpenSSH::debug & 16
$Net::OpenSSH::debug $Net::OpenSSH::debug & 16
Truth table0%0/3
A and B
A= $Net::OpenSSH::debugB= $Net::OpenSSH::debug & 16
ABresult
0X0
100
111
1711 0 my $pid = open my $rin, '|-', @call;
1712 0 ▶ unless ($pid) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($pid) 0 0 0
1713 0 $self->_set_error(OSSH_SLAVE_FAILED,
1714 "unable to fork new ssh slave: $!");
1715 0 return;
1716 }
1717 0 ▶ wantarray ? ($rin, $pid) : $rin;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
1718 }
1719  
1720 0 ▶sub pipe_out {
Subroutine pipe_out: not called CC=9 SCAR=45.0
Pod documented
1721 0 ▶ ${^TAINT} and &_catch_tainted_args;
Branch: 1 branch
BranchTrueFalseTotal
${^TAINT} and &_catch_tainted_args 0 0 0
1722 0 my $self = shift;
1723 0 ▶ $self->wait_for_master or return;
Branch: 1 branch
BranchTrueFalseTotal
$self->wait_for_master or return 0 0 0
1724 0 ▶ my %opts = (ref $_[0] eq 'HASH' ? %{shift()} : ());
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] eq 'HASH' ? : 0 0 0
1725 0 my $argument_encoding = $self->_delete_argument_encoding(\%opts);
1726 0 my @args = $self->_quote_args(\%opts, @_);
1727 0 _croak_bad_options %opts;
1728  
1729 0 ▶ $self->_encode_args($argument_encoding, @args) or return;
Branch: 1 branch
BranchTrueFalseTotal
$self->_encode_args($argument_encoding, @args) or return 0 0 0
1730 0 my @call = $self->_make_ssh_call([], @args);
1731 0 ▶ $debug and $debug & 16 and _debug_dump pipe_out => @call;
Branch: 1 branch
BranchTrueFalseTotal
$Net::OpenSSH::debug and $Net::OpenSSH::debug & 16 and _debug_dump("pipe_out", @call) 0 0 0
Condition0%0/3
$Net::OpenSSH::debug and $Net::OpenSSH::debug & 16
!ll&&!rl&&r
000
MC/DC0%0/2
$Net::OpenSSH::debug and $Net::OpenSSH::debug & 16
$Net::OpenSSH::debug $Net::OpenSSH::debug & 16
Truth table0%0/3
A and B
A= $Net::OpenSSH::debugB= $Net::OpenSSH::debug & 16
ABresult
0X0
100
111
1732 0 my $pid = open my $rout, '-|', @call;
1733 0 ▶ unless ($pid) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($pid) 0 0 0
1734 0 $self->_set_error(OSSH_SLAVE_FAILED,
1735 "unable to fork new ssh slave: $!");
1736 0 return;
1737 }
1738 0 ▶ wantarray ? ($rout, $pid) : $rout;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
1739 }
1740  
1741 0 ▶sub _find_encoding {
Subroutine _find_encoding: not called CC=4 SCAR=30.0
1742 0 my ($self, $encoding, $data) = @_;
1743 0 ▶ if (defined $encoding and $encoding ne 'bytes') {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $encoding and $encoding ne "bytes") 0 0 0
Condition0%0/3
defined $encoding and $encoding ne "bytes"
!ll&&!rl&&r
000
MC/DC0%0/2
defined $encoding and $encoding ne "bytes"
defined $encoding $encoding ne "bytes"
Truth table0%0/3
A and B
A= defined $encodingB= $encoding ne "bytes"
ABresult
0X0
100
111
1744 0 _load_module('Encode');
1745 0 my $enc = Encode::find_encoding($encoding);
1746 0 ▶ unless (defined $enc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $enc) 0 0 0
1747 0 $self->_set_error(OSSH_ENCODING_ERROR, "bad encoding '$encoding'");
1748 return
1749 0 }
1750 0 return $enc
1751 }
1752 return undef
1753 0 }
1754  
1755 0 ▶sub _encode {
Subroutine _encode: not called CC=6 SCAR=37.4
1756 0 my $self = shift;
1757 0 my $enc = shift;
1758 0 ▶ if (defined $enc and @_) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $enc and @_) 0 0 0
Condition0%0/3
defined $enc and @_
!ll&&!rl&&r
000
MC/DC0%0/2
defined $enc and @_
defined $enc @_
Truth table0%0/3
A and B
A= defined $encB= @_
ABresult
0X0
100
111
1759 0 local ($@, $SIG{__DIE__});
1760 0 eval {
1761 0 for (@_) {
1762 0 ▶ defined or next;
Branch: 1 branch
BranchTrueFalseTotal
defined $_ or next 0 0 0
1763 0 $_ = $enc->encode($_, Encode::FB_CROAK());
1764 }
1765 };
1766 0 ▶ $self->_check_eval_ok(OSSH_ENCODING_ERROR) or return undef;
Branch: 1 branch
BranchTrueFalseTotal
$self->_check_eval_ok(7) or return undef 0 0 0
1767 }
1768 0 1;
1769 }
1770  
1771 0 ▶sub _encode_args {
Subroutine _encode_args: not called CC=3 SCAR=24.8
1772 0 ▶ if (@_ > 2) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_ > 2) 0 0 0
1773 0 my $self = shift;
1774 0 my $encoding = shift;
1775  
1776 0 my $enc = $self->_find_encoding($encoding);
1777 0 ▶ if ($enc) {
Branch: 1 branch
BranchTrueFalseTotal
if ($enc) 0 0 0
1778 0 local $self->{_error_prefix} = [@{$self->{_error_prefix}}, "argument encoding failed"];
1779 0 $self->_encode($enc, @_);
1780 }
1781 0 return !$self->{_error};
1782 }
1783 0 1;
1784 }
1785  
1786 0 ▶sub _decode {
Subroutine _decode: not called CC=3 SCAR=24.8
1787 0 my $self = shift;
1788 0 my $enc = shift;
1789 0 local ($@, $SIG{__DIE__});
1790 0 eval {
1791 0 for (@_) {
1792 0 ▶ defined or next;
Branch: 1 branch
BranchTrueFalseTotal
defined $_ or next 0 0 0
1793 0 $_ = $enc->decode($_, Encode::FB_CROAK());
1794 }
1795 };
1796 0 $self->_check_eval_ok(OSSH_ENCODING_ERROR);
1797 }
1798  
1799 3 my @retriable = (Errno::EINTR(), Errno::EAGAIN());
1800 3 push @retriable, Errno::EWOULDBLOCK() if Errno::EWOULDBLOCK() != Errno::EAGAIN();
1801  
1802 0 ▶sub _io3 {
Subroutine _io3: not called CC=68 SCAR=84.5
1803 0 my ($self, $out, $err, $in, $stdin_data, $timeout, $encoding, $keep_in_open) = @_;
1804 # $self->wait_for_master or return;
1805 0 my @data = _array_or_scalar_to_list $stdin_data;
1806 0 my ($cout, $cerr, $cin) = (defined($out), defined($err), defined($in));
1807 0 ▶ $timeout = $self->{_timeout} unless defined $timeout;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $timeout 0 0 0
1808  
1809 0 ▶ my $has_input = grep { defined and length } @data;
Condition0%0/3
defined $_ && length $_
!ll&&!rl&&r
000
MC/DC0%0/2
defined $_ && length $_
defined $_ length $_
Truth table0%0/3
A && B
A= defined $_B= length $_
ABresult
0X0
100
111
1810 0 ▶ if ($cin and !$has_input) {
Branch: 2 branches
BranchTrueFalseTotal
if ($cin and not $has_input) { } 0 0 0
elsif (not $cin and $has_input) { } 0 0 0
Condition0%0/3
$cin and not $has_input
!ll&&!rl&&r
000
MC/DC0%0/2
$cin and not $has_input
$cin not $has_input
Truth table0%0/3
A and not(B)
A= $cinB= not $has_input
ABresult
0X0
100
111
1811 0 ▶ close $in unless $keep_in_open;
Branch: 1 branch
BranchTrueFalseTotal
unless $keep_in_open 0 0 0
1812 0 undef $cin;
1813 }
1814 ▶ elsif (!$cin and $has_input) {
Condition0%0/3
not $cin and $has_input
!ll&&!rl&&r
000
MC/DC0%0/2
not $cin and $has_input
not $cin $has_input
Truth table0%0/3
not(A) and B
A= not $cinB= $has_input
ABresult
0X0
100
111
1815 0 croak "remote input channel is not defined but data is available for sending"
1816 }
1817  
1818 0 my $enc = $self->_find_encoding($encoding);
1819 0 ▶ if ($enc and @data) {
Branch: 1 branch
BranchTrueFalseTotal
if ($enc and @data) 0 0 0
Condition0%0/3
$enc and @data
!ll&&!rl&&r
000
MC/DC0%0/2
$enc and @data
$enc @data
Truth table0%0/3
A and B
A= $encB= @data
ABresult
0X0
100
111
1820 0 local $self->{_error_prefix} = [@{$self->{_error_prefix}}, "stdin data encoding failed"];
1821 0 ▶ $self->_encode($enc, @data) if $has_input;
Branch: 1 branch
BranchTrueFalseTotal
if $has_input 0 0 0
1822 0 ▶ return if $self->{_error};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"_error"} 0 0 0
1823 }
1824  
1825 0 my $bout = '';
1826 0 my $berr = '';
1827 0 my ($fnoout, $fnoerr, $fnoin);
1828 0 local $SIG{PIPE} = 'IGNORE';
1829  
1830 0 ▶ MLOOP: while ($cout or $cerr or $cin) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cout or $cerr or $cin) 0 0 0
Condition0%0/6
$cout or $cerr or $cin
l!l&&r!l&&!r
000
$cout or $cerr
l!l&&r!l&&!r
000
MC/DC0%0/3
$cout or $cerr or $cin
$cout $cerr $cin
Truth table0%0/4
A or B or C
A= $coutB= $cerrC= $cin
ABCresult
1XX1
01X1
0011
0000
1831 0 ▶ $debug and $debug & 64 and _debug "io3 mloop, cin: " . ($cin || 0) .
Branch: 1 branch
BranchTrueFalseTotal
$Net::OpenSSH::debug and $Net::OpenSSH::debug & 64 and _debug('io3 mloop, cin: ' . ($cin || 0) . ', cout: ' . ($cout || 0) . ', cerr: ' . ($cerr || 0)) 0 0 0
Condition0%0/9
$Net::OpenSSH::debug and $Net::OpenSSH::debug & 64
!ll&&!rl&&r
000
$cin || 0
l!l
00
$cout || 0
l!l
00
$cerr || 0
l!l
00
MC/DC0%0/2
$Net::OpenSSH::debug and $Net::OpenSSH::debug & 64
$Net::OpenSSH::debug $Net::OpenSSH::debug & 64
MC/DC0%0/1
$cin || 0
$cin
MC/DC0%0/1
$cout || 0
$cout
MC/DC0%0/1
$cerr || 0
$cerr
Truth table0%0/3
A and B
A= $Net::OpenSSH::debugB= $Net::OpenSSH::debug & 64
ABresult
0X0
100
111
Truth table0%0/2
A
A= $cin
Aresult
11
00
Truth table0%0/2
A
A= $cout
Aresult
11
00
Truth table0%0/2
A
A= $cerr
Aresult
11
00
1832 ", cout: " . ($cout || 0) . ", cerr: " . ($cerr || 0);
1833 0 my ($rv, $wv);
1834  
1835 0 ▶ if ($cout or $cerr) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cout or $cerr) 0 0 0
Condition0%0/3
$cout or $cerr
l!l&&r!l&&!r
000
MC/DC0%0/2
$cout or $cerr
$cout $cerr
Truth table0%0/3
A or B
A= $coutB= $cerr
ABresult
1X1
011
000
1836 0 $rv = '';
1837 0 ▶ if ($cout) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cout) 0 0 0
1838 0 $fnoout = fileno $out;
1839 0 vec($rv, $fnoout, 1) = 1;
1840 }
1841 0 ▶ if ($cerr) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cerr) 0 0 0
1842 0 $fnoerr = fileno $err;
1843 0 vec($rv, $fnoerr, 1) = 1
1844 }
1845 }
1846  
1847 0 ▶ if ($cin) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cin) 0 0 0
1848 0 $fnoin = fileno $in;
1849 0 $wv = '';
1850 0 vec($wv, $fnoin, 1) = 1;
1851 }
1852  
1853 0 my $recalc_vecs;
1854 0 ▶ FAST: until ($recalc_vecs) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($recalc_vecs) 0 0 0
1855 0 ▶ $debug and $debug & 64 and
Branch: 1 branch
BranchTrueFalseTotal
$Net::OpenSSH::debug and $Net::OpenSSH::debug & 64 and _debug('io3 fast, cin: ' . ($cin || 0) . ', cout: ' . ($cout || 0) . ', cerr: ' . ($cerr || 0)) 0 0 0
Condition0%0/9
$Net::OpenSSH::debug and $Net::OpenSSH::debug & 64
!ll&&!rl&&r
000
$cin || 0
l!l
00
$cout || 0
l!l
00
$cerr || 0
l!l
00
MC/DC0%0/2
$Net::OpenSSH::debug and $Net::OpenSSH::debug & 64
$Net::OpenSSH::debug $Net::OpenSSH::debug & 64
MC/DC0%0/1
$cin || 0
$cin
MC/DC0%0/1
$cout || 0
$cout
MC/DC0%0/1
$cerr || 0
$cerr
Truth table0%0/3
A and B
A= $Net::OpenSSH::debugB= $Net::OpenSSH::debug & 64
ABresult
0X0
100
111
Truth table0%0/2
A
A= $cin
Aresult
11
00
Truth table0%0/2
A
A= $cout
Aresult
11
00
Truth table0%0/2
A
A= $cerr
Aresult
11
00
1856 _debug "io3 fast, cin: " . ($cin || 0) .
1857 ", cout: " . ($cout || 0) . ", cerr: " . ($cerr || 0);
1858 0 my ($rv1, $wv1) = ($rv, $wv);
1859 0 my $n = select ($rv1, $wv1, undef, $timeout);
1860 0 ▶ if ($n > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($n > 0) { } 0 0 0
1861 0 ▶ if ($cout and vec($rv1, $fnoout, 1)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cout and vec $rv1, $fnoout, 1) 0 0 0
Condition0%0/3
$cout and vec $rv1, $fnoout, 1
!ll&&!rl&&r
000
MC/DC0%0/2
$cout and vec $rv1, $fnoout, 1
$cout vec $rv1, $fnoout, 1
Truth table0%0/3
A and B
A= $coutB= vec $rv1, $fnoout, 1
ABresult
0X0
100
111
1862 0 my $offset = length $bout;
1863 0 my $read = sysread($out, $bout, 20480, $offset);
1864 0 ▶ if ($debug and $debug & 64) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Net::OpenSSH::debug and $Net::OpenSSH::debug & 64) 0 0 0
Condition0%0/3
$Net::OpenSSH::debug and $Net::OpenSSH::debug & 64
!ll&&!rl&&r
000
MC/DC0%0/2
$Net::OpenSSH::debug and $Net::OpenSSH::debug & 64
$Net::OpenSSH::debug $Net::OpenSSH::debug & 64
Truth table0%0/3
A and B
A= $Net::OpenSSH::debugB= $Net::OpenSSH::debug & 64
ABresult
0X0
100
111
1865 0 _debug "stdout, bytes read: ", $read, " at offset $offset";
1866 0 ▶ $read and $debug & 128 and _hexdump substr $bout, $offset;
Branch: 1 branch
BranchTrueFalseTotal
$read and $Net::OpenSSH::debug & 128 and _hexdump(substr($bout, $offset)) 0 0 0
Condition0%0/3
$read and $Net::OpenSSH::debug & 128
!ll&&!rl&&r
000
MC/DC0%0/2
$read and $Net::OpenSSH::debug & 128
$read $Net::OpenSSH::debug & 128
Truth table0%0/3
A and B
A= $readB= $Net::OpenSSH::debug & 128
ABresult
0X0
100
111
1867 }
1868 0 ▶ unless ($read or grep $! == $_, @retriable) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($read or grep(($! == $_), @retriable)) 0 0 0
Condition0%0/3
$read or grep(($! == $_), @retriable)
l!l&&r!l&&!r
000
MC/DC0%0/2
$read or grep(($! == $_), @retriable)
$read grep(($! == $_), @retriable)
Truth table0%0/3
A or B
A= $readB= grep(($! == $_), @retriable)
ABresult
1X1
011
000
1869 0 close $out;
1870 0 undef $cout;
1871 0 $recalc_vecs = 1;
1872 }
1873 }
1874 0 ▶ if ($cerr and vec($rv1, $fnoerr, 1)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cerr and vec $rv1, $fnoerr, 1) 0 0 0
Condition0%0/3
$cerr and vec $rv1, $fnoerr, 1
!ll&&!rl&&r
000
MC/DC0%0/2
$cerr and vec $rv1, $fnoerr, 1
$cerr vec $rv1, $fnoerr, 1
Truth table0%0/3
A and B
A= $cerrB= vec $rv1, $fnoerr, 1
ABresult
0X0
100
111
1875 0 my $read = sysread($err, $berr, 20480, length($berr));
1876 0 ▶ $debug and $debug & 64 and _debug "stderr, bytes read: ", $read;
Branch: 1 branch
BranchTrueFalseTotal
$Net::OpenSSH::debug and $Net::OpenSSH::debug & 64 and _debug("stderr, bytes read: ", $read) 0 0 0
Condition0%0/3
$Net::OpenSSH::debug and $Net::OpenSSH::debug & 64
!ll&&!rl&&r
000
MC/DC0%0/2
$Net::OpenSSH::debug and $Net::OpenSSH::debug & 64
$Net::OpenSSH::debug $Net::OpenSSH::debug & 64
Truth table0%0/3
A and B
A= $Net::OpenSSH::debugB= $Net::OpenSSH::debug & 64
ABresult
0X0
100
111
1877 0 ▶ unless ($read or grep $! == $_, @retriable) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($read or grep(($! == $_), @retriable)) 0 0 0
Condition0%0/3
$read or grep(($! == $_), @retriable)
l!l&&r!l&&!r
000
MC/DC0%0/2
$read or grep(($! == $_), @retriable)
$read grep(($! == $_), @retriable)
Truth table0%0/3
A or B
A= $readB= grep(($! == $_), @retriable)
ABresult
1X1
011
000
1878 0 close $err;
1879 0 undef $cerr;
1880 0 $recalc_vecs = 1;
1881 }
1882 }
1883 0 ▶ if ($cin and vec($wv1, $fnoin, 1)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cin and vec $wv1, $fnoin, 1) 0 0 0
Condition0%0/3
$cin and vec $wv1, $fnoin, 1
!ll&&!rl&&r
000
MC/DC0%0/2
$cin and vec $wv1, $fnoin, 1
$cin vec $wv1, $fnoin, 1
Truth table0%0/3
A and B
A= $cinB= vec $wv1, $fnoin, 1
ABresult
0X0
100
111
1884 0 my $written = syswrite($in, $data[0], 20480);
1885 0 ▶ if ($debug and $debug & 64) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Net::OpenSSH::debug and $Net::OpenSSH::debug & 64) 0 0 0
Condition0%0/3
$Net::OpenSSH::debug and $Net::OpenSSH::debug & 64
!ll&&!rl&&r
000
MC/DC0%0/2
$Net::OpenSSH::debug and $Net::OpenSSH::debug & 64
$Net::OpenSSH::debug $Net::OpenSSH::debug & 64
Truth table0%0/3
A and B
A= $Net::OpenSSH::debugB= $Net::OpenSSH::debug & 64
ABresult
0X0
100
111
1886 0 _debug "stdin, bytes written: ", $written;
1887 0 ▶ $written and $debug & 128 and _hexdump substr $data[0], 0, $written;
Branch: 1 branch
BranchTrueFalseTotal
$written and $Net::OpenSSH::debug & 128 and _hexdump(substr($data[0], 0, $written)) 0 0 0
Condition0%0/3
$written and $Net::OpenSSH::debug & 128
!ll&&!rl&&r
000
MC/DC0%0/2
$written and $Net::OpenSSH::debug & 128
$written $Net::OpenSSH::debug & 128
Truth table0%0/3
A and B
A= $writtenB= $Net::OpenSSH::debug & 128
ABresult
0X0
100
111
1888 }
1889 0 ▶ if ($written) {
Branch: 2 branches
BranchTrueFalseTotal
if ($written) { } 0 0 0
elsif (grep(($! == $_), @retriable)) { } 0 0 0
1890 0 substr($data[0], 0, $written, '');
1891 0 ▶ while (@data) {
Branch: 1 branch
BranchTrueFalseTotal
if (@data) 0 0 0
1892 next FAST
1893 0 ▶ if (defined $data[0] and length $data[0]);
Branch: 1 branch
BranchTrueFalseTotal
if defined $data[0] and length $data[0] 0 0 0
Condition0%0/3
defined $data[0] and length $data[0]
!ll&&!rl&&r
000
MC/DC0%0/2
defined $data[0] and length $data[0]
defined $data[0] length $data[0]
Truth table0%0/3
A and B
A= defined $data[0]B= length $data[0]
ABresult
0X0
100
111
1894 0 shift @data;
1895 }
1896 # fallback when stdin queue is exhausted
1897 }
1898 elsif (grep $! == $_, @retriable) {
1899 0 next FAST;
1900 }
1901 0 ▶ close $in unless $keep_in_open;
Branch: 1 branch
BranchTrueFalseTotal
unless $keep_in_open 0 0 0
1902 0 undef $cin;
1903 0 $recalc_vecs = 1;
1904 }
1905 }
1906 else {
1907 0 ▶ next if $n < 0 and grep $! == $_, @retriable;
Branch: 1 branch
BranchTrueFalseTotal
if $n < 0 and grep(($! == $_), @retriable) 0 0 0
Condition0%0/3
$n < 0 and grep(($! == $_), @retriable)
!ll&&!rl&&r
000
MC/DC0%0/2
$n < 0 and grep(($! == $_), @retriable)
$n < 0 grep(($! == $_), @retriable)
Truth table0%0/3
A and B
A= $n < 0B= grep(($! == $_), @retriable)
ABresult
0X0
100
111
1908 0 $self->_set_error(OSSH_SLAVE_TIMEOUT, 'ssh slave failed', 'timed out');
1909 0 last MLOOP;
1910 }
1911 }
1912 }
1913 0 ▶ close $out if $cout;
Branch: 1 branch
BranchTrueFalseTotal
if $cout 0 0 0
1914 0 ▶ close $err if $cerr;
Branch: 1 branch
BranchTrueFalseTotal
if $cerr 0 0 0
1915 0 ▶ close $in if $cin and not $keep_in_open;
Branch: 1 branch
BranchTrueFalseTotal
if $cin and not $keep_in_open 0 0 0
Condition0%0/3
$cin and not $keep_in_open
!ll&&!rl&&r
000
MC/DC0%0/2
$cin and not $keep_in_open
$cin not $keep_in_open
Truth table0%0/3
A and not(B)
A= $cinB= not $keep_in_open
ABresult
0X0
100
111
1916  
1917 0 ▶ if ($enc) {
Branch: 1 branch
BranchTrueFalseTotal
if ($enc) 0 0 0
1918 0 local $self->{_error_prefix} = [@{$self->{_error_prefix}}, 'output decoding failed'];
1919 0 ▶ unless ($self->_decode($enc, $bout, $berr)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->_decode($enc, $bout, $berr)) 0 0 0
1920 0 undef $bout;
1921 0 undef $berr;
1922 }
1923 }
1924 0 ▶ $debug and $debug & 64 and _debug "leaving _io3()";
Branch: 1 branch
BranchTrueFalseTotal
$Net::OpenSSH::debug and $Net::OpenSSH::debug & 64 and _debug("leaving _io3()") 0 0 0
Condition0%0/3
$Net::OpenSSH::debug and $Net::OpenSSH::debug & 64
!ll&&!rl&&r
000
MC/DC0%0/2
$Net::OpenSSH::debug and $Net::OpenSSH::debug & 64
$Net::OpenSSH::debug $Net::OpenSSH::debug & 64
Truth table0%0/3
A and B
A= $Net::OpenSSH::debugB= $Net::OpenSSH::debug & 64
ABresult
0X0
100
111
1925 0 return ($bout, $berr);
1926 }
1927  
1928  
1929  
1930 3 _sub_options spawn => qw(stderr_to_stdout stdin_discard stdin_fh stdin_file stdout_discard stdout_fh
1931 stdout_file stderr_discard stderr_fh stderr_file stdinout_dpipe
1932 stdinout_dpipe_make_parent quote_args quote_args_extended remote_shell
1933 glob_quoting tty ssh_opts tunnel encoding argument_encoding forward_agent
1934 forward_X11 setpgrp subsystem);
1935 0 ▶sub spawn {
Subroutine spawn: not called CC=3 SCAR=24.8
Pod documented
1936 0 ▶ ${^TAINT} and &_catch_tainted_args;
Branch: 1 branch
BranchTrueFalseTotal
${^TAINT} and &_catch_tainted_args 0 0 0
1937 0 my $self = shift;
1938 0 ▶ my %opts = (ref $_[0] eq 'HASH' ? %{shift()} : ());
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] eq 'HASH' ? : 0 0 0
1939 0 _croak_bad_options %opts;
1940  
1941 0 return scalar $self->open_ex(\%opts, @_);
1942 }
1943  
1944 3 _sub_options open2 => qw(stderr_to_stdout stderr_discard stderr_fh stderr_file quote_args quote_args_extended
1945 remote_shell glob_quoting tty ssh_opts tunnel encoding argument_encoding forward_agent
1946 forward_X11 setpgrp subsystem);
1947 0 ▶sub open2 {
Subroutine open2: not called CC=4 SCAR=30.0
Pod documented
1948 0 ▶ ${^TAINT} and &_catch_tainted_args;
Branch: 1 branch
BranchTrueFalseTotal
${^TAINT} and &_catch_tainted_args 0 0 0
1949 0 my $self = shift;
1950 0 ▶ my %opts = (ref $_[0] eq 'HASH' ? %{shift()} : ());
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] eq 'HASH' ? : 0 0 0
1951 0 _croak_bad_options %opts;
1952 0 _croak_scalar_context;
1953  
1954 0 ▶ my ($in, $out, undef, $pid) =
Branch: 1 branch
BranchTrueFalseTotal
() = $self->open_ex({"stdout_pipe", 1, "stdin_pipe", 1, %opts}, @_) or return () 0 0 0
1955 $self->open_ex({ stdout_pipe => 1,
1956 stdin_pipe => 1,
1957 %opts }, @_) or return ();
1958 0 return ($in, $out, $pid);
1959 }
1960  
1961 3 _sub_options open2pty => qw(stderr_to_stdout stderr_discard stderr_fh stderr_file
1962 quote_args quote_args_extended remote_shell glob_quoting tty
1963 close_slave_pty ssh_opts encoding argument_encoding forward_agent
1964 forward_X11 setpgrp subsystem);
1965 0 ▶sub open2pty {
Subroutine open2pty: not called CC=5 SCAR=34.0
Pod documented
1966 0 ▶ ${^TAINT} and &_catch_tainted_args;
Branch: 1 branch
BranchTrueFalseTotal
${^TAINT} and &_catch_tainted_args 0 0 0
1967 0 my $self = shift;
1968 0 ▶ my %opts = (ref $_[0] eq 'HASH' ? %{shift()} : ());
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] eq 'HASH' ? : 0 0 0
1969 0 _croak_bad_options %opts;
1970  
1971 0 ▶ my ($pty, undef, undef, $pid) =
Branch: 1 branch
BranchTrueFalseTotal
my($pty, undef, undef, $pid) = $self->open_ex({"stdout_pty", 1, "stdin_pty", 1, "tty", 1, %opts}, @_) or return () 0 0 0
1972 $self->open_ex({ stdout_pty => 1,
1973 stdin_pty => 1,
1974 tty => 1,
1975 %opts }, @_) or return ();
1976 0 ▶ wantarray ? ($pty, $pid) : $pty;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
1977 }
1978  
1979 3 _sub_options open2socket => qw(stderr_to_stdout stderr_discard stderr_fh stderr_file
1980 quote_args quote_args_extended remote_shell glob_quoting tty
1981 ssh_opts tunnel encoding argument_encoding forward_agent
1982 forward_X11 setpgrp subsystem);
1983 0 ▶sub open2socket {
Subroutine open2socket: not called CC=5 SCAR=34.0
Pod documented
1984 0 ▶ ${^TAINT} and &_catch_tainted_args;
Branch: 1 branch
BranchTrueFalseTotal
${^TAINT} and &_catch_tainted_args 0 0 0
1985 0 my $self = shift;
1986 0 ▶ my %opts = (ref $_[0] eq 'HASH' ? %{shift()} : ());
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] eq 'HASH' ? : 0 0 0
1987 0 _croak_bad_options %opts;
1988  
1989 0 ▶ my ($socket, undef, undef, $pid) =
Branch: 1 branch
BranchTrueFalseTotal
my($socket, undef, undef, $pid) = $self->open_ex({"stdinout_socket", 1, %opts}, @_) or return () 0 0 0
1990 $self->open_ex({ stdinout_socket => 1,
1991 %opts }, @_) or return ();
1992 0 ▶ wantarray ? ($socket, $pid) : $socket;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
1993 }
1994  
1995 3 _sub_options open3 => qw(quote_args quote_args_extended remote_shell glob_quoting tty ssh_opts
1996 encoding argument_encoding forward_agent forward_X11 setpgrp subsystem);
1997 0 ▶sub open3 {
Subroutine open3: not called CC=4 SCAR=30.0
Pod documented
1998 0 ▶ ${^TAINT} and &_catch_tainted_args;
Branch: 1 branch
BranchTrueFalseTotal
${^TAINT} and &_catch_tainted_args 0 0 0
1999 0 my $self = shift;
2000 0 ▶ my %opts = (ref $_[0] eq 'HASH' ? %{shift()} : ());
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] eq 'HASH' ? : 0 0 0
2001 0 _croak_bad_options %opts;
2002 0 _croak_scalar_context;
2003  
2004 0 ▶ my ($in, $out, $err, $pid) =
Branch: 1 branch
BranchTrueFalseTotal
() = $self->open_ex({"stdout_pipe", 1, "stdin_pipe", 1, "stderr_pipe", 1, %opts}, @_) or return () 0 0 0
2005 $self->open_ex({ stdout_pipe => 1,
2006 stdin_pipe => 1,
2007 stderr_pipe => 1,
2008 %opts },
2009 @_) or return ();
2010 0 return ($in, $out, $err, $pid);
2011 }
2012  
2013 3 _sub_options open3pty => qw(quote_args quote_args_extended remote_shell glob_quoting tty close_slave_pty ssh_opts
2014 encoding argument_encoding forward_agent forward_X11 setpgrp subsystem);
2015 0 ▶sub open3pty {
Subroutine open3pty: not called CC=4 SCAR=30.0
Pod documented
2016 0 ▶ ${^TAINT} and &_catch_tainted_args;
Branch: 1 branch
BranchTrueFalseTotal
${^TAINT} and &_catch_tainted_args 0 0 0
2017 0 my $self = shift;
2018 0 ▶ my %opts = (ref $_[0] eq 'HASH' ? %{shift()} : ());
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] eq 'HASH' ? : 0 0 0
2019 0 _croak_bad_options %opts;
2020 0 _croak_scalar_context;
2021  
2022 0 ▶ my ($pty, undef, $err, $pid) =
Branch: 1 branch
BranchTrueFalseTotal
my($pty, undef, $err, $pid) = $self->open_ex({"stdout_pty", 1, "stdin_pty", 1, "tty", 1, "stderr_pipe", 1, %opts}, @_) or return () 0 0 0
2023 $self->open_ex({ stdout_pty => 1,
2024 stdin_pty => 1,
2025 tty => 1,
2026 stderr_pipe => 1,
2027 %opts },
2028 @_) or return ();
2029 0 return ($pty, $err, $pid);
2030 }
2031  
2032 3 _sub_options open3socket => qw(quote_args quote_args_extended remote_shell glob_quoting tty ssh_opts encoding
2033 argument_encoding forward_agent forward_X11 setpgrp subsystem);
2034 0 ▶sub open3socket {
Subroutine open3socket: not called CC=4 SCAR=30.0
Pod undocumented
2035 0 ▶ ${^TAINT} and &_catch_tainted_args;
Branch: 1 branch
BranchTrueFalseTotal
${^TAINT} and &_catch_tainted_args 0 0 0
2036 0 my $self = shift;
2037 0 ▶ my %opts = (ref $_[0] eq 'HASH' ? %{shift()} : ());
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] eq 'HASH' ? : 0 0 0
2038 0 _croak_bad_options %opts;
2039 0 _croak_scalar_context;
2040  
2041 0 ▶ my ($socket, undef, $err, $pid) =
Branch: 1 branch
BranchTrueFalseTotal
my($socket, undef, $err, $pid) = $self->open_ex({"stdinout_socket", 1, "stderr_pipe", 1, %opts}, @_) or return () 0 0 0
2042 $self->open_ex({ stdinout_socket => 1,
2043 stderr_pipe => 1,
2044 %opts }, @_) or return ();
2045 0 return ($socket, $err, $pid);
2046 }
2047  
2048 3 _sub_options system => qw(stdout_discard stdout_fh stdin_discard stdout_file stdin_fh stdin_file
2049 quote_args quote_args_extended remote_shell glob_quoting
2050 stderr_to_stdout stderr_discard stderr_fh stderr_file
2051 stdinout_dpipe stdinout_dpipe_make_parent tty ssh_opts tunnel encoding
2052 argument_encoding forward_agent forward_X11 setpgrp subsystem);
2053 0 ▶sub system {
Subroutine system: not called CC=10 SCAR=47.0
Pod documented
2054 0 ▶ ${^TAINT} and &_catch_tainted_args;
Branch: 1 branch
BranchTrueFalseTotal
${^TAINT} and &_catch_tainted_args 0 0 0
2055 0 my $self = shift;
2056 0 ▶ my %opts = (ref $_[0] eq 'HASH' ? %{shift()} : ());
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] eq 'HASH' ? : 0 0 0
2057 0 my $stdin_data = delete $opts{stdin_data};
2058 0 my $timeout = delete $opts{timeout};
2059 0 my $async = delete $opts{async};
2060 0 ▶ my $stdin_keep_open = ($async ? undef : delete $opts{stdin_keep_open});
Branch: 1 branch
BranchTrueFalseTotal
$async ? : 0 0 0
2061  
2062 0 _croak_bad_options %opts;
2063  
2064 0 ▶ $stdin_data = '' if $stdin_keep_open and not defined $stdin_data;
Branch: 1 branch
BranchTrueFalseTotal
if $stdin_keep_open and not defined $stdin_data 0 0 0
Condition0%0/3
$stdin_keep_open and not defined $stdin_data
!ll&&!rl&&r
000
MC/DC0%0/2
$stdin_keep_open and not defined $stdin_data
$stdin_keep_open not defined $stdin_data
Truth table0%0/3
A and not(B)
A= $stdin_keep_openB= not defined $stdin_data
ABresult
0X0
100
111
2065  
2066 0 my $stream_encoding;
2067 0 ▶ if (defined $stdin_data) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $stdin_data) 0 0 0
2068 0 $opts{stdin_pipe} = 1;
2069 0 $stream_encoding = $self->_delete_stream_encoding(\%opts);
2070 }
2071  
2072 0 local $SIG{INT} = 'IGNORE';
2073 0 local $SIG{QUIT} = 'IGNORE';
2074 0 local $SIG{CHLD};
2075  
2076 0 ▶ my ($in, undef, undef, $pid) = $self->open_ex(\%opts, @_) or return undef;
Branch: 1 branch
BranchTrueFalseTotal
my($in, undef, undef, $pid) = $self->open_ex(\%opts, @_) or return undef 0 0 0
2077  
2078 0 ▶ $self->_io3(undef, undef, $in, $stdin_data,
Branch: 1 branch
BranchTrueFalseTotal
if defined $stdin_data 0 0 0
2079 $timeout, $stream_encoding, $stdin_keep_open) if defined $stdin_data;
2080 0 ▶ return $pid if $async;
Branch: 1 branch
BranchTrueFalseTotal
if $async 0 0 0
2081 0 $self->_waitpid($pid, $timeout);
2082 }
2083  
2084 3 _sub_options test => qw(stdout_discard stdout_fh stdin_discard stdout_file stdin_fh stdin_file
2085 quote_args quote_args_extended remote_shell glob_quoting stderr_to_stdout
2086 stderr_discard stderr_fh stderr_file stdinout_dpipe
2087 stdinout_dpipe_make_parent tty ssh_opts timeout stdin_data stdin_keep_open
2088 encoding stream_encoding argument_encoding forward_agent forward_X11
2089 setpgrp subsystem);
2090  
2091 0 ▶sub test {
Subroutine test: not called CC=7 SCAR=40.3
Pod documented
2092 0 ▶ ${^TAINT} and &_catch_tainted_args;
Branch: 1 branch
BranchTrueFalseTotal
${^TAINT} and &_catch_tainted_args 0 0 0
2093 0 my $self = shift;
2094 0 ▶ my %opts = (ref $_[0] eq 'HASH' ? %{shift()} : ());
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] eq 'HASH' ? : 0 0 0
2095 0 ▶ $opts{stdout_discard} = 1 unless grep defined($opts{$_}), qw(stdout_discard stdout_fh
Branch: 1 branch
BranchTrueFalseTotal
unless grep defined($opts{$_}), ("stdout_discard", "stdout_fh", "stdout_file", "stdinout_dpipe") 0 0 0
2096 stdout_file stdinout_dpipe);
2097 0 ▶ $opts{stderr_discard} = 1 unless grep defined($opts{$_}), qw(stderr_discard stderr_fh
Branch: 1 branch
BranchTrueFalseTotal
unless grep defined($opts{$_}), ("stderr_discard", "stderr_fh", "stderr_file", "stderr_to_stdout") 0 0 0
2098 stderr_file stderr_to_stdout);
2099 0 _croak_bad_options %opts;
2100  
2101 0 $self->system(\%opts, @_);
2102 0 my $error = $self->{_error};
2103 0 ▶ unless ($error) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($error) 0 0 0
2104 0 return 1;
2105 }
2106 0 ▶ if ($error == OSSH_SLAVE_CMD_FAILED) {
Branch: 1 branch
BranchTrueFalseTotal
if ($error == 5) 0 0 0
2107 0 $self->_set_error(0);
2108 0 return 0;
2109 }
2110 0 return undef;
2111 }
2112  
2113 3 _sub_options capture => qw(stderr_to_stdout stderr_discard stderr_fh stderr_file stdin_discard
2114 stdin_fh stdin_file quote_args quote_args_extended remote_shell
2115 glob_quoting tty ssh_opts tunnel encoding argument_encoding forward_agent
2116 forward_X11 setpgrp subsystem);
2117 0 ▶sub capture {
Subroutine capture: not called CC=8 SCAR=42.8
Pod documented
2118 0 ▶ ${^TAINT} and &_catch_tainted_args;
Branch: 1 branch
BranchTrueFalseTotal
${^TAINT} and &_catch_tainted_args 0 0 0
2119 0 my $self = shift;
2120 0 ▶ my %opts = (ref $_[0] eq 'HASH' ? %{shift()} : ());
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] eq 'HASH' ? : 0 0 0
2121 0 my $stdin_data = delete $opts{stdin_data};
2122 0 my $stdin_keep_open = delete $opts{stdin_keep_open};
2123 0 my $timeout = delete $opts{timeout};
2124 0 _croak_bad_options %opts;
2125  
2126 0 ▶ $stdin_data = '' if $stdin_keep_open and not defined $stdin_data;
Branch: 1 branch
BranchTrueFalseTotal
if $stdin_keep_open and not defined $stdin_data 0 0 0
Condition0%0/3
$stdin_keep_open and not defined $stdin_data
!ll&&!rl&&r
000
MC/DC0%0/2
$stdin_keep_open and not defined $stdin_data
$stdin_keep_open not defined $stdin_data
Truth table0%0/3
A and not(B)
A= $stdin_keep_openB= not defined $stdin_data
ABresult
0X0
100
111
2127  
2128 0 my $stream_encoding = $self->_delete_stream_encoding(\%opts);
2129 0 $opts{stdout_pipe} = 1;
2130 0 ▶ $opts{stdin_pipe} = 1 if defined $stdin_data;
Branch: 1 branch
BranchTrueFalseTotal
if defined $stdin_data 0 0 0
2131  
2132 0 local $SIG{INT} = 'IGNORE';
2133 0 local $SIG{QUIT} = 'IGNORE';
2134 0 local $SIG{CHLD};
2135  
2136 0 ▶ my ($in, $out, undef, $pid) = $self->open_ex(\%opts, @_) or return ();
Branch: 1 branch
BranchTrueFalseTotal
() = $self->open_ex(\%opts, @_) or return () 0 0 0
2137 0 my ($output) = $self->_io3($out, undef, $in, $stdin_data,
2138 $timeout, $stream_encoding, $stdin_keep_open);
2139 0 $self->_waitpid($pid, $timeout);
2140 0 ▶ if (wantarray) {
Branch: 1 branch
BranchTrueFalseTotal
if (wantarray) 0 0 0
2141 0 my $pattern = quotemeta $/;
2142 0 return split /(?<=$pattern)/, $output;
2143 }
2144 $output
2145 0 }
2146  
2147 3 _sub_options capture2 => qw(stdin_discard stdin_fh stdin_file quote_args quote_args_extended
2148 remote_shell glob_quoting tty ssh_opts encoding stream_encoding
2149 argument_encoding forward_agent forward_X11 setpgrp subsystem);
2150 0 ▶sub capture2 {
Subroutine capture2: not called CC=8 SCAR=42.8
Pod documented
2151 0 ▶ ${^TAINT} and &_catch_tainted_args;
Branch: 1 branch
BranchTrueFalseTotal
${^TAINT} and &_catch_tainted_args 0 0 0
2152 0 my $self = shift;
2153 0 ▶ my %opts = (ref $_[0] eq 'HASH' ? %{shift()} : ());
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] eq 'HASH' ? : 0 0 0
2154 0 my $stdin_data = delete $opts{stdin_data};
2155 0 my $stdin_keep_open = delete $opts{stdin_keep_open};
2156 0 my $timeout = delete $opts{timeout};
2157 0 _croak_bad_options %opts;
2158  
2159 0 ▶ $stdin_data = '' if $stdin_keep_open and not defined $stdin_data;
Branch: 1 branch
BranchTrueFalseTotal
if $stdin_keep_open and not defined $stdin_data 0 0 0
Condition0%0/3
$stdin_keep_open and not defined $stdin_data
!ll&&!rl&&r
000
MC/DC0%0/2
$stdin_keep_open and not defined $stdin_data
$stdin_keep_open not defined $stdin_data
Truth table0%0/3
A and not(B)
A= $stdin_keep_openB= not defined $stdin_data
ABresult
0X0
100
111
2160  
2161 0 my $stream_encoding = $self->_delete_stream_encoding(\%opts);
2162 0 $opts{stdout_pipe} = 1;
2163 0 $opts{stderr_pipe} = 1;
2164 0 ▶ $opts{stdin_pipe} = 1 if defined $stdin_data;
Branch: 1 branch
BranchTrueFalseTotal
if defined $stdin_data 0 0 0
2165  
2166 0 local $SIG{INT} = 'IGNORE';
2167 0 local $SIG{QUIT} = 'IGNORE';
2168 0 local $SIG{CHLD};
2169  
2170 0 ▶ my ($in, $out, $err, $pid) = $self->open_ex( \%opts, @_) or return ();
Branch: 1 branch
BranchTrueFalseTotal
() = $self->open_ex(\%opts, @_) or return () 0 0 0
2171 0 my @capture = $self->_io3($out, $err, $in, $stdin_data,
2172 $timeout, $stream_encoding, $stdin_keep_open);
2173 0 $self->_waitpid($pid, $timeout);
2174 0 ▶ wantarray ? @capture : $capture[0];
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
2175 }
2176  
2177 3 _sub_options open_tunnel => qw(ssh_opts stderr_discard stderr_fh stderr_file
2178 encoding argument_encoding forward_agent setpgrp);
2179 0 ▶sub open_tunnel {
Subroutine open_tunnel: not called CC=5 SCAR=34.0
Pod documented
2180 0 ▶ ${^TAINT} and &_catch_tainted_args;
Branch: 1 branch
BranchTrueFalseTotal
${^TAINT} and &_catch_tainted_args 0 0 0
2181 0 my $self = shift;
2182 0 ▶ my %opts = (ref $_[0] eq 'HASH' ? %{shift()} : ());
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] eq 'HASH' ? : 0 0 0
2183 0 ▶ $opts{stderr_discard} = 1 unless grep defined $opts{$_}, qw(stderr_discard stderr_fh stderr_file);
Branch: 1 branch
BranchTrueFalseTotal
unless grep defined($opts{$_}), ("stderr_discard", "stderr_fh", "stderr_file") 0 0 0
2184 0 _croak_bad_options %opts;
2185 0 ▶ @_ == 2 or croak 'Usage: $ssh->open_tunnel(\%opts, $host, $port)';
Branch: 1 branch
BranchTrueFalseTotal
@_ == 2 or croak("Usage: \$ssh->open_tunnel(\\%opts, \$host, \$port)") 0 0 0
2186 0 $opts{tunnel} = 1;
2187 0 $self->open2socket(\%opts, @_);
2188 }
2189  
2190 3 _sub_options capture_tunnel => qw(ssh_opts stderr_discard stderr_fh stderr_file stdin_discard
2191 stdin_fh stdin_file stdin_data timeout encoding stream_encoding
2192 argument_encoding forward_agent setpgrp);
2193 0 ▶sub capture_tunnel {
Subroutine capture_tunnel: not called CC=5 SCAR=34.0
Pod documented
2194 0 ▶ ${^TAINT} and &_catch_tainted_args;
Branch: 1 branch
BranchTrueFalseTotal
${^TAINT} and &_catch_tainted_args 0 0 0
2195 0 my $self = shift;
2196 0 ▶ my %opts = (ref $_[0] eq 'HASH' ? %{shift()} : ());
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] eq 'HASH' ? : 0 0 0
2197 0 ▶ $opts{stderr_discard} = 1 unless grep defined $opts{$_}, qw(stderr_discard stderr_fh stderr_file);
Branch: 1 branch
BranchTrueFalseTotal
unless grep defined($opts{$_}), ("stderr_discard", "stderr_fh", "stderr_file") 0 0 0
2198 0 _croak_bad_options %opts;
2199 0 ▶ @_ == 2 or croak 'Usage: $ssh->capture_tunnel(\%opts, $host, $port)';
Branch: 1 branch
BranchTrueFalseTotal
@_ == 2 or croak("Usage: \$ssh->capture_tunnel(\\%opts, \$host, \$port)") 0 0 0
2200 0 $opts{tunnel} = 1;
2201 0 $self->capture(\%opts, @_);
2202 }
2203  
2204 0 ▶sub _calling_method {
Subroutine _calling_method: not called CC=1 SCAR=6.9
2205 0 my $method = (caller 2)[3];
2206 0 $method =~ s/.*:://;
2207 0 $method;
2208 }
2209  
2210 0 ▶sub _scp_get_args {
Subroutine _scp_get_args: not called CC=6 SCAR=37.4
2211 0 my $self = shift;
2212 0 ▶ my %opts = (ref $_[0] eq 'HASH' ? %{shift()} : ());
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] eq 'HASH' ? : 0 0 0
2213  
2214 0 ▶ @_ > 0 or croak
Branch: 1 branch
BranchTrueFalseTotal
@_ > 0 or croak('Usage: $ssh->' . _calling_method() . '(\\%opts, $remote_fn1, $remote_fn2, ..., $local_fn_or_dir)') 0 0 0
2215 'Usage: $ssh->' . _calling_method . '(\%opts, $remote_fn1, $remote_fn2, ..., $local_fn_or_dir)';
2216  
2217 0 my $glob = delete $opts{glob};
2218  
2219 0 ▶ my $target = (@_ > 1 ? pop @_ : '.');
Branch: 1 branch
BranchTrueFalseTotal
@_ > 1 ? : 0 0 0
2220 0 ▶ $target =~ m|^[^/]*:| and $target = "./$target";
Branch: 1 branch
BranchTrueFalseTotal
$target =~ m[^[^/]*:] and $target = "./$target" 0 0 0
2221  
2222 0 my $prefix = $self->{_host_squared};
2223 0 ▶ $prefix = "$self->{_user}\@$prefix" if defined $self->{_user};
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{"_user"} 0 0 0
2224  
2225 0 my @src = map "$prefix:". $self->_quote_args({quote_args => 1,
2226 glob_quoting => $glob}, $_), @_;
2227 0 ($self, \%opts, $target, @src);
2228 }
2229  
2230 0 ▶sub scp_get {
Subroutine scp_get: not called CC=2 SCAR=17.9
Pod documented
2231 0 ▶ ${^TAINT} and &_catch_tainted_args;
Branch: 1 branch
BranchTrueFalseTotal
${^TAINT} and &_catch_tainted_args 0 0 0
2232 0 my ($self, $opts, $target, @src) = _scp_get_args @_;
2233 0 $self->_scp($opts, @src, $target);
2234 }
2235  
2236 0 ▶sub rsync_get {
Subroutine rsync_get: not called CC=2 SCAR=17.9
Pod documented
2237 0 ▶ ${^TAINT} and &_catch_tainted_args;
Branch: 1 branch
BranchTrueFalseTotal
${^TAINT} and &_catch_tainted_args 0 0 0
2238 0 my ($self, $opts, $target, @src) = _scp_get_args @_;
2239 0 $self->_rsync($opts, @src, $target);
2240 }
2241  
2242 0 ▶sub _scp_put_args {
Subroutine _scp_put_args: not called CC=10 SCAR=47.0
2243 0 my $self = shift;
2244 0 ▶ my %opts = (ref $_[0] eq 'HASH' ? %{shift()} : ());
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] eq 'HASH' ? : 0 0 0
2245  
2246 0 ▶ @_ > 0 or croak
Branch: 1 branch
BranchTrueFalseTotal
@_ > 0 or croak('Usage: $ssh->' . _calling_method() . '(\\%opts, $local_fn1, $local_fn2, ..., $remote_dir_or_fn)') 0 0 0
2247 'Usage: $ssh->' . _calling_method . '(\%opts, $local_fn1, $local_fn2, ..., $remote_dir_or_fn)';
2248  
2249 0 my $glob = delete $opts{glob};
2250 0 ▶ my $glob_flags = ($glob ? delete $opts{glob_flags} || 0 : undef);
Branch: 1 branch
BranchTrueFalseTotal
$glob ? : 0 0 0
Condition0%0/2
delete $opts{"glob_flags"} or 0
l!l
00
MC/DC0%0/1
delete $opts{"glob_flags"} or 0
delete $opts{"glob_flags"}
Truth table0%0/2
A
A= delete $opts{"glob_flags"}
Aresult
11
00
2251  
2252 0 my $prefix = $self->{_host_squared};
2253 0 ▶ $prefix = "$self->{_user}\@$prefix" if defined $self->{_user};
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{"_user"} 0 0 0
2254  
2255 0 my $remote_shell = delete $opts{remote_shell};
2256 0 ▶ my $target = $prefix . ':' . ( @_ > 1
Branch: 1 branch
BranchTrueFalseTotal
@_ > 1 ? : 0 0 0
2257 ? $self->_quote_args({quote_args => 1, remote_shell => $remote_shell}, pop(@_))
2258 : '');
2259  
2260 0 my @src = @_;
2261 0 ▶ if ($glob) {
Branch: 1 branch
BranchTrueFalseTotal
if ($glob) 0 0 0
2262 0 require File::Glob;
2263 0 @src = map File::Glob::bsd_glob($_, $glob_flags), @src;
2264 0 ▶ unless (@src) {
Branch: 1 branch
BranchTrueFalseTotal
unless (@src) 0 0 0
2265 0 $self->_set_error(OSSH_SLAVE_FAILED,
2266 "given file name patterns did not match any file");
2267 0 return undef;
2268 }
2269 }
2270 0 $_ = "./$_" for grep m|^[^/]*:|, @src;
2271  
2272 0 ($self, \%opts, $target, @src);
2273 }
2274  
2275 0 ▶sub scp_put {
Subroutine scp_put: not called CC=3 SCAR=24.8
Pod documented
2276 0 ▶ ${^TAINT} and &_catch_tainted_args;
Branch: 1 branch
BranchTrueFalseTotal
${^TAINT} and &_catch_tainted_args 0 0 0
2277 0 my ($self, $opts, $target, @src) = _scp_put_args @_;
2278 0 ▶ return unless $self;
Branch: 1 branch
BranchTrueFalseTotal
unless $self 0 0 0
2279 0 $self->_scp($opts, @src, $target);
2280 }
2281  
2282 0 ▶sub rsync_put {
Subroutine rsync_put: not called CC=3 SCAR=24.8
Pod documented
2283 0 ▶ ${^TAINT} and &_catch_tainted_args;
Branch: 1 branch
BranchTrueFalseTotal
${^TAINT} and &_catch_tainted_args 0 0 0
2284 0 my ($self, $opts, $target, @src) = _scp_put_args @_;
2285 0 ▶ return unless $self;
Branch: 1 branch
BranchTrueFalseTotal
unless $self 0 0 0
2286 0 $self->_rsync($opts, @src, $target);
2287 }
2288  
2289 3 _sub_options _scp => qw(stderr_to_stdout stderr_discard stderr_fh
2290 stderr_file stdout_discard stdout_fh
2291 stdout_file encoding argument_encoding
2292 forward_agent setpgrp);
2293 0 ▶sub _scp {
Subroutine _scp: not called CC=10 SCAR=47.0
2294 0 my $self = shift;
2295 0 ▶ my %opts = (ref $_[0] eq 'HASH' ? %{shift()} : ());
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] eq 'HASH' ? : 0 0 0
2296 0 my $quiet = delete $opts{quiet};
2297 0 ▶ $quiet = 1 unless defined $quiet;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $quiet 0 0 0
2298 0 my $recursive = delete $opts{recursive};
2299 0 my $copy_attrs = delete $opts{copy_attrs};
2300 0 my $bwlimit = delete $opts{bwlimit};
2301 0 my $async = delete $opts{async};
2302 0 my $ssh_opts = delete $opts{ssh_opts};
2303 0 my $timeout = delete $opts{timeout};
2304 0 my $verbose = delete $opts{verbose};
2305 0 _croak_bad_options %opts;
2306  
2307 0 my @opts;
2308 0 ▶ @opts = @$ssh_opts if $ssh_opts;
Branch: 1 branch
BranchTrueFalseTotal
if $ssh_opts 0 0 0
2309 0 ▶ push @opts, '-q' if $quiet;
Branch: 1 branch
BranchTrueFalseTotal
if $quiet 0 0 0
2310 0 ▶ push @opts, '-v' if $verbose;
Branch: 1 branch
BranchTrueFalseTotal
if $verbose 0 0 0
2311 0 ▶ push @opts, '-r' if $recursive;
Branch: 1 branch
BranchTrueFalseTotal
if $recursive 0 0 0
2312 0 ▶ push @opts, '-p' if $copy_attrs;
Branch: 1 branch
BranchTrueFalseTotal
if $copy_attrs 0 0 0
2313 0 ▶ push @opts, '-l', $bwlimit if $bwlimit;
Branch: 1 branch
BranchTrueFalseTotal
if $bwlimit 0 0 0
2314  
2315 0 local $self->{_error_prefix} = [@{$self->{_error_prefix}}, 'scp failed'];
2316  
2317 0 my $pid = $self->open_ex({ %opts,
2318 _cmd => 'scp',
2319 ssh_opts => \@opts,
2320 quote_args => 0 },
2321 @_);
2322  
2323 0 ▶ return $pid if $async;
Branch: 1 branch
BranchTrueFalseTotal
if $async 0 0 0
2324 0 $self->_waitpid($pid, $timeout);
2325 }
2326  
2327 3 my %rsync_opt_with_arg = map { $_ => 1 } qw(chmod suffix backup-dir rsync-path max-delete max-size min-size partial-dir
2328 timeout modify-window temp-dir compare-dest copy-dest link-dest compress-level
2329 skip-compress filter exclude exclude-from include include-from
2330 out-format log-file log-file-format bwlimit protocol iconv checksum-seed files-from);
2331  
2332 3 my %rsync_opt_forbidden = map { $_ => 1 } qw(rsh address port sockopts password-file write-batch
2333 only-write-batch read-batch ipv4 ipv6 version help daemon config detach
2334 protect-args list-only);
2335  
2336 3 $rsync_opt_forbidden{"no-$_"} = 1 for (keys %rsync_opt_with_arg, keys %rsync_opt_forbidden);
2337  
2338 3 my %rsync_error = (1, 'syntax or usage error',
2339 2, 'protocol incompatibility',
2340 3, 'errors selecting input/output files, dirs',
2341 4, 'requested action not supported: an attempt was made to manipulate 64-bit files on a platform '.
2342 'that cannot support them; or an option was specified that is supported by the client and not '.
2343 'by the server.',
2344 5, 'error starting client-server protocol',
2345 6, 'daemon unable to append to log-file',
2346 10, 'error in socket I/O',
2347 11, 'error in file I/O',
2348 12, 'error in rsync protocol data stream',
2349 13, 'errors with program diagnostics',
2350 14, 'error in IPC code',
2351 20, 'received SIGUSR1 or SIGINT',
2352 21, 'some error returned by waitpid()',
2353 22, 'error allocating core memory buffers',
2354 23, 'partial transfer due to error',
2355 24, 'partial transfer due to vanished source files',
2356 25, 'the --max-delete limit stopped deletions',
2357 30, 'timeout in data send/receive',
2358 35, 'timeout waiting for daemon connection');
2359  
2360 3 my %rsync_opt_open_ex = map { $_ => 1 } qw(stderr_to_stdout
2361 stderr_discard stderr_fh
2362 stderr_file stdout_discard
2363 stdout_fh stdout_file encoding
2364 argument_encoding);
2365 0 ▶sub _rsync {
Subroutine _rsync: not called CC=22 SCAR=62.3
2366 0 my $self = shift;
2367 0 ▶ my %opts = (ref $_[0] eq 'HASH' ? %{shift()} : ());
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] eq 'HASH' ? : 0 0 0
2368 0 my $async = delete $opts{async};
2369 0 my $verbose = delete $opts{verbose};
2370 0 my $quiet = delete $opts{quiet};
2371 0 my $copy_attrs = delete $opts{copy_attrs};
2372 0 my $timeout = delete $opts{timeout};
2373 0 ▶ $quiet = 1 unless (defined $quiet or $verbose);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $quiet or $verbose 0 0 0
Condition0%0/3
defined $quiet or $verbose
l!l&&r!l&&!r
000
MC/DC0%0/2
defined $quiet or $verbose
defined $quiet $verbose
Truth table0%0/3
A or B
A= defined $quietB= $verbose
ABresult
1X1
011
000
2374  
2375 0 my @opts;
2376 0 ▶ push @opts, '-q' if $quiet;
Branch: 1 branch
BranchTrueFalseTotal
if $quiet 0 0 0
2377 0 ▶ push @opts, '-pt' if $copy_attrs;
Branch: 1 branch
BranchTrueFalseTotal
if $copy_attrs 0 0 0
2378 0 ▶ push @opts, '-' . ($verbose =~ /^\d+$/ ? 'v' x $verbose : 'v') if $verbose;
Branch: 2 branches
BranchTrueFalseTotal
if $verbose 0 0 0
$verbose =~ /^\d+$/ ? : 0 0 0
2379  
2380 0 my %opts_open_ex = ( _cmd => 'rsync',
2381 quote_args => 0 );
2382  
2383 0 for my $opt (keys %opts) {
2384 0 my $value = $opts{$opt};
2385 0 ▶ if (defined $value) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value) 0 0 0
2386 0 ▶ if ($rsync_opt_open_ex{$opt}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($rsync_opt_open_ex{$opt}) { } 0 0 0
2387 0 $opts_open_ex{$opt} = $value;
2388 }
2389 else {
2390 0 my $opt1 = $opt;
2391 0 $opt1 =~ tr/_/-/;
2392 0 ▶ $rsync_opt_forbidden{$opt1} and croak "forbidden rsync option '$opt' used";
Branch: 1 branch
BranchTrueFalseTotal
$rsync_opt_forbidden{$opt1} and croak("forbidden rsync option '${opt}' used") 0 0 0
2393 0 ▶ if ($rsync_opt_with_arg{$opt1}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($rsync_opt_with_arg{$opt1}) { } 0 0 0
2394 0 push @opts, "--$opt1=$_" for _array_or_scalar_to_list($value)
2395 }
2396 else {
2397 0 ▶ $value = !$value if $opt1 =~ s/^no-//;
Branch: 1 branch
BranchTrueFalseTotal
if $opt1 =~ s/^no-// 0 0 0
2398 0 ▶ push @opts, ($value ? "--$opt1" : "--no-$opt1");
Branch: 1 branch
BranchTrueFalseTotal
$value ? : 0 0 0
2399 }
2400 }
2401 }
2402 }
2403  
2404 0 local $self->{_error_prefix} = [@{$self->{_error_prefix}}, 'rsync failed'];
2405  
2406 0 my $pid = $self->open_ex(\%opts_open_ex, @opts, '--', @_);
2407 0 ▶ return $pid if $async;
Branch: 1 branch
BranchTrueFalseTotal
if $async 0 0 0
2408 0 ▶ $self->_waitpid($pid, $timeout) and return 1;
Branch: 1 branch
BranchTrueFalseTotal
$self->_waitpid($pid, $timeout) and return 1 0 0 0
2409  
2410 0 ▶ if ($self->{_error} == OSSH_SLAVE_CMD_FAILED and $?) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"_error"} == 5 and $?) 0 0 0
Condition0%0/3
$self->{"_error"} == 5 and $?
!ll&&!rl&&r
000
MC/DC0%0/2
$self->{"_error"} == 5 and $?
$self->{"_error"} == 5 $?
Truth table0%0/3
A and B
A= $self->{"_error"} == 5B= $?
ABresult
0X0
100
111
2411 0 my $err = ($? >> 8);
2412 0 my $errstr = $rsync_error{$err};
2413 0 ▶ $errstr = 'Unknown rsync error' unless defined $errstr;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $errstr 0 0 0
2414 0 my $signal = $? & 255;
2415 0 ▶ my $signalstr = ($signal ? " (signal $signal)" : '');
Branch: 1 branch
BranchTrueFalseTotal
$signal ? : 0 0 0
2416 0 $self->_set_error(OSSH_SLAVE_CMD_FAILED,
2417 "command exited with code $err$signalstr: $errstr");
2418 }
2419 return undef
2420 0 }
2421  
2422 3 _sub_options sftp => qw(autoflush timeout argument_encoding encoding block_size queue_size autodie
2423 late_set_perm forward_agent setpgrp min_block_size read_ahead write_delay
2424 dirty_cleanup remote_has_volumes autodisconnect more);
2425  
2426 0 ▶sub sftp {
Subroutine sftp: not called CC=9 SCAR=45.0
Pod documented
2427 0 ▶ ${^TAINT} and &_catch_tainted_args;
Branch: 1 branch
BranchTrueFalseTotal
${^TAINT} and &_catch_tainted_args 0 0 0
2428 0 ▶ @_ & 1 or croak 'Usage: $ssh->sftp(%sftp_opts)';
Branch: 1 branch
BranchTrueFalseTotal
@_ & 1 or croak("Usage: \$ssh->sftp(%sftp_opts)") 0 0 0
2429 0 _load_module('Net::SFTP::Foreign', '1.47');
2430 0 my ($self, %opts) = @_;
2431 0 my $stderr_fh = delete $opts{stderr_fh};
2432 0 my $stderr_discard = delete $opts{stderr_discard};
2433 my $fs_encoding = _first_defined(delete $opts{fs_encoding},
2434 $opts{argument_encoding},
2435 $opts{encoding},
2436 0 $self->{_default_argument_encoding});
2437 0 ▶ undef $fs_encoding if (defined $fs_encoding and $fs_encoding eq 'bytes');
Branch: 1 branch
BranchTrueFalseTotal
if defined $fs_encoding and $fs_encoding eq "bytes" 0 0 0
Condition0%0/3
defined $fs_encoding and $fs_encoding eq "bytes"
!ll&&!rl&&r
000
MC/DC0%0/2
defined $fs_encoding and $fs_encoding eq "bytes"
defined $fs_encoding $fs_encoding eq "bytes"
Truth table0%0/3
A and B
A= defined $fs_encodingB= $fs_encoding eq "bytes"
ABresult
0X0
100
111
2438 0 _croak_bad_options %opts;
2439 0 ▶ $opts{timeout} = $self->{_timeout} unless defined $opts{timeout};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $opts{"timeout"} 0 0 0
2440 0 ▶ $self->wait_for_master or return undef;
Branch: 1 branch
BranchTrueFalseTotal
$self->wait_for_master or return undef 0 0 0
2441 0 ▶ my ($in, $out, $pid) = $self->open2( { subsystem => 1,
Branch: 1 branch
BranchTrueFalseTotal
() = $self->open2({"subsystem", 1, "stderr_fh", $stderr_fh, "stderr_discard", $stderr_discard}, "sftp") or return undef 0 0 0
2442 stderr_fh => $stderr_fh,
2443 stderr_discard => $stderr_discard },
2444 'sftp' )
2445 or return undef;
2446  
2447 0 my $sftp = Net::SFTP::Foreign->new(transport => [$out, $in, $pid],
2448 dirty_cleanup => 0,
2449 fs_encoding => $fs_encoding,
2450 %opts);
2451 0 ▶ if ($sftp->error) {
Branch: 1 branch
BranchTrueFalseTotal
if ($sftp->error) 0 0 0
2452 0 $self->_or_set_error(OSSH_SLAVE_SFTP_FAILED, "unable to create SFTP client", $sftp->error);
2453 0 return undef;
2454 }
2455 $sftp
2456 0 }
2457  
2458 3 _sub_options sshfs_import => qw(stderr_discard stderr_fh stderr_file
2459 ssh_opts argument_encoding sshfs_opts setpgrp);
2460 0 ▶sub sshfs_import {
Subroutine sshfs_import: not called CC=4 SCAR=30.0
Pod documented
2461 0 ▶ ${^TAINT} and &_catch_tainted_args;
Branch: 1 branch
BranchTrueFalseTotal
${^TAINT} and &_catch_tainted_args 0 0 0
2462 0 my $self = shift;
2463 0 ▶ my %opts = (ref $_[0] eq 'HASH' ? %{shift()} : ());
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] eq 'HASH' ? : 0 0 0
2464 0 ▶ @_ == 2 or croak 'Usage: $ssh->sshfs_import(\%opts, $remote, $local)';
Branch: 1 branch
BranchTrueFalseTotal
@_ == 2 or croak("Usage: \$ssh->sshfs_import(\\%opts, \$remote, \$local)") 0 0 0
2465 0 my ($from, $to) = @_;
2466 my @sshfs_opts = ( -o => 'slave',
2467 0 _array_or_scalar_to_list delete $opts{sshfs_opts} );
2468 0 _croak_bad_options %opts;
2469  
2470 0 $opts{ssh_opts} = ['-s', _array_or_scalar_to_list delete $opts{ssh_opts}];
2471 0 $opts{stdinout_dpipe} = [$self->{_sshfs_cmd}, "$self->{_host_squared}:$from", $to, @sshfs_opts];
2472 0 $opts{stdinout_dpipe_make_parent} = 1;
2473 0 $self->spawn(\%opts, 'sftp');
2474 }
2475  
2476 3 _sub_options sshfs_export => qw(stderr_discard stderr_fh stderr_file
2477 ssh_opts argument_encoding sshfs_opts setpgrp);
2478 0 ▶sub sshfs_export {
Subroutine sshfs_export: not called CC=7 SCAR=40.3
Pod documented
2479 0 ▶ ${^TAINT} and &_catch_tainted_args;
Branch: 1 branch
BranchTrueFalseTotal
${^TAINT} and &_catch_tainted_args 0 0 0
2480 0 my $self = shift;
2481 0 ▶ my %opts = (ref $_[0] eq 'HASH' ? %{shift()} : ());
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] eq 'HASH' ? : 0 0 0
2482 0 ▶ @_ == 2 or croak 'Usage: $ssh->sshfs_export(\%opts, $local, $remote)';
Branch: 1 branch
BranchTrueFalseTotal
@_ == 2 or croak("Usage: \$ssh->sshfs_export(\\%opts, \$local, \$remote)") 0 0 0
2483 0 my ($from, $to) = @_;
2484 my @sshfs_opts = ( -o => 'slave',
2485 0 _array_or_scalar_to_list delete $opts{sshfs_opts} );
2486 0 _croak_bad_options %opts;
2487 0 $opts{stdinout_dpipe} = $self->{_sftp_server_cmd};
2488  
2489 0 my $hostname = do {
2490 0 local ($@, $SIG{__DIE__});
2491 0 eval {
2492 0 require Sys::Hostname;
2493 0 Sys::Hostname::hostname();
2494 };
2495 };
2496 0 ▶ $hostname = 'remote' if (not defined $hostname or
Branch: 1 branch
BranchTrueFalseTotal
if not defined $hostname && length $hostname or $hostname =~ /^localhost\b/ 0 0 0
Condition0%0/6
not defined $hostname && length $hostname or $hostname =~ /^localhost\b/
l!l&&r!l&&!r
000
defined $hostname && length $hostname
!ll&&!rl&&r
000
MC/DC0%0/3
not defined $hostname && length $hostname or $hostname =~ /^localhost\b/
defined $hostname length $hostname $hostname =~ /^localhost\b/
Truth table0%0/4
not(A && B) or C
A= defined $hostnameB= length $hostnameC= $hostname =~ /^localhost\b/
ABCresult
0XX1
10X1
1111
1100
2497 not length $hostname or
2498 $hostname=~/^localhost\b/);
2499 0 $self->spawn(\%opts, $self->{_sshfs_cmd}, "$hostname:$from", $to, @sshfs_opts);
2500 }
2501  
2502 0 ▶sub object_remote {
Subroutine object_remote: not called CC=3 SCAR=24.8
Pod documented
2503 0 my $self = shift;
2504 0 ▶ _load_module('Object::Remote') or return;
Branch: 1 branch
BranchTrueFalseTotal
_load_module("Object::Remote") or return 0 0 0
2505 0 ▶ _load_module('Net::OpenSSH::ObjectRemote') or return;
Branch: 1 branch
BranchTrueFalseTotal
_load_module("Net::OpenSSH::ObjectRemote") or return 0 0 0
2506 0 my $connector = Net::OpenSSH::ObjectRemote->new(net_openssh => $self);
2507 0 $connector->connect(@_);
2508 }
2509  
2510 0 ▶sub any {
Subroutine any: not called CC=1 SCAR=6.9
Pod documented
2511 0 my $self = shift;
2512 0 _load_module('Net::SSH::Any');
2513 Net::SSH::Any->new($self->{_host}, user => $self->{_user}, port => $self->{_port},
2514 0 backend => 'Net_OpenSSH',
2515 backend_opts => { Net_OpenSSH => { instance => $self } });
2516 }
2517  
2518 0 ▶sub DESTROY {
Subroutine DESTROY: not called CC=3 SCAR=24.8
2519 0 my $self = shift;
2520 0 ▶ $debug and $debug & 2 and _debug("DESTROY($self, pid: ", $self->{_pid}, ")");
Branch: 1 branch
BranchTrueFalseTotal
$Net::OpenSSH::debug and $Net::OpenSSH::debug & 2 and _debug("DESTROY($self, pid: ", $self->{"_pid"}, ")") 0 0 0
Condition0%0/3
$Net::OpenSSH::debug and $Net::OpenSSH::debug & 2
!ll&&!rl&&r
000
MC/DC0%0/2
$Net::OpenSSH::debug and $Net::OpenSSH::debug & 2
$Net::OpenSSH::debug $Net::OpenSSH::debug & 2
Truth table0%0/3
A and B
A= $Net::OpenSSH::debugB= $Net::OpenSSH::debug & 2
ABresult
0X0
100
111
2521 0 local ($SIG{__DIE__}, $@, $?, $!);
2522 0 $self->_disconnect;
2523 }
2524  
2525 3 1;
2526 __END__
↑ Summary OpenSSH/OSTracer.pm »