Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
94 | magnus | 1 | From: Sebastian Schweizer <sebastian@schweizer.tel> |
2 | Subject: Return header info also in case of missing or multiple SPF records. |
||
3 | Bug: https://bugs.debian.org/806313 |
||
4 | Forwarded: https://github.com/shevek/libspf2/pull/9 |
||
5 | |||
6 | diff --git a/src/libspf2/spf_interpret.c b/src/libspf2/spf_interpret.c |
||
7 | index a35b58c..5f15df4 100644 |
||
8 | --- a/src/libspf2/spf_interpret.c |
||
9 | +++ b/src/libspf2/spf_interpret.c |
||
10 | @@ -104,7 +104,6 @@ SPF_i_set_smtp_comment(SPF_response_t *spf_response) |
||
11 | case SPF_RESULT_FAIL: |
||
12 | case SPF_RESULT_SOFTFAIL: |
||
13 | case SPF_RESULT_NEUTRAL: |
||
14 | - case SPF_RESULT_NONE: |
||
15 | |||
16 | err = SPF_i_set_explanation(spf_response); |
||
17 | if (err != SPF_E_SUCCESS) |
||
18 | @@ -126,6 +125,7 @@ SPF_i_set_smtp_comment(SPF_response_t *spf_response) |
||
19 | case SPF_RESULT_PASS: |
||
20 | case SPF_RESULT_TEMPERROR: |
||
21 | case SPF_RESULT_PERMERROR: |
||
22 | + case SPF_RESULT_NONE: |
||
23 | default: |
||
24 | break; |
||
25 | } |
||
26 | @@ -380,7 +380,7 @@ SPF_i_set_received_spf(SPF_response_t *spf_response) |
||
27 | * This must be called with EITHER |
||
28 | * spf_response->spf_record_exp != NULL |
||
29 | * OR |
||
30 | - * result in { SPF_RESULT_PASS SPF_RESULT_INVALID |
||
31 | + * result in { SPF_RESULT_NONE SPF_RESULT_PASS SPF_RESULT_INVALID |
||
32 | * SPF_RESULT_TEMPERROR SPF_RESULT_PERMERROR } |
||
33 | * or the library will abort when it tries to generate an explanation. |
||
34 | */ |
||
35 | diff --git a/src/libspf2/spf_server.c b/src/libspf2/spf_server.c |
||
36 | index d648b4e..66beb69 100644 |
||
37 | --- a/src/libspf2/spf_server.c |
||
38 | +++ b/src/libspf2/spf_server.c |
||
39 | @@ -361,8 +361,9 @@ retry: |
||
40 | } |
||
41 | spf_response->result = SPF_RESULT_NONE; |
||
42 | spf_response->reason = SPF_REASON_FAILURE; |
||
43 | - return SPF_response_add_error(spf_response, SPF_E_NOT_SPF, |
||
44 | - "Host '%s' not found.", domain); |
||
45 | + return SPF_i_done(spf_response, SPF_RESULT_NONE, SPF_REASON_FAILURE, |
||
46 | + SPF_response_add_error(spf_response, SPF_E_NOT_SPF, |
||
47 | + "Host '%s' not found.", domain)); |
||
48 | // break; |
||
49 | |||
50 | case NO_DATA: |
||
51 | @@ -375,8 +376,9 @@ retry: |
||
52 | } |
||
53 | spf_response->result = SPF_RESULT_NONE; |
||
54 | spf_response->reason = SPF_REASON_FAILURE; |
||
55 | - return SPF_response_add_error(spf_response, SPF_E_NOT_SPF, |
||
56 | - "No DNS data for '%s'.", domain); |
||
57 | + return SPF_i_done(spf_response, SPF_RESULT_NONE, SPF_REASON_FAILURE, |
||
58 | + SPF_response_add_error(spf_response, SPF_E_NOT_SPF, |
||
59 | + "No DNS data for '%s'.", domain)); |
||
60 | // break; |
||
61 | |||
62 | case TRY_AGAIN: |
||
63 | @@ -453,17 +455,18 @@ retry: |
||
64 | } |
||
65 | spf_response->result = SPF_RESULT_NONE; |
||
66 | spf_response->reason = SPF_REASON_FAILURE; |
||
67 | - return SPF_response_add_error(spf_response, SPF_E_NOT_SPF, |
||
68 | - "No SPF records for '%s'", domain); |
||
69 | + return SPF_i_done(spf_response, SPF_RESULT_NONE, SPF_REASON_FAILURE, |
||
70 | + SPF_response_add_error(spf_response, SPF_E_NOT_SPF, |
||
71 | + "No SPF records for '%s'", domain)); |
||
72 | } |
||
73 | if (num_found > 1) { |
||
74 | SPF_dns_rr_free(rr_txt); |
||
75 | // rfc4408 requires permerror here. |
||
76 | - /* XXX This could be refactored with SPF_i_done. */ |
||
77 | spf_response->result = SPF_RESULT_PERMERROR; |
||
78 | spf_response->reason = SPF_REASON_FAILURE; |
||
79 | - return SPF_response_add_error(spf_response, SPF_E_MULTIPLE_RECORDS, |
||
80 | - "Multiple SPF records for '%s'", domain); |
||
81 | + return SPF_i_done(spf_response, SPF_RESULT_PERMERROR, SPF_REASON_FAILURE, |
||
82 | + SPF_response_add_error(spf_response, SPF_E_MULTIPLE_RECORDS, |
||
83 | + "Multiple SPF records for '%s'", domain)); |
||
84 | } |
||
85 | |||
86 | /* try to compile the SPF record */ |