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