*BSD News Article 20536


Return to BSD News archive

Path: sserve!newshost.anu.edu.au!munnari.oz.au!news.Hawaii.Edu!ames!agate!spool.mu.edu!bloom-beacon.mit.edu!news.kei.com!ub!rutgers!headwall.Stanford.EDU!kithrup.com!sef
From: sef@kithrup.com (Sean Eric Fagan)
Newsgroups: comp.os.386bsd.bugs
Subject: bug with ufs file creation
Message-ID: <CCyLF6.n6@kithrup.com>
Date: 7 Sep 93 00:59:14 GMT
Organization: Kithrup Enterprises, Ltd.
Lines: 26

*I* consider this a bug.  It exists in every Net/2-derived system I could
play with, including BSD4.4.  When creating a file, the gid given to the
file is the gid of the directory it is in, and not the gid of the process
creating the file.  The following patch fixes that; it will only use the
gid of the directory if the directory's SGID bit is set.

*** 1.10	1993/08/08 12:09:51
--- ufs_vnops.c	1993/09/07 00:15:51
***************
*** 1641,1647 ****
--- 1641,1655 ----
  		ip->i_di_spare[i] = (unsigned long)0L;
  	ip->i_fsize = (unsigned long)0L;
  	ip->i_uid = ndp->ni_cred->cr_uid;
+ 	/*
+ 	 * If the SGID bit is set on the parent directory,
+ 	 * use its GID for the file; otherwise, use the 'default
+ 	 * group' of the creating process.
+ 	 */
+ 	if (pdir->i_mode & S_ISGID)
  		ip->i_gid = pdir->i_gid;
+ 	else
+ 		ip->i_gid = ndp->ni_cred->cr_groups[0];
  #ifdef QUOTA
  	if ((error = getinoquota(ip)) ||
  	    (error = chkiq(ip, 1, ndp->ni_cred, 0))) {