Subject: Re: Permissions on directories.To: I can teach you how to fish... <greywolf@starwolf.starwolf.com>From: Todd Vierling <tv@pobox.com>List: current-usersDate: 10/20/1998 18:24:21

On Tue, 20 Oct 1998, I can teach you how to fish... wrote:
: The ability to have it optional certainly is more appealing; SVRx (for
: 0 <= x < 4) only did the real gid, while BSD has _always_ done the
: "inherit the parent directory's gid" which, while I was used to it,
: was occasionally annoying.
Well, for those who _do_ care, here's a not so beautiful patch that adds a
compile time option. I'd like to propose sysctling it and adding it to
-current.
When FFS_USE_EGID is compiled in the kernel, if the user is a member of the
parent directory's group, or the directory is setgid, the new inode will be
created with the directory's group. Otherwise, the new inode will use the
user's egid. This seemed to me like the best tradeoff between the two.
This is not quite the same thing as SVR4: it uses the directory's group if
the user is a member of that group, not just if that group is the user's
primary.
Index: ufs_vnops.c
===================================================================
RCS file: /cvsroot/src/sys/ufs/ufs/ufs_vnops.c,v
retrieving revision 1.51
diff -u -r1.51 ufs_vnops.c
--- ufs_vnops.c 1998/09/08 08:37:12 1.51
+++ ufs_vnops.c 1998/10/20 22:25:45
@@ -1210,6 +1210,11 @@
goto out;
ip = VTOI(tvp);
ip->i_ffs_uid = cnp->cn_cred->cr_uid;
+#ifdef FFS_USE_EGID
+ if (!groupmember(dp->i_ffs_gid, cnp->cn_cred))
+ ip->i_ffs_gid = cnp->cn_cred->cr_gid;
+ else
+#endif
ip->i_ffs_gid = dp->i_ffs_gid;
#ifdef QUOTA
if ((error = getinoquota(ip)) ||
@@ -1983,6 +1988,11 @@
return (error);
}
ip = VTOI(tvp);
+#ifdef FFS_USE_EGID
+ if (!groupmember(pdir->i_ffs_gid, cnp->cn_cred))
+ ip->i_ffs_gid = cnp->cn_cred->cr_gid;
+ else
+#endif
ip->i_ffs_gid = pdir->i_ffs_gid;
ip->i_ffs_uid = cnp->cn_cred->cr_uid;
#ifdef QUOTA
--
-- Todd Vierling (Personal tv@pobox.com; Bus. todd_vierling@xn.xerox.com)