/*++ /* NAME /* mail_copy 3 /* SUMMARY /* copy message with extreme prejudice /* SYNOPSIS /* #include <mail_copy.h> /* /* int mail_copy(sender, orig_to, delivered, src, dst, flags, eol, why) /* const char *sender; /* const char *orig_to; /* const char *delivered; /* VSTREAM *src; /* VSTREAM *dst; /* int flags; /* const char *eol; /* DSN_BUF *why; /* DESCRIPTION /* mail_copy() copies a mail message from record stream to stream-lf /* stream, and attempts to detect all possible I/O errors. /* /* Arguments: /* .IP sender /* The sender envelope address. /* .IP delivered /* Null pointer or delivered-to: header address. /* .IP src /* The source record stream, positioned at the beginning of the /* message contents. /* .IP dst /* The destination byte stream (in stream-lf format). If the message /* ends in an incomplete line, a newline character is appended to /* the output. /* .IP flags /* The binary OR of zero or more of the following: /* .RS /* .IP MAIL_COPY_QUOTE /* Prepend a `>' character to lines beginning with `From '. /* .IP MAIL_COPY_DOT /* Prepend a `.' character to lines beginning with `.'. /* .IP MAIL_COPY_TOFILE /* On systems that support this, use fsync() to flush the /* data to stable storage, and truncate the destination /* file to its original length in case of problems. /* .IP MAIL_COPY_FROM /* Prepend a UNIX-style From_ line to the message. /* .IP MAIL_COPY_BLANK /* Append an empty line to the end of the message. /* .IP MAIL_COPY_DELIVERED /* Prepend a Delivered-To: header with the name of the /* \fIdelivered\fR attribute. /* The address is quoted according to RFC822 rules. /* .IP MAIL_COPY_ORIG_RCPT /* Prepend an X-Original-To: header with the original /* envelope recipient address. This is a NOOP with /* var_enable_orcpt === 0. /* .IP MAIL_COPY_RETURN_PATH /* Prepend a Return-Path: header with the value of the /* \fIsender\fR attribute. /* .RE /* The manifest constant MAIL_COPY_MBOX is a convenient shorthand for /* all MAIL_COPY_XXX options that are appropriate for mailbox delivery. /* Use MAIL_COPY_NONE to copy a message without any options enabled. /* .IP eol /* Record delimiter, for example, LF or CF LF. /* .IP why /* A null pointer, or storage for the reason of failure in /* the form of a DSN detail code plus free text. /* DIAGNOSTICS /* A non-zero result means the operation failed. Warnings: corrupt /* message file. A corrupt message is marked as corrupt. /* /* The result is the bit-wise OR of zero or more of the following: /* .IP MAIL_COPY_STAT_CORRUPT /* The queue file is marked as corrupt. /* .IP MAIL_COPY_STAT_READ /* A read error was detected; errno specifies the nature of the problem. /* .IP MAIL_COPY_STAT_WRITE /* A write error was detected; errno specifies the nature of the problem. /* SEE ALSO /* mark_corrupt(3), mark queue file as corrupted. /* LICENSE /* .ad /* .fi /* The Secure Mailer license must be distributed with this software. /* AUTHOR(S) /* Wietse Venema /* IBM T.J. Watson Research /* P.O. Box 704 /* Yorktown Heights, NY 10598, USA /* /* Wietse Venema /* Google, Inc. /* 111 8th Avenue /* New York, NY 10011, USA
/*--*/
/* mail_copy - copy message with extreme prejudice */
int mail_copy(constchar *sender, constchar *orig_rcpt, constchar *delivered,
VSTREAM *src, VSTREAM *dst, int flags, constchar *eol, DSN_BUF *why)
{ constchar *myname = "mail_copy";
VSTRING *buf; char *bp;
off_t orig_length; int read_error; int write_error; int corrupt_error = 0;
time_t now; int type; int prev_type; struct stat st;
off_t size_limit;
/* *Workaround20090114.Thiswillhopefullygetsomeone'sattention.The *problemwithfile_size_limit<message_size_limitisthatmailwillbe *deliveredagainandagainuntilsomeoneremovesitfromthequeueby *hand,becausePostfixcannotmarkarecipientrecordas"completed".
*/ if (fstat(vstream_fileno(src), &st) < 0)
msg_fatal("fstat: %m"); if ((size_limit = get_file_limit()) < st.st_size)
msg_panic("file size limit %lu < message size %lu. This " "causes large messages to be delivered repeatedly " "after they were submitted with \"sendmail -t\" " "or after recipients were added with the Milter " "SMFIR_ADDRCPT request",
(unsignedlong) size_limit,
(unsignedlong) st.st_size);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.