From stephen@cauchy.math.missouri.edu  Wed Mar 26 16:38:46 2003
Return-Path: <stephen@cauchy.math.missouri.edu>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 474F537B404
	for <FreeBSD-gnats-submit@freebsd.org>; Wed, 26 Mar 2003 16:38:46 -0800 (PST)
Received: from cauchy.math.missouri.edu (cauchy.math.missouri.edu [128.206.49.166])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 92E5C43F75
	for <FreeBSD-gnats-submit@freebsd.org>; Wed, 26 Mar 2003 16:38:45 -0800 (PST)
	(envelope-from stephen@cauchy.math.missouri.edu)
Received: from cauchy.math.missouri.edu (stephen@localhost [127.0.0.1])
	by cauchy.math.missouri.edu (8.12.8/8.12.8) with ESMTP id h2R0cK5C055497
	for <FreeBSD-gnats-submit@freebsd.org>; Wed, 26 Mar 2003 18:38:20 -0600 (CST)
	(envelope-from stephen@cauchy.math.missouri.edu)
Received: (from stephen@localhost)
	by cauchy.math.missouri.edu (8.12.8/8.12.8/Submit) id h2R0cKIQ055496;
	Wed, 26 Mar 2003 18:38:20 -0600 (CST)
	(envelope-from stephen)
Message-Id: <200303270038.h2R0cKIQ055496@cauchy.math.missouri.edu>
Date: Wed, 26 Mar 2003 18:38:20 -0600 (CST)
From: Stephen Montgomery-Smith <stephen@cauchy.math.missouri.edu>
Reply-To: Stephen Montgomery-Smith <stephen@math.missouri.edu>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: ctm_smail doesn't handle large deltas well
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         50328
>Category:       bin
>Synopsis:       ctm_smail doesn't handle large deltas well
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    kris
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Wed Mar 26 16:40:20 PST 2003
>Closed-Date:    Sun Jan 15 02:36:47 GMT 2006
>Last-Modified:  Sun Jan 15 02:36:47 GMT 2006
>Originator:     Stephen Montgomery-Smith
>Release:        FreeBSD 4.8-RC i386
>Organization:
>Environment:
System: FreeBSD cauchy 4.8-RC FreeBSD 4.8-RC #0: Fri Mar 21 10:46:19 CST 2003 stephen@cauchy:/usr/obj/usr/src/sys/cauchy i386


	
>Description:

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.
>How-To-Repeat:
	
>Fix:

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.

--- ctm_smail.c-orig	Tue Mar  4 05:29:40 2003
+++ ctm_smail.c	Tue Mar  4 06:10:24 2003
@@ -43,7 +43,7 @@
 	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 @@
 	}
 
     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 @@
  * 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 @@
 
     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;
     }


>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->patched 
State-Changed-By: kris 
State-Changed-When: Sat Jul 12 23:38:18 PDT 2003 
State-Changed-Why:  
Patch committed, thanks! 


Responsible-Changed-From-To: freebsd-bugs->kris 
Responsible-Changed-By: kris 
Responsible-Changed-When: Sat Jul 12 23:38:18 PDT 2003 
Responsible-Changed-Why:  
Patch committed, thanks! 

http://www.freebsd.org/cgi/query-pr.cgi?pr=50328 
State-Changed-From-To: patched->closed 
State-Changed-By: kris 
State-Changed-When: Sun Jan 15 02:36:18 UTC 2006 
State-Changed-Why:  
Patch committed some time ago, I don't have interest in 
MFCing it further. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=50328 
>Unformatted:
