*BSD News Article 95097


Return to BSD News archive

Newsgroups: comp.bugs.2bsd
Path: euryale.cc.adfa.oz.au!newshost.carno.net.au!harbinger.cc.monash.edu.au!munnari.OZ.AU!news.ecn.uoknor.edu!news.wildstar.net!news.ececs.uc.edu!newsrelay.netins.net!newsfeed.dacom.co.kr!nntp.kreonet.re.kr!xfer.kren.nm.kr!news-west.sprintlink.net!news-peer.sprintlink.net!news.sprintlink.net!Sprint!news.maxwell.syr.edu!news.new-york.net!wlbr!moe.2bsd.com!sms
From: sms@moe.2bsd.com (Steven M. Schultz)
Subject: static memory conflict in sendmail, hack Makefile fixed (#373)
Organization: 2BSD, Simi Valley CA USA
Message-ID: <E9y9J7.Io2@moe.2bsd.com>
Date: Sat, 10 May 1997 05:21:07 GMT
Lines: 379
Xref: euryale.cc.adfa.oz.au comp.bugs.2bsd:767

Subject: static memory conflict in sendmail, hack Makefile fixed (#373)
Index:	usr.sbin/sendmail/src/conf.c,games/hack/Makefile 2.11BSD

Description:
	Sendmail was unable to determine the name of the user running him
	due to a static buffer being used without being saved between calls.

	The Makefile for hack(6) was installing the executable in the wrong
	place and failing to create a required directory.

Repeat-By:
	Recreate the aliases database with "sendmail -bi".  Then look at the
	logfile.  Note that you see your timezone name instead of 'root' or 
	other valid username.

May  9 20:16:35 curly sendmail[1622]: alias database rebuilt by PDT
May  9 20:16:36 curly sendmail[1622]: 12 aliases, longest 21 bytes, 201 bytes total

	After applying the fix below and installing the new sendmail the 
	expected message is seen:

May  9 20:17:04 curly sendmail[1634]: alias database rebuilt by root
May  9 20:17:05 curly sendmail[1634]: 12 aliases, longest 21 bytes, 201 bytes total

	cd /usr/src/games/hack
	make install

	Note that an error occurs because the executable is attempting to
	be installed in an incorrect directory.

Fix:
	The fixes are small but will require 'sendmail' to be recompiled and
	installed.

	Cut where indicated and save to a file (/tmp/373).  Then:

		patch -p0 < /tmp/373
		cd /usr/src/usr.sbin/sendmail/src
		make
		make install
		sendmail -bz

	If you run sendmail in 'daemon' mode it will be necessary to do a 
	'ps -ax|grep sendmail' and kill the running sendmail process and
	restart it.

	hack(6) may even run - if you're the adventurous type of person:

		cd /usr/src/games/hack
		make
		make install

	As always this and previous updates to 2.11BSD are available via
	anonymous FTP to either FTP.IIPO.GTEGSC.COM or MOE.2BSD.COM in the
	directory /pub/2.11BSD.
-----------------------------cut here------------------------
*** /usr/src/games/hack/Makefile.old	Sat Mar 30 23:10:15 1996
--- /usr/src/games/hack/Makefile	Mon Apr 28 20:14:27 1997
***************
*** 1,4 ****
! #	#(@)	Makefile	1.1 (2.11BSD)	1996/3/21
  #
  # Hack Overlay Makefile.
  
--- 1,4 ----
! #	#(@)	Makefile	1.2 (2.11BSD)	1997/4/28
  #
  # Hack Overlay Makefile.
  
***************
*** 7,13 ****
  
  # make hack
  GAME = hack
! GAMEDIR = /usr/games/lib/hackdir
  DESTDIR =
  GAMEUID = daemon
  CFLAGS = -O
--- 7,14 ----
  
  # make hack
  GAME = hack
! BINDIR = /usr/games
! LIBDIR = /usr/games/lib/hackdir
  DESTDIR =
  GAMEUID = daemon
  CFLAGS = -O
***************
*** 160,168 ****
  
  
  install: $(GAME)
! 	install -o $(GAMEUID) -m 4711 $(GAME) $(DESTDIR)$(GAMEDIR)/$(GAME)
! 	rm -f $(DESTDIR)/$(GAMEDIR)/bones*
! 
  
  #   The make node `depend' has been commented out as the current dependency
  # list is [now] not as simple as it used to be ...  The reason for this is
--- 161,171 ----
  
  
  install: $(GAME)
! 	install -o $(GAMEUID) -m 4711 $(GAME) $(DESTDIR)$(BINDIR)/$(GAME)
! 	-rm -rf $(DESTDIR)/$(LIBDIR)
! 	-mkdir -p ${DESTDIR}/${LIBDIR}
! 	chown daemon ${DESTDIR}/${LIBDIR}
! 	chmod 700 ${DESTDIR}/${LIBDIR}
  
  #   The make node `depend' has been commented out as the current dependency
  # list is [now] not as simple as it used to be ...  The reason for this is
*** /usr/src/usr.sbin/sendmail/src/conf.c.old	Thu Oct 24 21:08:11 1996
--- /usr/src/usr.sbin/sendmail/src/conf.c	Fri May  9 20:09:39 1997
***************
*** 9,15 ****
  */
  
  #if !defined(lint) && !defined(NOSCCS)
! static char	SccsId[] = "@(#)conf.c	5.14.4 (2.11BSD GTE) 1996/10/24";
  #endif
  
  # include <pwd.h>
--- 9,15 ----
  */
  
  #if !defined(lint) && !defined(NOSCCS)
! static char	SccsId[] = "@(#)conf.c	5.14.5 (2.11BSD GTE) 1997/5/9";
  #endif
  
  # include <pwd.h>
***************
*** 25,35 ****
  **	Defines the configuration of this installation.
  **
  **	Compilation Flags:
- **		V6 -- running on a version 6 system.  This determines
- **			whether to define certain routines between
- **			the two systems.  If you are running a funny
- **			system, e.g., V6 with long tty names, this
- **			should be checked carefully.
  **		VMUNIX -- running on a Berkeley UNIX system.
  **
  **	Configuration Variables:
--- 25,30 ----
***************
*** 152,317 ****
  	DefUid = 1;
  	DefGid = 1;
  }
- 
- # ifdef V6
- /*
- **  TTYNAME -- return name of terminal.
- **
- **	Parameters:
- **		fd -- file descriptor to check.
- **
- **	Returns:
- **		pointer to full path of tty.
- **		NULL if no tty.
- **
- **	Side Effects:
- **		none.
- */
  
- char *
- ttyname(fd)
- 	int fd;
- {
- 	register char tn;
- 	static char pathn[] = "/dev/ttyx";
- 
- 	/* compute the pathname of the controlling tty */
- 	if ((tn = ttyn(fd)) == NULL)
- 	{
- 		errno = 0;
- 		return (NULL);
- 	}
- 	pathn[8] = tn;
- 	return (pathn);
- }
- /*
- **  FDOPEN -- Open a stdio file given an open file descriptor.
- **
- **	This is included here because it is standard in v7, but we
- **	need it in v6.
- **
- **	Algorithm:
- **		Open /dev/null to create a descriptor.
- **		Close that descriptor.
- **		Copy the existing fd into the descriptor.
- **
- **	Parameters:
- **		fd -- the open file descriptor.
- **		type -- "r", "w", or whatever.
- **
- **	Returns:
- **		The file descriptor it creates.
- **
- **	Side Effects:
- **		none
- **
- **	Called By:
- **		deliver
- **
- **	Notes:
- **		The mode of fd must match "type".
- */
- 
- FILE *
- fdopen(fd, type)
- 	int fd;
- 	char *type;
- {
- 	register FILE *f;
- 
- 	f = fopen("/dev/null", type);
- 	(void) close(fileno(f));
- 	fileno(f) = fd;
- 	return (f);
- }
- /*
- **  INDEX -- Return pointer to character in string
- **
- **	For V7 compatibility.
- **
- **	Parameters:
- **		s -- a string to scan.
- **		c -- a character to look for.
- **
- **	Returns:
- **		If c is in s, returns the address of the first
- **			instance of c in s.
- **		NULL if c is not in s.
- **
- **	Side Effects:
- **		none.
- */
- 
- char *
- index(s, c)
- 	register char *s;
- 	register char c;
- {
- 	while (*s != '\0')
- 	{
- 		if (*s++ == c)
- 			return (--s);
- 	}
- 	return (NULL);
- }
- /*
- **  UMASK -- fake the umask system call.
- **
- **	Since V6 always acts like the umask is zero, we will just
- **	assume the same thing.
- */
- 
- /*ARGSUSED*/
- umask(nmask)
- {
- 	return (0);
- }
- 
- 
  /*
- **  GETRUID -- get real user id.
- */
- 
- getruid()
- {
- 	return (getuid() & 0377);
- }
- 
- 
- /*
- **  GETRGID -- get real group id.
- */
- 
- getrgid()
- {
- 	return (getgid() & 0377);
- }
- 
- 
- /*
- **  GETEUID -- get effective user id.
- */
- 
- geteuid()
- {
- 	return ((getuid() >> 8) & 0377);
- }
- 
- 
- /*
- **  GETEGID -- get effective group id.
- */
- 
- getegid()
- {
- 	return ((getgid() >> 8) & 0377);
- }
- 
- # endif V6
- 
- # ifndef V6
- 
- /*
  **  GETRUID -- get real user id (V7)
  */
  
--- 147,154 ----
***************
*** 336,343 ****
  		return (getgid());
  }
  
! # endif V6
! /*
  **  USERNAME -- return the user id of the logged in user.
  **
  **	Parameters:
--- 173,179 ----
  		return (getgid());
  }
  
! /*
  **  USERNAME -- return the user id of the logged in user.
  **
  **	Parameters:
***************
*** 370,376 ****
  
  			pw = getpwuid(getruid());
  			if (pw != NULL)
! 				myname = pw->pw_name;
  		}
  		else
  		{
--- 206,212 ----
  
  			pw = getpwuid(getruid());
  			if (pw != NULL)
! 				myname = newstr(pw->pw_name);
  		}
  		else
  		{
***************
*** 380,386 ****
  			{
  				pw = getpwuid(getuid());
  				if (pw != NULL)
! 					myname = pw->pw_name;
  			}
  		}
  		if (myname == NULL || myname[0] == '\0')
--- 216,222 ----
  			{
  				pw = getpwuid(getuid());
  				if (pw != NULL)
! 					myname = newstr(pw->pw_name);
  			}
  		}
  		if (myname == NULL || myname[0] == '\0')
*** /VERSION.old	Wed May  7 20:06:21 1997
--- /VERSION	Fri May  9 21:57:12 1997
***************
*** 1,5 ****
! Current Patch Level: 372
! Date: May 7, 1997
  
  2.11 BSD
  ============
--- 1,5 ----
! Current Patch Level: 373
! Date: May 9, 1997
  
  2.11 BSD
  ============