| 1 | 1 | ▶ | use 5.014; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 2 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||||||||||||||||
| 4 | package Mail::Qmail::Filter::CheckDeliverability; | ||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||
| 6 | 1 | our $VERSION = '1.02'; | |||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use Mo qw(coerce default); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | 1 | extends 'Mail::Qmail::Filter'; | |||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||
| 11 | 1 | has 'reject_text' => 'Recipient unknown.'; | |||||||||||||||||||||||||||||||||||||||||
| 12 | 1 | has 'run_commands_matching'; | |||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||
| 14 | 0 | ▶ | sub filter { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
filter: not called CC=23 SCAR=63.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 15 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 16 | 0 | my $message = $self->message; | |||||||||||||||||||||||||||||||||||||||||
| 17 | 0 | my $run_commands_matching = $self->run_commands_matching; | |||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||
| 19 | 0 | ▶ | require Qmail::Deliverable and Qmail::Deliverable->import('dot_qmail') | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
defined &Mail::Qmail::Filter::CheckDeliverability::dot_qmail || require Qmail::Deliverable && 'Qmail::Deliverable'->import('dot_qmail')
require Qmail::Deliverable and "Qmail::Deliverable"->import("dot_qmail")
MC/DC0%0/3
defined &Mail::Qmail::Filter::CheckDeliverability::dot_qmail || require Qmail::Deliverable && 'Qmail::Deliverable'->import('dot_qmail')
defined &Mail::Qmail::Filter::CheckDeliverability::dot_qmail
require Qmail::Deliverable
"Qmail::Deliverable"->import("dot_qmail")
Truth table0%0/4
A || B and C
A= defined &Mail::Qmail::Filter::CheckDeliverability::dot_qmailB= require Qmail::DeliverableC= "Qmail::Deliverable"->import("dot_qmail")
| |||||||||||||||||||||||||||||||||||||||||||
| 20 | unless defined &dot_qmail; | ||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||
| 22 | 0 | my ( %done, $reject_text, $valid ); | |||||||||||||||||||||||||||||||||||||||||
| 23 | 0 | Recipient: for ( $message->to ) { | |||||||||||||||||||||||||||||||||||||||||
| 24 | 0 | my $dot_qmail = dot_qmail($_); | |||||||||||||||||||||||||||||||||||||||||
| 25 | 0 | ▶ | unless ( defined $dot_qmail ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 26 | 0 | $self->debug( 'No .qmail file found for rcpt' => $_ ); | |||||||||||||||||||||||||||||||||||||||||
| 27 | 0 | $reject_text = $self->reject_text; | |||||||||||||||||||||||||||||||||||||||||
| 28 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||
| 29 | } | ||||||||||||||||||||||||||||||||||||||||||
| 30 | 0 | ▶ | next if $done{$dot_qmail}++; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 31 | 0 | ▶ | open my $fh, '<', $dot_qmail | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 32 | or return $self->debug( "Cannot read $dot_qmail", $! ); | ||||||||||||||||||||||||||||||||||||||||||
| 33 | 0 | $self->debug( "Checking .qmail for $_" => $dot_qmail ); | |||||||||||||||||||||||||||||||||||||||||
| 34 | 0 | ▶ | while ( defined( my $line = <$fh> ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||
| 36 | 0 | ▶ | next if $line =~ /^#/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 37 | 0 | ++$valid; | |||||||||||||||||||||||||||||||||||||||||
| 38 | 0 | chomp $line; | |||||||||||||||||||||||||||||||||||||||||
| 39 | 0 | ▶ | return $self->debug( "$_ is at least deliverable to" => $line ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 40 | if $line =~ m{^[&/\w]}; | ||||||||||||||||||||||||||||||||||||||||||
| 41 | next | ||||||||||||||||||||||||||||||||||||||||||
| 42 | 0 | ▶ | unless $line =~ /^\|/ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$line =~ /^\|/u and defined $run_commands_matching and $line =~ /$run_commands_matching/u
$line =~ /^\|/u and defined $run_commands_matching
MC/DC0%0/3
$line =~ /^\|/u and defined $run_commands_matching and $line =~ /$run_commands_matching/u
$line =~ /^\|/u
defined $run_commands_matching
$line =~ /$run_commands_matching/u
Truth table0%0/4
A and B and C
A= $line =~ /^\|/uB= defined $run_commands_matchingC= $line =~ /$run_commands_matching/u
| |||||||||||||||||||||||||||||||||||||||||||
| 43 | && defined $run_commands_matching | ||||||||||||||||||||||||||||||||||||||||||
| 44 | && $line =~ $run_commands_matching; | ||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||
| 46 | require Capture::Tiny | ||||||||||||||||||||||||||||||||||||||||||
| 47 | 0 | ▶ | and Capture::Tiny->import('capture_merged') | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
defined &Mail::Qmail::Filter::CheckDeliverability::capture_merged || require Capture::Tiny && 'Capture::Tiny'->import('capture_merged')
require Capture::Tiny and "Capture::Tiny"->import("capture_merged")
MC/DC0%0/3
defined &Mail::Qmail::Filter::CheckDeliverability::capture_merged || require Capture::Tiny && 'Capture::Tiny'->import('capture_merged')
defined &Mail::Qmail::Filter::CheckDeliverability::capture_merged
require Capture::Tiny
"Capture::Tiny"->import("capture_merged")
Truth table0%0/4
A || B and C
A= defined &Mail::Qmail::Filter::CheckDeliverability::capture_mergedB= require Capture::TinyC= "Capture::Tiny"->import("capture_merged")
| |||||||||||||||||||||||||||||||||||||||||||
| 48 | unless defined &capture_merged; | ||||||||||||||||||||||||||||||||||||||||||
| 49 | 0 | local $ENV{SENDER} = $message->from; | |||||||||||||||||||||||||||||||||||||||||
| 50 | my ( $output, $exitcode ) = capture_merged( | ||||||||||||||||||||||||||||||||||||||||||
| 51 | 0 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 52 | 0 | ▶ | open my $fh, $line | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 53 | or return $self->debug( "Cannot start $line", $! ); | ||||||||||||||||||||||||||||||||||||||||||
| 54 | 0 | print $fh $message->body; | |||||||||||||||||||||||||||||||||||||||||
| 55 | 0 | close $fh; | |||||||||||||||||||||||||||||||||||||||||
| 56 | 0 | $?; | |||||||||||||||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||||||||||||||||
| 58 | 0 | ); | |||||||||||||||||||||||||||||||||||||||||
| 59 | 0 | $output = join '/', split /\n/, $output; | |||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | $exitcode >>= 8; | |||||||||||||||||||||||||||||||||||||||||
| 61 | 0 | $self->debug( qq("$line") => $exitcode ); | |||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | ▶ | last if $exitcode == 99; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | ▶ | return $self->debug("Calling $line for $_ resulted in soft failure") | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 64 | if $exitcode == 111; | ||||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | ▶ | next unless $exitcode == 100; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | ▶ | unless ( defined $reject_text ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | $reject_text = $output; | |||||||||||||||||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | elsif ( $output ne $reject_text ) { | |||||||||||||||||||||||||||||||||||||||||
| 70 | 0 | return $self->debug( | |||||||||||||||||||||||||||||||||||||||||
| 71 | qq(Different reject texts: "$reject_text" vs. "$output")); | ||||||||||||||||||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||||||||||||||||
| 73 | 0 | next Recipient; | |||||||||||||||||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | ▶ | return $self->debug("might be deliverable to <$_>") if $valid; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | ▶ | $self->reject($reject_text) if defined $reject_text; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | ▶ | $self->reject( $self->reject_text ) unless $valid; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||
| 82 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||
| 84 | __END__ | ||||||||||||||||||||||||||||||||||||||||||