dbaa9dbd6c
on files in plugins dir: fixed a number of POD errors formatted some # comments into POD removed bare 1; (these are plugins, not perl modules) most instances of this were copy/pasted from a previous plugin that had it removed instances of # vim ts=N ... they weren't consistent, many didn't match .perltidyrc on modules that failed perl -c tests, added 'use Qpsmtpd::Constants;' Conflicts: plugins/async/check_earlytalker plugins/async/dns_whitelist_soft plugins/async/dnsbl plugins/async/queue/smtp-forward plugins/async/require_resolvable_fromhost plugins/async/rhsbl plugins/async/uribl plugins/auth/auth_checkpassword plugins/auth/auth_cvm_unix_local plugins/auth/auth_flat_file plugins/auth/auth_ldap_bind plugins/auth/auth_vpopmail plugins/auth/auth_vpopmail_sql plugins/auth/authdeny plugins/check_badmailfromto plugins/check_badrcptto_patterns plugins/check_bogus_bounce plugins/check_earlytalker plugins/check_norelay plugins/check_spamhelo plugins/connection_time plugins/dns_whitelist_soft plugins/dnsbl plugins/domainkeys plugins/greylisting plugins/hosts_allow plugins/http_config plugins/logging/adaptive plugins/logging/apache plugins/logging/connection_id plugins/logging/transaction_id plugins/logging/warn plugins/milter plugins/queue/exim-bsmtp plugins/queue/maildir plugins/queue/postfix-queue plugins/queue/smtp-forward plugins/quit_fortune plugins/random_error plugins/rcpt_map plugins/rcpt_regexp plugins/relay_only plugins/require_resolvable_fromhost plugins/rhsbl plugins/sender_permitted_from plugins/spamassassin plugins/tls plugins/tls_cert plugins/uribl plugins/virus/aveclient plugins/virus/bitdefender plugins/virus/clamav plugins/virus/clamdscan plugins/virus/hbedv plugins/virus/kavscanner plugins/virus/klez_filter plugins/virus/sophie plugins/virus/uvscan
62 lines
1.8 KiB
Perl
62 lines
1.8 KiB
Perl
#!perl -Tw
|
|
|
|
=head1 NAME
|
|
|
|
check_badmailfrom - checks the badmailfrom config, with per-line reasons
|
|
|
|
=head1 DESCRIPTION
|
|
|
|
Reads the "badmailfrom" configuration like qmail-smtpd does. From the
|
|
qmail-smtpd docs:
|
|
|
|
"Unacceptable envelope sender addresses. qmail-smtpd will reject every
|
|
recipient address for a message if the envelope sender address is
|
|
listed in badmailfrom. A line in badmailfrom may be of the form
|
|
@host, meaning every address at host."
|
|
|
|
You may optionally include a message after the sender address (leave a space),
|
|
which is used when rejecting the sender.
|
|
|
|
=head1 NOTES
|
|
|
|
According to the SMTP protocol, we can't reject until after the RCPT
|
|
stage, so store it until later.
|
|
|
|
=cut
|
|
|
|
# TODO: add the ability to provide a custom default rejection reason
|
|
|
|
sub hook_mail {
|
|
my ($self, $transaction, $sender, %param) = @_;
|
|
|
|
my @badmailfrom = $self->qp->config("badmailfrom")
|
|
or return (DECLINED);
|
|
|
|
return (DECLINED) unless ($sender->format ne "<>"
|
|
and $sender->host && $sender->user);
|
|
|
|
my $host = lc $sender->host;
|
|
my $from = lc($sender->user) . '@' . $host;
|
|
|
|
for my $config (@badmailfrom) {
|
|
my ($bad, $reason) = $config =~ /^\s*(\S+)(?:\s*(.*))?$/;
|
|
$reason = "sorry, your envelope sender is in my badmailfrom list" unless $reason;
|
|
next unless $bad;
|
|
$bad = lc $bad;
|
|
$self->log(LOGWARN, "Bad badmailfrom config: No \@ sign in $bad") and next unless $bad =~ m/\@/;
|
|
$transaction->notes('badmailfrom', $reason)
|
|
if ($bad eq $from) || (substr($bad,0,1) eq '@' && $bad eq "\@$host");
|
|
}
|
|
return (DECLINED);
|
|
}
|
|
|
|
sub hook_rcpt {
|
|
my ($self, $transaction, $rcpt, %param) = @_;
|
|
my $note = $transaction->notes('badmailfrom');
|
|
if ($note) {
|
|
$self->log(LOGINFO, $note);
|
|
return (DENY, $note);
|
|
}
|
|
return (DECLINED);
|
|
}
|