4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
22 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
23 /* All Rights Reserved */
26 #pragma ident "%Z%%M% %I% %E% SMI"
29 * Copyright 2002 Sun Microsystems, Inc. All rights reserved.
30 * Use is subject to license terms.
35 This routine returns undeliverable mail as well as handles
42 static char pn
[] = "goback";
44 char buf
[1024], *cp
, work
[1024], wuser
[1024];
47 * If dflag already == 1, then been here already and
48 * having a problem delivering failure notification.
49 * Reset dflag to 9 to avoid endless loop.....
53 Dout(pn
, 0, "dflag = %d\n", dflag
);
56 Dout(pn
, 0, "error = %d\n", error
);
66 Dout(pn
, 0, "dflag = 1\n");
67 if ((debug
> 0) && (keepdbgfile
== 0)) {
70 if (ckdlivopts(H_TCOPY
, (int *)0) & IGNORE
) {
74 tmpf
= doopen(lettmp
, "r+", E_TMP
);
76 fseek(tmpf
, let
[letnum
].adr
, 0);
78 for (fgets(line
, LSIZE
, tmpf
);
79 strncmp(line
, header
[H_FROM
].tag
, strlen(header
[H_FROM
].tag
))
81 strncmp(line
, header
[H_FROM1
].tag
,
82 strlen(header
[H_FROM1
].tag
)) == SAME
; ) {
83 if ((i
= substr(line
, "remote from")) != -1) {
84 for (i
= 0, cp
= strrchr(line
, ' ') + 1;
97 for (w
= i
; line
[w
] != ' '; w
++) {
101 } else if ((i
= substr(line
, "forwarded by")) == -1) {
102 if (line
[0] == '>') {
107 for (w
= i
; line
[w
] != ' '; w
++) {
108 wuser
[w
-i
] = line
[w
];
111 } else if ((i
= substr(line
, "forwarded by")) > -1) {
114 fgets(line
, LSIZE
, tmpf
);
118 tmpf
= doopen(lettmp
, "r+", E_TMP
);
119 if (work
[0] != '\0') {
122 (void) snprintf(buf
, sizeof (buf
),
123 "mail %s %s", m_sendto
, work
);
129 (void) strlcpy(work
, my_name
, sizeof (work
));
131 fprintf(stderr
, "%s: Return to %s\n", program
, work
);
132 /* Put header info from message aside so it won't */
133 /* get confused with the Delivery Notification info */
134 Daffbytecnt
= affbytecnt
; affbytecnt
= 0;
135 Daffcnt
= affcnt
; affcnt
= 0;
136 Drcvbytecnt
= rcvbytecnt
; rcvbytecnt
= 0;
138 hdrlines
[H_DAFWDFROM
].head
= hdrlines
[H_AFWDFROM
].head
;
139 hdrlines
[H_DAFWDFROM
].tail
= hdrlines
[H_AFWDFROM
].tail
;
140 hdrlines
[H_AFWDFROM
].head
= NULL
;
141 hdrlines
[H_AFWDFROM
].tail
= NULL
;
142 hdrlines
[H_DRECEIVED
].head
= hdrlines
[H_RECEIVED
].head
;
143 hdrlines
[H_DRECEIVED
].tail
= hdrlines
[H_RECEIVED
].tail
;
144 hdrlines
[H_RECEIVED
].head
= NULL
;
145 hdrlines
[H_RECEIVED
].tail
= NULL
;
146 hdrlines
[H_DTCOPY
].head
= hdrlines
[H_TCOPY
].head
;
147 hdrlines
[H_DTCOPY
].tail
= hdrlines
[H_TCOPY
].tail
;
148 hdrlines
[H_TCOPY
].head
= NULL
;
149 hdrlines
[H_TCOPY
].tail
= NULL
;
151 pushlist(H_TCOPY
, HEAD
, work
, FALSE
);
153 new_reciplist(&list
);
154 add_recip(&list
, work
, FALSE
);
155 sendlist(&list
, 0, 0);
156 del_reciplist(&list
);
163 "%s: Cannot return mail.\n",
168 else if (dflag
< 2) {
169 if (!maxerr
&& (dflag
!= 1)) {
171 Dout(pn
, 0, "maxerr = %d\n", maxerr
);
175 Dout(pn
, 0, "before return, dflag = %d, error = %d\n",