| 1 | package Mail::Milter::Authentication::Handler; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 143 | ▶ | use 5.20.0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 143 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 143 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 143 | ▶ | use Mail::Milter::Authentication::Pragmas; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | # ABSTRACT: Handler superclass | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 143 | our $VERSION = '4.20261116'; # VERSION | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 143 | ▶ | use Mail::Milter::Authentication::Exception; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 143 | ▶ | use Mail::Milter::Authentication::Resolver; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 143 | ▶ | use Digest::MD5 qw{ md5_hex }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 143 | ▶ | use Fcntl qw{ O_RDONLY O_NOFOLLOW S_ISREG }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 143 | ▶ | use List::MoreUtils qw{ uniq }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 143 | ▶ | use Lock::File; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 143 | ▶ | use MIME::Base64; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 143 | ▶ | use Mail::SPF; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 143 | ▶ | use Net::DNS::Resolver; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 143 | ▶ | use Net::IP; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 143 | ▶ | use Proc::ProcessTable; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 143 | ▶ | use Sereal qw{encode_sereal decode_sereal}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 143 | ▶ | use Sys::Hostname; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 143 | ▶ | use Time::HiRes qw{ ualarm gettimeofday }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 143 | ▶ | use Digest::SHA qw(sha1_hex); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 143 | ▶ | use Email::Address::XS 1.05; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 143 | our $TestResolver; # For Testing | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 1459 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 1459 | my ( $class, $thischild ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 1459 | my $self = { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 'thischild' => $thischild, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 1459 | bless $self, $class; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 1459 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 211 | ▶ | sub get_version { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_version: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 211 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 143 | ▶ | no strict 'refs'; ## no critic; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 211 | ▶ | return ${ ref( $self ) . "::VERSION" } // 'unknown'; # no critic; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
${ref($self) . '::VERSION';} // "unknown"
MC/DC0%0/1
${ref($self) . '::VERSION';} // "unknown"
${ref($self) . '::VERSION';}
Truth table50%1/2
A
A= ${ref($self) . '::VERSION';}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 6 | ▶ | sub get_json { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_json: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 6 | my ( $self, $file ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 6 | my $basefile = __FILE__; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 6 | $basefile =~ s/Handler\.pm$/Handler\/$file/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 6 | $basefile .= '.json'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 6 | ▶ | if ( ! -e $basefile ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 0 | die 'json file ' . $file . ' not found'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 6 | open my $InF, '<', $basefile; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 6 | my @Content = <$InF>; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 6 | close $InF; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 6 | return join( q{}, @Content ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | ▶ | sub metric_register { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
metric_register: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | my ( $self, $id, $help ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | $self->{'thischild'}->{'metric'}->register( $id, $help, $self->{'thischild'} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 8290 | ▶ | sub metric_count { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
metric_count: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 8290 | my ( $self, $count_id, $labels, $count ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 8290 | ▶ | $labels = {} if ! defined $labels; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 8290 | ▶ | $count = 1 if ! defined $count; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 8290 | my $metric = $self->{'thischild'}->{'metric'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 8290 | $metric->set_handler( $self ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | $metric->count({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 'count_id' => $count_id, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 'labels' => $labels, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 8290 | 'server' => $self->{'thischild'}, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 'count' => $count, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 8290 | $metric->set_handler( undef ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 15 | ▶ | sub metric_set { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
metric_set: called CC=3 SCAR=11.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 15 | my ( $self, $gauge_id, $labels, $value ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 15 | ▶ | $labels = {} if ! defined $labels; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 15 | ▶ | die 'Must set value in metric_set call' if ! defined $value; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 15 | my $metric = $self->{'thischild'}->{'metric'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 15 | $metric->set_handler( $self ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | $metric->set({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 'gauge_id' => $gauge_id, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 'labels' => $labels, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 15 | 'server' => $self->{'thischild'}, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 'value' => $value, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 15 | $metric->set_handler( undef ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 0 | ▶ | sub metric_send { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
metric_send: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 0 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | # NOOP | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | # TODO Deprecate and remove | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 4 | ▶ | sub rbl_check_ip { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
rbl_check_ip: called CC=4 SCAR=14.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 4 | my ( $self, $ip, $list ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 4 | my $lookup_ip; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | # Reverse the IP | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 4 | ▶ | if ( $ip->version() == 4 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 2 | $lookup_ip = join( '.', reverse( split( /\./, $ip->ip() ) ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | elsif ( $ip->version() == 6 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 2 | my $ip_string = $ip->ip(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 2 | $ip_string =~ s/://g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 2 | $lookup_ip = join( '.', reverse( split( '', $ip_string ) ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 4 | ▶ | return 0 if ! $lookup_ip; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 4 | return $self->rbl_check_domain( $lookup_ip, $list ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 6 | ▶ | sub rbl_check_domain { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
rbl_check_domain: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 6 | my ( $self, $domain, $list ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 6 | my $resolver = $self->get_object( 'resolver' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 6 | my $lookup = join( '.', $domain, $list ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 6 | my $packet = $resolver->query( $lookup, 'A' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 6 | ▶ | if ($packet) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 3 | foreach my $rr ( $packet->answer ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 3 | ▶ | if ( lc $rr->type eq 'a' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 3 | return $rr->address(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 3 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 0 | ▶ | sub rbl_check_email_address { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
rbl_check_email_address: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 0 | my ( $self, $email_address, $list ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | # This matches the SA HBL hash. Although the documentation says sha256-base32, they also | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | # list all entries as sha1-hex, so we'll just use that as well | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | $email_address = lc $email_address; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | $email_address =~ s/\+.*@/@/; # No plus addressing | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | my $entry_hash = sha1_hex($email_address); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 0 | my $resolver = $self->get_object( 'resolver' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 0 | my $lookup = join( '.', $entry_hash, $list ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 0 | my $packet = $resolver->query( $lookup, 'A' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 0 | ▶ | if ($packet) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 0 | foreach my $rr ( $packet->answer ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 0 | ▶ | if ( lc $rr->type eq 'a' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 0 | return $rr->address(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 45875 | ▶ | sub get_microseconds { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_microseconds: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | # Micro-optimise, get_microseconds is called a lot | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | #my ( $self ) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | #my ($seconds, $microseconds) = gettimeofday; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | #return ( ( $seconds * 1000000 ) + $microseconds ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 45875 | return int(Time::HiRes::time * 1000000); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 13230 | ▶ | sub get_microseconds_since { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_microseconds_since: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 13230 | my ( $self, $since ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 13230 | my $now = $self->get_microseconds(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 13230 | my $elapsed = $now - $since; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 13230 | ▶ | $elapsed = 1 if $elapsed == 0; # Always return at least 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 13230 | return $elapsed; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | # Top Level Callbacks | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 43 | ▶ | sub register_metrics { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
register_metrics: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | return { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 43 | 'connect_total' => 'The number of connections made to authentication milter', | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 'callback_error_total' => 'The number of errors in callbacks', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 'time_microseconds_total' => 'The time in microseconds spent in various handlers', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 2 | ▶ | sub top_dequeue_callback { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
top_dequeue_callback: called CC=5 SCAR=16.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 2 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 2 | $self->status('dequeue'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 2 | $self->set_symbol('C','i','DEQUEUE.'.substr( uc md5_hex( "Authentication Milter Client $PID " . time() . rand(100) ) , -11 )); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 2 | $self->dbgout( 'CALLBACK', 'Dequeue', LOG_DEBUG ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 2 | my $config = $self->config(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 2 | eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 0 | ▶ | local $SIG{'ALRM'} = sub{ die Mail::Milter::Authentication::Exception->new({ 'Type' => 'Timeout', 'Text' => 'Dequeue callback timeout' }) }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 2 | ▶ | if ( my $timeout = $self->get_type_timeout( 'dequeue' ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 1 | $self->set_alarm( $timeout ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 2 | my $callbacks = $self->get_callbacks( 'dequeue' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 2 | foreach my $handler ( @$callbacks ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 2 | $self->dbgout( 'CALLBACK', 'Dequeue ' . $handler, LOG_DEBUG ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 2 | my $start_time = $self->get_microseconds(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 2 | $self->get_handler($handler)->dequeue_callback(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 1 | $self->dbgoutwrite(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 1 | $self->metric_count( 'time_microseconds_total', { 'callback' => 'dequeue', 'handler' => $handler }, $self->get_microseconds_since( $start_time ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 1 | $self->set_alarm(0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 2 | ▶ | if ( my $error = $@ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 1 | ▶ | if ( my $type = $self->is_exception_type( $error ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 1 | $self->metric_count( 'callback_error_total', { 'stage' => 'dequeue', 'type' => $type } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 0 | $self->metric_count( 'callback_error_total', { 'stage' => 'dequeue' } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 2 | $self->dbgoutwrite(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 2 | $self->status('postdequeue'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 178 | ▶ | sub top_setup_callback { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
top_setup_callback: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 178 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 178 | $self->status('setup'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 178 | $self->dbgout( 'CALLBACK', 'Setup', LOG_DEBUG ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 178 | $self->set_return( $self->smfis_continue() ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 178 | my $callbacks = $self->get_callbacks( 'setup' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 178 | foreach my $handler ( @$callbacks ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 173 | $self->dbgout( 'CALLBACK', 'Setup ' . $handler, LOG_DEBUG ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 173 | my $start_time = $self->get_microseconds(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 173 | $self->get_handler($handler)->setup_callback(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 173 | $self->metric_count( 'time_microseconds_total', { 'callback' => 'setup', 'handler' => $handler }, $self->get_microseconds_since( $start_time ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 178 | $self->status('postsetup'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 8565 | ▶ | sub is_exception_type { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_exception_type: called CC=5 SCAR=16.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 8565 | my ( $self, $exception ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 8565 | ▶ | return if ! defined $exception; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 8565 | ▶ | return if ! $exception; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 613 | ▶ | return if ref $exception ne 'Mail::Milter::Authentication::Exception'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 50 | ▶ | my $Type = $exception->{ 'Type' } || 'Unknown'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$exception->{'Type'} || 'Unknown'
MC/DC0%0/1
$exception->{'Type'} || 'Unknown'
$exception->{'Type'}
Truth table50%1/2
A
A= $exception->{'Type'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 50 | return $Type; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 8540 | ▶ | sub handle_exception { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
handle_exception: called CC=4 SCAR=14.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 8540 | my ( $self, $exception ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 8540 | ▶ | return if ! defined $exception; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 8540 | my $Type = $self->is_exception_type( $exception ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 8540 | ▶ | return if ! $Type; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 25 | ▶ | die $exception if $Type eq 'Timeout'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | #my $Text = $exception->{ 'Text' } || 'Unknown'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 241 | ▶ | sub get_time_remaining { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_time_remaining: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | 241 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 241 | my $top_handler = $self->get_top_handler(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 241 | ▶ | return if ! exists $top_handler->{ 'timeout_at' }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 238 | my $now = $self->get_microseconds(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 238 | my $remaining = $top_handler->{ 'timeout_at' } - $now; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | # can be zero or -ve | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 238 | return $remaining; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 9912 | ▶ | sub set_alarm { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_alarm: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 9912 | my ( $self, $microseconds ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 9912 | my $top_handler = $self->get_top_handler(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 9912 | $self->dbgout( 'Timeout set', $microseconds, LOG_DEBUG ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 9912 | ualarm( $microseconds ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 9912 | ▶ | if ( $microseconds == 0 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 5217 | delete $top_handler->{ 'timeout_at' }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 4695 | $top_handler->{ 'timeout_at' } = $self->get_microseconds() + ( $microseconds ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | 125 | ▶ | sub set_handler_alarm { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_handler_alarm: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | # Call this in a handler to set a local alarm, will take the lower value | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | # of the microseconds passed in, or what is left of a higher level timeout. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 125 | my ( $self, $microseconds ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | 125 | my $remaining = $self->get_time_remaining(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | 125 | ▶ | if ( $remaining < $microseconds ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | # This should already be set of course, but for clarity... | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 1 | $self->dbgout( 'Handler timeout set (remaining used)', $remaining, LOG_DEBUG ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 1 | ualarm( $remaining ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | 124 | $self->dbgout( 'Handler timeout set', $microseconds, LOG_DEBUG ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 124 | ualarm( $microseconds ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | 116 | ▶ | sub reset_alarm { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
reset_alarm: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | # Call this after any local handler timeouts to reset to the overall value remaining | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | 116 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | 116 | my $remaining = $self->get_time_remaining(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 116 | $self->dbgout( 'Timeout reset', $remaining, LOG_DEBUG ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | 116 | ▶ | if ( $remaining < 1 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | # We have already timed out! | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 2 | die Mail::Milter::Authentication::Exception->new({ 'Type' => 'Timeout', 'Text' => 'Reset check timeout' }); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | 114 | ualarm( $remaining ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | 38 | ▶ | sub clear_overall_timeout { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
clear_overall_timeout: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | 38 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | 38 | $self->dbgout( 'Overall timeout', 'Clear', LOG_DEBUG ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | 38 | my $top_handler = $self->get_top_handler(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | 38 | delete $top_handler->{ 'overall_timeout' }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | 80 | ▶ | sub set_overall_timeout { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_overall_timeout: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | 80 | my ( $self, $microseconds ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 80 | my $top_handler = $self->get_top_handler(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | 80 | $self->dbgout( 'Overall timeout', $microseconds, LOG_DEBUG ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 80 | $top_handler->{ 'overall_timeout' } = $self->get_microseconds() + $microseconds; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | 5242 | ▶ | sub get_type_timeout { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_type_timeout: called CC=8 SCAR=20.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | 5242 | my ( $self, $type ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | 5242 | my @log; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | 5242 | push @log, "Type: $type"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | 5242 | my $effective; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | my $timeout; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | 5242 | my $config = $self->config(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | 5242 | ▶ | if ( $config->{ $type . '_timeout' } ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 4652 | $timeout = $config->{ $type . '_timeout' } * 1000000; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | 4652 | $effective = $timeout; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | 4652 | push @log, "Section: $timeout"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | 5242 | my $remaining; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | 5242 | my $top_handler = $self->get_top_handler(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | 5242 | ▶ | if ( my $overall_timeout = $top_handler->{ 'overall_timeout' } ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | 876 | my $now = $self->get_microseconds(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | 876 | $remaining = $overall_timeout - $now; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | 876 | push @log, "Overall: $remaining"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | 876 | ▶ | if ( $remaining < 1 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | 0 | push @log, "Overall Timedout"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | 0 | $remaining = 10; # arb low value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 5242 | ▶ | if ( $remaining ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | 876 | ▶ | if ( $timeout ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | 833 | ▶ | if ( $remaining < $timeout ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | 617 | $effective = $remaining; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | 43 | $effective = $remaining; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | 5242 | ▶ | push @log, "Effective: $effective" if $effective; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | 5242 | $self->dbgout( 'Timeout set', join( ', ', @log ), LOG_DEBUG ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | 5242 | return $effective; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | 13781 | ▶ | sub check_timeout { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
check_timeout: called CC=3 SCAR=12.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | 13781 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | 13781 | my $top_handler = $self->get_top_handler(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | 13781 | ▶ | return if ! exists $top_handler->{ 'timeout_at' }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | 13501 | ▶ | return if $top_handler->{ 'timeout_at' } >= $self->get_microseconds(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | 0 | delete $top_handler->{ 'timeout_at' }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | 0 | ualarm( 0 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | 0 | die Mail::Milter::Authentication::Exception->new({ 'Type' => 'Timeout', 'Text' => 'Manual check timeout' }); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | 698 | ▶ | sub _remap_ip_and_helo { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_remap_ip_and_helo: called CC=12 SCAR=25.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | 698 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | 698 | my $config = $self->config(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | 698 | ▶ | if ( exists ( $config->{ 'ip_map' } ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | 140 | my $ip_object = $self->{ 'raw_ip_object' }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | 140 | my $helo_host = $self->{'raw_helo_name'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | 140 | foreach my $ip_map ( sort keys %{ $config->{ 'ip_map' } } ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | 264 | my $map_obj = Net::IP->new( $ip_map ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | 264 | ▶ | if ( !$map_obj ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | 0 | $self->log_error( 'Core: Could not parse IP '.$ip_map ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | 264 | ▶ | my $is_overlap = $ip_object->overlaps($map_obj) || 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$ip_object->overlaps($map_obj) || 0
MC/DC100%1/1
$ip_object->overlaps($map_obj) || 0
$ip_object->overlaps($map_obj)
Truth table100%2/2
A
A= $ip_object->overlaps($map_obj)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | 264 | ▶ | if ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition77%7/9
$is_overlap == $Mail::Milter::Authentication::Handler::IP_A_IN_B_OVERLAP or $is_overlap == $Mail::Milter::Authentication::Handler::IP_B_IN_A_OVERLAP or $is_overlap == $Mail::Milter::Authentication::Handler::IP_PARTIAL_OVERLAP or $is_overlap == $Mail::Milter::Authentication::Handler::IP_IDENTICAL
$is_overlap == $Mail::Milter::Authentication::Handler::IP_A_IN_B_OVERLAP or $is_overlap == $Mail::Milter::Authentication::Handler::IP_B_IN_A_OVERLAP or $is_overlap == $Mail::Milter::Authentication::Handler::IP_PARTIAL_OVERLAP
$is_overlap == $Mail::Milter::Authentication::Handler::IP_A_IN_B_OVERLAP or $is_overlap == $Mail::Milter::Authentication::Handler::IP_B_IN_A_OVERLAP
MC/DC50%2/4
$is_overlap == $Mail::Milter::Authentication::Handler::IP_A_IN_B_OVERLAP or $is_overlap == $Mail::Milter::Authentication::Handler::IP_B_IN_A_OVERLAP or $is_overlap == $Mail::Milter::Authentication::Handler::IP_PARTIAL_OVERLAP or $is_overlap == $Mail::Milter::Authentication::Handler::IP_IDENTICAL
$is_overlap == $Mail::Milter::Authentication::Handler::IP_A_IN_B_OVERLAP
$is_overlap == $Mail::Milter::Authentication::Handler::IP_B_IN_A_OVERLAP
$is_overlap == $Mail::Milter::Authentication::Handler::IP_PARTIAL_OVERLAP
$is_overlap == $Mail::Milter::Authentication::Handler::IP_IDENTICAL
Truth table60%3/5
A or B or C or D
A= $is_overlap == $Mail::Milter::Authentication::Handler::IP_A_IN_B_OVERLAPB= $is_overlap == $Mail::Milter::Authentication::Handler::IP_B_IN_A_OVERLAPC= $is_overlap == $Mail::Milter::Authentication::Handler::IP_PARTIAL_OVERLAPD= $is_overlap == $Mail::Milter::Authentication::Handler::IP_IDENTICAL
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | $is_overlap == $IP_A_IN_B_OVERLAP | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | || $is_overlap == $IP_B_IN_A_OVERLAP # Should never happen | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | || $is_overlap == $IP_PARTIAL_OVERLAP # Should never happen | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | || $is_overlap == $IP_IDENTICAL | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | 16 | my $mapped_to = $config->{ 'ip_map' }->{ $ip_map }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | 16 | ▶ | if ( $helo_host && exists $mapped_to->{helo_map} && exists $mapped_to->{helo_map}->{ $helo_host } ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
$helo_host and exists $mapped_to->{"helo_map"} and exists $mapped_to->{"helo_map"}{$helo_host}
$helo_host and exists $mapped_to->{"helo_map"}
MC/DC100%3/3
$helo_host and exists $mapped_to->{"helo_map"} and exists $mapped_to->{"helo_map"}{$helo_host}
$helo_host
exists $mapped_to->{"helo_map"}
exists $mapped_to->{"helo_map"}{$helo_host}
Truth table100%4/4
A and B and C
A= $helo_hostB= exists $mapped_to->{"helo_map"}C= exists $mapped_to->{"helo_map"}{$helo_host}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | # We have a specific HELO mapping for this! | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | 2 | $mapped_to = $mapped_to->{helo_map}->{ $helo_host }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | return { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | ip => Net::IP->new( $mapped_to->{ip} ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | helo => $mapped_to->{helo}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | 2 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | # Remap based on IP Only | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | return { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | ip => Net::IP->new( $mapped_to->{ip} ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | helo => $mapped_to->{helo}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | 14 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | 352 | ▶ | sub remap_connect_callback { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
remap_connect_callback: called CC=3 SCAR=11.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | 352 | my ( $self, $hostname, $ip ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | 352 | $self->{'raw_ip_object'} = $ip; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | 352 | my $ip_remap = $self->_remap_ip_and_helo(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | 352 | ▶ | if ( $ip_remap ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | 8 | ▶ | if ( !$ip_remap->{ip} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | 0 | $self->log_error( 'Core: Ignored bad IP in remapping' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | 8 | $ip = $ip_remap->{ip}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | 8 | $self->dbgout( 'RemappedConnect', $self->{'raw_ip_object'}->short() . ' > ' . $ip->short(), LOG_DEBUG ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | 352 | $self->{'ip_object'} = $ip; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | 11 | ▶ | sub top_metrics_callback { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
top_metrics_callback: called CC=3 SCAR=11.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | 11 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | 11 | my $callbacks = $self->get_callbacks( 'metrics' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | 11 | foreach my $handler ( @$callbacks ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | 10 | $self->dbgout( 'CALLBACK', 'Metrics ' . $handler, LOG_DEBUG ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | 10 | eval{ $self->get_handler($handler)->metrics_callback(); }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | 10 | ▶ | if ( my $error = $@ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | 0 | $self->handle_exception( $error ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | 0 | $self->log_error( 'Metrics callback error ' . $error ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | 352 | ▶ | sub top_connect_callback { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
top_connect_callback: called CC=6 SCAR=18.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | # On Connect | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | 352 | my ( $self, $hostname, $ip ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | 352 | $self->metric_count( 'connect_total' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | 352 | $self->status('connect'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | 352 | $self->dbgout( 'CALLBACK', 'Connect', LOG_DEBUG ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | 352 | $self->set_return( $self->smfis_continue() ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | 352 | $self->clear_reject_mail(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | 352 | $self->clear_defer_mail(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | 352 | $self->clear_quarantine_mail(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | 352 | my $config = $self->config(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | 352 | eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | 352 | ▶ | local $SIG{'ALRM'} = sub{ die Mail::Milter::Authentication::Exception->new({ 'Type' => 'Timeout', 'Text' => 'Connect callback timeout' }) }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | 352 | ▶ | if ( my $timeout = $self->get_type_timeout( 'connect' ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | 352 | $self->set_alarm( $timeout ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | 352 | $self->dbgout( 'ConnectFrom', $ip->short(), LOG_DEBUG ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | 352 | my $callbacks = $self->get_callbacks( 'connect' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | 352 | foreach my $handler ( @$callbacks ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | 420 | $self->dbgout( 'CALLBACK', 'Connect ' . $handler, LOG_DEBUG ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | 420 | my $start_time = $self->get_microseconds(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | 420 | eval{ $self->get_handler($handler)->connect_callback( $hostname, $ip ); }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | 420 | ▶ | if ( my $error = $@ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | 1 | $self->handle_exception( $error ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | 0 | $self->exit_on_close( 'Connect callback error ' . $error ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | 0 | $self->tempfail_on_error(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | 0 | $self->metric_count( 'callback_error_total', { 'stage' => 'connect', 'handler' => $handler } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | 419 | $self->metric_count( 'time_microseconds_total', { 'callback' => 'connect', 'handler' => $handler }, $self->get_microseconds_since( $start_time ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | 419 | $self->check_timeout(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | 351 | $self->set_alarm(0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | 352 | ▶ | if ( my $error = $@ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | 1 | ▶ | if ( my $type = $self->is_exception_type( $error ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | 1 | $self->metric_count( 'callback_error_total', { 'stage' => 'connect', 'type' => $type } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | 1 | $self->exit_on_close( 'Connect callback error ' . $type . ' - ' . $error->{ 'Text' } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | 0 | $self->metric_count( 'callback_error_total', { 'stage' => 'connect' } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | 0 | $self->exit_on_close( 'Connect callback error ' . $error ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | 1 | $self->tempfail_on_error(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | 352 | $self->status('postconnect'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | 352 | return $self->get_return(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | 346 | ▶ | sub remap_helo_callback { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
remap_helo_callback: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | 346 | my ( $self, $helo_host ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | 346 | ▶ | if ( !( $self->{'helo_name'} ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | 346 | $self->{'raw_helo_name'} = $helo_host; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | 346 | my $ip_remap = $self->_remap_ip_and_helo(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | 346 | ▶ | if ( $ip_remap ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | 8 | my $ip = $ip_remap->{ip}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | 8 | ▶ | if ( $self->{'ip_object'}->ip() ne $ip_remap->{ip}->ip() ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | # The mapped IP has been changed based on the HELO host received | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | 2 | $self->{'ip_object'} = $ip; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | 2 | $self->dbgout( 'RemappedConnectHELO', $self->{'ip_object'}->short() . ' > ' . $ip->short(), LOG_DEBUG ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | 8 | $helo_host = $ip_remap->{helo}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | 8 | $self->dbgout( 'RemappedHELO', $self->{'raw_helo_name'} . ' > ' . $helo_host, LOG_DEBUG ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | 346 | $self->{'helo_name'} = $helo_host; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | 346 | ▶ | sub top_helo_callback { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
top_helo_callback: called CC=8 SCAR=21.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | # On HELO | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | 346 | my ( $self, $helo_host ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | 346 | $self->status('helo'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | 346 | $self->dbgout( 'CALLBACK', 'Helo', LOG_DEBUG ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | 346 | $self->set_return( $self->smfis_continue() ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | 346 | ▶ | $helo_host = q{} if ! defined $helo_host; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | 346 | my $config = $self->config(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | 346 | eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | 346 | ▶ | local $SIG{'ALRM'} = sub{ die Mail::Milter::Authentication::Exception->new({ 'Type' => 'Timeout', 'Text' => 'HELO callback timeout' }) }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | 346 | ▶ | if ( my $timeout = $self->get_type_timeout( 'command' ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | 346 | $self->set_alarm( $timeout ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | # Take only the first HELO from a connection | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | 346 | ▶ | if ( !( $self->{'seen_helo_name'} ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | 346 | $self->{'seen_helo_name'} = $helo_host; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | 346 | my $callbacks = $self->get_callbacks( 'helo' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | 346 | foreach my $handler ( @$callbacks ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | 493 | $self->dbgout( 'CALLBACK', 'Helo ' . $handler, LOG_DEBUG ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | 493 | my $start_time = $self->get_microseconds(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | 493 | eval{ $self->get_handler($handler)->helo_callback($helo_host); }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | 493 | ▶ | if ( my $error = $@ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | 1 | $self->handle_exception( $error ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | 0 | $self->exit_on_close( 'HELO callback error ' . $error ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | 0 | $self->tempfail_on_error(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | 0 | $self->metric_count( 'callback_error_total', { 'stage' => 'helo', 'handler' => $handler } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | 492 | $self->metric_count( 'time_microseconds_total', { 'callback' => 'helo', 'handler' => $handler }, $self->get_microseconds_since( $start_time ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | 492 | $self->check_timeout(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | 0 | $self->dbgout('Multiple HELO callbacks detected and ignored', $self->{'seen_helo_name'} . ' / ' . $helo_host, LOG_DEBUG ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | 345 | $self->set_alarm(0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | 346 | ▶ | if ( my $error = $@ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | 1 | ▶ | if ( my $type = $self->is_exception_type( $error ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | 1 | $self->metric_count( 'callback_error_total', { 'stage' => 'helo', 'type' => $type } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | 1 | $self->exit_on_close( 'HELO error ' . $type . ' - ' . $error->{ 'Text' } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | 0 | $self->metric_count( 'callback_error_total', { 'stage' => 'helo' } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | 0 | $self->exit_on_close( 'HELO callback error ' . $error ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | 1 | $self->tempfail_on_error(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | 346 | $self->status('posthelo'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | 346 | return $self->get_return(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | 345 | ▶ | sub top_envfrom_callback { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
top_envfrom_callback: called CC=7 SCAR=19.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | # On MAILFROM | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | #... | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | 345 | my ( $self, $env_from, @params ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | 345 | $self->status('envfrom'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | 345 | $self->dbgout( 'CALLBACK', 'EnvFrom', LOG_DEBUG ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | 345 | $self->set_return( $self->smfis_continue() ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | 345 | ▶ | $env_from = q{} if ! defined $env_from; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | 345 | my $config = $self->config(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | 345 | eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | 345 | ▶ | local $SIG{'ALRM'} = sub{ die Mail::Milter::Authentication::Exception->new({ 'Type' => 'Timeout', 'Text' => 'EnvFrom callback timeout' }) }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | 345 | ▶ | if ( my $timeout = $self->get_type_timeout( 'command' ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | 345 | $self->set_alarm( $timeout ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | # Reset private data for this MAIL transaction | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | 345 | delete $self->{'auth_headers'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | 345 | delete $self->{'pre_headers'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | 345 | delete $self->{'add_headers'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | 345 | delete $self->{'suppress_error_emails'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | 345 | my $callbacks = $self->get_callbacks( 'envfrom' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | 345 | foreach my $handler ( @$callbacks ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | 1012 | $self->dbgout( 'CALLBACK', 'EnvFrom ' . $handler, LOG_DEBUG ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | 1012 | my $start_time = $self->get_microseconds(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | 1012 | eval { $self->get_handler($handler)->envfrom_callback($env_from, @params); }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 633 | 1012 | ▶ | if ( my $error = $@ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | 1 | $self->handle_exception( $error ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 635 | 0 | $self->exit_on_close( 'Env From callback error ' . $error ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | 0 | $self->tempfail_on_error(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 637 | 0 | $self->metric_count( 'callback_error_total', { 'stage' => 'envfrom', 'handler' => $handler } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 639 | 1011 | $self->metric_count( 'time_microseconds_total', { 'callback' => 'envfrom', 'handler' => $handler }, $self->get_microseconds_since( $start_time ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 640 | 1011 | $self->check_timeout(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 641 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 642 | 344 | $self->set_alarm(0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 643 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 644 | 345 | ▶ | if ( my $error = $@ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 645 | 1 | ▶ | if ( my $type = $self->is_exception_type( $error ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 646 | 1 | $self->metric_count( 'callback_error_total', { 'stage' => 'envfrom', 'type' => $type } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 647 | 1 | $self->exit_on_close( 'Env From error ' . $type . ' - ' . $error->{ 'Text' } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 648 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 649 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 650 | 0 | $self->metric_count( 'callback_error_total', { 'stage' => 'envfrom' } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 651 | 0 | $self->exit_on_close( 'Env From callback error ' . $error ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 652 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 653 | 1 | $self->tempfail_on_error(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 654 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 655 | 345 | $self->status('postenvfrom'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 656 | 345 | return $self->get_return(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 657 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 658 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 659 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 660 | 344 | ▶ | sub top_envrcpt_callback { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
top_envrcpt_callback: called CC=7 SCAR=19.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 661 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 662 | # On RCPTTO | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 663 | #... | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 664 | 344 | my ( $self, $env_to, @params ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 665 | 344 | $self->status('envrcpt'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 666 | 344 | $self->dbgout( 'CALLBACK', 'EnvRcpt', LOG_DEBUG ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 667 | 344 | $self->set_return( $self->smfis_continue() ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 668 | 344 | ▶ | $env_to = q{} if ! defined $env_to; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 669 | 344 | my $config = $self->config(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 670 | 344 | eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 671 | 344 | ▶ | local $SIG{'ALRM'} = sub{ die Mail::Milter::Authentication::Exception->new({ 'Type' => 'Timeout', 'Text' => 'EnvRcpt callback timeout' }) }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 672 | 344 | ▶ | if ( my $timeout = $self->get_type_timeout( 'command' ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 673 | 344 | $self->set_alarm( $timeout ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 674 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 675 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 676 | 344 | my $callbacks = $self->get_callbacks( 'envrcpt' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 677 | 344 | foreach my $handler ( @$callbacks ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 678 | 175 | $self->dbgout( 'CALLBACK', 'EnvRcpt ' . $handler, LOG_DEBUG ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 679 | 175 | my $start_time = $self->get_microseconds(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 680 | 175 | eval{ $self->get_handler($handler)->envrcpt_callback($env_to, @params); }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 681 | 175 | ▶ | if ( my $error = $@ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 682 | 1 | $self->handle_exception( $error ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 683 | 0 | $self->exit_on_close( 'Env Rcpt callback error ' . $error ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 684 | 0 | $self->tempfail_on_error(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 685 | 0 | $self->metric_count( 'callback_error_total', { 'stage' => 'rcptto', 'handler' => $handler } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 686 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 687 | 174 | $self->metric_count( 'time_microseconds_total', { 'callback' => 'rcptto', 'handler' => $handler }, $self->get_microseconds_since( $start_time ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 688 | 174 | $self->check_timeout(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 689 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 690 | 343 | $self->set_alarm(0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 691 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 692 | 344 | ▶ | if ( my $error = $@ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 693 | 1 | ▶ | if ( my $type = $self->is_exception_type( $error ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 694 | 1 | $self->metric_count( 'callback_error_total', { 'stage' => 'rcptto', 'type' => $type } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 695 | 1 | $self->exit_on_close( 'Env Rcpt callback error ' . $type . ' - ' . $error->{ 'Text' } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 696 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 697 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 698 | 0 | $self->metric_count( 'callback_error_total', { 'stage' => 'rcptto' } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 699 | 0 | $self->exit_on_close( 'Env Rcpt callback error ' . $error ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 700 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 701 | 1 | $self->tempfail_on_error(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 702 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 703 | 344 | $self->status('postenvrcpt'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 704 | 344 | return $self->get_return(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 705 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 706 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 707 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 708 | 2028 | ▶ | sub top_header_callback { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
top_header_callback: called CC=11 SCAR=25.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 709 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 710 | # On Each Header | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 711 | 2028 | my ( $self, $header, $value, $original ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 712 | 2028 | $self->status('header'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 713 | 2028 | $self->dbgout( 'CALLBACK', 'Header', LOG_DEBUG ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 714 | 2028 | $self->set_return( $self->smfis_continue() ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 715 | 2028 | ▶ | $value = q{} if ! defined $value; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 716 | 2028 | my $config = $self->config(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 717 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 718 | 2028 | ▶ | if ( $header eq 'X-Authentication-Milter-Error' && $value eq 'Generated Error Report' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$header eq "X-Authentication-Milter-Error" and $value eq "Generated Error Report"
MC/DC0%0/2
$header eq "X-Authentication-Milter-Error" and $value eq "Generated Error Report"
$header eq "X-Authentication-Milter-Error"
$value eq "Generated Error Report"
Truth table33%1/3
A and B
A= $header eq "X-Authentication-Milter-Error"B= $value eq "Generated Error Report"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 719 | 0 | $self->{'suppress_error_emails'} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 720 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 721 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 722 | 2028 | eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 723 | 2028 | ▶ | local $SIG{'ALRM'} = sub{ die Mail::Milter::Authentication::Exception->new({ 'Type' => 'Timeout', 'Text' => 'Header callback timeout' }) }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 724 | 2028 | ▶ | if ( my $timeout = $self->get_type_timeout( 'content' ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 725 | 2028 | $self->set_alarm( $timeout ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 726 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 727 | 2028 | ▶ | if ( my $error = $@ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 728 | 0 | $self->dbgout( 'inline error $error', '', LOG_DEBUG ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 729 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 730 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 731 | # Local cache these metrics for performance, actually process in top_eoh_callback | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 732 | 2028 | ▶ | $self->{'header_metrics'} ||= {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$self->{"header_metrics"} ||= {}
MC/DC100%1/1
$self->{"header_metrics"} ||= {}
$self->{"header_metrics"}
Truth table100%2/2
A
A= $self->{"header_metrics"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 733 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 734 | 2028 | my $callbacks = $self->get_callbacks( 'header' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 735 | 2028 | foreach my $handler ( @$callbacks ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 736 | 7789 | $self->dbgout( 'CALLBACK', 'Header ' . $handler, LOG_DEBUG ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 737 | 7789 | my $start_time = $self->get_microseconds(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 738 | 7789 | eval{ $self->get_handler($handler)->header_callback( $header, $value, $original ); }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 739 | 7789 | ▶ | if ( my $error = $@ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 740 | 15 | $self->handle_exception( $error ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 741 | 0 | $self->exit_on_close( 'Header callback error ' . $error ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 742 | 0 | $self->tempfail_on_error(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 743 | 0 | $self->metric_count( 'callback_error_total', { 'stage' => 'header', 'handler' => $handler } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 744 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 745 | 7774 | $self->{'header_metrics'}->{$handler} += $self->get_microseconds_since( $start_time ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 746 | 7774 | $self->check_timeout(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 747 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 748 | 2013 | $self->set_alarm(0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 749 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 750 | 2028 | ▶ | if ( my $error = $@ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 751 | 15 | ▶ | if ( my $type = $self->is_exception_type( $error ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 752 | 15 | $self->metric_count( 'callback_error_total', { 'stage' => 'header', 'type' => $type } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 753 | 15 | $self->exit_on_close( 'Header error ' . $type . ' - ' . $error->{ 'Text' } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 754 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 755 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 756 | 0 | $self->metric_count( 'callback_error_total', { 'stage' => 'header' } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 757 | 0 | $self->exit_on_close( 'Header callback error ' . $error ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 758 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 759 | 15 | $self->tempfail_on_error(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 760 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 761 | 2028 | $self->status('postheader'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 762 | 2028 | return $self->get_return(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 763 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 764 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 765 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 766 | 342 | ▶ | sub top_eoh_callback { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
top_eoh_callback: called CC=7 SCAR=19.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 767 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 768 | # On End of headers | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 769 | 342 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 770 | 342 | $self->status('eoh'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 771 | 342 | $self->dbgout( 'CALLBACK', 'EOH', LOG_DEBUG ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 772 | 342 | $self->set_return( $self->smfis_continue() ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 773 | 342 | my $config = $self->config(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 774 | 342 | eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 775 | 342 | ▶ | local $SIG{'ALRM'} = sub{ die Mail::Milter::Authentication::Exception->new({ 'Type' => 'Timeout', 'Text' => 'EOH callback timeout' }) }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 776 | 342 | ▶ | if ( my $timeout = $self->get_type_timeout( 'content' ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 777 | 342 | $self->set_alarm( $timeout ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 778 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 779 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 780 | # Process accumulated header metrics from top_header_callback | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 781 | 342 | foreach my $handler (keys %{$self->{'header_metrics'}}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 782 | 933 | $self->metric_count( 'time_microseconds_total', { 'callback' => 'header', 'handler' => $handler }, $self->{'header_metrics'}->{$handler} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 783 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 784 | 342 | delete $self->{'header_metrics'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 785 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 786 | 342 | my $callbacks = $self->get_callbacks( 'eoh' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 787 | 342 | foreach my $handler ( @$callbacks ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 788 | 625 | $self->dbgout( 'CALLBACK', 'EOH ' . $handler, LOG_DEBUG ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 789 | 625 | my $start_time = $self->get_microseconds(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 790 | 625 | eval{ $self->get_handler($handler)->eoh_callback(); }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 791 | 625 | ▶ | if ( my $error = $@ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 792 | 1 | $self->handle_exception( $error ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 793 | 0 | $self->exit_on_close( 'EOH callback error ' . $error ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 794 | 0 | $self->tempfail_on_error(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 795 | 0 | $self->metric_count( 'callback_error_total', { 'stage' => 'eoh', 'handler' => $handler } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 796 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 797 | 624 | $self->metric_count( 'time_microseconds_total', { 'callback' => 'eoh', 'handler' => $handler }, $self->get_microseconds_since( $start_time ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 798 | 624 | $self->check_timeout(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 799 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 800 | 341 | $self->set_alarm(0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 801 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 802 | 342 | ▶ | if ( my $error = $@ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 803 | 1 | ▶ | if ( my $type = $self->is_exception_type( $error ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 804 | 1 | $self->metric_count( 'callback_error_total', { 'stage' => 'eoh', 'type' => $type } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 805 | 1 | $self->exit_on_close( 'EOH error ' . $type . ' - ' . $error->{ 'Text' } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 806 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 807 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 808 | 0 | $self->metric_count( 'callback_error_total', { 'stage' => 'eoh' } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 809 | 0 | $self->exit_on_close( 'EOH callback error ' . $error ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 810 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 811 | 1 | $self->tempfail_on_error(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 812 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 813 | 342 | $self->dbgoutwrite(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 814 | 342 | $self->status('posteoh'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 815 | 342 | return $self->get_return(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 816 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 817 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 818 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 819 | 340 | ▶ | sub top_body_callback { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
top_body_callback: called CC=6 SCAR=18.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 820 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 821 | # On each body chunk | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 822 | 340 | my ( $self, $body_chunk ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 823 | 340 | $self->status('body'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 824 | 340 | $self->dbgout( 'CALLBACK', 'Body', LOG_DEBUG ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 825 | 340 | $self->set_return( $self->smfis_continue() ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 826 | 340 | my $config = $self->config(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 827 | 340 | eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 828 | 340 | ▶ | local $SIG{'ALRM'} = sub{ die Mail::Milter::Authentication::Exception->new({ 'Type' => 'Timeout', 'Text' => 'Body callback timeout' }) }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 829 | 340 | ▶ | if ( my $timeout = $self->get_type_timeout( 'content' ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 830 | 340 | $self->set_alarm( $timeout ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 831 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 832 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 833 | 340 | my $callbacks = $self->get_callbacks( 'body' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 834 | 340 | foreach my $handler ( @$callbacks ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 835 | 335 | $self->dbgout( 'CALLBACK', 'Body ' . $handler, LOG_DEBUG ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 836 | 335 | my $start_time = $self->get_microseconds(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 837 | 335 | eval{ $self->get_handler($handler)->body_callback( $body_chunk ); }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 838 | 335 | ▶ | if ( my $error = $@ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 839 | 1 | $self->handle_exception( $error ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 840 | 0 | $self->exit_on_close( 'Body callback error ' . $error ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 841 | 0 | $self->tempfail_on_error(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 842 | 0 | $self->metric_count( 'callback_error_total', { 'stage' => 'body', 'handler' => $handler } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 843 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 844 | 334 | $self->metric_count( 'time_microseconds_total', { 'callback' => 'body', 'handler' => $handler }, $self->get_microseconds_since( $start_time ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 845 | 334 | $self->check_timeout(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 846 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 847 | 339 | $self->set_alarm(0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 848 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 849 | 340 | ▶ | if ( my $error = $@ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 850 | 1 | ▶ | if ( my $type = $self->is_exception_type( $error ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 851 | 1 | $self->metric_count( 'callback_error_total', { 'stage' => 'body', 'type' => $type } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 852 | 1 | $self->exit_on_close( 'Body error ' . $type . ' - ' . $error->{ 'Text' } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 853 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 854 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 855 | 0 | $self->metric_count( 'callback_error_total', { 'stage' => 'body' } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 856 | 0 | $self->exit_on_close( 'Body callback error ' . $error ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 857 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 858 | 1 | $self->tempfail_on_error(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 859 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 860 | 340 | $self->dbgoutwrite(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 861 | 340 | $self->status('postbody'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 862 | 340 | return $self->get_return(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 863 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 864 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 865 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 866 | 342 | ▶ | sub top_eom_callback { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
top_eom_callback: called CC=6 SCAR=18.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 867 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 868 | # On End of Message | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 869 | 342 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 870 | 342 | $self->status('eom'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 871 | 342 | $self->dbgout( 'CALLBACK', 'EOM', LOG_DEBUG ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 872 | 342 | $self->set_return( $self->smfis_continue() ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 873 | 342 | my $config = $self->config(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 874 | 342 | eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 875 | 342 | ▶ | local $SIG{'ALRM'} = sub{ die Mail::Milter::Authentication::Exception->new({ 'Type' => 'Timeout', 'Text' => 'EOM callback timeout' }) }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 876 | 342 | ▶ | if ( my $timeout = $self->get_type_timeout( 'content' ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 877 | 342 | $self->set_alarm( $timeout ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 878 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 879 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 880 | 342 | my $callbacks = $self->get_callbacks( 'eom' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 881 | 342 | foreach my $handler ( @$callbacks ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 882 | 642 | $self->dbgout( 'CALLBACK', 'EOM ' . $handler, LOG_DEBUG ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 883 | 642 | my $start_time = $self->get_microseconds(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 884 | 642 | eval{ $self->get_handler($handler)->eom_callback(); }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 885 | 642 | ▶ | if ( my $error = $@ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 886 | 1 | $self->handle_exception( $error ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 887 | 0 | $self->exit_on_close( 'EOM callback error ' . $error ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 888 | 0 | $self->tempfail_on_error(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 889 | 0 | $self->metric_count( 'callback_error_total', { 'stage' => 'eom', 'handler' => $handler } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 890 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 891 | 641 | $self->metric_count( 'time_microseconds_total', { 'callback' => 'eom', 'handler' => $handler }, $self->get_microseconds_since( $start_time ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 892 | 641 | $self->check_timeout(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 893 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 894 | 341 | $self->set_alarm(0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 895 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 896 | 342 | ▶ | if ( my $error = $@ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 897 | 1 | ▶ | if ( my $type = $self->is_exception_type( $error ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 898 | 1 | $self->metric_count( 'callback_error_total', { 'stage' => 'eom', 'type' => $type } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 899 | 1 | $self->exit_on_close( 'EOM error ' . $type . ' - ' . $error->{ 'Text' } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 900 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 901 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 902 | 0 | $self->metric_count( 'callback_error_total', { 'stage' => 'eom' } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 903 | 0 | $self->exit_on_close( 'EOM callback error ' . $error ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 904 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 905 | 1 | $self->tempfail_on_error(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 906 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 907 | #$self->apply_policy(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 908 | 342 | $self->add_headers(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 909 | 342 | $self->dbgoutwrite(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 910 | 342 | $self->status('posteom'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 911 | 342 | return $self->get_return(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 912 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 913 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 914 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 915 | 0 | ▶ | sub apply_policy { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
apply_policy: not called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 916 | #my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 917 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 918 | #my @auth_headers; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 919 | #my $top_handler = $self->get_top_handler(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 920 | #if ( exists( $top_handler->{'c_auth_headers'} ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 921 | # @auth_headers = @{ $top_handler->{'c_auth_headers'} }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 922 | #} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 923 | #if ( exists( $top_handler->{'auth_headers'} ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 924 | # @auth_headers = ( @auth_headers, @{ $top_handler->{'auth_headers'} } ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 925 | #} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 926 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 927 | #my $parsed_headers = Mail::AuthenticationResults::Parser->new( \@auth_headers ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 928 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 929 | #use Data::Dumper; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 930 | #print Dumper \@structured_headers; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 931 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 932 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 933 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 934 | 33 | ▶ | sub top_abort_callback { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
top_abort_callback: called CC=6 SCAR=18.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 935 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 936 | # On any out of our control abort | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 937 | 33 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 938 | 33 | $self->status('abort'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 939 | 33 | $self->dbgout( 'CALLBACK', 'Abort', LOG_DEBUG ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 940 | 33 | $self->set_return( $self->smfis_continue() ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 941 | 33 | my $config = $self->config(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 942 | 33 | eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 943 | 33 | ▶ | local $SIG{'ALRM'} = sub{ die Mail::Milter::Authentication::Exception->new({ 'Type' => 'Timeout', 'Text' => 'Abord callback timeout' }) }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 944 | 33 | ▶ | if ( my $timeout = $self->get_type_timeout( 'command' ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 945 | 33 | $self->set_alarm( $timeout ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 946 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 947 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 948 | 33 | my $callbacks = $self->get_callbacks( 'abort' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 949 | 33 | foreach my $handler ( @$callbacks ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 950 | 1 | $self->dbgout( 'CALLBACK', 'Abort ' . $handler, LOG_DEBUG ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 951 | 1 | my $start_time = $self->get_microseconds(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 952 | 1 | eval{ $self->get_handler($handler)->abort_callback(); }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 953 | 1 | ▶ | if ( my $error = $@ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 954 | 1 | $self->handle_exception( $error ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 955 | 0 | $self->exit_on_close( 'Abort callback error ' . $error ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 956 | 0 | $self->tempfail_on_error(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 957 | 0 | $self->metric_count( 'callback_error_total', { 'stage' => 'abort', 'handler' => $handler } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 958 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 959 | 0 | $self->metric_count( 'time_microseconds_total', { 'callback' => 'abort', 'handler' => $handler }, $self->get_microseconds_since( $start_time ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 960 | 0 | $self->check_timeout(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 961 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 962 | 32 | $self->set_alarm(0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 963 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 964 | 33 | ▶ | if ( my $error = $@ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 965 | 1 | ▶ | if ( my $type = $self->is_exception_type( $error ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 966 | 1 | $self->metric_count( 'callback_error_total', { 'stage' => 'abort', 'type' => $type } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 967 | 1 | $self->exit_on_close( 'Abort error ' . $type . ' - ' . $error->{ 'Text' } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 968 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 969 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 970 | 0 | $self->metric_count( 'callback_error_total', { 'stage' => 'abort' } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 971 | 0 | $self->exit_on_close( 'Abort callback error ' . $error ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 972 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 973 | 1 | $self->tempfail_on_error(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 974 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 975 | 33 | $self->status('postabort'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 976 | 33 | return $self->get_return(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 977 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 978 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 979 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 980 | 180 | ▶ | sub top_close_callback { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
top_close_callback: called CC=8 SCAR=21.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 981 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 982 | # On end of connection | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 983 | 180 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 984 | 180 | $self->status('close'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 985 | 180 | $self->dbgout( 'CALLBACK', 'Close', LOG_DEBUG ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 986 | 180 | $self->set_return( $self->smfis_continue() ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 987 | 180 | $self->clear_reject_mail(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 988 | 180 | $self->clear_defer_mail(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 989 | 180 | $self->clear_quarantine_mail(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 990 | 180 | my $config = $self->config(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 991 | 180 | eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 992 | 180 | ▶ | local $SIG{'ALRM'} = sub{ die Mail::Milter::Authentication::Exception->new({ 'Type' => 'Timeout', 'Text' => 'Close callback timeout' }) }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 993 | 180 | ▶ | if ( my $timeout = $self->get_type_timeout( 'command' ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 994 | 180 | $self->set_alarm( $timeout ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 995 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 996 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 997 | 180 | my $callbacks = $self->get_callbacks( 'close' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 998 | 180 | foreach my $handler ( @$callbacks ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 999 | 1298 | $self->dbgout( 'CALLBACK', 'Close ' . $handler, LOG_DEBUG ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1000 | 1298 | my $start_time = $self->get_microseconds(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1001 | 1298 | eval{ $self->get_handler($handler)->close_callback(); }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1002 | 1298 | ▶ | if ( my $error = $@ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1003 | 1 | $self->handle_exception( $error ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1004 | 0 | $self->exit_on_close( 'Close callback error ' . $error ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1005 | 0 | $self->tempfail_on_error(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1006 | 0 | $self->metric_count( 'callback_error_total', { 'stage' => 'close', 'handler' => $handler } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1007 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1008 | 1297 | $self->metric_count( 'time_microseconds_total', { 'callback' => 'close', 'handler' => $handler }, $self->get_microseconds_since( $start_time ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1009 | 1297 | $self->check_timeout(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1010 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1011 | 1297 | my $handler_object = $self->get_handler($handler); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1012 | 1297 | foreach my $key ( sort keys $handler_object->%* ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1013 | 1297 | ▶ | next if $key eq 'thischild'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1014 | 0 | $self->exit_on_close( 'Handler '.$handler.' did not clean up data for key '.$key.' in close callback' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1015 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1016 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1017 | 179 | $self->set_alarm(0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1018 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1019 | 180 | ▶ | if ( my $error = $@ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1020 | 1 | ▶ | if ( my $type = $self->is_exception_type( $error ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1021 | 1 | $self->metric_count( 'callback_error_total', { 'stage' => 'close', 'type' => $type } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1022 | 1 | $self->exit_on_close( 'Close error ' . $type . ' - ' . $error->{ 'Text' } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1023 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1024 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1025 | 0 | $self->metric_count( 'callback_error_total', { 'stage' => 'close' } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1026 | 0 | $self->exit_on_close( 'Close callback error ' . $error ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1027 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1028 | 1 | $self->tempfail_on_error(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1029 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1030 | 180 | delete $self->{'helo_name'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1031 | 180 | delete $self->{'seen_helo_name'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1032 | 180 | delete $self->{'raw_helo_name'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1033 | 180 | delete $self->{'c_auth_headers'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1034 | 180 | delete $self->{'auth_headers'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1035 | 180 | delete $self->{'pre_headers'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1036 | 180 | delete $self->{'add_headers'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1037 | 180 | delete $self->{'ip_object'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1038 | 180 | delete $self->{'raw_ip_object'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1039 | 180 | delete $self->{'header_metrics'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1040 | 180 | $self->dbgoutwrite(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1041 | 180 | $self->clear_all_symbols(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1042 | 180 | $self->status('postclose'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1043 | 180 | return $self->get_return(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1044 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1045 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1046 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1047 | 588 | ▶ | sub top_addheader_callback { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
top_addheader_callback: called CC=5 SCAR=18.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1048 | 588 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1049 | 588 | my $config = $self->config(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1050 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1051 | 588 | eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1052 | 0 | ▶ | local $SIG{'ALRM'} = sub{ die Mail::Milter::Authentication::Exception->new({ 'Type' => 'Timeout', 'Text' => 'AddHeader callback timeout' }) }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1053 | 588 | ▶ | if ( my $timeout = $self->get_type_timeout( 'addheader' ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1054 | 42 | $self->set_alarm( $timeout ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1055 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1056 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1057 | 588 | my $callbacks = $self->get_callbacks( 'addheader' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1058 | 588 | foreach my $handler ( @$callbacks ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1059 | 290 | my $start_time = $self->get_microseconds(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1060 | 290 | $self->get_handler($handler)->addheader_callback($self); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1061 | 290 | $self->metric_count( 'time_microseconds_total', { 'callback' => 'addheader', 'handler' => $handler }, $self->get_microseconds_since( $start_time ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1062 | 290 | $self->check_timeout(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1063 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1064 | 588 | $self->set_alarm(0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1065 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1066 | 588 | ▶ | if ( my $error = $@ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1067 | 0 | ▶ | if ( my $type = $self->is_exception_type( $error ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1068 | 0 | $self->metric_count( 'callback_error_total', { 'stage' => 'addheader', 'type' => $type } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1069 | 0 | $self->exit_on_close( 'AddHeader error ' . $type . ' - ' . $error->{ 'Text' } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1070 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1071 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1072 | 0 | $self->metric_count( 'callback_error_total', { 'stage' => 'addheader' } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1073 | 0 | $self->exit_on_close( 'AddHeader callback error ' . $error ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1074 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1075 | 0 | $self->tempfail_on_error(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1076 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1077 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1078 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1079 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1080 | # Other methods | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1081 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1082 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1083 | 9664 | ▶ | sub status { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
status: called CC=4 SCAR=14.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1084 | 9664 | my ($self, $status) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1085 | 9664 | my $count = $self->{'thischild'}->{'count'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1086 | 9664 | ▶ | if ( exists ( $self->{'thischild'}->{'smtp'} ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1087 | 1666 | ▶ | if ( $self->{'thischild'}->{'smtp'}->{'count'} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1088 | 1666 | $count .= '.' . $self->{'thischild'}->{'smtp'}->{'count'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1089 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1090 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1091 | 9664 | ▶ | if ( $status ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1092 | 9664 | $PROGRAM_NAME = $Mail::Milter::Authentication::Config::IDENT . ':processing:' . $status . '(' . $count . ')'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1093 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1094 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1095 | 0 | $PROGRAM_NAME = $Mail::Milter::Authentication::Config::IDENT . ':processing(' . $count . ')'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1096 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1097 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1098 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1099 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1100 | 86712 | ▶ | sub config { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
config: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1101 | 86712 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1102 | 86712 | return $self->{'thischild'}->{'config'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1103 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1104 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1105 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1106 | 5712 | ▶ | sub handler_config { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
handler_config: called CC=5 SCAR=19.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1107 | 5712 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1108 | 5712 | my $type = $self->handler_type(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1109 | 5712 | ▶ | return if ! $type; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1110 | 5712 | ▶ | if ( $self->is_handler_loaded( $type ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1111 | 5712 | my $config = $self->config(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1112 | 5712 | my $handler_config = $config->{'handlers'}->{$type}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1113 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1114 | 5712 | ▶ | if ( exists( $config->{ '_external_callback_processor' } ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1115 | 0 | ▶ | if ( $config->{ '_external_callback_processor' }->can( 'handler_config' ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1116 | 0 | $handler_config = clone $handler_config; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1117 | 0 | $config->{ '_external_callback_processor' }->handler_config( $type, $handler_config ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1118 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1119 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1120 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1121 | 5712 | return $handler_config; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1122 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1123 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1124 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1125 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1126 | 5712 | ▶ | sub handler_type { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
handler_type: called CC=3 SCAR=12.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1127 | 5712 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1128 | 5712 | my $type = ref $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1129 | 5712 | ▶ | if ( $type eq 'Mail::Milter::Authentication::Handler' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1130 | 0 | return 'Handler'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1131 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1132 | elsif ( $type =~ /^Mail::Milter::Authentication::Handler::(.*)/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1133 | 5712 | my $handler_type = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1134 | 5712 | return $handler_type; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1135 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1136 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1137 | 0 | return undef; ## no critic | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1138 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1139 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1140 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1141 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1142 | 4854 | ▶ | sub set_return { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_return: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1143 | 4854 | my ( $self, $return ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1144 | 4854 | my $top_handler = $self->get_top_handler(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1145 | 4854 | $top_handler->{'return_code'} = $return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1146 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1147 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1148 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1149 | 4652 | ▶ | sub get_return { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_return: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1150 | 4652 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1151 | 4652 | my $top_handler = $self->get_top_handler(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1152 | 4652 | ▶ | if ( defined $self->get_reject_mail() ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1153 | 15 | return $self->smfis_reject(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1154 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1155 | elsif ( defined $self->get_defer_mail() ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1156 | 9 | return $self->smfis_tempfail(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1157 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1158 | elsif ( defined $self->get_quarantine_mail() ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1159 | ## TODO Implement this. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1160 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1161 | 4628 | return $top_handler->{'return_code'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1162 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1163 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1164 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1165 | 5556 | ▶ | sub get_reject_mail { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_reject_mail: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1166 | 5556 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1167 | 5556 | my $top_handler = $self->get_top_handler(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1168 | 5556 | return $top_handler->{'reject_mail'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1169 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1170 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1171 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1172 | 534 | ▶ | sub clear_reject_mail { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
clear_reject_mail: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1173 | 534 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1174 | 534 | my $top_handler = $self->get_top_handler(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1175 | 534 | delete $top_handler->{'reject_mail'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1176 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1177 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1178 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1179 | 5526 | ▶ | sub get_defer_mail { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_defer_mail: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1180 | 5526 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1181 | 5526 | my $top_handler = $self->get_top_handler(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1182 | 5526 | return $top_handler->{'defer_mail'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1183 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1184 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1185 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1186 | 532 | ▶ | sub clear_defer_mail { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
clear_defer_mail: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1187 | 532 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1188 | 532 | my $top_handler = $self->get_top_handler(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1189 | 532 | delete $top_handler->{'defer_mail'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1190 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1191 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1192 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1193 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1194 | 5913 | ▶ | sub get_quarantine_mail { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_quarantine_mail: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1195 | 5913 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1196 | 5913 | my $top_handler = $self->get_top_handler(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1197 | 5913 | return $top_handler->{'quarantine_mail'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1198 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1199 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1200 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1201 | 532 | ▶ | sub clear_quarantine_mail { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
clear_quarantine_mail: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1202 | 532 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1203 | 532 | my $top_handler = $self->get_top_handler(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1204 | 532 | delete $top_handler->{'quarantine_mail'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1205 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1206 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1207 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1208 | 86051 | ▶ | sub get_top_handler { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_top_handler: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1209 | 86051 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1210 | 86051 | my $thischild = $self->{'thischild'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1211 | 86051 | my $object = $thischild->{'handler'}->{'_Handler'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1212 | 86051 | return $object; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1213 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1214 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1215 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1216 | 16653 | ▶ | sub is_handler_loaded { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_handler_loaded: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1217 | 16653 | my ( $self, $name ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1218 | 16653 | my $config = $self->config(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1219 | 16653 | ▶ | if ( exists ( $config->{'handlers'}->{$name} ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1220 | 11768 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1221 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1222 | 4885 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1223 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1224 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1225 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1226 | 22350 | ▶ | sub get_handler { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_handler: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1227 | 22350 | my ( $self, $name ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1228 | 22350 | my $thischild = $self->{'thischild'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1229 | 22350 | my $object = $thischild->{'handler'}->{$name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1230 | 22350 | return $object; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1231 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1232 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1233 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1234 | 5431 | ▶ | sub get_callbacks { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_callbacks: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1235 | 5431 | my ( $self, $callback ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1236 | 5431 | my $thischild = $self->{'thischild'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1237 | 5431 | return $thischild->{'callbacks_list'}->{$callback}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1238 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1239 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1240 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1241 | 172 | ▶ | sub set_object_maker { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_object_maker: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1242 | 172 | my ( $self, $name, $ref ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1243 | 172 | my $thischild = $self->{'thischild'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1244 | 172 | ▶ | return if $thischild->{'object_maker'}->{$name}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1245 | 49 | $thischild->{'object_maker'}->{$name} = $ref; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1246 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1247 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1248 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1249 | 3027 | ▶ | sub get_object { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_object: called CC=11 SCAR=34.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1250 | 3027 | my ( $self, $name ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1251 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1252 | 3027 | my $thischild = $self->{'thischild'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1253 | 3027 | my $object = $thischild->{'object'}->{$name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1254 | 3027 | ▶ | if ( ! $object ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1255 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1256 | 922 | ▶ | if ( exists( $thischild->{'object_maker'}->{$name} ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1257 | 108 | my $maker = $thischild->{'object_maker'}->{$name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1258 | 108 | &$maker( $self, $name ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1259 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1260 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1261 | elsif ( $name eq 'resolver' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1262 | 226 | $self->dbgout( 'Object created', $name, LOG_DEBUG ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1263 | 226 | ▶ | if ( defined $TestResolver ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1264 | 226 | $object = $TestResolver; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1265 | 226 | warn "Using FAKE TEST DNS Resolver - I Hope this isn't production!"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1266 | # If it is you better know what you're doing! | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1267 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1268 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1269 | 0 | my $config = $self->config(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1270 | 0 | my %args; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1271 | 0 | $args{_handler} = $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1272 | 0 | ▶ | $args{udp_timeout} = $config->{'dns_timeout'} || 8; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$config->{'dns_timeout'} || 8
MC/DC0%0/1
$config->{'dns_timeout'} || 8
$config->{'dns_timeout'}
Truth table0%0/2
A
A= $config->{'dns_timeout'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1273 | 0 | ▶ | $args{tcp_timeout} = $config->{'dns_timeout'} || 8; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$config->{'dns_timeout'} || 8
MC/DC0%0/1
$config->{'dns_timeout'} || 8
$config->{'dns_timeout'}
Truth table0%0/2
A
A= $config->{'dns_timeout'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1274 | 0 | ▶ | $args{retry} = $config->{'dns_retry'} || 2; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$config->{'dns_retry'} || 2
MC/DC0%0/1
$config->{'dns_retry'} || 2
$config->{'dns_retry'}
Truth table0%0/2
A
A= $config->{'dns_retry'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1275 | 0 | ▶ | $args{cache_dns_timeouts} = $config->{'cache_dns_timeouts'} // 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$config->{"cache_dns_timeouts"} // 1
MC/DC0%0/1
$config->{"cache_dns_timeouts"} // 1
$config->{"cache_dns_timeouts"}
Truth table0%0/2
A
A= $config->{"cache_dns_timeouts"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1276 | 0 | ▶ | $args{nameservers} = $config->{'dns_resolvers'} if $config->{'dns_resolvers'} && $config->{'dns_resolvers'}->@*; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$config->{"dns_resolvers"} and @{$config->{"dns_resolvers"}}
MC/DC0%0/2
$config->{"dns_resolvers"} and @{$config->{"dns_resolvers"}}
$config->{"dns_resolvers"}
@{$config->{"dns_resolvers"}}
Truth table0%0/3
A and B
A= $config->{"dns_resolvers"}B= @{$config->{"dns_resolvers"}}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1277 | 0 | $object = Mail::Milter::Authentication::Resolver->new(%args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1278 | 0 | $object->udppacketsize(1240); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1279 | 0 | $object->persistent_udp(1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1280 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1281 | 226 | $thischild->{'object'}->{$name} = { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1282 | 'object' => $object, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1283 | 'destroy' => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1284 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1285 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1286 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1287 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1288 | 3027 | return $thischild->{'object'}->{$name}->{'object'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1289 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1290 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1291 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1292 | 1680 | ▶ | sub set_object { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_object: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1293 | 1680 | my ( $self, $name, $object, $destroy ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1294 | 1680 | my $thischild = $self->{'thischild'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1295 | 1680 | $self->dbgout( 'Object set', $name, LOG_DEBUG ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1296 | 1680 | $thischild->{'object'}->{$name} = { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1297 | 'object' => $object, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1298 | 'destroy' => $destroy, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1299 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1300 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1301 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1302 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1303 | 1424 | ▶ | sub destroy_object { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
destroy_object: called CC=5 SCAR=16.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1304 | 1424 | my ( $self, $name ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1305 | 1424 | my $thischild = $self->{'thischild'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1306 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1307 | # Objects may be set to not be destroyed, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1308 | # eg. resolver and spf_server are not | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1309 | # destroyed for performance reasons | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1310 | # Resolver, however, has its error cache cleared, as this should only | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1311 | # cache errors within a single transaction. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1312 | 1424 | ▶ | return if ! $thischild->{'object'}->{$name}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1313 | 651 | ▶ | if ($name eq 'resolver' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1314 | 17 | ▶ | if ( $thischild->{'object'}->{'resolver'}->{'object'}->can( 'clear_error_cache' ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1315 | 0 | $thischild->{'object'}->{'resolver'}->{'object'}->clear_error_cache(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1316 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1317 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1318 | 651 | ▶ | return if ! $thischild->{'object'}->{$name}->{'destroy'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1319 | 618 | $self->dbgout( 'Object destroyed', $name, LOG_DEBUG ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1320 | 618 | delete $thischild->{'object'}->{$name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1321 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1322 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1323 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1324 | 23 | ▶ | sub destroy_all_objects { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
destroy_all_objects: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1325 | # Unused! | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1326 | 23 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1327 | 23 | my $thischild = $self->{'thischild'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1328 | 23 | foreach my $name ( keys %{ $thischild->{'object'} } ) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1329 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1330 | 33 | $self->destroy_object( $name ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1331 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1332 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1333 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1334 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1335 | 24 | ▶ | sub exit_on_close { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
exit_on_close: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1336 | 24 | my ( $self, $error ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1337 | 24 | ▶ | $error = 'Generic exit_on_close requested' if ! $error; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1338 | 24 | $self->log_error( $error ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1339 | 24 | my $top_handler = $self->get_top_handler(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1340 | 24 | $top_handler->{'exit_on_close'} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1341 | 24 | ▶ | $top_handler->{'exit_on_close_error'} = 'Exit on close requested' if ! exists $top_handler->{'exit_on_close_error'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1342 | 24 | $top_handler->{'exit_on_close_error'} .= "\n$error"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1343 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1344 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1345 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1346 | 15 | ▶ | sub reject_mail { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
reject_mail: called CC=4 SCAR=17.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1347 | 15 | my ( $self, $reason ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1348 | 15 | my ( $rcode, $xcode, $message ) = split( ' ', $reason, 3 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1349 | 15 | ▶ | if ($rcode !~ /^[5]\d\d$/ || $xcode !~ /^[5]\.\d+\.\d+$/ || substr($rcode, 0, 1) ne substr($xcode, 0, 1)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
not $rcode =~ /^[5]\d\d$/u && $xcode =~ /^[5]\.\d+\.\d+$/u or substr($rcode, 0, 1) ne substr($xcode, 0, 1)
$rcode =~ /^[5]\d\d$/u && $xcode =~ /^[5]\.\d+\.\d+$/u
MC/DC0%0/3
not $rcode =~ /^[5]\d\d$/u && $xcode =~ /^[5]\.\d+\.\d+$/u or substr($rcode, 0, 1) ne substr($xcode, 0, 1)
$rcode =~ /^[5]\d\d$/u
$xcode =~ /^[5]\.\d+\.\d+$/u
substr($rcode, 0, 1) ne substr($xcode, 0, 1)
Truth table25%1/4
not(A && B) or C
A= $rcode =~ /^[5]\d\d$/uB= $xcode =~ /^[5]\.\d+\.\d+$/uC= substr($rcode, 0, 1) ne substr($xcode, 0, 1)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1350 | 0 | $self->loginfo ( "Invalid reject message $reason - setting to default" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1351 | 0 | $reason = '550 5.0.0 Message rejected'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1352 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1353 | 15 | my $top_handler = $self->get_top_handler(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1354 | 15 | $top_handler->{'reject_mail'} = $reason; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1355 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1356 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1357 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1358 | 50 | ▶ | sub quarantine_mail { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
quarantine_mail: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1359 | 50 | my ( $self, $reason ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1360 | 50 | my $top_handler = $self->get_top_handler(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1361 | 50 | $top_handler->{'quarantine_mail'} = $reason; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1362 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1363 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1364 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1365 | 9 | ▶ | sub defer_mail { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
defer_mail: called CC=4 SCAR=17.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1366 | 9 | my ( $self, $reason ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1367 | 9 | my ( $rcode, $xcode, $message ) = split( ' ', $reason, 3 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1368 | 9 | ▶ | if ($rcode !~ /^[4]\d\d$/ || $xcode !~ /^[4]\.\d+\.\d+$/ || substr($rcode, 0, 1) ne substr($xcode, 0, 1)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
not $rcode =~ /^[4]\d\d$/u && $xcode =~ /^[4]\.\d+\.\d+$/u or substr($rcode, 0, 1) ne substr($xcode, 0, 1)
$rcode =~ /^[4]\d\d$/u && $xcode =~ /^[4]\.\d+\.\d+$/u
MC/DC0%0/3
not $rcode =~ /^[4]\d\d$/u && $xcode =~ /^[4]\.\d+\.\d+$/u or substr($rcode, 0, 1) ne substr($xcode, 0, 1)
$rcode =~ /^[4]\d\d$/u
$xcode =~ /^[4]\.\d+\.\d+$/u
substr($rcode, 0, 1) ne substr($xcode, 0, 1)
Truth table25%1/4
not(A && B) or C
A= $rcode =~ /^[4]\d\d$/uB= $xcode =~ /^[4]\.\d+\.\d+$/uC= substr($rcode, 0, 1) ne substr($xcode, 0, 1)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1369 | 0 | $self->loginfo ( "Invalid defer message $reason - setting to default" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1370 | 0 | $reason = '450 4.0.0 Message deferred'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1371 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1372 | 9 | my $top_handler = $self->get_top_handler(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1373 | 9 | $top_handler->{'defer_mail'} = $reason; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1374 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1375 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1376 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1377 | 180 | ▶ | sub clear_all_symbols { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
clear_all_symbols: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1378 | 180 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1379 | 180 | my $top_handler = $self->get_top_handler(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1380 | 180 | delete $top_handler->{'symbols'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1381 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1382 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1383 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1384 | 0 | ▶ | sub clear_symbols { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
clear_symbols: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1385 | 0 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1386 | 0 | my $top_handler = $self->get_top_handler(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1387 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1388 | 0 | my $connect_symbols; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1389 | 0 | ▶ | if ( exists ( $top_handler->{'symbols'} ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1390 | 0 | ▶ | if ( exists ( $top_handler->{'symbols'}->{'C'} ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1391 | 0 | $connect_symbols = $top_handler->{'symbols'}->{'C'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1392 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1393 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1394 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1395 | 0 | delete $top_handler->{'symbols'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1396 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1397 | 0 | ▶ | if ( $connect_symbols ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1398 | 0 | $top_handler->{'symbols'} = { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1399 | 'C' => $connect_symbols, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1400 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1401 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1402 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1403 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1404 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1405 | 460 | ▶ | sub set_symbol { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_symbol: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1406 | 460 | my ( $self, $code, $key, $value ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1407 | 460 | $self->dbgout( 'SetSymbol', "$code: $key: $value", LOG_DEBUG ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1408 | 460 | my $top_handler = $self->get_top_handler(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1409 | 460 | ▶ | if ( ! exists ( $top_handler->{'symbols'} ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1410 | 79 | $top_handler->{'symbols'} = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1411 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1412 | 460 | ▶ | if ( ! exists ( $top_handler->{'symbols'}->{$code} ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1413 | 145 | $top_handler->{'symbols'}->{$code} = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1414 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1415 | 460 | $top_handler->{'symbols'}->{$code}->{$key} = $value;; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1416 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1417 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1418 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1419 | 78832 | ▶ | sub get_symbol { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_symbol: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1420 | 78832 | my ( $self, $searchkey ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1421 | # Micro-optimise, get_symbol is called a lot | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1422 | # my $top_handler = $self->get_top_handler(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1423 | # my $symbols = $top_handler->{'symbols'} || {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1424 | 78832 | ▶ | my $symbols = $self->{'thischild'}->{'handler'}->{'_Handler'}->{'symbols'} || {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$self->{'thischild'}{'handler'}{'_Handler'}{'symbols'} || {}
MC/DC100%1/1
$self->{'thischild'}{'handler'}{'_Handler'}{'symbols'} || {}
$self->{'thischild'}{'handler'}{'_Handler'}{'symbols'}
Truth table100%2/2
A
A= $self->{'thischild'}{'handler'}{'_Handler'}{'symbols'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1425 | 78832 | foreach my $subsymbols (values %{$symbols}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1426 | 43233 | ▶ | return $subsymbols->{$searchkey} if exists $subsymbols->{$searchkey}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1427 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1428 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1429 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1430 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1431 | 24 | ▶ | sub tempfail_on_error { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
tempfail_on_error: called CC=8 SCAR=32.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1432 | 24 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1433 | 24 | my $config = $self->config(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1434 | 24 | ▶ | if ( $self->is_authenticated() ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1435 | 0 | ▶ | if ( $config->{'tempfail_on_error_authenticated'} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1436 | 0 | $self->log_error('TempFail set'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1437 | 0 | $self->set_return( $self->smfis_tempfail() ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1438 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1439 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1440 | elsif ( $self->is_local_ip_address() ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1441 | 0 | ▶ | if ( $config->{'tempfail_on_error_local'} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1442 | 0 | $self->log_error('TempFail set'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1443 | 0 | $self->set_return( $self->smfis_tempfail() ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1444 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1445 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1446 | elsif ( $self->is_trusted_ip_address() ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1447 | 0 | ▶ | if ( $config->{'tempfail_on_error_trusted'} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1448 | 0 | $self->log_error('TempFail set'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1449 | 0 | $self->set_return( $self->smfis_tempfail() ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1450 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1451 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1452 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1453 | 24 | ▶ | if ( $config->{'tempfail_on_error'} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1454 | 24 | $self->log_error('TempFail set'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1455 | 24 | $self->set_return( $self->smfis_tempfail() ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1456 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1457 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1458 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1459 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1460 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1461 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1462 | # Common calls into other Handlers | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1463 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1464 | 156 | ▶ | sub _dequeue_dir($self) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_dequeue_dir: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1465 | 156 | my $config = $self->config(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1466 | 156 | my $dir = $config->{spool_dir}.'/dequeue'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1467 | 156 | ▶ | mkdir $dir, 0700 if ! -e $dir; ## no critic | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1468 | 156 | my $tightened = eval { Mail::Milter::Authentication::Config::secure_private_dir( $dir ) }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1469 | 156 | ▶ | if ( my $error = $@ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1470 | 2 | chomp $error; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1471 | 2 | $self->log_error( "Dequeue directory not usable: $error" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1472 | 2 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1473 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1474 | 154 | ▶ | $self->log_error( "Dequeue directory $dir was accessible to other users, mode set to 0700" ) if $tightened; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1475 | 154 | return $dir; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1476 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1477 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1478 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1479 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1480 | 143 | my $queue_index = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1481 | 70 | ▶ | sub add_dequeue($self,$key,$data) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_dequeue: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1482 | 70 | my $dir = $self->_dequeue_dir; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1483 | 70 | ▶ | return if ! $dir; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1484 | 69 | my $fullpath; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1485 | 69 | my $timestamp = join( '.',gettimeofday); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1486 | 69 | my $filename = join( '.',$key,$PID,$timestamp,$queue_index++,'dequeue'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1487 | 69 | $fullpath = "$dir/$filename"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1488 | 69 | my $serialised_data = encode_sereal($data,{croak_on_bless=>1}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1489 | 68 | write_file($fullpath,{atomic=>1,perms=>0600},$serialised_data); ## no critic | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1490 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1491 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1492 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1493 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1494 | 143 | ▶ | sub get_dequeue_list($self,$key) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_dequeue_list: called CC=11 SCAR=25.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1495 | 6 | my $dir = $self->_dequeue_dir; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1496 | 6 | ▶ | return [] if ! $dir; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1497 | 5 | my $dequeue_index_file = $dir.'/dequeue.index'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1498 | 5 | my $dequeue_lock_file = $dir.'/dequeue.lock'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1499 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1500 | 5 | my $lock = Lock::File->new( $dequeue_lock_file, {} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1501 | 5 | my $count_new = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1502 | 5 | my $count_allocated = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1503 | 5 | my $count_stale = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1504 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1505 | 5 | my $dequeue_index = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1506 | 5 | my $j = JSON->new->pretty->canonical->utf8; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1507 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1508 | # Build a list of Process IDs | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1509 | 5 | my $process_ids = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1510 | 5 | my $process_table = Proc::ProcessTable->new(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1511 | 5 | foreach my $process ( @{$process_table->table} ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1512 | 50 | $process_ids->{$process->pid} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1513 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1514 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1515 | # Read the last state from the index file | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1516 | 5 | ▶ | if ( -e $dequeue_index_file ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1517 | 0 | eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1518 | 0 | my $body = scalar read_file($dequeue_index_file); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1519 | 0 | $dequeue_index = $j->decode($body); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1520 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1521 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1522 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1523 | 5 | my @dequeue_list; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1524 | 5 | ▶ | opendir(my $dh, $dir) || die "Failed to open dequeue directory: $!"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1525 | FILE: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1526 | 5 | ▶ | while (my $file = readdir $dh) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1527 | 55 | ▶ | if ( $file =~ /^$key\..*\.dequeue$/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1528 | 40 | ▶ | if ( exists ( $dequeue_index->{ $file } ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1529 | 0 | ▶ | if ( exists $process_ids->{ $dequeue_index->{$file}->{pid} } ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1530 | # File exists in the index, and is associated with a currently valid PID | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1531 | 0 | $count_allocated++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1532 | 0 | next FILE; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1533 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1534 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1535 | 0 | $count_stale++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1536 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1537 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1538 | 40 | $dequeue_index->{$file} = { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1539 | pid => $PID, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1540 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1541 | 40 | $count_new++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1542 | 40 | push @dequeue_list, $file; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1543 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1544 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1545 | 5 | closedir $dh; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1546 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1547 | # Remove deleted files from the dequeue index | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1548 | 5 | foreach my $id ( sort keys $dequeue_index->%* ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1549 | 40 | my $filepath = join('/',$dir,$id); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1550 | 40 | ▶ | delete $dequeue_index->{$id} unless -e $filepath; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1551 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1552 | 5 | write_file($dequeue_index_file,{atomic=>1},$j->encode($dequeue_index)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1553 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1554 | 5 | $lock->unlock; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1555 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1556 | 5 | $self->metric_set( 'dequeue_files_total', { 'key' => $key, 'state' => 'new' }, $count_new - $count_stale ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1557 | 5 | $self->metric_set( 'dequeue_files_total', { 'key' => $key, 'state' => 'allocated' }, $count_allocated ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1558 | 5 | $self->metric_set( 'dequeue_files_total', { 'key' => $key, 'state' => 'stale' }, $count_stale ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1559 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1560 | 5 | return \@dequeue_list; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1561 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1562 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1563 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1564 | 42 | ▶ | sub get_dequeue($self,$id) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_dequeue: called CC=6 SCAR=18.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1565 | 42 | my $dir = $self->_dequeue_dir; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1566 | 42 | ▶ | return if ! $dir; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1567 | 42 | my $filepath = join('/',$dir,$id); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1568 | 42 | ▶ | sysopen( my $fh, $filepath, O_RDONLY | O_NOFOLLOW ) or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1569 | 41 | my @stat = stat $fh; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1570 | 41 | ▶ | if ( ! S_ISREG( $stat[2] ) || $stat[4] != $EUID ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not S_ISREG($stat[2]) or $stat[4] != $Mail::Milter::Authentication::Handler::EUID
MC/DC0%0/2
not S_ISREG($stat[2]) or $stat[4] != $Mail::Milter::Authentication::Handler::EUID
not S_ISREG($stat[2])
$stat[4] != $Mail::Milter::Authentication::Handler::EUID
Truth table33%1/3
not(A) or B
A= not S_ISREG($stat[2])B= $stat[4] != $Mail::Milter::Authentication::Handler::EUID
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1571 | 0 | $self->log_error( "Dequeue file $filepath is not a regular file owned by uid $EUID, ignoring" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1572 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1573 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1574 | 41 | my $data = eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1575 | 41 | my $serialized = scalar read_file( $fh, binmode => ':raw' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1576 | 41 | decode_sereal( $serialized, { refuse_objects => 1 } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1577 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1578 | 41 | ▶ | if ( my $error = $@ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1579 | 1 | chomp $error; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1580 | 1 | $self->log_error( "Dequeue file $filepath could not be decoded: $error" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1581 | 1 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1582 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1583 | 40 | return $data; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1584 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1585 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1586 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1587 | 38 | ▶ | sub delete_dequeue($self,$id) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
delete_dequeue: called CC=4 SCAR=14.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1588 | 38 | my $dir = $self->_dequeue_dir; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1589 | 38 | ▶ | return if ! $dir; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1590 | 38 | my $filepath = join('/',$dir,$id); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1591 | 38 | ▶ | return if ! -e $filepath; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1592 | 38 | ▶ | return if ! -f $filepath; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1593 | 38 | unlink $filepath; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1594 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1595 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1596 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1597 | 0 | ▶ | sub error_dequeue($self,$id) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
error_dequeue: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1598 | 0 | my $dir = $self->_dequeue_dir; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1599 | 0 | ▶ | return if ! $dir; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1600 | 0 | my $filepath = join('/',$dir,$id); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1601 | 0 | ▶ | return if ! -e $filepath; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1602 | 0 | ▶ | return if ! -f $filepath; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1603 | 0 | rename $filepath, $filepath . '.err'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1604 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1605 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1606 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1607 | 2 | ▶ | sub add_header_to_sanitize_list { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_header_to_sanitize_list: called CC=2 SCAR=8.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1608 | 2 | my($self,$header,$silent) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1609 | 2 | ▶ | return 0 if ! $self->is_handler_loaded('Sanitize'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1610 | 0 | return $self->get_handler('Sanitize')->add_header_to_sanitize_list($header,$silent); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1611 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1612 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1613 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1614 | 3338 | ▶ | sub is_local_ip_address { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_local_ip_address: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1615 | 3338 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1616 | 3338 | ▶ | return 0 if ! $self->is_handler_loaded('LocalIP'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1617 | 1908 | return $self->get_handler('LocalIP')->{'is_local_ip_address'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1618 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1619 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1620 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1621 | 3935 | ▶ | sub is_trusted_ip_address { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_trusted_ip_address: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1622 | 3935 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1623 | 3935 | ▶ | return 0 if ! $self->is_handler_loaded('TrustedIP'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1624 | 2275 | return $self->get_handler('TrustedIP')->{'is_trusted_ip_address'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1625 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1626 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1627 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1628 | 4 | ▶ | sub is_encrypted { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_encrypted: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1629 | 4 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1630 | 4 | ▶ | return undef if ! $self->is_handler_loaded('TLS'); ## no critic | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1631 | 4 | return $self->get_handler('TLS')->{'is_encrypted'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1632 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1633 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1634 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1635 | 2881 | ▶ | sub is_authenticated { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_authenticated: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1636 | 2881 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1637 | 2881 | ▶ | return 0 if ! $self->is_handler_loaded('Auth'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1638 | 1449 | return $self->get_handler('Auth')->{'is_authenticated'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1639 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1640 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1641 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1642 | 596 | ▶ | sub ip_address { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ip_address: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1643 | 596 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1644 | 596 | my $top_handler = $self->get_top_handler(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1645 | 596 | return $top_handler->{'ip_object'}->short(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1646 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1647 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1648 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1649 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1650 | # Header formatting and data methods | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1651 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1652 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1653 | 1692 | ▶ | sub format_ctext { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
format_ctext: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1654 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1655 | # Return ctext (but with spaces intact) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1656 | 1692 | my ( $self, $text ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1657 | 1692 | ▶ | $text = q{} if ! defined $text; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1658 | 1692 | $text =~ s/\t/ /g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1659 | 1692 | $text =~ s/\n/ /g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1660 | 1692 | $text =~ s/\r/ /g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1661 | 1692 | $text =~ s/\(/ /g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1662 | 1692 | $text =~ s/\)/ /g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1663 | 1692 | $text =~ s/\\/ /g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1664 | 1692 | return $text; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1665 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1666 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1667 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1668 | 1692 | ▶ | sub format_ctext_no_space { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
format_ctext_no_space: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1669 | 1692 | my ( $self, $text ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1670 | 1692 | $text = $self->format_ctext($text); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1671 | 1692 | $text =~ s/ //g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1672 | 1692 | $text =~ s/;/_/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1673 | 1692 | return $text; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1674 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1675 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1676 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1677 | 0 | ▶ | sub format_header_comment { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
format_header_comment: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1678 | 0 | my ( $self, $comment ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1679 | 0 | $comment = $self->format_ctext($comment); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1680 | 0 | return $comment; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1681 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1682 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1683 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1684 | 846 | ▶ | sub format_header_entry { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
format_header_entry: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1685 | 846 | my ( $self, $key, $value ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1686 | 846 | $key = $self->format_ctext_no_space($key); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1687 | 846 | $value = $self->format_ctext_no_space($value); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1688 | 846 | my $string = "$key=$value"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1689 | 846 | return $string; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1690 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1691 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1692 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1693 | 1707 | ▶ | sub get_address_xs_from ($self, $string, $args={}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_address_xs_from: called CC=10 SCAR=23.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1694 | 1707 | ▶ | unless (defined $string) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1695 | 0 | $self->dbgout( 'Address Parse Error', 'could not parse undef address', LOG_INFO ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1696 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1697 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1698 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1699 | # Milter header values arrive with bare-LF folding, which Email::Address::XS rejects inside quoted | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1700 | # strings. Restore the RFC 5322 CRLF folding (sections 3.2.2, 3.2.4), as DKIM.pm and ARC.pm do. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1701 | 1707 | $string =~ s/\015?\012/\015\012/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1702 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1703 | 1707 | my @address_objects = Email::Address::XS->parse($string); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1704 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1705 | 1707 | ▶ | unless (@address_objects) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1706 | 28 | $self->dbgout( 'Address Parse Error', 'could not parse address', LOG_INFO ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1707 | 28 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1708 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1709 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1710 | 1679 | ▶ | if ($args->{single} && scalar @address_objects != 1) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$args->{"single"} and scalar @address_objects != 1
MC/DC100%2/2
$args->{"single"} and scalar @address_objects != 1
$args->{"single"}
scalar @address_objects != 1
Truth table100%3/3
A and B
A= $args->{"single"}B= scalar @address_objects != 1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1711 | 29 | $self->dbgout( 'Address Parse Error', 'found multiple addresses', LOG_INFO ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1712 | 29 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1713 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1714 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1715 | 1650 | for my $address_object (@address_objects) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1716 | 1653 | ▶ | next if $address_object->is_valid; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1717 | 41 | $self->dbgout( 'Address Parse Error', 'address was invalid', LOG_INFO ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1718 | 41 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1719 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1720 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1721 | 1609 | for my $address_object (@address_objects) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1722 | 1612 | my $host = lc $address_object->host; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1723 | 1612 | ▶ | next if $host =~ /^[a-z0-9_\-]+(?:\.[a-z0-9_\-]+)*$/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1724 | 0 | $self->dbgout( 'Address Parse Error', 'domain failed check', LOG_INFO ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1725 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1726 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1727 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1728 | 1609 | return @address_objects; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1729 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1730 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1731 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1732 | 595 | ▶ | sub get_address_from ($self, $string) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_address_from: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1733 | 595 | my @address_objects = $self->get_address_xs_from($string, {single=>1}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1734 | 595 | ▶ | return '' unless @address_objects; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1735 | 566 | return join('@', $address_objects[0]->user, lc $address_objects[0]->host); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1736 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1737 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1738 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1739 | # Escapes non-printable ASCII and backslash as \xHH. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1740 | 6 | ▶ | sub escape_non_printable_ascii ($self, $text) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
escape_non_printable_ascii: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1741 | 6 | ▶ | utf8::encode($text) if utf8::is_utf8($text); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1742 | 6 | $text =~ s/([^\x20-\x5B\x5D-\x7E])/sprintf('\\x%02X', ord($1))/ge; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1743 | 6 | return $text; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1744 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1745 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1746 | # Unfolds header continuation lines and escapes remaining control characters | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1747 | # as \xHH, so a logged value cannot start a new log line. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1748 | 94115 | ▶ | sub escape_for_log ($self, $text) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
escape_for_log: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1749 | 94115 | $text =~ s/\r?\n[ \t]+/ /g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1750 | 94115 | $text =~ s/([\x00-\x1F\x7F])/sprintf('\\x%02X', ord($1))/ge; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1751 | 94115 | return $text; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1752 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1753 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1754 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1755 | 862 | ▶ | sub get_domain_from ($self, $string) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_domain_from: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1756 | 862 | my @address_objects = $self->get_address_xs_from($string, {single=>1}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1757 | 862 | ▶ | return '' unless @address_objects; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1758 | 823 | return lc $address_objects[0]->host; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1759 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1760 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1761 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1762 | 157 | ▶ | sub get_domains_from ($self, $string) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_domains_from: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1763 | 157 | my @address_objects = $self->get_address_xs_from($string); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1764 | 157 | ▶ | return [] unless @address_objects; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1765 | 147 | my @hosts = map {lc $_->host} @address_objects; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1766 | 147 | return \@hosts; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1767 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1768 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1769 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1770 | 93 | ▶ | sub get_addresses_from ($self, $string) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_addresses_from: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1771 | 93 | my @address_objects = $self->get_address_xs_from($string); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1772 | 93 | ▶ | return [] unless @address_objects; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1773 | 73 | my @addresses = map {join('@', $_->user, lc $_->host)} @address_objects; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1774 | 73 | return \@addresses; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1775 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1776 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1777 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1778 | 530 | ▶ | sub get_my_hostname { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_my_hostname: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1779 | 530 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1780 | 530 | my $hostname = $self->get_symbol('j'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1781 | 530 | ▶ | if ( ! $hostname ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1782 | 404 | $hostname = $self->get_symbol('{rcpt_host}'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1783 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1784 | 530 | ▶ | if ( ! $hostname ) { # Fallback | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1785 | 404 | $hostname = hostname; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1786 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1787 | 530 | return $hostname; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1788 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1789 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1790 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1791 | 381 | ▶ | sub get_my_authserv_id { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_my_authserv_id: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1792 | 381 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1793 | 381 | my $config = $self->config(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1794 | 381 | ▶ | if ( exists( $config->{'authserv_id'} ) && $config->{'authserv_id'} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
exists $config->{"authserv_id"} and $config->{"authserv_id"}
MC/DC50%1/2
exists $config->{"authserv_id"} and $config->{"authserv_id"}
exists $config->{"authserv_id"}
$config->{"authserv_id"}
Truth table66%2/3
A and B
A= exists $config->{"authserv_id"}B= $config->{"authserv_id"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1795 | 22 | return $config->{'authserv_id'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1796 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1797 | 359 | return $self->get_my_hostname(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1798 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1799 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1800 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1801 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1802 | # Logging | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1803 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1804 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1805 | 47054 | ▶ | sub dbgout { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
dbgout: called CC=20 SCAR=31.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1806 | 47054 | my ( $self, $key, $value, $priority ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1807 | 47054 | ▶ | my $queue_id = $self->get_symbol('i') || q{--}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$self->get_symbol('i') || '--'
MC/DC100%1/1
$self->get_symbol('i') || '--'
$self->get_symbol('i')
Truth table100%2/2
A
A= $self->get_symbol('i')
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1808 | 47054 | ▶ | $key = q{--} if ! defined $key; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1809 | 47054 | ▶ | $value = q{--} if ! defined $value; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1810 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1811 | # Keep each entry on one line, values may be folded headers or DNS data | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1812 | 47054 | $key = $self->escape_for_log( $key ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1813 | 47054 | $value = $self->escape_for_log( $value ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1814 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1815 | 47054 | my $thischild = $self->{'thischild'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1816 | 47054 | ▶ | if ( exists $thischild->{'tracelog'} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1817 | 23868 | push $thischild->{'tracelog'}->@*, [ time, "$queue_id: $key: $value" ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1818 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1819 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1820 | 47054 | my $config = $self->config(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1821 | 47054 | ▶ | if ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$priority == 7 and not $config->{"debug"}
MC/DC100%2/2
$priority == 7 and not $config->{"debug"}
$priority == 7
not $config->{"debug"}
Truth table100%3/3
A and not(B)
A= $priority == 7B= not $config->{"debug"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1822 | $priority == LOG_DEBUG | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1823 | && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1824 | ! $config->{'debug'} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1825 | ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1826 | 23625 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1827 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1828 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1829 | # Sys::Syslog and Log::Dispatchouli have different priority models | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1830 | 23429 | ▶ | my $log_priority = $priority == LOG_DEBUG ? 'debug' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 8 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1831 | : $priority == LOG_INFO ? 'info' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1832 | : $priority == LOG_NOTICE ? 'notice' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1833 | : $priority == LOG_WARNING ? 'warning' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1834 | : $priority == LOG_ERR ? 'error' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1835 | : $priority == LOG_CRIT ? 'critical' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1836 | : $priority == LOG_ALERT ? 'alert' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1837 | : $priority == LOG_EMERG ? 'emergency' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1838 | : 'info'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1839 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1840 | 23429 | ▶ | if ( $config->{'logtoerr'} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1841 | 23429 | Mail::Milter::Authentication::_warn( "$queue_id: $key: $value" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1842 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1843 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1844 | 23429 | my $top_handler = $self->get_top_handler(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1845 | 23429 | ▶ | if ( !exists( $top_handler->{'dbgout'} ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1846 | 1206 | $top_handler->{'dbgout'} = []; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1847 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1848 | 23429 | ▶ | push @{ $top_handler->{'dbgout'} }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition75%3/4
$key || ''
$value || ''
MC/DC0%0/1
$key || ''
$key
MC/DC100%1/1
$value || ''
$value
Truth table50%1/2
A
A= $key
Truth table100%2/2
A
A= $value
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1849 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1850 | 'priority' => $log_priority, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1851 | 'key' => $key || q{}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1852 | 'value' => $value || q{}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1853 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1854 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1855 | # Write now if we can. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1856 | 23429 | ▶ | if ( $self->get_symbol('i') ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1857 | 308 | $self->dbgoutwrite(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1858 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1859 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1860 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1861 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1862 | 184 | ▶ | sub log_error { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
log_error: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1863 | 184 | my ( $self, $error ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1864 | 184 | $self->dbgout( 'ERROR', $error, LOG_ERR ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1865 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1866 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1867 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1868 | 1515 | ▶ | sub dbgoutwrite { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
dbgoutwrite: called CC=6 SCAR=18.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1869 | 1515 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1870 | 1515 | eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1871 | 1515 | my $config = $self->config(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1872 | 1515 | ▶ | my $queue_id = $self->get_symbol('i') || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$self->get_symbol('i') || 'NOQUEUE.' . substr(uc md5_hex("Authentication Milter Client $Mail::Milter::Authentication::Handler::PID " . time . rand(100)), -11)
MC/DC100%1/1
$self->get_symbol('i') || 'NOQUEUE.' . substr(uc md5_hex("Authentication Milter Client $Mail::Milter::Authentication::Handler::PID " . time . rand(100)), -11)
$self->get_symbol('i')
Truth table100%2/2
A
A= $self->get_symbol('i')
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1873 | 'NOQUEUE.' . substr( uc md5_hex( "Authentication Milter Client $PID " . time() . rand(100) ) , -11 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1874 | 1515 | my $top_handler = $self->get_top_handler(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1875 | 1515 | ▶ | if ( exists( $top_handler->{'dbgout'} ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1876 | LOGENTRY: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1877 | 1172 | foreach my $entry ( @{ $top_handler->{'dbgout'} } ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1878 | 23054 | my $key = $entry->{'key'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1879 | 23054 | my $value = $entry->{'value'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1880 | 23054 | my $priority = $entry->{'priority'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1881 | 23054 | my $line = "$queue_id: $key: $value"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1882 | 23054 | ▶ | if ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$priority eq "debug" and not $config->{"debug"}
MC/DC0%0/2
$priority eq "debug" and not $config->{"debug"}
$priority eq "debug"
not $config->{"debug"}
Truth table66%2/3
A and not(B)
A= $priority eq "debug"B= not $config->{"debug"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1883 | $priority eq 'debug' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1884 | && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1885 | ! $config->{'debug'} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1886 | ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1887 | 0 | next LOGENTRY; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1888 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1889 | 23054 | Mail::Milter::Authentication::logger()->log( { 'level' => $priority }, $line ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1890 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1891 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1892 | 1515 | delete $top_handler->{'dbgout'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1893 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1894 | 1515 | $self->handle_exception( $@ ); # Not usually called within an eval, however we shouldn't | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1895 | # ever get a Timeout (for example) here, so it is safe to | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1896 | # pass to handle_exception anyway. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1897 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1898 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1899 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1900 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1901 | # Header handling | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1902 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1903 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1904 | 694 | ▶ | sub can_sort_header { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
can_sort_header: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1905 | 694 | my ( $self, $header ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1906 | 694 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1907 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1908 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1909 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1910 | 1809 | ▶ | sub header_sort { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
header_sort: called CC=7 SCAR=20.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1911 | 1809 | my ( $self, $sa, $sb ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1912 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1913 | 1809 | my $config = $self->config(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1914 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1915 | 1809 | my $string_a; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1916 | my $string_b; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1917 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1918 | 1809 | my $handler_a; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1919 | 1809 | ▶ | if ( ref $sa eq 'Mail::AuthenticationResults::Header::Entry' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1920 | 1809 | $handler_a = $sa->key(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1921 | 1809 | $string_a = $sa->as_string(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1922 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1923 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1924 | 0 | ( $handler_a ) = split( '=', $sa, 2 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1925 | 0 | $string_a = $sa; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1926 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1927 | 1809 | my $handler_b; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1928 | 1809 | ▶ | if ( ref $sb eq 'Mail::AuthenticationResults::Header::Entry' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1929 | 1809 | $handler_b = $sb->key(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1930 | 1809 | $string_b = $sb->as_string(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1931 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1932 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1933 | 0 | ( $handler_b ) = split( '=', $sb, 2 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1934 | 0 | $string_b = $sb; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1935 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1936 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1937 | 1809 | ▶ | if ( $handler_a eq $handler_b ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1938 | # Check for a handler specific sort method | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1939 | 552 | foreach my $name ( @{$config->{'load_handlers'}} ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1940 | 1214 | my $handler = $self->get_handler($name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1941 | 1214 | ▶ | if ( $handler->can_sort_header( lc $handler_a ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1942 | 519 | ▶ | if ( $handler->can( 'handler_header_sort' ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1943 | 519 | return $handler->handler_header_sort( $sa, $sb ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1944 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1945 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1946 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1947 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1948 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1949 | 1290 | return $string_a cmp $string_b; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1950 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1951 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1952 | 0 | ▶ | sub _stringify_header { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_stringify_header: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1953 | 0 | my ( $self, $header ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1954 | 0 | ▶ | if ( ref $header eq 'Mail::AuthenticationResults::Header::Entry' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1955 | 0 | return $header->as_string(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1956 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1957 | 0 | return $header; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1958 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1959 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1960 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1961 | 342 | ▶ | sub add_headers { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_headers: called CC=11 SCAR=24.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1962 | 342 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1963 | 342 | my $config = $self->config(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1964 | 342 | my $top_handler = $self->get_top_handler(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1965 | 342 | my @types; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1966 | 342 | ▶ | push @types, keys $top_handler->{'c_auth_headers'}->%* if exists $top_handler->{'c_auth_headers'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1967 | 342 | ▶ | push @types, keys $top_handler->{'auth_headers'}->%* if exists $top_handler->{'auth_headers'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1968 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1969 | 342 | ▶ | my $queue_id = $self->get_symbol('i') || q{--}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$self->get_symbol('i') || '--'
MC/DC100%1/1
$self->get_symbol('i') || '--'
$self->get_symbol('i')
Truth table100%2/2
A
A= $self->get_symbol('i')
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1970 | 342 | $self->{extended_log} = {ar => [], queue_id => $queue_id}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1971 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1972 | 342 | for my $type (uniq sort @types) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1973 | 321 | $self->add_auth_headers_of_type($type); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1974 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1975 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1976 | 342 | ▶ | if ($config->{extended_log}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1977 | 0 | my $j = JSON->new->canonical->utf8; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1978 | 0 | $self->dbgout( 'ARex',$j->encode($self->{extended_log}), LOG_INFO ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1979 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1980 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1981 | 342 | ▶ | if ( my $reason = $self->get_quarantine_mail() ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1982 | 41 | $self->prepend_header( 'X-Disposition-Quarantine', $reason ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1983 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1984 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1985 | 342 | $top_handler->top_addheader_callback(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1986 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1987 | 342 | ▶ | if ( exists( $top_handler->{'pre_headers'} ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1988 | 321 | foreach my $header ( @{ $top_handler->{'pre_headers'} } ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1989 | $self->dbgout( 'PreHeader', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1990 | 564 | $header->{'field'} . ': ' . $header->{'value'}, LOG_DEBUG ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1991 | 564 | $self->insert_header( 1, $header->{'field'}, $header->{'value'} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1992 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1993 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1994 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1995 | 342 | ▶ | if ( exists( $top_handler->{'add_headers'} ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1996 | 9 | foreach my $header ( @{ $top_handler->{'add_headers'} } ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1997 | $self->dbgout( 'AddHeader', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1998 | 24 | $header->{'field'} . ': ' . $header->{'value'}, LOG_DEBUG ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1999 | 24 | $self->add_header( $header->{'field'}, $header->{'value'} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2000 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2001 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2002 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2003 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2004 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2005 | 321 | ▶ | sub add_auth_headers_of_type($self,$type) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_auth_headers_of_type: called CC=15 SCAR=32.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2006 | 321 | my $config = $self->config(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2007 | 321 | my $top_handler = $self->get_top_handler(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2008 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2009 | 321 | my @auth_headers; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2010 | 321 | ▶ | if ( exists( $top_handler->{'c_auth_headers'}->{$type} ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2011 | 103 | @auth_headers = @{ $top_handler->{'c_auth_headers'}->{$type} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2012 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2013 | 321 | ▶ | if ( exists( $top_handler->{'auth_headers'}->{$type} ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2014 | 284 | @auth_headers = ( @auth_headers, @{ $top_handler->{'auth_headers'}->{$type} } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2015 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2016 | 321 | ▶ | if (@auth_headers) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2017 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2018 | 321 | @auth_headers = sort { $self->header_sort( $a, $b ) } @auth_headers; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2019 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2020 | # Do we have any legacy type headers? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2021 | 321 | my $are_string_headers = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2022 | 321 | my $header_obj = Mail::AuthenticationResults::Header->new(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2023 | 321 | foreach my $header ( @auth_headers ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2024 | 1150 | ▶ | if ( ref $header ne 'Mail::AuthenticationResults::Header::Entry' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2025 | 0 | $are_string_headers = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2026 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2027 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2028 | 1150 | ▶ | $header->orphan() if exists $header->{parent}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2029 | 1150 | $header_obj->add_child( $header ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2030 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2031 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2032 | 321 | my $header_text; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2033 | 321 | ▶ | if ( $are_string_headers ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2034 | # We have legacy headers, add in a legacy way | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2035 | 0 | $header_text = $self->get_my_authserv_id(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2036 | 0 | $header_text .= ";\n "; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2037 | 0 | $header_text .= join( ";\n ", map { $self->_stringify_header( $_ ) } @auth_headers ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2038 | 0 | $self->dbgout( 'auth header added: $type: ',$header_text, LOG_INFO ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2039 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2040 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2041 | 321 | $header_obj->set_value( Mail::AuthenticationResults::Header::AuthServID->new()->safe_set_value( $self->get_my_authserv_id() ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2042 | 321 | $header_obj->set_eol( "\n" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2043 | 321 | ▶ | if ( exists( $config->{'header_indent_style'} ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2044 | 0 | $header_obj->set_indent_style( $config->{'header_indent_style'} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2045 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2046 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2047 | 321 | $header_obj->set_indent_style( 'entry' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2048 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2049 | 321 | ▶ | if ( exists( $config->{'header_indent_by'} ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2050 | 0 | $header_obj->set_indent_by( $config->{'header_indent_by'} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2051 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2052 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2053 | 321 | $header_obj->set_indent_by( 4 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2054 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2055 | 321 | ▶ | if ( exists( $config->{'header_fold_at'} ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2056 | 0 | $header_obj->set_fold_at( $config->{'header_fold_at'} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2057 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2058 | 321 | $header_text = $header_obj->as_string(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2059 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2060 | # Log a single line version of the added auth header | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2061 | 321 | $header_obj->set_indent_style('none'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2062 | 321 | $header_obj->set_fold_at(9999); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2063 | 321 | my $header_log_text = $header_obj->as_string(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2064 | 321 | ▶ | $self->dbgout( "A-R: $type",$header_log_text, LOG_INFO ) unless $config->{extended_log} && ! $config->{legacy_log}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$config->{"extended_log"} and not $config->{"legacy_log"}
MC/DC0%0/2
$config->{"extended_log"} and not $config->{"legacy_log"}
$config->{"extended_log"}
not $config->{"legacy_log"}
Truth table33%1/3
A and not(B)
A= $config->{"extended_log"}B= not $config->{"legacy_log"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2065 | 321 | ▶ | push $self->{extended_log}->{ar}->@*, {type => $type, payload =>$header_obj->_as_hashref} if $config->{extended_log}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2066 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2067 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2068 | 321 | my ($header_type,$header_type_postfix) = split /:/, $type; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2069 | 321 | $self->prepend_header( $header_type, $header_text ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2070 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2071 | elsif ( !$config->{'hide_none'} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2072 | 0 | my $header_text = $self->get_my_authserv_id(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2073 | 0 | $header_text .= '; none'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2074 | 0 | my ($header_type,$header_type_postfix) = split /:/, $type; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2075 | 0 | $self->prepend_header( $header_type, $header_text ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2076 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2077 | # the result is none and hide_none is set, so we do not add an AR header | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2078 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2079 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2080 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2081 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2082 | 531 | ▶ | sub prepend_header { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
prepend_header: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2083 | 531 | my ( $self, $field, $value ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2084 | 531 | my $top_handler = $self->get_top_handler(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2085 | 531 | ▶ | if ( !exists( $top_handler->{'pre_headers'} ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2086 | 321 | $top_handler->{'pre_headers'} = []; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2087 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2088 | 531 | push @{ $top_handler->{'pre_headers'} }, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2089 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2090 | 'field' => $field, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2091 | 'value' => $value, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2092 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2093 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2094 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2095 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2096 | 988 | ▶ | sub add_auth_header($self,$value) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_auth_header: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2097 | 988 | my $config = $self->handler_config(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2098 | 988 | ▶ | my $header_name = $config->{auth_header_name} // 'Authentication-Results'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$config->{"auth_header_name"} // "Authentication-Results"
MC/DC0%0/1
$config->{"auth_header_name"} // "Authentication-Results"
$config->{"auth_header_name"}
Truth table50%1/2
A
A= $config->{"auth_header_name"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2099 | 988 | my $top_handler = $self->get_top_handler(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2100 | 988 | ▶ | $top_handler->{auth_headers} = {} unless exists $top_handler->{auth_headers}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2101 | 988 | ▶ | $top_handler->{auth_headers}->{$header_name} = [] unless exists $top_handler->{auth_headers}->{$header_name}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2102 | 988 | push $top_handler->{auth_headers}->{$header_name}->@*, $value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2103 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2104 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2105 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2106 | 162 | ▶ | sub add_c_auth_header($self,$value) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_c_auth_header: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2107 | # Connection wide auth headers | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2108 | 162 | my $config = $self->handler_config(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2109 | 162 | ▶ | my $header_name = $config->{auth_header_name} // 'Authentication-Results'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$config->{"auth_header_name"} // "Authentication-Results"
MC/DC0%0/1
$config->{"auth_header_name"} // "Authentication-Results"
$config->{"auth_header_name"}
Truth table50%1/2
A
A= $config->{"auth_header_name"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2110 | 162 | my $top_handler = $self->get_top_handler(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2111 | 162 | ▶ | $top_handler->{c_auth_headers} = {} unless exists $top_handler->{c_auth_headers}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2112 | 162 | ▶ | $top_handler->{c_auth_headers}->{$header_name} = [] unless exists $top_handler->{c_auth_headers}->{$header_name}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2113 | 162 | push $top_handler->{c_auth_headers}->{$header_name}->@*, $value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2114 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2115 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2116 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2117 | 24 | ▶ | sub append_header { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
append_header: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2118 | 24 | my ( $self, $field, $value ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2119 | 24 | my $top_handler = $self->get_top_handler(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2120 | 24 | ▶ | if ( !exists( $top_handler->{'add_headers'} ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2121 | 9 | $top_handler->{'add_headers'} = []; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2122 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2123 | 24 | push @{ $top_handler->{'add_headers'} }, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2124 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2125 | 'field' => $field, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2126 | 'value' => $value, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2127 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2128 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2129 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2130 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2131 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2132 | # Lower level methods | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2133 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2134 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2135 | 4830 | ▶ | sub smfis_continue { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
smfis_continue: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2136 | 4830 | return SMFIS_CONTINUE; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2137 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2138 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2139 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2140 | 33 | ▶ | sub smfis_tempfail { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
smfis_tempfail: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2141 | 33 | return SMFIS_TEMPFAIL; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2142 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2143 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2144 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2145 | 15 | ▶ | sub smfis_reject { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
smfis_reject: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2146 | 15 | return SMFIS_REJECT; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2147 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2148 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2149 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2150 | 0 | ▶ | sub smfis_discard { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
smfis_discard: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2151 | 0 | return SMFIS_DISCARD; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2152 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2153 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2154 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2155 | 0 | ▶ | sub smfis_accept { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
smfis_accept: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2156 | 0 | return SMFIS_ACCEPT; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2157 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2158 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2159 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2160 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2161 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2162 | 0 | ▶ | sub write_packet { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
write_packet: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2163 | 0 | my ( $self, $type, $data ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2164 | 0 | my $thischild = $self->{'thischild'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2165 | 0 | $thischild->write_packet( $type, $data ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2166 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2167 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2168 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2169 | 24 | ▶ | sub add_header { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_header: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2170 | 24 | my ( $self, $key, $value ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2171 | 24 | my $thischild = $self->{'thischild'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2172 | 24 | my $config = $self->config(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2173 | 24 | ▶ | return if $config->{'dryrun'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2174 | 24 | $thischild->add_header( $key, $value ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2175 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2176 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2177 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2178 | 564 | ▶ | sub insert_header { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
insert_header: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2179 | 564 | my ( $self, $index, $key, $value ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2180 | 564 | my $thischild = $self->{'thischild'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2181 | 564 | my $config = $self->config(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2182 | 564 | ▶ | return if $config->{'dryrun'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2183 | 560 | $thischild->insert_header( $index, $key, $value ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2184 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2185 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2186 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2187 | 31 | ▶ | sub change_header { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
change_header: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2188 | 31 | my ( $self, $key, $index, $value ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2189 | 31 | my $thischild = $self->{'thischild'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2190 | 31 | my $config = $self->config(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2191 | 31 | ▶ | return if $config->{'dryrun'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2192 | 31 | $thischild->change_header( $key, $index, $value ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2193 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2194 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2195 | 143 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2196 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2197 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||