| 1 | package App::BCSSH::Message; | ||||||||||||||||||||
| 2 | 1 | ▶ | use strictures 1; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 3 | 1 | ▶ | use Safe::Isa; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 4 | |||||||||||||||||||||
| 5 | 1 | ▶ | use Exporter 'import'; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 6 | 1 | ▶ | use constant (); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 7 | |||||||||||||||||||||
| 8 | 1 | ▶ | BEGIN { | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 9 | 1 | my %constants = ( | |||||||||||||||||||
| 10 | BCSSH_QUERY => -40, | ||||||||||||||||||||
| 11 | BCSSH_SUCCESS => -41, | ||||||||||||||||||||
| 12 | BCSSH_FAILURE => -42, | ||||||||||||||||||||
| 13 | BCSSH_COMMAND => -43, | ||||||||||||||||||||
| 14 | |||||||||||||||||||||
| 15 | SSH_AGENTC_REQUEST_RSA_IDENTITIES => 1, | ||||||||||||||||||||
| 16 | SSH_AGENT_RSA_IDENTITIES_ANSWER => 2, | ||||||||||||||||||||
| 17 | SSH_AGENTC_RSA_CHALLENGE => 3, | ||||||||||||||||||||
| 18 | SSH_AGENT_RSA_RESPONSE => 4, | ||||||||||||||||||||
| 19 | SSH_AGENT_FAILURE => 5, | ||||||||||||||||||||
| 20 | SSH_AGENT_SUCCESS => 6, | ||||||||||||||||||||
| 21 | |||||||||||||||||||||
| 22 | SSH2_AGENTC_REQUEST_IDENTITIES => 11, | ||||||||||||||||||||
| 23 | SSH2_AGENT_IDENTITIES_ANSWER => 12, | ||||||||||||||||||||
| 24 | SSH2_AGENTC_SIGN_REQUEST => 13, | ||||||||||||||||||||
| 25 | SSH2_AGENT_SIGN_RESPONSE => 14, | ||||||||||||||||||||
| 26 | |||||||||||||||||||||
| 27 | SSH_COM_AGENT2_FAILURE => 102, | ||||||||||||||||||||
| 28 | ); | ||||||||||||||||||||
| 29 | 1 | our %EXPORT_TAGS = (message_types => [keys %constants]); | |||||||||||||||||||
| 30 | 1 | our @EXPORT_OK = (qw(make_response send_message), keys %constants); | |||||||||||||||||||
| 31 | 1 | our @EXPORT = @EXPORT_OK; | |||||||||||||||||||
| 32 | 1 | $EXPORT_TAGS{all} = [@EXPORT_OK]; | |||||||||||||||||||
| 33 | |||||||||||||||||||||
| 34 | 1 | constant->import(\%constants); | |||||||||||||||||||
| 35 | } | ||||||||||||||||||||
| 36 | |||||||||||||||||||||
| 37 | 0 | ▶ | sub make_response { | ||||||||||||||||||
|
Subroutine
make_response: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||
| 38 | 0 | my $type = shift; | |||||||||||||||||||
| 39 | 0 | my $message = shift; | |||||||||||||||||||
| 40 | 0 | ▶ | if (!defined $message) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 41 | 0 | $message = ''; | |||||||||||||||||||
| 42 | } | ||||||||||||||||||||
| 43 | 0 | my $full_message = pack('c', $type) . $message; | |||||||||||||||||||
| 44 | 0 | return pack('N', length $full_message) . $full_message; | |||||||||||||||||||
| 45 | } | ||||||||||||||||||||
| 46 | |||||||||||||||||||||
| 47 | 0 | ▶ | sub send_message { | ||||||||||||||||||
|
Subroutine
send_message: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||
| 48 | 0 | my $path = shift; | |||||||||||||||||||
| 49 | 0 | ▶ | my $agent = $path->$_can('syswrite') ? $path : do { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 50 | 0 | require IO::Socket::UNIX; | |||||||||||||||||||
| 51 | 0 | IO::Socket::UNIX->new( | |||||||||||||||||||
| 52 | Peer => $path, | ||||||||||||||||||||
| 53 | ); | ||||||||||||||||||||
| 54 | }; | ||||||||||||||||||||
| 55 | |||||||||||||||||||||
| 56 | 0 | $agent->syswrite(make_response(@_)); | |||||||||||||||||||
| 57 | 0 | my ($type, $message) = read_message($agent); | |||||||||||||||||||
| 58 | 0 | return ($type, $message); | |||||||||||||||||||
| 59 | } | ||||||||||||||||||||
| 60 | |||||||||||||||||||||
| 61 | 0 | ▶ | sub read_message { | ||||||||||||||||||
|
Subroutine
read_message: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||
| 62 | 0 | my $agent = shift; | |||||||||||||||||||
| 63 | 0 | $agent->sysread(my $buf, 4); | |||||||||||||||||||
| 64 | 0 | my $left = unpack 'N', $buf; | |||||||||||||||||||
| 65 | 0 | my $message = ''; | |||||||||||||||||||
| 66 | 0 | ▶ | while (my $read = $agent->sysread($buf, $left)) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 67 | 0 | $message .= $buf; | |||||||||||||||||||
| 68 | 0 | $left -= $read; | |||||||||||||||||||
| 69 | } | ||||||||||||||||||||
| 70 | 0 | ▶ | if ($left) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 71 | 0 | return; | |||||||||||||||||||
| 72 | } | ||||||||||||||||||||
| 73 | 0 | my $type = unpack 'c', substr($message, 0, 1, ''); | |||||||||||||||||||
| 74 | 0 | return ($type, $message); | |||||||||||||||||||
| 75 | } | ||||||||||||||||||||
| 76 | |||||||||||||||||||||
| 77 | 0 | ▶ | sub ping { | ||||||||||||||||||
|
Subroutine
ping: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||
| 78 | 0 | my $agent = shift; | |||||||||||||||||||
| 79 | 0 | my ($type) = send_message($agent, BCSSH_QUERY); | |||||||||||||||||||
| 80 | 0 | ▶ | return($type && $type == BCSSH_SUCCESS); | ||||||||||||||||||
|
Condition0%0/3
$type && $type == -41
MC/DC0%0/2
$type && $type == -41
$type
$type == -41
Truth table0%0/3
A && B
A= $typeB= $type == -41
| |||||||||||||||||||||
| 81 | } | ||||||||||||||||||||
| 82 | |||||||||||||||||||||
| 83 | 1 | 1; | |||||||||||||||||||
| 84 | __END__ | ||||||||||||||||||||