File create permissions, what am I missing?

Dan Nelson dnelson at allantgroup.com
Sat Aug 13 06:11:17 GMT 2005


In the last episode (Aug 12), Mike Meyer said:
> In <20050812233728.GA22225 at odin.ac.hmc.edu>, Brooks Davis <brooks at one-eyed-alien.net> typed:
> > On Fri, Aug 12, 2005 at 06:34:34PM -0300, Jo~ao Carlos Mendes Luis wrote:
> > > In a directory with -rwxrwxrwx, any user can create files, but
> > > who should be the owner/group of this file?
> > 
> > On BSD systems, the group of a file is always the group of the
> > directory it is in.  This differs from SysV UNIX.  The resident
> > grey-beard at work feels this is a new and annoying behavior. (i.e.
> > it wasn't always this way. :)
> 
> SysV lets you toggle that behavior on a per-directory basis. Turn the
> setgid bit on in the directory, and files created in it will be owned
> by the group that owns the directory.

Unfortunately, FreeBSD doesn't honor the "subdirectories created under
SGID subdirectories inherit the flag" rule, so you can't serve SysV
clients from FreeBSD NFS hosts without the permissions getting screwed
up (SysV clients expect the nfs server to set the bit).  Fix:

RCS file: /home/ncvs/src/sys/ufs/ufs/ufs_vnops.c,v
retrieving revision 1.271
diff -u -r1.271 ufs_vnops.c
--- ufs_vnops.c 9 Jun 2005 20:20:31 -0000       1.271
+++ ufs_vnops.c 14 Jun 2005 18:22:01 -0000
@@ -1336,6 +1336,8 @@
        ip = VTOI(tvp);
        ip->i_gid = dp->i_gid;
        DIP_SET(ip, i_gid, dp->i_gid);
+       if (dp->i_mode & ISGID) 
+               dmode |= ISGID;
 #ifdef SUIDDIR
        {
 #ifdef QUOTA

-- 
	Dan Nelson
	dnelson at allantgroup.com


More information about the freebsd-hackers mailing list