Making inheritance of group ID configurable

Andre Albsmeier andre.albsmeier at siemens.com
Mon Feb 9 08:11:03 PST 2004


New items created on an ufs normally inherit their group ID from
the parent directory. I have the need for making this configurable.

Since the set-group-ID bit is not used for directories on BSD,
I would like to use it to decide on this: If it is set, the group
ID of the newly created item corresponds to the one of the creating
process. (Yeah, this is exactly the wrong way around compared to
what "the Others" do but I don't want to change the BSD default).

I am currently using this patch. It seems to work great but I would
like to know if I have forgotten something ;-)

--- sys/ufs/ufs/ufs_vnops.c.ORI	Fri Jan  3 08:41:47 2003
+++ sys/ufs/ufs/ufs_vnops.c	Mon Feb  9 16:32:46 2004
@@ -1276,6 +1276,11 @@
 	if (error)
 		goto out;
 	ip = VTOI(tvp);
+#ifdef ANDRE
+	if( (dp->i_mode & ISGID) )
+	  ip->i_gid = cnp->cn_cred->cr_gid;
+	else
+#endif
 	ip->i_gid = dp->i_gid;
 #ifdef SUIDDIR
 	{
@@ -2070,6 +2075,11 @@
 	if (error)
 		return (error);
 	ip = VTOI(tvp);
+#ifdef ANDRE
+	if( (pdir->i_mode & ISGID) )
+	  ip->i_gid = cnp->cn_cred->cr_gid;
+	else
+#endif
 	ip->i_gid = pdir->i_gid;
 #ifdef SUIDDIR
 	{


Any hints are welcome.

Thanks,

	-Andre


More information about the freebsd-hackers mailing list