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