From 3c0e388f670b2d0ce9bab9e9796738d3c7fbcd7c Mon Sep 17 00:00:00 2001 From: kris Date: Sun, 13 Jul 2003 06:38:13 +0000 Subject: From the PR: I am the maintainer of CTM. There is a problem that when very large deltas are created, that the program ctm_smail, which is responsible for mailing the deltas out, will instead create a single message that says the delta is too large. However, if the -q option is set, instead of placing this message in the queue (as it would have done with the deltas), it mails it out directly. This conflicts with the current working of CTM in that the email address is set as %%REPLACE-ME%% so that the created mailing pieces can be signed by gnu-pgp, and then have the mailing address changed. This fix means that if the -q option is set, and the delta is too large, the "too large" message is placed in the queue. Also, I made the "too large" message a little more up to date. Submitted by: Stephen Montgomery-Smith PR: bin/50328 MFC After: 2 weeks --- usr.sbin/ctm/ctm_smail/ctm_smail.c | 48 ++++++++++++++++++++++++++++++-------- 1 file changed, 38 insertions(+), 10 deletions(-) (limited to 'usr.sbin') diff --git a/usr.sbin/ctm/ctm_smail/ctm_smail.c b/usr.sbin/ctm/ctm_smail/ctm_smail.c index f86d5d0..a0dc03c 100644 --- a/usr.sbin/ctm/ctm_smail/ctm_smail.c +++ b/usr.sbin/ctm/ctm_smail/ctm_smail.c @@ -43,7 +43,7 @@ void write_header(FILE *sfp, char *mail_alias, char *delta, int pce, int npieces); void write_trailer(FILE *sfp, unsigned sum); int apologise(char *delta, off_t ctm_size, long max_ctm_size, - char *mail_alias); + char *mail_alias, char *queue_dir); FILE *open_sendmail(void); int close_sendmail(FILE *fp); @@ -91,7 +91,8 @@ main(int argc, char **argv) } if (max_ctm_size != 0 && sb.st_size > max_ctm_size) - status = apologise(delta, sb.st_size, max_ctm_size, mail_alias); + status = apologise(delta, sb.st_size, max_ctm_size, mail_alias, + queue_dir); else status = chop_and_send_or_queue(dfp, delta, sb.st_size, max_msg_size, mail_alias, queue_dir); @@ -405,13 +406,29 @@ write_trailer(FILE *sfp, unsigned sum) * Returns 0 on success, 1 on failure. */ int -apologise(char *delta, off_t ctm_size, long max_ctm_size, char *mail_alias) +apologise(char *delta, off_t ctm_size, long max_ctm_size, char *mail_alias, + char *queue_dir) { FILE *sfp; + char qname[PATH_MAX]; + + if (queue_dir == NULL) + { + sfp = open_sendmail(); + if (sfp == NULL) + return 1; + } + else + { + mk_queue_name(qname, queue_dir, delta, 1, 1); + sfp = fopen(qname, "w"); + if (sfp == NULL) + { + err("cannot open '%s' for writing", qname); + return 1; + } + } - sfp = open_sendmail(); - if (sfp == NULL) - return 1; fprintf(sfp, "From: owner-%s\n", mail_alias); fprintf(sfp, "To: %s\n", mail_alias); @@ -419,11 +436,22 @@ apologise(char *delta, off_t ctm_size, long max_ctm_size, char *mail_alias) fprintf(sfp, "%s is %ld bytes. The limit is %ld bytes.\n\n", delta, (long)ctm_size, max_ctm_size); - fprintf(sfp, "You can retrieve this delta via ftpmail, " - "or your good mate at the university.\n"); + fprintf(sfp, "You can retrieve this delta via ftp.\n"); - if (!close_sendmail(sfp)) - return 1; + if (queue_dir == NULL) + { + if (!close_sendmail(sfp)) + return 1; + } + else + { + if (fclose(sfp)!=0) + { + err("error writing '%s'", qname); + unlink(qname); + return 1; + } + } return 0; } -- cgit v1.1