This patch fixed the modify of the group ownership before
do dir chmod and fixed the effective user when do cleanup.
Those problems cause the test failed with the following
error message:

  fchmod05    1  FAIL  :  testdir: Incorrect modes 043777, Expected 0777
  fchmod05    0  WARN  :  tst_rmdir(): rmobj(/tmp/fchUout8n) failed: \
    remove(/tmp/fchUout8n) failed; errno=1: Operation not permitted

Signed-off-by: Wei Yongjun <[email protected]>
---
 testcases/kernel/syscalls/fchmod/fchmod05.c |   13 ++++++++-----
 1 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/testcases/kernel/syscalls/fchmod/fchmod05.c 
b/testcases/kernel/syscalls/fchmod/fchmod05.c
index 3573f65..5226858 100644
--- a/testcases/kernel/syscalls/fchmod/fchmod05.c
+++ b/testcases/kernel/syscalls/fchmod/fchmod05.c
@@ -154,10 +154,10 @@ int main(int ac, char **av)
                        if ((PERMS & ~S_ISGID) != dir_mode) {
                                tst_resm(TFAIL, "%s: Incorrect modes 0%03o, "
                                         "Expected 0%03o",
-                                        TESTDIR, PERMS, MODE_RWX);
+                                        TESTDIR, dir_mode, PERMS & ~S_ISGID);
                        } else {
                                tst_resm(TPASS, "Functionality of fchmod(%d, "
-                                        "%#o) successful", fd, PERMS);
+                                        "%#o) successful", fd, PERMS & 
~S_ISGID);
                        }
                } else {
                        tst_resm(TPASS, "call succeeded");
@@ -218,12 +218,12 @@ void setup()
                tst_brkm(TBROK, cleanup, "mkdir(2) of %s failed", TESTDIR);
        }
 
-       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 || seteuid(nobody_u->pw_uid) == -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));
 
@@ -258,6 +258,9 @@ void cleanup()
                         TESTDIR, errno, strerror(errno));
        }
 
+       setegid(0);
+       seteuid(0);
+
        /* Remove tmp dir and all files in it */
        tst_rmdir();
 
-- 
1.6.0.2.530.g67faa





------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables unlimited
royalty-free distribution of the report engine for externally facing 
server and web deployment.
http://p.sf.net/sfu/businessobjects
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

Reply via email to