line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# Mail::SPF::Mech::Include |
3
|
|
|
|
|
|
|
# SPF record "include" mechanism class. |
4
|
|
|
|
|
|
|
# |
5
|
|
|
|
|
|
|
# (C) 2005-2012 Julian Mehnle |
6
|
|
|
|
|
|
|
# 2005 Shevek |
7
|
|
|
|
|
|
|
# $Id: Include.pm 57 2012-01-30 08:15:31Z julian $ |
8
|
|
|
|
|
|
|
# |
9
|
|
|
|
|
|
|
############################################################################## |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
package Mail::SPF::Mech::Include; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 NAME |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
Mail::SPF::Mech::Include - SPF record C mechanism class |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=cut |
18
|
|
|
|
|
|
|
|
19
|
1
|
|
|
1
|
|
929
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
24
|
|
20
|
1
|
|
|
1
|
|
4
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
24
|
|
21
|
|
|
|
|
|
|
|
22
|
1
|
|
|
1
|
|
4
|
use base 'Mail::SPF::Mech'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
60
|
|
23
|
|
|
|
|
|
|
|
24
|
1
|
|
|
1
|
|
4
|
use constant TRUE => (0 == 0); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
45
|
|
25
|
1
|
|
|
1
|
|
4
|
use constant FALSE => not TRUE; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
34
|
|
26
|
|
|
|
|
|
|
|
27
|
1
|
|
|
1
|
|
4
|
use constant name => 'include'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
49
|
|
28
|
1
|
|
|
1
|
|
4
|
use constant name_pattern => qr/${\name}/i; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
296
|
|
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=head1 DESCRIPTION |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
An object of class B represents an SPF record |
33
|
|
|
|
|
|
|
mechanism of type C. |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=head2 Constructors |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
The following constructors are provided: |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=over |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=item B: returns I |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
Creates a new SPF record C mechanism object. |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
%options is a list of key/value pairs representing any of the following |
46
|
|
|
|
|
|
|
options: |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=over |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=item B |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=item B |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
See L. |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=back |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=item B: returns I; |
59
|
|
|
|
|
|
|
throws I, I |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
Creates a new SPF record C mechanism object by parsing the string and |
62
|
|
|
|
|
|
|
any options given. |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=back |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head2 Class methods |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
The following class methods are provided: |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=over |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=item B |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=item B |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
See L. |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=item B: returns I |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
Returns B<'include'>. |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=item B: returns I |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
Returns a regular expression that matches a mechanism name of B<'include'>. |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=back |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=head2 Instance methods |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
The following instance methods are provided: |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=over |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=cut |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
sub parse_params { |
97
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
98
|
0
|
|
|
|
|
|
$self->parse_domain_spec(TRUE); |
99
|
0
|
|
|
|
|
|
return; |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=item B |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=item B |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=item B |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=cut |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
sub params { |
111
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
112
|
0
|
0
|
|
|
|
|
return defined($self->{domain_spec}) ? ':' . $self->{domain_spec} : undef; |
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=item B |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
See L. |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=item B: returns I |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
Returns the C parameter of the mechanism. |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=cut |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
# Make read-only accessor: |
126
|
|
|
|
|
|
|
__PACKAGE__->make_accessor('domain_spec', TRUE); |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=item B: returns I |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
Performs a recursive SPF check using the given SPF server and request objects |
131
|
|
|
|
|
|
|
and substituting the mechanism's target domain name for the request's authority |
132
|
|
|
|
|
|
|
domain. The result of the recursive SPF check is translated as follows: |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
Recursive result | Effect |
135
|
|
|
|
|
|
|
------------------+----------------- |
136
|
|
|
|
|
|
|
pass | return true |
137
|
|
|
|
|
|
|
fail | return false |
138
|
|
|
|
|
|
|
softfail | return false |
139
|
|
|
|
|
|
|
neutral | return false |
140
|
|
|
|
|
|
|
none | throw PermError |
141
|
|
|
|
|
|
|
permerror | throw PermError |
142
|
|
|
|
|
|
|
temperror | throw TempError |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
See RFC 4408, 5.2, for the exact algorithm used. |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=cut |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
sub match { |
149
|
0
|
|
|
0
|
1
|
|
my ($self, $server, $request) = @_; |
150
|
|
|
|
|
|
|
|
151
|
0
|
|
|
|
|
|
$server->count_dns_interactive_term($request); |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
# Create sub-request with mutated authority domain: |
154
|
0
|
|
|
|
|
|
my $authority_domain = $self->domain($server, $request); |
155
|
0
|
|
|
|
|
|
my $sub_request = $request->new_sub_request(authority_domain => $authority_domain); |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
# Process sub-request: |
158
|
0
|
|
|
|
|
|
my $result = $server->process($sub_request); |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
# Translate result of sub-request (RFC 4408, 5/9): |
161
|
|
|
|
|
|
|
|
162
|
0
|
0
|
|
|
|
|
return TRUE |
163
|
|
|
|
|
|
|
if $result->isa('Mail::SPF::Result::Pass'); |
164
|
|
|
|
|
|
|
|
165
|
0
|
0
|
0
|
|
|
|
return FALSE |
|
|
|
0
|
|
|
|
|
166
|
|
|
|
|
|
|
if $result->isa('Mail::SPF::Result::Fail') |
167
|
|
|
|
|
|
|
or $result->isa('Mail::SPF::Result::SoftFail') |
168
|
|
|
|
|
|
|
or $result->isa('Mail::SPF::Result::Neutral'); |
169
|
|
|
|
|
|
|
|
170
|
0
|
0
|
|
|
|
|
$server->throw_result('permerror', $request, |
171
|
|
|
|
|
|
|
"Included domain '$authority_domain' has no applicable sender policy") |
172
|
|
|
|
|
|
|
if $result->isa('Mail::SPF::Result::None'); |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
# Propagate any other results (including {Perm,Temp}Error) as-is: |
175
|
0
|
|
|
|
|
|
$result->throw(); |
176
|
|
|
|
|
|
|
} |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
=back |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
=head1 SEE ALSO |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
L, L, L, L |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
L |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
For availability, support, and license information, see the README file |
187
|
|
|
|
|
|
|
included with Mail::SPF. |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
=head1 AUTHORS |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
Julian Mehnle , Shevek |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
=cut |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
TRUE; |