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