summaryrefslogtreecommitdiff
path: root/source/tests/trapdoor.c
blob: 83e10d061302c85005eff53a0b2f29e202cd9638 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
/* test for a trapdoor uid system */

#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>

main()
{
	if (getuid() != 0) {
		fprintf(stderr,"ERROR: This test must be run as root - assuming non-trapdoor system\n");
		exit(0);
	}

	if (seteuid(1) != 0) exit(1);
	if (geteuid() != 1) exit(1);
	if (seteuid(0) != 0) exit(1);
	if (geteuid() != 0) exit(1);

	if (setegid(1) != 0) exit(1);
	if (getegid() != 1) exit(1);
	if (setegid(0) != 0) exit(1);
	if (getegid() != 0) exit(1);

	exit(0);
}