OpenSSH.pm

filter: Statementstmt 7.4% 108 / 1442 Branchbran 1.3% 15 / 1094 Conditioncond 0.4% 2 / 447 MC/DCmcdc 0.0% 0 / 265 Subroutinesub 13.7% 17 / 124 Podpod 91.8% 45 / 49 totaltotal 5.4% 187 / 3421 CC 706 SCAR 77.2
CC
706
Cov
4%
open_ex
9506.0
_master_wait
4970.0
_io3
4692.0
CRAP 2246.2
↑ Summary OpenSSH/OSTracer.pm »
1 package Net::OpenSSH;
2  
3 3 our $VERSION = '0.81_04';
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 sub _debug {
30 0 ▶ local ($!, $@);
Subroutine _debug: not called CC=2 SCAR=17.9
31 0 ▶ print {$debug_fh} '# ', (map { defined($_) ? $_ : '<undef>' } @_), "\n"
Branch: 1 branch
BranchTrueFalseTotal
defined $_ ? : 0 0 0
32 }
33  
34 sub _debug_dump {
35 0 ▶ local ($!, $@);
Subroutine _debug_dump: not called CC=1 SCAR=6.9
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 sub _hexdump {
44 3 ▶ no warnings qw(uninitialized);
Subroutine BEGIN: called CC=1 SCAR=0.0
45 0 ▶ my $data = shift;
Subroutine _hexdump: not called CC=3 SCAR=24.8
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 sub _sub_options {
59 51 ▶ my $sub = shift;
Subroutine _sub_options: called CC=1 SCAR=0.0
60 51 $good{__PACKAGE__ . "::$sub"} = { map { $_ => 1 } @_ };
61 }
62  
63 sub _croak_bad_options (\%) {
64 0 ▶ my $opts = shift;
Subroutine _croak_bad_options: not called CC=4 SCAR=30.0
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 {
77 0 ▶ my ($sub, $wantarray) = (caller 1)[3, 5];
Subroutine _croak_scalar_context: not called CC=2 SCAR=17.9
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 sub _tcroak {
85 0 ▶ if (${^TAINT} > 0) {
Subroutine _tcroak: not called CC=3 SCAR=24.8
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 sub _catch_tainted_args {
96 0 ▶ my $i;
Subroutine _catch_tainted_args: not called CC=8 SCAR=42.8
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 sub _set_error {
119 0 ▶ my $self = shift;
Subroutine _set_error: not called CC=6 SCAR=37.4
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 sub _check_eval_ok {
136 0 ▶ my ($self, $code) = @_;
Subroutine _check_eval_ok: not called CC=2 SCAR=17.9
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 sub _or_set_error {
147 0 ▶ my $self = shift;
Subroutine _or_set_error: not called CC=2 SCAR=17.9
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 my $obfuscate = sub {
154 # just for the casual observer...
155 0 ▶ my $txt = shift;
Subroutine __ANON__: not called CC=2 SCAR=17.9
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 sub parse_connection_opts {
167 19 ▶ my ($class, $opts) = @_;
Subroutine parse_connection_opts: called CC=10 SCAR=23.2
Pod undocumented
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") 0 19 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") 0 19 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 sub new {
224 0 ▶ ${^TAINT} and &_catch_tainted_args;
Subroutine new: not called CC=56 SCAR=80.7
Pod documented
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 sub set_expand_vars {
507 0 ▶ my $self = shift;
Subroutine set_expand_vars: not called CC=2 SCAR=17.9
Pod documented
508 0 ▶ $self->{_expand_vars} = (shift(@_) ? 1 : 0);
Branch: 1 branch
BranchTrueFalseTotal
shift @_ ? : 0 0 0
509 }
510  
511 sub set_var {
512 0 ▶ ${^TAINT} and &_catch_tainted_args;
Subroutine set_var: not called CC=3 SCAR=24.8
Pod documented
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 sub get_var {
521 0 ▶ my ($self, $k) = @_;
Subroutine get_var: not called CC=3 SCAR=24.8
Pod documented
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 sub _expand_vars {
529 0 ▶ my ($self, @str) = @_;
Subroutine _expand_vars: not called CC=7 SCAR=40.3
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 sub die_on_error {
542 0 ▶ my $ssh = shift;
Subroutine die_on_error: not called CC=3 SCAR=24.8
Pod undocumented
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 sub _is_secure_path {
548 0 ▶ my ($self, $path) = @_;
Subroutine _is_secure_path: not called CC=13 SCAR=52.0
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 sub _detect_ssh_version {
566 0 ▶ my $self = shift;
Subroutine _detect_ssh_version: not called CC=9 SCAR=45.0
567 0 ▶ if (defined $self->{_ssh_version}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{'_ssh_version'}) { } 0 0 0
568 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
569 }
570 else {
571 my (undef, $out, undef, $pid) = $self->open_ex({_cmd => 'raw',
572 _no_master_required => 1,
573 stdout_pipe => 1,
574 stdin_discard => 1,
575 stderr_to_stdout => 1 },
576 0 $self->{_ssh_cmd}, '-V');
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 ▶ if (my ($full, $num) = $txt =~ /^OpenSSH_((\d+\.\d+)\S*)/mi) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = $txt =~ /^OpenSSH_((\d+\.\d+)\S*)/im) { } 0 0 0
581 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
582 0 $self->{_ssh_version} = $num;
583 }
584 else {
585 0 $self->{_ssh_version} = 0;
586 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
587 }
588 }
589 }
590  
591 sub _make_ssh_call {
592 0 ▶ my $self = shift;
Subroutine _make_ssh_call: not called CC=5 SCAR=34.0
593 0 ▶ my @before = @{shift || []};
Branch: 1 branch
BranchTrueFalseTotal
shift() or [] 0 0 0
594 my @args = ($self->{_ssh_cmd}, @before,
595 -S => $self->{_ctl_path},
596 0 ▶ @{$self->{_ssh_opts}}, $self->{_host},
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 0 0 0
597 0 '--',
598 (@_ ? "@_" : ()));
599 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
600 0 @args;
601 }
602  
603 sub _scp_cmd {
604 0 ▶ my $self = shift;
Subroutine _scp_cmd: not called CC=3 SCAR=24.8
605 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
606 0 my $scp = $self->{_ssh_cmd};
607 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
608 0 $scp;
609 }
610 }
611  
612 sub _make_scp_call {
613 0 ▶ my $self = shift;
Subroutine _make_scp_call: not called CC=5 SCAR=34.0
614 0 ▶ my @before = @{shift || []};
Branch: 1 branch
BranchTrueFalseTotal
shift() or [] 0 0 0
615 my @args = ($self->_scp_cmd, @before,
616 -o => "ControlPath=$self->{_ctl_path}",
617 -S => $self->{_ssh_cmd},
618 0 ▶ (defined $self->{_port} ? (-P => $self->{_port}) : ()),
Branch: 1 branch
BranchTrueFalseTotal
defined $self->{'_port'} ? : 0 0 0
619 '--', @_);
620  
621 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
622 0 @args;
623 }
624  
625 sub _rsync_quote {
626 0 ▶ my ($self, @args) = @_;
Subroutine _rsync_quote: not called CC=4 SCAR=30.0
627 0 for (@args) {
628 0 ▶ if (/['"\s]/) {
Branch: 1 branch
BranchTrueFalseTotal
if (/['"\s]/) 0 0 0
629 0 s/"/""/g;
630 0 $_ = qq|"$_"|;
631 }
632 0 s/%/%%/;
633 }
634 0 ▶ wantarray ? @args : join(' ', @args);
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
635 }
636  
637 sub _make_rsync_call {
638 0 ▶ my $self = shift;
Subroutine _make_rsync_call: not called CC=3 SCAR=24.8
639 0 my $before = shift;
640 my @transport = ($self->{_ssh_cmd}, @$before,
641 0 -S => $self->{_ctl_path});
642 0 my $transport = $self->_rsync_quote(@transport);
643 my @args = ( $self->{_rsync_cmd},
644 0 -e => $transport,
645 @_);
646  
647 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
648 0 @args;
649 }
650  
651 sub _make_W_option {
652 0 ▶ my $self = shift;
Subroutine _make_W_option: not called CC=4 SCAR=30.0
653 0 ▶ if (@_ == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_ == 1) 0 0 0
654 0 my $path = shift;
655 0 ▶ $path = "./$path" unless $path =~ m|/|;
Branch: 1 branch
BranchTrueFalseTotal
unless $path =~ m[/] 0 0 0
656 0 $path =~ s/([\\:])/\\$1/g;
657 0 return "-W$path";
658 }
659 0 ▶ if (@_ == 2) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_ == 2) 0 0 0
660 0 return "-W" . join(':', @_);
661 }
662 0 croak "bad number of arguments for creating a tunnel"
663 }
664  
665 sub _make_tunnel_call {
666 0 ▶ my $self = shift;
Subroutine _make_tunnel_call: not called CC=4 SCAR=30.0
667 0 ▶ my @before = @{shift||[]};
Branch: 1 branch
BranchTrueFalseTotal
shift() or [] 0 0 0
668 0 push @before, $self->_make_W_option(@_);
669 0 my @args = $self->_make_ssh_call(\@before);
670 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
671 0 @args;
672 }
673  
674 sub master_exited {
675 0 ▶ my $self = shift;
Subroutine master_exited: not called CC=1 SCAR=6.9
Pod documented
676 0 $self->_master_gone(1)
677 }
678  
679 sub _master_gone {
680 0 ▶ my $self = shift;
Subroutine _master_gone: not called CC=2 SCAR=17.9
681 0 my $async = shift;
682 0 delete $self->{_pid};
683 0 ▶ $self->_master_fail($async, (@_ ? @_ : "master process exited unexpectedly"));
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 0 0 0
684 }
685  
686 3 my @kill_signal = qw(0 0 TERM TERM TERM KILL);
687  
688 sub __has_sigchld_handle {
689 0 ▶ my $h = $SIG{CHLD};
Subroutine __has_sigchld_handle: not called CC=3 SCAR=24.8
690 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
691 }
692  
693 sub _master_kill {
694 0 ▶ my ($self, $async) = @_;
Subroutine _master_kill: not called CC=24 SCAR=64.0
695  
696 0 ▶ if (my $pid = $self->_my_master_pid) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $pid = $self->_my_master_pid) { } 0 0 0
697 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
698  
699 0 my $now = time;
700 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
701 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
702 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
703  
704 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
705 0 while (1) {
706 0 ▶ if ($self->{_master_kill_last} < $now) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"_master_kill_last"} < $now) 0 0 0
707 0 $self->{_master_kill_last} = $now;
708 0 my $sig = $kill_signal[$self->{_master_kill_count}++];
709 0 ▶ $sig = 'KILL' unless defined $sig;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $sig 0 0 0
710 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
711 0 kill $sig, $pid;
712 }
713 0 my $deceased = waitpid($pid, WNOHANG);
714 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
715 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
716 0 ▶ if ($self->{_master_kill_count} > 20) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"_master_kill_count"} > 20) 0 0 0
717 # FIXME: remove the hard-coded 20 retries?
718 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
719 0 last;
720 }
721 0 ▶ return if $async;
Branch: 1 branch
BranchTrueFalseTotal
if $async 0 0 0
722 0 select(undef, undef, undef, 0.2);
723 0 $now = time;
724 }
725 }
726 else {
727 $debug and $debug & 32 and _debug("not killing master SSH (", $self->{_pid}, ") started from " .
728 "process ", $self->{_perl_pid}, "/", $self->{_thread_generation},
729 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
730 }
731 0 $self->_master_gone($async);
732 }
733  
734 sub disconnect {
735 0 ▶ my ($self, $async) = @_;
Subroutine disconnect: not called CC=2 SCAR=17.9
Pod documented
736 0 ▶ @_ <= 2 or croak 'Usage: $self->disconnect([$async])';
Branch: 1 branch
BranchTrueFalseTotal
@_ <= 2 or croak("Usage: \$self->disconnect([\$async])") 0 0 0
737 0 $self->_disconnect($async, 1);
738 }
739  
740 sub disown_master {
741 0 ▶ my $self = shift;
Subroutine disown_master: not called CC=3 SCAR=24.8
Pod documented
742 0 ▶ if (my $pid = $self->_my_master_pid) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $pid = $self->_my_master_pid) 0 0 0
743 0 ▶ if ($self->wait_for_master) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->wait_for_master) 0 0 0
744 0 $self->{_external_master} = 1;
745 0 return $pid;
746 }
747 }
748 0 undef;
749 }
750  
751 sub restart {
752 0 ▶ my ($self, $async) = @_;
Subroutine restart: not called CC=5 SCAR=34.0
Pod documented
753 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
754  
755 # user is responsible for calling us in STATE_GONE in async mode
756 0 ▶ $self->_disconnect($async, 1) unless $async;
Branch: 1 branch
BranchTrueFalseTotal
unless $async 0 0 0
757  
758 0 ▶ if ($self->{_master_state} != _STATE_GONE) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"_master_state"} != "_STATE_GONE") 0 0 0
759 0 ▶ croak "restart method called in wrong state (terminate the connection first!)" if $async;
Branch: 1 branch
BranchTrueFalseTotal
if $async 0 0 0
760 0 return $self->_master_fail($async, "Unable to restart SSH session from state $self->{_master_state}")
761 }
762  
763 # These slots should be deleted when exiting the KILLING state but
764 # I like keeping them around for throubleshoting purposes.
765 0 delete $self->{_master_kill_start};
766 0 delete $self->{_master_kill_last};
767 0 delete $self->{_master_kill_count};
768 0 $self->_master_jump_state(_STATE_START, $async);
769 }
770  
771 sub _my_master_pid {
772 0 ▶ my $self = shift;
Subroutine _my_master_pid: not called CC=5 SCAR=34.0
773 0 ▶ unless ($self->{_external_master}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"_external_master"}) 0 0 0
774 0 my $pid = $self->{_pid};
775 return $pid if
776 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
777 }
778 ()
779 0 }
780  
781 sub _disconnect {
782 0 ▶ my ($self, $async, $send_ctl) = @_;
Subroutine _disconnect: not called CC=8 SCAR=42.8
783 0 ▶ return if $self->{_master_state} == _STATE_GONE;
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"_master_state"} == "_STATE_GONE" 0 0 0
784  
785 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
786 $self->{_master_state} == _STATE_RUNNING and
787 ($send_ctl or $self->_my_master_pid)) {
788 # we have successfully created the master connection so we
789 # can send control commands:
790 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
791 0 $self->_master_ctl('exit');
792 }
793 0 $self->_master_fail($async, 'aborted')
794 }
795  
796 sub _check_is_system_fh {
797 0 ▶ my ($name, $fh) = @_;
Subroutine _check_is_system_fh: not called CC=4 SCAR=30.0
798 0 ▶ my $fn = fileno(defined $fh ? $fh : $name);
Branch: 1 branch
BranchTrueFalseTotal
defined $fh ? : 0 0 0
799 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
800 0 croak "child process $name is not a real system file handle";
801 }
802  
803 sub _master_redirect {
804 0 ▶ my $self = shift;
Subroutine _master_redirect: not called CC=6 SCAR=34.1
805 0 my $uname = uc shift;
806 0 my $name = lc $uname;
807  
808 3 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
809 0 ▶ if ($self->{"_master_${name}_discard"}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($$self{"_master_${name}_discard"}) { } 0 0 0
810 0 open *$uname, '>>', '/dev/null';
811 }
812 else {
813 0 my $fh = $self->{"_master_${name}_fh"};
814 0 ▶ $fh = $self->{"_default_${name}_fh"} unless defined $fh;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $fh 0 0 0
815 0 ▶ if (defined $fh) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $fh) 0 0 0
816 0 _check_is_system_fh $uname => $fh;
817 0 ▶ if (fileno $fh != fileno *$uname) {
Branch: 1 branch
BranchTrueFalseTotal
if (fileno $fh != fileno $uname) 0 0 0
818 0 ▶ open *$uname, '>>&', $fh or POSIX::_exit(255);
Branch: 1 branch
BranchTrueFalseTotal
open $uname, ">>&", $fh or POSIX::_exit(255) 0 0 0
819 }
820 }
821 }
822 }
823  
824 sub _waitpid {
825 0 ▶ my ($self, $pid, $timeout) = @_;
Subroutine _waitpid: not called CC=25 SCAR=64.8
826 0 $? = 0;
827 0 ▶ if ($pid) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pid) { } 0 0 0
828 0 ▶ $timeout = $self->{_timeout} unless defined $timeout;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $timeout 0 0 0
829  
830 0 my $time_limit;
831 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
832 0 ▶ $timeout = 0 if $self->{_error} == OSSH_SLAVE_TIMEOUT;
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"_error"} == 4 0 0 0
833 0 $time_limit = time + $timeout;
834 }
835 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
836 0 while (1) {
837 0 my $deceased;
838 0 ▶ if (defined $time_limit) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $time_limit) { } 0 0 0
839 0 while (1) {
840 # TODO: we assume that all OSs return 0 when the
841 # process is still running, that may be wrong!
842 0 ▶ $deceased = waitpid($pid, WNOHANG) and last;
Branch: 1 branch
BranchTrueFalseTotal
$deceased = waitpid($pid, 1) and last 0 0 0
843 0 my $remaining = $time_limit - time;
844 0 ▶ if ($remaining <= 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($remaining <= 0) 0 0 0
845 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
846 0 kill TERM => $pid;
847 0 $self->_or_set_error(OSSH_SLAVE_TIMEOUT, "ssh slave failed", "timed out");
848 }
849 # There is a race condition here. We try to
850 # minimize it keeping the waitpid and the select
851 # together and limiting the sleep time to 1s:
852 0 ▶ my $sleep = ($remaining < 0.1 ? 0.1 : 1);
Branch: 1 branch
BranchTrueFalseTotal
$remaining < 0.1 ? : 0 0 0
853 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
854 _debug "waiting for slave, timeout: $timeout, remaining: $remaining, sleep: $sleep";
855 0 ▶ $deceased = waitpid($pid, WNOHANG) and last;
Branch: 1 branch
BranchTrueFalseTotal
$deceased = waitpid($pid, 1) and last 0 0 0
856 0 select(undef, undef, undef, $sleep);
857 }
858 }
859 else {
860 0 $deceased = waitpid($pid, 0);
861 }
862 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
863 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
864 0 ▶ if ($?) {
Branch: 1 branch
BranchTrueFalseTotal
if ($?) 0 0 0
865 0 my $signal = ($? & 255);
866 0 my $errstr = "child exited with code " . ($? >> 8);
867 0 ▶ $errstr .= ", signal $signal" if $signal;
Branch: 1 branch
BranchTrueFalseTotal
if $signal 0 0 0
868 0 $self->_or_set_error(OSSH_SLAVE_CMD_FAILED, $errstr);
869 0 return undef;
870 }
871 0 return 1;
872 }
873 elsif ($deceased < 0) {
874 # at this point $deceased < 0 and so, $! has a valid error value.
875 0 ▶ next if $! == Errno::EINTR();
Branch: 1 branch
BranchTrueFalseTotal
if $! == 4 0 0 0
876 0 ▶ if ($! == Errno::ECHILD()) {
Branch: 1 branch
BranchTrueFalseTotal
if ($! == 10) 0 0 0
877 0 $self->_or_set_error(OSSH_SLAVE_FAILED, "child process $pid does not exist", $!);
878 return undef
879 0 }
880 0 warn "Internal error: unexpected error (".($!+0).": $!) from waitpid($pid) = $deceased. Report it, please!";
881 }
882 elsif ($deceased > 0) {
883 0 warn "Internal error: spurious process $deceased exited"
884 }
885  
886 # wait a bit before trying again
887 0 select(undef, undef, undef, 0.1);
888 }
889 }
890 else {
891 0 $self->_or_set_error(OSSH_SLAVE_FAILED, "spawning of new process failed");
892 0 return undef;
893 }
894 }
895  
896 sub check_master {
897 0 ▶ my $self = shift;
Subroutine check_master: not called CC=2 SCAR=17.9
Pod documented
898 0 ▶ @_ and croak 'Usage: $ssh->check_master()';
Branch: 1 branch
BranchTrueFalseTotal
@_ and croak("Usage: \$ssh->check_master()") 0 0 0
899 0 $self->_master_check(0);
900 }
901  
902 sub wait_for_master {
903 0 ▶ my ($self, $async) = @_;
Subroutine wait_for_master: not called CC=3 SCAR=24.8
Pod documented
904 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
905 $self->{_error} = 0
906 0 ▶ unless $self->{_error} == OSSH_MASTER_FAILED;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"_error"} == 1 0 0 0
907 0 $self->_master_wait($async);
908 }
909  
910 sub _master_start {
911 0 ▶ my ($self, $async) = @_;
Subroutine _master_start: not called CC=27 SCAR=66.3
912 0 $self->_set_error;
913  
914 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
915 0 my $ssh_flags= '-2MN';
916 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
917 0 ▶ $ssh_flags .= ($self->{_forward_X11} ? 'X' : 'x');
Branch: 1 branch
BranchTrueFalseTotal
$self->{'_forward_X11'} ? : 0 0 0
918 0 ▶ my @master_opts = (@{$self->{_master_opts}},
Branch: 1 branch
BranchTrueFalseTotal
$self->{'_ssh_version'} >= 5.6 ? : 0 0 0
919 -o => "ServerAliveInterval=$timeout",
920 0 ($self->{_ssh_version} >= 5.6 ? (-o => "ControlPersist=no") : ()),
921 $ssh_flags);
922  
923 0 my ($mpty, $use_pty, $pref_auths);
924 $use_pty = 1 if ( $self->{_master_pty_force} or
925 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
926 0 ▶ if (defined $self->{_passwd}) {
Branch: 2 branches
BranchTrueFalseTotal
if (defined $self->{'_passwd'}) { } 0 0 0
elsif ($self->{'_batch_mode'}) { } 0 0 0
927 0 $use_pty = 1;
928 $pref_auths = ($self->{_passphrase}
929 0 ▶ ? 'publickey'
Branch: 1 branch
BranchTrueFalseTotal
$self->{'_passphrase'} ? : 0 0 0
930 : 'keyboard-interactive,password');
931 0 push @master_opts, -o => 'NumberOfPasswordPrompts=1';
932 }
933 elsif ($self->{_batch_mode}) {
934 0 push @master_opts, -o => 'BatchMode=yes';
935 }
936  
937 0 ▶ if (defined $self->{_key_path}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"_key_path"}) 0 0 0
938 0 $pref_auths = 'publickey';
939 0 push @master_opts, -i => $self->{_key_path};
940 }
941  
942 0 my $proxy_command = $self->{_proxy_command};
943  
944 0 my $gateway;
945 0 ▶ if (my $gateway_args = $self->{_gateway_args}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $gateway_args = $self->{"_gateway_args"}) 0 0 0
946 0 ▶ if (ref $gateway_args eq 'HASH') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $gateway_args eq 'HASH') { } 0 0 0
947 0 _load_module('Net::OpenSSH::Gateway');
948 0 my $errors;
949 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
950 host => $self->{_host}, port => $self->{_port},
951 %$gateway_args)) {
952 0 return $self->_master_fail($async, 'Unable to build gateway object', join(', ', @$errors));
953 }
954 }
955 else {
956 0 $gateway = $gateway_args
957 }
958 0 $self->{_gateway} = $gateway;
959 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
960 return $self->_master_fail($async, 'Gateway setup failed', join(', ', $gateway->errors));
961 0 $proxy_command = $gateway->proxy_command;
962 }
963  
964 0 ▶ if (defined $proxy_command) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $proxy_command) 0 0 0
965 0 push @master_opts, -o => "ProxyCommand=$proxy_command";
966 }
967  
968 0 ▶ if ($use_pty) {
Branch: 1 branch
BranchTrueFalseTotal
if ($use_pty) 0 0 0
969 0 _load_module('IO::Pty');
970 0 $self->{_mpty} = $mpty = IO::Pty->new;
971 }
972  
973 0 ▶ push @master_opts, -o => "PreferredAuthentications=$pref_auths"
Branch: 1 branch
BranchTrueFalseTotal
if defined $pref_auths 0 0 0
974 if defined $pref_auths;
975  
976 0 my @call = $self->_make_ssh_call(\@master_opts);
977  
978 0 my $pid = fork;
979 0 ▶ unless ($pid) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($pid) 0 0 0
980 0 ▶ defined $pid
Branch: 1 branch
BranchTrueFalseTotal
defined $pid or return $self->_master_fail($async, "unable to fork ssh master: $!") 0 0 0
981 or return $self->_master_fail($async, "unable to fork ssh master: $!");
982  
983 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
984 0 require Net::OpenSSH::OSTracer;
985 0 Net::OpenSSH::OSTracer->trace;
986 }
987  
988 0 ▶ $mpty->make_slave_controlling_terminal if $mpty;
Branch: 1 branch
BranchTrueFalseTotal
if $mpty 0 0 0
989  
990 0 $self->_master_redirect('STDOUT');
991 0 $self->_master_redirect('STDERR');
992  
993 0 ▶ delete $ENV{SSH_ASKPASS} if defined $self->{_passwd};
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{"_passwd"} 0 0 0
994 0 ▶ delete $ENV{SSH_AUTH_SOCK} if defined $self->{_passphrase};
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{"_passphrase"} 0 0 0
995  
996 0 ▶ setpgrp if $self->{_master_setpgrp};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"_master_setpgrp"} 0 0 0
997  
998 0 local $SIG{__DIE__};
999 0 eval { exec @call };
1000 0 POSIX::_exit(255);
1001 }
1002 0 $self->{_pid} = $pid;
1003 0 1;
1004 }
1005  
1006 sub _master_check {
1007 0 ▶ my ($self, $async) = @_;
Subroutine _master_check: not called CC=8 SCAR=42.8
1008 0 my $error;
1009 0 ▶ if ($async) {
Branch: 1 branch
BranchTrueFalseTotal
if ($async) { } 0 0 0
1010 0 ▶ if (-S $self->{_ctl_path}) {
Branch: 1 branch
BranchTrueFalseTotal
if (-S $self->{"_ctl_path"}) 0 0 0
1011 0 delete $self->{_master_pty_log};
1012 0 return 1
1013 }
1014 0 $error = "master SSH connection broken";
1015 }
1016 else {
1017 0 my $out = $self->_master_ctl('check');
1018 0 $error = $self->{_error};
1019 0 ▶ unless ($error) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($error) 0 0 0
1020 0 my $pid = $self->{_pid};
1021 0 ▶ if ($out =~ /pid=(\d+)/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($out =~ /pid=(\d+)/) { } 0 0 0
1022 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
1023 0 delete $self->{_master_pty_log};
1024 0 return 1;
1025 }
1026 0 $error = "bad ssh master at $self->{_ctl_path} socket owned by pid $1 (pid $pid expected)";
1027 }
1028 else {
1029 0 ▶ $error = ($out =~ /illegal option/i
Branch: 1 branch
BranchTrueFalseTotal
$out =~ /illegal option/i ? : 0 0 0
1030 ? 'OpenSSH 4.1 or later required'
1031 : 'unknown error');
1032 }
1033 }
1034 }
1035 0 $self->_master_fail($async, $error);
1036 }
1037  
1038 sub _master_fail {
1039 0 ▶ my $self = shift;
Subroutine _master_fail: not called CC=3 SCAR=24.8
1040 0 my $async = shift;
1041 0 ▶ if ($self->{_error} != OSSH_MASTER_FAILED) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"_error"} != 1) 0 0 0
1042 0 $self->_set_error(OSSH_MASTER_FAILED, @_);
1043 }
1044 0 ▶ $self->_master_jump_state($self->{_pid} ? _STATE_KILLING : _STATE_GONE, $async);
Branch: 1 branch
BranchTrueFalseTotal
$self->{'_pid'} ? : 0 0 0
1045 }
1046  
1047 sub _master_jump_state {
1048 0 ▶ my ($self, $state, $async) = @_;
Subroutine _master_jump_state: not called CC=6 SCAR=37.4
1049 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
1050 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
1051 $state != _STATE_KILLING and
1052 $state != _STATE_GONE) {
1053 0 croak "internal error: state jump to itself ($state)!";
1054 }
1055 0 $self->{_master_state} = $state;
1056 0 return $self->_master_wait($async);
1057 }
1058  
1059 sub _master_wait {
1060 0 ▶ my ($self, $async) = @_;
Subroutine _master_wait: not called CC=70 SCAR=85.1
1061  
1062 0 my $pid = $self->_my_master_pid;
1063 0 ▶ if ($pid) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pid) 0 0 0
1064 0 my $deceased = waitpid($pid, WNOHANG);
1065 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
1066 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
1067 0 return $self->_master_gone($async);
1068 }
1069 }
1070  
1071 0 ▶ if ($self->{_master_state} == _STATE_RUNNING) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"_master_state"} == "_STATE_RUNNING") 0 0 0
1072 0 ▶ return 1 if -S $self->{_ctl_path};
Branch: 1 branch
BranchTrueFalseTotal
if -S $self->{"_ctl_path"} 0 0 0
1073 0 return $self->_master_fail($async, "master SSH connection broken");
1074 }
1075  
1076 0 ▶ if ($self->{_master_state} == _STATE_KILLING) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"_master_state"} == "_STATE_KILLING") 0 0 0
1077 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
1078 0 return $self->_master_kill($async);
1079 }
1080  
1081 0 ▶ if ($self->{_master_state} == _STATE_START) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"_master_state"} == "_STATE_START") 0 0 0
1082 0 ▶ if ($self->{_external_master}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"_external_master"}) 0 0 0
1083 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
1084 $self->_master_check($async))
1085 }
1086  
1087 0 ▶ $self->_master_start($async) or return;
Branch: 1 branch
BranchTrueFalseTotal
$self->_master_start($async) or return 0 0 0
1088 0 ▶ if ($self->{_mpty}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"_mpty"}) 0 0 0
1089 0 $self->{_wfm_bout} = '';
1090 0 $self->{_master_pty_log} = '';
1091 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
1092 0 return $self->_master_jump_state(_STATE_LOGIN, $async);
1093 }
1094 }
1095 0 return $self->_master_jump_state(_STATE_AWAITING_MUX, $async);
1096 }
1097  
1098 0 ▶ if ($self->{_master_state} == _STATE_GONE) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"_master_state"} == "_STATE_GONE") 0 0 0
1099 0 ▶ if (my $mpty = delete $self->{_mpty}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $mpty = delete $self->{"_mpty"}) 0 0 0
1100 0 close($mpty)
1101 }
1102 0 return 0;
1103 }
1104 0 ▶ if ($self->{_master_state} == _STATE_STOPPED) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"_master_state"} == "_STATE_STOPPED") 0 0 0
1105 0 return 0;
1106 }
1107  
1108 # At this point we are either in state AWAITIN_MUX or LOGIN
1109  
1110 0 local $self->{_error_prefix} = [@{$self->{_error_prefix}},
1111 "unable to establish master SSH connection"];
1112  
1113 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
1114 "perl process was forked or threaded before SSH connection had been established");
1115  
1116 0 my $old_tcpgrp;
1117 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
1118 not $self->{_batch_mode} and not $self->{_external_master}) {
1119 0 $old_tcpgrp = POSIX::tcgetpgrp(0);
1120 0 ▶ if ($old_tcpgrp > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($old_tcpgrp > 0) { } 0 0 0
1121 # let the master process ask for passwords at the TTY
1122 0 POSIX::tcsetpgrp(0, $pid);
1123 }
1124 else {
1125 0 undef $old_tcpgrp;
1126 }
1127 }
1128  
1129 0 my $mpty = $self->{_mpty};
1130 0 my $fnopty;
1131 0 my $rv = '';
1132 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
1133 ( $self->{_master_state} == _STATE_LOGIN or
1134 $self->{_master_state} == _STATE_AWAITING_MUX )) {
1135 0 $fnopty = fileno $mpty;
1136 0 vec($rv, $fnopty, 1) = 1
1137 }
1138  
1139 0 my $timeout = $self->{_timeout};
1140 0 ▶ my $dt = ($async ? 0 : 0.02);
Branch: 1 branch
BranchTrueFalseTotal
$async ? : 0 0 0
1141 0 my $start_time = time;
1142 0 my $error;
1143  
1144 # Loop until the mux socket appears or something goes wrong:
1145 0 while (1) {
1146 0 ▶ $dt *= 1.10 if $dt < 0.2; # adaptative delay
Branch: 1 branch
BranchTrueFalseTotal
if $dt < "0.2" 0 0 0
1147 0 ▶ if (-e $self->{_ctl_path}) {
Branch: 1 branch
BranchTrueFalseTotal
if (-e $self->{"_ctl_path"}) 0 0 0
1148 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
1149 0 last;
1150 }
1151 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
1152  
1153 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
1154 0 $error = "login timeout";
1155 0 last;
1156 }
1157  
1158 0 my $deceased = waitpid($pid, WNOHANG);
1159 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
1160 0 $error = "master process exited unexpectedly";
1161 $error = "bad pass" . ($self->{_passphrase} ? 'phrase' : 'word') . " or $error"
1162 0 ▶ if defined $self->{_passwd};
Branch: 2 branches
BranchTrueFalseTotal
if defined $self->{"_passwd"} 0 0 0
$self->{'_passphrase'} ? : 0 0 0
1163 0 delete $self->{_pid};
1164 0 last;
1165 }
1166  
1167 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
1168 0 local ($@, $SIG{__DIE__});
1169 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
1170 0 $self->{_master_state} = _STATE_AWAITING_MUX;
1171 0 next;
1172 }
1173 0 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
1174 0 $error = "custom login handler failed: $@";
1175 0 last;
1176 }
1177 # fallback
1178 }
1179 else {
1180 # we keep reading from mpty even after leaving state
1181 # STATE_LOGIN in order to search for additional password
1182 # prompts.
1183 0 my $rv1 = $rv;
1184 0 my $n = select($rv1, undef, undef, $dt);
1185 0 ▶ if ($n > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($n > 0) 0 0 0
1186 0 ▶ vec($rv1, $fnopty, 1) or die "internal error";
Branch: 1 branch
BranchTrueFalseTotal
vec $rv1, $fnopty, 1 or die "internal error" 0 0 0
1187 0 my $read = sysread($mpty, $self->{_wfm_bout}, 4096, length $self->{_wfm_bout});
1188 0 ▶ if ($read) {
Branch: 1 branch
BranchTrueFalseTotal
if ($read) 0 0 0
1189 0 $self->{_master_pty_log} .= substr($self->{_wfm_bout}, -$read);
1190 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
1191 0 substr($self->{_master_pty_log}, 0, $remove) = ''
1192 }
1193  
1194 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
1195 0 $error = "the authenticity of the target host can't be established; the remote host " .
1196 "public key is probably not present in the '~/.ssh/known_hosts' file";
1197 0 last;
1198 }
1199  
1200 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
1201 0 $error = "the authenticity of the target host can't be established; the remote host " .
1202 "public key doesn't match the one stored locally";
1203 0 last;
1204 }
1205  
1206 0 my $passwd_prompt = _first_defined $self->{_passwd_prompt}, qr/[:?]/;
1207 0 ▶ $passwd_prompt = quotemeta $passwd_prompt unless ref $passwd_prompt;
Branch: 1 branch
BranchTrueFalseTotal
unless ref $passwd_prompt 0 0 0
1208  
1209 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
1210 0 ▶ if ($self->{_wfm_bout} =~ /^(.*$passwd_prompt)/s) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"_wfm_bout"} =~ /^(.*$passwd_prompt)/s) 0 0 0
1211 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
1212 0 print $mpty $deobfuscate->($self->{_passwd}) . "\n";
1213 0 $self->{_wfm_bout} = ''; # reset
1214 0 $self->{_master_state} = _STATE_AWAITING_MUX;
1215 }
1216 }
1217 ▶ 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
1218 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
1219 0 $error = "password authentication failed";
1220 0 last;
1221 }
1222 0 next; # skip delay
1223 }
1224 }
1225 }
1226 0 ▶ return if $async;
Branch: 1 branch
BranchTrueFalseTotal
if $async 0 0 0
1227 0 select(undef, undef, undef, $dt);
1228 }
1229  
1230 0 ▶ if (defined $old_tcpgrp) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $old_tcpgrp) 0 0 0
1231 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
1232 _debug("ssh pid: $pid, pgrp: ", getpgrp($pid),
1233 ", \$\$: ", $$,
1234 ", tcpgrp: ", POSIX::tcgetpgrp(0),
1235 ", old_tcppgrp: ", $old_tcpgrp);
1236 0 local $SIG{TTOU} = 'IGNORE';
1237 0 POSIX::tcsetpgrp(0, $old_tcpgrp);
1238 }
1239  
1240 0 ▶ if ($error) {
Branch: 1 branch
BranchTrueFalseTotal
if ($error) 0 0 0
1241 0 return $self->_master_fail($async, $error);
1242 }
1243  
1244 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
1245 and $self->_master_check($async);
1246 }
1247  
1248 sub _master_ctl {
1249 0 ▶ my $self = shift;
Subroutine _master_ctl: not called CC=2 SCAR=17.9
1250 0 ▶ my %opts = (ref $_[0] eq 'HASH' ? %{shift()} : ());
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] eq 'HASH' ? : 0 0 0
1251 0 my $cmd = shift;
1252  
1253 0 local $?;
1254 0 local $self->{_error_prefix} = [@{$self->{_error_prefix}},
1255 "control command failed"];
1256 0 $self->capture({ %opts,
1257 encoding => 'bytes', # don't let the encoding
1258 # stuff get in the way
1259 stdin_discard => 1, tty => 0,
1260 stderr_to_stdout => 1, ssh_opts => [-O => $cmd]});
1261 }
1262  
1263 sub stop {
1264 0 ▶ my ($self, $timeout) = @_;
Subroutine stop: not called CC=2 SCAR=17.9
Pod undocumented
1265 0 my $pid = $self->{_pid};
1266 0 local $self->{_kill_ssh_on_timeout} = 1;
1267 0 $self->_master_ctl({timeout => $timeout}, 'stop');
1268 0 ▶ unless ($self->{_error}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"_error"}) 0 0 0
1269 0 $self->_set_error(OSSH_MASTER_FAILED, "master stopped");
1270 0 $self->_master_jump_state(_STATE_STOPPED, 1);
1271 }
1272 }
1273  
1274 sub _make_pipe {
1275 0 ▶ my $self = shift;
Subroutine _make_pipe: not called CC=2 SCAR=17.9
1276 0 my ($r, $w);
1277 0 ▶ if (pipe $r, $w) {
Branch: 1 branch
BranchTrueFalseTotal
if (pipe $r, $w) 0 0 0
1278 0 my $old = select;
1279 0 select $r; $ |= 1;
1280 0 select $w; $ |= 1;
1281 0 select $old;
1282 0 return ($r, $w);
1283 }
1284 0 $self->_set_error(OSSH_SLAVE_PIPE_FAILED, "unable to create pipe: $!");
1285 0 return;
1286 }
1287  
1288 sub _remote_quoter {
1289 0 ▶ my ($self, $remote_shell) = @_;
Subroutine _remote_quoter: not called CC=5 SCAR=34.0
1290 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
1291 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
1292 }
1293 0 Net::OpenSSH::ShellQuoter->quoter($remote_shell);
1294 }
1295  
1296 sub _quote_args {
1297 0 ▶ my $self = shift;
Subroutine _quote_args: not called CC=18 SCAR=58.3
1298 0 my $opts = shift;
1299 0 ▶ ref $opts eq 'HASH' or die "internal error";
Branch: 1 branch
BranchTrueFalseTotal
ref $opts eq "HASH" or die "internal error" 0 0 0
1300 0 my $quote = delete $opts->{quote_args};
1301 0 my $quote_extended = delete $opts->{quote_args_extended};
1302 0 my $glob_quoting = delete $opts->{glob_quoting};
1303 0 ▶ $quote = (@_ > 1) unless defined $quote;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $quote 0 0 0
1304  
1305 0 ▶ if ($quote) {
Branch: 1 branch
BranchTrueFalseTotal
if ($quote) { } 0 0 0
1306 0 my $remote_shell = delete $opts->{remote_shell};
1307 0 my $quoter = $self->_remote_quoter($remote_shell);
1308 0 ▶ my $quote_method = ($glob_quoting ? 'quote_glob' : 'quote');
Branch: 1 branch
BranchTrueFalseTotal
$glob_quoting ? : 0 0 0
1309 # foo => $quoter
1310 # \foo => $quoter_glob
1311 # \\foo => no quoting at all and disable extended quoting as it is not safe
1312 0 my @quoted;
1313 0 for (@_) {
1314 0 ▶ if (ref $_) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $_) { } 0 0 0
1315 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
1316 0 push @quoted, $quoter->quote_glob($self->_expand_vars($$_));
1317 }
1318 ▶ 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
1319 0 push @quoted, $self->_expand_vars($$$_);
1320 0 undef $quote_extended;
1321 }
1322 else {
1323 0 croak "invalid reference in remote command argument list"
1324 }
1325 }
1326 else {
1327 0 push @quoted, $quoter->$quote_method($self->_expand_vars($_));
1328 }
1329 }
1330  
1331 0 ▶ if ($quote_extended) {
Branch: 1 branch
BranchTrueFalseTotal
if ($quote_extended) 0 0 0
1332 0 my @fragments;
1333 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
1334 ( $opts->{stderr_discard} or $opts->{stderr_to_stdout} ) ) {
1335 0 @fragments = ('stdout_and_stderr_discard');
1336 0 ▶ push @fragments, 'stdin_discard' if $opts->{stdin_discard};
Branch: 1 branch
BranchTrueFalseTotal
if $opts->{"stdin_discard"} 0 0 0
1337 }
1338 else {
1339 0 @fragments = grep $opts->{$_}, qw(stdin_discard stdout_discard
1340 stderr_discard stderr_to_stdout);
1341 }
1342 0 push @quoted, $quoter->shell_fragments(@fragments);
1343 }
1344 0 ▶ wantarray ? @quoted : join(" ", @quoted);
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
1345 }
1346 else {
1347 0 ▶ croak "reference found in argument list when argument quoting is disabled"
Branch: 1 branch
BranchTrueFalseTotal
if grep ref($_), @_ 0 0 0
1348 if (grep ref, @_);
1349  
1350 0 my @args = $self->_expand_vars(@_);
1351 0 ▶ wantarray ? @args : join(" ", @args);
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
1352 }
1353 }
1354  
1355 sub shell_quote {
1356 0 ▶ shift->_quote_args({quote_args => 1}, @_);
Subroutine shell_quote: not called CC=1 SCAR=6.9
Pod documented
1357 }
1358  
1359 sub shell_quote_glob {
1360 0 ▶ shift->_quote_args({quote_args => 1, glob_quoting => 1}, @_);
Subroutine shell_quote_glob: not called CC=1 SCAR=6.9
Pod documented
1361 }
1362  
1363 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
1364  
1365 sub make_remote_command {
1366 0 ▶ my $self = shift;
Subroutine make_remote_command: not called CC=20 SCAR=60.4
Pod documented
1367 0 ▶ $self->wait_for_master or return;
Branch: 1 branch
BranchTrueFalseTotal
$self->wait_for_master or return 0 0 0
1368 0 ▶ my %opts = (ref $_[0] eq 'HASH' ? %{shift()} : ());
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] eq 'HASH' ? : 0 0 0
1369 0 my @ssh_opts = _array_or_scalar_to_list delete $opts{ssh_opts};
1370 0 my $tty = delete $opts{tty};
1371 0 my $ssh_flags = '';
1372 0 ▶ $ssh_flags .= ($tty ? 'qtt' : 'T') if defined $tty;
Branch: 2 branches
BranchTrueFalseTotal
if defined $tty 0 0 0
$tty ? : 0 0 0
1373 0 ▶ if ($self->{_forward_agent}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"_forward_agent"}) 0 0 0
1374 0 ▶ my $forward_always = (($self->{_forward_agent} eq 'always') ? 1 : undef);
Branch: 1 branch
BranchTrueFalseTotal
$self->{'_forward_agent'} eq 'always' ? : 0 0 0
1375 0 my $forward_agent = _first_defined(delete($opts{forward_agent}), $forward_always);
1376 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
1377 }
1378 0 ▶ if ($self->{_forward_X11}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"_forward_X11"}) 0 0 0
1379 0 my $forward_X11 = delete $opts{forward_X11};
1380 0 ▶ $ssh_flags .= ($forward_X11 ? 'X' : 'x');
Branch: 1 branch
BranchTrueFalseTotal
$forward_X11 ? : 0 0 0
1381 }
1382 0 my $tunnel = delete $opts{tunnel};
1383 0 my (@args);
1384 0 ▶ if ($tunnel) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tunnel) { } 0 0 0
1385 0 push @ssh_opts, $self->_make_W_option(@_);
1386 }
1387 else {
1388 0 my $subsystem = delete $opts{subsystem};
1389 0 ▶ if ($subsystem) {
Branch: 1 branch
BranchTrueFalseTotal
if ($subsystem) 0 0 0
1390 0 push @ssh_opts, '-s';
1391 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
1392 }
1393 0 @args = $self->_quote_args(\%opts, @_);
1394 }
1395 0 _croak_bad_options %opts;
1396  
1397 0 ▶ push @ssh_opts, "-$ssh_flags" if length $ssh_flags;
Branch: 1 branch
BranchTrueFalseTotal
if length $ssh_flags 0 0 0
1398 0 my @call = $self->_make_ssh_call(\@ssh_opts, @args);
1399 0 ▶ if (wantarray) {
Branch: 1 branch
BranchTrueFalseTotal
if (wantarray) { } 0 0 0
1400 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
1401 0 return @call;
1402 }
1403 else {
1404 0 my $call = join ' ', $self->shell_quote(@call);
1405 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
1406 0 return $call
1407 }
1408 }
1409  
1410 sub _open_file {
1411 0 ▶ my ($self, $default_mode, $name_or_args) = @_;
Subroutine _open_file: not called CC=3 SCAR=24.8
1412 0 ▶ my ($mode, @args) = (ref $name_or_args
Branch: 1 branch
BranchTrueFalseTotal
ref $name_or_args ? : 0 0 0
1413 ? @$name_or_args
1414 : ($default_mode, $name_or_args));
1415 0 @args = $self->_expand_vars(@args);
1416 0 ▶ if (open my $fh, $mode, @args) {
Branch: 1 branch
BranchTrueFalseTotal
if (open my $fh, $mode, @args) { } 0 0 0
1417 0 return $fh;
1418 }
1419 else {
1420 0 $self->_set_error(OSSH_SLAVE_PIPE_FAILED,
1421 "Unable to open file '$args[0]': $!");
1422 0 return undef;
1423 }
1424 }
1425  
1426 sub _fileno_dup_over {
1427 0 ▶ my ($good_fn, $fh) = @_;
Subroutine _fileno_dup_over: not called CC=4 SCAR=30.0
1428 0 ▶ if (defined $fh) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $fh) 0 0 0
1429 0 my $fn = fileno $fh;
1430 0 for (1..5) {
1431 0 ▶ $fn >= $good_fn and return $fn;
Branch: 1 branch
BranchTrueFalseTotal
$fn >= $good_fn and return $fn 0 0 0
1432 0 $fn = POSIX::dup($fn);
1433 }
1434 0 POSIX::_exit(255);
1435 }
1436 0 undef;
1437 }
1438  
1439 sub _exec_dpipe {
1440 0 ▶ my ($self, $cmd, $io, $err) = @_;
Subroutine _exec_dpipe: not called CC=3 SCAR=24.8
1441 0 my $io_fd = _fileno_dup_over(3 => $io);
1442 0 my $err_fd = _fileno_dup_over(3 => $err);
1443 0 POSIX::dup2($io_fd, 0);
1444 0 POSIX::dup2($io_fd, 1);
1445 0 ▶ POSIX::dup2($err_fd, 2) if defined $err_fd;
Branch: 1 branch
BranchTrueFalseTotal
if defined $err_fd 0 0 0
1446 0 ▶ if (ref $cmd) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $cmd) { } 0 0 0
1447 0 exec @$cmd;
1448 }
1449 else {
1450 0 exec $cmd;
1451 }
1452 }
1453  
1454 sub _delete_stream_encoding {
1455 0 ▶ my ($self, $opts) = @_;
Subroutine _delete_stream_encoding: not called CC=1 SCAR=6.9
1456 _first_defined(delete $opts->{stream_encoding},
1457 $opts->{encoding},
1458 0 $self->{_default_stream_encoding});
1459 }
1460  
1461 sub _delete_argument_encoding {
1462 0 ▶ my ($self, $opts) = @_;
Subroutine _delete_argument_encoding: not called CC=1 SCAR=6.9
1463 _first_defined(delete $opts->{argument_encoding},
1464 delete $opts->{encoding},
1465 0 $self->{_default_argument_encoding});
1466 }
1467  
1468 sub open_ex {
1469 0 ▶ ${^TAINT} and &_catch_tainted_args;
Subroutine open_ex: not called CC=97 SCAR=91.6
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
${^TAINT} and &_catch_tainted_args 0 0 0
1470 0 my $self = shift;
1471 0 ▶ my %opts = (ref $_[0] eq 'HASH' ? %{shift()} : ());
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] eq 'HASH' ? : 0 0 0
1472 0 ▶ unless (delete $opts{_no_master_required}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (delete $opts{"_no_master_required"}) 0 0 0
1473 0 ▶ $self->wait_for_master or return;
Branch: 1 branch
BranchTrueFalseTotal
$self->wait_for_master or return 0 0 0
1474 }
1475  
1476 0 my $ssh_flags = '';
1477 0 my $tunnel = delete $opts{tunnel};
1478 0 my ($cmd, $close_slave_pty, @args);
1479 0 ▶ if ($tunnel) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tunnel) { } 0 0 0
1480 0 @args = @_;
1481 }
1482 else {
1483 0 my $argument_encoding = $self->_delete_argument_encoding(\%opts);
1484 0 my $tty = delete $opts{tty};
1485 0 ▶ $ssh_flags .= ($tty ? 'qtt' : 'T') if defined $tty;
Branch: 2 branches
BranchTrueFalseTotal
if defined $tty 0 0 0
$tty ? : 0 0 0
1486  
1487 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
1488 $opts{quote_args_extended} = 1
1489 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
1490 0 @args = $self->_quote_args(\%opts, @_);
1491 0 ▶ $self->_encode_args($argument_encoding, @args) or return;
Branch: 1 branch
BranchTrueFalseTotal
$self->_encode_args($argument_encoding, @args) or return 0 0 0
1492 }
1493  
1494 0 my ($stdinout_socket, $stdinout_dpipe_make_parent);
1495 0 my $stdinout_dpipe = delete $opts{stdinout_dpipe};
1496 0 ▶ if ($stdinout_dpipe) {
Branch: 1 branch
BranchTrueFalseTotal
if ($stdinout_dpipe) { } 0 0 0
1497 0 $stdinout_dpipe_make_parent = delete $opts{stdinout_dpipe_make_parent};
1498 0 $stdinout_socket = 1;
1499 }
1500 else {
1501 0 $stdinout_socket = delete $opts{stdinout_socket};
1502 }
1503  
1504 0 my ($stdin_discard, $stdin_pipe, $stdin_fh, $stdin_file, $stdin_pty,
1505 $stdout_discard, $stdout_pipe, $stdout_fh, $stdout_file, $stdout_pty,
1506 $stderr_discard, $stderr_pipe, $stderr_fh, $stderr_file, $stderr_to_stdout);
1507 0 ▶ unless ($stdinout_socket) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($stdinout_socket) 0 0 0
1508 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
1509 $stdin_pipe = delete $opts{stdin_pipe} or
1510 $stdin_fh = delete $opts{stdin_fh} or
1511 $stdin_file = delete $opts{stdin_file}) {
1512 0 ▶ unless ($tunnel) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($tunnel) 0 0 0
1513 0 ▶ if ($stdin_pty = delete $opts{stdin_pty}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($stdin_pty = delete $opts{"stdin_pty"}) 0 0 0
1514 0 $close_slave_pty = _first_defined delete $opts{close_slave_pty}, 1;
1515 }
1516 }
1517 }
1518  
1519 ( $stdout_discard = delete $opts{stdout_discard} or
1520 $stdout_pipe = delete $opts{stdout_pipe} or
1521 $stdout_fh = delete $opts{stdout_fh} or
1522 $stdout_file = delete $opts{stdout_file} or
1523 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
1524  
1525 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
1526 and croak "option stdout_pty requires stdin_pty set";
1527 }
1528  
1529 ( $stderr_discard = delete $opts{stderr_discard} or
1530 $stderr_pipe = delete $opts{stderr_pipe} or
1531 $stderr_fh = delete $opts{stderr_fh} or
1532 $stderr_to_stdout = delete $opts{stderr_to_stdout} or
1533 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
1534  
1535 0 my $ssh_opts = delete $opts{ssh_opts};
1536 0 ▶ $ssh_opts = $self->{_default_ssh_opts} unless defined $ssh_opts;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $ssh_opts 0 0 0
1537 0 my @ssh_opts = $self->_expand_vars(_array_or_scalar_to_list $ssh_opts);
1538 0 ▶ if ($self->{_forward_agent}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"_forward_agent"}) 0 0 0
1539 0 ▶ my $forward_always = (($self->{_forward_agent} eq 'always') ? 1 : undef);
Branch: 1 branch
BranchTrueFalseTotal
$self->{'_forward_agent'} eq 'always' ? : 0 0 0
1540 0 my $forward_agent = _first_defined(delete($opts{forward_agent}), $forward_always);
1541 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
1542 }
1543 0 ▶ if ($self->{_forward_X11}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"_forward_X11"}) 0 0 0
1544 0 my $forward_X11 = delete $opts{forward_X11};
1545 0 ▶ $ssh_flags .= ($forward_X11 ? 'X' : 'x');
Branch: 1 branch
BranchTrueFalseTotal
$forward_X11 ? : 0 0 0
1546 }
1547 0 ▶ if (delete $opts{subsystem}) {
Branch: 1 branch
BranchTrueFalseTotal
if (delete $opts{"subsystem"}) 0 0 0
1548 0 $ssh_flags .= 's';
1549 }
1550  
1551 0 my $setpgrp = delete $opts{setpgrp};
1552 0 ▶ undef $setpgrp if defined $stdin_pty;
Branch: 1 branch
BranchTrueFalseTotal
if defined $stdin_pty 0 0 0
1553  
1554 0 _croak_bad_options %opts;
1555  
1556 0 ▶ if (defined $stdin_file) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $stdin_file) 0 0 0
1557 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
1558 }
1559 0 ▶ if (defined $stdout_file) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $stdout_file) 0 0 0
1560 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
1561 }
1562 0 ▶ if (defined $stderr_file) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $stderr_file) 0 0 0
1563 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
1564 }
1565  
1566 0 my ($rin, $win, $rout, $wout, $rerr, $werr);
1567  
1568 0 ▶ if ($stdinout_socket) {
Branch: 1 branch
BranchTrueFalseTotal
if ($stdinout_socket) { } 0 0 0
1569 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
1570 0 $self->_set_error(OSSH_SLAVE_PIPE_FAILED, "socketpair failed: $!");
1571 0 return;
1572 }
1573 0 $wout = $rin;
1574 }
1575 else {
1576 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
1577 0 ▶ ($rin, $win) = $self->_make_pipe or return;
Branch: 1 branch
BranchTrueFalseTotal
() = $self->_make_pipe or return 0 0 0
1578 }
1579 elsif ($stdin_pty) {
1580 0 _load_module('IO::Pty');
1581 0 $win = IO::Pty->new;
1582 0 ▶ unless ($win) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($win) 0 0 0
1583 0 $self->_set_error(OSSH_SLAVE_PIPE_FAILED, "unable to allocate pseudo-tty: $!");
1584 0 return;
1585 }
1586 0 $rin = $win->slave;
1587 }
1588 elsif (defined $stdin_fh) {
1589 0 $rin = $stdin_fh;
1590 }
1591 else {
1592 $rin = $self->{_default_stdin_fh}
1593 0 }
1594 0 _check_is_system_fh STDIN => $rin;
1595  
1596 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
1597 0 ▶ ($rout, $wout) = $self->_make_pipe or return;
Branch: 1 branch
BranchTrueFalseTotal
() = $self->_make_pipe or return 0 0 0
1598 }
1599 elsif ($stdout_pty) {
1600 0 $wout = $rin;
1601 }
1602 elsif (defined $stdout_fh) {
1603 0 $wout = $stdout_fh;
1604 }
1605 else {
1606 0 $wout = $self->{_default_stdout_fh};
1607 }
1608 0 _check_is_system_fh STDOUT => $wout;
1609 }
1610  
1611 0 ▶ unless ($stderr_to_stdout) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($stderr_to_stdout) 0 0 0
1612 0 ▶ if ($stderr_pipe) {
Branch: 2 branches
BranchTrueFalseTotal
if ($stderr_pipe) { } 0 0 0
elsif (defined $stderr_fh) { } 0 0 0
1613 0 ▶ ($rerr, $werr) = $self->_make_pipe or return;
Branch: 1 branch
BranchTrueFalseTotal
() = $self->_make_pipe or return 0 0 0
1614 }
1615 elsif (defined $stderr_fh) {
1616 0 $werr = $stderr_fh;
1617 }
1618 else {
1619 0 $werr = $self->{_default_stderr_fh};
1620 }
1621 0 _check_is_system_fh STDERR => $werr;
1622 }
1623  
1624 0 ▶ push @ssh_opts, "-$ssh_flags" if length $ssh_flags;
Branch: 1 branch
BranchTrueFalseTotal
if length $ssh_flags 0 0 0
1625  
1626 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
1627 $cmd eq 'ssh' ? $self->_make_ssh_call(\@ssh_opts, @args) :
1628 $cmd eq 'scp' ? $self->_make_scp_call(\@ssh_opts, @args) :
1629 $cmd eq 'rsync' ? $self->_make_rsync_call(\@ssh_opts, @args) :
1630 $cmd eq 'raw' ? @args :
1631 die "Internal error: bad _cmd protocol" );
1632  
1633 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
1634  
1635 0 my $pid = fork;
1636 0 ▶ unless ($pid) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($pid) 0 0 0
1637 0 ▶ unless (defined $pid) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $pid) 0 0 0
1638 0 $self->_set_error(OSSH_SLAVE_FAILED,
1639 "unable to fork new ssh slave: $!");
1640 0 return;
1641 }
1642  
1643 0 ▶ setpgrp if $setpgrp;
Branch: 1 branch
BranchTrueFalseTotal
if $setpgrp 0 0 0
1644  
1645 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
1646 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
1647 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
1648  
1649 0 ▶ if ($stdinout_dpipe) {
Branch: 1 branch
BranchTrueFalseTotal
if ($stdinout_dpipe) 0 0 0
1650 0 my $pid1 = fork;
1651 0 ▶ defined $pid1 or POSIX::_exit(255);
Branch: 1 branch
BranchTrueFalseTotal
defined $pid1 or POSIX::_exit(255) 0 0 0
1652  
1653 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
1654 0 eval { $self->_exec_dpipe($stdinout_dpipe, $win, $werr) };
1655 0 POSIX::_exit(255);
1656 }
1657 }
1658  
1659 0 my $rin_fd = _fileno_dup_over(0 => $rin);
1660 0 my $wout_fd = _fileno_dup_over(1 => $wout);
1661 0 my $werr_fd = _fileno_dup_over(2 => $werr);
1662  
1663 0 ▶ if (defined $rin_fd) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $rin_fd) 0 0 0
1664 0 ▶ $win->make_slave_controlling_terminal if $stdin_pty;
Branch: 1 branch
BranchTrueFalseTotal
if $stdin_pty 0 0 0
1665 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
1666 }
1667 0 ▶ if (defined $wout_fd) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $wout_fd) 0 0 0
1668 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
1669 }
1670 0 ▶ if (defined $werr_fd) {
Branch: 2 branches
BranchTrueFalseTotal
if (defined $werr_fd) { } 0 0 0
elsif ($stderr_to_stdout) { } 0 0 0
1671 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
1672 }
1673 elsif ($stderr_to_stdout) {
1674 0 ▶ POSIX::dup2(1, 2) or POSIX::_exit(255);
Branch: 1 branch
BranchTrueFalseTotal
POSIX::dup2(1, 2) or POSIX::_exit(255) 0 0 0
1675 }
1676 0 do { exec @call };
1677 0 POSIX::_exit(255);
1678 }
1679 0 ▶ $win->close_slave() if $close_slave_pty;
Branch: 1 branch
BranchTrueFalseTotal
if $close_slave_pty 0 0 0
1680 0 ▶ undef $win if defined $stdinout_dpipe;
Branch: 1 branch
BranchTrueFalseTotal
if defined $stdinout_dpipe 0 0 0
1681 0 ▶ wantarray ? ($win, $rout, $rerr, $pid) : $pid;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
1682 }
1683  
1684 sub pipe_in {
1685 0 ▶ ${^TAINT} and &_catch_tainted_args;
Subroutine pipe_in: not called CC=9 SCAR=45.0
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
${^TAINT} and &_catch_tainted_args 0 0 0
1686 0 my $self = shift;
1687 0 ▶ $self->wait_for_master or return;
Branch: 1 branch
BranchTrueFalseTotal
$self->wait_for_master or return 0 0 0
1688 0 ▶ my %opts = (ref $_[0] eq 'HASH' ? %{shift()} : ());
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] eq 'HASH' ? : 0 0 0
1689 0 my $argument_encoding = $self->_delete_argument_encoding(\%opts);
1690 0 my @args = $self->_quote_args(\%opts, @_);
1691 0 _croak_bad_options %opts;
1692  
1693 0 ▶ $self->_encode_args($argument_encoding, @args) or return;
Branch: 1 branch
BranchTrueFalseTotal
$self->_encode_args($argument_encoding, @args) or return 0 0 0
1694 0 my @call = $self->_make_ssh_call([], @args);
1695 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
1696 0 my $pid = open my $rin, '|-', @call;
1697 0 ▶ unless ($pid) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($pid) 0 0 0
1698 0 $self->_set_error(OSSH_SLAVE_FAILED,
1699 "unable to fork new ssh slave: $!");
1700 0 return;
1701 }
1702 0 ▶ wantarray ? ($rin, $pid) : $rin;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
1703 }
1704  
1705 sub pipe_out {
1706 0 ▶ ${^TAINT} and &_catch_tainted_args;
Subroutine pipe_out: not called CC=9 SCAR=45.0
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
${^TAINT} and &_catch_tainted_args 0 0 0
1707 0 my $self = shift;
1708 0 ▶ $self->wait_for_master or return;
Branch: 1 branch
BranchTrueFalseTotal
$self->wait_for_master or return 0 0 0
1709 0 ▶ my %opts = (ref $_[0] eq 'HASH' ? %{shift()} : ());
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] eq 'HASH' ? : 0 0 0
1710 0 my $argument_encoding = $self->_delete_argument_encoding(\%opts);
1711 0 my @args = $self->_quote_args(\%opts, @_);
1712 0 _croak_bad_options %opts;
1713  
1714 0 ▶ $self->_encode_args($argument_encoding, @args) or return;
Branch: 1 branch
BranchTrueFalseTotal
$self->_encode_args($argument_encoding, @args) or return 0 0 0
1715 0 my @call = $self->_make_ssh_call([], @args);
1716 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
1717 0 my $pid = open my $rout, '-|', @call;
1718 0 ▶ unless ($pid) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($pid) 0 0 0
1719 0 $self->_set_error(OSSH_SLAVE_FAILED,
1720 "unable to fork new ssh slave: $!");
1721 0 return;
1722 }
1723 0 ▶ wantarray ? ($rout, $pid) : $rout;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
1724 }
1725  
1726 sub _find_encoding {
1727 0 ▶ my ($self, $encoding, $data) = @_;
Subroutine _find_encoding: not called CC=4 SCAR=30.0
1728 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
1729 0 _load_module('Encode');
1730 0 my $enc = Encode::find_encoding($encoding);
1731 0 ▶ unless (defined $enc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $enc) 0 0 0
1732 0 $self->_set_error(OSSH_ENCODING_ERROR, "bad encoding '$encoding'");
1733 return
1734 0 }
1735 0 return $enc
1736 }
1737 return undef
1738 0 }
1739  
1740 sub _encode {
1741 0 ▶ my $self = shift;
Subroutine _encode: not called CC=6 SCAR=37.4
1742 0 my $enc = shift;
1743 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
1744 0 local ($@, $SIG{__DIE__});
1745 0 eval {
1746 0 for (@_) {
1747 0 ▶ defined or next;
Branch: 1 branch
BranchTrueFalseTotal
defined $_ or next 0 0 0
1748 0 $_ = $enc->encode($_, Encode::FB_CROAK());
1749 }
1750 };
1751 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
1752 }
1753 0 1;
1754 }
1755  
1756 sub _encode_args {
1757 0 ▶ if (@_ > 2) {
Subroutine _encode_args: not called CC=3 SCAR=24.8
Branch: 1 branch
BranchTrueFalseTotal
if (@_ > 2) 0 0 0
1758 0 my $self = shift;
1759 0 my $encoding = shift;
1760  
1761 0 my $enc = $self->_find_encoding($encoding);
1762 0 ▶ if ($enc) {
Branch: 1 branch
BranchTrueFalseTotal
if ($enc) 0 0 0
1763 0 local $self->{_error_prefix} = [@{$self->{_error_prefix}}, "argument encoding failed"];
1764 0 $self->_encode($enc, @_);
1765 }
1766 0 return !$self->{_error};
1767 }
1768 0 1;
1769 }
1770  
1771 sub _decode {
1772 0 ▶ my $self = shift;
Subroutine _decode: not called CC=3 SCAR=24.8
1773 0 my $enc = shift;
1774 0 local ($@, $SIG{__DIE__});
1775 0 eval {
1776 0 for (@_) {
1777 0 ▶ defined or next;
Branch: 1 branch
BranchTrueFalseTotal
defined $_ or next 0 0 0
1778 0 $_ = $enc->decode($_, Encode::FB_CROAK());
1779 }
1780 };
1781 0 $self->_check_eval_ok(OSSH_ENCODING_ERROR);
1782 }
1783  
1784 3 my @retriable = (Errno::EINTR(), Errno::EAGAIN());
1785 3 push @retriable, Errno::EWOULDBLOCK() if Errno::EWOULDBLOCK() != Errno::EAGAIN();
1786  
1787 sub _io3 {
1788 0 ▶ my ($self, $out, $err, $in, $stdin_data, $timeout, $encoding, $keep_in_open) = @_;
Subroutine _io3: not called CC=68 SCAR=84.5
1789 # $self->wait_for_master or return;
1790 0 my @data = _array_or_scalar_to_list $stdin_data;
1791 0 my ($cout, $cerr, $cin) = (defined($out), defined($err), defined($in));
1792 0 ▶ $timeout = $self->{_timeout} unless defined $timeout;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $timeout 0 0 0
1793  
1794 0 ▶ my $has_input = grep { defined and length } @data;
Branch: 1 branch
BranchTrueFalseTotal
defined $_ and length $_ 0 0 0
1795 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
1796 0 ▶ close $in unless $keep_in_open;
Branch: 1 branch
BranchTrueFalseTotal
unless $keep_in_open 0 0 0
1797 0 undef $cin;
1798 }
1799 ▶ 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
1800 0 croak "remote input channel is not defined but data is available for sending"
1801 }
1802  
1803 0 my $enc = $self->_find_encoding($encoding);
1804 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
1805 0 local $self->{_error_prefix} = [@{$self->{_error_prefix}}, "stdin data encoding failed"];
1806 0 ▶ $self->_encode($enc, @data) if $has_input;
Branch: 1 branch
BranchTrueFalseTotal
if $has_input 0 0 0
1807 0 ▶ return if $self->{_error};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"_error"} 0 0 0
1808 }
1809  
1810 0 my $bout = '';
1811 0 my $berr = '';
1812 0 my ($fnoout, $fnoerr, $fnoin);
1813 0 local $SIG{PIPE} = 'IGNORE';
1814  
1815 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
1816 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
1817 ", cout: " . ($cout || 0) . ", cerr: " . ($cerr || 0);
1818 0 my ($rv, $wv);
1819  
1820 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
1821 0 $rv = '';
1822 0 ▶ if ($cout) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cout) 0 0 0
1823 0 $fnoout = fileno $out;
1824 0 vec($rv, $fnoout, 1) = 1;
1825 }
1826 0 ▶ if ($cerr) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cerr) 0 0 0
1827 0 $fnoerr = fileno $err;
1828 0 vec($rv, $fnoerr, 1) = 1
1829 }
1830 }
1831  
1832 0 ▶ if ($cin) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cin) 0 0 0
1833 0 $fnoin = fileno $in;
1834 0 $wv = '';
1835 0 vec($wv, $fnoin, 1) = 1;
1836 }
1837  
1838 0 my $recalc_vecs;
1839 0 ▶ FAST: until ($recalc_vecs) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($recalc_vecs) 0 0 0
1840 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
1841 _debug "io3 fast, cin: " . ($cin || 0) .
1842 ", cout: " . ($cout || 0) . ", cerr: " . ($cerr || 0);
1843 0 my ($rv1, $wv1) = ($rv, $wv);
1844 0 my $n = select ($rv1, $wv1, undef, $timeout);
1845 0 ▶ if ($n > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($n > 0) { } 0 0 0
1846 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
1847 0 my $offset = length $bout;
1848 0 my $read = sysread($out, $bout, 20480, $offset);
1849 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
1850 0 _debug "stdout, bytes read: ", $read, " at offset $offset";
1851 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
1852 }
1853 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
1854 0 close $out;
1855 0 undef $cout;
1856 0 $recalc_vecs = 1;
1857 }
1858 }
1859 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
1860 0 my $read = sysread($err, $berr, 20480, length($berr));
1861 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
1862 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
1863 0 close $err;
1864 0 undef $cerr;
1865 0 $recalc_vecs = 1;
1866 }
1867 }
1868 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
1869 0 my $written = syswrite($in, $data[0], 20480);
1870 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
1871 0 _debug "stdin, bytes written: ", $written;
1872 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
1873 }
1874 0 ▶ if ($written) {
Branch: 2 branches
BranchTrueFalseTotal
if ($written) { } 0 0 0
elsif (grep(($! == $_), @retriable)) { } 0 0 0
1875 0 substr($data[0], 0, $written, '');
1876 0 ▶ while (@data) {
Branch: 1 branch
BranchTrueFalseTotal
if (@data) 0 0 0
1877 next FAST
1878 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
1879 0 shift @data;
1880 }
1881 # fallback when stdin queue is exhausted
1882 }
1883 elsif (grep $! == $_, @retriable) {
1884 0 next FAST;
1885 }
1886 0 ▶ close $in unless $keep_in_open;
Branch: 1 branch
BranchTrueFalseTotal
unless $keep_in_open 0 0 0
1887 0 undef $cin;
1888 0 $recalc_vecs = 1;
1889 }
1890 }
1891 else {
1892 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
1893 0 $self->_set_error(OSSH_SLAVE_TIMEOUT, 'ssh slave failed', 'timed out');
1894 0 last MLOOP;
1895 }
1896 }
1897 }
1898 0 ▶ close $out if $cout;
Branch: 1 branch
BranchTrueFalseTotal
if $cout 0 0 0
1899 0 ▶ close $err if $cerr;
Branch: 1 branch
BranchTrueFalseTotal
if $cerr 0 0 0
1900 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
1901  
1902 0 ▶ if ($enc) {
Branch: 1 branch
BranchTrueFalseTotal
if ($enc) 0 0 0
1903 0 local $self->{_error_prefix} = [@{$self->{_error_prefix}}, 'output decoding failed'];
1904 0 ▶ unless ($self->_decode($enc, $bout, $berr)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->_decode($enc, $bout, $berr)) 0 0 0
1905 0 undef $bout;
1906 0 undef $berr;
1907 }
1908 }
1909 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
1910 0 return ($bout, $berr);
1911 }
1912  
1913  
1914  
1915 3 _sub_options spawn => qw(stderr_to_stdout stdin_discard stdin_fh stdin_file stdout_discard stdout_fh
1916 stdout_file stderr_discard stderr_fh stderr_file stdinout_dpipe
1917 stdinout_dpipe_make_parent quote_args quote_args_extended remote_shell
1918 glob_quoting tty ssh_opts tunnel encoding argument_encoding forward_agent
1919 forward_X11 setpgrp subsystem);
1920 sub spawn {
1921 0 ▶ ${^TAINT} and &_catch_tainted_args;
Subroutine spawn: not called CC=3 SCAR=24.8
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
${^TAINT} and &_catch_tainted_args 0 0 0
1922 0 my $self = shift;
1923 0 ▶ my %opts = (ref $_[0] eq 'HASH' ? %{shift()} : ());
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] eq 'HASH' ? : 0 0 0
1924 0 _croak_bad_options %opts;
1925  
1926 0 return scalar $self->open_ex(\%opts, @_);
1927 }
1928  
1929 3 _sub_options open2 => qw(stderr_to_stdout stderr_discard stderr_fh stderr_file quote_args quote_args_extended
1930 remote_shell glob_quoting tty ssh_opts tunnel encoding argument_encoding forward_agent
1931 forward_X11 setpgrp subsystem);
1932 sub open2 {
1933 0 ▶ ${^TAINT} and &_catch_tainted_args;
Subroutine open2: not called CC=4 SCAR=30.0
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
${^TAINT} and &_catch_tainted_args 0 0 0
1934 0 my $self = shift;
1935 0 ▶ my %opts = (ref $_[0] eq 'HASH' ? %{shift()} : ());
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] eq 'HASH' ? : 0 0 0
1936 0 _croak_bad_options %opts;
1937 0 _croak_scalar_context;
1938  
1939 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
1940 $self->open_ex({ stdout_pipe => 1,
1941 stdin_pipe => 1,
1942 %opts }, @_) or return ();
1943 0 return ($in, $out, $pid);
1944 }
1945  
1946 3 _sub_options open2pty => qw(stderr_to_stdout stderr_discard stderr_fh stderr_file
1947 quote_args quote_args_extended remote_shell glob_quoting tty
1948 close_slave_pty ssh_opts encoding argument_encoding forward_agent
1949 forward_X11 setpgrp subsystem);
1950 sub open2pty {
1951 0 ▶ ${^TAINT} and &_catch_tainted_args;
Subroutine open2pty: not called CC=5 SCAR=34.0
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
${^TAINT} and &_catch_tainted_args 0 0 0
1952 0 my $self = shift;
1953 0 ▶ my %opts = (ref $_[0] eq 'HASH' ? %{shift()} : ());
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] eq 'HASH' ? : 0 0 0
1954 0 _croak_bad_options %opts;
1955  
1956 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
1957 $self->open_ex({ stdout_pty => 1,
1958 stdin_pty => 1,
1959 tty => 1,
1960 %opts }, @_) or return ();
1961 0 ▶ wantarray ? ($pty, $pid) : $pty;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
1962 }
1963  
1964 3 _sub_options open2socket => qw(stderr_to_stdout stderr_discard stderr_fh stderr_file
1965 quote_args quote_args_extended remote_shell glob_quoting tty
1966 ssh_opts tunnel encoding argument_encoding forward_agent
1967 forward_X11 setpgrp subsystem);
1968 sub open2socket {
1969 0 ▶ ${^TAINT} and &_catch_tainted_args;
Subroutine open2socket: not called CC=5 SCAR=34.0
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
${^TAINT} and &_catch_tainted_args 0 0 0
1970 0 my $self = shift;
1971 0 ▶ my %opts = (ref $_[0] eq 'HASH' ? %{shift()} : ());
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] eq 'HASH' ? : 0 0 0
1972 0 _croak_bad_options %opts;
1973  
1974 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
1975 $self->open_ex({ stdinout_socket => 1,
1976 %opts }, @_) or return ();
1977 0 ▶ wantarray ? ($socket, $pid) : $socket;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
1978 }
1979  
1980 3 _sub_options open3 => qw(quote_args quote_args_extended remote_shell glob_quoting tty ssh_opts
1981 encoding argument_encoding forward_agent forward_X11 setpgrp subsystem);
1982 sub open3 {
1983 0 ▶ ${^TAINT} and &_catch_tainted_args;
Subroutine open3: not called CC=4 SCAR=30.0
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
${^TAINT} and &_catch_tainted_args 0 0 0
1984 0 my $self = shift;
1985 0 ▶ my %opts = (ref $_[0] eq 'HASH' ? %{shift()} : ());
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] eq 'HASH' ? : 0 0 0
1986 0 _croak_bad_options %opts;
1987 0 _croak_scalar_context;
1988  
1989 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
1990 $self->open_ex({ stdout_pipe => 1,
1991 stdin_pipe => 1,
1992 stderr_pipe => 1,
1993 %opts },
1994 @_) or return ();
1995 0 return ($in, $out, $err, $pid);
1996 }
1997  
1998 3 _sub_options open3pty => qw(quote_args quote_args_extended remote_shell glob_quoting tty close_slave_pty ssh_opts
1999 encoding argument_encoding forward_agent forward_X11 setpgrp subsystem);
2000 sub open3pty {
2001 0 ▶ ${^TAINT} and &_catch_tainted_args;
Subroutine open3pty: not called CC=4 SCAR=30.0
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
${^TAINT} and &_catch_tainted_args 0 0 0
2002 0 my $self = shift;
2003 0 ▶ my %opts = (ref $_[0] eq 'HASH' ? %{shift()} : ());
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] eq 'HASH' ? : 0 0 0
2004 0 _croak_bad_options %opts;
2005 0 _croak_scalar_context;
2006  
2007 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
2008 $self->open_ex({ stdout_pty => 1,
2009 stdin_pty => 1,
2010 tty => 1,
2011 stderr_pipe => 1,
2012 %opts },
2013 @_) or return ();
2014 0 return ($pty, $err, $pid);
2015 }
2016  
2017 3 _sub_options open3socket => qw(quote_args quote_args_extended remote_shell glob_quoting tty ssh_opts encoding
2018 argument_encoding forward_agent forward_X11 setpgrp subsystem);
2019 sub open3socket {
2020 0 ▶ ${^TAINT} and &_catch_tainted_args;
Subroutine open3socket: not called CC=4 SCAR=30.0
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
${^TAINT} and &_catch_tainted_args 0 0 0
2021 0 my $self = shift;
2022 0 ▶ my %opts = (ref $_[0] eq 'HASH' ? %{shift()} : ());
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] eq 'HASH' ? : 0 0 0
2023 0 _croak_bad_options %opts;
2024 0 _croak_scalar_context;
2025  
2026 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
2027 $self->open_ex({ stdinout_socket => 1,
2028 stderr_pipe => 1,
2029 %opts }, @_) or return ();
2030 0 return ($socket, $err, $pid);
2031 }
2032  
2033 3 _sub_options system => qw(stdout_discard stdout_fh stdin_discard stdout_file stdin_fh stdin_file
2034 quote_args quote_args_extended remote_shell glob_quoting
2035 stderr_to_stdout stderr_discard stderr_fh stderr_file
2036 stdinout_dpipe stdinout_dpipe_make_parent tty ssh_opts tunnel encoding
2037 argument_encoding forward_agent forward_X11 setpgrp subsystem);
2038 sub system {
2039 0 ▶ ${^TAINT} and &_catch_tainted_args;
Subroutine system: not called CC=10 SCAR=47.0
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
${^TAINT} and &_catch_tainted_args 0 0 0
2040 0 my $self = shift;
2041 0 ▶ my %opts = (ref $_[0] eq 'HASH' ? %{shift()} : ());
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] eq 'HASH' ? : 0 0 0
2042 0 my $stdin_data = delete $opts{stdin_data};
2043 0 my $timeout = delete $opts{timeout};
2044 0 my $async = delete $opts{async};
2045 0 ▶ my $stdin_keep_open = ($async ? undef : delete $opts{stdin_keep_open});
Branch: 1 branch
BranchTrueFalseTotal
$async ? : 0 0 0
2046  
2047 0 _croak_bad_options %opts;
2048  
2049 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
2050  
2051 0 my $stream_encoding;
2052 0 ▶ if (defined $stdin_data) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $stdin_data) 0 0 0
2053 0 $opts{stdin_pipe} = 1;
2054 0 $stream_encoding = $self->_delete_stream_encoding(\%opts);
2055 }
2056  
2057 0 local $SIG{INT} = 'IGNORE';
2058 0 local $SIG{QUIT} = 'IGNORE';
2059 0 local $SIG{CHLD};
2060  
2061 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
2062  
2063 0 ▶ $self->_io3(undef, undef, $in, $stdin_data,
Branch: 1 branch
BranchTrueFalseTotal
if defined $stdin_data 0 0 0
2064 $timeout, $stream_encoding, $stdin_keep_open) if defined $stdin_data;
2065 0 ▶ return $pid if $async;
Branch: 1 branch
BranchTrueFalseTotal
if $async 0 0 0
2066 0 $self->_waitpid($pid, $timeout);
2067 }
2068  
2069 3 _sub_options test => qw(stdout_discard stdout_fh stdin_discard stdout_file stdin_fh stdin_file
2070 quote_args quote_args_extended remote_shell glob_quoting stderr_to_stdout
2071 stderr_discard stderr_fh stderr_file stdinout_dpipe
2072 stdinout_dpipe_make_parent tty ssh_opts timeout stdin_data stdin_keep_open
2073 encoding stream_encoding argument_encoding forward_agent forward_X11
2074 setpgrp subsystem);
2075  
2076 sub test {
2077 0 ▶ ${^TAINT} and &_catch_tainted_args;
Subroutine test: not called CC=7 SCAR=40.3
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
${^TAINT} and &_catch_tainted_args 0 0 0
2078 0 my $self = shift;
2079 0 ▶ my %opts = (ref $_[0] eq 'HASH' ? %{shift()} : ());
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] eq 'HASH' ? : 0 0 0
2080 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
2081 stdout_file stdinout_dpipe);
2082 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
2083 stderr_file stderr_to_stdout);
2084 0 _croak_bad_options %opts;
2085  
2086 0 $self->system(\%opts, @_);
2087 0 my $error = $self->{_error};
2088 0 ▶ unless ($error) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($error) 0 0 0
2089 0 return 1;
2090 }
2091 0 ▶ if ($error == OSSH_SLAVE_CMD_FAILED) {
Branch: 1 branch
BranchTrueFalseTotal
if ($error == 5) 0 0 0
2092 0 $self->_set_error(0);
2093 0 return 0;
2094 }
2095 0 return undef;
2096 }
2097  
2098 3 _sub_options capture => qw(stderr_to_stdout stderr_discard stderr_fh stderr_file stdin_discard
2099 stdin_fh stdin_file quote_args quote_args_extended remote_shell
2100 glob_quoting tty ssh_opts tunnel encoding argument_encoding forward_agent
2101 forward_X11 setpgrp subsystem);
2102 sub capture {
2103 0 ▶ ${^TAINT} and &_catch_tainted_args;
Subroutine capture: not called CC=8 SCAR=42.8
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
${^TAINT} and &_catch_tainted_args 0 0 0
2104 0 my $self = shift;
2105 0 ▶ my %opts = (ref $_[0] eq 'HASH' ? %{shift()} : ());
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] eq 'HASH' ? : 0 0 0
2106 0 my $stdin_data = delete $opts{stdin_data};
2107 0 my $stdin_keep_open = delete $opts{stdin_keep_open};
2108 0 my $timeout = delete $opts{timeout};
2109 0 _croak_bad_options %opts;
2110  
2111 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
2112  
2113 0 my $stream_encoding = $self->_delete_stream_encoding(\%opts);
2114 0 $opts{stdout_pipe} = 1;
2115 0 ▶ $opts{stdin_pipe} = 1 if defined $stdin_data;
Branch: 1 branch
BranchTrueFalseTotal
if defined $stdin_data 0 0 0
2116  
2117 0 local $SIG{INT} = 'IGNORE';
2118 0 local $SIG{QUIT} = 'IGNORE';
2119 0 local $SIG{CHLD};
2120  
2121 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
2122 0 my ($output) = $self->_io3($out, undef, $in, $stdin_data,
2123 $timeout, $stream_encoding, $stdin_keep_open);
2124 0 $self->_waitpid($pid, $timeout);
2125 0 ▶ if (wantarray) {
Branch: 1 branch
BranchTrueFalseTotal
if (wantarray) 0 0 0
2126 0 my $pattern = quotemeta $/;
2127 0 return split /(?<=$pattern)/, $output;
2128 }
2129 $output
2130 0 }
2131  
2132 3 _sub_options capture2 => qw(stdin_discard stdin_fh stdin_file quote_args quote_args_extended
2133 remote_shell glob_quoting tty ssh_opts encoding stream_encoding
2134 argument_encoding forward_agent forward_X11 setpgrp subsystem);
2135 sub capture2 {
2136 0 ▶ ${^TAINT} and &_catch_tainted_args;
Subroutine capture2: not called CC=8 SCAR=42.8
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
${^TAINT} and &_catch_tainted_args 0 0 0
2137 0 my $self = shift;
2138 0 ▶ my %opts = (ref $_[0] eq 'HASH' ? %{shift()} : ());
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] eq 'HASH' ? : 0 0 0
2139 0 my $stdin_data = delete $opts{stdin_data};
2140 0 my $stdin_keep_open = delete $opts{stdin_keep_open};
2141 0 my $timeout = delete $opts{timeout};
2142 0 _croak_bad_options %opts;
2143  
2144 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
2145  
2146 0 my $stream_encoding = $self->_delete_stream_encoding(\%opts);
2147 0 $opts{stdout_pipe} = 1;
2148 0 $opts{stderr_pipe} = 1;
2149 0 ▶ $opts{stdin_pipe} = 1 if defined $stdin_data;
Branch: 1 branch
BranchTrueFalseTotal
if defined $stdin_data 0 0 0
2150  
2151 0 local $SIG{INT} = 'IGNORE';
2152 0 local $SIG{QUIT} = 'IGNORE';
2153 0 local $SIG{CHLD};
2154  
2155 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
2156 0 my @capture = $self->_io3($out, $err, $in, $stdin_data,
2157 $timeout, $stream_encoding, $stdin_keep_open);
2158 0 $self->_waitpid($pid, $timeout);
2159 0 ▶ wantarray ? @capture : $capture[0];
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
2160 }
2161  
2162 3 _sub_options open_tunnel => qw(ssh_opts stderr_discard stderr_fh stderr_file
2163 encoding argument_encoding forward_agent setpgrp);
2164 sub open_tunnel {
2165 0 ▶ ${^TAINT} and &_catch_tainted_args;
Subroutine open_tunnel: not called CC=5 SCAR=34.0
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
${^TAINT} and &_catch_tainted_args 0 0 0
2166 0 my $self = shift;
2167 0 ▶ my %opts = (ref $_[0] eq 'HASH' ? %{shift()} : ());
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] eq 'HASH' ? : 0 0 0
2168 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
2169 0 _croak_bad_options %opts;
2170 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
2171 0 $opts{tunnel} = 1;
2172 0 $self->open2socket(\%opts, @_);
2173 }
2174  
2175 3 _sub_options capture_tunnel => qw(ssh_opts stderr_discard stderr_fh stderr_file stdin_discard
2176 stdin_fh stdin_file stdin_data timeout encoding stream_encoding
2177 argument_encoding forward_agent setpgrp);
2178 sub capture_tunnel {
2179 0 ▶ ${^TAINT} and &_catch_tainted_args;
Subroutine capture_tunnel: not called CC=5 SCAR=34.0
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
${^TAINT} and &_catch_tainted_args 0 0 0
2180 0 my $self = shift;
2181 0 ▶ my %opts = (ref $_[0] eq 'HASH' ? %{shift()} : ());
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] eq 'HASH' ? : 0 0 0
2182 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
2183 0 _croak_bad_options %opts;
2184 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
2185 0 $opts{tunnel} = 1;
2186 0 $self->capture(\%opts, @_);
2187 }
2188  
2189 sub _calling_method {
2190 0 ▶ my $method = (caller 2)[3];
Subroutine _calling_method: not called CC=1 SCAR=6.9
2191 0 $method =~ s/.*:://;
2192 0 $method;
2193 }
2194  
2195 sub _scp_get_args {
2196 0 ▶ my $self = shift;
Subroutine _scp_get_args: not called CC=6 SCAR=37.4
2197 0 ▶ my %opts = (ref $_[0] eq 'HASH' ? %{shift()} : ());
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] eq 'HASH' ? : 0 0 0
2198  
2199 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
2200 'Usage: $ssh->' . _calling_method . '(\%opts, $remote_fn1, $remote_fn2, ..., $local_fn_or_dir)';
2201  
2202 0 my $glob = delete $opts{glob};
2203  
2204 0 ▶ my $target = (@_ > 1 ? pop @_ : '.');
Branch: 1 branch
BranchTrueFalseTotal
@_ > 1 ? : 0 0 0
2205 0 ▶ $target =~ m|^[^/]*:| and $target = "./$target";
Branch: 1 branch
BranchTrueFalseTotal
$target =~ m[^[^/]*:] and $target = "./$target" 0 0 0
2206  
2207 0 my $prefix = $self->{_host_squared};
2208 0 ▶ $prefix = "$self->{_user}\@$prefix" if defined $self->{_user};
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{"_user"} 0 0 0
2209  
2210 0 my $src = "$prefix:". join(" ", $self->_quote_args({quote_args => 1,
2211 glob_quoting => $glob},
2212 @_));
2213 0 ($self, \%opts, $target, $src);
2214 }
2215  
2216 sub scp_get {
2217 0 ▶ ${^TAINT} and &_catch_tainted_args;
Subroutine scp_get: not called CC=2 SCAR=17.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
${^TAINT} and &_catch_tainted_args 0 0 0
2218 0 my ($self, $opts, $target, @src) = _scp_get_args @_;
2219 0 $self->_scp($opts, @src, $target);
2220 }
2221  
2222 sub rsync_get {
2223 0 ▶ ${^TAINT} and &_catch_tainted_args;
Subroutine rsync_get: not called CC=2 SCAR=17.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
${^TAINT} and &_catch_tainted_args 0 0 0
2224 0 my ($self, $opts, $target, @src) = _scp_get_args @_;
2225 0 $self->_rsync($opts, @src, $target);
2226 }
2227  
2228 sub _scp_put_args {
2229 0 ▶ my $self = shift;
Subroutine _scp_put_args: not called CC=10 SCAR=47.0
2230 0 ▶ my %opts = (ref $_[0] eq 'HASH' ? %{shift()} : ());
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] eq 'HASH' ? : 0 0 0
2231  
2232 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
2233 'Usage: $ssh->' . _calling_method . '(\%opts, $local_fn1, $local_fn2, ..., $remote_dir_or_fn)';
2234  
2235 0 my $glob = delete $opts{glob};
2236 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
2237  
2238 0 my $prefix = $self->{_host_squared};
2239 0 ▶ $prefix = "$self->{_user}\@$prefix" if defined $self->{_user};
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{"_user"} 0 0 0
2240  
2241 0 my $remote_shell = delete $opts{remote_shell};
2242 0 ▶ my $target = $prefix . ':' . ( @_ > 1
Branch: 1 branch
BranchTrueFalseTotal
@_ > 1 ? : 0 0 0
2243 ? $self->_quote_args({quote_args => 1, remote_shell => $remote_shell}, pop(@_))
2244 : '');
2245  
2246 0 my @src = @_;
2247 0 ▶ if ($glob) {
Branch: 1 branch
BranchTrueFalseTotal
if ($glob) 0 0 0
2248 0 require File::Glob;
2249 0 @src = map File::Glob::bsd_glob($_, $glob_flags), @src;
2250 0 ▶ unless (@src) {
Branch: 1 branch
BranchTrueFalseTotal
unless (@src) 0 0 0
2251 0 $self->_set_error(OSSH_SLAVE_FAILED,
2252 "given file name patterns did not match any file");
2253 0 return undef;
2254 }
2255 }
2256 0 $_ = "./$_" for grep m|^[^/]*:|, @src;
2257  
2258 0 ($self, \%opts, $target, @src);
2259 }
2260  
2261 sub scp_put {
2262 0 ▶ ${^TAINT} and &_catch_tainted_args;
Subroutine scp_put: not called CC=3 SCAR=24.8
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
${^TAINT} and &_catch_tainted_args 0 0 0
2263 0 my ($self, $opts, $target, @src) = _scp_put_args @_;
2264 0 ▶ return unless $self;
Branch: 1 branch
BranchTrueFalseTotal
unless $self 0 0 0
2265 0 $self->_scp($opts, @src, $target);
2266 }
2267  
2268 sub rsync_put {
2269 0 ▶ ${^TAINT} and &_catch_tainted_args;
Subroutine rsync_put: not called CC=3 SCAR=24.8
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
${^TAINT} and &_catch_tainted_args 0 0 0
2270 0 my ($self, $opts, $target, @src) = _scp_put_args @_;
2271 0 ▶ return unless $self;
Branch: 1 branch
BranchTrueFalseTotal
unless $self 0 0 0
2272 0 $self->_rsync($opts, @src, $target);
2273 }
2274  
2275 3 _sub_options _scp => qw(stderr_to_stdout stderr_discard stderr_fh
2276 stderr_file stdout_discard stdout_fh
2277 stdout_file encoding argument_encoding
2278 forward_agent setpgrp);
2279 sub _scp {
2280 0 ▶ my $self = shift;
Subroutine _scp: not called CC=10 SCAR=47.0
2281 0 ▶ my %opts = (ref $_[0] eq 'HASH' ? %{shift()} : ());
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] eq 'HASH' ? : 0 0 0
2282 0 my $quiet = delete $opts{quiet};
2283 0 ▶ $quiet = 1 unless defined $quiet;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $quiet 0 0 0
2284 0 my $recursive = delete $opts{recursive};
2285 0 my $copy_attrs = delete $opts{copy_attrs};
2286 0 my $bwlimit = delete $opts{bwlimit};
2287 0 my $async = delete $opts{async};
2288 0 my $ssh_opts = delete $opts{ssh_opts};
2289 0 my $timeout = delete $opts{timeout};
2290 0 my $verbose = delete $opts{verbose};
2291 0 _croak_bad_options %opts;
2292  
2293 0 my @opts;
2294 0 ▶ @opts = @$ssh_opts if $ssh_opts;
Branch: 1 branch
BranchTrueFalseTotal
if $ssh_opts 0 0 0
2295 0 ▶ push @opts, '-q' if $quiet;
Branch: 1 branch
BranchTrueFalseTotal
if $quiet 0 0 0
2296 0 ▶ push @opts, '-v' if $verbose;
Branch: 1 branch
BranchTrueFalseTotal
if $verbose 0 0 0
2297 0 ▶ push @opts, '-r' if $recursive;
Branch: 1 branch
BranchTrueFalseTotal
if $recursive 0 0 0
2298 0 ▶ push @opts, '-p' if $copy_attrs;
Branch: 1 branch
BranchTrueFalseTotal
if $copy_attrs 0 0 0
2299 0 ▶ push @opts, '-l', $bwlimit if $bwlimit;
Branch: 1 branch
BranchTrueFalseTotal
if $bwlimit 0 0 0
2300  
2301 0 local $self->{_error_prefix} = [@{$self->{_error_prefix}}, 'scp failed'];
2302  
2303 0 my $pid = $self->open_ex({ %opts,
2304 _cmd => 'scp',
2305 ssh_opts => \@opts,
2306 quote_args => 0 },
2307 @_);
2308  
2309 0 ▶ return $pid if $async;
Branch: 1 branch
BranchTrueFalseTotal
if $async 0 0 0
2310 0 $self->_waitpid($pid, $timeout);
2311 }
2312  
2313 3 my %rsync_opt_with_arg = map { $_ => 1 } qw(chmod suffix backup-dir rsync-path max-delete max-size min-size partial-dir
2314 timeout modify-window temp-dir compare-dest copy-dest link-dest compress-level
2315 skip-compress filter exclude exclude-from include include-from
2316 out-format log-file log-file-format bwlimit protocol iconv checksum-seed files-from);
2317  
2318 3 my %rsync_opt_forbidden = map { $_ => 1 } qw(rsh address port sockopts password-file write-batch
2319 only-write-batch read-batch ipv4 ipv6 version help daemon config detach
2320 protect-args list-only);
2321  
2322 3 $rsync_opt_forbidden{"no-$_"} = 1 for (keys %rsync_opt_with_arg, keys %rsync_opt_forbidden);
2323  
2324 3 my %rsync_error = (1, 'syntax or usage error',
2325 2, 'protocol incompatibility',
2326 3, 'errors selecting input/output files, dirs',
2327 4, 'requested action not supported: an attempt was made to manipulate 64-bit files on a platform '.
2328 'that cannot support them; or an option was specified that is supported by the client and not '.
2329 'by the server.',
2330 5, 'error starting client-server protocol',
2331 6, 'daemon unable to append to log-file',
2332 10, 'error in socket I/O',
2333 11, 'error in file I/O',
2334 12, 'error in rsync protocol data stream',
2335 13, 'errors with program diagnostics',
2336 14, 'error in IPC code',
2337 20, 'received SIGUSR1 or SIGINT',
2338 21, 'some error returned by waitpid()',
2339 22, 'error allocating core memory buffers',
2340 23, 'partial transfer due to error',
2341 24, 'partial transfer due to vanished source files',
2342 25, 'the --max-delete limit stopped deletions',
2343 30, 'timeout in data send/receive',
2344 35, 'timeout waiting for daemon connection');
2345  
2346 3 my %rsync_opt_open_ex = map { $_ => 1 } qw(stderr_to_stdout
2347 stderr_discard stderr_fh
2348 stderr_file stdout_discard
2349 stdout_fh stdout_file encoding
2350 argument_encoding);
2351 sub _rsync {
2352 0 ▶ my $self = shift;
Subroutine _rsync: not called CC=22 SCAR=62.3
2353 0 ▶ my %opts = (ref $_[0] eq 'HASH' ? %{shift()} : ());
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] eq 'HASH' ? : 0 0 0
2354 0 my $async = delete $opts{async};
2355 0 my $verbose = delete $opts{verbose};
2356 0 my $quiet = delete $opts{quiet};
2357 0 my $copy_attrs = delete $opts{copy_attrs};
2358 0 my $timeout = delete $opts{timeout};
2359 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
2360  
2361 0 my @opts;
2362 0 ▶ push @opts, '-q' if $quiet;
Branch: 1 branch
BranchTrueFalseTotal
if $quiet 0 0 0
2363 0 ▶ push @opts, '-pt' if $copy_attrs;
Branch: 1 branch
BranchTrueFalseTotal
if $copy_attrs 0 0 0
2364 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
2365  
2366 0 my %opts_open_ex = ( _cmd => 'rsync',
2367 quote_args => 0 );
2368  
2369 0 for my $opt (keys %opts) {
2370 0 my $value = $opts{$opt};
2371 0 ▶ if (defined $value) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value) 0 0 0
2372 0 ▶ if ($rsync_opt_open_ex{$opt}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($rsync_opt_open_ex{$opt}) { } 0 0 0
2373 0 $opts_open_ex{$opt} = $value;
2374 }
2375 else {
2376 0 my $opt1 = $opt;
2377 0 $opt1 =~ tr/_/-/;
2378 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
2379 0 ▶ if ($rsync_opt_with_arg{$opt1}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($rsync_opt_with_arg{$opt1}) { } 0 0 0
2380 0 push @opts, "--$opt1=$_" for _array_or_scalar_to_list($value)
2381 }
2382 else {
2383 0 ▶ $value = !$value if $opt1 =~ s/^no-//;
Branch: 1 branch
BranchTrueFalseTotal
if $opt1 =~ s/^no-// 0 0 0
2384 0 ▶ push @opts, ($value ? "--$opt1" : "--no-$opt1");
Branch: 1 branch
BranchTrueFalseTotal
$value ? : 0 0 0
2385 }
2386 }
2387 }
2388 }
2389  
2390 0 local $self->{_error_prefix} = [@{$self->{_error_prefix}}, 'rsync failed'];
2391  
2392 0 my $pid = $self->open_ex(\%opts_open_ex, @opts, '--', @_);
2393 0 ▶ return $pid if $async;
Branch: 1 branch
BranchTrueFalseTotal
if $async 0 0 0
2394 0 ▶ $self->_waitpid($pid, $timeout) and return 1;
Branch: 1 branch
BranchTrueFalseTotal
$self->_waitpid($pid, $timeout) and return 1 0 0 0
2395  
2396 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
2397 0 my $err = ($? >> 8);
2398 0 my $errstr = $rsync_error{$err};
2399 0 ▶ $errstr = 'Unknown rsync error' unless defined $errstr;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $errstr 0 0 0
2400 0 my $signal = $? & 255;
2401 0 ▶ my $signalstr = ($signal ? " (signal $signal)" : '');
Branch: 1 branch
BranchTrueFalseTotal
$signal ? : 0 0 0
2402 0 $self->_set_error(OSSH_SLAVE_CMD_FAILED,
2403 "command exited with code $err$signalstr: $errstr");
2404 }
2405 return undef
2406 0 }
2407  
2408 3 _sub_options sftp => qw(autoflush timeout argument_encoding encoding block_size queue_size autodie
2409 late_set_perm forward_agent setpgrp min_block_size read_ahead write_delay
2410 dirty_cleanup remote_has_volumes autodisconnect more);
2411  
2412 sub sftp {
2413 0 ▶ ${^TAINT} and &_catch_tainted_args;
Subroutine sftp: not called CC=9 SCAR=45.0
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
${^TAINT} and &_catch_tainted_args 0 0 0
2414 0 ▶ @_ & 1 or croak 'Usage: $ssh->sftp(%sftp_opts)';
Branch: 1 branch
BranchTrueFalseTotal
@_ & 1 or croak("Usage: \$ssh->sftp(%sftp_opts)") 0 0 0
2415 0 _load_module('Net::SFTP::Foreign', '1.47');
2416 0 my ($self, %opts) = @_;
2417 0 my $stderr_fh = delete $opts{stderr_fh};
2418 0 my $stderr_discard = delete $opts{stderr_discard};
2419 my $fs_encoding = _first_defined(delete $opts{fs_encoding},
2420 $opts{argument_encoding},
2421 $opts{encoding},
2422 0 $self->{_default_argument_encoding});
2423 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
2424 0 _croak_bad_options %opts;
2425 0 ▶ $opts{timeout} = $self->{_timeout} unless defined $opts{timeout};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $opts{"timeout"} 0 0 0
2426 0 ▶ $self->wait_for_master or return undef;
Branch: 1 branch
BranchTrueFalseTotal
$self->wait_for_master or return undef 0 0 0
2427 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
2428 stderr_fh => $stderr_fh,
2429 stderr_discard => $stderr_discard },
2430 'sftp' )
2431 or return undef;
2432  
2433 0 my $sftp = Net::SFTP::Foreign->new(transport => [$out, $in, $pid],
2434 dirty_cleanup => 0,
2435 fs_encoding => $fs_encoding,
2436 %opts);
2437 0 ▶ if ($sftp->error) {
Branch: 1 branch
BranchTrueFalseTotal
if ($sftp->error) 0 0 0
2438 0 $self->_or_set_error(OSSH_SLAVE_SFTP_FAILED, "unable to create SFTP client", $sftp->error);
2439 0 return undef;
2440 }
2441 $sftp
2442 0 }
2443  
2444 3 _sub_options sshfs_import => qw(stderr_discard stderr_fh stderr_file
2445 ssh_opts argument_encoding sshfs_opts setpgrp);
2446 sub sshfs_import {
2447 0 ▶ ${^TAINT} and &_catch_tainted_args;
Subroutine sshfs_import: not called CC=4 SCAR=30.0
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
${^TAINT} and &_catch_tainted_args 0 0 0
2448 0 my $self = shift;
2449 0 ▶ my %opts = (ref $_[0] eq 'HASH' ? %{shift()} : ());
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] eq 'HASH' ? : 0 0 0
2450 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
2451 0 my ($from, $to) = @_;
2452 my @sshfs_opts = ( -o => 'slave',
2453 0 _array_or_scalar_to_list delete $opts{sshfs_opts} );
2454 0 _croak_bad_options %opts;
2455  
2456 0 $opts{ssh_opts} = ['-s', _array_or_scalar_to_list delete $opts{ssh_opts}];
2457 0 $opts{stdinout_dpipe} = [$self->{_sshfs_cmd}, "$self->{_host_squared}:$from", $to, @sshfs_opts];
2458 0 $opts{stdinout_dpipe_make_parent} = 1;
2459 0 $self->spawn(\%opts, 'sftp');
2460 }
2461  
2462 3 _sub_options sshfs_export => qw(stderr_discard stderr_fh stderr_file
2463 ssh_opts argument_encoding sshfs_opts setpgrp);
2464 sub sshfs_export {
2465 0 ▶ ${^TAINT} and &_catch_tainted_args;
Subroutine sshfs_export: not called CC=7 SCAR=40.3
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
${^TAINT} and &_catch_tainted_args 0 0 0
2466 0 my $self = shift;
2467 0 ▶ my %opts = (ref $_[0] eq 'HASH' ? %{shift()} : ());
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] eq 'HASH' ? : 0 0 0
2468 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
2469 0 my ($from, $to) = @_;
2470 my @sshfs_opts = ( -o => 'slave',
2471 0 _array_or_scalar_to_list delete $opts{sshfs_opts} );
2472 0 _croak_bad_options %opts;
2473 0 $opts{stdinout_dpipe} = $self->{_sftp_server_cmd};
2474  
2475 0 my $hostname = do {
2476 0 local ($@, $SIG{__DIE__});
2477 0 eval {
2478 0 require Sys::Hostname;
2479 0 Sys::Hostname::hostname();
2480 };
2481 };
2482 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
2483 not length $hostname or
2484 $hostname=~/^localhost\b/);
2485 0 $self->spawn(\%opts, $self->{_sshfs_cmd}, "$hostname:$from", $to, @sshfs_opts);
2486 }
2487  
2488 sub object_remote {
2489 0 ▶ my $self = shift;
Subroutine object_remote: not called CC=3 SCAR=24.8
Pod documented
2490 0 ▶ _load_module('Object::Remote') or return;
Branch: 1 branch
BranchTrueFalseTotal
_load_module("Object::Remote") or return 0 0 0
2491 0 ▶ _load_module('Net::OpenSSH::ObjectRemote') or return;
Branch: 1 branch
BranchTrueFalseTotal
_load_module("Net::OpenSSH::ObjectRemote") or return 0 0 0
2492 0 my $connector = Net::OpenSSH::ObjectRemote->new(net_openssh => $self);
2493 0 $connector->connect(@_);
2494 }
2495  
2496 sub any {
2497 0 ▶ my $self = shift;
Subroutine any: not called CC=1 SCAR=6.9
Pod documented
2498 0 _load_module('Net::SSH::Any');
2499 Net::SSH::Any->new($self->{_host}, user => $self->{_user}, port => $self->{_port},
2500 0 backend => 'Net_OpenSSH',
2501 backend_opts => { Net_OpenSSH => { instance => $self } });
2502 }
2503  
2504 sub DESTROY {
2505 0 ▶ my $self = shift;
Subroutine DESTROY: not called CC=3 SCAR=24.8
2506 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
2507 0 local ($SIG{__DIE__}, $@, $?, $!);
2508 0 $self->_disconnect;
2509 }
2510  
2511 3 1;
2512 __END__
↑ Summary OpenSSH/OSTracer.pm »