Subject: setgid bit cleared by root chown (#382)
Index:	sys/ufs_syscalls.c 2.11BSD

Description:
	The setgid bit is not being preserved when a uid 0 process changes
	the ownership of a file.

Repeat-By:
	Extra a tar or afio archive containing setgid files (/bin/ps is
	a good example, it needs to be setgid=kmem).  Note that while the
	group ownership is preserved but the setgid bit is cleared.

Fix:
	A typographical logic error was the cause.  Instead of checking that
	the process performing the chown(2) had a UID of 0 the check was
	made against the GID 0.

	To apply this fix cut where indicated and save to a file (/tmp/382)
	Then:

		patch  -p0 < /tmp/382
		cd /sys/YOUR_KERNEL
		make
		make install
		reboot

	The GENERIC kernel, if you keep one around, should also be rebuilt:

		cd /sys/GENERIC
		make
		mv unix /genunix
		chmod 744 /genunix

	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/sys/sys/ufs_syscalls.c.old	Fri Feb  7 10:34:33 1997
--- /usr/src/sys/sys/ufs_syscalls.c	Tue Aug  5 21:06:27 1997
***************
*** 3,9 ****
   * All rights reserved.  The Berkeley software License Agreement
   * specifies the terms and conditions for redistribution.
   *
!  *	@(#)ufs_syscalls.c	1.10 (2.11BSD GTE) 1997/2/7
   */
  
  #include "param.h"
--- 3,9 ----
   * All rights reserved.  The Berkeley software License Agreement
   * specifies the terms and conditions for redistribution.
   *
!  *	@(#)ufs_syscalls.c	1.11 (2.11BSD GTE) 1997/8/5
   */
  
  #include "param.h"
***************
*** 716,722 ****
  		ip->i_flag |= ICHG;
  	if (ouid != uid && u.u_uid != 0)
  		ip->i_mode &= ~ISUID;
! 	if (ogid != gid && u.u_gid != 0)
  		ip->i_mode &= ~ISGID;
  	return (0);
  }
--- 716,722 ----
  		ip->i_flag |= ICHG;
  	if (ouid != uid && u.u_uid != 0)
  		ip->i_mode &= ~ISUID;
! 	if (ogid != gid && u.u_uid != 0)
  		ip->i_mode &= ~ISGID;
  	return (0);
  }
*** /VERSION.old	Sat Aug  2 21:26:20 1997
--- /VERSION	Tue Aug  5 21:07:30 1997
***************
*** 1,5 ****
! Current Patch Level: 381
! Date: August 2, 1997
  
  2.11 BSD
  ============
--- 1,5 ----
! Current Patch Level: 382
! Date: August 5, 1997
  
  2.11 BSD
  ============
