| 1 | 15 | ▶ | use 5.006; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 15 | ▶ | use strict; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | package Mail::Audit; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 15 | $Mail::Audit::VERSION = '2.228'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | # ABSTRACT: library for creating easy mail filters | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 15 | ▶ | use Carp (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 15 | ▶ | use File::Basename (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 15 | ▶ | use File::HomeDir 0.61 (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 15 | ▶ | use File::Spec (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 15 | ▶ | use Mail::Audit::MailInternet (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 15 | ▶ | use Mail::Internet (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 15 | ▶ | use Symbol (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 15 | ▶ | use Sys::Hostname (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 15 | ▶ | use Fcntl ':flock'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 15 | ▶ | use constant REJECTED => 100; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 15 | ▶ | use constant DEFERRED => 75; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 15 | ▶ | use constant DELIVERED => 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 13 | ▶ | sub import { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
import: called CC=3 SCAR=17.3
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 13 | my ($pkg, @plugins) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 13 | for (@plugins) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 0 | eval "use $pkg\::$_"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 0 | ▶ | die $@ if $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 99 | ▶ | sub _log { shift->log(@_) } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_log: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 23 | ▶ | sub _get_opt { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_opt: called CC=5 SCAR=17.8
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 23 | my ($self, $arg) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 23 | my $opt; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 23 | ▶ | if (ref $arg->[0] eq 'HASH') { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 0 | ▶ | Carp::carp "prepending arguments is deprecated; append them instead" | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | unless @$arg == 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 0 | $opt = shift @$arg; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | } elsif (ref $arg->[-1] eq 'HASH') { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 13 | $opt = pop @$arg; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 23 | ▶ | return $opt || {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$opt || {}
MC/DC100%1/1
$opt || {}
$opt
Truth table100%2/2
A
A= $opt
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 9 | ▶ | my $default_mime_test = sub { $_[0]->get("MIME-Version") }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 9 | ▶ | sub new { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=17 SCAR=30.2
Pod
documented
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 9 | my $class = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 9 | my %opts = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 9 | ▶ | my $type = ref($class) || $class; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
ref $class || $class
MC/DC0%0/2
ref $class || $class
ref $class
$class
Truth table33%1/3
A || B
A= ref $classB= $class
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 9 | ▶ | my $mime_test = (delete $opts{mime_test}) || $default_mime_test; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
delete $opts{'mime_test'} || $default_mime_test
MC/DC0%0/2
delete $opts{'mime_test'} || $default_mime_test
delete $opts{'mime_test'}
$default_mime_test
Truth table33%1/3
A || B
A= delete $opts{'mime_test'}B= $default_mime_test
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | my $self = Mail::Audit::MailInternet->new( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 9 | ▶ | (exists $opts{data} ? $opts{data} : \*STDIN), | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | Modify => 0 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | # set up logging | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 9 | ▶ | unless ($opts{no_log}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 9 | my $log = {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 9 | ▶ | $log->{level} = exists $opts{loglevel} ? $opts{loglevel} : 3; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | $log->{file} = exists $opts{log} | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | ? $opts{log} | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 9 | ▶ | : File::Spec->catfile( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | File::HomeDir->my_home, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | "mail-audit.log" | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 9 | my $output_fh; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 9 | ▶ | if ($log->{file} and open $output_fh, '>>', $log->{file}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$log->{"file"} and open $output_fh, ">>", $log->{"file"}
MC/DC50%1/2
$log->{"file"} and open $output_fh, ">>", $log->{"file"}
$log->{"file"}
open $output_fh, ">>", $log->{"file"}
Truth table66%2/3
A and B
A= $log->{"file"}B= open $output_fh, ">>", $log->{"file"}
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 7 | $log->{fh} = $output_fh; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | } else { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 2 | ▶ | warn "couldn't open $log->{file} to log: $!" if $log->{file}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 2 | $log->{fh} = \*STDERR; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | # This sucks, but the gut-construction order does, too. We need to make it | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | # saner in general. -- rjbs, 2006-06-04 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 9 | $self->{_log} = $log; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 9 | $self->_log(1, "------------------------------ new run at " . localtime); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 9 | $self->_log(2, " From: " . ($self->get("from"))); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 9 | $self->_log(2, " To: " . ($self->get("to"))); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 9 | $self->_log(2, "Subject: " . ($self->get("subject"))); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | # do we have a MIME-Version header? | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | # if so, we subclass MIME::Entity. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | # if not, we remain Mail::Internet, and, presumably, diminish, and go | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | # into the West. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 9 | ▶ | if ($opts{alwaysmime} or $mime_test->($self)) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$opts{"alwaysmime"} or &$mime_test($self)
MC/DC50%1/2
$opts{"alwaysmime"} or &$mime_test($self)
$opts{"alwaysmime"}
&$mime_test($self)
Truth table66%2/3
A or B
A= $opts{"alwaysmime"}B= &$mime_test($self)
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 1 | ▶ | unless ($opts{nomime}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 1 | $self->_log(3, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | "message is MIME. MIME-Version is " . ($self->get("MIME-Version")) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 1 | eval { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 1 | require Mail::Audit::MimeEntity; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 1 | Mail::Audit::MimeEntity->import; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 1 | ▶ | die "$@" if $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 1 | $self = Mail::Audit::MimeEntity->_autotype_new($self, $opts{mimeoptions}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | } else { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 0 | $self->_log(3, "message is MIME, but 'nomime' option was set."); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 9 | ($self->{_hostname} = Sys::Hostname::hostname) =~ s/\..*//; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 9 | $self->{_audit_opts} = \%opts; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 9 | ▶ | $self->{_audit_opts}->{noexit} ||= 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->{"_audit_opts"}{"noexit"} ||= 0
MC/DC0%0/1
$self->{"_audit_opts"}{"noexit"} ||= 0
$self->{"_audit_opts"}{"noexit"}
Truth table50%1/2
A
A= $self->{"_audit_opts"}{"noexit"}
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 9 | ▶ | $self->{_audit_opts}->{interpolate_strftime} ||= 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->{"_audit_opts"}{"interpolate_strftime"} ||= 0
MC/DC0%0/1
$self->{"_audit_opts"}{"interpolate_strftime"} ||= 0
$self->{"_audit_opts"}{"interpolate_strftime"}
Truth table50%1/2
A
A= $self->{"_audit_opts"}{"interpolate_strftime"}
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 9 | ▶ | $self->{_audit_opts}->{one_for_all} ||= 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->{"_audit_opts"}{"one_for_all"} ||= 0
MC/DC0%0/1
$self->{"_audit_opts"}{"one_for_all"} ||= 0
$self->{"_audit_opts"}{"one_for_all"}
Truth table50%1/2
A
A= $self->{"_audit_opts"}{"one_for_all"}
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 9 | return $self; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 1 | ▶ | sub _emergency_mbox { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_emergency_mbox: called CC=2 SCAR=8.1
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 1 | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | return $self->{_audit_opts}->{emergency} | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 1 | ▶ | if exists $self->{_audit_opts}->{emergency}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | return $self->{_audit_opts}->{emergency} = $self->_default_mbox; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 0 | ▶ | sub _default_mbox { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_default_mbox: not called CC=5 SCAR=34.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | ▶ | return $self->{_default_mbox} if exists $self->{_default_mbox}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | # XXX: How very unixocentric of us; how can we fix this? -- rjbs, 2006-06-04 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | # It's not really broken, but it's also not very awesome. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 0 | my $default_mbox = $ENV{MAIL}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | ▶ | return $default_mbox if $default_mbox; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 0 | my $default_maildir = File::Spec->catdir( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | File::HomeDir->my_home, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 'Maildir' | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | $default_mbox = | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | (-d File::Spec->catdir($default_maildir, 'new') ? $default_maildir : ()) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | ▶ | || ((grep { -d $_ } qw(/var/spool/mail/ /var/mail/))[0] . getpwuid($>)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
(-d 'File::Spec'->catdir($default_maildir, 'new') ? $default_maildir : ()) || (grep {-d $_;} '/var/spool/mail/', '/var/mail/')[0] . getpwuid($>)
MC/DC0%0/2
(-d 'File::Spec'->catdir($default_maildir, 'new') ? $default_maildir : ()) || (grep {-d $_;} '/var/spool/mail/', '/var/mail/')[0] . getpwuid($>)
(-d 'File::Spec'->catdir($default_maildir, 'new') ? $default_maildir : ())
(grep {-d $_;} '/var/spool/mail/', '/var/mail/')[0] . getpwuid($>)
Truth table0%0/3
A || B
A= (-d 'File::Spec'->catdir($default_maildir, 'new') ? $default_maildir : ())B= (grep {-d $_;} '/var/spool/mail/', '/var/mail/')[0] . getpwuid($>)
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 0 | return $self->{_default_mbox} = $default_mbox; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | # XXX: This is a test case until I have a better interface. This will make | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | # testing simpler! -- rjbs, 2006-06-04 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 5 | ▶ | sub _exit { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_exit: called CC=2 SCAR=8.1
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 5 | my ($self, $exit) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | return $self->{_audit_opts}->{_exit}->(@_) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 5 | ▶ | if exists $self->{_audit_opts}->{_exit}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 0 | exit $exit; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 6 | ▶ | sub _shorthand_expand { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_shorthand_expand: called CC=5 SCAR=16.2
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | # perform ~user and %Y%m%d strftime expansion | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 6 | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 6 | my $local_opts = $self->_get_opt(\@_); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 6 | my @out = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 6 | my $opt = 'interpolate_strftime'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 6 | ▶ | if ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%6/9
exists $local_opts->{$opt} && $local_opts->{$opt} || $self->{"_audit_opts"}{$opt} and grep {index($_, "%") != -1;} @out
exists $local_opts->{$opt} and $local_opts->{$opt} or $self->{"_audit_opts"}{$opt}
exists $local_opts->{$opt} and $local_opts->{$opt}
MC/DC25%1/4
exists $local_opts->{$opt} && $local_opts->{$opt} || $self->{"_audit_opts"}{$opt} and grep {index($_, "%") != -1;} @out
exists $local_opts->{$opt}
$local_opts->{$opt}
$self->{"_audit_opts"}{$opt}
grep {index($_, "%") != -1;} @out
Truth table25%2/8
A and B or C and D
A= exists $local_opts->{$opt}B= $local_opts->{$opt}C= $self->{"_audit_opts"}{$opt}D= grep {index($_, "%") != -1;} @out
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | ((exists $local_opts->{$opt} and $local_opts->{$opt}) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | or $self->{_audit_opts}->{$opt}) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 1 | and grep { index($_, '%') >= 0 } @out | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 1 | my @localtime = localtime; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 1 | require POSIX; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 1 | import POSIX qw(strftime); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 1 | @out = map { strftime($_, @localtime) } @out; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 6 | return @out = map { $self->_expand_homedir($_) } @out; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 6 | ▶ | sub _expand_homedir { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_expand_homedir: called CC=4 SCAR=14.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 6 | my ($self, $path) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 6 | my ($user, $rest) = $path =~ m!^~(\w*)((?:[/\\]).+)?$!; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 6 | ▶ | return $path unless defined $user and defined $rest; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $user and defined $rest
MC/DC50%1/2
defined $user and defined $rest
defined $user
defined $rest
Truth table66%2/3
A and B
A= defined $userB= defined $rest
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 2 | ▶ | my $base = (length $user) ? File::HomeDir->users_home($user) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | : File::HomeDir->my_home; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 2 | return "$base$rest"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 5 | ▶ | sub accept { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
accept: called CC=14 SCAR=29.1
Pod
documented
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 5 | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 5 | my $local_opts = $self->_get_opt(\@_); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | return $self->{_audit_opts}->{accept}->(@_, $local_opts) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 5 | ▶ | if exists $self->{_audit_opts}->{accept}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 4 | my @files = $self->_shorthand_expand(@_, $local_opts); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 4 | ▶ | @files = $self->_default_mbox unless @files; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 4 | my @actually_saved_to_files = (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 4 | $self->_log(2, "accepting to @files"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | # from man procmailrc: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | # If it is a directory, the mail will be delivered to a newly created, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | # guaranteed to be unique file named $MSGPREFIX* in the specified | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | # directory. If the mailbox name ends in "/.", then this directory is | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | # presumed to be an MH folder; i.e., procmail will use the next | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | # number it finds available. If the mailbox name ends in "/", then | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | # this directory is presumed to be a maildir folder; i.e., procmail will | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | # deliver the message to a file in a subdirectory named "tmp" and | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | # rename it to be inside a subdirectory named "new". If the mailbox is | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | # specified to be an MH folder or maildir folder, procmail will create | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | # the necessary directories if they don't exist, rather than treat the | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | # mailbox as a non-existent filename. When procmail is delivering to | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | # directories, you can specify multiple directories to deliver to | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | # (procmail will do so utilising hardlinks). | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | # | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | # for now we will support maildir and mbox delivery. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | # MH delivery remains TODO. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 4 | my %accept_types = ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | mbox => [], | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | maildir => [], | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | mh => [], | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 4 | for my $file (@files) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 4 | my $mailbox_type = $self->_mailbox_type($file); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 4 | push @{ $accept_types{$mailbox_type} }, $file; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 4 | $self->_log(3, "$file is of type $mailbox_type"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 4 | foreach my $accept_type (sort keys %accept_types) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 12 | ▶ | next if not @{ $accept_types{$accept_type} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 4 | my $accept_handler = "_accept_to_$accept_type"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 4 | $self->_log(3, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 4 | "calling accept handler $accept_handler(@{$accept_types{$accept_type}})" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | push @actually_saved_to_files, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 4 | $self->$accept_handler(@{ $accept_types{$accept_type} }, $local_opts); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 4 | ▶ | if ((my $success_count = @actually_saved_to_files) > 0) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 3 | $self->_log(3, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | "delivered successfully to $success_count destinations at " . localtime | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 3 | ▶ | unless ((exists $local_opts->{noexit} and $local_opts->{noexit}) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%3/6
exists $local_opts->{"noexit"} and $local_opts->{"noexit"} or $self->{"_audit_opts"}{"noexit"}
exists $local_opts->{"noexit"} and $local_opts->{"noexit"}
MC/DC33%1/3
exists $local_opts->{"noexit"} and $local_opts->{"noexit"} or $self->{"_audit_opts"}{"noexit"}
exists $local_opts->{"noexit"}
$local_opts->{"noexit"}
$self->{"_audit_opts"}{"noexit"}
Truth table40%2/5
A and B or C
A= exists $local_opts->{"noexit"}B= $local_opts->{"noexit"}C= $self->{"_audit_opts"}{"noexit"}
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | or $self->{_audit_opts}->{noexit} | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 1 | $self->_log(2, "Exiting with status DELIVERED = " . DELIVERED); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 1 | $self->_exit(DELIVERED); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | } else { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | # nothing got delivered, take emergency action. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 1 | my $emergency = $self->_emergency_mbox; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 1 | ▶ | if (not defined $emergency) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | 0 | $self->_log(0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | "unable to write to @files and no emergency mailbox defined; " | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | . "exiting DEFERRED" | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 0 | warn "unable to write to @files"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 0 | $self->_exit(DEFERRED); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | } else { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 1 | ▶ | if (grep { $emergency eq $_ } @files) { # already tried that mailbox | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 0 | ▶ | if (@files == 1) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 0 | $self->_log(0, "unable to write to @files; exiting DEFERRED"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | } else { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 0 | $self->_log(0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | "unable to write to any of (@files), which includes the emergency mailbox; exiting DEFERRED" | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 0 | warn "unable to write to @files"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 0 | $self->_exit(DEFERRED); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | } else { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | 1 | my $accept_type = $self->_mailbox_type($emergency); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 1 | my $accept_handler = "_accept_to_$accept_type"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 1 | @actually_saved_to_files = $self->$accept_handler($emergency); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 1 | ▶ | if (not @actually_saved_to_files) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 0 | $self->_log(0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | "unable to write to @files or to emergency mailbox $emergency either; exiting DEFERRED" | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 0 | warn "unable to write to @files" ; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 0 | $self->_exit(DEFERRED); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | } else { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | 1 | $self->_log(0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | "unable to write to @files; wrote to emergency mailbox $emergency." | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | 4 | return @actually_saved_to_files; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | 5 | ▶ | sub _mailbox_type { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_mailbox_type: called CC=4 SCAR=14.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 5 | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | 5 | my $file = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | 5 | ▶ | return 'maildir' if $file =~ m{/\z}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | 5 | ▶ | return 'mh' if $file =~ m{/\.\z}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | 5 | ▶ | return 'maildir' if -d $file; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | 1 | return 'mbox'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | 1 | ▶ | sub _accept_to_mbox { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_accept_to_mbox: called CC=4 SCAR=16.8
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | 1 | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 1 | my @saved_to = (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | 1 | my $local_opts = $self->_get_opt(\@_); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | 1 | foreach my $file (@_) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | # auto-create the parent dir. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | 1 | ▶ | if (my $mkdir_error = $self->_mkdir_p(File::Basename::dirname($file))) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | 1 | $self->_log(0, $mkdir_error); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | 1 | next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | 0 | my $error = $self->_write_message($file, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | { need_lock => 1, need_from => 1, extra_newline => 1 }); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | 0 | ▶ | if (not $error) { push @saved_to, $file; } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | 0 | else { $self->_log(1, $error); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | 1 | return @saved_to; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | 4 | ▶ | sub _write_message { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_write_message: called CC=22 SCAR=48.6
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | 4 | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | 4 | my $file = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | 4 | ▶ | my $write_opts = shift || {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
shift() || {}
MC/DC0%0/1
shift() || {}
shift()
Truth table50%1/2
A
A= shift()
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | 4 | ▶ | $write_opts->{need_from} = 1 if not defined $write_opts->{need_from}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | 4 | ▶ | $write_opts->{need_lock} = 1 if not defined $write_opts->{need_lock}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | $write_opts->{extra_newline} = 0 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | 4 | ▶ | if not defined $write_opts->{extra_newline}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | 4 | $self->_log(3, "writing to $file; options @{[%$write_opts]}"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | 4 | my $fh = Symbol::gensym; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 0 | ▶ | unless (open($fh, ">>$file")) { return "Couldn't open $file: $!"; } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | 4 | ▶ | if ($write_opts->{need_lock}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | 0 | my $lock_error = $self->_audit_get_lock($fh, $file); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | 0 | ▶ | return $lock_error if $lock_error; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | 4 | seek $fh, 0, 2; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | 4 | ▶ | if (not $write_opts->{need_from} and $self->head->header->[0] =~ /^From\s/) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not $write_opts->{"need_from"} and $self->head->header->[0] =~ /^From\s/
MC/DC0%0/2
not $write_opts->{"need_from"} and $self->head->header->[0] =~ /^From\s/
not $write_opts->{"need_from"}
$self->head->header->[0] =~ /^From\s/
Truth table33%1/3
not(A) and B
A= not $write_opts->{"need_from"}B= $self->head->header->[0] =~ /^From\s/
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | 0 | $self->_log(3, "mbox From line found, stripping because we're maildir"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | 0 | $self->delete_header("From "); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | 0 | $self->unescape_from(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | 4 | ▶ | if ($write_opts->{need_from} and $self->head->header->[0] !~ /^From\s/) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$write_opts->{"need_from"} and not $self->head->header->[0] =~ /^From\s/
MC/DC0%0/2
$write_opts->{"need_from"} and not $self->head->header->[0] =~ /^From\s/
$write_opts->{"need_from"}
not $self->head->header->[0] =~ /^From\s/
Truth table33%1/3
A and not(B)
A= $write_opts->{"need_from"}B= not $self->head->header->[0] =~ /^From\s/
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | 0 | $self->_log(3, "No mbox From line, making one up."); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 0 | ▶ | if (exists $ENV{UFLINE}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | 0 | $self->_log(3, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | "Looks qmail, but preline not run, prepending UFLINE, RPLINE, DTLINE"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | 0 | print $fh $ENV{UFLINE}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | 0 | print $fh $ENV{RPLINE}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | 0 | print $fh $ENV{DTLINE}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | } else { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | 0 | ▶ | my $from = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/8
$self->get('Return-path') || $self->get('Sender') || $self->get('Reply-To') || 'root@localhost'
$self->get("Return-path") or $self->get("Sender") or $self->get("Reply-To")
$self->get("Return-path") or $self->get("Sender")
MC/DC0%0/3
$self->get('Return-path') || $self->get('Sender') || $self->get('Reply-To') || 'root@localhost'
$self->get("Return-path")
$self->get("Sender")
$self->get("Reply-To")
Truth table0%0/4
A or B or C
A= $self->get("Return-path")B= $self->get("Sender")C= $self->get("Reply-To")
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | $self->get('Return-path') | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | || $self->get('Sender') | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | || $self->get('Reply-To') | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | || 'root@localhost' | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | 0 | chomp $from; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | 0 | ▶ | $from = $1 if $from =~ /<(.*?)>/; # comment <name@domain> -> name@domain | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | 0 | $from =~ s/\s*\(.*\)\s*//; # name@domain (comment) -> name@domain | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | 0 | $from =~ s/\s+//g; # if any whitespace remains, get rid of it. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | # strip timezone. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | 0 | (my $fromtime = localtime) =~ s/(:\d\d) \S+ (\d{4})$/$1 $2/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | 0 | print $fh "From $from $fromtime\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | 4 | $self->_log(4, "printing self as mbox string."); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | 4 | ▶ | if ($write_opts->{need_from}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | 0 | my $content = $self->as_string; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | 0 | $content =~ s/\nFrom /\n>From /g; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | 0 | print $fh $content; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | } else { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | 4 | print $fh $self->as_string; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | # extra \n added because mutt seems to like a "\n\nFrom " in mbox files | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | 4 | ▶ | print $fh "\n" if $write_opts->{extra_newline}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | 4 | ▶ | if ($write_opts->{need_lock}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | 0 | ▶ | flock($fh, LOCK_UN) or return "Couldn't unlock $file"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | 4 | ▶ | close $fh or return "Couldn't close $file after writing: $!"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | 4 | $self->_log(4, "returning success."); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | 4 | return 0; # success | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | 0 | ▶ | sub _accept_to_mh { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_accept_to_mh: not called CC=1 SCAR=6.9
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | 0 | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | 0 | my @saved_to = (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | 0 | my $local_opts = $self->_get_opt(\@_); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | 0 | die "_accept_to_mh not implemented"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | 0 | return @saved_to; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | # variables for accept_to_maildir | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | 15 | my $maildir_time = 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | 15 | my $maildir_counter = 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | 4 | ▶ | sub _accept_to_maildir { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_accept_to_maildir: called CC=21 SCAR=35.8
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | 4 | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | 4 | my @saved_to = (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | 4 | my $local_opts = $self->_get_opt(\@_); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | $local_opts->{one_for_all} = exists $local_opts->{one_for_all} | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | ? $local_opts->{one_for_all} | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | 4 | ▶ | : $self->{_audit_opts}->{one_for_all}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | 4 | $self->_log(3, "will write to @_"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | # since mutt won't add a lines tag to maildir messages, we'll add it here | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | # XXX: Why the nuts is this here? This should be another method, or a | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | # plugin! -- rjbs, 2006-05-30 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | 4 | ▶ | unless (length $self->get("Lines")) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | 2 | my @lines = $self->body; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | 2 | ▶ | @lines = @{ $lines[0] } if @lines == 1 and ref $lines[0] eq 'ARRAY'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
@lines == 1 and ref $lines[0] eq "ARRAY"
MC/DC0%0/2
@lines == 1 and ref $lines[0] eq "ARRAY"
@lines == 1
ref $lines[0] eq "ARRAY"
Truth table33%1/3
A and B
A= @lines == 1B= ref $lines[0] eq "ARRAY"
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | 2 | my $num_lines = @lines; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | 2 | $self->head->add("Lines", $num_lines); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | 2 | $self->_log(4, "Adding Lines: $num_lines header"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | 4 | ▶ | if ($maildir_time != time) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | 2 | $maildir_time = time; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | 2 | $maildir_counter = 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | } else { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | 2 | $maildir_counter++; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | # write the tmp file. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | # hardlink to all the new files. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | # unlink the temp file. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | # write the tmp file in the first writable maildir directory. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | 4 | my $tmp_path; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | 4 | foreach my $file (my @maildirs = @_) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | 4 | $file =~ s/\/$//; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | 4 | ▶ | my $tmpdir = $local_opts->{one_for_all} ? $file : "$file/tmp"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | 4 | my $msg_file; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | 4 | ▶ | do { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | $msg_file = join ".", | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | 4 | ($maildir_time, $$ . "_$maildir_counter", $self->{_hostname}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | 4 | $maildir_counter++; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | } while (-e "$tmpdir/$msg_file"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | 4 | $tmp_path = "$tmpdir/$msg_file"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | 4 | $self->_log(3, "writing to $tmp_path"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | # auto-create the maildir. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | 4 | ▶ | if ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | my $mkdir_error = $self->_mkdir_p( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | $local_opts->{one_for_all} | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | ? ($file) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | 12 | : map { "$file/$_" } qw(tmp new cur) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | ) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | 0 | $self->_log(0, $mkdir_error); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | 0 | next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | 4 | my $error | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | = $self->_write_message($tmp_path, { need_from => 0, need_lock => 0 }); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | # only write to the first writeable maildir | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | 4 | ▶ | last unless $error; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | 0 | $self->_log(1, $error); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | 0 | unlink $tmp_path; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | 0 | $tmp_path = undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | # unable to write to any of the specified maildirs. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | 4 | ▶ | if (not $tmp_path) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | 0 | return 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | # it is now in tmp/. hardlink to all the new/ destinations. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | 4 | foreach my $file (my @maildirs = @_) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | 4 | $file =~ s/\/$//; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | 4 | my $msg_file; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | 4 | ▶ | my $newdir = $local_opts->{one_for_all} ? $file : "$file/new"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | 4 | $maildir_counter = 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | 4 | ▶ | do { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | $msg_file = join ".", | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | 5 | ($maildir_time = time, $$ . "_$maildir_counter", $self->{_hostname}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | 5 | $maildir_counter++; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | } while (-e File::Spec->catdir($newdir, $msg_file)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | # auto-create the maildir. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | 4 | ▶ | if ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | my $mkdir_error = $self->_mkdir_p( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | $local_opts->{one_for_all} | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | ? ($file) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | 12 | : map { File::Spec->catdir($file, $_) } qw(tmp new cur) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | ) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | 0 | $self->_log(0, $mkdir_error); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | 0 | next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | 4 | my $new_path = File::Spec->catfile($newdir, $msg_file); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | 4 | $self->_log(3, "maildir: hardlinking to $new_path"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | 4 | ▶ | if (link $tmp_path, $new_path) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | 4 | push @saved_to, $new_path; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | } else { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | 0 | require Errno; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | 0 | ▶ | if ($! == Errno::EXDEV()) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | # Invalid cross-device link, see /usr/**/include/*/errno.h | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | 0 | $self->_log(0, "Couldn't link $tmp_path to $new_path: $!"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | 0 | $self->_log(0, "attempting direct maildir delivery to $new_path..."); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | 0 | push @saved_to, $self->_accept_to_maildir($file); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | 0 | next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | } else { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | 0 | $self->_log(0, "Couldn't link $tmp_path to $new_path: $!"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | # unlink the temp file | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | 4 | ▶ | unlink $tmp_path or $self->_log(1, "Couldn't unlink $tmp_path: $!"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | 4 | return @saved_to; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | 4 | ▶ | sub reject { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
reject: called CC=2 SCAR=6.9
Pod
documented
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | 4 | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | 4 | my $local_opt = $self->_get_opt(\@_); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | return $self->{_audit_opts}->{reject}->(@_, $local_opt) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | 4 | ▶ | if exists $self->{_audit_opts}->{reject}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | 3 | $self->_log(1, "Rejecting with exitcode " . REJECTED . " and reason $_[0]"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | 3 | $self->_exit(REJECTED); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | 0 | ▶ | sub resend { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
resend: not called CC=7 SCAR=40.3
Pod
documented
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | 0 | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | 0 | my $local_opts = $self->_get_opt(\@_); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | 0 | my $rcpt = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | $self->smtpsend( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | To => $rcpt, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | (exists $local_opts->{host} ? (Host => $local_opts->{host}) : ()), | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | (exists $local_opts->{port} ? (Port => $local_opts->{port}) : ()), | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | 0 | ▶ | (exists $local_opts->{debug} ? (Debug => $local_opts->{debug}) : ()), | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | 0 | ▶ | unless ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
exists $local_opts->{"noexit"} and $local_opts->{"noexit"} or $self->{"_audit_opts"}{"noexit"}
exists $local_opts->{"noexit"} and $local_opts->{"noexit"}
MC/DC0%0/3
exists $local_opts->{"noexit"} and $local_opts->{"noexit"} or $self->{"_audit_opts"}{"noexit"}
exists $local_opts->{"noexit"}
$local_opts->{"noexit"}
$self->{"_audit_opts"}{"noexit"}
Truth table0%0/5
A and B or C
A= exists $local_opts->{"noexit"}B= $local_opts->{"noexit"}C= $self->{"_audit_opts"}{"noexit"}
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | (exists $local_opts->{noexit} and $local_opts->{noexit}) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | or $self->{_audit_opts}->{noexit} | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | 0 | $self->_log(2, "Exiting with status DELIVERED = " . DELIVERED); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | 0 | $self->_exit(DELIVERED); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | 0 | ▶ | sub pipe { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pipe: not called CC=6 SCAR=37.4
Pod
documented
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | 0 | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | return $self->{_audit_opts}->{pipe}->(@_) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | 0 | ▶ | if exists $self->{_audit_opts}->{pipe}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | 0 | my $local_opts = $self->_get_opt(\@_); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | 0 | my ($command) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | 0 | my ($file) = $self->_shorthand_expand($command, $local_opts); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | 0 | $self->_log(1, "Piping to $file"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | 0 | my $pipe = Symbol::gensym; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | 0 | ▶ | unless (open($pipe, "|$file")) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | 0 | $self->_log(0, "Couldn't open pipe $file: $!"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | 0 | $self->accept(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | 0 | $self->print($pipe); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | 0 | close $pipe; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | 0 | my $status = $? >> 8; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | 0 | $self->_log(3, "Pipe closed with status $status"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | 0 | ▶ | unless ((exists $local_opts->{noexit} and $local_opts->{noexit}) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
exists $local_opts->{"noexit"} and $local_opts->{"noexit"} or $self->{"_audit_opts"}{"noexit"}
exists $local_opts->{"noexit"} and $local_opts->{"noexit"}
MC/DC0%0/3
exists $local_opts->{"noexit"} and $local_opts->{"noexit"} or $self->{"_audit_opts"}{"noexit"}
exists $local_opts->{"noexit"}
$local_opts->{"noexit"}
$self->{"_audit_opts"}{"noexit"}
Truth table0%0/5
A and B or C
A= exists $local_opts->{"noexit"}B= $local_opts->{"noexit"}C= $self->{"_audit_opts"}{"noexit"}
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | or $self->{_audit_opts}->{noexit} | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | 0 | $self->_log(2, "Exiting with status DELIVERED = " . DELIVERED); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | 0 | $self->_exit(DELIVERED); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | 0 | return $status; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | 3 | ▶ | sub ignore { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ignore: called CC=5 SCAR=16.1
Pod
documented
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | 3 | my ($self, $reason) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 633 | 3 | ▶ | $self->_log( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | 1, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 635 | "Ignoring: " . (defined $reason ? $reason : '(no reason given)') | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 637 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | 3 | my $local_opts = $self->_get_opt(\@_); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 639 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 640 | $self->_exit(DELIVERED) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 641 | unless ((exists $local_opts->{noexit} and $local_opts->{noexit}) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 642 | 3 | ▶ | or $self->{_audit_opts}->{noexit}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
exists $local_opts->{"noexit"} and $local_opts->{"noexit"} or $self->{"_audit_opts"}{"noexit"}
exists $local_opts->{"noexit"} and $local_opts->{"noexit"}
MC/DC66%2/3
exists $local_opts->{"noexit"} and $local_opts->{"noexit"} or $self->{"_audit_opts"}{"noexit"}
exists $local_opts->{"noexit"}
$local_opts->{"noexit"}
$self->{"_audit_opts"}{"noexit"}
Truth table60%3/5
A and B or C
A= exists $local_opts->{"noexit"}B= $local_opts->{"noexit"}C= $self->{"_audit_opts"}{"noexit"}
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 643 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 644 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 645 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 646 | 0 | ▶ | sub _reply_recipient { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_reply_recipient: not called CC=5 SCAR=34.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 647 | 0 | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 648 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 649 | # TODO: clean this up with Mail::Address. right now if From: <> we barf. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 650 | 0 | ▶ | return ($self->get("Resent-From") | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/12
$self->get('Resent-From') || $self->get('Reply-To') || $self->get('From') || $self->get('Sender') || $self->get('Return-Path')
$self->get("Resent-From") or $self->get("Reply-To") or $self->get("From") or $self->get("Sender")
$self->get("Resent-From") or $self->get("Reply-To") or $self->get("From")
$self->get("Resent-From") or $self->get("Reply-To")
MC/DC0%0/5
$self->get('Resent-From') || $self->get('Reply-To') || $self->get('From') || $self->get('Sender') || $self->get('Return-Path')
$self->get("Resent-From")
$self->get("Reply-To")
$self->get("From")
$self->get("Sender")
$self->get('Return-Path')
Truth table0%0/6
A or B or C or D || E
A= $self->get("Resent-From")B= $self->get("Reply-To")C= $self->get("From")D= $self->get("Sender")E= $self->get('Return-Path')
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 651 | || $self->get("Reply-To") | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 652 | || $self->get("From") | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 653 | || $self->get("Sender") | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 654 | || $self->get("Return-Path")); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 655 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 656 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 657 | 0 | ▶ | sub reply { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
reply: not called CC=23 SCAR=63.1
Pod
documented
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 658 | 0 | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 659 | 0 | my %reply_opts = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 660 | 0 | foreach my $k (keys %reply_opts) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 661 | 0 | $reply_opts{ lc $k } = delete $reply_opts{$k}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 662 | } # lowercase option names | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 663 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 664 | # thanks to man procmailrc(1), this is ^FROM_DAEMON | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 665 | 0 | ▶ | if ($self->from_daemon) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 666 | 0 | ▶ | unless (defined $reply_opts{even_if_from_daemon} | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $reply_opts{"even_if_from_daemon"} and $reply_opts{"even_if_from_daemon"}
MC/DC0%0/2
defined $reply_opts{"even_if_from_daemon"} and $reply_opts{"even_if_from_daemon"}
defined $reply_opts{"even_if_from_daemon"}
$reply_opts{"even_if_from_daemon"}
Truth table0%0/3
A and B
A= defined $reply_opts{"even_if_from_daemon"}B= $reply_opts{"even_if_from_daemon"}
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 667 | and $reply_opts{even_if_from_daemon} | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 668 | ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 669 | 0 | $self->_log(2, "message is ^FROM_DAEMON, skipping reply"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 670 | 0 | return "(^FROM_DAEMON, no reply)"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 671 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 672 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 673 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 674 | 0 | ▶ | if ( length $self->get("X-Loop") | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
length $self->get("X-Loop") or length $self->get("X-Loop-Detect")
MC/DC0%0/2
length $self->get("X-Loop") or length $self->get("X-Loop-Detect")
length $self->get("X-Loop")
length $self->get("X-Loop-Detect")
Truth table0%0/3
A or B
A= length $self->get("X-Loop")B= length $self->get("X-Loop-Detect")
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 675 | or length $self->get("X-Loop-Detect") | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 676 | ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 677 | 0 | return "(X-Loop header found, not replying)"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 678 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 679 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 680 | 0 | require Mail::Mailer; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 681 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 682 | 0 | ▶ | my $rcpt = ($reply_opts{"to"} || $self->_reply_recipient); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$reply_opts{'to'} || $self->_reply_recipient
MC/DC0%0/2
$reply_opts{'to'} || $self->_reply_recipient
$reply_opts{'to'}
$self->_reply_recipient
Truth table0%0/3
A || B
A= $reply_opts{'to'}B= $self->_reply_recipient
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 683 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 684 | 0 | ▶ | return if not $rcpt; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 685 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 686 | my $subject = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 687 | 0 | ▶ | $reply_opts{"subject"} | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/6
$reply_opts{'subject'} || (defined $self->subject && length $self->subject ? !($self->subject =~ /\bRe:/i) ? 'Re: ' . $self->subject : $self->subject : 'your mail')
defined $self->subject and length $self->subject
MC/DC0%0/3
$reply_opts{'subject'} || (defined $self->subject && length $self->subject ? !($self->subject =~ /\bRe:/i) ? 'Re: ' . $self->subject : $self->subject : 'your mail')
$reply_opts{'subject'}
defined $self->subject
length $self->subject
Truth table0%0/4
A || B and C
A= $reply_opts{'subject'}B= defined $self->subjectC= length $self->subject
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 688 | || ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 689 | defined $self->subject | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 690 | && length $self->subject | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 691 | ? ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 692 | $self->subject !~ /\bRe:/i | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 693 | ? "Re: " . $self->subject | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 694 | : $self->subject | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 695 | ) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 696 | : "your mail" | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 697 | ) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 698 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 699 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 700 | 0 | chomp($rcpt, $subject); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 701 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 702 | 0 | my @references; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 703 | @references = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 704 | defined $reply_opts{"references"} | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 705 | ? ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 706 | ref($reply_opts{"references"}) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 707 | 0 | ? map { split ' ', $_ } @{ $reply_opts{"references"} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 708 | : split ' ', $reply_opts{"references"} | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 709 | ) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 710 | 0 | ▶ | : grep { length $_ } ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 711 | split(' ', $self->get("References")), | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 712 | split(' ', $self->get("Message-ID")) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 713 | ) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 714 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 715 | 0 | @references = grep { /^<.*>$/ } @references; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 716 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 717 | 0 | my %headers = ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 718 | To => $rcpt, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 719 | Subject => $subject, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 720 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 721 | 0 | ▶ | $headers{From} = $reply_opts{from} if defined $reply_opts{from}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 722 | 0 | ▶ | $headers{CC} = $reply_opts{cc} if defined $reply_opts{cc}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 723 | 0 | ▶ | $headers{BCC} = $reply_opts{bcc} if defined $reply_opts{bcc}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 724 | 0 | ▶ | $headers{References} = "@references" if @references; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 725 | 0 | ▶ | $headers{"X-Loop"} = $reply_opts{"x-loop"} || $self->get("X-Loop") || "1"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/5
$reply_opts{'x-loop'} || $self->get('X-Loop') || '1'
$reply_opts{"x-loop"} or $self->get("X-Loop")
MC/DC0%0/2
$reply_opts{'x-loop'} || $self->get('X-Loop') || '1'
$reply_opts{"x-loop"}
$self->get("X-Loop")
Truth table0%0/3
A or B
A= $reply_opts{"x-loop"}B= $self->get("X-Loop")
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 726 | 0 | ▶ | $headers{"X-Loop-Detect"} = $self->get("X-Loop-Detect") || "1"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->get('X-Loop-Detect') || '1'
MC/DC0%0/1
$self->get('X-Loop-Detect') || '1'
$self->get('X-Loop-Detect')
Truth table0%0/2
A
A= $self->get('X-Loop-Detect')
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 727 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 728 | 0 | my $reply = Mail::Mailer->new(qw(sendmail)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 729 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 730 | 0 | $reply->open(\%headers); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 731 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 732 | print $reply ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 733 | defined $reply_opts{body} | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 734 | ? $reply_opts{body} | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 735 | 0 | ▶ | : "Your message has been received.\n"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 736 | 0 | $reply->close; # complete the message and send it | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 737 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 738 | 0 | $self->_log(1, "reply sent to $rcpt"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 739 | 0 | return $rcpt; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 740 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 741 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 742 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 743 | 99 | ▶ | sub log { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
log: called CC=4 SCAR=13.9
Pod
documented
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 744 | 99 | my ($self, $priority, $what) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 745 | 99 | ▶ | return unless $self->{_log}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 746 | 99 | ▶ | return if $self->{_log}{level} < $priority; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 747 | 35 | chomp $what; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 748 | 35 | chomp $what; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 749 | 35 | my ($subroutine) = (caller(1))[3]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 750 | 35 | $subroutine =~ s/(.*):://; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 751 | 35 | my ($line) = (caller(0))[2]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 752 | 35 | ▶ | print { $self->{_log}{fh} } "$line($subroutine): $what\n" | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 753 | or die "couldn't write to log file: $!"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 754 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 755 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 756 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 757 | # ---------------------------------------------------------- | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 758 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 759 | 0 | ▶ | sub header { $_[0]->head->as_string() } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
header: not called CC=1 SCAR=6.9
Pod
documented
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 760 | 0 | ▶ | sub add_header { $_[0]->head->add($_[1], $_[2]); } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_header: not called CC=1 SCAR=6.9
Pod
documented
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 761 | 0 | ▶ | sub put_header { &add_header } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
put_header: not called CC=1 SCAR=6.9
Pod
documented
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 762 | 0 | ▶ | sub get_header { &get } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_header: not called CC=1 SCAR=6.9
Pod
documented
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 763 | 0 | ▶ | sub replace_header { $_[0]->head->replace($_[1], $_[2]); } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
replace_header: not called CC=1 SCAR=6.9
Pod
documented
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 764 | 0 | ▶ | sub delete_header { $_[0]->head->delete($_[1]); } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
delete_header: not called CC=1 SCAR=6.9
Pod
documented
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 765 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 766 | 47 | ▶ | sub get { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get: called CC=4 SCAR=13.9
Pod
documented
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 767 | 47 | my ($self, $header) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 768 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 769 | 47 | ▶ | if (wantarray) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 770 | 2 | my @strings = $self->head->get($header); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 771 | 2 | chomp @strings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 772 | 2 | return @strings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 773 | } else { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 774 | 45 | my $string = $self->head->get($header); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 775 | 45 | ▶ | chomp($string = (defined $string && length $string) ? $string : ""); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $string and length $string
MC/DC50%1/2
defined $string and length $string
defined $string
length $string
Truth table66%2/3
A and B
A= defined $stringB= length $string
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 776 | 45 | return $string; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 777 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 778 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 779 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 780 | # inheriting from MIME::Entity breaks this. mengwong 20020112 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 781 | 0 | ▶ | sub tidy { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
tidy: not called CC=1 SCAR=6.9
Pod
documented
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 782 | 0 | $_[0]->tidy_body(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 783 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 784 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 785 | 8 | ▶ | sub noexit { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
noexit: called CC=2 SCAR=6.9
Pod
documented
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 786 | 8 | ▶ | $_[0]->{_audit_opts}->{noexit} = $_[1] ? 1 : 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 787 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 788 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 789 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 790 | # ---------------------------------------------------------- | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 791 | 0 | ▶ | sub from { $_[0]->get("From") } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
from: not called CC=1 SCAR=6.9
Pod
documented
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 792 | 0 | ▶ | sub to { $_[0]->get("To") } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
to: not called CC=1 SCAR=6.9
Pod
documented
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 793 | 2 | ▶ | sub subject { $_[0]->get("Subject") } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
subject: called CC=1 SCAR=0.0
Pod
documented
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 794 | 0 | ▶ | sub bcc { $_[0]->get("BCC") } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
bcc: not called CC=1 SCAR=6.9
Pod
documented
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 795 | 0 | ▶ | sub cc { $_[0]->get("CC") } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
cc: not called CC=1 SCAR=6.9
Pod
documented
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 796 | 0 | ▶ | sub received { $_[0]->get("Received") } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
received: not called CC=1 SCAR=6.9
Pod
documented
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 797 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 798 | # from_mailer and from_daemon inspired by procmailrc | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 799 | 0 | ▶ | sub from_daemon { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
from_daemon: not called CC=2 SCAR=17.9
Pod
documented
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 800 | 0 | my $message = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 801 | 0 | my $head = $message->head->dup; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 802 | 0 | $head->unfold; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 803 | 0 | ▶ | if ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 804 | $head->as_string =~ /(^(Mailing-List: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 805 | |List-ID: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 806 | |Precedence:.*(junk|bulk|list) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 807 | |To:.*Multiple recipients of | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 808 | |(((Resent-)?(From|Sender)|X-Envelope-From):|>?From ) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 809 | .*?\b | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 810 | (Post(ma?(st(e?r)?|n)|office) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 811 | |(?-i)Mailer?(?i) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 812 | |sendmail | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 813 | |daemon | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 814 | |m(mdf|ajordomo) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 815 | |n?uucp | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 816 | |LIST(SERV|proc) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 817 | |NETSERV | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 818 | |o(wner|ps) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 819 | |(?-i)r(e(quest|sponse)|oot)(?i) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 820 | |b(ounce|bs\.smtp) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 821 | |mirror | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 822 | |s(erv(ices?|er)|mtp(error)?|ystem) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 823 | |A(dmin(istrator)?|MMGR|utoanswer) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 824 | )\@ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 825 | ))/imx | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 826 | ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 827 | 0 | return $1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 828 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 829 | 0 | return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 830 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 831 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 832 | 0 | ▶ | sub from_mailer { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
from_mailer: not called CC=1 SCAR=6.9
Pod
documented
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 833 | 0 | my $message = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 834 | 0 | my $head = $message->head->dup; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 835 | 0 | $head->unfold; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 836 | 0 | __from_mailer($head->as_string); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 837 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 838 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 839 | 5 | ▶ | sub __from_mailer { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__from_mailer: called CC=2 SCAR=6.9
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 840 | 5 | my $header = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 841 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 842 | 5 | ▶ | if ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 843 | $header =~ / | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 844 | (^(((Resent-)?(From|Sender) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 845 | |X-Envelope-From):|>?From ) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 846 | .*?\b | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 847 | (Post(ma(st(er)?|n)|office) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 848 | |(?-i)Mailer?(?i) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 849 | |sendmail | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 850 | |daemon | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 851 | |mmdf | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 852 | |n?uucp | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 853 | |ops | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 854 | |(?-i)r(esponse|oot)(?i) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 855 | |(bbs\.)?smtp(error)? | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 856 | |s(erv(ices?|er)|ystem)|A(dmin(istrator)?|MMGR) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 857 | )\@ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 858 | )/imx | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 859 | ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 860 | 3 | return $1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 861 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 862 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 863 | 2 | return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 864 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 865 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 866 | # ---------------------------------------------------------- | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 867 | # utility functions | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 868 | # ---------------------------------------------------------- | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 869 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 870 | 0 | ▶ | sub _audit_get_lock { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_audit_get_lock: not called CC=4 SCAR=30.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 871 | 0 | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 872 | 0 | my $fh = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 873 | 0 | my $file = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 874 | 0 | $self->_log(4, " attempting to lock file $file"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 875 | 0 | for (1 .. 10) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 876 | 0 | ▶ | if (flock($fh, LOCK_EX)) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 877 | 0 | $self->_log(4, " successfully locked file $file"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 878 | 0 | return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 879 | } else { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 880 | 0 | ▶ | sleep $_ and next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 881 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 882 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 883 | 0 | $self->_log(1, my $errstr = "Couldn't get exclusive lock on $file"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 884 | 0 | return $errstr; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 885 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 886 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 887 | 19 | ▶ | sub _mkdir_p { # mkdir -p (also create parents if necessary) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_mkdir_p: called CC=8 SCAR=21.6
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 888 | 19 | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 889 | 19 | ▶ | return if not @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 890 | 19 | ▶ | return if not length $_[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 891 | 19 | foreach (@_) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 892 | 35 | ▶ | next if -d $_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 893 | 10 | ▶ | chop while m{/$}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 894 | 10 | $self->_log(4, "$_ doesn't exist, creating."); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 895 | 10 | ▶ | if (my $error = $self->_mkdir_p(File::Basename::dirname($_))) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 896 | 0 | return $error | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 897 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 898 | 10 | ▶ | mkdir($_, 0755) or return "unable to mkdir $_: $!"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 899 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 900 | 18 | return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 901 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 902 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 903 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 904 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 905 | 15 | 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 906 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 907 | __END__ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||