From: Subrata <sub...@us...> - 2008-12-31 05:35:08
|
Update of /cvsroot/ltp/ltp/testcases/kernel/syscalls/mknod In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv21288/ltp/testcases/kernel/syscalls/mknod Modified Files: mknod07.c Log Message: Amend cleanup procedure in mknod07: the cleanup in mknod07 didn't work for me, because the test yields root, removes search permission on its current directory and then tries to chdir("..") which fails due to the missing permission. This patch fixes that by re-gaining root before the cleanup. - restore root privileges before tmp directory cleanup. This is needed, because as nonprivileged user, we don't have search permission on the current directory, - because of that, do not drop root completely by setuid(), change effective uid instead, - call cleanup in one case when setup fails, Signed-Off-By: Jiri Palecek <jpa...@we...>. Index: mknod07.c =================================================================== RCS file: /cvsroot/ltp/ltp/testcases/kernel/syscalls/mknod/mknod07.c,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** mknod07.c 26 Mar 2003 22:40:44 -0000 1.4 --- mknod07.c 31 Dec 2008 05:35:03 -0000 1.5 *************** *** 210,218 **** } ltpuser = getpwnam(nobody_uid); ! if (setuid(ltpuser->pw_uid) == -1) { ! tst_resm(TINFO, "setuid failed to " ! "to set the effective uid to %d", ! ltpuser->pw_uid); ! perror("setuid"); } --- 210,217 ---- } ltpuser = getpwnam(nobody_uid); ! if (seteuid(ltpuser->pw_uid) == -1) { ! tst_brkm(TBROK, NULL, "setuid failed to " ! "to set the effective uid to %d: %s", ! ltpuser->pw_uid, strerror(errno)); } *************** *** 229,233 **** */ if (mkdir(DIR_TEMP, MODE_RWX) < 0) { ! tst_brkm(TBROK, NULL, "mkdir(2) of %s failed", DIR_TEMP); tst_exit(); } --- 228,232 ---- */ if (mkdir(DIR_TEMP, MODE_RWX) < 0) { ! tst_brkm(TBROK, cleanup, "mkdir(2) of %s failed", DIR_TEMP); tst_exit(); } *************** *** 294,304 **** TEST_CLEANUP; ! /* Change the directory back to temporary directory */ ! chdir(".."); ! ! /* Restore mode permissions on test directory created in setup2() */ ! if (chmod(DIR_TEMP, MODE_RWX) < 0) { ! tst_brkm(TBROK, NULL, "chmod(2) of %s failed", DIR_TEMP); ! } /* Remove files and temporary directory created */ --- 293,298 ---- TEST_CLEANUP; ! if(seteuid(0)==-1) ! tst_resm(TBROK, "Couldn't get root back: %s", strerror(errno)); /* Remove files and temporary directory created */ |