X-Git-Url: http://nsz.repo.hu/git/?p=musl;a=blobdiff_plain;f=src%2Funistd%2Fsetxid.c;h=2f651a110eb64f15f68c34a0be464466d2fa11c1;hp=d3bfaf6269bb6e65c8f1f2333a0ee47d0b4b31f0;hb=544ee752cd38febfa3aa3798b4dfb6fabd13846b;hpb=afade2356ea148e715307be8f7334b790282341e diff --git a/src/unistd/setxid.c b/src/unistd/setxid.c index d3bfaf62..2f651a11 100644 --- a/src/unistd/setxid.c +++ b/src/unistd/setxid.c @@ -11,6 +11,8 @@ struct ctx { /* We jump through hoops to eliminate the possibility of partial failures. */ +int __setrlimit(int, const struct rlimit *); + static void do_setxid(void *p) { struct ctx *c = p; @@ -18,17 +20,13 @@ static void do_setxid(void *p) if (c->rlim && c->id >= 0 && c->id != getuid()) { struct rlimit inf = { RLIM_INFINITY, RLIM_INFINITY }, old; getrlimit(RLIMIT_NPROC, &old); - if (setrlimit(RLIMIT_NPROC, &inf) && libc.threads_minus_1) { - c->err = errno; + if ((c->err = -__setrlimit(RLIMIT_NPROC, &inf)) && libc.threads_minus_1) return; - } - if (__syscall(c->nr, c->id, c->eid, c->sid)) - c->err = errno; - setrlimit(RLIMIT_NPROC, &old); + c->err = -__syscall(c->nr, c->id, c->eid, c->sid); + __setrlimit(RLIMIT_NPROC, &old); return; } - if (__syscall(c->nr, c->id, c->eid, c->sid)) - c->err = errno; + c->err = -__syscall(c->nr, c->id, c->eid, c->sid); } int __setxid(int nr, int id, int eid, int sid)