| 1 | package POE::Component::Server::NRPE; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 21 | $POE::Component::Server::NRPE::VERSION = '0.18'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | #ABSTRACT: A POE Component implementation of NRPE Daemon. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 21 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 21 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 21 | ▶ | use Socket; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 21 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 21 | ▶ | use Net::Netmask; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 21 | ▶ | use Net::SSLeay qw(die_now); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 21 | ▶ | use POE qw(Wheel::SocketFactory Wheel::ReadWrite Wheel::Run Filter::Stream Filter::Line); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 21 | ▶ | use POE::Component::SSLify qw(Server_SSLify); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 21 | ▶ | use POE::Component::Server::NRPE::Constants; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 19 | ▶ | sub spawn { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
spawn: called CC=12 SCAR=25.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 19 | my $package = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 19 | my %opts = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 19 | $opts{lc $_} = delete $opts{$_} for keys %opts; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 19 | my $options = delete $opts{options}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 19 | ▶ | my $access = delete $opts{access} || [ Net::Netmask->new('any') ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
delete $opts{'access'} || ['Net::Netmask'->new('any')]
MC/DC100%1/1
delete $opts{'access'} || ['Net::Netmask'->new('any')]
delete $opts{'access'}
Truth table100%2/2
A
A= delete $opts{'access'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 19 | ▶ | $access = [ ] unless ref $access eq 'ARRAY'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 19 | foreach my $acl ( @$access ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 19 | ▶ | next unless $acl->isa('Net::Netmask'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 19 | push @{ $opts{access} }, $acl; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 19 | ▶ | $opts{verstring} = __PACKAGE__ . ' v' . $POE::Component::Server::NRPE::VERSION unless $opts{verstring}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 19 | ▶ | $opts{version} = 2 unless $opts{version} and $opts{version} eq '1'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$opts{"version"} and $opts{"version"} eq 1
MC/DC50%1/2
$opts{"version"} and $opts{"version"} eq 1
$opts{"version"}
$opts{"version"} eq 1
Truth table66%2/3
A and B
A= $opts{"version"}B= $opts{"version"} eq 1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 19 | ▶ | $opts{usessl} = 1 unless defined $opts{usessl} and $opts{usessl} eq '0'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $opts{"usessl"} and $opts{"usessl"} eq 0
MC/DC100%2/2
defined $opts{"usessl"} and $opts{"usessl"} eq 0
defined $opts{"usessl"}
$opts{"usessl"} eq 0
Truth table100%3/3
A and B
A= defined $opts{"usessl"}B= $opts{"usessl"} eq 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 19 | my $self = bless \%opts, $package; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 19 | ▶ | $self->{session_id} = POE::Session->create( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | object_states => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | $self => { shutdown => '_shutdown', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | $self => [qw( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | _start | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | _accept_client | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | _accept_failed | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | _conn_input | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | _conn_error | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | _conn_flushed | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | _conn_alarm | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | _sig_child | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | _stdout | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | _wheel_close | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | _wheel_error | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | _wheel_alarm | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | _session_alarm | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | register_command | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | unregister_command | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | return_result | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | )], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | heap => $self, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | ( ref($options) eq 'HASH' ? ( options => $options ) : () ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | )->ID(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 19 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 13 | ▶ | sub shutdown { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
shutdown: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 13 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 13 | $poe_kernel->post( $self->{session_id}, 'shutdown' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 3 | ▶ | sub session_id { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
session_id: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 3 | return $_[0]->{session_id}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 18 | ▶ | sub getsockname { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getsockname: called CC=2 SCAR=7.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 18 | ▶ | return unless $_[0]->{listener}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 18 | return $_[0]->{listener}->getsockname(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 46 | ▶ | sub add_command { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_command: called CC=9 SCAR=26.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 46 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 46 | my %args; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 46 | ▶ | if ( ref $_[0] eq 'HASH' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 0 | %args = %{ $_[0] }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | elsif ( ref $_[0] eq 'ARRAY' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 0 | %args = @{ $_[0] }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 46 | %args = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 46 | $args{lc $_} = delete $args{$_} for keys %args; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 46 | ▶ | return unless $args{command} and $args{program}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$args{"command"} and $args{"program"}
MC/DC0%0/2
$args{"command"} and $args{"program"}
$args{"command"}
$args{"program"}
Truth table33%1/3
A and B
A= $args{"command"}B= $args{"program"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 46 | ▶ | return if defined $self->{commands}->{ $args{command} } or defined $self->{sess_cmds}->{ $args{command} }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $self->{"commands"}{$args{"command"}} or defined $self->{"sess_cmds"}{$args{"command"}}
MC/DC0%0/2
defined $self->{"commands"}{$args{"command"}} or defined $self->{"sess_cmds"}{$args{"command"}}
defined $self->{"commands"}{$args{"command"}}
defined $self->{"sess_cmds"}{$args{"command"}}
Truth table33%1/3
A or B
A= defined $self->{"commands"}{$args{"command"}}B= defined $self->{"sess_cmds"}{$args{"command"}}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 46 | ▶ | $args{args} = [ $args{args} ] if ref $args{args} ne 'ARRAY'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 46 | $self->{commands}->{ delete $args{command} } = \%args; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 46 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 0 | ▶ | sub del_command { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
del_command: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 0 | ▶ | my $command = shift || return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
shift() || (return)
MC/DC0%0/1
shift() || (return)
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 0 | ▶ | return unless defined $self->{commands}->{ $command }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 0 | delete $self->{commands}->{ $command }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 3 | ▶ | sub register_command { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
register_command: called CC=8 SCAR=27.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 3 | my ($kernel,$self,$sender) = @_[KERNEL,OBJECT,SENDER]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 3 | my $sender_id = $sender->ID(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 3 | my %args; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 3 | ▶ | if ( ref $_[ARG0] eq 'HASH' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 0 | %args = %{ $_[ARG0] }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | elsif ( ref $_[ARG0] eq 'ARRAY' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 0 | %args = @{ $_[ARG0] }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 3 | %args = @_[ARG0..$#_]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 3 | $args{lc $_} = delete $args{$_} for keys %args; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 3 | ▶ | unless ( $args{command} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 0 | warn "No 'command' argument supplied\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 3 | ▶ | unless ( $args{event} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 0 | warn "No 'event' argument supplied\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 3 | ▶ | if ( defined $self->{commands}->{ $args{command} } ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | warn "There is an internal command called '$args{command}' already\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 3 | ▶ | if ( defined $self->{sess_cmds}->{ $args{command} } ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 0 | warn "There is a session command called '$args{command}' already\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 3 | $self->{sess_cmds}->{ $args{command} } = { session => $sender_id, event => $args{event} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 3 | $kernel->refcount_increment( $sender_id, __PACKAGE__ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 3 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | ▶ | sub unregister_command { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
unregister_command: not called CC=7 SCAR=40.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 0 | my ($kernel,$self,$sender) = @_[KERNEL,OBJECT,SENDER]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | my $sender_id = $sender->ID(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | my %args; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 0 | ▶ | if ( ref $_[ARG0] eq 'HASH' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | %args = %{ $_[ARG0] }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | elsif ( ref $_[ARG0] eq 'ARRAY' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 0 | %args = @{ $_[ARG0] }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 0 | %args = @_[ARG0..$#_]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | $args{lc $_} = delete $args{$_} for keys %args; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | ▶ | unless ( $args{command} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | warn "No 'command' argument supplied\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 0 | ▶ | unless ( defined $self->{sess_cmds}->{ $args{command} } ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 0 | warn "There isn't a session command called '$args{command}'\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 0 | ▶ | unless ( $self->{sess_cmds}->{ $args{command} }->{session} eq $sender_id ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 0 | warn "Session '$sender_id' isn't the registered owner of '$args{command}'\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 0 | delete $self->{sess_cmds}->{ $args{command} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 0 | $kernel->refcount_decrement( $sender_id, __PACKAGE__ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 2 | ▶ | sub return_result { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
return_result: called CC=10 SCAR=29.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 2 | my ($kernel,$self,$sender,$id,$status,$output) = @_[KERNEL,OBJECT,SENDER,ARG0..ARG2]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 2 | my $sender_id = $sender->ID(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 2 | ▶ | return unless $id and defined $self->{clients}->{ $id }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$id and defined $self->{"clients"}{$id}
MC/DC0%0/2
$id and defined $self->{"clients"}{$id}
$id
defined $self->{"clients"}{$id}
Truth table33%1/3
A and B
A= $idB= defined $self->{"clients"}{$id}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 2 | $kernel->alarm_remove( $self->{clients}->{ $id }->{sess_alarm} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 2 | ▶ | return unless $self->{clients}->{ $id }->{session} and $self->{clients}->{ $id }->{session} eq $sender_id; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->{"clients"}{$id}{"session"} and $self->{"clients"}{$id}{"session"} eq $sender_id
MC/DC0%0/2
$self->{"clients"}{$id}{"session"} and $self->{"clients"}{$id}{"session"} eq $sender_id
$self->{"clients"}{$id}{"session"}
$self->{"clients"}{$id}{"session"} eq $sender_id
Truth table33%1/3
A and B
A= $self->{"clients"}{$id}{"session"}B= $self->{"clients"}{$id}{"session"} eq $sender_id
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 2 | ▶ | $output = 'NRPE: Unable to read output' unless $output; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 2 | ▶ | $status = NRPE_STATE_UNKNOWN unless $status or $status =~ /^\d+$/ or ( $status >= 0 or $status <= 3 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition22%2/9
$status or $status =~ /^\d+$/ or ($status >= 0 or $status <= 3)
$status or $status =~ /^\d+$/
$status >= 0 or $status <= 3
MC/DC0%0/4
$status or $status =~ /^\d+$/ or ($status >= 0 or $status <= 3)
$status
$status =~ /^\d+$/
$status >= 0
$status <= 3
Truth table20%1/5
A or B or C or D
A= $statusB= $status =~ /^\d+$/C= $status >= 0D= $status <= 3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 2 | $self->_send_response( $id, $status, $output ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 2 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 53 | ▶ | sub _conn_exists { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_conn_exists: called CC=3 SCAR=12.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 53 | my ($self,$wheel_id) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 53 | ▶ | return 0 unless $wheel_id and defined $self->{clients}->{ $wheel_id }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$wheel_id and defined $self->{"clients"}{$wheel_id}
MC/DC0%0/2
$wheel_id and defined $self->{"clients"}{$wheel_id}
$wheel_id
defined $self->{"clients"}{$wheel_id}
Truth table33%1/3
A and B
A= $wheel_idB= defined $self->{"clients"}{$wheel_id}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 53 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 0 | ▶ | sub _disconnect { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_disconnect: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 0 | my ($self,$wheel_id) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 0 | ▶ | return unless $wheel_id and defined $self->{clients}->{ $wheel_id }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$wheel_id and defined $self->{"clients"}{$wheel_id}
MC/DC0%0/2
$wheel_id and defined $self->{"clients"}{$wheel_id}
$wheel_id
defined $self->{"clients"}{$wheel_id}
Truth table0%0/3
A and B
A= $wheel_idB= defined $self->{"clients"}{$wheel_id}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 0 | delete $self->{clients}->{ $wheel_id }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 16 | ▶ | sub _send_response { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_send_response: called CC=4 SCAR=14.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 16 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 16 | my ($wheel_id,$status,$response) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 16 | ▶ | return unless $wheel_id and defined $self->{clients}->{ $wheel_id }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$wheel_id and defined $self->{"clients"}{$wheel_id}
MC/DC0%0/2
$wheel_id and defined $self->{"clients"}{$wheel_id}
$wheel_id
defined $self->{"clients"}{$wheel_id}
Truth table33%1/3
A and B
A= $wheel_idB= defined $self->{"clients"}{$wheel_id}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 16 | my $packet; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 16 | ▶ | if ( $self->{version} == 1 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 1 | $packet = pack "NNNNa[1024]", 2, 1, $status, length( $response ), $response; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 15 | $packet = _gen_packet_ver2( $status, $response ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 16 | $self->{clients}->{ $wheel_id }->{wheel}->put( $packet ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 16 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 19 | ▶ | sub _start { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_start: called CC=7 SCAR=19.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 19 | my ($kernel,$self,$sender) = @_[KERNEL,OBJECT,SENDER]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 19 | $self->{session_id} = $_[SESSION]->ID(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 19 | ▶ | if ( $self->{alias} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 0 | $kernel->alias_set( $self->{alias} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 19 | $kernel->refcount_increment( $self->{session_id} => __PACKAGE__ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 19 | $self->{filter} = POE::Filter::Stream->new(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | $self->{listener} = POE::Wheel::SocketFactory->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | ( defined $self->{address} ? ( BindAddress => $self->{address} ) : () ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 19 | ▶ | ( defined $self->{port} ? ( BindPort => $self->{port} ) : ( BindPort => 5666 ) ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | SuccessEvent => '_accept_client', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | FailureEvent => '_accept_failed', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | SocketDomain => AF_INET, # Sets the socket() domain | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | SocketType => SOCK_STREAM, # Sets the socket() type | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | SocketProtocol => 'tcp', # Sets the socket() protocol | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | Reuse => 'on', # Lets the port be reused | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 19 | ▶ | if ( $self->{version} eq '2' and $self->{usessl} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$self->{"version"} eq 2 and $self->{"usessl"}
MC/DC100%2/2
$self->{"version"} eq 2 and $self->{"usessl"}
$self->{"version"} eq 2
$self->{"usessl"}
Truth table100%3/3
A and B
A= $self->{"version"} eq 2B= $self->{"usessl"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 1 | eval { $self->{_ctx} = _SSLify_Initialise(); }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 1 | ▶ | if ($@) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 1 | warn "SSL initialisation failed: $@\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 1 | $self->{usessl} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 19 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 13 | ▶ | sub _shutdown { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_shutdown: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 13 | my ($kernel,$self) = @_[KERNEL,OBJECT]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 13 | delete $self->{listener}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 13 | delete $self->{clients}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 13 | delete $self->{wheels}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 13 | delete $self->{pids}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 13 | $kernel->refcount_decrement( $_, __PACKAGE__ ) for | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 3 | map { $self->{sess_cmds}->{$_}->{session} } keys %{ $self->{sess_cmds} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 13 | $kernel->alarm_remove_all(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 13 | $kernel->alias_remove( $_ ) for $kernel->alias_list(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 13 | ▶ | $kernel->refcount_decrement( $self->{session_id} => __PACKAGE__ ) unless $self->{alias}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 13 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 0 | ▶ | sub _accept_failed { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_accept_failed: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 0 | my ($kernel,$self,$operation,$errnum,$errstr,$wheel_id) = @_[KERNEL,OBJECT,ARG0..ARG3]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 0 | warn "Listener: $wheel_id generated $operation error $errnum: $errstr\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 0 | delete $self->{listener}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 0 | $kernel->yield( '_shutdown' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 43 | ▶ | sub _accept_client { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_accept_client: called CC=7 SCAR=20.7
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 43 | my ($kernel,$self,$socket,$peeraddr,$peerport) = @_[KERNEL,OBJECT,ARG0..ARG2]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 43 | my $sockaddr = inet_ntoa( ( unpack_sockaddr_in ( CORE::getsockname $socket ) )[1] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 43 | my $sockport = ( unpack_sockaddr_in ( CORE::getsockname $socket ) )[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 43 | $peeraddr = inet_ntoa( $peeraddr ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 43 | ▶ | return unless grep { $_->match( $peeraddr ) } @{ $self->{access} }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 42 | ▶ | if ( $self->{version} == 2 and $self->{usessl} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$self->{"version"} == 2 and $self->{"usessl"}
MC/DC0%0/2
$self->{"version"} == 2 and $self->{"usessl"}
$self->{"version"} == 2
$self->{"usessl"}
Truth table66%2/3
A and B
A= $self->{"version"} == 2B= $self->{"usessl"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 0 | eval { $socket = Server_SSLify( $socket, $self->{_ctx} ) }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 0 | ▶ | warn "Failed to SSLify the socket: $@\n" if $@; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | my $wheel = POE::Wheel::ReadWrite->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | Handle => $socket, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | Filter => $self->{filter}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 42 | InputEvent => '_conn_input', | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | ErrorEvent => '_conn_error', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | FlushedEvent => '_conn_flushed', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 42 | ▶ | return unless $wheel; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 42 | my $id = $wheel->ID(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 42 | $self->{clients}->{ $id } = | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | wheel => $wheel, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | peeraddr => $peeraddr, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | peerport => $peerport, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | sockaddr => $sockaddr, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | sockport => $sockport, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 42 | ▶ | $self->{clients}->{ $id }->{alarm} = $kernel->delay_set( '_conn_alarm', $self->{time_out} || 60, $id ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$self->{'time_out'} || 60
MC/DC100%1/1
$self->{'time_out'} || 60
$self->{'time_out'}
Truth table100%2/2
A
A= $self->{'time_out'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 42 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | 37 | ▶ | sub _conn_input { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_conn_input: called CC=18 SCAR=32.3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 37 | my ($kernel,$self,$input,$id) = @_[KERNEL,OBJECT,ARG0,ARG1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 37 | ▶ | return unless $self->_conn_exists( $id ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 37 | ▶ | return if $self->{clients}->{ $id }->{cmd_id}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | 37 | $kernel->alarm_remove( $self->{clients}->{ $id }->{alarm} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | 37 | my $data; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 37 | ▶ | if ( $self->{version} == 1 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 1 | my $length = length $input; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 1 | ▶ | if ( $length != 1040 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 0 | $self->_disconnect( $id ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 1 | my @args = unpack "NNNNa*", $input; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 1 | ▶ | if ( $args[0] ne '1' or $args[1] ne '1' or $args[2] !~ /^[0123456789]*$/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
$args[0] ne 1 or $args[1] ne 1 or not $args[2] =~ /^[0123456789]*$/
$args[0] ne 1 or $args[1] ne 1
MC/DC0%0/3
$args[0] ne 1 or $args[1] ne 1 or not $args[2] =~ /^[0123456789]*$/
$args[0] ne 1
$args[1] ne 1
not $args[2] =~ /^[0123456789]*$/
Truth table25%1/4
A or B or not(C)
A= $args[0] ne 1B= $args[1] ne 1C= not $args[2] =~ /^[0123456789]*$/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | 0 | $self->_disconnect( $id ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | 1 | $args[4] =~ s/\x00*$//g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | 1 | $data = $args[4]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 36 | my $length = length $input; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | 36 | ▶ | if ( $length != 1036 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | 0 | $self->_disconnect( $id ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | 36 | my @args = unpack "nnNnZ*", $input; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 36 | ▶ | if ( $args[0] ne '2' or $args[1] ne '1' or $args[3] !~ /^[0123456789]*$/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
$args[0] ne 2 or $args[1] ne 1 or not $args[3] =~ /^[0123456789]*$/
$args[0] ne 2 or $args[1] ne 1
MC/DC0%0/3
$args[0] ne 2 or $args[1] ne 1 or not $args[3] =~ /^[0123456789]*$/
$args[0] ne 2
$args[1] ne 1
not $args[3] =~ /^[0123456789]*$/
Truth table25%1/4
A or B or not(C)
A= $args[0] ne 2B= $args[1] ne 1C= not $args[3] =~ /^[0123456789]*$/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | 0 | $self->_disconnect( $id ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | 36 | $args[4] =~ s/\x00*$//g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | 36 | $data = $args[4]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | 37 | ▶ | unless ( $data ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | 0 | $self->_disconnect( $id ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | 37 | ▶ | if ( $data eq '_NRPE_CHECK' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | 2 | $self->_send_response( $id, NRPE_STATE_OK, $self->{verstring} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 2 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 35 | ▶ | if ( defined $self->{commands}->{ $data } ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | my $wheel = POE::Wheel::Run->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | Program => $self->{commands}->{ $data }->{program}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | ProgramArgs => $self->{commands}->{ $data }->{args}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | 31 | StdoutEvent => '_stdout', | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | CloseEvent => '_wheel_close', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | ErrorEvent => '_wheel_error', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | 25 | my $wheel_id = $wheel->ID(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | 25 | my $wheel_pid = $wheel->PID(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | 25 | $self->{clients}->{ $id }->{cmd_id} = $wheel_id; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | 25 | $self->{clients}->{ $id }->{cmd_pid} = $wheel_pid; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | 25 | $self->{wheels}->{ $wheel_id } = { wheel => $wheel, pid => $wheel_pid, client => $id }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | 25 | $self->{pids}->{ $wheel_pid } = { wheel_id => $wheel_id, client => $id }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | 25 | $kernel->sig_child( $wheel_pid, '_sig_child' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 25 | ▶ | $self->{pids}->{ $wheel_pid }->{alarm_id} = $kernel->delay_set( '_wheel_alarm', $self->{time_out} || 60, $wheel_pid, $wheel_id ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$self->{'time_out'} || 60
MC/DC100%1/1
$self->{'time_out'} || 60
$self->{'time_out'}
Truth table100%2/2
A
A= $self->{'time_out'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | 25 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | 4 | ▶ | if ( defined $self->{sess_cmds}->{ $data } ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | 3 | my $rec = $self->{sess_cmds}->{ $data }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | 3 | $kernel->post( $rec->{session}, $rec->{event}, $id, $rec->{context} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | 3 | ▶ | $self->{clients}->{ $id }->{sess_alarm} = $kernel->delay_set( '_session_alarm', $self->{time_out} || 60, $id, $rec->{session} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$self->{'time_out'} || 60
MC/DC100%1/1
$self->{'time_out'} || 60
$self->{'time_out'}
Truth table100%2/2
A
A= $self->{'time_out'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | 3 | $self->{clients}->{ $id }->{session} = $rec->{session}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | 3 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | 1 | $self->_send_response( $id, NRPE_STATE_CRITICAL, sprintf("NRPE: Command '%s' not defined", $data ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | 1 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | 18 | ▶ | sub _stdout { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_stdout: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | 18 | my ($self,$input,$wheel_id) = @_[OBJECT,ARG0,ARG1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | 18 | $self->{pids}->{ $self->{wheels}->{ $wheel_id }->{pid} }->{output} = $input; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 18 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | 10 | ▶ | sub _wheel_close { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_wheel_close: called CC=2 SCAR=8.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | 10 | my ($self,$wheel_id) = @_[OBJECT,ARG0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | 10 | my $wheel = delete $self->{wheels}->{ $wheel_id }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | 10 | ▶ | return unless $wheel; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | 0 | delete $self->{clients}->{ $wheel->{client} }->{cmd_id}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | 10 | ▶ | sub _wheel_error { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_wheel_error: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | 10 | my ($self,$wheel_id) = @_[OBJECT,ARG3]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | 10 | my $wheel = delete $self->{wheels}->{ $wheel_id }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | 10 | ▶ | return unless $wheel; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | 10 | delete $self->{clients}->{ $wheel->{client} }->{cmd_id}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | 10 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | 1 | ▶ | sub _wheel_alarm { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_wheel_alarm: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | 1 | my ($self,$wheel_pid,$wheel_id) = @_[OBJECT,ARG0,ARG1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | 1 | ▶ | $self->{pids}->{ $wheel_pid }->{timed_out} = sprintf("NRPE: Command timed out after %d seconds", $self->{time_out} || 60 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->{'time_out'} || 60
MC/DC0%0/1
$self->{'time_out'} || 60
$self->{'time_out'}
Truth table50%1/2
A
A= $self->{'time_out'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | 1 | $self->{wheels}->{ $wheel_id }->{wheel}->kill(9); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | 1 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | 1 | ▶ | sub _session_alarm { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_session_alarm: called CC=2 SCAR=7.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | 1 | my ($self,$id,$session_id) = @_[OBJECT,ARG0,ARG1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | 1 | ▶ | $self->_send_response( $id, NRPE_STATE_CRITICAL, sprintf("NRPE: Command timed out after %d seconds", $self->{time_out} || 60 ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->{'time_out'} || 60
MC/DC0%0/1
$self->{'time_out'} || 60
$self->{'time_out'}
Truth table50%1/2
A
A= $self->{'time_out'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | 1 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | 0 | ▶ | sub _conn_error { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_conn_error: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | 0 | my ($self,$errstr,$id) = @_[OBJECT,ARG2,ARG3]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | 0 | ▶ | return unless $self->_conn_exists( $id ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | 0 | my $client = delete $self->{clients}->{ $id }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | 0 | ▶ | if ( $client->{cmd_id} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | 0 | delete $self->{wheels}->{ $client->{cmd_id} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | 0 | delete $self->{pids}->{ $client->{cmd_pid} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | 16 | ▶ | sub _conn_flushed { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_conn_flushed: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | 16 | my ($self,$id) = @_[OBJECT,ARG0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | 16 | ▶ | return unless $self->_conn_exists( $id ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | 16 | my $client = delete $self->{clients}->{ $id }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | 16 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | 0 | ▶ | sub _conn_alarm { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_conn_alarm: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | 0 | my ($kernel,$self,$id) = @_[KERNEL,OBJECT,ARG0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | 0 | ▶ | return unless $self->_conn_exists( $id ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | 0 | my $client = delete $self->{clients}->{ $id }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | 0 | ▶ | if ( $client->{cmd_id} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | 0 | delete $self->{wheels}->{ $client->{cmd_id} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | 0 | delete $self->{pids}->{ $client->{cmd_pid} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | 10 | ▶ | sub _sig_child { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_sig_child: called CC=7 SCAR=19.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | 10 | my ($kernel,$self,$signal,$pid,$status) = @_[KERNEL,OBJECT,ARG0..ARG2]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | 10 | $pid = delete $self->{pids}->{ $pid }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | 10 | ▶ | if ( $pid ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | 10 | $kernel->alarm_remove( $pid->{alarm_id} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | 10 | my ( $return, $output ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | 10 | ▶ | if ( $pid->{output} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | 8 | $output = $pid->{output}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | 2 | $output = 'NRPE: Unable to read output'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | 10 | ▶ | $output = $pid->{timed_out} if $pid->{timed_out}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | 10 | $return = $status >> 8; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | 10 | ▶ | $return = NRPE_STATE_UNKNOWN if $return < 0 or $return > 3; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$return < 0 or $return > 3
MC/DC50%1/2
$return < 0 or $return > 3
$return < 0
$return > 3
Truth table66%2/3
A or B
A= $return < 0B= $return > 3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | 10 | ▶ | $return = NRPE_STATE_UNKNOWN if $pid->{timed_out}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | 10 | $self->_send_response( $pid->{client}, $return, $output ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | 10 | return $kernel->sig_handled(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | # These functions are derived from http://www.stic-online.de/stic/html/nrpe-generic.html | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | # Copyright (C) 2006, 2007 STIC GmbH, http://www.stic-online.de | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | # Licensed under GPLv2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | 15 | ▶ | sub _gen_packet_ver2 { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_gen_packet_ver2: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | 15 | my $result = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | 15 | my $data = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | 15 | ▶ | for ( my $i = length ( $data ); $i < 1024; $i++ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | 15055 | $data .= "\x00"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | 15 | $data .= "SR"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | 15 | my $res = pack "n", $result; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | 15 | my $packet = "\x00\x02\x00\x02"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | 15 | my $tail = $res . $data; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | 15 | my $crc = ~_crc32( $packet . "\x00\x00\x00\x00" . $tail ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | 15 | $packet .= pack ( "N", $crc ) . $tail; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | 15 | return $packet; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | 15 | ▶ | sub _crc32 { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_crc32: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | 15 | my $crc; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | my $len; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | 15 | my $i; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | 15 | my $index; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | 15 | my @args; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | 15 | my ($arg) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | 15 | my @crc_table =( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | 0x706af48f, 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | 0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | 0x90bf1d91, 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, 0x136c9856, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | 0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | 0xa2677172, 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | 0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | 0x45df5c75, 0xdcd60dcf, 0xabd13d59, 0x26d930ac, 0x51de003a, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, 0xcfba9599, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | 0x01db7106, 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | 0x9fbfe4a5, 0xe8b8d433, 0x7807c9a2, 0x0f00f934, 0x9609a88e, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, 0x6c0695ed, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | 0xfbd44c65, 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | 0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | 0x346ed9fc, 0xad678846, 0xda60b8d0, 0x44042d73, 0x33031de5, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa, 0xbe0b1010, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | 0x03b6e20c, 0x74b1d29a, 0xead54739, 0x9dd277af, 0x04db2615, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | 0x73dc1683, 0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, 0xf00f9344, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | 0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | 0x67dd4acc, 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | 0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | 0xa6bc5767, 0x3fb506dd, 0x48b2364b, 0xd80d2bda, 0xaf0a1b4c, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, 0x316e8eef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | 0x2cd99e8b, 0x5bdeae1d, 0x9b64c2b0, 0xec63f226, 0x756aa39c, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | 0x026d930a, 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, 0x92d28e9b, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | 0x18b74777, 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | 0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45, 0xa00ae278, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | 0xd70dd2ee, 0x4e048354, 0x3903b3c2, 0xa7672661, 0xd06016f7, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc, 0x40df0b66, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | 0xcdd70693, 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | 0x5d681b02, 0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | 0x2d02ef8d | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | 15 | $crc = 0xffffffff; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | 15 | $len = length($arg); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | 15 | @args = unpack "c*", $arg; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | 15 | ▶ | for ($i = 0; $i < $len; $i++) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | 15540 | $index = ($crc ^ $args[$i]) & 0xff; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | 15540 | $crc = $crc_table[$index] ^ (($crc >> 8) & 0x00ffffff); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | 15 | return $crc; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | 1 | ▶ | sub _SSLify_Initialise { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_SSLify_Initialise: called CC=6 SCAR=20.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | 1 | my $data = "-----BEGIN DH PARAMETERS-----\nMEYCQQD9eJtH5rywhI/PGD+RaFvEptXwGrqtjm4Jw+GSniG72OLThcOcb29iEIcp\nXgrpPtClVGHYs4lNZbpwFz1ufNnjAgEC\n-----END DH PARAMETERS-----\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | 1 | ▶ | my $ctx = Net::SSLeay::CTX_new() or die_now( "Failed to create SSL_CTX $!" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | 1 | ▶ | Net::SSLeay::CTX_set_cipher_list( $ctx, 'ADH') or die_now( " Failed to set cipher list $!" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | 1 | ▶ | my $bio = Net::SSLeay::BIO_new( Net::SSLeay::BIO_s_mem() ) or die_now( "Failed to create BIO: $!" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | 1 | my $retval = Net::SSLeay::BIO_write( $bio, $data ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | 1 | ▶ | my $dh = Net::SSLeay::PEM_read_bio_DHparams( $bio ) or die_now( "Failed to read DHparams: $!" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | 1 | Net::SSLeay::BIO_free( $bio ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | 1 | ▶ | Net::SSLeay::CTX_set_tmp_dh( $ctx, $dh ) or die_now( "Failed to set tmp DH: $!" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | 0 | Net::SSLeay::DH_free( $dh ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | 0 | return $ctx; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | 21 | 'POE it'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||