summaryrefslogtreecommitdiff
path: root/usr/src/test/os-tests/tests/secflags/secflags_syscall.c
blob: eea8f48648950f42dcad8a53d205077eb0f7a9c4 (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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#include <stdio.h>
#include <err.h>
#include <errno.h>

#include <sys/secflags.h>
#include <sys/syscall.h>

int
main(int argc, char **argv)
{
	int err = 0;
	secflagdelta_t act = {0};

	if ((err = syscall(SYS_psecflags, NULL, PSF_INHERIT, NULL)) != 0) {
		if (errno != EFAULT)
			warnx("attempt to set secflags with a NULL procset "
			    "set errno other than EFAULT (%d)", errno);
	} else {
		warnx("attempt to set secflags with a NULL procset succeeded");
	}

	if ((err = syscall(SYS_psecflags, (void*)0xdeadbeef,
	    PSF_INHERIT, NULL)) != 0) {
		if (errno != EFAULT)
			warnx("attempt to set secflags with a bad procset "
			    "set errno other than EFAULT (%d)", errno);
	} else {
		warnx("attempt to set secflags with a bad procset succeeded");
	}


	if ((err = psecflags(P_PID, P_MYID, PSF_INHERIT, NULL)) != 0) {
		if (errno != EFAULT)
			warnx("attempt to set secflags with a NULL "
			    "delta set errno to other than EFAULT (%d)",
			    errno);
	} else {
		warnx("attempt to set secflags with a NULL delta succeeded");
	}

	if ((err = psecflags(P_PID, P_MYID, PSF_INHERIT,
	    (void*)0xdeadbeef)) != 0) {
		if (errno != EFAULT)
			warnx("attempt to set secflags with a bad "
			    "delta set errno to other than EFAULT (%d)",
			    errno);
	} else {
		warnx("attempt to set secflags with a bad delta succeeded");
	}

	if ((err = psecflags(P_LWPID, P_MYID, PSF_INHERIT, &act)) != 0) {
		if (errno != EINVAL)
			warnx("attempt to set secflags of an lwpid set errno "
			    "to other than EINVAL (%d)", errno);
	} else {
		warnx("attempt to set secflags of an lwpid succeeded");
	}

	if ((err = psecflags(P_LWPID, P_MYID, PSF_EFFECTIVE, &act)) != 0) {
		if (errno != EINVAL)
			warnx("attempt to set effective secflags set errno "
			    "to other than EINVAL (%d)", errno);
	} else {
		warnx("attempt to set effective secflags succeeded");
	}

	return (0);
}