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