1 |
diff -Nur -x '*.orig' -x '*.rej' qpsmtpd-0.96/docs/hooks.md mezzanine_patched_qpsmtpd-0.96/docs/hooks.md |
2 |
--- qpsmtpd-0.96/docs/hooks.md 2016-02-16 23:52:02.000000000 +0100 |
3 |
+++ mezzanine_patched_qpsmtpd-0.96/docs/hooks.md 2016-05-03 21:56:38.216306190 +0200 |
4 |
@@ -343,26 +343,20 @@ |
5 |
|
6 |
The `data_post_headers` hook is called after the client sends the final .\r\n of |
7 |
a message and before the message is processed by `data_post`. This hook is |
8 |
-primarily used by plugins that insert new headers (ex: Received-SPF) and/or |
9 |
+used by plugins that insert new headers (ex: Received-SPF) and/or |
10 |
modify headers such as appending to Authentication-Results (SPF, DKIM, DMARC). |
11 |
|
12 |
When it is desirable to have these header modifications evaluated by filtering |
13 |
software (spamassassin, dspam, etc.) running on `data_post`, this hook should be |
14 |
used instead of `data_post`. |
15 |
|
16 |
-Allowed return codes are |
17 |
- |
18 |
-- DENY |
19 |
- |
20 |
- Return a hard failure code |
21 |
+Note that you cannot reject in this hook, use the data_post hook instead |
22 |
|
23 |
-- DENYSOFT |
24 |
- |
25 |
- Return a soft failure code |
26 |
+Allowed return codes are |
27 |
|
28 |
-- DENY\_DISCONNECT / DENYSOFT\_DISCONNECT |
29 |
+- DECLINED |
30 |
|
31 |
- as above but with disconnect |
32 |
+ Do nothing |
33 |
|
34 |
## hook\_data\_post |
35 |
|
36 |
diff -Nur -x '*.orig' -x '*.rej' qpsmtpd-0.96/plugins/dmarc mezzanine_patched_qpsmtpd-0.96/plugins/dmarc |
37 |
--- qpsmtpd-0.96/plugins/dmarc 2016-02-16 23:52:02.000000000 +0100 |
38 |
+++ mezzanine_patched_qpsmtpd-0.96/plugins/dmarc 2016-05-03 21:57:11.943312651 +0200 |
39 |
@@ -102,6 +102,7 @@ |
40 |
else { |
41 |
$self->{_dmarc} = Mail::DMARC::PurePerl->new(); |
42 |
$self->register_hook('data_post_headers', 'check_dmarc'); |
43 |
+ $self->register_hook('data_post', 'reject_dmarc'); |
44 |
}; |
45 |
} |
46 |
|
47 |
@@ -189,6 +190,13 @@ |
48 |
return DECLINED if $self->is_immune; |
49 |
|
50 |
$self->adjust_karma(-3); |
51 |
-# at what point do we reject? |
52 |
- return $self->get_reject("failed DMARC policy"); |
53 |
+ # Add a mark now so the data_post hook can do the real reject |
54 |
+ $transaction->notes('reject_dmarc', '1'); |
55 |
+} |
56 |
+ |
57 |
+sub reject_dmarc { |
58 |
+ my ($self, $transaction) = @_; |
59 |
+ return $self->get_reject("failed DMARC policy") |
60 |
+ if ($transaction->notes('reject_dmarc')); |
61 |
+ return DECLINED; |
62 |
} |