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