process: fix setuid() and setgid() error reporting

Zero errno before calling getgrnam_r() or getpwnam_r(). If errno had previously
been clobbered, node would report the wrong error.
This commit is contained in:
Ben Noordhuis 2012-09-17 07:17:11 +02:00
parent db5c26e3b5
commit 96ca59fbf3

View File

@ -1508,6 +1508,7 @@ static Handle<Value> SetGid(const Arguments& args) {
struct group grp, *grpp = NULL;
int err;
errno = 0;
if ((err = getgrnam_r(*grpnam, &grp, getbuf, ARRAY_SIZE(getbuf), &grpp)) ||
grpp == NULL) {
if (errno == 0)
@ -1548,6 +1549,7 @@ static Handle<Value> SetUid(const Arguments& args) {
struct passwd pwd, *pwdp = NULL;
int err;
errno = 0;
if ((err = getpwnam_r(*pwnam, &pwd, getbuf, ARRAY_SIZE(getbuf), &pwdp)) ||
pwdp == NULL) {
if (errno == 0)