Deleted Added
full compact
savemail.c (159613) savemail.c (168520)
1/*
2 * Copyright (c) 1998-2003, 2006 Sendmail, Inc. and its suppliers.
3 * All rights reserved.
4 * Copyright (c) 1983, 1995-1997 Eric P. Allman. All rights reserved.
5 * Copyright (c) 1988, 1993
6 * The Regents of the University of California. All rights reserved.
7 *
8 * By using this file, you agree to the terms and conditions set
9 * forth in the LICENSE file which can be found at the top level of
10 * the sendmail distribution.
11 *
1/*
2 * Copyright (c) 1998-2003, 2006 Sendmail, Inc. and its suppliers.
3 * All rights reserved.
4 * Copyright (c) 1983, 1995-1997 Eric P. Allman. All rights reserved.
5 * Copyright (c) 1988, 1993
6 * The Regents of the University of California. All rights reserved.
7 *
8 * By using this file, you agree to the terms and conditions set
9 * forth in the LICENSE file which can be found at the top level of
10 * the sendmail distribution.
11 *
12 * $FreeBSD: head/contrib/sendmail/src/savemail.c 159613 2006-06-14 16:25:31Z gshapiro $
12 * $FreeBSD: head/contrib/sendmail/src/savemail.c 168520 2007-04-09 01:44:16Z gshapiro $
13 *
14 */
15
16#include <sendmail.h>
17
13 *
14 */
15
16#include <sendmail.h>
17
18SM_RCSID("@(#)$Id: savemail.c,v 8.308 2006/04/18 01:31:33 ca Exp $")
18SM_RCSID("@(#)$Id: savemail.c,v 8.313 2006/11/29 00:20:41 ca Exp $")
19
20static bool errbody __P((MCI *, ENVELOPE *, char *));
21static bool pruneroute __P((char *));
22
23/*
24** SAVEMAIL -- Save mail on error
25**
26** If mailing back errors, mail it back to the originator

--- 163 unchanged lines hidden (view full) ---

190 SM_TIME_DEFAULT,
191 p, SM_IO_WRONLY, NULL,
192 smioout) == NULL)
193 {
194 state = ESM_MAIL;
195 break;
196 }
197
19
20static bool errbody __P((MCI *, ENVELOPE *, char *));
21static bool pruneroute __P((char *));
22
23/*
24** SAVEMAIL -- Save mail on error
25**
26** If mailing back errors, mail it back to the originator

--- 163 unchanged lines hidden (view full) ---

190 SM_TIME_DEFAULT,
191 p, SM_IO_WRONLY, NULL,
192 smioout) == NULL)
193 {
194 state = ESM_MAIL;
195 break;
196 }
197
198 expand("\201n", buf, sizeof buf, e);
198 expand("\201n", buf, sizeof(buf), e);
199 (void) sm_io_fprintf(smioout, SM_TIME_DEFAULT,
200 "\r\nMessage from %s...\r\n", buf);
201 (void) sm_io_fprintf(smioout, SM_TIME_DEFAULT,
202 "Errors occurred while sending mail.\r\n");
203 if (e->e_xfp != NULL)
204 {
205 (void) bfrewind(e->e_xfp);
206 (void) sm_io_fprintf(smioout, SM_TIME_DEFAULT,
207 "Transcript follows:\r\n");
208 while (sm_io_fgets(e->e_xfp, SM_TIME_DEFAULT,
199 (void) sm_io_fprintf(smioout, SM_TIME_DEFAULT,
200 "\r\nMessage from %s...\r\n", buf);
201 (void) sm_io_fprintf(smioout, SM_TIME_DEFAULT,
202 "Errors occurred while sending mail.\r\n");
203 if (e->e_xfp != NULL)
204 {
205 (void) bfrewind(e->e_xfp);
206 (void) sm_io_fprintf(smioout, SM_TIME_DEFAULT,
207 "Transcript follows:\r\n");
208 while (sm_io_fgets(e->e_xfp, SM_TIME_DEFAULT,
209 buf, sizeof buf) != NULL &&
209 buf, sizeof(buf)) != NULL &&
210 !sm_io_error(smioout))
211 (void) sm_io_fputs(smioout,
212 SM_TIME_DEFAULT,
213 buf);
214 }
215 else
216 {
217 syserr("Cannot open %s",

--- 30 unchanged lines hidden (view full) ---

248 (void) sendtolist("postmaster", NULLADDR,
249 &e->e_errorqueue, 0, e);
250 }
251 if (!emptyaddr(&e->e_from))
252 {
253 char from[TOBUFSIZE];
254
255 if (sm_strlcpy(from, e->e_from.q_paddr,
210 !sm_io_error(smioout))
211 (void) sm_io_fputs(smioout,
212 SM_TIME_DEFAULT,
213 buf);
214 }
215 else
216 {
217 syserr("Cannot open %s",

--- 30 unchanged lines hidden (view full) ---

248 (void) sendtolist("postmaster", NULLADDR,
249 &e->e_errorqueue, 0, e);
250 }
251 if (!emptyaddr(&e->e_from))
252 {
253 char from[TOBUFSIZE];
254
255 if (sm_strlcpy(from, e->e_from.q_paddr,
256 sizeof from) >= sizeof from)
256 sizeof(from)) >= sizeof(from))
257 {
258 state = ESM_POSTMASTER;
259 break;
260 }
261
262 if (!DontPruneRoutes)
263 (void) pruneroute(from);
264

--- 37 unchanged lines hidden (view full) ---

302 break;
303
304 case ESM_POSTMASTER:
305 /*
306 ** Similar to previous case, but to system postmaster.
307 */
308
309 q = NULL;
257 {
258 state = ESM_POSTMASTER;
259 break;
260 }
261
262 if (!DontPruneRoutes)
263 (void) pruneroute(from);
264

--- 37 unchanged lines hidden (view full) ---

302 break;
303
304 case ESM_POSTMASTER:
305 /*
306 ** Similar to previous case, but to system postmaster.
307 */
308
309 q = NULL;
310 expand(DoubleBounceAddr, buf, sizeof buf, e);
310 expand(DoubleBounceAddr, buf, sizeof(buf), e);
311
312 /*
313 ** Just drop it on the floor if DoubleBounceAddr
314 ** expands to an empty string.
315 */
316
317 if (*buf == '\0')
318 {

--- 49 unchanged lines hidden (view full) ---

368
369 /* we have a home directory; write dead.letter */
370 macdefine(&e->e_macro, A_TEMP, 'z', p);
371
372 /* get the sender for the UnixFromLine */
373 p = macvalue('g', e);
374 macdefine(&e->e_macro, A_PERM, 'g', e->e_sender);
375
311
312 /*
313 ** Just drop it on the floor if DoubleBounceAddr
314 ** expands to an empty string.
315 */
316
317 if (*buf == '\0')
318 {

--- 49 unchanged lines hidden (view full) ---

368
369 /* we have a home directory; write dead.letter */
370 macdefine(&e->e_macro, A_TEMP, 'z', p);
371
372 /* get the sender for the UnixFromLine */
373 p = macvalue('g', e);
374 macdefine(&e->e_macro, A_PERM, 'g', e->e_sender);
375
376 expand("\201z/dead.letter", dlbuf, sizeof dlbuf, e);
376 expand("\201z/dead.letter", dlbuf, sizeof(dlbuf), e);
377 sff = SFF_CREAT|SFF_REGONLY|SFF_RUNASREALUID;
378 if (RealUid == 0)
379 sff |= SFF_ROOTOK;
380 e->e_to = dlbuf;
381 if (writable(dlbuf, NULL, sff) &&
382 mailfile(dlbuf, FileMailer, NULL, sff, e) == EX_OK)
383 {
384 int oldverb = Verbose;

--- 34 unchanged lines hidden (view full) ---

419 if (!writable(DeadLetterDrop, NULL, sff) ||
420 (fp = safefopen(DeadLetterDrop, O_WRONLY|O_APPEND,
421 FileMode, sff)) == NULL)
422 {
423 state = ESM_PANIC;
424 break;
425 }
426
377 sff = SFF_CREAT|SFF_REGONLY|SFF_RUNASREALUID;
378 if (RealUid == 0)
379 sff |= SFF_ROOTOK;
380 e->e_to = dlbuf;
381 if (writable(dlbuf, NULL, sff) &&
382 mailfile(dlbuf, FileMailer, NULL, sff, e) == EX_OK)
383 {
384 int oldverb = Verbose;

--- 34 unchanged lines hidden (view full) ---

419 if (!writable(DeadLetterDrop, NULL, sff) ||
420 (fp = safefopen(DeadLetterDrop, O_WRONLY|O_APPEND,
421 FileMode, sff)) == NULL)
422 {
423 state = ESM_PANIC;
424 break;
425 }
426
427 memset(&mcibuf, '\0', sizeof mcibuf);
427 memset(&mcibuf, '\0', sizeof(mcibuf));
428 mcibuf.mci_out = fp;
429 mcibuf.mci_mailer = FileMailer;
430 if (bitnset(M_7BITS, FileMailer->m_flags))
431 mcibuf.mci_flags |= MCIF_7BIT;
432
433 /* get the sender for the UnixFromLine */
434 p = macvalue('g', e);
435 macdefine(&e->e_macro, A_PERM, 'g', e->e_sender);

--- 167 unchanged lines hidden (view full) ---

603
604 q->q_flags &= ~(QHASNOTIFY|Q_PINGFLAGS);
605 q->q_flags |= QPINGONFAILURE;
606
607 if (!QS_IS_DEAD(q->q_state))
608 ee->e_nrcpts++;
609
610 if (q->q_alias == NULL)
428 mcibuf.mci_out = fp;
429 mcibuf.mci_mailer = FileMailer;
430 if (bitnset(M_7BITS, FileMailer->m_flags))
431 mcibuf.mci_flags |= MCIF_7BIT;
432
433 /* get the sender for the UnixFromLine */
434 p = macvalue('g', e);
435 macdefine(&e->e_macro, A_PERM, 'g', e->e_sender);

--- 167 unchanged lines hidden (view full) ---

603
604 q->q_flags &= ~(QHASNOTIFY|Q_PINGFLAGS);
605 q->q_flags |= QPINGONFAILURE;
606
607 if (!QS_IS_DEAD(q->q_state))
608 ee->e_nrcpts++;
609
610 if (q->q_alias == NULL)
611 addheader("To", q->q_paddr, 0, ee);
611 addheader("To", q->q_paddr, 0, ee, true);
612 }
613
614 if (LogLevel > 5)
615 {
616 if (bitset(EF_RESPONSE, e->e_flags))
617 p = "return to sender";
618 else if (bitset(EF_WARNING, e->e_flags))
619 p = "sender notify";
620 else if (bitset(RTSF_PM_BOUNCE, flags))
621 p = "postmaster notify";
622 else
623 p = "DSN";
624 sm_syslog(LOG_INFO, e->e_id, "%s: %s: %s",
625 ee->e_id, p, shortenstring(msg, MAXSHORTSTR));
626 }
627
628 if (SendMIMEErrors)
629 {
612 }
613
614 if (LogLevel > 5)
615 {
616 if (bitset(EF_RESPONSE, e->e_flags))
617 p = "return to sender";
618 else if (bitset(EF_WARNING, e->e_flags))
619 p = "sender notify";
620 else if (bitset(RTSF_PM_BOUNCE, flags))
621 p = "postmaster notify";
622 else
623 p = "DSN";
624 sm_syslog(LOG_INFO, e->e_id, "%s: %s: %s",
625 ee->e_id, p, shortenstring(msg, MAXSHORTSTR));
626 }
627
628 if (SendMIMEErrors)
629 {
630 addheader("MIME-Version", "1.0", 0, ee);
631 (void) sm_snprintf(buf, sizeof buf, "%s.%ld/%.100s",
630 addheader("MIME-Version", "1.0", 0, ee, true);
631 (void) sm_snprintf(buf, sizeof(buf), "%s.%ld/%.100s",
632 ee->e_id, (long)curtime(), MyHostName);
633 ee->e_msgboundary = sm_rpool_strdup_x(ee->e_rpool, buf);
632 ee->e_id, (long)curtime(), MyHostName);
633 ee->e_msgboundary = sm_rpool_strdup_x(ee->e_rpool, buf);
634 (void) sm_snprintf(buf, sizeof buf,
634 (void) sm_snprintf(buf, sizeof(buf),
635#if DSN
636 "multipart/report; report-type=delivery-status;\n\tboundary=\"%s\"",
637#else /* DSN */
638 "multipart/mixed; boundary=\"%s\"",
639#endif /* DSN */
640 ee->e_msgboundary);
635#if DSN
636 "multipart/report; report-type=delivery-status;\n\tboundary=\"%s\"",
637#else /* DSN */
638 "multipart/mixed; boundary=\"%s\"",
639#endif /* DSN */
640 ee->e_msgboundary);
641 addheader("Content-Type", buf, 0, ee);
641 addheader("Content-Type", buf, 0, ee, true);
642
643 p = hvalue("Content-Transfer-Encoding", e->e_header);
644 if (p != NULL && sm_strcasecmp(p, "binary") != 0)
645 p = NULL;
646 if (p == NULL && bitset(EF_HAS8BIT, e->e_flags))
647 p = "8bit";
648 if (p != NULL)
642
643 p = hvalue("Content-Transfer-Encoding", e->e_header);
644 if (p != NULL && sm_strcasecmp(p, "binary") != 0)
645 p = NULL;
646 if (p == NULL && bitset(EF_HAS8BIT, e->e_flags))
647 p = "8bit";
648 if (p != NULL)
649 addheader("Content-Transfer-Encoding", p, 0, ee);
649 addheader("Content-Transfer-Encoding", p, 0, ee, true);
650 }
651 if (strncmp(msg, "Warning:", 8) == 0)
652 {
650 }
651 if (strncmp(msg, "Warning:", 8) == 0)
652 {
653 addheader("Subject", msg, 0, ee);
653 addheader("Subject", msg, 0, ee, true);
654 p = "warning-timeout";
655 }
656 else if (strncmp(msg, "Postmaster warning:", 19) == 0)
657 {
654 p = "warning-timeout";
655 }
656 else if (strncmp(msg, "Postmaster warning:", 19) == 0)
657 {
658 addheader("Subject", msg, 0, ee);
658 addheader("Subject", msg, 0, ee, true);
659 p = "postmaster-warning";
660 }
661 else if (strcmp(msg, "Return receipt") == 0)
662 {
659 p = "postmaster-warning";
660 }
661 else if (strcmp(msg, "Return receipt") == 0)
662 {
663 addheader("Subject", msg, 0, ee);
663 addheader("Subject", msg, 0, ee, true);
664 p = "return-receipt";
665 }
666 else if (bitset(RTSF_PM_BOUNCE, flags))
667 {
664 p = "return-receipt";
665 }
666 else if (bitset(RTSF_PM_BOUNCE, flags))
667 {
668 (void) sm_snprintf(buf, sizeof buf,
668 (void) sm_snprintf(buf, sizeof(buf),
669 "Postmaster notify: see transcript for details");
669 "Postmaster notify: see transcript for details");
670 addheader("Subject", buf, 0, ee);
670 addheader("Subject", buf, 0, ee, true);
671 p = "postmaster-notification";
672 }
673 else
674 {
671 p = "postmaster-notification";
672 }
673 else
674 {
675 (void) sm_snprintf(buf, sizeof buf,
675 (void) sm_snprintf(buf, sizeof(buf),
676 "Returned mail: see transcript for details");
676 "Returned mail: see transcript for details");
677 addheader("Subject", buf, 0, ee);
677 addheader("Subject", buf, 0, ee, true);
678 p = "failure";
679 }
678 p = "failure";
679 }
680 (void) sm_snprintf(buf, sizeof buf, "auto-generated (%s)", p);
681 addheader("Auto-Submitted", buf, 0, ee);
680 (void) sm_snprintf(buf, sizeof(buf), "auto-generated (%s)", p);
681 addheader("Auto-Submitted", buf, 0, ee, true);
682
683 /* fake up an address header for the from person */
682
683 /* fake up an address header for the from person */
684 expand("\201n", buf, sizeof buf, e);
684 expand("\201n", buf, sizeof(buf), e);
685 if (parseaddr(buf, &ee->e_from,
686 RF_COPYALL|RF_SENDERADDR, '\0', NULL, e, false) == NULL)
687 {
688 syserr("553 5.3.5 Can't parse myself!");
689 ExitStat = EX_SOFTWARE;
690 returndepth--;
691 return -1;
692 }

--- 80 unchanged lines hidden (view full) ---

773 }
774
775 /*
776 ** Output MIME header.
777 */
778
779 if (e->e_msgboundary != NULL)
780 {
685 if (parseaddr(buf, &ee->e_from,
686 RF_COPYALL|RF_SENDERADDR, '\0', NULL, e, false) == NULL)
687 {
688 syserr("553 5.3.5 Can't parse myself!");
689 ExitStat = EX_SOFTWARE;
690 returndepth--;
691 return -1;
692 }

--- 80 unchanged lines hidden (view full) ---

773 }
774
775 /*
776 ** Output MIME header.
777 */
778
779 if (e->e_msgboundary != NULL)
780 {
781 (void) sm_strlcpyn(buf, sizeof buf, 2, "--", e->e_msgboundary);
781 (void) sm_strlcpyn(buf, sizeof(buf), 2, "--", e->e_msgboundary);
782 if (!putline("This is a MIME-encapsulated message", mci) ||
783 !putline("", mci) ||
784 !putline(buf, mci) ||
785 !putline("", mci))
786 goto writeerr;
787 }
788
789 /*

--- 21 unchanged lines hidden (view full) ---

811 mci) ||
812 !putline(" ** YOU DO NOT NEED TO RESEND YOUR MESSAGE **",
813 mci) ||
814 !putline(" **********************************************",
815 mci) ||
816 !putline("", mci))
817 goto writeerr;
818 }
782 if (!putline("This is a MIME-encapsulated message", mci) ||
783 !putline("", mci) ||
784 !putline(buf, mci) ||
785 !putline("", mci))
786 goto writeerr;
787 }
788
789 /*

--- 21 unchanged lines hidden (view full) ---

811 mci) ||
812 !putline(" ** YOU DO NOT NEED TO RESEND YOUR MESSAGE **",
813 mci) ||
814 !putline(" **********************************************",
815 mci) ||
816 !putline("", mci))
817 goto writeerr;
818 }
819 (void) sm_snprintf(buf, sizeof buf,
819 (void) sm_snprintf(buf, sizeof(buf),
820 "The original message was received at %s",
821 arpadate(ctime(&e->e_parent->e_ctime)));
822 if (!putline(buf, mci))
823 goto writeerr;
820 "The original message was received at %s",
821 arpadate(ctime(&e->e_parent->e_ctime)));
822 if (!putline(buf, mci))
823 goto writeerr;
824 expand("from \201_", buf, sizeof buf, e->e_parent);
824 expand("from \201_", buf, sizeof(buf), e->e_parent);
825 if (!putline(buf, mci))
826 goto writeerr;
827
828 /* include id in postmaster copies */
829 if (pm_notify && e->e_parent->e_id != NULL)
830 {
825 if (!putline(buf, mci))
826 goto writeerr;
827
828 /* include id in postmaster copies */
829 if (pm_notify && e->e_parent->e_id != NULL)
830 {
831 (void) sm_strlcpyn(buf, sizeof buf, 2, "with id ",
831 (void) sm_strlcpyn(buf, sizeof(buf), 2, "with id ",
832 e->e_parent->e_id);
833 if (!putline(buf, mci))
834 goto writeerr;
835 }
836 if (!putline("", mci))
837 goto writeerr;
838
839 /*

--- 11 unchanged lines hidden (view full) ---

851 sff |= SFF_NOLOCK;
852 if (!bitnset(DBS_ERRORHEADERINUNSAFEDIRPATH,
853 DontBlameSendmail))
854 sff |= SFF_SAFEDIRPATH;
855 xfile = safefopen(ErrMsgFile, O_RDONLY, 0444, sff);
856 if (xfile != NULL)
857 {
858 while (sm_io_fgets(xfile, SM_TIME_DEFAULT, buf,
832 e->e_parent->e_id);
833 if (!putline(buf, mci))
834 goto writeerr;
835 }
836 if (!putline("", mci))
837 goto writeerr;
838
839 /*

--- 11 unchanged lines hidden (view full) ---

851 sff |= SFF_NOLOCK;
852 if (!bitnset(DBS_ERRORHEADERINUNSAFEDIRPATH,
853 DontBlameSendmail))
854 sff |= SFF_SAFEDIRPATH;
855 xfile = safefopen(ErrMsgFile, O_RDONLY, 0444, sff);
856 if (xfile != NULL)
857 {
858 while (sm_io_fgets(xfile, SM_TIME_DEFAULT, buf,
859 sizeof buf) != NULL)
859 sizeof(buf)) != NULL)
860 {
860 {
861 translate_dollars(buf);
862 expand(buf, buf, sizeof buf, e);
863 if (!putline(buf, mci))
861 int lbs;
862 bool putok;
863 char *lbp;
864
865 lbs = sizeof(buf);
866 lbp = translate_dollars(buf, buf, &lbs);
867 expand(lbp, lbp, lbs, e);
868 putok = putline(lbp, mci);
869 if (lbp != buf)
870 sm_free(lbp);
871 if (!putok)
864 goto writeerr;
865 }
866 (void) sm_io_close(xfile, SM_TIME_DEFAULT);
867 if (!putline("\n", mci))
868 goto writeerr;
869 }
870 }
871 else
872 {
872 goto writeerr;
873 }
874 (void) sm_io_close(xfile, SM_TIME_DEFAULT);
875 if (!putline("\n", mci))
876 goto writeerr;
877 }
878 }
879 else
880 {
873 expand(ErrMsgFile, buf, sizeof buf, e);
881 expand(ErrMsgFile, buf, sizeof(buf), e);
874 if (!putline(buf, mci) || !putline("", mci))
875 goto writeerr;
876 }
877 }
878
879 /*
880 ** Output message introduction
881 */

--- 10 unchanged lines hidden (view full) ---

892 {
893 if (!putline(" ----- The following addresses had permanent fatal errors -----",
894 mci))
895 goto writeerr;
896 printheader = false;
897 }
898
899 (void) sm_strlcpy(buf, shortenstring(q->q_paddr, MAXSHORTSTR),
882 if (!putline(buf, mci) || !putline("", mci))
883 goto writeerr;
884 }
885 }
886
887 /*
888 ** Output message introduction
889 */

--- 10 unchanged lines hidden (view full) ---

900 {
901 if (!putline(" ----- The following addresses had permanent fatal errors -----",
902 mci))
903 goto writeerr;
904 printheader = false;
905 }
906
907 (void) sm_strlcpy(buf, shortenstring(q->q_paddr, MAXSHORTSTR),
900 sizeof buf);
908 sizeof(buf));
901 if (!putline(buf, mci))
902 goto writeerr;
903 if (q->q_rstatus != NULL)
904 {
909 if (!putline(buf, mci))
910 goto writeerr;
911 if (q->q_rstatus != NULL)
912 {
905 (void) sm_snprintf(buf, sizeof buf,
913 (void) sm_snprintf(buf, sizeof(buf),
906 " (reason: %s)",
907 shortenstring(exitstat(q->q_rstatus),
908 MAXSHORTSTR));
909 if (!putline(buf, mci))
910 goto writeerr;
911 }
912 if (q->q_alias != NULL)
913 {
914 " (reason: %s)",
915 shortenstring(exitstat(q->q_rstatus),
916 MAXSHORTSTR));
917 if (!putline(buf, mci))
918 goto writeerr;
919 }
920 if (q->q_alias != NULL)
921 {
914 (void) sm_snprintf(buf, sizeof buf,
922 (void) sm_snprintf(buf, sizeof(buf),
915 " (expanded from: %s)",
916 shortenstring(q->q_alias->q_paddr,
917 MAXSHORTSTR));
918 if (!putline(buf, mci))
919 goto writeerr;
920 }
921 }
922 if (!printheader && !putline("", mci))

--- 13 unchanged lines hidden (view full) ---

936 {
937 if (!putline(" ----- The following addresses had transient non-fatal errors -----",
938 mci))
939 goto writeerr;
940 printheader = false;
941 }
942
943 (void) sm_strlcpy(buf, shortenstring(q->q_paddr, MAXSHORTSTR),
923 " (expanded from: %s)",
924 shortenstring(q->q_alias->q_paddr,
925 MAXSHORTSTR));
926 if (!putline(buf, mci))
927 goto writeerr;
928 }
929 }
930 if (!printheader && !putline("", mci))

--- 13 unchanged lines hidden (view full) ---

944 {
945 if (!putline(" ----- The following addresses had transient non-fatal errors -----",
946 mci))
947 goto writeerr;
948 printheader = false;
949 }
950
951 (void) sm_strlcpy(buf, shortenstring(q->q_paddr, MAXSHORTSTR),
944 sizeof buf);
952 sizeof(buf));
945 if (!putline(buf, mci))
946 goto writeerr;
947 if (q->q_alias != NULL)
948 {
953 if (!putline(buf, mci))
954 goto writeerr;
955 if (q->q_alias != NULL)
956 {
949 (void) sm_snprintf(buf, sizeof buf,
957 (void) sm_snprintf(buf, sizeof(buf),
950 " (expanded from: %s)",
951 shortenstring(q->q_alias->q_paddr,
952 MAXSHORTSTR));
953 if (!putline(buf, mci))
954 goto writeerr;
955 }
956 }
957 if (!printheader && !putline("", mci))

--- 31 unchanged lines hidden (view full) ---

989 if (printheader)
990 {
991 if (!putline(" ----- The following addresses had successful delivery notifications -----",
992 mci))
993 goto writeerr;
994 printheader = false;
995 }
996
958 " (expanded from: %s)",
959 shortenstring(q->q_alias->q_paddr,
960 MAXSHORTSTR));
961 if (!putline(buf, mci))
962 goto writeerr;
963 }
964 }
965 if (!printheader && !putline("", mci))

--- 31 unchanged lines hidden (view full) ---

997 if (printheader)
998 {
999 if (!putline(" ----- The following addresses had successful delivery notifications -----",
1000 mci))
1001 goto writeerr;
1002 printheader = false;
1003 }
1004
997 (void) sm_snprintf(buf, sizeof buf, "%s (%s)",
1005 (void) sm_snprintf(buf, sizeof(buf), "%s (%s)",
998 shortenstring(q->q_paddr, MAXSHORTSTR), p);
999 if (!putline(buf, mci))
1000 goto writeerr;
1001 if (q->q_alias != NULL)
1002 {
1006 shortenstring(q->q_paddr, MAXSHORTSTR), p);
1007 if (!putline(buf, mci))
1008 goto writeerr;
1009 if (q->q_alias != NULL)
1010 {
1003 (void) sm_snprintf(buf, sizeof buf,
1011 (void) sm_snprintf(buf, sizeof(buf),
1004 " (expanded from: %s)",
1005 shortenstring(q->q_alias->q_paddr,
1006 MAXSHORTSTR));
1007 if (!putline(buf, mci))
1008 goto writeerr;
1009 }
1010 }
1011 if (!printheader && !putline("", mci))

--- 12 unchanged lines hidden (view full) ---

1024 }
1025 else
1026 {
1027 printheader = true;
1028 (void) bfrewind(e->e_parent->e_xfp);
1029 if (e->e_xfp != NULL)
1030 (void) sm_io_flush(e->e_xfp, SM_TIME_DEFAULT);
1031 while (sm_io_fgets(e->e_parent->e_xfp, SM_TIME_DEFAULT, buf,
1012 " (expanded from: %s)",
1013 shortenstring(q->q_alias->q_paddr,
1014 MAXSHORTSTR));
1015 if (!putline(buf, mci))
1016 goto writeerr;
1017 }
1018 }
1019 if (!printheader && !putline("", mci))

--- 12 unchanged lines hidden (view full) ---

1032 }
1033 else
1034 {
1035 printheader = true;
1036 (void) bfrewind(e->e_parent->e_xfp);
1037 if (e->e_xfp != NULL)
1038 (void) sm_io_flush(e->e_xfp, SM_TIME_DEFAULT);
1039 while (sm_io_fgets(e->e_parent->e_xfp, SM_TIME_DEFAULT, buf,
1032 sizeof buf) != NULL)
1040 sizeof(buf)) != NULL)
1033 {
1034 if (printheader && !putline(" ----- Transcript of session follows -----\n",
1035 mci))
1036 goto writeerr;
1037 printheader = false;
1038 if (!putline(buf, mci))
1039 goto writeerr;
1040 }
1041 }
1042 errno = 0;
1043
1044#if DSN
1045 /*
1046 ** Output machine-readable version.
1047 */
1048
1049 if (e->e_msgboundary != NULL)
1050 {
1041 {
1042 if (printheader && !putline(" ----- Transcript of session follows -----\n",
1043 mci))
1044 goto writeerr;
1045 printheader = false;
1046 if (!putline(buf, mci))
1047 goto writeerr;
1048 }
1049 }
1050 errno = 0;
1051
1052#if DSN
1053 /*
1054 ** Output machine-readable version.
1055 */
1056
1057 if (e->e_msgboundary != NULL)
1058 {
1051 (void) sm_strlcpyn(buf, sizeof buf, 2, "--", e->e_msgboundary);
1059 (void) sm_strlcpyn(buf, sizeof(buf), 2, "--", e->e_msgboundary);
1052 if (!putline("", mci) ||
1053 !putline(buf, mci) ||
1054 !putline("Content-Type: message/delivery-status", mci) ||
1055 !putline("", mci))
1056 goto writeerr;
1057
1058 /*
1059 ** Output per-message information.
1060 */
1061
1062 /* original envelope id from MAIL FROM: line */
1063 if (e->e_parent->e_envid != NULL)
1064 {
1060 if (!putline("", mci) ||
1061 !putline(buf, mci) ||
1062 !putline("Content-Type: message/delivery-status", mci) ||
1063 !putline("", mci))
1064 goto writeerr;
1065
1066 /*
1067 ** Output per-message information.
1068 */
1069
1070 /* original envelope id from MAIL FROM: line */
1071 if (e->e_parent->e_envid != NULL)
1072 {
1065 (void) sm_snprintf(buf, sizeof buf,
1073 (void) sm_snprintf(buf, sizeof(buf),
1066 "Original-Envelope-Id: %.800s",
1067 xuntextify(e->e_parent->e_envid));
1068 if (!putline(buf, mci))
1069 goto writeerr;
1070 }
1071
1072 /* Reporting-MTA: is us (required) */
1074 "Original-Envelope-Id: %.800s",
1075 xuntextify(e->e_parent->e_envid));
1076 if (!putline(buf, mci))
1077 goto writeerr;
1078 }
1079
1080 /* Reporting-MTA: is us (required) */
1073 (void) sm_snprintf(buf, sizeof buf,
1081 (void) sm_snprintf(buf, sizeof(buf),
1074 "Reporting-MTA: dns; %.800s", MyHostName);
1075 if (!putline(buf, mci))
1076 goto writeerr;
1077
1078 /* DSN-Gateway: not relevant since we are not translating */
1079
1080 /* Received-From-MTA: shows where we got this message from */
1081 if (RealHostName != NULL)
1082 {
1083 /* XXX use $s for type? */
1084 if (e->e_parent->e_from.q_mailer == NULL ||
1085 (p = e->e_parent->e_from.q_mailer->m_mtatype) == NULL)
1086 p = "dns";
1082 "Reporting-MTA: dns; %.800s", MyHostName);
1083 if (!putline(buf, mci))
1084 goto writeerr;
1085
1086 /* DSN-Gateway: not relevant since we are not translating */
1087
1088 /* Received-From-MTA: shows where we got this message from */
1089 if (RealHostName != NULL)
1090 {
1091 /* XXX use $s for type? */
1092 if (e->e_parent->e_from.q_mailer == NULL ||
1093 (p = e->e_parent->e_from.q_mailer->m_mtatype) == NULL)
1094 p = "dns";
1087 (void) sm_snprintf(buf, sizeof buf,
1095 (void) sm_snprintf(buf, sizeof(buf),
1088 "Received-From-MTA: %s; %.800s",
1089 p, RealHostName);
1090 if (!putline(buf, mci))
1091 goto writeerr;
1092 }
1093
1094 /* Arrival-Date: -- when it arrived here */
1096 "Received-From-MTA: %s; %.800s",
1097 p, RealHostName);
1098 if (!putline(buf, mci))
1099 goto writeerr;
1100 }
1101
1102 /* Arrival-Date: -- when it arrived here */
1095 (void) sm_strlcpyn(buf, sizeof buf, 2, "Arrival-Date: ",
1103 (void) sm_strlcpyn(buf, sizeof(buf), 2, "Arrival-Date: ",
1096 arpadate(ctime(&e->e_parent->e_ctime)));
1097 if (!putline(buf, mci))
1098 goto writeerr;
1099
1100 /* Deliver-By-Date: -- when it should have been delivered */
1101 if (IS_DLVR_BY(e->e_parent))
1102 {
1103 time_t dbyd;
1104
1105 dbyd = e->e_parent->e_ctime + e->e_parent->e_deliver_by;
1104 arpadate(ctime(&e->e_parent->e_ctime)));
1105 if (!putline(buf, mci))
1106 goto writeerr;
1107
1108 /* Deliver-By-Date: -- when it should have been delivered */
1109 if (IS_DLVR_BY(e->e_parent))
1110 {
1111 time_t dbyd;
1112
1113 dbyd = e->e_parent->e_ctime + e->e_parent->e_deliver_by;
1106 (void) sm_strlcpyn(buf, sizeof buf, 2,
1114 (void) sm_strlcpyn(buf, sizeof(buf), 2,
1107 "Deliver-By-Date: ",
1108 arpadate(ctime(&dbyd)));
1109 if (!putline(buf, mci))
1110 goto writeerr;
1111 }
1112
1113 /*
1114 ** Output per-address information.

--- 36 unchanged lines hidden (view full) ---

1151 continue;
1152
1153 if (!putline("", mci))
1154 goto writeerr;
1155
1156 /* Original-Recipient: -- passed from on high */
1157 if (q->q_orcpt != NULL)
1158 {
1115 "Deliver-By-Date: ",
1116 arpadate(ctime(&dbyd)));
1117 if (!putline(buf, mci))
1118 goto writeerr;
1119 }
1120
1121 /*
1122 ** Output per-address information.

--- 36 unchanged lines hidden (view full) ---

1159 continue;
1160
1161 if (!putline("", mci))
1162 goto writeerr;
1163
1164 /* Original-Recipient: -- passed from on high */
1165 if (q->q_orcpt != NULL)
1166 {
1159 (void) sm_snprintf(buf, sizeof buf,
1167 (void) sm_snprintf(buf, sizeof(buf),
1160 "Original-Recipient: %.800s",
1161 q->q_orcpt);
1162 if (!putline(buf, mci))
1163 goto writeerr;
1164 }
1165
1166 /* Figure out actual recipient */
1167 actual[0] = '\0';

--- 4 unchanged lines hidden (view full) ---

1172 p = q->q_mailer->m_addrtype;
1173 else
1174 p = "rfc822";
1175
1176 if (sm_strcasecmp(p, "rfc822") == 0 &&
1177 strchr(q->q_user, '@') == NULL)
1178 {
1179 (void) sm_snprintf(actual,
1168 "Original-Recipient: %.800s",
1169 q->q_orcpt);
1170 if (!putline(buf, mci))
1171 goto writeerr;
1172 }
1173
1174 /* Figure out actual recipient */
1175 actual[0] = '\0';

--- 4 unchanged lines hidden (view full) ---

1180 p = q->q_mailer->m_addrtype;
1181 else
1182 p = "rfc822";
1183
1184 if (sm_strcasecmp(p, "rfc822") == 0 &&
1185 strchr(q->q_user, '@') == NULL)
1186 {
1187 (void) sm_snprintf(actual,
1180 sizeof actual,
1188 sizeof(actual),
1181 "%s; %.700s@%.100s",
1182 p, q->q_user,
1183 MyHostName);
1184 }
1185 else
1186 {
1187 (void) sm_snprintf(actual,
1189 "%s; %.700s@%.100s",
1190 p, q->q_user,
1191 MyHostName);
1192 }
1193 else
1194 {
1195 (void) sm_snprintf(actual,
1188 sizeof actual,
1196 sizeof(actual),
1189 "%s; %.800s",
1190 p, q->q_user);
1191 }
1192 }
1193
1194 /* Final-Recipient: -- the name from the RCPT command */
1195 if (q->q_finalrcpt == NULL)
1196 {

--- 4 unchanged lines hidden (view full) ---

1201 /* try to fall back to the actual recipient */
1202 if (actual[0] != '\0')
1203 q->q_finalrcpt = sm_rpool_strdup_x(e->e_rpool,
1204 actual);
1205 }
1206
1207 if (q->q_finalrcpt != NULL)
1208 {
1197 "%s; %.800s",
1198 p, q->q_user);
1199 }
1200 }
1201
1202 /* Final-Recipient: -- the name from the RCPT command */
1203 if (q->q_finalrcpt == NULL)
1204 {

--- 4 unchanged lines hidden (view full) ---

1209 /* try to fall back to the actual recipient */
1210 if (actual[0] != '\0')
1211 q->q_finalrcpt = sm_rpool_strdup_x(e->e_rpool,
1212 actual);
1213 }
1214
1215 if (q->q_finalrcpt != NULL)
1216 {
1209 (void) sm_snprintf(buf, sizeof buf,
1217 (void) sm_snprintf(buf, sizeof(buf),
1210 "Final-Recipient: %s",
1211 q->q_finalrcpt);
1212 if (!putline(buf, mci))
1213 goto writeerr;
1214 }
1215
1216 /* X-Actual-Recipient: -- the real problem address */
1217 if (actual[0] != '\0' &&
1218 q->q_finalrcpt != NULL &&
1218 "Final-Recipient: %s",
1219 q->q_finalrcpt);
1220 if (!putline(buf, mci))
1221 goto writeerr;
1222 }
1223
1224 /* X-Actual-Recipient: -- the real problem address */
1225 if (actual[0] != '\0' &&
1226 q->q_finalrcpt != NULL &&
1219#if _FFR_PRIV_NOACTUALRECIPIENT
1220 !bitset(PRIV_NOACTUALRECIPIENT, PrivacyFlags) &&
1227 !bitset(PRIV_NOACTUALRECIPIENT, PrivacyFlags) &&
1221#endif /* _FFR_PRIV_NOACTUALRECIPIENT */
1222 strcmp(actual, q->q_finalrcpt) != 0)
1223 {
1228 strcmp(actual, q->q_finalrcpt) != 0)
1229 {
1224 (void) sm_snprintf(buf, sizeof buf,
1230 (void) sm_snprintf(buf, sizeof(buf),
1225 "X-Actual-Recipient: %s",
1226 actual);
1227 if (!putline(buf, mci))
1228 goto writeerr;
1229 }
1230
1231 /* Action: -- what happened? */
1231 "X-Actual-Recipient: %s",
1232 actual);
1233 if (!putline(buf, mci))
1234 goto writeerr;
1235 }
1236
1237 /* Action: -- what happened? */
1232 (void) sm_strlcpyn(buf, sizeof buf, 2, "Action: ",
1238 (void) sm_strlcpyn(buf, sizeof(buf), 2, "Action: ",
1233 action);
1234 if (!putline(buf, mci))
1235 goto writeerr;
1236
1237 /* Status: -- what _really_ happened? */
1238 if (q->q_status != NULL)
1239 p = q->q_status;
1240 else if (QS_IS_BADADDR(q->q_state))
1241 p = "5.0.0";
1242 else if (QS_IS_QUEUEUP(q->q_state))
1243 p = "4.0.0";
1244 else
1245 p = "2.0.0";
1239 action);
1240 if (!putline(buf, mci))
1241 goto writeerr;
1242
1243 /* Status: -- what _really_ happened? */
1244 if (q->q_status != NULL)
1245 p = q->q_status;
1246 else if (QS_IS_BADADDR(q->q_state))
1247 p = "5.0.0";
1248 else if (QS_IS_QUEUEUP(q->q_state))
1249 p = "4.0.0";
1250 else
1251 p = "2.0.0";
1246 (void) sm_strlcpyn(buf, sizeof buf, 2, "Status: ", p);
1252 (void) sm_strlcpyn(buf, sizeof(buf), 2, "Status: ", p);
1247 if (!putline(buf, mci))
1248 goto writeerr;
1249
1250 /* Remote-MTA: -- who was I talking to? */
1251 if (q->q_statmta != NULL)
1252 {
1253 if (q->q_mailer == NULL ||
1254 (p = q->q_mailer->m_mtatype) == NULL)
1255 p = "dns";
1253 if (!putline(buf, mci))
1254 goto writeerr;
1255
1256 /* Remote-MTA: -- who was I talking to? */
1257 if (q->q_statmta != NULL)
1258 {
1259 if (q->q_mailer == NULL ||
1260 (p = q->q_mailer->m_mtatype) == NULL)
1261 p = "dns";
1256 (void) sm_snprintf(buf, sizeof buf,
1262 (void) sm_snprintf(buf, sizeof(buf),
1257 "Remote-MTA: %s; %.800s",
1258 p, q->q_statmta);
1259 p = &buf[strlen(buf) - 1];
1260 if (*p == '.')
1261 *p = '\0';
1262 if (!putline(buf, mci))
1263 goto writeerr;
1264 }
1265
1266 /* Diagnostic-Code: -- actual result from other end */
1267 if (q->q_rstatus != NULL)
1268 {
1269 if (q->q_mailer == NULL ||
1270 (p = q->q_mailer->m_diagtype) == NULL)
1271 p = "smtp";
1263 "Remote-MTA: %s; %.800s",
1264 p, q->q_statmta);
1265 p = &buf[strlen(buf) - 1];
1266 if (*p == '.')
1267 *p = '\0';
1268 if (!putline(buf, mci))
1269 goto writeerr;
1270 }
1271
1272 /* Diagnostic-Code: -- actual result from other end */
1273 if (q->q_rstatus != NULL)
1274 {
1275 if (q->q_mailer == NULL ||
1276 (p = q->q_mailer->m_diagtype) == NULL)
1277 p = "smtp";
1272 (void) sm_snprintf(buf, sizeof buf,
1278 (void) sm_snprintf(buf, sizeof(buf),
1273 "Diagnostic-Code: %s; %.800s",
1274 p, q->q_rstatus);
1275 if (!putline(buf, mci))
1276 goto writeerr;
1277 }
1278
1279 /* Last-Attempt-Date: -- fine granularity */
1280 if (q->q_statdate == (time_t) 0L)
1281 q->q_statdate = curtime();
1279 "Diagnostic-Code: %s; %.800s",
1280 p, q->q_rstatus);
1281 if (!putline(buf, mci))
1282 goto writeerr;
1283 }
1284
1285 /* Last-Attempt-Date: -- fine granularity */
1286 if (q->q_statdate == (time_t) 0L)
1287 q->q_statdate = curtime();
1282 (void) sm_strlcpyn(buf, sizeof buf, 2,
1288 (void) sm_strlcpyn(buf, sizeof(buf), 2,
1283 "Last-Attempt-Date: ",
1284 arpadate(ctime(&q->q_statdate)));
1285 if (!putline(buf, mci))
1286 goto writeerr;
1287
1288 /* Will-Retry-Until: -- for delayed messages only */
1289 if (QS_IS_QUEUEUP(q->q_state))
1290 {
1291 time_t xdate;
1292
1293 xdate = e->e_parent->e_ctime +
1294 TimeOuts.to_q_return[e->e_parent->e_timeoutclass];
1289 "Last-Attempt-Date: ",
1290 arpadate(ctime(&q->q_statdate)));
1291 if (!putline(buf, mci))
1292 goto writeerr;
1293
1294 /* Will-Retry-Until: -- for delayed messages only */
1295 if (QS_IS_QUEUEUP(q->q_state))
1296 {
1297 time_t xdate;
1298
1299 xdate = e->e_parent->e_ctime +
1300 TimeOuts.to_q_return[e->e_parent->e_timeoutclass];
1295 (void) sm_strlcpyn(buf, sizeof buf, 2,
1301 (void) sm_strlcpyn(buf, sizeof(buf), 2,
1296 "Will-Retry-Until: ",
1297 arpadate(ctime(&xdate)));
1298 if (!putline(buf, mci))
1299 goto writeerr;
1300 }
1301 }
1302 }
1303#endif /* DSN */

--- 17 unchanged lines hidden (view full) ---

1321 : " ----- Message header follows -----\n",
1322 mci))
1323 {
1324 goto writeerr;
1325 }
1326 }
1327 else
1328 {
1302 "Will-Retry-Until: ",
1303 arpadate(ctime(&xdate)));
1304 if (!putline(buf, mci))
1305 goto writeerr;
1306 }
1307 }
1308 }
1309#endif /* DSN */

--- 17 unchanged lines hidden (view full) ---

1327 : " ----- Message header follows -----\n",
1328 mci))
1329 {
1330 goto writeerr;
1331 }
1332 }
1333 else
1334 {
1329 (void) sm_strlcpyn(buf, sizeof buf, 2, "--",
1335 (void) sm_strlcpyn(buf, sizeof(buf), 2, "--",
1330 e->e_msgboundary);
1331
1332 if (!putline(buf, mci))
1333 goto writeerr;
1336 e->e_msgboundary);
1337
1338 if (!putline(buf, mci))
1339 goto writeerr;
1334 (void) sm_strlcpyn(buf, sizeof buf, 2, "Content-Type: ",
1340 (void) sm_strlcpyn(buf, sizeof(buf), 2, "Content-Type: ",
1335 sendbody ? "message/rfc822"
1336 : "text/rfc822-headers");
1337 if (!putline(buf, mci))
1338 goto writeerr;
1339
1340 p = hvalue("Content-Transfer-Encoding",
1341 e->e_parent->e_header);
1342 if (p != NULL && sm_strcasecmp(p, "binary") != 0)
1343 p = NULL;
1344 if (p == NULL &&
1345 bitset(EF_HAS8BIT, e->e_parent->e_flags))
1346 p = "8bit";
1347 if (p != NULL)
1348 {
1341 sendbody ? "message/rfc822"
1342 : "text/rfc822-headers");
1343 if (!putline(buf, mci))
1344 goto writeerr;
1345
1346 p = hvalue("Content-Transfer-Encoding",
1347 e->e_parent->e_header);
1348 if (p != NULL && sm_strcasecmp(p, "binary") != 0)
1349 p = NULL;
1350 if (p == NULL &&
1351 bitset(EF_HAS8BIT, e->e_parent->e_flags))
1352 p = "8bit";
1353 if (p != NULL)
1354 {
1349 (void) sm_snprintf(buf, sizeof buf,
1355 (void) sm_snprintf(buf, sizeof(buf),
1350 "Content-Transfer-Encoding: %s",
1351 p);
1352 if (!putline(buf, mci))
1353 goto writeerr;
1354 }
1355 }
1356 if (!putline("", mci))
1357 goto writeerr;

--- 20 unchanged lines hidden (view full) ---

1378 else if (e->e_msgboundary == NULL)
1379 {
1380 if (!putline(" ----- No message was collected -----\n", mci))
1381 goto writeerr;
1382 }
1383
1384 if (e->e_msgboundary != NULL)
1385 {
1356 "Content-Transfer-Encoding: %s",
1357 p);
1358 if (!putline(buf, mci))
1359 goto writeerr;
1360 }
1361 }
1362 if (!putline("", mci))
1363 goto writeerr;

--- 20 unchanged lines hidden (view full) ---

1384 else if (e->e_msgboundary == NULL)
1385 {
1386 if (!putline(" ----- No message was collected -----\n", mci))
1387 goto writeerr;
1388 }
1389
1390 if (e->e_msgboundary != NULL)
1391 {
1386 (void) sm_strlcpyn(buf, sizeof buf, 3, "--", e->e_msgboundary,
1392 (void) sm_strlcpyn(buf, sizeof(buf), 3, "--", e->e_msgboundary,
1387 "--");
1388 if (!putline("", mci) || !putline(buf, mci))
1389 goto writeerr;
1390 }
1391 if (!putline("", mci) ||
1392 sm_io_flush(mci->mci_out, SM_TIME_DEFAULT) == SM_IO_EOF)
1393 goto writeerr;
1394

--- 327 unchanged lines hidden (view full) ---

1722 return false;
1723
1724 at = strrchr(addr, '@');
1725 if (at == NULL || at < start)
1726 return false;
1727
1728 /* slice off the angle brackets */
1729 i = strlen(at + 1);
1393 "--");
1394 if (!putline("", mci) || !putline(buf, mci))
1395 goto writeerr;
1396 }
1397 if (!putline("", mci) ||
1398 sm_io_flush(mci->mci_out, SM_TIME_DEFAULT) == SM_IO_EOF)
1399 goto writeerr;
1400

--- 327 unchanged lines hidden (view full) ---

1728 return false;
1729
1730 at = strrchr(addr, '@');
1731 if (at == NULL || at < start)
1732 return false;
1733
1734 /* slice off the angle brackets */
1735 i = strlen(at + 1);
1730 if (i >= sizeof hostbuf)
1736 if (i >= sizeof(hostbuf))
1731 return false;
1737 return false;
1732 (void) sm_strlcpy(hostbuf, at + 1, sizeof hostbuf);
1738 (void) sm_strlcpy(hostbuf, at + 1, sizeof(hostbuf));
1733 hostbuf[i - 1] = '\0';
1734
1735 while (start != NULL)
1736 {
1737 if (getmxrr(hostbuf, mxhosts, NULL, false,
1738 &rcode, true, NULL) > 0)
1739 {
1740 (void) sm_strlcpy(addr + 1, start + 1,
1741 strlen(addr) - 1);
1742 return true;
1743 }
1744 c = *start;
1745 *start = '\0';
1746 comma = strrchr(addr, ',');
1747 if (comma != NULL && comma[1] == '@' &&
1739 hostbuf[i - 1] = '\0';
1740
1741 while (start != NULL)
1742 {
1743 if (getmxrr(hostbuf, mxhosts, NULL, false,
1744 &rcode, true, NULL) > 0)
1745 {
1746 (void) sm_strlcpy(addr + 1, start + 1,
1747 strlen(addr) - 1);
1748 return true;
1749 }
1750 c = *start;
1751 *start = '\0';
1752 comma = strrchr(addr, ',');
1753 if (comma != NULL && comma[1] == '@' &&
1748 strlen(comma + 2) < sizeof hostbuf)
1749 (void) sm_strlcpy(hostbuf, comma + 2, sizeof hostbuf);
1754 strlen(comma + 2) < sizeof(hostbuf))
1755 (void) sm_strlcpy(hostbuf, comma + 2, sizeof(hostbuf));
1750 else
1751 comma = NULL;
1752 *start = c;
1753 start = comma;
1754 }
1755#endif /* NAMED_BIND */
1756 return false;
1757}
1756 else
1757 comma = NULL;
1758 *start = c;
1759 start = comma;
1760 }
1761#endif /* NAMED_BIND */
1762 return false;
1763}