[comp.sources.unix] v23i010: Deliver 2.0 patches, Part10/10

rsalz@bbn.com (Rich Salz) (08/31/90)

Submitted-by: Chip Salzenberg <tct!chip@uunet.uu.net>
Posting-number: Volume 23, Issue 10
Archive-name: deliver2.0pch/part10

Changes in patch #11 to Deliver 2.0:

1.  If neither /bin/uux nor /usr/bin/uux exists, don't complain until
    UUCP delivery is requested.  This change is required because some
    machines using Deliver don't have UUCP installed.  Thanks to Brian
    Antoine for this fix.

2.  If the sender of the message is a bang path beginning with
    "thishost!", strip thishost from the "From " line at the beginning
    of UUCP mail messages.  Before this fix, outgoing UUCP mail could
    sometimes mention the sending host twice.  That is, on host "foo"
    it could say "From foo!bar [today] remote from foo".

The latter fix is significant for people using the "From " line for
replies, so I decided to issue this patch right away.

This patch contains changes to the following files:
	patchlevel.h
	copymsg.c
	deliver.h
	subs.c
	uucp.c

Index: patchlevel.h
Prereq: 10
***************
*** 1,1 ****
! #define PATCHLEVEL 10
--- 1,1 ----
! #define PATCHLEVEL 11

Index: copymsg.c
***************
*** 1,3 ****
! /* $Header: copymsg.c,v 2.4 90/02/06 11:56:38 chip Exp $
   *
   * Take the message from standard input and write it to two temp files,
--- 1,3 ----
! /* $Header: copymsg.c,v 2.5 90/05/15 11:20:44 chip Exp $
   *
   * Take the message from standard input and write it to two temp files,
***************
*** 5,8 ****
--- 5,11 ----
   *
   * $Log:	copymsg.c,v $
+  * Revision 2.5  90/05/15  11:20:44  chip
+  * Use skipfrom().
+  * 
   * Revision 2.4  90/02/06  11:56:38  chip
   * Enforce MBX_MODE regardless of UMASK.
***************
*** 28,40 ****
  #include "deliver.h"
  
- /*
-  * Macros.
-  */
- 
- /* Does a string start with "From "? */
- 
- #define ISFROM(p) ((p)[0] == 'F' && (p)[1] == 'r' && (p)[2] == 'o' \
- 		&& (p)[3] == 'm' && (p)[4] == ' ')
- 
  /*----------------------------------------------------------------------
   * Copy the message on the standard input to two temp files:
--- 31,34 ----
***************
*** 93,97 ****
  	b = (fgets(buf, GETSIZE(buf), stdin) ? TRUE : FALSE);
  
! 	if (b && ISFROM(buf) && (p = strchr(buf, '\n')) != NULL)
  	{
  		b = FALSE;
--- 87,91 ----
  	b = (fgets(buf, GETSIZE(buf), stdin) ? TRUE : FALSE);
  
! 	if (b && skipfrom(buf) && (p = strchr(buf, '\n')) != NULL)
  	{
  		b = FALSE;
***************
*** 265,269 ****
  		if (isspace(buf[0]))
  			;               /* continuation */
! 		else if (ISFROM(buf) || (buf[0] == '>'))
  			(void) fputc('>', dfp[T_HDR]);
  		else
--- 259,263 ----
  		if (isspace(buf[0]))
  			;               /* continuation */
! 		else if (skipfrom(buf) || (buf[0] == '>'))
  			(void) fputc('>', dfp[T_HDR]);
  		else
***************
*** 306,310 ****
  		}
  
! 		if (ISFROM(buf))
  			(void) fputc('>', dfp[T_BODY]);
  		(void) fputs(buf, dfp[T_BODY]);
--- 300,304 ----
  		}
  
! 		if (skipfrom(buf))
  			(void) fputc('>', dfp[T_BODY]);
  		(void) fputs(buf, dfp[T_BODY]);

Index: deliver.h
***************
*** 1,3 ****
! /* $Header: deliver.h,v 2.8 90/03/06 12:17:42 chip Exp $
   *
   * General pull-it-together include file.
--- 1,3 ----
! /* $Header: deliver.h,v 2.9 90/05/15 11:21:55 chip Exp $
   *
   * General pull-it-together include file.
***************
*** 4,7 ****
--- 4,10 ----
   *
   * $Log:	deliver.h,v $
+  * Revision 2.9  90/05/15  11:21:55  chip
+  * Add skipfrom().
+  * 
   * Revision 2.8  90/03/06  12:17:42  chip
   * Move logging into log.c and address parsing into addr.c.
***************
*** 116,119 ****
--- 119,123 ----
  char    *relpath();
  char    *gethost();
+ char    *skipfrom();
  char    *copystr();
  char    *derrmsg();

Index: subs.c
***************
*** 1,3 ****
! /* $Header: subs.c,v 2.6 90/03/06 12:21:17 chip Exp $
   *
   * Miscellaneous subroutines.
--- 1,3 ----
! /* $Header: subs.c,v 2.7 90/05/15 11:22:01 chip Exp $
   *
   * Miscellaneous subroutines.
***************
*** 4,7 ****
--- 4,10 ----
   *
   * $Log:	subs.c,v $
+  * Revision 2.7  90/05/15  11:22:01  chip
+  * Add skipfrom().
+  * 
   * Revision 2.6  90/03/06  12:21:17  chip
   * Move logging into log.c and address parsing into addr.c.
***************
*** 180,183 ****
--- 183,203 ----
  	for (; *e; ++e)
  		*e = *(e + 1);
+ }
+ 
+ /*----------------------------------------------------------------------
+  * Skip the string "From " and return new pointer, or NULL if the
+  * parameter doesn't contain "From ".
+  */
+ 
+ char *
+ skipfrom(s)
+ char *s;
+ {
+ 	if (s != NULL
+ 	 && s[0] == 'F' && s[1] == 'r' && s[2] == 'o' && s[3] == 'm'
+ 	 && s[4] == ' ')
+ 		return s + 5;
+ 
+ 	return NULL;
  }
  

Index: uucp.c
***************
*** 1,3 ****
! /* $Header: uucp.c,v 2.6 90/05/03 10:35:51 chip Exp $
   *
   * Handle mail destined for other hosts via UUCP.
--- 1,3 ----
! /* $Header: uucp.c,v 2.7 90/05/15 11:20:58 chip Exp $
   *
   * Handle mail destined for other hosts via UUCP.
***************
*** 6,9 ****
--- 6,13 ----
   *
   * $Log:	uucp.c,v $
+  * Revision 2.7  90/05/15  11:20:58  chip
+  * Omit "thishost!" from From_ line fed to uux.
+  * Don't complain about missing uux, just let the exec fail.
+  * 
   * Revision 2.6  90/05/03  10:35:51  chip
   * Quiet lint.
***************
*** 58,63 ****
  	int	uucpcount;
  
! 	if ((uux = find_uux()) == NULL)
! 		return -1;
  
  	av = uav;
--- 62,66 ----
  	int	uucpcount;
  
! 	uux = find_uux();
  
  	av = uav;
***************
*** 221,224 ****
--- 224,229 ----
  /*----------------------------------------------------------------------
   * Where is uux?
+  * This function is allowed to be wrong; if a user without a
+  * uux binary is trying to send UUCP mail, he's got problems.
   */
  
***************
*** 229,238 ****
  	static char uux2[] = "/usr/bin/uux";
  
! 	if (exists(uux1))
! 		return uux1;
! 	if (exists(uux2))
! 		return uux2;
! 	error("can't find uux!?\n");
! 	return NULL;
  }
  
--- 234,238 ----
  	static char uux2[] = "/usr/bin/uux";
  
! 	return exists(uux1) ? uux1 : uux2;
  }
  
***************
*** 273,277 ****
  	if ((p = strchr(buf, '\n')) != NULL)
  		*p = 0;
! 	(void) fprintf(ofp, "%s remote from %s\n", buf, hostname);
  
  	while ((c = getc(ifp)) != EOF)
--- 273,291 ----
  	if ((p = strchr(buf, '\n')) != NULL)
  		*p = 0;
! 
! 	if ((p = skipfrom(buf)) == NULL)
! 		(void) fputs(buf, ofp);	/* should never happen */
! 	else
! 	{
! 		int hlen;
! 
! 		hlen = strlen(hostname);
! 		if (strncmp(p, hostname, hlen) == 0 && *(p + hlen) == '!')
! 			p += hlen + 1;
! 		(void) fputs("From ", ofp);
! 		(void) fputs(p, ofp);
! 	}
! 
! 	(void) fprintf(ofp, " remote from %s\n", hostname);
  
  	while ((c = getc(ifp)) != EOF)

-- 
Chip Salzenberg at ComDev/TCT     <chip@tct.uucp>, <uunet!ateng!tct!chip>


exit 0 # Just in case...
-- 
Please send comp.sources.unix-related mail to rsalz@uunet.uu.net.
Use a domain-based address or give alternate paths, or you may lose out.