xref: /xnu-10002.81.5/tests/sysctl_system_version.c (revision 5e3eaea39dcf651e66cb99ba7d70e32cc4a99587)
1*5e3eaea3SApple OSS Distributions #include <darwintest.h>
2*5e3eaea3SApple OSS Distributions #include <sys/sysctl.h>
3*5e3eaea3SApple OSS Distributions 
4*5e3eaea3SApple OSS Distributions T_DECL(sysctl_osreleasetype_nowrite,
5*5e3eaea3SApple OSS Distributions     "ensure the osreleasetype sysctl is not writeable by normal processes")
6*5e3eaea3SApple OSS Distributions {
7*5e3eaea3SApple OSS Distributions 	char nice_try[32] = "FactoryToAvoidSandbox!";
8*5e3eaea3SApple OSS Distributions 	int ret = sysctlbyname("kern.osreleasetype", NULL, NULL, nice_try,
9*5e3eaea3SApple OSS Distributions 	    sizeof(nice_try));
10*5e3eaea3SApple OSS Distributions 	T_ASSERT_POSIX_FAILURE(ret, EPERM, "try to set kern.osreleasetype sysctl");
11*5e3eaea3SApple OSS Distributions }
12*5e3eaea3SApple OSS Distributions 
13*5e3eaea3SApple OSS Distributions T_DECL(sysctl_osreleasetype_exists, "ensure the osreleasetype sysctl exists")
14*5e3eaea3SApple OSS Distributions {
15*5e3eaea3SApple OSS Distributions 	char release_type[64] = "";
16*5e3eaea3SApple OSS Distributions 	size_t release_type_size = sizeof(release_type);
17*5e3eaea3SApple OSS Distributions 	int ret = sysctlbyname("kern.osreleasetype", release_type,
18*5e3eaea3SApple OSS Distributions 	    &release_type_size, NULL, 0);
19*5e3eaea3SApple OSS Distributions 	T_ASSERT_POSIX_SUCCESS(ret, "kern.osreleasetype sysctl");
20*5e3eaea3SApple OSS Distributions 	T_LOG("kern.osreleasetype = %s", release_type);
21*5e3eaea3SApple OSS Distributions }
22