line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mail::Qmail::Queue::Error; |
2
|
|
|
|
|
|
|
our $VERSION = 0.02; |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
# Copyright 2006 Scott Gifford |
5
|
|
|
|
|
|
|
# |
6
|
|
|
|
|
|
|
# This library is free software; you can redistribute it and/or |
7
|
|
|
|
|
|
|
# modify it under the same terms as Perl itself. |
8
|
|
|
|
|
|
|
|
9
|
8
|
|
|
8
|
|
59139
|
use warnings; |
|
8
|
|
|
|
|
16
|
|
|
8
|
|
|
|
|
392
|
|
10
|
8
|
|
|
8
|
|
47
|
use strict; |
|
8
|
|
|
|
|
19
|
|
|
8
|
|
|
|
|
337
|
|
11
|
|
|
|
|
|
|
|
12
|
8
|
|
|
8
|
|
54
|
use base 'Exporter'; |
|
8
|
|
|
|
|
16
|
|
|
8
|
|
|
|
|
1974
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
our %EXPORT_TAGS = ( |
15
|
|
|
|
|
|
|
errcodes => [qw( |
16
|
|
|
|
|
|
|
QQ_EXIT_ADDR_TOO_LONG QQ_EXIT_REFUSED QQ_EXIT_NOMEM QQ_EXIT_TIMEOUT |
17
|
|
|
|
|
|
|
QQ_EXIT_WRITEERR QQ_EXIT_READERR QQ_EXIT_BADCONF QQ_EXIT_NETERR |
18
|
|
|
|
|
|
|
QQ_EXIT_BADQHOME QQ_EXIT_BADQUEUEDIR QQ_EXIT_BADQUEUEPID |
19
|
|
|
|
|
|
|
QQ_EXIT_BADQUEUEMESS QQ_EXIT_BADQUEUEINTD QQ_EXIT_BADQUEUETODO |
20
|
|
|
|
|
|
|
QQ_EXIT_TEMPREFUSE QQ_EXIT_CONNTIMEOUT QQ_EXIT_NETREJECT |
21
|
|
|
|
|
|
|
QQ_EXIT_NETFAIL QQ_EXIT_BUG QQ_EXIT_BADENVELOPE |
22
|
|
|
|
|
|
|
)], |
23
|
|
|
|
|
|
|
fail => [qw(tempfail permfail qfail)], |
24
|
|
|
|
|
|
|
test => [qw(is_tempfail is_permfail)], |
25
|
|
|
|
|
|
|
); |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
our @EXPORT_OK = (map { @$_} values %EXPORT_TAGS); |
28
|
|
|
|
|
|
|
|
29
|
8
|
|
|
8
|
|
51
|
use Carp; |
|
8
|
|
|
|
|
12
|
|
|
8
|
|
|
|
|
4107
|
|
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=head1 NAME |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
Mail::Qmail::Queue::Error - Error handling for programs which emulate or use qmail-queue. |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=head1 SYNOPSIS |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
use Mail::Qmail::Queue::Error qw(:errcodes :fail); |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
print "blah\n" |
40
|
|
|
|
|
|
|
or tempfail QQ_EXIT_WRITEERR,"Write error: $!\n"; |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
if (has_virus($body)) { |
43
|
|
|
|
|
|
|
permfail QQ_EXIT_REFUSED,"Message refused: it has a virus!!\n"; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
qfail $exit_status,"qmail-queue exited $exit_status\n"; |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=head1 DESCRIPTION |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
C is designed to simplify error handling |
51
|
|
|
|
|
|
|
for a program which emulates or uses a program implementing the |
52
|
|
|
|
|
|
|
L interface. It declares constants for |
53
|
|
|
|
|
|
|
a variety of permanent and temporary error codes, and provides |
54
|
|
|
|
|
|
|
shorthand methods similar to C that return an appropriate error |
55
|
|
|
|
|
|
|
code. It also provides some methods to look at an error code returned |
56
|
|
|
|
|
|
|
by C and determine whether it is temporary or permanent. |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=head2 CONSTANTS |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
These constants are defined in L. They are mostly |
61
|
|
|
|
|
|
|
self-explanatory. |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head3 Permanent Errors |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=over 4 |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=item QQ_EXIT_ADDR_TOO_LONG |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=cut |
70
|
|
|
|
|
|
|
|
71
|
8
|
|
|
8
|
|
83
|
use constant QQ_EXIT_ADDR_TOO_LONG => 11; |
|
8
|
|
|
|
|
18
|
|
|
8
|
|
|
|
|
687
|
|
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=item QQ_EXIT_REFUSED |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=cut |
76
|
|
|
|
|
|
|
|
77
|
8
|
|
|
8
|
|
45
|
use constant QQ_EXIT_REFUSED => 31; |
|
8
|
|
|
|
|
35
|
|
|
8
|
|
|
|
|
425
|
|
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=back |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head3 Temporary Errors |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=over 4 |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=item QQ_EXIT_NOMEM |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=cut |
88
|
|
|
|
|
|
|
|
89
|
8
|
|
|
8
|
|
41
|
use constant QQ_EXIT_NOMEM => 51; |
|
8
|
|
|
|
|
16
|
|
|
8
|
|
|
|
|
373
|
|
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=item QQ_EXIT_TIMEOUT |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=cut |
94
|
|
|
|
|
|
|
|
95
|
8
|
|
|
8
|
|
42
|
use constant QQ_EXIT_TIMEOUT => 52; |
|
8
|
|
|
|
|
16
|
|
|
8
|
|
|
|
|
382
|
|
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=item QQ_EXIT_WRITEERR |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=cut |
100
|
|
|
|
|
|
|
|
101
|
8
|
|
|
8
|
|
45
|
use constant QQ_EXIT_WRITEERR => 53; |
|
8
|
|
|
|
|
21
|
|
|
8
|
|
|
|
|
514
|
|
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=item QQ_EXIT_READERR |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=cut |
106
|
|
|
|
|
|
|
|
107
|
8
|
|
|
8
|
|
59
|
use constant QQ_EXIT_READERR => 54; |
|
8
|
|
|
|
|
15
|
|
|
8
|
|
|
|
|
352
|
|
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=item QQ_EXIT_BADCONF |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=cut |
112
|
|
|
|
|
|
|
|
113
|
8
|
|
|
8
|
|
37
|
use constant QQ_EXIT_BADCONF => 55; |
|
8
|
|
|
|
|
13
|
|
|
8
|
|
|
|
|
362
|
|
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=item QQ_EXIT_NETERR |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=cut |
118
|
|
|
|
|
|
|
|
119
|
8
|
|
|
8
|
|
40
|
use constant QQ_EXIT_NETERR => 56; |
|
8
|
|
|
|
|
14
|
|
|
8
|
|
|
|
|
336
|
|
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=item QQ_EXIT_BADQHOME |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=cut |
124
|
|
|
|
|
|
|
|
125
|
8
|
|
|
8
|
|
40
|
use constant QQ_EXIT_BADQHOME => 61; |
|
8
|
|
|
|
|
33
|
|
|
8
|
|
|
|
|
368
|
|
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=item QQ_EXIT_BADQUEUEDIR |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=cut |
130
|
|
|
|
|
|
|
|
131
|
8
|
|
|
8
|
|
59
|
use constant QQ_EXIT_BADQUEUEDIR => 62; |
|
8
|
|
|
|
|
10
|
|
|
8
|
|
|
|
|
356
|
|
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=item QQ_EXIT_BADQUEUEPID |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=cut |
136
|
|
|
|
|
|
|
|
137
|
8
|
|
|
8
|
|
38
|
use constant QQ_EXIT_BADQUEUEPID => 63; |
|
8
|
|
|
|
|
15
|
|
|
8
|
|
|
|
|
345
|
|
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=item QQ_EXIT_BADQUEUEMESS |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=cut |
142
|
|
|
|
|
|
|
|
143
|
8
|
|
|
8
|
|
35
|
use constant QQ_EXIT_BADQUEUEMESS => 64; |
|
8
|
|
|
|
|
12
|
|
|
8
|
|
|
|
|
493
|
|
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=item QQ_EXIT_BADQUEUEINTD |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=cut |
148
|
|
|
|
|
|
|
|
149
|
8
|
|
|
8
|
|
37
|
use constant QQ_EXIT_BADQUEUEINTD => 65; |
|
8
|
|
|
|
|
14
|
|
|
8
|
|
|
|
|
330
|
|
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=item QQ_EXIT_BADQUEUETODO |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=cut |
154
|
|
|
|
|
|
|
|
155
|
8
|
|
|
8
|
|
58
|
use constant QQ_EXIT_BADQUEUETODO => 66; |
|
8
|
|
|
|
|
25
|
|
|
8
|
|
|
|
|
351
|
|
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
=item QQ_EXIT_TEMPREFUSE |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=cut |
160
|
|
|
|
|
|
|
|
161
|
8
|
|
|
8
|
|
37
|
use constant QQ_EXIT_TEMPREFUSE => 71; |
|
8
|
|
|
|
|
14
|
|
|
8
|
|
|
|
|
343
|
|
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
=item QQ_EXIT_CONNTIMEOUT |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=cut |
166
|
|
|
|
|
|
|
|
167
|
8
|
|
|
8
|
|
38
|
use constant QQ_EXIT_CONNTIMEOUT => 72; |
|
8
|
|
|
|
|
12
|
|
|
8
|
|
|
|
|
325
|
|
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
=item QQ_EXIT_NETREJECT |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
=cut |
172
|
|
|
|
|
|
|
|
173
|
8
|
|
|
8
|
|
37
|
use constant QQ_EXIT_NETREJECT => 73; |
|
8
|
|
|
|
|
10
|
|
|
8
|
|
|
|
|
374
|
|
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
=item QQ_EXIT_NETFAIL |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
=cut |
178
|
|
|
|
|
|
|
|
179
|
8
|
|
|
8
|
|
39
|
use constant QQ_EXIT_NETFAIL => 74; |
|
8
|
|
|
|
|
12
|
|
|
8
|
|
|
|
|
344
|
|
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
=item QQ_EXIT_BUG |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
=cut |
184
|
|
|
|
|
|
|
|
185
|
8
|
|
|
8
|
|
38
|
use constant QQ_EXIT_BUG => 81; |
|
8
|
|
|
|
|
16
|
|
|
8
|
|
|
|
|
359
|
|
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
=item QQ_EXIT_BADENVELOPE |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
=cut |
190
|
|
|
|
|
|
|
|
191
|
8
|
|
|
8
|
|
88
|
use constant QQ_EXIT_BADENVELOPE => 91; |
|
8
|
|
|
|
|
14
|
|
|
8
|
|
|
|
|
3125
|
|
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
=back |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
=head2 FUNCTIONS |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
=over 4 |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
=item tempfail ( [$failcode,] @message ) |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
Exit with a temporary failure code, or C if in an C. If |
202
|
|
|
|
|
|
|
the first argument is numeric, or if the message starts with a number, |
203
|
|
|
|
|
|
|
that will be used as the exit code. Otherwise, the temporary failure |
204
|
|
|
|
|
|
|
code C will be used. |
205
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
Note that no checking of the failure code is done; if you pass a code |
207
|
|
|
|
|
|
|
that does not indicate temporary failure, it will be used as is. |
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
=cut |
210
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
sub tempfail(@) |
212
|
|
|
|
|
|
|
{ |
213
|
4
|
|
|
4
|
1
|
977
|
unshift(@_,QQ_EXIT_BUG); |
214
|
4
|
|
|
|
|
12
|
goto &_fail; |
215
|
|
|
|
|
|
|
} |
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
=item permfail ( [$failcode,] @message ) |
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
Exit with a permanent failure code, or C if in an C. If |
220
|
|
|
|
|
|
|
the first argument is numeric, that will be used as the exit code. |
221
|
|
|
|
|
|
|
Otherwise, the permanent failure code C will be used. |
222
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
Note that no checking of the failure code is done; if you pass a code |
224
|
|
|
|
|
|
|
that does not indicate permanent failure, it will be used as is. |
225
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
=cut |
227
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
sub permfail(@) |
229
|
|
|
|
|
|
|
{ |
230
|
|
|
|
|
|
|
|
231
|
2
|
|
|
2
|
1
|
2376
|
unshift(@_,QQ_EXIT_REFUSED); |
232
|
2
|
|
|
|
|
7
|
goto &_fail; |
233
|
|
|
|
|
|
|
} |
234
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
=item qfail ( [$failcode,] @message ) |
236
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
Exit with a failure code, or C if in an C. If the first |
238
|
|
|
|
|
|
|
argument is numeric, that will be used as the exit code. Otherwise, |
239
|
|
|
|
|
|
|
the temporary failure code C will be used. |
240
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
=cut |
242
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
sub qfail(@) |
244
|
|
|
|
|
|
|
{ |
245
|
2
|
|
|
2
|
1
|
2112
|
goto &tempfail; |
246
|
|
|
|
|
|
|
} |
247
|
|
|
|
|
|
|
|
248
|
|
|
|
|
|
|
=item is_tempfail ( $exit_value ) |
249
|
|
|
|
|
|
|
|
250
|
|
|
|
|
|
|
Test if the provided value is a temporary exit status. |
251
|
|
|
|
|
|
|
|
252
|
|
|
|
|
|
|
=cut |
253
|
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
sub is_tempfail |
255
|
|
|
|
|
|
|
{ |
256
|
18
|
|
|
18
|
1
|
41
|
return !is_permfail(@_); |
257
|
|
|
|
|
|
|
} |
258
|
|
|
|
|
|
|
|
259
|
|
|
|
|
|
|
=item is_permfail |
260
|
|
|
|
|
|
|
|
261
|
|
|
|
|
|
|
Test if the provided value is a permanent exit status. |
262
|
|
|
|
|
|
|
|
263
|
|
|
|
|
|
|
=cut |
264
|
|
|
|
|
|
|
|
265
|
|
|
|
|
|
|
sub is_permfail |
266
|
|
|
|
|
|
|
{ |
267
|
20
|
|
66
|
20
|
1
|
1241
|
return ($_[0] >= 11 and $_[0] <= 40); |
268
|
|
|
|
|
|
|
} |
269
|
|
|
|
|
|
|
|
270
|
|
|
|
|
|
|
sub _fail(@) |
271
|
|
|
|
|
|
|
{ |
272
|
6
|
|
|
6
|
|
9
|
my $default_ec = shift; |
273
|
6
|
50
|
|
|
|
21
|
if ($^S) |
274
|
|
|
|
|
|
|
{ |
275
|
|
|
|
|
|
|
# Eval |
276
|
0
|
|
|
|
|
0
|
die @_; |
277
|
|
|
|
|
|
|
} |
278
|
6
|
100
|
|
|
|
30
|
my $ec = ($_[0] =~ /^\d+$/) ? shift : $default_ec; |
279
|
|
|
|
|
|
|
|
280
|
6
|
|
|
|
|
997
|
carp @_; |
281
|
6
|
|
|
|
|
43
|
exit($ec); |
282
|
|
|
|
|
|
|
} |
283
|
|
|
|
|
|
|
|
284
|
|
|
|
|
|
|
=back |
285
|
|
|
|
|
|
|
|
286
|
|
|
|
|
|
|
=head1 SEE ALSO |
287
|
|
|
|
|
|
|
|
288
|
|
|
|
|
|
|
L, L, |
289
|
|
|
|
|
|
|
L, |
290
|
|
|
|
|
|
|
L, L. |
291
|
|
|
|
|
|
|
|
292
|
|
|
|
|
|
|
=head1 COPYRIGHT |
293
|
|
|
|
|
|
|
|
294
|
|
|
|
|
|
|
Copyright 2006 Scott Gifford. |
295
|
|
|
|
|
|
|
|
296
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or |
297
|
|
|
|
|
|
|
modify it under the same terms as Perl itself. |
298
|
|
|
|
|
|
|
|
299
|
|
|
|
|
|
|
=cut |
300
|
|
|
|
|
|
|
|
301
|
|
|
|
|
|
|
1; |