Issue observed with chmod05, fchmod05 test cases
Hi Sharyathi,
This is the forwarded mail containing the patch for chmod05 in new LTP provided by Wei Yongjun <[email protected]>.
Is this the functionality you are also looking for and trying to fix?
Thanks
Muni
Refer to the manpage:
# man 2 chmod If the calling process is not privileged (Linux: does not have the CAP_FSETID capability), and the group of the file does not match the effective group ID of the process or one of its supplementary group IDs, the S_ISGID bit will be turned off, but this will not cause an error to be returned.
So, if we want S_ISGID bit be turned off after chmod(), we can not have the CAP_FSETID capability and not match the effective group ID. The 'bin' group always has the CAP_FSETID capability, so we can not change the own of the TESTDIR to 'bin' group, instead, 'nobody' can be used.
This patch fixed the problem by change gid of chown to 'nobody' group and change the gid of setegid() to 'bin' group.
--- testcases/kernel/syscalls/chmod/chmod05.c | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-)
testcases/kernel/syscalls/chmod/chmod05.c +4 -4
@@ -177,7 +177,7 @@ int main(int ac, char **av)if ((PERMS & ~S_ISGID ) != dir_mode) {tst_resm (TFAIL ,"%s: Incorrect modes 0%03o, " "Expected 0%03o" ,TESTDIR , dir_mode, -PERMS ); +PERMS & ~S_ISGID ); }else { tst_resm(TPASS, "Functionality of chmod(%s, %#o) successful",
@@ -241,12 +241,12 @@ void setup() strerror(errno)); } -if (chown (TESTDIR , nobody_u->pw_uid, bin_group->gr_gid) ==-1 ) +if (chown (TESTDIR , nobody_u->pw_uid, nobody_u->pw_gid) ==-1 )tst_brkm (TBROK , cleanup,"Couldn't change owner of testdir: %s" ,strerror (errno)); -/* change to nobody:nobody */ -if (setegid (nobody_u->pw_gid) ==-1 || +/* change to nobody:bin */ +if (setegid (bin_group->gr_gid) ==-1 ||seteuid (nobody_u->pw_uid) ==-1 )tst_brkm (TBROK , cleanup,"Couldn't switch to nobody:nobody: %s" ,strerror (errno));
Signature · 16 lines
1.6.0.2.530.g67faa ------------------------------------------------------------------------------ OpenSolaris 2009.06 is a cutting edge operating system for enterprises looking to deploy the next generation of Solaris that includes the latest innovations from Sun and the OpenSource community. Download a copy and enjoy capabilities such as Networking, Storage and Virtualization. Go to: http://p.sf.net/sfu/opensolaris-get _______________________________________________ Ltp-list mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/ltp-list
------------------------------------------------------------------------------
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
Muni
What I am trying to say is, this fix assumes thatBin->GID is part of supplementary group IDs of root and nobody->GID is not. There is no basis for this assumption. If nobody->GID is part of supplementary group ID than it will fail again.
So instead specifically set the supplementary group ID of the process to avoid confusion
Thanks
Yeehaw
Quoted 30 lines
testcases/kernel/syscalls/chmod/chmod05.c +4
-4@@ -177,7 +177,7 @@ int main(int ac, char **av)if ((PERMS & ~S_ISGID ) != dir_mode) {tst_resm (TFAIL ,"%s: Incorrect modes 0%03o, " "Expected 0%03o" ,TESTDIR , dir_mode, -PERMS ); +PERMS & ~S_ISGID ); }else { tst_resm(TPASS, "Functionality of chmod(%s, %#o) successful",@@ -241,12 +241,12 @@ void setup() strerror(errno)); } -if (chown (TESTDIR , nobody_u->pw_uid, bin_group->gr_gid) ==-1 ) +if (chown (TESTDIR , nobody_u->pw_uid, nobody_u->pw_gid) ==-1 )tst_brkm (TBROK , cleanup,"Couldn't change owner of testdir: %s" ,strerror (errno)); -/* change to nobody:nobody */ -if (setegid (nobody_u->pw_gid) ==-1 || +/* change to nobody:bin */ +if (setegid (bin_group->gr_gid) ==-1 ||seteuid (nobody_u->pw_uid) ==-1 ) tst_brkm(TBROK, cleanup, "Couldn't switch to nobody:nobody: %s",
Quoted 1 line
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