[Unionfs] SGID directory flag doesn't work

Andrew Stepanov stanv at altlinux.ru
Tue Aug 21 02:11:51 EDT 2007


Hello.

I have LiveCD.

Mount options are like this:

/mnt/root//etc /etc unionfs
rw,dirs=/mnt/root/etc=rw:/etc=ro,debug=4294967295,delete=whiteout 0 0

CD-ROM contain /etc/tcb/user directory with 'drwx--x---' rights

[root at localhost~] # chmod 2710 /etc/tcb/user directory now with 
'drwx--s---' rights

/etc/tcb/user is owned by 'user' (uid) and 'auth' (gid)

[user at localhost~] $ touch /etc/tcb/user/test_file
[user at localhost~] $ ls -l /etc/tcb/user/test_file
-rw-r--r-- 1 user user 0 Aug 21 06:49 test_file
Instead of:
-rw-r--r-- 1 user auth 0 Aug 21 06:49 test_file

So, SGID flag for directory doesn't make any sense.

Please, see attached patch. Does it solve this problem ?

Thanks.
-------------- next part --------------
diff -ruN linux-2.6.18/fs/unionfs/inode.c linux-2.6.18-modified/fs/unionfs/inode.c
--- linux-2.6.18/fs/unionfs/inode.c	2007-08-20 16:23:45 +0400
+++ linux-2.6.18-modified/fs/unionfs/inode.c	2007-08-20 16:20:44 +0400
@@ -85,7 +85,12 @@
 
 		newattrs.ia_mode = mode & ~current->fs->umask;
 		newattrs.ia_uid = current->fsuid;
-		newattrs.ia_gid = current->fsgid;
+		else if (parent->i_mode & S_ISGID) {
+			newattrs.i_gid = parent->i_gid;
+			if (S_ISDIR(mode))
+				mode |= S_ISGID;
+		} else
+			newattrs.ia_gid = current->fsgid;
 
 		if (wh_dentry->d_inode->i_size != 0) {
 			newattrs.ia_valid |= ATTR_SIZE;


More information about the unionfs mailing list