This file is indexed.

/usr/share/perl5/Qpsmtpd/DSN.pm is in qpsmtpd 0.94-2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
#
# Enhanced Mail System Status Codes - RFC 1893
#
package Qpsmtpd::DSN;
use strict;
use Qpsmtpd::Constants;

=head1 NAME

Qpsmtpd::DSN - Enhanced Mail System Status Codes - RFC 1893

=head1 DESCRIPTION

The B<Qpsmtpd::DSN> implements the I<Enhanced Mail System Status Codes> from
RFC 1893.

=head1 USAGE

Any B<qpsmtpd> plugin can access these status codes. All sub routines are used
the same way:
 use Qpsmtpd::DSN;
 ...;
 return Qpsmtpd::DSN->relaying_denied();

or

 return Qpsmtpd::DSN->relaying_denied("Relaying from $ip denied");

or 

 return Qpsmtpd::DSN->relaying_denied(DENY,"Relaying from $ip denied");

If no status message was given, it will use the predefined one from the 
RFC. If the first argument is numeric, it will use this as a return code, 
else the default return code is used. See below which default return code
is used in the different functions.

The first example will return 
I<(DENY, "Relaying denied");>
the others 
I<(DENY, "Relaying from $ip denied");>
which will be returned to qpsmtpd.

In those sub routines which don't start with I<addr_, sys_, net_, proto_, 
media_, sec_> I've added a default message which describes the status better
than the RFC message.

=cut

my @rfc1893 = (
    [
     "Other or Undefined Status",    # x.0.x
    ],
    [
     "Other address status.",                                    # x.1.0
     "Bad destination mailbox address.",                         # x.1.1
     "Bad destination system address.",                          # x.1.2
     "Bad destination mailbox address syntax.",                  # x.1.3
     "Destination mailbox address ambiguous.",                   # x.1.4
     "Destination address valid.",                               # x.1.5
     "Destination mailbox has moved, No forwarding address.",    # x.1.6
     "Bad sender's mailbox address syntax.",                     # x.1.7
     "Bad sender's system address.",                             # x.1.8
    ],
    [
     "Other or undefined mailbox status.",                       # x.2.0
     "Mailbox disabled, not accepting messages.",                # x.2.1
     "Mailbox full.",                                            # x.2.2
     "Message length exceeds administrative limit.",             # x.2.3
     "Mailing list expansion problem.",                          # x.2.4
    ],
    [
     "Other or undefined mail system status.",                   # x.3.0
     "Mail system full.",                                        # x.3.1
     "System not accepting network messages.",                   # x.3.2
     "System not capable of selected features.",                 # x.3.3
     "Message too big for system.",                              # x.3.4
     "System incorrectly configured.",                           # x.3.5
    ],
    [
     "Other or undefined network or routing status.",            # x.4.0
     "No answer from host.",                                     # x.4.1
     "Bad connection.",                                          # x.4.2
     "Directory server failure.",                                # x.4.3
     "Unable to route.",                                         # x.4.4
     "Mail system congestion.",                                  # x.4.5
     "Routing loop detected.",                                   # x.4.6
     "Delivery time expired.",                                   # x.4.7
    ],
    [
     "Other or undefined protocol status.",                      # x.5.0
     "Invalid command.",                                         # x.5.1
     "Syntax error.",                                            # x.5.2
     "Too many recipients.",                                     # x.5.3
     "Invalid command arguments.",                               # x.5.4
     "Wrong protocol version.",                                  # x.5.5
    ],
    [
     "Other or undefined media error.",                          # x.6.0
     "Media not supported.",                                     # x.6.1
     "Conversion required and prohibited.",                      # x.6.2
     "Conversion required but not supported.",                   # x.6.3
     "Conversion with loss performed.",                          # x.6.4
     "Conversion Failed.",                                       # x.6.5
    ],
    [
     "Other or undefined security status.",                      # x.7.0
     "Delivery not authorized, message refused.",                # x.7.1
     "Mailing list expansion prohibited.",                       # x.7.2
     "Security conversion required but not possible.",           # x.7.3
     "Security features not supported.",                         # x.7.4
     "Cryptographic failure.",                                   # x.7.5
     "Cryptographic algorithm not supported.",                   # x.7.6
     "Message integrity failure.",                               # x.7.7
    ],
);

sub _status {
    my $return = shift;
    my $const  = Qpsmtpd::Constants::return_code($return);
    if ($const =~ /^DENYSOFT/) {
        return 4;
    }
    elsif ($const =~ /^DENY/) {
        return 5;
    }
    elsif ($const eq 'OK' or $const eq 'DONE') {
        return 2;
    }
    else {    # err .... no :)
        return 4;    # just 2,4,5 are allowed.. temp error by default
    }
}

sub _dsn {
    my ($self, $return, $reason, $default, $subject, $detail) = @_;
    if (!defined $return) {
        $return = $default;
    }
    elsif ($return !~ /^\d+$/) {
        $reason = $return;
        $return = $default;
    }
    my $msg = $rfc1893[$subject][$detail];
    unless (defined $msg) {
        $detail = 0;
        $msg    = $rfc1893[$subject][$detail];
        unless (defined $msg) {
            $subject = 0;
            $msg     = $rfc1893[$subject][$detail];
        }
    }
    my $class = &_status($return);
    if (defined $reason) {
        $msg = $reason;
    }
    return ($return, "$msg (#$class.$subject.$detail)");
}

sub unspecified { shift->_dsn(shift, shift, DENYSOFT, 0, 0); }

=head1 ADDRESS STATUS

=over 9

=item addr_unspecified

X.1.0
default: DENYSOFT

=cut

sub addr_unspecified { shift->_dsn(shift, shift, DENYSOFT, 1, 0); }

=item no_such_user, addr_bad_dest_mbox

X.1.1
default: DENY

=cut

sub no_such_user { shift->_dsn(shift, (shift || "No such user"), DENY, 1, 1); }
sub addr_bad_dest_mbox { shift->_dsn(shift, shift, DENY, 1, 1); }

=item addr_bad_dest_system 

X.1.2
default: DENY

=cut

sub addr_bad_dest_system { shift->_dsn(shift, shift, DENY, 1, 2); }

=item addr_bad_dest_syntax

X.1.3
default: DENY

=cut

sub addr_bad_dest_syntax { shift->_dsn(shift, shift, DENY, 1, 3); }

=item addr_dest_ambigous

X.1.4
default: DENYSOFT

=cut

sub addr_dest_ambigous { shift->_dsn(shift, shift, DENYSOFT, 1, 4); }

=item addr_rcpt_ok

X.1.5
default: OK

=cut

# XXX: do we need this? Maybe in all address verifying plugins?
sub addr_rcpt_ok { shift->_dsn(shift, shift, OK, 1, 5); }

=item addr_mbox_moved 

X.1.6
default: DENY

=cut

sub addr_mbox_moved { shift->_dsn(shift, shift, DENY, 1, 6); }

=item addr_bad_from_syntax

X.1.7
default: DENY

=cut 

sub addr_bad_from_syntax { shift->_dsn(shift, shift, DENY, 1, 7); }

=item addr_bad_from_system

X.1.8
default: DENY

=back

=cut

sub addr_bad_from_system { shift->_dsn(shift, shift, DENY, 1, 8); }

=head1 MAILBOX STATUS

=over 5

=item mbox_unspecified

X.2.0
default: DENYSOFT

=cut

sub mbox_unspecified { shift->_dsn(shift, shift, DENYSOFT, 2, 0); }

=item mbox_disabled

X.2.1
default: DENY ...but RFC says:
   The mailbox exists, but is not accepting messages.  This may
   be a permanent error if the mailbox will never be re-enabled
   or a transient error if the mailbox is only temporarily
   disabled.

=cut 

sub mbox_disabled { shift->_dsn(shift, shift, DENY, 2, 1); }

=item mbox_full

X.2.2
default: DENYSOFT

=cut

sub mbox_full { shift->_dsn(shift, shift, DENYSOFT, 2, 2); }

=item mbox_msg_too_long 

X.2.3
default: DENY

=cut

sub mbox_msg_too_long { shift->_dsn(shift, shift, DENY, 2, 3); }

=item mbox_list_expansion_problem   

X.2.4
default: DENYSOFT

=back

=cut

sub mbox_list_expansion_problem { shift->_dsn(shift, shift, DENYSOFT, 2, 4); }

=head1 MAIL SYSTEM STATUS

=over 4

=item sys_unspecified

X.3.0
default: DENYSOFT

=cut

sub sys_unspecified { shift->_dsn(shift, shift, DENYSOFT, 3, 0); }

=item sys_disk_full

X.3.1
default: DENYSOFT

=cut

sub sys_disk_full { shift->_dsn(shift, shift, DENYSOFT, 3, 1); }

=item sys_not_accepting_mail

X.3.2
default: DENYSOFT

=cut

sub sys_not_accepting_mail { shift->_dsn(shift, shift, DENYSOFT, 3, 2); }

=item sys_not_supported

X.3.3
default: DENYSOFT
          Selected features specified for the message are not
          supported by the destination system.  This can occur in
          gateways when features from one domain cannot be mapped onto
          the supported feature in another.

=cut

sub sys_not_supported { shift->_dsn(shift, shift, DENYSOFT, 3, 3); }

=item sys_msg_too_big           

X.3.4
default DENY

=back

=cut

sub sys_msg_too_big { shift->_dsn(shift, shift, DENY, 3, 4); }

=head1 NETWORK AND ROUTING STATUS

=cut

=over 4

=item net_unspecified 

X.4.0
default: DENYSOFT

=cut 

sub net_unspecified { shift->_dsn(shift, shift, DENYSOFT, 4, 0); }

# not useful # sub net_no_answer   { shift->_dsn(shift,shift,4,1); }
# not useful # sub net_bad_connection { shift->_dsn(shift,shift,4,2); }

=item net_directory_server_failed, temp_resolver_failed

X.4.3
default: DENYSOFT

=cut

sub temp_resolver_failed {
    shift->_dsn(shift, (shift || "Temporary address resolution failure"),
                DENYSOFT, 4, 3);
}
sub net_directory_server_failed { shift->_dsn(shift, shift, DENYSOFT, 4, 3); }

# not useful # sub net_unable_to_route { shift->_dsn(shift,shift,4,4); }

=item net_system_congested

X.4.5
default: DENYSOFT

=cut

sub net_system_congested { shift->_dsn(shift, shift, DENYSOFT, 4, 5); }

=item net_routing_loop, too_many_hops

X.4.6
default: DENY, but RFC says:
  A routing loop caused the message to be forwarded too many
  times, either because of incorrect routing tables or a user
  forwarding loop. This is useful only as a persistent
  transient error.

Why do we want to DENYSOFT something like this?

=back

=cut

sub net_routing_loop { shift->_dsn(shift, shift, DENY, 4, 6); }
sub too_many_hops {
    shift->_dsn(shift, (shift || "Too many hops"), DENY, 4, 6,);
}

# not useful # sub delivery_time_expired    { shift->_dsn(shift,shift,4,7); }

=head1 MAIL DELIVERY PROTOCOL STATUS

=over 6

=item proto_unspecified

X.5.0
default: DENYSOFT

=cut

sub proto_unspecified { shift->_dsn(shift, shift, DENYSOFT, 5, 0); }

=item proto_invalid_command

X.5.1
default: DENY

=cut

sub proto_invalid_command { shift->_dsn(shift, shift, DENY, 5, 1); }

=item proto_syntax_error

X.5.2
default: DENY

=cut

sub proto_syntax_error { shift->_dsn(shift, shift, DENY, 5, 2); }

=item proto_rcpt_list_too_long, too_many_rcpts

X.5.3
default: DENYSOFT

=cut

sub proto_rcpt_list_too_long { shift->_dsn(shift, shift, DENYSOFT, 5, 3); }
sub too_many_rcpts           { shift->_dsn(shift, shift, DENYSOFT, 5, 3); }

=item proto_invalid_cmd_args 

X.5.4
default: DENY

=cut

sub proto_invalid_cmd_args { shift->_dsn(shift, shift, DENY, 5, 4); }

=item proto_wrong_version 

X.5.5
default: DENYSOFT

=back

=cut

sub proto_wrong_version { shift->_dsn(shift, shift, DENYSOFT, 5, 5); }

=head1 MESSAGE CONTENT OR MESSAGE MEDIA STATUS

=over 5

=item media_unspecified

X.6.0
default: DENYSOFT

=cut

sub media_unspecified { shift->_dsn(shift, shift, DENYSOFT, 6, 0); }

=item media_unsupported

X.6.1
default: DENY

=cut

sub media_unsupported { shift->_dsn(shift, shift, DENY, 6, 1); }

=item media_conv_prohibited

X.6.2
default: DENY

=cut

sub media_conv_prohibited { shift->_dsn(shift, shift, DENY, 6, 2); }

=item media_conv_unsupported

X.6.3
default: DENYSOFT

=cut

sub media_conv_unsupported { shift->_dsn(shift, shift, DENYSOFT, 6, 3); }

=item media_conv_lossy

X.6.4
default: DENYSOFT

=back 

=cut

sub media_conv_lossy { shift->_dsn(shift, shift, DENYSOFT, 6, 4); }

=head1 SECURITY OR POLICY STATUS

=over 8

=item sec_unspecified

X.7.0
default: DENYSOFT

=cut

sub sec_unspecified { shift->_dsn(shift, shift, DENYSOFT, 7, 0); }

=item sec_sender_unauthorized, bad_sender_ip, relaying_denied 

X.7.1
default: DENY

=cut

sub sec_sender_unauthorized { shift->_dsn(shift, shift, DENY, 7, 1); }

sub bad_sender_ip {
    shift->_dsn(shift, (shift || "Bad sender's IP"), DENY, 7, 1,);
}

sub relaying_denied {
    shift->_dsn(shift, (shift || "Relaying denied"), DENY, 7, 1);
}

=item sec_list_dest_prohibited

X.7.2
default: DENY

=cut

sub sec_list_dest_prohibited { shift->_dsn(shift, shift, DENY, 7, 2); }

=item sec_conv_failed 

X.7.3
default: DENY

=cut

sub sec_conv_failed { shift->_dsn(shift, shift, DENY, 7, 3); }

=item sec_feature_unsupported 

X.7.4
default: DENY

=cut

sub sec_feature_unsupported { shift->_dsn(shift, shift, DENY, 7, 4); }

=item sec_crypto_failure

X.7.5
default: DENY

=cut

sub sec_crypto_failure { shift->_dsn(shift, shift, DENY, 7, 5); }

=item sec_crypto_algorithm_unsupported

X.7.6
default: DENYSOFT

=cut

sub sec_crypto_algorithm_unsupported {
    shift->_dsn(shift, shift, DENYSOFT, 7, 6);
}

=item sec_msg_integrity_failure

X.7.7
default: DENY

=back

=cut

sub sec_msg_integrity_failure { shift->_dsn(shift, shift, DENY, 7, 7); }

1;

# vim: st=4 sw=4 expandtab