[Unionfs] SGID directory flag doesn't work
Josef Sipek
jsipek at fsl.cs.sunysb.edu
Wed Aug 22 10:50:55 EDT 2007
On Tue, Aug 21, 2007 at 10:11:51AM +0400, Andrew Stepanov wrote:
> 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
Which version of unionfs is this? It looks old. Unionfs 2.x doesn't support
the debug/delete mount options - no need for them really.
> 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
Good catch.
> Please, see attached patch. Does it solve this problem ?
>
> Thanks.
> 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) {
I'm a little bit confused about the above 'else' keyword (could be that
you're looking at 1.x code which is different quite a bit), but otherwise I
think idea is sane.
Josef 'Jeff' Sipek.
> + 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;
--
Intellectuals solve problems; geniuses prevent them
- Albert Einstein
More information about the unionfs
mailing list