xref: /illumos-gate/usr/src/cmd/mail/mta_ercode.c (revision 7c478bd9)
1*7c478bd9Sstevel@tonic-gate /*
2*7c478bd9Sstevel@tonic-gate  * CDDL HEADER START
3*7c478bd9Sstevel@tonic-gate  *
4*7c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*7c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*7c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*7c478bd9Sstevel@tonic-gate  * with the License.
8*7c478bd9Sstevel@tonic-gate  *
9*7c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*7c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*7c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*7c478bd9Sstevel@tonic-gate  * and limitations under the License.
13*7c478bd9Sstevel@tonic-gate  *
14*7c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*7c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*7c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*7c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*7c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*7c478bd9Sstevel@tonic-gate  *
20*7c478bd9Sstevel@tonic-gate  * CDDL HEADER END
21*7c478bd9Sstevel@tonic-gate  */
22*7c478bd9Sstevel@tonic-gate /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
23*7c478bd9Sstevel@tonic-gate /*	  All Rights Reserved  	*/
24*7c478bd9Sstevel@tonic-gate 
25*7c478bd9Sstevel@tonic-gate 
26*7c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
27*7c478bd9Sstevel@tonic-gate 	 	/* SVr4.0 2.	*/
28*7c478bd9Sstevel@tonic-gate #include "mail.h"
29*7c478bd9Sstevel@tonic-gate /*
30*7c478bd9Sstevel@tonic-gate  * Map mail(1) error into MTA reason-codes for negative delivery notification.
31*7c478bd9Sstevel@tonic-gate  */
32*7c478bd9Sstevel@tonic-gate static char *MTAerrors[] = {
33*7c478bd9Sstevel@tonic-gate 		"",
34*7c478bd9Sstevel@tonic-gate /*  1 */	"Invalid Address Specification",
35*7c478bd9Sstevel@tonic-gate /*  2 */	"Ambiguous Originator/Recipient Name",
36*7c478bd9Sstevel@tonic-gate /*  3 */	"Message Transfer Agent Congestion",
37*7c478bd9Sstevel@tonic-gate /*  4 */	"Loop Detection",
38*7c478bd9Sstevel@tonic-gate /*  5 */	"Unavailable User Agent",
39*7c478bd9Sstevel@tonic-gate /*  6 */	"Expired Maximum Time",
40*7c478bd9Sstevel@tonic-gate /*  7 */	"Unsupported Encoded Information Types",
41*7c478bd9Sstevel@tonic-gate /*  8 */	"Prohibited Conversion",
42*7c478bd9Sstevel@tonic-gate /*  9 */	"Impractical Conversion",
43*7c478bd9Sstevel@tonic-gate /* 10 */	"Invalid Parameters",
44*7c478bd9Sstevel@tonic-gate /* 11 */	"Transfer Failure",
45*7c478bd9Sstevel@tonic-gate /* 12 */	"Inability To Transfer",
46*7c478bd9Sstevel@tonic-gate /* 13 */	"Conversion Not Performed",
47*7c478bd9Sstevel@tonic-gate /* 14 */	"Deferred Delivery Not Available",
48*7c478bd9Sstevel@tonic-gate /* 15 */	"Too many Recipients",
49*7c478bd9Sstevel@tonic-gate /* 16 */	"Mail Too Large For Destination To Receive"
50*7c478bd9Sstevel@tonic-gate };
51*7c478bd9Sstevel@tonic-gate 
52*7c478bd9Sstevel@tonic-gate void mta_ercode(outfile)
53*7c478bd9Sstevel@tonic-gate FILE *outfile;
54*7c478bd9Sstevel@tonic-gate {
55*7c478bd9Sstevel@tonic-gate 	register int mtacode;
56*7c478bd9Sstevel@tonic-gate 	switch (error) {
57*7c478bd9Sstevel@tonic-gate 	case E_FROM:	/* too many From lines */
58*7c478bd9Sstevel@tonic-gate 		mtacode = 1;
59*7c478bd9Sstevel@tonic-gate 		break;
60*7c478bd9Sstevel@tonic-gate 
61*7c478bd9Sstevel@tonic-gate 	case E_SNDR:	/* invalid sender */
62*7c478bd9Sstevel@tonic-gate 	case E_USER:	/* invalid user */
63*7c478bd9Sstevel@tonic-gate 		mtacode = 2;
64*7c478bd9Sstevel@tonic-gate 		break;
65*7c478bd9Sstevel@tonic-gate 
66*7c478bd9Sstevel@tonic-gate 	case E_FRWL:	/* forwarding loop */
67*7c478bd9Sstevel@tonic-gate 	case E_UNBND:	/* Unbounded forwarding */
68*7c478bd9Sstevel@tonic-gate 		mtacode = 4;
69*7c478bd9Sstevel@tonic-gate 		break;
70*7c478bd9Sstevel@tonic-gate 
71*7c478bd9Sstevel@tonic-gate 	case 23:	/* disallowed from sending binary to remote */
72*7c478bd9Sstevel@tonic-gate 		mtacode = 7;
73*7c478bd9Sstevel@tonic-gate 		break;
74*7c478bd9Sstevel@tonic-gate 
75*7c478bd9Sstevel@tonic-gate 	case E_SYNTAX:	/* syntax error */
76*7c478bd9Sstevel@tonic-gate 	default:
77*7c478bd9Sstevel@tonic-gate 		mtacode = 10;
78*7c478bd9Sstevel@tonic-gate 		break;
79*7c478bd9Sstevel@tonic-gate 
80*7c478bd9Sstevel@tonic-gate 	case E_SURG:	/* surrogate command failed - rc != 0 || 99 */
81*7c478bd9Sstevel@tonic-gate 		mtacode = 11;
82*7c478bd9Sstevel@tonic-gate 		break;
83*7c478bd9Sstevel@tonic-gate 
84*7c478bd9Sstevel@tonic-gate 	case E_REMOTE:	/* unknown remote */
85*7c478bd9Sstevel@tonic-gate 	case E_FILE:	/* file error */
86*7c478bd9Sstevel@tonic-gate 	case E_FRWD:	/* cannot forward */
87*7c478bd9Sstevel@tonic-gate 	case E_PERM:	/* bad permissions */
88*7c478bd9Sstevel@tonic-gate 	case E_TMP:	/* temporary file problem */
89*7c478bd9Sstevel@tonic-gate 	case E_DEAD:	/* Cannot create dead.letter */
90*7c478bd9Sstevel@tonic-gate 	case E_LOCK:	/* cannot create lock file */
91*7c478bd9Sstevel@tonic-gate 	case E_GROUP:	/* no group id of 'mail' */
92*7c478bd9Sstevel@tonic-gate 	case E_MEM:	/* malloc failure */
93*7c478bd9Sstevel@tonic-gate 	case E_FORK:	/* could not fork */
94*7c478bd9Sstevel@tonic-gate 	case E_PIPE:	/* could not pipe */
95*7c478bd9Sstevel@tonic-gate 	case E_OWNR:	/* invoker does not own mailfile */
96*7c478bd9Sstevel@tonic-gate 	case E_DENY:	/* permission denied by mailsurr file */
97*7c478bd9Sstevel@tonic-gate 		mtacode = 12;
98*7c478bd9Sstevel@tonic-gate 		break;
99*7c478bd9Sstevel@tonic-gate 
100*7c478bd9Sstevel@tonic-gate 	case E_MBOX:	/* mbox problem */
101*7c478bd9Sstevel@tonic-gate 		mtacode = 12;
102*7c478bd9Sstevel@tonic-gate 		if (sav_errno != EFBIG) {
103*7c478bd9Sstevel@tonic-gate 			break;
104*7c478bd9Sstevel@tonic-gate 		}
105*7c478bd9Sstevel@tonic-gate 		/* Note drop-thru... */
106*7c478bd9Sstevel@tonic-gate 	case E_SPACE:	/* no space */
107*7c478bd9Sstevel@tonic-gate 		mtacode = 16;
108*7c478bd9Sstevel@tonic-gate 		break;
109*7c478bd9Sstevel@tonic-gate 	}
110*7c478bd9Sstevel@tonic-gate 	fprintf(outfile, "%.2d  %s\n", mtacode, MTAerrors[mtacode]);
111*7c478bd9Sstevel@tonic-gate }
112