Subject: Misc. cleanup (#189)
Index:	lib/libc/*,ucb/{several},usr.bin/{several},usr.lib/{several} 2.11BSD

Description:
	There are a number of places in libc.a where some D-space can be
	saved by not overallocating structures/arrays.

	When using the resolver routines (res_*) or syslog(3) the 
	amount of stack space required can be reduced by making a couple
	simple changes.

	There should not be hardcoded references to /usr/lib/sendmail, the
	_PATH_SENDMAIL define should be added to <paths.h> and that file
	included as needed.

	Use of the global symbols 'sys_nerr' and 'sys_errlist[]' is
	deprecated (and may go away in the future).  The routine 'strerror()'
	should be used instead.  

	The varargs macros should have been used in the sendmail and
	kermit modules which manipulate the extracted strings file.

Repeat-By:
	Observation.

Fix:
	The changes presented here are the remnants of a (temporarily)
	abandoned experiment.  In an attempt to make yet another 'monster'
	program run under 2.11BSD some minor changes were made to various
	routines in the system.  While the experiment was less than a
	success the updates below were felt to be worth retaining.  D-space 
	savings are always welcome on a pdp-11.

	Other changes include:
	
		1) replacing hardcoded references to the path 
		   /usr/lib/sendmail with _PATH_SENDMAIL.  This
		   makes it much easier to change where sendmail
		   resides (thought was being given to moving it
		   to /usr/sbin - this has been put on hold).

		2) The resolver routine res_send() was using a 512 byte
		   'junk' buffer.  This caused problems with large
		   programs because there was insufficient room to grow
		   the stack further.  By reducing the stack space required
		   this problem is avoided (well, postponed a while longer).

		   In syslog(3) the maximum message size was reduced from
		   1kb to 640 bytes.  Since the _doprnt (the routine printf(3)
		   calls to actually do the formatting) has a limit of around
		   300 bytes this change won't hurt anything but will reduce
		   the chances of pushing the stack down too far.
		   
		3) The perror() and syslog() functions were modified to call 
		   'strerror()' instead of directly referencing sys_errlist[].
		   There is exactly 1 reference to sys_errlist[] in the entire 
		   C library now, it is in strerror().  This makes it possible
		   to move the error message strings to a file, all programs
		   that use strerror() will see no change except for 1600 bytes
		   of D space being freed.  This is something being considered
		   for the future (when all the applications in the system
		   have been modified/fixed).

		4) The gethostent() routines declared space for 35 aliases of
		   a system.  This appeared excessive and was reduced to 16.
		   The same for the getservent() function - 35 aliases won't
		   fit (realistically) into the line buffer used to read the
		   file.

		5) In the extracted string modules (ckustr.c for kermit,
		   extract.c for sendmail) the varargs macros are used now.
		   There were a couple problems reported with the variable
		   argument lists not being long enough.

	After saving the patch kit below into a file (/tmp/p) apply the
	patch by:

		patch -p0 < /tmp/p

	If you know how to insert individual modules into libc.a (and libc_p.a)
	you can replace the following: syslog.o, perror.o, res_send.o, getsent.o
	and named/gethnamadr.o.

	The easiest but timewise lengthiest way is to rebuild the C library:

		cd /usr/src/lib/libc
		make
		make install

	There is no urgent requirement to recompile the various modified 
	applications at this time.  If you wish to do so then something like
	the following will need to be done:

		cd /usr/src/ucb/Mail
		make Mail
		install -s -m 755 Mail /usr/ucb/Mail
		rm /usr/ucb/mail
		ln /usr/ucb/Mail /usr/ucb/Mail

		cd /usr/src/new/rcs/src
		make 
		make install

		cd /usr/src/usr.bin/uucp
		make
		make install

	and so on.
============================cut here
*** /usr/src/bin/mail.c.old	Fri Dec 31 21:59:28 1993
--- /usr/src/bin/mail.c	Sat Jun 11 17:38:36 1994
***************
*** 1,5 ****
! #ifndef lint
! static char sccsid[] = "@(#)mail.c	4.33.1 (2.11BSD GTE) 12/31/93";
  #endif
  
  #include <sys/param.h>
--- 1,5 ----
! #if	!defined(lint) && defined(DOSCCS)
! static char sccsid[] = "@(#)mail.c	4.33.2 (2.11BSD GTE) 6/11/94";
  #endif
  
  #include <sys/param.h>
***************
*** 13,21 ****
  #include <signal.h>
  #include <setjmp.h>
  #include <sysexits.h>
  
- #define SENDMAIL	"/usr/lib/sendmail"
- 
  	/* copylet flags */
  #define REMOTE		1		/* remote mail, add rmtmsg */
  #define ORDINARY	2
--- 13,20 ----
  #include <signal.h>
  #include <setjmp.h>
  #include <sysexits.h>
+ #include <paths.h>
  
  	/* copylet flags */
  #define REMOTE		1		/* remote mail, add rmtmsg */
  #define ORDINARY	2
***************
*** 432,439 ****
  			*ap-- = "-s";
  		*ap = "-sendmail";
  		setuid(getuid());
! 		execv(SENDMAIL, ap);
! 		perror(SENDMAIL);
  		exit(EX_UNAVAILABLE);
  	}
  
--- 431,438 ----
  			*ap-- = "-s";
  		*ap = "-sendmail";
  		setuid(getuid());
! 		execv(_PATH_SENDMAIL, ap);
! 		perror(_PATH_SENDMAIL);
  		exit(EX_UNAVAILABLE);
  	}
  
*** /usr/src/lib/libc/gen/perror.c.old	Sun May 14 22:30:21 1989
--- /usr/src/lib/libc/gen/perror.c	Fri Jul  8 16:01:17 1994
***************
*** 16,27 ****
   */
  
  #if defined(LIBC_SCCS) && !defined(lint)
! static char sccsid[] = "@(#)perror.c	5.7 (Berkeley) 12/16/88";
  #endif /* LIBC_SCCS and not lint */
  
  #include <sys/types.h>
  #include <sys/uio.h>
  
  int errno;
  extern int sys_nerr;
  extern char *sys_errlist[];
--- 16,28 ----
   */
  
  #if defined(LIBC_SCCS) && !defined(lint)
! static char sccsid[] = "@(#)perror.c	5.7.1 (2.11BSD GTE) 7/8/94";
  #endif /* LIBC_SCCS and not lint */
  
  #include <sys/types.h>
  #include <sys/uio.h>
  
+ char *strerror();
  int errno;
  extern int sys_nerr;
  extern char *sys_errlist[];
***************
*** 42,53 ****
  		v->iov_len = 2;
  		v++;
  	}
! 	if ((u_int)errno < sys_nerr)
! 		v->iov_base = sys_errlist[errno];
! 	else {
! 		(void)sprintf(ebuf, "Unknown error: %d", errno);
! 		v->iov_base = ebuf;
! 	}
  	v->iov_len = strlen(v->iov_base);
  	v++;
  	v->iov_base = "\n";
--- 43,49 ----
  		v->iov_len = 2;
  		v++;
  	}
! 	v->iov_base = strerror(errno);
  	v->iov_len = strlen(v->iov_base);
  	v++;
  	v->iov_base = "\n";
*** /usr/src/lib/libc/gen/syslog.c.old	Sat Feb  5 20:14:24 1994
--- /usr/src/lib/libc/gen/syslog.c	Fri Jul  8 15:27:35 1994
***************
*** 5,11 ****
   */
  
  #if defined(LIBC_SCCS) && !defined(lint)
! static char sccsid[] = "@(#)syslog.c	5.9.1 (2.11BSD GTE) 1/1/94";
  #endif LIBC_SCCS and not lint
  
  /*
--- 5,11 ----
   */
  
  #if defined(LIBC_SCCS) && !defined(lint)
! static char sccsid[] = "@(#)syslog.c	5.9.2 (2.11BSD GTE) 7/8/94";
  #endif LIBC_SCCS and not lint
  
  /*
***************
*** 33,40 ****
  #include <sys/syslog.h>
  #include <strings.h>
  
! #define	MAXLINE	1024			/* max message size */
! #define NULL	0			/* manifest */
  
  #define PRIMASK(p)	(1 << ((p) & LOG_PRIMASK))
  #define PRIFAC(p)	(((p) & LOG_FACMASK) >> 3)
--- 33,40 ----
  #include <sys/syslog.h>
  #include <strings.h>
  
! #define	MAXLINE	640		/* max message size */
! #define NULL	0		/* manifest */
  
  #define PRIMASK(p)	(1 << ((p) & LOG_PRIMASK))
  #define PRIFAC(p)	(((p) & LOG_FACMASK) >> 3)
***************
*** 55,62 ****
  
  static struct sockaddr SyslogAddr;	/* AF_UNIX address of local logger */
  
! extern	int errno, sys_nerr;
! extern	char *sys_errlist[];
  
  syslog(pri, fmt, p0, p1, p2, p3, p4)
  	int pri;
--- 55,61 ----
  
  static struct sockaddr SyslogAddr;	/* AF_UNIX address of local logger */
  
! extern	int errno;
  
  syslog(pri, fmt, p0, p1, p2, p3, p4)
  	int pri;
***************
*** 110,119 ****
  			*b++ = c;
  			continue;
  		}
! 		if ((unsigned)olderrno > sys_nerr)
! 			sprintf(b, "error %d", olderrno);
! 		else
! 			strcpy(b, sys_errlist[olderrno]);
  		b += strlen(b);
  	}
  	*b++ = '\n';
--- 109,115 ----
  			*b++ = c;
  			continue;
  		}
! 		strcpy(b, strerror(olderrno));
  		b += strlen(b);
  	}
  	*b++ = '\n';
*** /usr/src/lib/libc/net/named/gethnamadr.c.old	Sat Feb  5 20:14:29 1994
--- /usr/src/lib/libc/net/named/gethnamadr.c	Sun Jul 10 18:04:23 1994
***************
*** 11,17 ****
   */
  
  #if defined(LIBC_SCCS) && !defined(lint)
! static char sccsid[] = "@(#)gethostnamadr.c	6.31.1 (2.11BSD GTE) 1/1/94";
  #endif /* LIBC_SCCS and not lint */
  
  #include <sys/param.h>
--- 11,17 ----
   */
  
  #if defined(LIBC_SCCS) && !defined(lint)
! static char sccsid[] = "@(#)gethostnamadr.c	6.31.2 (2.11BSD GTE) 6/27/94";
  #endif /* LIBC_SCCS and not lint */
  
  #include <sys/param.h>
***************
*** 25,32 ****
  #include <arpa/nameser.h>
  #include <resolv.h>
  
! #define	MAXALIASES	35
! #define	MAXADDRS	35
  
  static char *h_addr_ptrs[MAXADDRS + 1];
  
--- 25,32 ----
  #include <arpa/nameser.h>
  #include <resolv.h>
  
! #define	MAXALIASES	16
! #define	MAXADDRS	16
  
  static char *h_addr_ptrs[MAXADDRS + 1];
  
*** /usr/src/lib/libc/net/res_send.c.old	Sat Sep 17 00:48:49 1988
--- /usr/src/lib/libc/net/res_send.c	Sun Jun 26 17:22:50 1994
***************
*** 11,17 ****
   */
  
  #if defined(LIBC_SCCS) && !defined(lint)
! static char sccsid[] = "@(#)res_send.c	6.19 (Berkeley) 3/7/88";
  #endif /* LIBC_SCCS and not lint */
  
  /*
--- 11,17 ----
   */
  
  #if defined(LIBC_SCCS) && !defined(lint)
! static char sccsid[] = "@(#)res_send.c	6.19.1 (Berkeley) 6/27/94";
  #endif /* LIBC_SCCS and not lint */
  
  /*
***************
*** 62,68 ****
  	HEADER *anhp = (HEADER *) answer;
  	struct iovec iov[2];
  	int terrno = ETIMEDOUT;
! 	char junk[512];
  
  #ifdef DEBUG
  	if (_res.options & RES_DEBUG) {
--- 62,68 ----
  	HEADER *anhp = (HEADER *) answer;
  	struct iovec iov[2];
  	int terrno = ETIMEDOUT;
! 	char junk[16];
  
  #ifdef DEBUG
  	if (_res.options & RES_DEBUG) {
*** /usr/src/lib/libc/net/getsent.c.old	Mon Dec 26 14:38:07 1988
--- /usr/src/lib/libc/net/getsent.c	Sun Jul 10 18:00:57 1994
***************
*** 5,11 ****
   */
  
  #if defined(LIBC_SCCS) && !defined(lint)
! static char sccsid[] = "@(#)getservent.c	5.3 (Berkeley) 5/19/86";
  #endif LIBC_SCCS and not lint
  
  #include <stdio.h>
--- 5,11 ----
   */
  
  #if defined(LIBC_SCCS) && !defined(lint)
! static char sccsid[] = "@(#)getservent.c	5.3.1 (2.11BSD GTE) 6/27/94";
  #endif LIBC_SCCS and not lint
  
  #include <stdio.h>
***************
*** 15,25 ****
  #include <netdb.h>
  #include <ctype.h>
  
! #define	MAXALIASES	35
  
  static char SERVDB[] = "/etc/services";
  static FILE *servf = NULL;
! static char line[256+1];
  static struct servent serv;
  static char *serv_aliases[MAXALIASES];
  static char *any();
--- 15,25 ----
  #include <netdb.h>
  #include <ctype.h>
  
! #define	MAXALIASES	16
  
  static char SERVDB[] = "/etc/services";
  static FILE *servf = NULL;
! static char line[160+1];
  static struct servent serv;
  static char *serv_aliases[MAXALIASES];
  static char *any();
*** /usr/src/local/popper/popper.h.old	Wed Jun 24 16:31:47 1992
--- /usr/src/local/popper/popper.h	Sat Jun 11 17:44:02 1994
***************
*** 4,10 ****
   * specifies the terms and conditions for redistribution.
   *
   * static char copyright[] = "Copyright (c) 1990 Regents of the University of California.\nAll rights reserved.\n";
!  * static char SccsId[] = "@(#)@(#)popper.h	2.2  2.2 4/2/91";
   *
   */
  
--- 4,10 ----
   * specifies the terms and conditions for redistribution.
   *
   * static char copyright[] = "Copyright (c) 1990 Regents of the University of California.\nAll rights reserved.\n";
!  * static char SccsId[] = "@(#)@(#)popper.h	2.2.1  (2.11BSD) 6/11/94";
   *
   */
  
***************
*** 15,20 ****
--- 15,21 ----
   */
  
  #include <syslog.h>
+ #include <paths.h>
  #include "version.h"
  
  #define NULLCP          ((char *) 0)
***************
*** 33,39 ****
  #define MAXPARMCOUNT    5
  #define MAXPARMLEN      10
  #define ALLOC_MSGS  20
! #define MAIL_COMMAND    "/usr/lib/sendmail"
  
  #define POP_FACILITY    LOG_LOCAL0
  #define POP_PRIORITY    LOG_NOTICE
--- 34,40 ----
  #define MAXPARMCOUNT    5
  #define MAXPARMLEN      10
  #define ALLOC_MSGS  20
! #define MAIL_COMMAND    _PATH_SENDMAIL
  
  #define POP_FACILITY    LOG_LOCAL0
  #define POP_PRIORITY    LOG_NOTICE
***************
*** 170,178 ****
  extern int  pop_xtnd();
  extern int  pop_xmit();
  extern long lseek();
- 
- #ifdef	pdp11
- #define pop_get_subcommand Apop_get_command
- #define pop_dropcopy Apop_dropcopy
- #define pop_sendline p_sndline
- #endif
--- 171,173 ----
*** /usr/src/local/popper/Makefile.old	Fri Jan 29 21:11:22 1993
--- /usr/src/local/popper/Makefile	Mon Jun 13 20:12:30 1994
***************
*** 72,78 ****
  	mv xae ${TAR}.Z.uuencoded.xae
  
  clean:
! 	rm -f core *.o *.Z* ${CATPAGE}
  
  install: ${TARGET} installman
  	install -c -m 700 -o root -g staff ${TARGET} ${INSTALLDIR}
--- 72,78 ----
  	mv xae ${TAR}.Z.uuencoded.xae
  
  clean:
! 	rm -f core *.o *.Z* ${CATPAGE} popper
  
  install: ${TARGET} installman
  	install -c -m 700 -o root -g staff ${TARGET} ${INSTALLDIR}
*** /usr/src/new/rcs/src/rcs.c.old	Tue Apr 26 14:54:59 1988
--- /usr/src/new/rcs/src/rcs.c	Mon Jul 11 09:57:14 1994
***************
*** 1,7 ****
  /*
   *                      RCS create/change operation
   */
! #ifndef lint
  static char rcsid[]=
  "$Header: /usr/src/local/bin/rcs/src/RCS/rcs.c,v 4.7 87/12/18 11:37:17 narten Exp $ Purdue CS";
  #endif
--- 1,7 ----
  /*
   *                      RCS create/change operation
   */
! #if	!defined(lint) && defined(DOSCCS)
  static char rcsid[]=
  "$Header: /usr/src/local/bin/rcs/src/RCS/rcs.c,v 4.7 87/12/18 11:37:17 narten Exp $ Purdue CS";
  #endif
***************
*** 103,108 ****
--- 103,109 ----
   */
  
  
+ #include <paths.h>
  #include <sys/types.h>
  #include <sys/stat.h>
  #include "rcsbase.h"
***************
*** 1006,1013 ****
          }
          ffclose(mailmess);
  
! #ifdef SENDMAIL
!      VOID sprintf(command, "/usr/lib/sendmail %s < %s",who,messagefile);
  #else
  #    ifdef DELIVERMAIL
          VOID sprintf(command, "/etc/delivermail -w %s < %s",who,messagefile);
--- 1007,1014 ----
          }
          ffclose(mailmess);
  
! #ifdef _PATH_SENDMAIL
!      VOID sprintf(command, "%s %s < %s", _PATH_SENDMAIL, who,messagefile);
  #else
  #    ifdef DELIVERMAIL
          VOID sprintf(command, "/etc/delivermail -w %s < %s",who,messagefile);
***************
*** 1014,1020 ****
  #    else
  	VOID sprintf(command, "/bin/mail %s < %s",who,messagefile);
  #    endif DELIVERMAIL
! #endif SENDMAIL
  
          VOID system(command);
  	    /* ignore the exit status, even if delivermail unsuccessful */
--- 1015,1021 ----
  #    else
  	VOID sprintf(command, "/bin/mail %s < %s",who,messagefile);
  #    endif DELIVERMAIL
! #endif _PATH_SENDMAIL
  
          VOID system(command);
  	    /* ignore the exit status, even if delivermail unsuccessful */
*** /usr/src/new/kermit5.188/ckustr.c.old	Mon Nov 23 21:07:01 1992
--- /usr/src/new/kermit5.188/ckustr.c	Fri Apr  8 22:03:31 1994
***************
*** 1,5 ****
--- 1,6 ----
  #include <stdio.h>
  #include <sysexits.h>
+ #include <varargs.h>
  
  /* string extraction/restoration routines */
  
***************
*** 61,96 ****
  
  /* extracted string front end for printf() */
  /*VARARGS1*/
! strprerror(fmt, a, b, c, d, e, f, g, h, i, j, k, l)
  	int fmt;
  {
  	char buf[BUFLEN];
  
  	errprep(fmt, buf);
! 	printf(buf, a, b, c, d, e, f, g, h, i ,j, k, l);
  }
  
  /* extracted string front end for sprintf() */
  /*VARARGS1*/
! strsrerror(fmt, obuf, a, b, c, d, e, f, g, h, i, j, k, l)
  	int fmt;
  	char *obuf;
  {
  	char buf[BUFLEN];
  
  	errprep(fmt, buf);
! 	sprintf(obuf, buf, a, b, c, d, e, f, g, h, i, j, k, l);
  }
  
  /* extracted string front end for fprintf() */
  /*VARARGS1*/
! strfrerror(fmt, fd, a, b, c, d, e, f, g, h, i, j, k, l)
  	int fmt, fd;
  {
  	char buf[BUFLEN];
  
  	errprep(fmt, buf);
! 	fprintf(fd, buf, a, b, c, d, e, f, g, h, i, j, k, l);
  }
  
  /* extracted string front end for perror() */
--- 62,109 ----
  
  /* extracted string front end for printf() */
  /*VARARGS1*/
! strprerror(fmt, va_alist)
  	int fmt;
+ 	va_dcl
  {
+ 	va_list	ap;
  	char buf[BUFLEN];
  
  	errprep(fmt, buf);
! 	va_start(ap);
! 	vprintf(buf, ap);
! 	va_end(ap);
  }
  
  /* extracted string front end for sprintf() */
  /*VARARGS1*/
! strsrerror(fmt, obuf, va_alist)
  	int fmt;
  	char *obuf;
+ 	va_dcl
  {
  	char buf[BUFLEN];
+ 	va_list	ap;
  
  	errprep(fmt, buf);
! 	va_start(ap);
! 	vsprintf(obuf, buf, ap);
! 	va_end(ap);
  }
  
  /* extracted string front end for fprintf() */
  /*VARARGS1*/
! strfrerror(fmt, fd, va_alist)
  	int fmt, fd;
+ 	va_dcl
  {
+ 	va_list	ap;
  	char buf[BUFLEN];
  
  	errprep(fmt, buf);
! 	va_start(ap);
! 	vfprintf(fd, buf, ap);
! 	va_end(ap);
  }
  
  /* extracted string front end for perror() */
*** /usr/src/ucb/Mail/pathnames.h.old	Thu Oct 22 15:46:00 1992
--- /usr/src/ucb/Mail/pathnames.h	Sat Jun 11 17:55:50 1994
***************
*** 30,36 ****
   * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   *
!  *	@(#)pathnames.h	5.14 (Berkeley) 6/19/91
   */
  
  #include <paths.h>
--- 30,36 ----
   * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   *
!  *	@(#)pathnames.h	5.14.1 (2.11BSD GTE) 6/11/94
   */
  
  #include <paths.h>
***************
*** 42,47 ****
  #define	_PATH_MAIL_LOG	"/usr/spool/mqueue/syslog"
  #define	_PATH_MASTER_RC	"/usr/lib/Mail.rc"
  #define	_PATH_MORE	"/usr/ucb/more"
- #define	_PATH_TMP	"/tmp/"
  #define	_PATH_MAILDIR	"/usr/spool/mail"
- #define	_PATH_SENDMAIL	"/usr/lib/sendmail"
--- 42,45 ----
*** /usr/src/ucb/rdist/pathnames.h.old	Sat Jun 11 17:58:05 1994
--- /usr/src/ucb/rdist/pathnames.h	Sat Jun 11 17:58:03 1994
***************
*** 0 ****
--- 1,38 ----
+ /*
+  * Copyright (c) 1989, 1993
+  *	The Regents of the University of California.  All rights reserved.
+  *
+  * Redistribution and use in source and binary forms, with or without
+  * modification, are permitted provided that the following conditions
+  * are met:
+  * 1. Redistributions of source code must retain the above copyright
+  *    notice, this list of conditions and the following disclaimer.
+  * 2. Redistributions in binary form must reproduce the above copyright
+  *    notice, this list of conditions and the following disclaimer in the
+  *    documentation and/or other materials provided with the distribution.
+  * 3. All advertising materials mentioning features or use of this software
+  *    must display the following acknowledgement:
+  *	This product includes software developed by the University of
+  *	California, Berkeley and its contributors.
+  * 4. Neither the name of the University nor the names of its contributors
+  *    may be used to endorse or promote products derived from this software
+  *    without specific prior written permission.
+  *
+  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+  * SUCH DAMAGE.
+  *
+  *	@(#)pathnames.h	8.1 (Berkeley) 6/9/93
+  */
+ 
+ #include <paths.h>
+ 
+ #define	_PATH_RDIST	"rdist"
*** /usr/src/ucb/rdist/defs.h.old	Mon Feb 16 22:09:48 1987
--- /usr/src/ucb/rdist/defs.h	Sat Jun 11 17:59:04 1994
***************
*** 3,9 ****
   * All rights reserved.  The Berkeley software License Agreement
   * specifies the terms and conditions for redistribution.
   *
!  *	@(#)defs.h	5.2 (Berkeley) 3/20/86
   */
  
  #include <stdio.h>
--- 3,9 ----
   * All rights reserved.  The Berkeley software License Agreement
   * specifies the terms and conditions for redistribution.
   *
!  *	@(#)defs.h	5.2.1 (2.11BSD GTE) 6/11/95
   */
  
  #include <stdio.h>
***************
*** 21,28 ****
   * The version number should be changed whenever the protocol changes.
   */
  #define VERSION	 3
- 
- #define	MAILCMD	 "/usr/lib/sendmail -oi -t"
  
  	/* defines for yacc */
  #define EQUAL	1
--- 21,26 ----
*** /usr/src/ucb/rdist/docmd.c.old	Mon Feb 16 22:09:49 1987
--- /usr/src/ucb/rdist/docmd.c	Mon Jun 13 22:05:14 1994
***************
*** 4,21 ****
   * specifies the terms and conditions for redistribution.
   */
  
! #ifndef lint
! static char sccsid[] = "@(#)docmd.c	5.1 (Berkeley) 6/6/85";
! #endif not lint
  
  #include "defs.h"
  #include <setjmp.h>
  #include <netdb.h>
  
- #ifndef RDIST
- #define RDIST "/usr/ucb/rdist"
- #endif
- 
  FILE	*lfp;			/* log file for recording files updated */
  struct	subcmd *subcmds;	/* list of sub-commands for current cmd */
  jmp_buf	env;
--- 4,18 ----
   * specifies the terms and conditions for redistribution.
   */
  
! #if	!defined(lint) && defined(DOSCCS)
! static char sccsid[] = "@(#)docmd.c	5.1.1 (2.11BSD GTE) 6/11/94";
! #endif
  
+ #include "pathnames.h"
  #include "defs.h"
  #include <setjmp.h>
  #include <netdb.h>
  
  FILE	*lfp;			/* log file for recording files updated */
  struct	subcmd *subcmds;	/* list of sub-commands for current cmd */
  jmp_buf	env;
***************
*** 198,204 ****
  		ruser = user;
  	if (!qflag)
  		printf("updating host %s\n", rhost);
! 	(void) sprintf(buf, "%s -Server%s", RDIST, qflag ? " -q" : "");
  	if (port < 0) {
  		struct servent *sp;
  
--- 195,201 ----
  		ruser = user;
  	if (!qflag)
  		printf("updating host %s\n", rhost);
! 	(void) sprintf(buf, "%s -Server%s", _PATH_RDIST, qflag ? " -q" : "");
  	if (port < 0) {
  		struct servent *sp;
  
***************
*** 482,490 ****
  	/*
  	 * Create a pipe to mailling program.
  	 */
! 	pf = popen(MAILCMD, "w");
  	if (pf == NULL) {
! 		error("notify: \"%s\" failed\n", MAILCMD);
  		(void) close(fd);
  		return;
  	}
--- 479,488 ----
  	/*
  	 * Create a pipe to mailling program.
  	 */
! 	sprintf(buf, "%s -oi -t", _PATH_SENDMAIL);
! 	pf = popen(buf, "w");
  	if (pf == NULL) {
! 		error("notify: \"%s\" failed\n", _PATH_SENDMAIL);
  		(void) close(fd);
  		return;
  	}
*** /usr/src/ucb/rdist/Makefile.old	Mon Jan 18 09:36:03 1993
--- /usr/src/ucb/rdist/Makefile	Mon Jul 11 10:28:05 1994
***************
*** 3,17 ****
  # All rights reserved.  The Berkeley software License Agreement
  # specifies the terms and conditions for redistribution.
  #
! #	@(#)Makefile	5.1 (Berkeley) 6/6/85
  #
- RDIST = /usr/ucb/rdist
  DESTDIR=
  SEPFLAG= -i
  SRCS =	docmd.c expand.c gram.y lookup.c main.c server.c
  OBJS =	docmd.o expand.o gram.o lookup.o main.o server.o
  LINT =	lint -ps
! CFLAGS= -O -DRDIST=\"${RDIST}\"
  
  rdist:	${OBJS}
  	${CC} ${SEPFLAG} -o rdist ${OBJS}
--- 3,16 ----
  # All rights reserved.  The Berkeley software License Agreement
  # specifies the terms and conditions for redistribution.
  #
! #	@(#)Makefile	5.1.1 (2.11BSD GTE) 7/11/94
  #
  DESTDIR=
  SEPFLAG= -i
  SRCS =	docmd.c expand.c gram.y lookup.c main.c server.c
  OBJS =	docmd.o expand.o gram.o lookup.o main.o server.o
  LINT =	lint -ps
! CFLAGS= -O
  
  rdist:	${OBJS}
  	${CC} ${SEPFLAG} -o rdist ${OBJS}
***************
*** 22,28 ****
  	rm -f *.o gram.c errs rdist
  
  install: rdist
! 	install -s -m 4751 rdist ${DESTDIR}${RDIST}
  
  lint:	docmd.c expand.c gram.c lookup.c main.c server.c
  	${LINT} docmd.c expand.c gram.c lookup.c main.c server.c
--- 21,27 ----
  	rm -f *.o gram.c errs rdist
  
  install: rdist
! 	install -s -m 4751 rdist ${DESTDIR}/usr/ucb/rdist
  
  lint:	docmd.c expand.c gram.c lookup.c main.c server.c
  	${LINT} docmd.c expand.c gram.c lookup.c main.c server.c
*** /usr/src/ucb/sendbug/bugfiler.c.old	Tue May 20 18:43:29 1986
--- /usr/src/ucb/sendbug/bugfiler.c	Sat Jun 11 18:06:43 1994
***************
*** 4,18 ****
   * specifies the terms and conditions for redistribution.
   */
  
! #ifndef lint
  char copyright[] =
  "@(#) Copyright (c) 1983 Regents of the University of California.\n\
   All rights reserved.\n";
- #endif not lint
  
! #ifndef lint
! static char sccsid[] = "@(#)bugfiler.c	5.5 (Berkeley) 86/05/20";
! #endif not lint
  
  /*
   * Bug report processing program.
--- 4,16 ----
   * specifies the terms and conditions for redistribution.
   */
  
! #if	!defined(lint) && defined(DOSCCS)
  char copyright[] =
  "@(#) Copyright (c) 1983 Regents of the University of California.\n\
   All rights reserved.\n";
  
! static char sccsid[] = "@(#)bugfiler.c	5.5.1 (2.11BSD GTE) 6/11/94";
! #endif
  
  /*
   * Bug report processing program.
***************
*** 24,29 ****
--- 22,28 ----
  #include <ctype.h>
  #include <signal.h>
  #include <pwd.h>
+ #include <paths.h>
  
  #include <sys/types.h>
  #include <sys/stat.h>
***************
*** 35,41 ****
  #ifndef BUGS_HOME
  #define	BUGS_HOME	"@ucbvax.BERKELEY.EDU"
  #endif
- #define	MAILCMD		"/usr/lib/sendmail -i -t"
  
  #ifndef UNIXTOMH
  #define UNIXTOMH	"/usr/lib/unixtomh"
--- 34,39 ----
***************
*** 698,704 ****
  	char buf[BUFSIZ], cmd[BUFSIZ];
  	FILE *pf, *popen();
  
! 	strcpy(cmd, MAILCMD);
  	if (debug) {
  		strcat(cmd, " -v");
  		printf("dodeliver \"%s\"\n", cmd);
--- 696,702 ----
  	char buf[BUFSIZ], cmd[BUFSIZ];
  	FILE *pf, *popen();
  
! 	sprintf(cmd, "%s -i -t", _PATH_SENDMAIL);
  	if (debug) {
  		strcat(cmd, " -v");
  		printf("dodeliver \"%s\"\n", cmd);
*** /usr/src/ucb/vacation.c.old	Mon Jul  8 17:13:58 1985
--- /usr/src/ucb/vacation.c	Sat Jun 11 18:09:57 1994
***************
*** 8,16 ****
  **  specifies the terms and conditions for redistribution.
  */
  
! #ifndef lint
! static char	SccsId[] = "@(#)vacation.c	5.3 (Berkeley) 7/1/85";
! #endif not lint
  
  # include <sys/types.h>
  # include <pwd.h>
--- 8,16 ----
  **  specifies the terms and conditions for redistribution.
  */
  
! #if	!defined(lint) && defined(DOSCCS)
! static char	SccsId[] = "@(#)vacation.c	5.3.1 (2.11BSD GTE) 6/11/94";
! #endif
  
  # include <sys/types.h>
  # include <pwd.h>
***************
*** 17,22 ****
--- 17,23 ----
  # include <stdio.h>
  # include <sysexits.h>
  # include <ctype.h>
+ #include <paths.h>
  
  /*
  **  VACATION -- return a message to the sender when on vacation.
***************
*** 330,336 ****
  **		none.
  **
  **	Side Effects:
! **		sends mail to 'user' using /usr/lib/sendmail.
  */
  
  sendmessage(msgf, user, myname)
--- 331,337 ----
  **		none.
  **
  **	Side Effects:
! **		sends mail to 'user' using sendmail.
  */
  
  sendmessage(msgf, user, myname)
***************
*** 349,356 ****
  			syserr("No message to send");
  	}
  
! 	execl("/usr/lib/sendmail", "sendmail", "-f", myname, user, NULL);
! 	syserr("Cannot exec /usr/lib/sendmail");
  }
  /*
  **  INITIALIZE -- initialize the database before leaving for vacation
--- 350,357 ----
  			syserr("No message to send");
  	}
  
! 	execl(_PATH_SENDMAIL, "sendmail", "-f", myname, user, NULL);
! 	syserr("Cannot exec sendmail");
  }
  /*
  **  INITIALIZE -- initialize the database before leaving for vacation
*** /usr/src/usr.bin/uucp/uucp.h.old	Fri Dec 31 23:02:50 1993
--- /usr/src/usr.bin/uucp/uucp.h	Sat Jun 11 18:16:13 1994
***************
*** 1,6 ****
! /*	uucp.h	5.11.1	93/12/31	*/
  
  #include <stdio.h>
  
  /*
   * Determine local uucp name of this machine.
--- 1,7 ----
! /*	uucp.h	5.11.2	94/6/11	*/
  
  #include <stdio.h>
+ #include <paths.h>
  
  /*
   * Determine local uucp name of this machine.
***************
*** 280,286 ****
  
  	/*  commands  */
  #define SHELL		"/bin/sh"
- #define MAIL		"/usr/lib/sendmail"
  #define UUCICO		"/usr/lib/uucp/uucico"
  #define UUXQT		"/usr/lib/uucp/uuxqt"
  #define UUCP		"uucp"
--- 281,286 ----
*** /usr/src/usr.bin/uucp/mailst.c.old	Mon Feb 16 16:21:46 1987
--- /usr/src/usr.bin/uucp/mailst.c	Sat Jun 11 18:18:09 1994
***************
*** 1,5 ****
! #ifndef lint
! static char sccsid[] = "@(#)mailst.c	5.6 (Berkeley) 10/9/85";
  #endif
  
  #include <signal.h>
--- 1,5 ----
! #if	!defined(lint) && defined(DOSCCS)
! static char sccsid[] = "@(#)mailst.c	5.6.1 (2.11BSD GTE) 6/11/94";
  #endif
  
  #include <signal.h>
***************
*** 24,30 ****
  	char buf[BUFSIZ];
  	register int c;
  
! 	sprintf(buf, "%s '%s'", MAIL, user);
  	if ((fp = rpopen(buf, "w")) != NULL) {
  		fprintf(fp, "From: uucp\nTo: %s\nSubject: %s\n\n", user, str);
  		if (file && *file != '\0' && (fi = fopen(subfile(file), "r")) != NULL) {
--- 24,30 ----
  	char buf[BUFSIZ];
  	register int c;
  
! 	sprintf(buf, "%s '%s'", _PATH_SENDMAIL, user);
  	if ((fp = rpopen(buf, "w")) != NULL) {
  		fprintf(fp, "From: uucp\nTo: %s\nSubject: %s\n\n", user, str);
  		if (file && *file != '\0' && (fi = fopen(subfile(file), "r")) != NULL) {
*** /usr/src/usr.lib/sendmail/src/extract.c.old	Wed Aug  8 05:15:24 1990
--- /usr/src/usr.lib/sendmail/src/extract.c	Wed Apr 13 21:30:59 1994
***************
*** 2,7 ****
--- 2,8 ----
  
  #define BUFLEN 256
  #include "sendmail.h"
+ #include <varargs.h>
  
  char	*StringFile =	"/usr/lib/sendmail.sr";	/* extracted string storage */
  static int strfile = -1, ourpid = 0;
***************
*** 34,69 ****
  
  /* extracted string front end for printf() */
  /*VARARGS1*/
! strprerror(fmt, a, b, c, d, e)
  	int fmt;
  {
  	char buf[BUFLEN];
  
  	errprep(fmt, buf);
! 	printf(buf, a, b, c, d, e);
  }
  
  /* extracted string front end for sprintf() */
  /*VARARGS1*/
! strsrerror(fmt, obuf, a, b, c, d, e)
  	int fmt;
  	char *obuf;
  {
  	char buf[BUFLEN];
  
  	errprep(fmt, buf);
! 	sprintf(obuf, buf, a, b, c, d, e);
  }
  
  /* extracted string front end for fprintf() */
  /*VARARGS1*/
! strfrerror(fmt, fd, a, b, c, d, e)
  	int fmt, fd;
  {
  	char buf[BUFLEN];
  
  	errprep(fmt, buf);
! 	fprintf(fd, buf, a, b, c, d, e);
  }
  
  /* extracted string front end for syslog() */
--- 35,82 ----
  
  /* extracted string front end for printf() */
  /*VARARGS1*/
! strprerror(fmt, va_alist)
  	int fmt;
+ 	va_dcl
  {
+ 	va_list ap;
  	char buf[BUFLEN];
  
  	errprep(fmt, buf);
! 	va_start(ap);
! 	vprintf(buf, ap);
! 	va_end(ap);
  }
  
  /* extracted string front end for sprintf() */
  /*VARARGS1*/
! strsrerror(fmt, obuf, va_alist)
  	int fmt;
  	char *obuf;
+ 	va_dcl
  {
  	char buf[BUFLEN];
+ 	va_list ap;
  
  	errprep(fmt, buf);
! 	va_start(ap);
! 	vsprintf(obuf, buf, ap);
! 	va_end(ap);
  }
  
  /* extracted string front end for fprintf() */
  /*VARARGS1*/
! strfrerror(fmt, fd, va_alist)
  	int fmt, fd;
+ 	va_dcl
  {
+ 	va_list ap;
  	char buf[BUFLEN];
  
  	errprep(fmt, buf);
! 	va_start(ap);
! 	vfprintf(fd, buf, ap);
! 	va_end(ap);
  }
  
  /* extracted string front end for syslog() */
*** /usr/src/usr.lib/lpr/lp.local.h.old	Sun Nov 25 11:15:55 1990
--- /usr/src/usr.lib/lpr/lp.local.h	Sat Jun 11 18:20:55 1994
***************
*** 3,9 ****
   * All rights reserved.  The Berkeley software License Agreement
   * specifies the terms and conditions for redistribution.
   *
!  *	@(#)lp.local.h	5.1 (Berkeley) 6/6/85
   */
  
  /*
--- 3,9 ----
   * All rights reserved.  The Berkeley software License Agreement
   * specifies the terms and conditions for redistribution.
   *
!  *	@(#)lp.local.h	5.1.1 (2.11BSD GTE) 6/11/94
   */
  
  /*
***************
*** 17,22 ****
--- 17,23 ----
  
  #include <a.out.h>
  #include <ar.h>
+ #include <paths.h>
  
  #ifndef A_MAGIC1	/* must be a VM/UNIX system */
  #	define A_MAGIC1	OMAGIC
***************
*** 74,80 ****
   * Some utilities used by printjob.
   */
  #define PR		"/bin/pr"
- #define MAIL		"/usr/lib/sendmail"
  
  /*
   * Define TERMCAP if the terminal capabilites are to be used for lpq.
--- 75,80 ----
*** /usr/src/usr.lib/lpr/printjob.c.old	Thu Aug 24 11:15:14 1989
--- /usr/src/usr.lib/lpr/printjob.c	Sat Jun 11 18:22:24 1994
***************
*** 4,12 ****
   * specifies the terms and conditions for redistribution.
   */
  
! #ifndef lint
! static char sccsid[] = "@(#)printjob.c	5.2 (Berkeley) 9/17/85";
! #endif not lint
  
  /*
   * printjob -- print jobs in the queue.
--- 4,12 ----
   * specifies the terms and conditions for redistribution.
   */
  
! #if	!defined(lint) && defined(DOSCCS)
! static char sccsid[] = "@(#)printjob.c	5.2.1 (2.11BSD GTE) 6/11/94";
! #endif
  
  /*
   * printjob -- print jobs in the queue.
***************
*** 911,922 ****
  		dup2(p[0], 0);
  		for (i = 3; i < NOFILE; i++)
  			(void) close(i);
! 		if ((cp = rindex(MAIL, '/')) != NULL)
  			cp++;
  		else
! 			cp = MAIL;
  		sprintf(buf, "%s@%s", user, fromhost);
! 		execl(MAIL, cp, buf, 0);
  		exit(0);
  	} else if (s > 0) {				/* parent */
  		dup2(p[1], 1);
--- 911,922 ----
  		dup2(p[0], 0);
  		for (i = 3; i < NOFILE; i++)
  			(void) close(i);
! 		if ((cp = rindex(_PATH_SENDMAIL, '/')) != NULL)
  			cp++;
  		else
! 			cp = _PATH_SENDMAIL;
  		sprintf(buf, "%s@%s", user, fromhost);
! 		execl(_PATH_SENDMAIL, cp, buf, 0);
  		exit(0);
  	} else if (s > 0) {				/* parent */
  		dup2(p[1], 1);
*** /usr/src/usr.lib/sendmail.MX/src/extract.c.old	Wed Sep 14 20:53:28 1988
--- /usr/src/usr.lib/sendmail.MX/src/extract.c	Wed Apr 13 21:35:55 1994
***************
*** 2,15 ****
  
  #define BUFLEN 256
  #include "sendmail.h"
  
  char	*StringFile =	"/usr/lib/sendmail.sr";	/* extracted string storage */
! strfile = -1;
  
  errprep(offset, buf)
! int offset;
  char *buf;
  {
  	if (strfile < 0) {
  		strfile = open(StringFile, 0);
  		if (strfile < 0) {
--- 2,25 ----
  
  #define BUFLEN 256
  #include "sendmail.h"
+ #include <varargs.h>
  
  char	*StringFile =	"/usr/lib/sendmail.sr";	/* extracted string storage */
! static int strfile = -1, ourpid = 0;
  
  errprep(offset, buf)
! unsigned short offset;
  char *buf;
  {
+ register int pid = getpid();
+ 
+ 	if (pid != ourpid) {
+ 		ourpid = pid;
+ 		if (strfile >= 0) {
+ 			close(strfile);
+ 			strfile = -1;
+ 		}
+ 	}
  	if (strfile < 0) {
  		strfile = open(StringFile, 0);
  		if (strfile < 0) {
***************
*** 25,60 ****
  
  /* extracted string front end for printf() */
  /*VARARGS1*/
! strprerror(fmt, a, b, c, d, e)
  	int fmt;
  {
  	char buf[BUFLEN];
  
  	errprep(fmt, buf);
! 	printf(buf, a, b, c, d, e);
  }
  
  /* extracted string front end for sprintf() */
  /*VARARGS1*/
! strsrerror(fmt, obuf, a, b, c, d, e)
  	int fmt;
  	char *obuf;
  {
  	char buf[BUFLEN];
  
  	errprep(fmt, buf);
! 	sprintf(obuf, buf, a, b, c, d, e);
  }
  
  /* extracted string front end for fprintf() */
  /*VARARGS1*/
! strfrerror(fmt, fd, a, b, c, d, e)
  	int fmt, fd;
  {
  	char buf[BUFLEN];
  
  	errprep(fmt, buf);
! 	fprintf(fd, buf, a, b, c, d, e);
  }
  
  /* extracted string front end for syslog() */
--- 35,82 ----
  
  /* extracted string front end for printf() */
  /*VARARGS1*/
! strprerror(fmt, va_alist)
  	int fmt;
+ 	va_dcl
  {
+ 	va_list ap;
  	char buf[BUFLEN];
  
  	errprep(fmt, buf);
! 	va_start(ap);
! 	vprintf(buf, ap);
! 	va_end(ap);
  }
  
  /* extracted string front end for sprintf() */
  /*VARARGS1*/
! strsrerror(fmt, obuf, va_alist)
  	int fmt;
  	char *obuf;
+ 	va_dcl
  {
  	char buf[BUFLEN];
+ 	va_list ap;
  
  	errprep(fmt, buf);
! 	va_start(ap);
! 	vsprintf(obuf, buf, ap);
! 	va_end(ap);
  }
  
  /* extracted string front end for fprintf() */
  /*VARARGS1*/
! strfrerror(fmt, fd, va_alist)
  	int fmt, fd;
+ 	va_dcl
  {
+ 	va_list ap;
  	char buf[BUFLEN];
  
  	errprep(fmt, buf);
! 	va_start(ap);
! 	vfprintf(fd, buf, ap);
! 	va_end(ap);
  }
  
  /* extracted string front end for syslog() */
***************
*** 75,81 ****
  {
  	char buf[BUFLEN];
  	extern int errno;
! 	int olderrno = errno;
  
  	errprep(fmt, buf);
  	errno = olderrno;
--- 97,103 ----
  {
  	char buf[BUFLEN];
  	extern int errno;
! 	register int olderrno = errno;
  
  	errprep(fmt, buf);
  	errno = olderrno;
***************
*** 89,95 ****
  {
  	char buf[BUFLEN];
  	extern int errno;
! 	int olderrno = errno;
  
  	errprep(fmt, buf);
  	errno = olderrno;
--- 111,117 ----
  {
  	char buf[BUFLEN];
  	extern int errno;
! 	register int olderrno = errno;
  
  	errprep(fmt, buf);
  	errno = olderrno;
