getuid, getgid, setuid, setgid: fixed 16-bit versions
Fixed 16-bit versions of testcases:
* getgid
* getuid
* setgid
* setuid
the way like setgroups.
Testcase getuid02 in fact tests geteuid() so renamed it to geteuid02.
Signed-off-by: Stanislav Kholmanskikh <stanislav.kholmanskikh@oracle.com>
diff --git a/testcases/kernel/syscalls/setuid/setuid03.c b/testcases/kernel/syscalls/setuid/setuid03.c
index e39ca7e..b836873 100644
--- a/testcases/kernel/syscalls/setuid/setuid03.c
+++ b/testcases/kernel/syscalls/setuid/setuid03.c
@@ -37,15 +37,17 @@
* 07/2001 Ported by Wayne Boyer
*
* RESTRICTIONS
- * Must be ran as non-root.
+ * Must be ran as root.
*/
#include <errno.h>
+#include <pwd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
+
#include "test.h"
#include "usctest.h"
-#include <pwd.h>
+#include "compat_16.h"
#define ROOT_USER 0
@@ -80,7 +82,7 @@
/* reset tst_count in case we are looping */
tst_count = 0;
- TEST(setuid(ROOT_USER));
+ TEST(SETUID(cleanup, ROOT_USER));
if (TEST_RETURN != -1) {
tst_resm(TFAIL, "call succeeded unexpectedly");
@@ -98,8 +100,6 @@
}
cleanup();
tst_exit();
- tst_exit();
-
}
/*
@@ -107,11 +107,14 @@
*/
void setup(void)
{
+ tst_require_root(NULL);
+
/* Switch to nobody user for correct error code collection */
- if (geteuid() != 0) {
- tst_brkm(TBROK, NULL, "Test must be run as root");
- }
ltpuser = getpwnam(nobody_uid);
+ if (ltpuser == NULL)
+ tst_brkm(TBROK, cleanup, "getpwnam failed for user id %s",
+ nobody_uid);
+
if (setuid(ltpuser->pw_uid) == -1) {
tst_resm(TINFO, "setuid failed to "
"to set the effective uid to %d", ltpuser->pw_uid);