| 1 | #!/usr/bin/env perl | ||||||||||||
| 2 | # | ||||||||||||
| 3 | # mail-dkim - sign a message that arrives on stdin, then hand it to sendmail(1) | ||||||||||||
| 4 | # with the arguments given on the command line. | ||||||||||||
| 5 | # | ||||||||||||
| 6 | # It exists to be dropped where a CGI script or a cron job calls | ||||||||||||
| 7 | # /usr/sbin/sendmail directly: those messages go out with no signature, so a | ||||||||||||
| 8 | # forwarded copy looks exactly like a forgery to the receiving site. Pointing | ||||||||||||
| 9 | # that one call at this instead signs the mail without touching the script. | ||||||||||||
| 10 | # | ||||||||||||
| 11 | # The signing is in Mail::Send::DKIM; this is the command line around it, so | ||||||||||||
| 12 | # that the module can be used and tested without a process and a pipe. | ||||||||||||
| 13 | |||||||||||||
| 14 | 5 | ▶ | use strict; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 15 | 5 | ▶ | use warnings; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 16 | |||||||||||||
| 17 | 5 | ▶ | use FindBin qw($Bin); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 18 | # Where the module is: beside this script in a checkout, and one level down | ||||||||||||
| 19 | # under lib/perl5 when the distribution was installed with INSTALL_BASE - which | ||||||||||||
| 20 | # is how perlbrew, local::lib and cpanm -l put it, and where @INC does not | ||||||||||||
| 21 | # reach unless PERL5LIB is set for every caller, cron included. | ||||||||||||
| 22 | 5 | ▶ | use lib grep { -d } map { "$Bin/../$_" } qw(lib lib/perl5); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 23 | 5 | ▶ | use Mail::Send::DKIM; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 24 | |||||||||||||
| 25 | 5 | my $dkim = Mail::Send::DKIM->new(); | |||||||||||
| 26 | |||||||||||||
| 27 | 5 | ▶ | my $message = do { local $/; <STDIN> } // ''; | ||||||||||
|
Condition50%1/2
do {
local $/;
readline STDIN
} // ""
MC/DC0%0/1
do {
local $/;
readline STDIN
} // ""
do {
local $/;
readline STDIN
}
Truth table50%1/2
A
A= do {
local $/;
readline STDIN
}
| |||||||||||||
| 28 | 5 | my $signed = $dkim->sign($message); | |||||||||||
| 29 | 5 | ▶ | $message = $signed if(defined($signed)); | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 30 | |||||||||||||
| 31 | 5 | my $status = $dkim->send($message, @ARGV); | |||||||||||
| 32 | 5 | ▶ | $dkim->log_send($message, @ARGV) if($status == 0); | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 33 | |||||||||||||
| 34 | 5 | exit($status); | |||||||||||
| 35 | |||||||||||||
| 36 | __END__ | ||||||||||||