Skip to content

Commit 43884a0

Browse files
committed
syscalls/unshare02: Fix failures on Debian
The order of checks in kernel is not defined and on Debian we end up getting eperm even before the flags are checked which fails the invalid flags testcase. The fix is simple, we change the test to setuid() only for the EPERM test. Signed-off-by: Cyril Hrubis <[email protected]> Reviewed-by: Petr Vorel <[email protected]> Tested-by: Petr Vorel <[email protected]>
1 parent 06ec928 commit 43884a0

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

testcases/kernel/syscalls/unshare/unshare02.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030

3131
#ifdef HAVE_UNSHARE
3232

33+
static uid_t nobody_uid;
34+
3335
static struct test_case_t {
3436
int mode;
3537
int expected_error;
@@ -42,28 +44,26 @@ static struct test_case_t {
4244
static void run(unsigned int i)
4345
{
4446
pid_t pid = SAFE_FORK();
45-
if (pid == 0)
47+
if (pid == 0) {
48+
if (tc[i].expected_error == EPERM)
49+
SAFE_SETUID(nobody_uid);
50+
4651
TST_EXP_FAIL(unshare(tc[i].mode), tc[i].expected_error,
4752
"unshare(%s)", tc[i].desc);
53+
}
4854
}
4955

5056
static void setup(void)
5157
{
5258
struct passwd *ltpuser = SAFE_GETPWNAM("nobody");
53-
SAFE_SETEUID(ltpuser->pw_uid);
54-
}
55-
56-
static void cleanup(void)
57-
{
58-
SAFE_SETEUID(0);
59+
nobody_uid = ltpuser->pw_uid;
5960
}
6061

6162
static struct tst_test test = {
6263
.tcnt = ARRAY_SIZE(tc),
6364
.forks_child = 1,
6465
.needs_tmpdir = 1,
6566
.needs_root = 1,
66-
.cleanup = cleanup,
6767
.setup = setup,
6868
.test = run,
6969
};

0 commit comments

Comments
 (0)