Any/OS/POSIX.pm

filter: Statementstmt 26.2% 56 / 213 Branchbran 4.3% 5 / 114 Conditioncond 1.3% 1 / 72 MC/DCmcdc 0.0% 0 / 45 Subroutinesub 54.1% 13 / 24 Podpod 0.0% 0 / 12 totaltotal 15.6% 75 / 480 CC 91 SCAR 72.0
CC
91
Cov
16%
io3
2862.0
open4
72.0
create_secret_file
72.0
CRAP 1344.9
↑ Summary Any/OS/_Base.pm »
1 package Net::SSH::Any::OS::POSIX;
2  
3 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 3 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 3 ▶use POSIX ();
Subroutine BEGIN: called CC=1 SCAR=0.0
8 3 ▶use Fcntl ();
Subroutine BEGIN: called CC=1 SCAR=0.0
9 3 ▶use Socket;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 3 ▶use Net::SSH::Any::Util qw($debug _debug _debug_hexdump _first_defined _warn);
Subroutine BEGIN: called CC=1 SCAR=0.0
11 3 ▶use Net::SSH::Any::Constants qw(:error);
Subroutine BEGIN: called CC=1 SCAR=0.0
12 3 ▶use File::Spec;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 3 ▶use Time::HiRes ();
Subroutine BEGIN: called CC=1 SCAR=0.0
14 3 ▶use Errno;
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 3 require Net::SSH::Any::OS::_Base;
17 3 our @ISA = qw(Net::SSH::Any::OS::_Base);
18  
19 0 ▶sub _fileno_dup_over {
Subroutine _fileno_dup_over: not called CC=4 SCAR=30.0
20 0 my ($good_fn, $fh) = @_;
21 0 ▶ if (defined $fh) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $fh) 0 0 0
22 0 my $fn = fileno $fh;
23 0 for (1..5) {
24 0 ▶ $fn >= $good_fn and return $fn;
Branch: 1 branch
BranchTrueFalseTotal
$fn >= $good_fn and return $fn 0 0 0
25 0 $fn = POSIX::dup($fn);
26 }
27 0 POSIX::_exit(255);
28 }
29 0 undef;
30 }
31  
32 0 ▶sub has_working_socketpair { 1 }
Subroutine has_working_socketpair: not called CC=1 SCAR=6.9
Pod undocumented
33  
34 0 ▶sub socketpair {
Subroutine socketpair: not called CC=4 SCAR=30.0
Pod undocumented
35 0 my $any = shift;
36 0 my ($a, $b);
37 0 ▶ unless (CORE::socketpair($a, $b, AF_UNIX, SOCK_STREAM, PF_UNSPEC)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (CORE::socketpair $a, $b, 1, 1, 0) 0 0 0
38 0 $any->_set_error(SSHA_LOCAL_IO_ERROR, "socketpair failed: $!");
39 0 return;
40 }
41 0 ▶ $debug and $debug & 1024 and _debug "socketpair => $a (", fileno($a), "), $b (", fileno($b), ")";
Branch: 1 branch
BranchTrueFalseTotal
$Net::SSH::Any::OS::POSIX::debug and $Net::SSH::Any::OS::POSIX::debug & 1024 and _debug("socketpair => $a (", fileno $a, "), $b (", fileno $b, ")") 0 0 0
Condition0%0/3
$Net::SSH::Any::OS::POSIX::debug and $Net::SSH::Any::OS::POSIX::debug & 1024
!ll&&!rl&&r
000
MC/DC0%0/2
$Net::SSH::Any::OS::POSIX::debug and $Net::SSH::Any::OS::POSIX::debug & 1024
$Net::SSH::Any::OS::POSIX::debug $Net::SSH::Any::OS::POSIX::debug & 1024
Truth table0%0/3
A and B
A= $Net::SSH::Any::OS::POSIX::debugB= $Net::SSH::Any::OS::POSIX::debug & 1024
ABresult
0X0
100
111
42 0 ($a, $b);
43 }
44  
45 0 ▶sub make_dpipe {
Subroutine make_dpipe: not called CC=2 SCAR=17.9
Pod undocumented
46 0 my ($any, $proc, $dpipe, $out) = @_;
47 0 ▶ defined $out and die "internal error: out should be undefined but is $out";
Branch: 1 branch
BranchTrueFalseTotal
defined $out and die "internal error: out should be undefined but is $out" 0 0 0
48 0 require Net::SSH::Any::OS::POSIX::DPipe;
49 0 Net::SSH::Any::OS::POSIX::DPipe->_upgrade_fh_to_dpipe($dpipe, $any, $proc);
50 0 $dpipe;
51 }
52  
53 0 ▶sub pipe {
Subroutine pipe: not called CC=4 SCAR=30.0
Pod undocumented
54 0 my $any = shift;
55 0 my ($r, $w);
56 0 ▶ unless (CORE::pipe $r, $w) {
Branch: 1 branch
BranchTrueFalseTotal
unless (CORE::pipe $r, $w) 0 0 0
57 0 $any->_set_error(SSHA_LOCAL_IO_ERROR, "Unable to create pipe: $!");
58 return
59 0 }
60 0 ▶ $debug and $debug & 1024 and _debug "pipe => $r (", fileno($r), "), $w (", fileno($w), ")";
Branch: 1 branch
BranchTrueFalseTotal
$Net::SSH::Any::OS::POSIX::debug and $Net::SSH::Any::OS::POSIX::debug & 1024 and _debug("pipe => $r (", fileno $r, "), $w (", fileno $w, ")") 0 0 0
Condition0%0/3
$Net::SSH::Any::OS::POSIX::debug and $Net::SSH::Any::OS::POSIX::debug & 1024
!ll&&!rl&&r
000
MC/DC0%0/2
$Net::SSH::Any::OS::POSIX::debug and $Net::SSH::Any::OS::POSIX::debug & 1024
$Net::SSH::Any::OS::POSIX::debug $Net::SSH::Any::OS::POSIX::debug & 1024
Truth table0%0/3
A and B
A= $Net::SSH::Any::OS::POSIX::debugB= $Net::SSH::Any::OS::POSIX::debug & 1024
ABresult
0X0
100
111
61 0 ($r, $w);
62 }
63  
64 0 ▶sub open4 {
Subroutine open4: not called CC=8 SCAR=42.8
Pod undocumented
65 0 my ($any, $fhs, $close, $pty, $stderr_to_stdout, @cmd) = @_;
66 0 my $pid = fork;
67 0 ▶ unless ($pid) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($pid) 0 0 0
68 0 ▶ unless (defined $pid) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $pid) 0 0 0
69 0 $any->_set_error(SSHA_CONNECTION_ERROR, "unable to fork new process: $!");
70 0 return;
71 }
72  
73 0 ▶ $pty->make_slave_controlling_terminal if $pty;
Branch: 1 branch
BranchTrueFalseTotal
if $pty 0 0 0
74  
75 0 my @fds = map _fileno_dup_over(3 => $_), @$fhs;
76 0 close $_ for grep defined, @$close;
77  
78 0 for (0..2) {
79 0 my $fd = $fds[$_];
80 0 ▶ POSIX::dup2($fd, $_) if defined $fd;
Branch: 1 branch
BranchTrueFalseTotal
if defined $fd 0 0 0
81 }
82  
83 0 ▶ POSIX::dup2(1, 2) if $stderr_to_stdout;
Branch: 1 branch
BranchTrueFalseTotal
if $stderr_to_stdout 0 0 0
84  
85 0 do { exec @cmd };
86 0 POSIX::_exit(255);
87 }
88 0 return { pid => $pid};
89 }
90  
91 3 my @retriable = (Errno::EINTR, Errno::EAGAIN);
92 3 push @retriable, Errno::EWOULDBLOCK if Errno::EWOULDBLOCK != Errno::EAGAIN;
93  
94 0 ▶sub io3 {
Subroutine io3: not called CC=53 SCAR=79.6
Pod undocumented
95 0 my ($any, $proc, $timeout, $data, $in, $out, $err) = @_;
96 0 my ($cin, $cout, $cerr) = map defined, $in, $out, $err;
97 0 ▶ $timeout = $any->{timeout} unless defined $timeout;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $timeout 0 0 0
98  
99 # removes undefs and zero length strings and copies the data
100 # string so that we can modify them in place
101 0 $data = $any->_os_io3_check_and_clean_data($data, $in);
102 0 ▶ if ($cin and not @$data) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cin and not @$data) 0 0 0
Condition0%0/3
$cin and not @$data
!ll&&!rl&&r
000
MC/DC0%0/2
$cin and not @$data
$cin not @$data
Truth table0%0/3
A and not(B)
A= $cinB= not @$data
ABresult
0X0
100
111
103 0 close $in;
104 0 undef $cin;
105 }
106  
107 0 my $bout = '';
108 0 my $berr = '';
109 0 my ($fnoout, $fnoerr, $fnoin);
110 0 local $SIG{PIPE} = 'IGNORE';
111  
112 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
113 0 ▶ $debug and $debug & 1024 and _debug "io3 mloop, cin: " . ($cin || 0) .
Branch: 1 branch
BranchTrueFalseTotal
$Net::SSH::Any::OS::POSIX::debug and $Net::SSH::Any::OS::POSIX::debug & 1024 and _debug('io3 mloop, cin: ' . ($cin || 0) . ', cout: ' . ($cout || 0) . ', cerr: ' . ($cerr || 0)) 0 0 0
Condition0%0/9
$Net::SSH::Any::OS::POSIX::debug and $Net::SSH::Any::OS::POSIX::debug & 1024
!ll&&!rl&&r
000
$cin || 0
l!l
00
$cout || 0
l!l
00
$cerr || 0
l!l
00
MC/DC0%0/2
$Net::SSH::Any::OS::POSIX::debug and $Net::SSH::Any::OS::POSIX::debug & 1024
$Net::SSH::Any::OS::POSIX::debug $Net::SSH::Any::OS::POSIX::debug & 1024
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::SSH::Any::OS::POSIX::debugB= $Net::SSH::Any::OS::POSIX::debug & 1024
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
114 ", cout: " . ($cout || 0) . ", cerr: " . ($cerr || 0);
115 0 my ($rv, $wv);
116  
117 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
118 0 $rv = '';
119 0 ▶ if ($cout) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cout) 0 0 0
120 0 $fnoout = fileno $out;
121 0 vec($rv, $fnoout, 1) = 1;
122 }
123 0 ▶ if ($cerr) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cerr) 0 0 0
124 0 $fnoerr = fileno $err;
125 0 vec($rv, $fnoerr, 1) = 1
126 }
127 }
128  
129 0 ▶ if ($cin) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cin) 0 0 0
130 0 $fnoin = fileno $in;
131 0 $wv = '';
132 0 vec($wv, $fnoin, 1) = 1;
133 }
134  
135 0 my $recalc_vecs;
136 0 ▶ FAST: until ($recalc_vecs) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($recalc_vecs) 0 0 0
137 0 ▶ $debug and $debug & 1024 and
Branch: 1 branch
BranchTrueFalseTotal
$Net::SSH::Any::OS::POSIX::debug and $Net::SSH::Any::OS::POSIX::debug & 1024 and _debug('io3 fast, cin: ' . ($cin || 0) . ', cout: ' . ($cout || 0) . ', cerr: ' . ($cerr || 0)) 0 0 0
Condition0%0/9
$Net::SSH::Any::OS::POSIX::debug and $Net::SSH::Any::OS::POSIX::debug & 1024
!ll&&!rl&&r
000
$cin || 0
l!l
00
$cout || 0
l!l
00
$cerr || 0
l!l
00
MC/DC0%0/2
$Net::SSH::Any::OS::POSIX::debug and $Net::SSH::Any::OS::POSIX::debug & 1024
$Net::SSH::Any::OS::POSIX::debug $Net::SSH::Any::OS::POSIX::debug & 1024
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::SSH::Any::OS::POSIX::debugB= $Net::SSH::Any::OS::POSIX::debug & 1024
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
138 _debug "io3 fast, cin: " . ($cin || 0) .
139 ", cout: " . ($cout || 0) . ", cerr: " . ($cerr || 0);
140 0 my ($rv1, $wv1) = ($rv, $wv);
141 0 my $n = select ($rv1, $wv1, undef, $timeout);
142 0 ▶ if ($n > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($n > 0) { } 0 0 0
143 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
144 0 my $offset = length $bout;
145 0 my $read = sysread($out, $bout, 20480, $offset);
146 0 ▶ $debug and $debug & 1024 and _debug "stdout, bytes read: ", $read, " at offset $offset";
Branch: 1 branch
BranchTrueFalseTotal
$Net::SSH::Any::OS::POSIX::debug and $Net::SSH::Any::OS::POSIX::debug & 1024 and _debug("stdout, bytes read: ", $read, " at offset $offset") 0 0 0
Condition0%0/3
$Net::SSH::Any::OS::POSIX::debug and $Net::SSH::Any::OS::POSIX::debug & 1024
!ll&&!rl&&r
000
MC/DC0%0/2
$Net::SSH::Any::OS::POSIX::debug and $Net::SSH::Any::OS::POSIX::debug & 1024
$Net::SSH::Any::OS::POSIX::debug $Net::SSH::Any::OS::POSIX::debug & 1024
Truth table0%0/3
A and B
A= $Net::SSH::Any::OS::POSIX::debugB= $Net::SSH::Any::OS::POSIX::debug & 1024
ABresult
0X0
100
111
147 0 ▶ unless ($read) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($read) 0 0 0
148 0 ▶ if (defined $read or not grep $! == $_, @retriable) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $read or not grep(($! == $_), @retriable)) 0 0 0
Condition0%0/3
defined $read or not grep(($! == $_), @retriable)
l!l&&r!l&&!r
000
MC/DC0%0/2
defined $read or not grep(($! == $_), @retriable)
defined $read not grep(($! == $_), @retriable)
Truth table0%0/3
A or not(B)
A= defined $readB= not grep(($! == $_), @retriable)
ABresult
1X1
011
000
149 0 close $out;
150 0 undef $cout;
151 0 $recalc_vecs = 1;
152 }
153 }
154 }
155 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
156 0 my $read = sysread($err, $berr, 20480, length($berr));
157 0 ▶ $debug and $debug & 1024 and _debug "stderr, bytes read: ", $read;
Branch: 1 branch
BranchTrueFalseTotal
$Net::SSH::Any::OS::POSIX::debug and $Net::SSH::Any::OS::POSIX::debug & 1024 and _debug("stderr, bytes read: ", $read) 0 0 0
Condition0%0/3
$Net::SSH::Any::OS::POSIX::debug and $Net::SSH::Any::OS::POSIX::debug & 1024
!ll&&!rl&&r
000
MC/DC0%0/2
$Net::SSH::Any::OS::POSIX::debug and $Net::SSH::Any::OS::POSIX::debug & 1024
$Net::SSH::Any::OS::POSIX::debug $Net::SSH::Any::OS::POSIX::debug & 1024
Truth table0%0/3
A and B
A= $Net::SSH::Any::OS::POSIX::debugB= $Net::SSH::Any::OS::POSIX::debug & 1024
ABresult
0X0
100
111
158 0 ▶ unless ($read) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($read) 0 0 0
159 0 ▶ if (defined $read or not grep $! == $_, @retriable) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $read or not grep(($! == $_), @retriable)) 0 0 0
Condition0%0/3
defined $read or not grep(($! == $_), @retriable)
l!l&&r!l&&!r
000
MC/DC0%0/2
defined $read or not grep(($! == $_), @retriable)
defined $read not grep(($! == $_), @retriable)
Truth table0%0/3
A or not(B)
A= defined $readB= not grep(($! == $_), @retriable)
ABresult
1X1
011
000
160 0 close $err;
161 0 undef $cerr;
162 0 $recalc_vecs = 1;
163 }
164 }
165 }
166 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
167 0 my $written = syswrite($in, $data->[0], 20480);
168 0 ▶ $debug and $debug & 64 and _debug "stdin, bytes written: ", $written;
Branch: 1 branch
BranchTrueFalseTotal
$Net::SSH::Any::OS::POSIX::debug and $Net::SSH::Any::OS::POSIX::debug & 64 and _debug("stdin, bytes written: ", $written) 0 0 0
Condition0%0/3
$Net::SSH::Any::OS::POSIX::debug and $Net::SSH::Any::OS::POSIX::debug & 64
!ll&&!rl&&r
000
MC/DC0%0/2
$Net::SSH::Any::OS::POSIX::debug and $Net::SSH::Any::OS::POSIX::debug & 64
$Net::SSH::Any::OS::POSIX::debug $Net::SSH::Any::OS::POSIX::debug & 64
Truth table0%0/3
A and B
A= $Net::SSH::Any::OS::POSIX::debugB= $Net::SSH::Any::OS::POSIX::debug & 64
ABresult
0X0
100
111
169 0 ▶ if ($written) {
Branch: 2 branches
BranchTrueFalseTotal
if ($written) { } 0 0 0
elsif (grep(($! == $_), @retriable)) { } 0 0 0
170 0 substr($data->[0], 0, $written, '');
171 0 ▶ next FAST if length $data->[0];
Branch: 1 branch
BranchTrueFalseTotal
if length $data->[0] 0 0 0
172 0 shift @$data;
173 0 ▶ next FAST if @$data;
Branch: 1 branch
BranchTrueFalseTotal
if @$data 0 0 0
174 # fallback when stdin queue is exhausted
175 }
176 elsif (grep $! == $_, @retriable) {
177 0 next FAST;
178 }
179 0 close $in;
180 0 undef $cin;
181 0 $recalc_vecs = 1;
182 }
183 }
184 else {
185 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
186 0 $any->_set_error(SSHA_TIMEOUT_ERROR, 'slave command timed out');
187 0 last MLOOP;
188 }
189 }
190 }
191 0 ▶ close $out if $cout;
Branch: 1 branch
BranchTrueFalseTotal
if $cout 0 0 0
192 0 ▶ close $err if $cerr;
Branch: 1 branch
BranchTrueFalseTotal
if $cerr 0 0 0
193 0 ▶ close $in if $cin;
Branch: 1 branch
BranchTrueFalseTotal
if $cin 0 0 0
194  
195 0 $any->_wait_ssh_proc($proc, $timeout);
196  
197 0 ▶ $debug and $debug & 1024 and _debug "leaving io3()";
Branch: 1 branch
BranchTrueFalseTotal
$Net::SSH::Any::OS::POSIX::debug and $Net::SSH::Any::OS::POSIX::debug & 1024 and _debug("leaving io3()") 0 0 0
Condition0%0/3
$Net::SSH::Any::OS::POSIX::debug and $Net::SSH::Any::OS::POSIX::debug & 1024
!ll&&!rl&&r
000
MC/DC0%0/2
$Net::SSH::Any::OS::POSIX::debug and $Net::SSH::Any::OS::POSIX::debug & 1024
$Net::SSH::Any::OS::POSIX::debug $Net::SSH::Any::OS::POSIX::debug & 1024
Truth table0%0/3
A and B
A= $Net::SSH::Any::OS::POSIX::debugB= $Net::SSH::Any::OS::POSIX::debug & 1024
ABresult
0X0
100
111
198 0 return ($bout, $berr);
199 }
200  
201 3 my @base_app_dirs = qw(/usr/lib /opt /usr/local);
202  
203 3 ▶sub find_cmd_by_app {
Subroutine find_cmd_by_app: called CC=8 SCAR=25.5
Pod undocumented
204 3 my ($any, $name, $app) = @_;
205 3 ▶ $app = $app->{POSIX} if ref $app;
Branch: 1 branch
BranchTrueFalseTotal
if ref $app 3 0 3
206 3 ▶ if (defined $app) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $app) 3 0 3
207 3 for my $app ($app, lc($app)) {
208 6 for my $base (@base_app_dirs) {
209 18 my $app_dir = "$base/$app";
210 18 ▶ if (-d $app_dir) {
Branch: 1 branch
BranchTrueFalseTotal
if (-d $app_dir) 0 18 18
211 0 for my $bin (qw(bin sbin libexec .)) {
212 0 my $path = $any->_os_validate_cmd("$app_dir/$bin/$name");
213 0 ▶ defined $path and return $path;
Branch: 1 branch
BranchTrueFalseTotal
defined $path and return $path 0 0 0
214 }
215 }
216 }
217 }
218 }
219 ()
220 3 }
221  
222 3 ▶sub find_user_dirs {
Subroutine find_user_dirs: called CC=5 SCAR=17.0
Pod undocumented
223 3 my $any = shift;
224 3 my $home = (getpwuid $<)[7];
225 3 my @dirs;
226 3 for my $name (@_) {
227 3 ▶ my $posix_name = (ref $name ? $name->{POSIX} : $name);
Branch: 1 branch
BranchTrueFalseTotal
ref $name ? : 3 0 3
228 3 ▶ if (defined $posix_name and
Branch: 1 branch
BranchTrueFalseTotal
if (defined $posix_name and defined $home) 3 0 3
Condition33%1/3
defined $posix_name and defined $home
!ll&&!rl&&r
003
MC/DC0%0/2
defined $posix_name and defined $home
defined $posix_name defined $home
Truth table33%1/3
A and B
A= defined $posix_nameB= defined $home
ABresult
0X0
100
111
229 defined $home) {
230 3 push @dirs, join('/', $home, $posix_name)
231 }
232 }
233 3 grep -d $_, @dirs;
234 }
235  
236 0 ▶sub set_file_inherit_flag {
Subroutine set_file_inherit_flag: not called CC=4 SCAR=30.0
Pod undocumented
237 0 my ($any, $file, $value) = @_;
238 0 ▶ $debug and $debug & 1024 and _debug "setting inherit flag for file $file (",fileno($file),") to $value";
Branch: 1 branch
BranchTrueFalseTotal
$Net::SSH::Any::OS::POSIX::debug and $Net::SSH::Any::OS::POSIX::debug & 1024 and _debug("setting inherit flag for file $file (", fileno $file, ") to $value") 0 0 0
Condition0%0/3
$Net::SSH::Any::OS::POSIX::debug and $Net::SSH::Any::OS::POSIX::debug & 1024
!ll&&!rl&&r
000
MC/DC0%0/2
$Net::SSH::Any::OS::POSIX::debug and $Net::SSH::Any::OS::POSIX::debug & 1024
$Net::SSH::Any::OS::POSIX::debug $Net::SSH::Any::OS::POSIX::debug & 1024
Truth table0%0/3
A and B
A= $Net::SSH::Any::OS::POSIX::debugB= $Net::SSH::Any::OS::POSIX::debug & 1024
ABresult
0X0
100
111
239 0 my $flags = fcntl($file, Fcntl::F_GETFL(), 0);
240 0 ▶ if ($value) {
Branch: 1 branch
BranchTrueFalseTotal
if ($value) { } 0 0 0
241 0 $flags &= ~Fcntl::FD_CLOEXEC();
242 }
243 else {
244 0 $flags |= Fcntl::FD_CLOEXEC();
245 }
246 0 fcntl($file, Fcntl::F_SETFL(), $flags);
247 0 1;
248 }
249  
250 3 my $unique_ix = 0;
251  
252 0 ▶sub create_secret_file {
Subroutine create_secret_file: not called CC=8 SCAR=42.8
Pod undocumented
253 0 my ($any, $name, $data) = @_;
254 0 my $home = (getpwuid $<)[7];
255 0 ▶ unless (defined $home) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $home) 0 0 0
256 0 $any->_os_set_error(SSHA_LOCAL_IO_ERROR, "Unable to determine user home directory: $!");
257 0 return;
258 }
259 0 my $base = File::Spec->rel2abs('.libssh-net-any-perl', $home);
260 0 ▶ mkdir $base, 0700 unless -d $base;
Branch: 1 branch
BranchTrueFalseTotal
unless -d $base 0 0 0
261 0 ▶ unless (do { local $!; -d $base }) {
Branch: 1 branch
BranchTrueFalseTotal
unless (do { local $!; -d $base }) 0 0 0
262 0 $any->_or_set_error(SSHA_LOCAL_IO_ERROR, "Unable to create private directory $base: $!");
263 0 return;
264 }
265  
266 0 $name = File::Spec->rel2abs($name, $base);
267  
268 0 my $ext = '';
269 0 ▶ if ($name =~ m|(.*)(\.[^/]*)$|) {
Branch: 1 branch
BranchTrueFalseTotal
if ($name =~ m[(.*)(\.[^/]*)$]) 0 0 0
270 0 $name = $1;
271 0 $ext = $2;
272 }
273  
274 0 while (1) {
275 0 my $final = join("-", $name, $$, $unique_ix++, int rand 1000).$ext;
276 0 ▶ if (sysopen(my $fh, $final,
Branch: 1 branch
BranchTrueFalseTotal
if (sysopen my $fh, $final, 194, 384) 0 0 0
277 Fcntl::O_RDWR()|Fcntl::O_CREAT()|Fcntl::O_EXCL(),
278 Fcntl::S_IRUSR()|Fcntl::S_IWUSR())) {
279 0 print {$fh} $data;
280 0 ▶ return $final if close $fh;
Branch: 1 branch
BranchTrueFalseTotal
if close $fh 0 0 0
281 0 $any->_or_set_error(SSHA_LOCAL_IO_ERROR, "Unable to write secret file $final: $!");
282 0 unlink $final;
283 0 return;
284 }
285 0 ▶ unless ($! == Errno::EEXIST()) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($! == 17) 0 0 0
286 0 $any->_or_set_error(SSHA_LOCAL_IO_ERROR, "Unable to create secret file $final: $!");
287 0 return;
288 }
289 }
290 }
291  
292 0 ▶sub unix_path { $_[1] }
Subroutine unix_path: not called CC=1 SCAR=6.9
Pod undocumented
293  
294 0 ▶sub version { 'POSIX' }
Subroutine version: not called CC=1 SCAR=6.9
Pod undocumented
295  
296 3 1;
↑ Summary Any/OS/_Base.pm »