1 #include <stdio.h>
2 #include <err.h>
3 #include <errno.h>
4 
5 #include <sys/secflags.h>
6 #include <sys/syscall.h>
7 
8 int
main(int argc,char ** argv)9 main(int argc, char **argv)
10 {
11 	int err = 0;
12 	secflagdelta_t act = {0};
13 
14 	if ((err = syscall(SYS_psecflags, NULL, PSF_INHERIT, NULL)) != 0) {
15 		if (errno != EFAULT)
16 			warnx("attempt to set secflags with a NULL procset "
17 			    "set errno other than EFAULT (%d)", errno);
18 	} else {
19 		warnx("attempt to set secflags with a NULL procset succeeded");
20 	}
21 
22 	if ((err = syscall(SYS_psecflags, (void*)0xdeadbeef,
23 	    PSF_INHERIT, NULL)) != 0) {
24 		if (errno != EFAULT)
25 			warnx("attempt to set secflags with a bad procset "
26 			    "set errno other than EFAULT (%d)", errno);
27 	} else {
28 		warnx("attempt to set secflags with a bad procset succeeded");
29 	}
30 
31 
32 	if ((err = psecflags(P_PID, P_MYID, PSF_INHERIT, NULL)) != 0) {
33 		if (errno != EFAULT)
34 			warnx("attempt to set secflags with a NULL "
35 			    "delta set errno to other than EFAULT (%d)",
36 			    errno);
37 	} else {
38 		warnx("attempt to set secflags with a NULL delta succeeded");
39 	}
40 
41 	if ((err = psecflags(P_PID, P_MYID, PSF_INHERIT,
42 	    (void*)0xdeadbeef)) != 0) {
43 		if (errno != EFAULT)
44 			warnx("attempt to set secflags with a bad "
45 			    "delta set errno to other than EFAULT (%d)",
46 			    errno);
47 	} else {
48 		warnx("attempt to set secflags with a bad delta succeeded");
49 	}
50 
51 	if ((err = psecflags(P_LWPID, P_MYID, PSF_INHERIT, &act)) != 0) {
52 		if (errno != EINVAL)
53 			warnx("attempt to set secflags of an lwpid set errno "
54 			    "to other than EINVAL (%d)", errno);
55 	} else {
56 		warnx("attempt to set secflags of an lwpid succeeded");
57 	}
58 
59 	if ((err = psecflags(P_LWPID, P_MYID, PSF_EFFECTIVE, &act)) != 0) {
60 		if (errno != EINVAL)
61 			warnx("attempt to set effective secflags set errno "
62 			    "to other than EINVAL (%d)", errno);
63 	} else {
64 		warnx("attempt to set effective secflags succeeded");
65 	}
66 
67 	return (0);
68 }
69