| 1 | package Net::xFTP; | ||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||
| 3 | 2 | require 5.001; | |||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||
| 5 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||
| 7 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 8 | 2 | ▶ | use vars qw(@ISA $VERSION %CONSTANTS); | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 9 | 2 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 10 | 2 | ▶ | use Cwd 'cwd'; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 11 | #x use Fcntl ':mode'; | ||||||||||||||||||||||||||||||||||||||
| 12 | #x use File::Copy; | ||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||
| 14 | 2 | my @supported_mods = (qw(ftp sftp ssh2 local foreign openssh fsp ftpssl)); | |||||||||||||||||||||||||||||||||||||
| 15 | 2 | my %haveit; | |||||||||||||||||||||||||||||||||||||
| 16 | 2 | my $haveSFTPConstants = 0; | |||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||
| 18 | 2 | foreach my $imod (@supported_mods) | |||||||||||||||||||||||||||||||||||||
| 19 | { | ||||||||||||||||||||||||||||||||||||||
| 20 | 16 | $haveit{$imod} = 0; | |||||||||||||||||||||||||||||||||||||
| 21 | } | ||||||||||||||||||||||||||||||||||||||
| 22 | 2 | $haveit{'local'} = 1; #JWT:ADDED 20150123 - WE *ALWAYS* HAVE "local", SINCE NO EXTERNAL MODULE REQUIRED! | |||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||
| 24 | 2 | ▶ | my $bummer = ($^O =~ /Win/o) ? 1 : 0; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||
| 26 | 2 | ▶ | eval 'use Net::FTP; $haveit{"ftp"} = 1; 1'; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 27 | 2 | ▶ | eval 'use Net::SFTP; $haveit{"sftp"} = 1; 1'; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||||||||||
| 28 | 2 | ▶ | eval 'use Net::SFTP::Constants qw(SSH2_FXF_WRITE SSH2_FXF_CREAT SSH2_FXF_TRUNC); $haveSFTPConstants = 1; 1'; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||||||||||
| 29 | 2 | ▶ | eval 'use Net::SSH2; use Net::SSH2::SFTP; $haveit{"ssh2"} = 1; 1'; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||||||||||
| 30 | 2 | ▶ | eval 'use Net::SFTP::Foreign; $haveit{"foreign"} = 1; 1'; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||||||||||
| 31 | 2 | ▶ | eval 'use Net::OpenSSH; use IO::Pty; $haveit{"openssh"} = 1; 1'; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||||||||||
| 32 | 2 | ▶ | eval 'use Net::FSP; $haveit{"fsp"} = 1; 1'; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||||||||||
| 33 | 2 | ▶ | eval 'use Net::FTPSSL; $haveit{"ftpssl"} = 1; 1'; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||
| 35 | 2 | our $VERSION = '1.01'; | |||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||
| 37 | sub new | ||||||||||||||||||||||||||||||||||||||
| 38 | { | ||||||||||||||||||||||||||||||||||||||
| 39 | 0 | ▶ | my $class = shift; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
new: not called CC=67 SCAR=84.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 40 | 0 | $@ = ''; | |||||||||||||||||||||||||||||||||||||
| 41 | 0 | ▶ | my $pkg = shift || 0; | ||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
shift() || 0
MC/DC0%0/1
shift() || 0
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||
| 42 | 0 | $pkg =~ s/\s+//go; | |||||||||||||||||||||||||||||||||||||
| 43 | 0 | ▶ | $pkg = 'Net::' . $pkg unless (!$pkg || $pkg =~ /^Net/o); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not $pkg or $pkg =~ /^Net/o
MC/DC0%0/2
not $pkg or $pkg =~ /^Net/o
not $pkg
$pkg =~ /^Net/o
Truth table0%0/3
not(A) or B
A= not $pkgB= $pkg =~ /^Net/o
| |||||||||||||||||||||||||||||||||||||||
| 44 | 0 | ▶ | $pkg = 'Net::SFTP::Foreign' if ($pkg eq 'Net::Foreign'); #FIXUP. | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 45 | 0 | my $host = shift; | |||||||||||||||||||||||||||||||||||||
| 46 | 0 | my %args = @_; | |||||||||||||||||||||||||||||||||||||
| 47 | 0 | my $xftp; | |||||||||||||||||||||||||||||||||||||
| 48 | my %xftp_args; | ||||||||||||||||||||||||||||||||||||||
| 49 | 0 | my ($i, $j, $t); | |||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||
| 51 | 0 | foreach $i (keys %args) | |||||||||||||||||||||||||||||||||||||
| 52 | { | ||||||||||||||||||||||||||||||||||||||
| 53 | 0 | ▶ | if ($i =~ s/^xftp_//o) #EXTRACT OUT OUR SPECIAL ARGS ("xftp_*") | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 54 | { | ||||||||||||||||||||||||||||||||||||||
| 55 | 0 | $xftp_args{$i} = $args{"xftp_$i"}; | |||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||
| 57 | 0 | delete $args{"xftp_$i"}; | |||||||||||||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||||||||||||
| 60 | 0 | ▶ | if ($pkg =~ /Net::FTPSSL/) | ||||||||||||||||||||||||||||||||||||
|
Branch: 8 branches
| |||||||||||||||||||||||||||||||||||||||
| 61 | { | ||||||||||||||||||||||||||||||||||||||
| 62 | 0 | eval { require "Net/xFTP_FTPSSL.pm" }; | |||||||||||||||||||||||||||||||||||||
| 63 | 0 | ▶ | if ($@ || !$haveit{'ftpssl'}) | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$@ or not $haveit{"ftpssl"}
MC/DC0%0/2
$@ or not $haveit{"ftpssl"}
$@
not $haveit{"ftpssl"}
Truth table0%0/3
A or not(B)
A= $@B= not $haveit{"ftpssl"}
| |||||||||||||||||||||||||||||||||||||||
| 64 | { | ||||||||||||||||||||||||||||||||||||||
| 65 | 0 | warn "xFTP:Could not require Net::xFTP_FTPSSL.pm module($@)!"; | |||||||||||||||||||||||||||||||||||||
| 66 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||||||||||||
| 68 | 0 | foreach $i (keys %args) | |||||||||||||||||||||||||||||||||||||
| 69 | { | ||||||||||||||||||||||||||||||||||||||
| 70 | 0 | foreach $j (@supported_mods) | |||||||||||||||||||||||||||||||||||||
| 71 | { | ||||||||||||||||||||||||||||||||||||||
| 72 | 0 | ▶ | if ($i =~ /^${j}\_/) | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 73 | { | ||||||||||||||||||||||||||||||||||||||
| 74 | 0 | ▶ | if ($j eq 'ftpssl') | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 75 | { | ||||||||||||||||||||||||||||||||||||||
| 76 | 0 | ($t = $i) =~ s/^${j}_//; | |||||||||||||||||||||||||||||||||||||
| 77 | 0 | $args{$t} = $args{$i}; | |||||||||||||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||||||||||||
| 79 | 0 | delete $args{$i}; | |||||||||||||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||||||||||||
| 83 | 0 | $xftp = Net::xFTP::FTPSSL::new_ftpssl("${class}::FTPSSL", $pkg, $host, %args); | |||||||||||||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||||||||||||
| 85 | elsif ($pkg =~ /Net::FTP/) | ||||||||||||||||||||||||||||||||||||||
| 86 | { | ||||||||||||||||||||||||||||||||||||||
| 87 | 0 | eval { require "Net/xFTP_FTP.pm" }; | |||||||||||||||||||||||||||||||||||||
| 88 | 0 | ▶ | if ($@ || !$haveit{'ftp'}) | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$@ or not $haveit{"ftp"}
MC/DC0%0/2
$@ or not $haveit{"ftp"}
$@
not $haveit{"ftp"}
Truth table0%0/3
A or not(B)
A= $@B= not $haveit{"ftp"}
| |||||||||||||||||||||||||||||||||||||||
| 89 | { | ||||||||||||||||||||||||||||||||||||||
| 90 | 0 | warn "xFTP:Could not require Net::xFTP_FTP.pm module($@)!"; | |||||||||||||||||||||||||||||||||||||
| 91 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||||||||||||
| 93 | 0 | foreach $i (keys %args) | |||||||||||||||||||||||||||||||||||||
| 94 | { | ||||||||||||||||||||||||||||||||||||||
| 95 | 0 | foreach $j (@supported_mods) | |||||||||||||||||||||||||||||||||||||
| 96 | { | ||||||||||||||||||||||||||||||||||||||
| 97 | 0 | ▶ | if ($i =~ /^${j}\_/) | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 98 | { | ||||||||||||||||||||||||||||||||||||||
| 99 | 0 | ▶ | if ($j eq 'ftp') | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 100 | { | ||||||||||||||||||||||||||||||||||||||
| 101 | 0 | ($t = $i) =~ s/^${j}_//; | |||||||||||||||||||||||||||||||||||||
| 102 | 0 | $args{$t} = $args{$i}; | |||||||||||||||||||||||||||||||||||||
| 103 | } | ||||||||||||||||||||||||||||||||||||||
| 104 | 0 | delete $args{$i}; | |||||||||||||||||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||||||||||||
| 108 | 0 | $xftp = Net::xFTP::FTP::new_ftp("${class}::FTP", $pkg, $host, %args); | |||||||||||||||||||||||||||||||||||||
| 109 | } | ||||||||||||||||||||||||||||||||||||||
| 110 | elsif ($pkg =~ /Net::SFTP::Foreign/) | ||||||||||||||||||||||||||||||||||||||
| 111 | { | ||||||||||||||||||||||||||||||||||||||
| 112 | 0 | eval { require "Net/xFTP_Foreign.pm" }; | |||||||||||||||||||||||||||||||||||||
| 113 | 0 | ▶ | if ($@ || !$haveit{'foreign'}) | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$@ or not $haveit{"foreign"}
MC/DC0%0/2
$@ or not $haveit{"foreign"}
$@
not $haveit{"foreign"}
Truth table0%0/3
A or not(B)
A= $@B= not $haveit{"foreign"}
| |||||||||||||||||||||||||||||||||||||||
| 114 | { | ||||||||||||||||||||||||||||||||||||||
| 115 | 0 | warn "xFTP:Could not require Net::xFTP_Foreign.pm module($@)!"; | |||||||||||||||||||||||||||||||||||||
| 116 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||
| 117 | } | ||||||||||||||||||||||||||||||||||||||
| 118 | 0 | foreach $i (keys %args) | |||||||||||||||||||||||||||||||||||||
| 119 | { | ||||||||||||||||||||||||||||||||||||||
| 120 | 0 | foreach $j (@supported_mods) | |||||||||||||||||||||||||||||||||||||
| 121 | { | ||||||||||||||||||||||||||||||||||||||
| 122 | 0 | ▶ | if ($i =~ /^${j}\_/) | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 123 | { | ||||||||||||||||||||||||||||||||||||||
| 124 | 0 | ▶ | if ($j eq 'foreign') | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 125 | { | ||||||||||||||||||||||||||||||||||||||
| 126 | 0 | ($t = $i) =~ s/^${j}_//; | |||||||||||||||||||||||||||||||||||||
| 127 | 0 | $args{$t} = $args{$i}; | |||||||||||||||||||||||||||||||||||||
| 128 | } | ||||||||||||||||||||||||||||||||||||||
| 129 | 0 | delete $args{$i}; | |||||||||||||||||||||||||||||||||||||
| 130 | } | ||||||||||||||||||||||||||||||||||||||
| 131 | } | ||||||||||||||||||||||||||||||||||||||
| 132 | } | ||||||||||||||||||||||||||||||||||||||
| 133 | 0 | $xftp = Net::xFTP::Foreign::new_foreign("${class}::Foreign", $pkg, $host, %args); | |||||||||||||||||||||||||||||||||||||
| 134 | } | ||||||||||||||||||||||||||||||||||||||
| 135 | elsif ($pkg =~ /Net::SSH2/) | ||||||||||||||||||||||||||||||||||||||
| 136 | { | ||||||||||||||||||||||||||||||||||||||
| 137 | 0 | eval { require "Net/xFTP_SSH2.pm" }; | |||||||||||||||||||||||||||||||||||||
| 138 | 0 | ▶ | if ($@ || !$haveit{'ssh2'}) | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$@ or not $haveit{"ssh2"}
MC/DC0%0/2
$@ or not $haveit{"ssh2"}
$@
not $haveit{"ssh2"}
Truth table0%0/3
A or not(B)
A= $@B= not $haveit{"ssh2"}
| |||||||||||||||||||||||||||||||||||||||
| 139 | { | ||||||||||||||||||||||||||||||||||||||
| 140 | 0 | warn "xFTP:Could not require Net::xFTP_SSH2.pm module($@)!"; | |||||||||||||||||||||||||||||||||||||
| 141 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||
| 142 | } | ||||||||||||||||||||||||||||||||||||||
| 143 | 0 | foreach $i (keys %args) | |||||||||||||||||||||||||||||||||||||
| 144 | { | ||||||||||||||||||||||||||||||||||||||
| 145 | 0 | foreach $j (@supported_mods) | |||||||||||||||||||||||||||||||||||||
| 146 | { | ||||||||||||||||||||||||||||||||||||||
| 147 | 0 | ▶ | if ($i =~ /^${j}\_/) | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 148 | { | ||||||||||||||||||||||||||||||||||||||
| 149 | 0 | ▶ | if ($j eq 'ssh2') | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 150 | { | ||||||||||||||||||||||||||||||||||||||
| 151 | 0 | ($t = $i) =~ s/^${j}_//; | |||||||||||||||||||||||||||||||||||||
| 152 | 0 | $args{$t} = $args{$i}; | |||||||||||||||||||||||||||||||||||||
| 153 | } | ||||||||||||||||||||||||||||||||||||||
| 154 | 0 | delete $args{$i}; | |||||||||||||||||||||||||||||||||||||
| 155 | } | ||||||||||||||||||||||||||||||||||||||
| 156 | } | ||||||||||||||||||||||||||||||||||||||
| 157 | } | ||||||||||||||||||||||||||||||||||||||
| 158 | 0 | $xftp = Net::xFTP::SSH2::new_ssh2("${class}::SSH2", $pkg, $host, %args); | |||||||||||||||||||||||||||||||||||||
| 159 | } | ||||||||||||||||||||||||||||||||||||||
| 160 | elsif ($pkg =~ /Net::SFTP/) | ||||||||||||||||||||||||||||||||||||||
| 161 | { | ||||||||||||||||||||||||||||||||||||||
| 162 | 0 | eval { require "Net/xFTP_SFTP.pm" }; | |||||||||||||||||||||||||||||||||||||
| 163 | 0 | ▶ | if ($@ || !$haveit{'sftp'}) | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$@ or not $haveit{"sftp"}
MC/DC0%0/2
$@ or not $haveit{"sftp"}
$@
not $haveit{"sftp"}
Truth table0%0/3
A or not(B)
A= $@B= not $haveit{"sftp"}
| |||||||||||||||||||||||||||||||||||||||
| 164 | { | ||||||||||||||||||||||||||||||||||||||
| 165 | 0 | warn "xFTP:Could not require Net::xFTP_SFTP.pm module($@)!"; | |||||||||||||||||||||||||||||||||||||
| 166 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||
| 167 | } | ||||||||||||||||||||||||||||||||||||||
| 168 | 0 | foreach $i (keys %args) | |||||||||||||||||||||||||||||||||||||
| 169 | { | ||||||||||||||||||||||||||||||||||||||
| 170 | 0 | foreach $j (@supported_mods) | |||||||||||||||||||||||||||||||||||||
| 171 | { | ||||||||||||||||||||||||||||||||||||||
| 172 | 0 | ▶ | if ($i =~ /^${j}\_/) | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 173 | { | ||||||||||||||||||||||||||||||||||||||
| 174 | 0 | ▶ | if ($j eq 'sftp') | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 175 | { | ||||||||||||||||||||||||||||||||||||||
| 176 | 0 | ($t = $i) =~ s/^${j}_//; | |||||||||||||||||||||||||||||||||||||
| 177 | 0 | $args{$t} = $args{$i}; | |||||||||||||||||||||||||||||||||||||
| 178 | } | ||||||||||||||||||||||||||||||||||||||
| 179 | 0 | delete $args{$i}; | |||||||||||||||||||||||||||||||||||||
| 180 | } | ||||||||||||||||||||||||||||||||||||||
| 181 | } | ||||||||||||||||||||||||||||||||||||||
| 182 | } | ||||||||||||||||||||||||||||||||||||||
| 183 | 0 | $xftp = Net::xFTP::SFTP::new_sftp("${class}::SFTP", $pkg, $host, %args); | |||||||||||||||||||||||||||||||||||||
| 184 | 0 | ▶ | $xftp->{haveSFTPConstants} = $haveSFTPConstants if ($xftp); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 185 | } | ||||||||||||||||||||||||||||||||||||||
| 186 | elsif ($pkg =~ /Net::FSP/) | ||||||||||||||||||||||||||||||||||||||
| 187 | { | ||||||||||||||||||||||||||||||||||||||
| 188 | 0 | eval { require "Net/xFTP_FSP.pm" }; | |||||||||||||||||||||||||||||||||||||
| 189 | 0 | ▶ | if ($@ || !$haveit{'fsp'}) | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$@ or not $haveit{"fsp"}
MC/DC0%0/2
$@ or not $haveit{"fsp"}
$@
not $haveit{"fsp"}
Truth table0%0/3
A or not(B)
A= $@B= not $haveit{"fsp"}
| |||||||||||||||||||||||||||||||||||||||
| 190 | { | ||||||||||||||||||||||||||||||||||||||
| 191 | 0 | warn "xFTP:Could not require Net::xFTP_FSP.pm module($@)!"; | |||||||||||||||||||||||||||||||||||||
| 192 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||
| 193 | } | ||||||||||||||||||||||||||||||||||||||
| 194 | 0 | foreach $i (keys %args) | |||||||||||||||||||||||||||||||||||||
| 195 | { | ||||||||||||||||||||||||||||||||||||||
| 196 | 0 | foreach $j (@supported_mods) | |||||||||||||||||||||||||||||||||||||
| 197 | { | ||||||||||||||||||||||||||||||||||||||
| 198 | 0 | ▶ | if ($i =~ /^${j}\_/) | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 199 | { | ||||||||||||||||||||||||||||||||||||||
| 200 | 0 | ▶ | if ($j eq 'fsp') | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 201 | { | ||||||||||||||||||||||||||||||||||||||
| 202 | 0 | ($t = $i) =~ s/^${j}_//; | |||||||||||||||||||||||||||||||||||||
| 203 | 0 | $args{$t} = $args{$i}; | |||||||||||||||||||||||||||||||||||||
| 204 | } | ||||||||||||||||||||||||||||||||||||||
| 205 | 0 | delete $args{$i}; | |||||||||||||||||||||||||||||||||||||
| 206 | } | ||||||||||||||||||||||||||||||||||||||
| 207 | } | ||||||||||||||||||||||||||||||||||||||
| 208 | } | ||||||||||||||||||||||||||||||||||||||
| 209 | 0 | $xftp = Net::xFTP::FSP::new_fsp("${class}::FSP", $pkg, $host, %args); | |||||||||||||||||||||||||||||||||||||
| 210 | } | ||||||||||||||||||||||||||||||||||||||
| 211 | elsif ($pkg =~ /Net::OpenSSH/) | ||||||||||||||||||||||||||||||||||||||
| 212 | { | ||||||||||||||||||||||||||||||||||||||
| 213 | 0 | eval { require "Net/xFTP_OpenSSH.pm" }; | |||||||||||||||||||||||||||||||||||||
| 214 | 0 | ▶ | if ($@ || !$haveit{'openssh'}) | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$@ or not $haveit{"openssh"}
MC/DC0%0/2
$@ or not $haveit{"openssh"}
$@
not $haveit{"openssh"}
Truth table0%0/3
A or not(B)
A= $@B= not $haveit{"openssh"}
| |||||||||||||||||||||||||||||||||||||||
| 215 | { | ||||||||||||||||||||||||||||||||||||||
| 216 | 0 | warn "xFTP:Could not require Net::xFTP_OpenSSH.pm module($@)!"; | |||||||||||||||||||||||||||||||||||||
| 217 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||
| 218 | } | ||||||||||||||||||||||||||||||||||||||
| 219 | 0 | foreach $i (keys %args) | |||||||||||||||||||||||||||||||||||||
| 220 | { | ||||||||||||||||||||||||||||||||||||||
| 221 | 0 | foreach $j (@supported_mods) | |||||||||||||||||||||||||||||||||||||
| 222 | { | ||||||||||||||||||||||||||||||||||||||
| 223 | 0 | ▶ | if ($i =~ /^${j}\_/) | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 224 | { | ||||||||||||||||||||||||||||||||||||||
| 225 | 0 | ▶ | if ($j eq 'openssh') | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 226 | { | ||||||||||||||||||||||||||||||||||||||
| 227 | 0 | ($t = $i) =~ s/^${j}_//; | |||||||||||||||||||||||||||||||||||||
| 228 | 0 | $args{$t} = $args{$i}; | |||||||||||||||||||||||||||||||||||||
| 229 | } | ||||||||||||||||||||||||||||||||||||||
| 230 | 0 | delete $args{$i}; | |||||||||||||||||||||||||||||||||||||
| 231 | } | ||||||||||||||||||||||||||||||||||||||
| 232 | } | ||||||||||||||||||||||||||||||||||||||
| 233 | } | ||||||||||||||||||||||||||||||||||||||
| 234 | 0 | $xftp = Net::xFTP::OpenSSH::new_openssh("${class}::OpenSSH", $pkg, $host, %args); | |||||||||||||||||||||||||||||||||||||
| 235 | } | ||||||||||||||||||||||||||||||||||||||
| 236 | ▶ | elsif (!$pkg || $pkg =~ /local/i) | |||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
not $pkg or $pkg =~ /local/i
MC/DC0%0/2
not $pkg or $pkg =~ /local/i
not $pkg
$pkg =~ /local/i
Truth table0%0/3
not(A) or B
A= not $pkgB= $pkg =~ /local/i
| |||||||||||||||||||||||||||||||||||||||
| 237 | { | ||||||||||||||||||||||||||||||||||||||
| 238 | 0 | eval { require "Net/xFTP_LOCAL.pm" }; | |||||||||||||||||||||||||||||||||||||
| 239 | 0 | ▶ | if ($@) | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 240 | { | ||||||||||||||||||||||||||||||||||||||
| 241 | 0 | warn "xFTP:Could not require Net::xFTP_LOCAL.pm module($@)!"; | |||||||||||||||||||||||||||||||||||||
| 242 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||
| 243 | } | ||||||||||||||||||||||||||||||||||||||
| 244 | 0 | foreach $i (keys %args) | |||||||||||||||||||||||||||||||||||||
| 245 | { | ||||||||||||||||||||||||||||||||||||||
| 246 | 0 | foreach $j (@supported_mods) | |||||||||||||||||||||||||||||||||||||
| 247 | { | ||||||||||||||||||||||||||||||||||||||
| 248 | 0 | ▶ | if ($i =~ /^${j}\_/) | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 249 | { | ||||||||||||||||||||||||||||||||||||||
| 250 | 0 | ▶ | if ($j eq 'local') | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 251 | { | ||||||||||||||||||||||||||||||||||||||
| 252 | 0 | ($t = $i) =~ s/^${j}_//; | |||||||||||||||||||||||||||||||||||||
| 253 | 0 | $args{$t} = $args{$i}; | |||||||||||||||||||||||||||||||||||||
| 254 | } | ||||||||||||||||||||||||||||||||||||||
| 255 | 0 | delete $args{$i}; | |||||||||||||||||||||||||||||||||||||
| 256 | } | ||||||||||||||||||||||||||||||||||||||
| 257 | } | ||||||||||||||||||||||||||||||||||||||
| 258 | } | ||||||||||||||||||||||||||||||||||||||
| 259 | 0 | $xftp = Net::xFTP::LOCAL::new_local("${class}::LOCAL", $pkg, $host, %args); | |||||||||||||||||||||||||||||||||||||
| 260 | } | ||||||||||||||||||||||||||||||||||||||
| 261 | else | ||||||||||||||||||||||||||||||||||||||
| 262 | { | ||||||||||||||||||||||||||||||||||||||
| 263 | 0 | $@ = "No such package \"$pkg\"!"; | |||||||||||||||||||||||||||||||||||||
| 264 | 0 | warn "xFTP:$@!"; | |||||||||||||||||||||||||||||||||||||
| 265 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||
| 266 | } | ||||||||||||||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||||||||||||
| 268 | 0 | ▶ | if ($xftp) | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 269 | { | ||||||||||||||||||||||||||||||||||||||
| 270 | 0 | ▶ | $xftp->{pkg} = ($pkg =~ /local/io) ? $pkg : ''; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 271 | 0 | ▶ | $xftp->{bummer} = ($^O =~ /Win/o) ? 1 : 0; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 272 | 0 | return $xftp; | |||||||||||||||||||||||||||||||||||||
| 273 | } | ||||||||||||||||||||||||||||||||||||||
| 274 | else | ||||||||||||||||||||||||||||||||||||||
| 275 | { | ||||||||||||||||||||||||||||||||||||||
| 276 | 0 | @_ = @_ . " Could not get new $pkg object (undef)!"; | |||||||||||||||||||||||||||||||||||||
| 277 | } | ||||||||||||||||||||||||||||||||||||||
| 278 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||
| 279 | } | ||||||||||||||||||||||||||||||||||||||
| 280 | |||||||||||||||||||||||||||||||||||||||
| 281 | sub haveFTP #DEPRECIATED, USE haveModule($module) INSTEAD! | ||||||||||||||||||||||||||||||||||||||
| 282 | { | ||||||||||||||||||||||||||||||||||||||
| 283 | 0 | ▶ | return $haveit{'ftp'}; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
haveFTP: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 284 | } | ||||||||||||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||||||||||||
| 286 | sub haveSFTP | ||||||||||||||||||||||||||||||||||||||
| 287 | { | ||||||||||||||||||||||||||||||||||||||
| 288 | 0 | ▶ | return $haveit{'sftp'}; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
haveSFTP: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 289 | } | ||||||||||||||||||||||||||||||||||||||
| 290 | |||||||||||||||||||||||||||||||||||||||
| 291 | sub haveModule | ||||||||||||||||||||||||||||||||||||||
| 292 | { | ||||||||||||||||||||||||||||||||||||||
| 293 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
haveModule: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 294 | 0 | my $modul = shift; | |||||||||||||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||||||||||||
| 296 | 0 | my $modHash = &haveModules(); | |||||||||||||||||||||||||||||||||||||
| 297 | 0 | ▶ | if ($modul =~ /^Net\:\:/) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 298 | 0 | ▶ | return (defined $modHash->{$modul}) ? $modHash->{$modul} : 0; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 299 | } | ||||||||||||||||||||||||||||||||||||||
| 300 | 0 | $modul =~ tr/A-Z/a-z/; | |||||||||||||||||||||||||||||||||||||
| 301 | 0 | ▶ | return (defined $haveit{$modul}) ? $haveit{$modul} : 0; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 302 | } | ||||||||||||||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||||||||||||
| 304 | sub haveModules | ||||||||||||||||||||||||||||||||||||||
| 305 | { | ||||||||||||||||||||||||||||||||||||||
| 306 | return { 'Net::FTP' => $haveit{'ftp'}, 'Net::SFTP' => $haveit{'sftp'}, | ||||||||||||||||||||||||||||||||||||||
| 307 | 'Net::SSH2' => $haveit{'ssh2'}, 'Net::SFTP::Foreign' => $haveit{'foreign'}, | ||||||||||||||||||||||||||||||||||||||
| 308 | 'Net::OpenSSH' => $haveit{'openssh'}, 'Net::FSP' => $haveit{'fsp'}, | ||||||||||||||||||||||||||||||||||||||
| 309 | 0 | ▶ | 'Net::FTPSSL' => $haveit{'ftpssl'}}; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
haveModules: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 310 | } | ||||||||||||||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||||||||||||
| 312 | sub protocol | ||||||||||||||||||||||||||||||||||||||
| 313 | { | ||||||||||||||||||||||||||||||||||||||
| 314 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
protocol: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||||||||||||
| 316 | 0 | return $self->{pkg}; | |||||||||||||||||||||||||||||||||||||
| 317 | } | ||||||||||||||||||||||||||||||||||||||
| 318 | |||||||||||||||||||||||||||||||||||||||
| 319 | 2 | 1 | |||||||||||||||||||||||||||||||||||||
| 320 | |||||||||||||||||||||||||||||||||||||||
| 321 | __END__ | ||||||||||||||||||||||||||||||||||||||