From: dhesi@rahul.net (Rahul Dhesi)
Newsgroups: comp.mail.sendmail
Subject: Re: Removing msg body in IDA for postmaster
Date: 7 Sep 92 02:42:02 GMT
Organization: a2i network

Here are very unofficial diffs for IDA sendmail so it will accept the
OP option as follows:

   OP      -- send headers of bounced mail to postmaster
   OPname  -- send headers of bounced mail to specified name
   OP+     -- send complete bounced message to postmaster
   OP+name -- send complete bounced message to specified name

I took Eric Wassenaar's changes and added a few more of my own.  These
changes are for sendmail 5.65c with IDA changes revision 1.4.4.4
(according to the ChangeLog file).  There diffs have been briefly
tested and only under SunOS 4.1 with gcc 2.2.2, so they should be
handled with great care.  Changes given here are to the following files
in the src directory:

   readcf.c, savemail.c, sendmail.h

These are unified diffs, so be sure to use a recent version of
"patch".  If "patch" fails, please apply the changes by hand.

Those of you who frequently modify the sendmail sources are invited to
look for any bugs and post fixes.

Rahul Dhesi <dhesi@rahul.net>
also:  dhesi@cirrus.com

===================================================================
RCS file: RCS/readcf.c,v
retrieving revision 5.21.0.15
diff -u5 -r5.21.0.15 readcf.c
--- 5.21.0.15	1991/08/06 18:17:12
+++ readcf.c	1992/09/06 19:51:16
@@ -18,11 +18,11 @@
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 
 #ifndef lint
 static char sccsid[] = "@(#)readcf.c	5.21 (Berkeley) 6/1/90";
-static char  rcsid[] = "@(#)$Id: readcf.c,v 5.21.0.15 1991/08/06 18:17:12 paul Exp $";
+static char  rcsid[] = "@(#)$Id: readcf.c,v 5.21.0.16 1992/09/06 19:50:43 dhesi Exp $";
 #endif /* not lint */
 
 #include "sendmail.h"
 
 #ifdef __STDC__
@@ -1044,10 +1044,17 @@
 			CurEnv->e_flags &= ~EF_OLDSTYLE;
 		break;
 
 	  case 'P':		/* postmaster copy address for returned mail */
 		PostMasterCopy = newstr(val);
+		if (*PostMasterCopy == '+') {
+			PostMasterCopy++;
+			PostMasterCopyFull = 1;
+		}
+		if (*PostMasterCopy == '\0') {
+			PostMasterCopy = "postmaster"; /* minor memory leak */
+		}
 		break;
 
 	  case 'q':		/* slope of queue only function */
 		QueueFactor = atoi(val);
 		break;
===================================================================
RCS file: RCS/savemail.c,v
retrieving revision 5.13.0.15
diff -u5 -r5.13.0.15 savemail.c
--- 5.13.0.15	1991/06/24 16:22:54
+++ savemail.c	1992/09/06 19:52:03
@@ -18,11 +18,11 @@
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 
 #ifndef lint
 static char sccsid[] = "@(#)savemail.c	5.14 (Berkeley) 8/29/90";
-static char  rcsid[] = "@(#)$Id: savemail.c,v 5.13.0.15 1991/06/24 16:22:54 paul Exp $";
+static char  rcsid[] = "@(#)$Id: savemail.c,v 5.13.0.17 1992/09/06 19:51:32 dhesi Exp $";
 #endif /* not lint */
 
 #include "sendmail.h"
 #include <pwd.h>
 
@@ -226,11 +226,11 @@
 					sendtolist(e->e_from.q_paddr,
 						(ADDRESS *) NULL,
 						&e->e_errorqueue);
 
 				/* deliver a cc: to the postmaster if desired */
-				if (PostMasterCopy != NULL)
+				if (PostMasterCopyFull)
 					sendtolist(PostMasterCopy,
 						(ADDRESS *) NULL,
 						&e->e_errorqueue);
 				q = e->e_errorqueue;
 			}
@@ -341,10 +341,22 @@
 
 			/* leave the locked queue & transcript files around */
 			exit(EX_SOFTWARE);
 		}
 	}
+
+	if (PostMasterCopy) {
+		/*
+		From: e07@nikhefh.nikhef.nl (Eric Wassenaar)
+		Newsgroups: comp.mail.sendmail
+		Message-Id: <1856@nikhefh.nikhef.nl>
+		Date: 4 Sep 92 20:18:59 GMT
+		*/
+		q = (ADDRESS *) NULL;
+		sendtolist(PostMasterCopy, (ADDRESS *) NULL, &q);
+		(void) returntosender("Delivery failure", q, FALSE);
+	}
 }
 /*
 **  RETURNTOSENDER -- return a message to the sender with an error.
 **
 **	Parameters:
@@ -417,11 +429,12 @@
 	to = buf;
 	for (q = returnq; q != NULL; q = q->q_next)
 	{
 		if (q->q_alias != NULL)
 			continue;
-		if (PostMasterCopy && (strcmp(q->q_paddr, PostMasterCopy) == 0))
+		if (PostMasterCopyFull && 
+			(strcmp(q->q_paddr, PostMasterCopy) == 0))
 			cc = q->q_paddr;
 		else
 		{
 			/* Not Postmaster; already on the To: line? */
 			for (p = returnq; p != q; p = p->q_next)
===================================================================
RCS file: RCS/sendmail.h,v
retrieving revision 5.16.0.24
diff -u5 -r5.16.0.24 sendmail.h
--- 5.16.0.24	1991/08/14 18:28:19
+++ sendmail.h	1992/09/06 19:52:24
@@ -26,11 +26,11 @@
 
 # ifdef _DEFINE
 #  define EXTERN
 #  ifndef lint
 static char SmailSccsId[] =	"@(#)sendmail.h	5.16		6/1/90";
-static char SmailRcsId[] =	"@(#)$Id: sendmail.h,v 5.16.0.24 1991/08/14 18:28:19 paul Exp $";
+static char SmailRcsId[] =	"@(#)$Id: sendmail.h,v 5.16.0.25 1992/09/06 19:52:11 dhesi Exp $";
 #  endif /* lint */
 # else  /* !_DEFINE */
 #  define EXTERN extern
 # endif /* _DEFINE */
 
@@ -730,10 +730,11 @@
 EXTERN int	WkRecipFact;	/* multiplier for # of recipients -> priority */
 EXTERN int	WkTimeFact;	/* priority offset each time this job is run */
 EXTERN int	CheckPointLimit;	/* deliveries before checkpointing */
 EXTERN int	Nmx;			/* number of MX RRs */
 EXTERN char	*PostMasterCopy;	/* address to get errs cc's */
+EXTERN int	PostMasterCopyFull;	/* .. whether to send full message */
 EXTERN bool	SplitRewriting;	/* use split envelope/header rewriting */
 EXTERN char	*MxHosts[MAXMXHOSTS+1];	/* for MX RRs */
 EXTERN char	*TrustedUsers[MAXTRUST+1];	/* list of trusted users */
 /*
 **  Trace information