bin/50328: ctm_smail doesn't handle large deltas well

Stephen Montgomery-Smith stephen at cauchy.math.missouri.edu
Thu Mar 27 00:40:26 PST 2003


>Number:         50328
>Category:       bin
>Synopsis:       ctm_smail doesn't handle large deltas well
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Wed Mar 26 16:40:20 PST 2003
>Closed-Date:
>Last-Modified:
>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 at 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:
>Unformatted:


More information about the freebsd-bugs mailing list