3 #include <sys/resource.h>
12 /* We jump through hoops to eliminate the possibility of partial failures. */
14 static void do_setxid(void *p)
18 if (c->rlim && c->id >= 0 && c->id != getuid()) {
19 struct rlimit inf = { RLIM_INFINITY, RLIM_INFINITY }, old;
20 getrlimit(RLIMIT_NPROC, &old);
21 if (setrlimit(RLIMIT_NPROC, &inf) && libc.threads_minus_1) {
25 if (__syscall(c->nr, c->id, c->eid, c->sid))
27 setrlimit(RLIMIT_NPROC, &old);
30 if (__syscall(c->nr, c->id, c->eid, c->sid))
34 int __setxid(int nr, int id, int eid, int sid)
36 struct ctx c = { .nr = nr, .id = id, .eid = eid, .sid = sid };
43 __synccall(do_setxid, &c);