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