mirror of
https://github.com/tiagovignatti/intel-gpu-tools.git
synced 2025-06-18 21:36:27 +00:00
lib: extract igt_drop_root
Useful in other tests. Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
This commit is contained in:
parent
70082e3677
commit
862de5636f
@ -1659,3 +1659,14 @@ void igt_system_suspend_autoresume(void)
|
|||||||
ret = system("rtcwake -s 30 -m mem");
|
ret = system("rtcwake -s 30 -m mem");
|
||||||
igt_assert(ret == 0);
|
igt_assert(ret == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void igt_drop_root(void)
|
||||||
|
{
|
||||||
|
igt_assert(getuid() == 0);
|
||||||
|
|
||||||
|
igt_assert(setgid(2) == 0);
|
||||||
|
igt_assert(setuid(2) == 0);
|
||||||
|
|
||||||
|
igt_assert(getgid() == 2);
|
||||||
|
igt_assert(getuid() == 2);
|
||||||
|
}
|
||||||
|
@ -357,4 +357,7 @@ void igt_enable_prefault(void);
|
|||||||
/* suspend and auto-resume system */
|
/* suspend and auto-resume system */
|
||||||
void igt_system_suspend_autoresume(void);
|
void igt_system_suspend_autoresume(void);
|
||||||
|
|
||||||
|
/* dropping priviledges */
|
||||||
|
void igt_drop_root(void);
|
||||||
|
|
||||||
#endif /* DRMTEST_H */
|
#endif /* DRMTEST_H */
|
||||||
|
@ -874,17 +874,6 @@ static void test_close_pending_fork(const bool reverse)
|
|||||||
close(fd);
|
close(fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void drop_root(void)
|
|
||||||
{
|
|
||||||
igt_assert(getuid() == 0);
|
|
||||||
|
|
||||||
igt_assert(setgid(2) == 0);
|
|
||||||
igt_assert(setuid(2) == 0);
|
|
||||||
|
|
||||||
igt_assert(getgid() == 2);
|
|
||||||
igt_assert(getuid() == 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void test_reset_count(const bool create_ctx)
|
static void test_reset_count(const bool create_ctx)
|
||||||
{
|
{
|
||||||
int fd, h, ctx;
|
int fd, h, ctx;
|
||||||
@ -912,7 +901,7 @@ static void test_reset_count(const bool create_ctx)
|
|||||||
igt_assert(c2 == (c1 + 1));
|
igt_assert(c2 == (c1 + 1));
|
||||||
|
|
||||||
igt_fork(child, 1) {
|
igt_fork(child, 1) {
|
||||||
drop_root();
|
igt_drop_root();
|
||||||
|
|
||||||
c2 = get_reset_count(fd, ctx);
|
c2 = get_reset_count(fd, ctx);
|
||||||
|
|
||||||
@ -988,7 +977,7 @@ static void _test_param(const int fd, const int ctx)
|
|||||||
igt_fork(child, 1) {
|
igt_fork(child, 1) {
|
||||||
check_params(fd, ctx, root);
|
check_params(fd, ctx, root);
|
||||||
|
|
||||||
drop_root();
|
igt_drop_root();
|
||||||
|
|
||||||
check_params(fd, ctx, user);
|
check_params(fd, ctx, user);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user