1*27b03b36SApple OSS Distributions #include <darwintest.h> 2*27b03b36SApple OSS Distributions #include <dispatch/dispatch.h> 3*27b03b36SApple OSS Distributions #include <sys/unistd.h> 4*27b03b36SApple OSS Distributions 5*27b03b36SApple OSS Distributions T_GLOBAL_META(T_META_NAMESPACE("xnu.rm"), 6*27b03b36SApple OSS Distributions T_META_RADAR_COMPONENT_NAME("xnu"), 7*27b03b36SApple OSS Distributions T_META_RADAR_COMPONENT_VERSION("rm"), 8*27b03b36SApple OSS Distributions T_META_OWNER("phabouzit") 9*27b03b36SApple OSS Distributions ); 10*27b03b36SApple OSS Distributions 11*27b03b36SApple OSS Distributions T_DECL(pthread_setugid_np_81523076, 12*27b03b36SApple OSS Distributions "Make sure pthread_setugid_np() isn't sticky to workqueue threads", 13*27b03b36SApple OSS Distributions T_META_CHECK_LEAKS(false), 14*27b03b36SApple OSS Distributions T_META_ASROOT(true)) 15*27b03b36SApple OSS Distributions { 16*27b03b36SApple OSS Distributions int rc; 17*27b03b36SApple OSS Distributions 18*27b03b36SApple OSS Distributions rc = pthread_setugid_np(501, getgid()); 19*27b03b36SApple OSS Distributions T_ASSERT_POSIX_SUCCESS(rc, "pthread_setugid_np(501, getgid())"); 20*27b03b36SApple OSS Distributions 21*27b03b36SApple OSS Distributions dispatch_async(dispatch_get_global_queue(0, 0), ^{ 22*27b03b36SApple OSS Distributions T_ASSERT_EQ(getuid(), 0, "getuid should still be 0"); 23*27b03b36SApple OSS Distributions T_END; 24*27b03b36SApple OSS Distributions }); 25*27b03b36SApple OSS Distributions pause(); 26*27b03b36SApple OSS Distributions } 27