Hi
I was able to understand the problem...
This is what I learnt
Supplementary group IDs of a process is inherited from its parent process, so
who ever spawns the process transfer its supplementary group ids also to its
child process.
in our test case scenario checking the supplementary group IDs of root which is
spawning the test cases fchmod5 and chmod5 shows this
---------------------------------------------------------
cat test.c
---------------------------------------------------------
int main()
{
int size = 10;
int i, index;
gid_t list[10];
index = getgroups(size, list);
for ( i =0 ;i < index; i++)
printf("\n list[%d]:%d", i, list[i]);
printf("\n");
}
---------------------------------------------------------
[r...@mx3350a sharyathi]# ./a.out
list[0]:0
list[1]:1
list[2]:2
list[3]:3
list[4]:4
list[5]:6
list[6]:10
---------------------------------------------------------
This shows that bin->GID (1) is one of the supplementary group IDs of the
process
while nobody->GID (99) is not.
So in the kernel code
--------------------------------------------------------
if (ia_valid & ATTR_MODE) {
umode_t mode = attr->ia_mode;
if (!in_group_p(inode->i_gid) && !capable(CAP_FSETID))
mode &= ~S_ISGID;
inode->i_mode = mode;
}
--------------------------------------------------------
S_ISGID is cleared in case file attribute is nobody and not in case of GID
being bin
I was thinking of what could be the best solution as earlier solution proposed
are not fool proof
Attaching a fix I though is the best way to handle the issue
Thanks
Yeehaw
Index: ltp-full-20090430/testcases/kernel/syscalls/chmod/chmod05.c
===================================================================
--- ltp-full-20090430.orig/testcases/kernel/syscalls/chmod/chmod05.c 2009-04-25 23:22:44.000000000 +0530
+++ ltp-full-20090430/testcases/kernel/syscalls/chmod/chmod05.c 2009-07-20 16:34:07.000000000 +0530
@@ -240,6 +240,10 @@
tst_brkm(TBROK, cleanup, "mkdir(2) of %s failed: %s", TESTDIR,
strerror(errno));
}
+
+ if(setgroups(1, &nobody_u->pw_gid) == -1)
+ tst_brkm(TBROK, cleanup, "Couldn't change supplementary group Id: %s",
+ strerror(errno));
if (chown(TESTDIR, nobody_u->pw_uid, bin_group->gr_gid) == -1)
tst_brkm(TBROK, cleanup, "Couldn't change owner of testdir: %s",
Index: ltp-full-20090430/testcases/kernel/syscalls/fchmod/fchmod05.c
===================================================================
--- ltp-full-20090430.orig/testcases/kernel/syscalls/fchmod/fchmod05.c 2009-07-20 16:22:56.000000000 +0530
+++ ltp-full-20090430/testcases/kernel/syscalls/fchmod/fchmod05.c 2009-07-20 16:32:26.000000000 +0530
@@ -218,6 +218,10 @@
tst_brkm(TBROK, cleanup, "mkdir(2) of %s failed", TESTDIR);
}
+ if(setgroups(1, &nobody_u->pw_gid) == -1)
+ tst_brkm(TBROK, cleanup, "Couldn't change supplementary group Id: %s",
+ strerror(errno));
+
if (chown(TESTDIR, nobody_u->pw_uid, bin_group->gr_gid) == -1)
tst_brkm(TBROK, cleanup, "Couldn't change owner of testdir: %s",
strerror(errno));
------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge
This is your chance to win up to $100,000 in prizes! For a limited time,
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize
details at: http://p.sf.net/sfu/Challenge
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list