| 28 |
my $nb_by_group = 20; # Number of emails sent together (in the same sendmail) |
my $nb_by_group = 20; # Number of emails sent together (in the same sendmail) |
| 29 |
my $debug = 0; |
my $debug = 0; |
| 30 |
my $spamc = ''; |
my $spamc = ''; |
| 31 |
|
my $needs_approval = 1; |
| 32 |
|
|
| 33 |
# Get the package name |
# Get the package name |
| 34 |
my $package = lc($ENV{'LOCAL_PART'}); # Exim sets that ... |
my $package = lc($ENV{'LOCAL_PART'}); # Exim sets that ... |
| 110 |
# If default keyword, it may be spam ... check with spamassassin |
# If default keyword, it may be spam ... check with spamassassin |
| 111 |
# before approving |
# before approving |
| 112 |
if ($keyword eq "default") { |
if ($keyword eq "default") { |
| 113 |
|
# Some mails comes from trusted sources |
| 114 |
|
# which do not need auto-approval |
| 115 |
|
if ($mail->head()->get('X-Bugzilla-Product')) { |
| 116 |
|
# Bugzilla(s) are trusted sources |
| 117 |
|
$needs_approval = 0; |
| 118 |
|
} |
| 119 |
|
# Check for spam |
| 120 |
if (defined($spamc) && $spamc) { |
if (defined($spamc) && $spamc) { |
| 121 |
open(SPAMC, "| $spamc -c >/dev/null") || die "Can't fork spamc: $!\n"; |
open(SPAMC, "| $spamc -c >/dev/null") || die "Can't fork spamc: $!\n"; |
| 122 |
$mail->print(\*SPAMC); |
$mail->print(\*SPAMC); |
| 123 |
my $res = close(SPAMC); |
my $res = close(SPAMC); |
| 124 |
if (!$res and !$!) { |
if (!$res and !$!) { |
| 125 |
# Looks like it's spam |
# Looks like it's spam |
| 126 |
print STDERR "Your message appears to be spam (according to spamassassin)."; |
print STDERR "Your message appears to be spam (according to spamassassin).\n"; |
| 127 |
print STDERR "If it wasn't please retry by writing simple plain text mails."; |
print STDERR "If it wasn't please retry by writing simple plain text mails.\n"; |
| 128 |
|
exit 2; |
| 129 |
|
} |
| 130 |
|
} |
| 131 |
|
# Check for approval |
| 132 |
|
if (defined($needs_approval) && $needs_approval) { |
| 133 |
|
if (! $mail->head()->get('X-PTS-Approved')) { |
| 134 |
|
print STDERR "The mail isn't auto-approved as it should be. Please include\n"; |
| 135 |
|
print STDERR "an 'X-PTS-Approved' (non-empty) header if you want to mail \n"; |
| 136 |
|
print STDERR "directly the Package Tracking System. This is made to avoid spam.\n"; |
| 137 |
exit 2; |
exit 2; |
| 138 |
} |
} |
| 139 |
} |
} |
| 140 |
} |
} |
| 141 |
|
|
| 142 |
# Modify the mail |
# Modify the mail |
| 143 |
|
$mail->head()->add("Precedence", "list"); |
| 144 |
$mail->head()->add("X-Loop", "$package\@packages.qa.debian.org"); |
$mail->head()->add("X-Loop", "$package\@packages.qa.debian.org"); |
| 145 |
$mail->head()->add("X-PTS-Package", $package); |
$mail->head()->add("X-PTS-Package", $package); |
| 146 |
$mail->head()->add("X-PTS-Keyword", $keyword); |
$mail->head()->add("X-PTS-Keyword", $keyword); |