Subject: Re: chmod g+s on directory
To: Theo Deraadt <deraadt@fsa.ca>
From: Manuel Bouyer <bouyer@ensta.fr>
List: current-users
Date: 05/12/1994 16:45:16
> 
> > The group id is always
> > propagated, even if the user which create the file isn't member of this group.
> 
> This is the BSD way to do it. The setgid bit thing you are describing
> is used to map to the SYSV way of creating new files -- in SYSV they
> files always take on the gid of the user.

So, the behavior for an UFS file system and a NFS one should be the same, i
think.  It is if the NFS server is a NetBSD, but it is not whith other os
as server (at least SunOS 4.1.1 and HP-UX 9.01). Here are my diffs (from
tar_ball of 16 april) to have the gid propagated on nfs filesystems.
This works whith SunOS 4.1.1 and HP-UX 9.01 servers. Perhaps this sould be set
as an option.

*** nfs_vnops.c-	Thu May 12 16:40:00 1994
--- nfs_vnops.c	Thu May 12 16:03:55 1994
***************
*** 789,794 ****
--- 789,795 ----
  	int error = 0;
  	struct mbuf *mreq, *mrep, *md, *mb, *mb2;
  	u_long rdev;
+ 	struct nfsnode *dnp=VTONFS(ndp->ni_dvp);
  
  	if (vap->va_type == VCHR || vap->va_type == VBLK)
  		rdev = txdr_unsigned(vap->va_rdev);
***************
*** 809,815 ****
  	nfsm_build(sp, struct nfsv2_sattr *, NFSX_SATTR);
  	sp->sa_mode = vtonfs_mode(vap->va_type, vap->va_mode);
  	sp->sa_uid = txdr_unsigned(ndp->ni_cred->cr_uid);
! 	sp->sa_gid = txdr_unsigned(ndp->ni_cred->cr_gid);
  	sp->sa_size = rdev;
  	/* or should these be VNOVAL ?? */
  	txdr_time(&vap->va_atime, &sp->sa_atime);
--- 810,817 ----
  	nfsm_build(sp, struct nfsv2_sattr *, NFSX_SATTR);
  	sp->sa_mode = vtonfs_mode(vap->va_type, vap->va_mode);
  	sp->sa_uid = txdr_unsigned(ndp->ni_cred->cr_uid);
! /*	sp->sa_gid = txdr_unsigned(ndp->ni_cred->cr_gid);*/
!     sp->sa_gid = txdr_unsigned(dnp->n_vattr.va_gid);
  	sp->sa_size = rdev;
  	/* or should these be VNOVAL ?? */
  	txdr_time(&vap->va_atime, &sp->sa_atime);
***************
*** 838,843 ****
--- 840,846 ----
  	u_long xid;
  	int error = 0;
  	struct mbuf *mreq, *mrep, *md, *mb, *mb2;
+     struct nfsnode *dnp=VTONFS(ndp->ni_dvp);
  
  	nfsstats.rpccnt[NFSPROC_CREATE]++;
  	nfsm_reqhead(nfs_procids[NFSPROC_CREATE], ndp->ni_cred,
***************
*** 847,853 ****
  	nfsm_build(sp, struct nfsv2_sattr *, NFSX_SATTR);
  	sp->sa_mode = vtonfs_mode(vap->va_type, vap->va_mode);
  	sp->sa_uid = txdr_unsigned(ndp->ni_cred->cr_uid);
! 	sp->sa_gid = txdr_unsigned(ndp->ni_cred->cr_gid);
  	sp->sa_size = txdr_unsigned(0);
  	/* or should these be VNOVAL ?? */
  	txdr_time(&vap->va_atime, &sp->sa_atime);
--- 850,857 ----
  	nfsm_build(sp, struct nfsv2_sattr *, NFSX_SATTR);
  	sp->sa_mode = vtonfs_mode(vap->va_type, vap->va_mode);
  	sp->sa_uid = txdr_unsigned(ndp->ni_cred->cr_uid);
! /*  sp->sa_gid = txdr_unsigned(ndp->ni_cred->cr_gid);*/
!     sp->sa_gid = txdr_unsigned(dnp->n_vattr.va_gid);
  	sp->sa_size = txdr_unsigned(0);
  	/* or should these be VNOVAL ?? */
  	txdr_time(&vap->va_atime, &sp->sa_atime);
***************
*** 1111,1116 ****
--- 1115,1121 ----
  	u_long xid;
  	int error = 0;
  	struct mbuf *mreq, *mrep, *md, *mb, *mb2;
+     struct nfsnode *dnp=VTONFS(ndp->ni_dvp);
  
  	nfsstats.rpccnt[NFSPROC_SYMLINK]++;
  	nfsm_reqhead(nfs_procids[NFSPROC_SYMLINK], ndp->ni_cred,
***************
*** 1121,1127 ****
  	nfsm_build(sp, struct nfsv2_sattr *, NFSX_SATTR);
  	sp->sa_mode = vtonfs_mode(VLNK, vap->va_mode);
  	sp->sa_uid = txdr_unsigned(ndp->ni_cred->cr_uid);
! 	sp->sa_gid = txdr_unsigned(ndp->ni_cred->cr_gid);
  	sp->sa_size = txdr_unsigned(VNOVAL);
  	txdr_time(&vap->va_atime, &sp->sa_atime);	/* or VNOVAL ?? */
  	txdr_time(&vap->va_mtime, &sp->sa_mtime);	/* or VNOVAL ?? */
--- 1126,1133 ----
  	nfsm_build(sp, struct nfsv2_sattr *, NFSX_SATTR);
  	sp->sa_mode = vtonfs_mode(VLNK, vap->va_mode);
  	sp->sa_uid = txdr_unsigned(ndp->ni_cred->cr_uid);
! /*  sp->sa_gid = txdr_unsigned(ndp->ni_cred->cr_gid);*/
!     sp->sa_gid = txdr_unsigned(dnp->n_vattr.va_gid);
  	sp->sa_size = txdr_unsigned(VNOVAL);
  	txdr_time(&vap->va_atime, &sp->sa_atime);	/* or VNOVAL ?? */
  	txdr_time(&vap->va_mtime, &sp->sa_mtime);	/* or VNOVAL ?? */
***************
*** 1155,1160 ****
--- 1161,1167 ----
  	u_long xid;
  	int error = 0, firsttry = 1;
  	struct mbuf *mreq, *mrep, *md, *mb, *mb2;
+     struct nfsnode *dnp=VTONFS(ndp->ni_dvp);
  
  	len = ndp->ni_namelen;
  	nfsstats.rpccnt[NFSPROC_MKDIR]++;
***************
*** 1165,1171 ****
  	nfsm_build(sp, struct nfsv2_sattr *, NFSX_SATTR);
  	sp->sa_mode = vtonfs_mode(VDIR, vap->va_mode);
  	sp->sa_uid = txdr_unsigned(ndp->ni_cred->cr_uid);
! 	sp->sa_gid = txdr_unsigned(ndp->ni_cred->cr_gid);
  	sp->sa_size = txdr_unsigned(VNOVAL);
  	txdr_time(&vap->va_atime, &sp->sa_atime);	/* or VNOVAL ?? */
  	txdr_time(&vap->va_mtime, &sp->sa_mtime);	/* or VNOVAL ?? */
--- 1172,1179 ----
  	nfsm_build(sp, struct nfsv2_sattr *, NFSX_SATTR);
  	sp->sa_mode = vtonfs_mode(VDIR, vap->va_mode);
  	sp->sa_uid = txdr_unsigned(ndp->ni_cred->cr_uid);
! /*  sp->sa_gid = txdr_unsigned(ndp->ni_cred->cr_gid);*/
!     sp->sa_gid = txdr_unsigned(dnp->n_vattr.va_gid);
  	sp->sa_size = txdr_unsigned(VNOVAL);
  	txdr_time(&vap->va_atime, &sp->sa_atime);	/* or VNOVAL ?? */
  	txdr_time(&vap->va_mtime, &sp->sa_mtime);	/* or VNOVAL ?? */

--
Manuel Bouyer, Ecole Nationale Superieure de Techniques Avancees, Paris
email: bouyer@ensta.fr
--

------------------------------------------------------------------------------