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