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:
parent
db5c26e3b5
commit
96ca59fbf3
@ -1508,6 +1508,7 @@ static Handle<Value> SetGid(const Arguments& args) {
|
|||||||
struct group grp, *grpp = NULL;
|
struct group grp, *grpp = NULL;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
|
errno = 0;
|
||||||
if ((err = getgrnam_r(*grpnam, &grp, getbuf, ARRAY_SIZE(getbuf), &grpp)) ||
|
if ((err = getgrnam_r(*grpnam, &grp, getbuf, ARRAY_SIZE(getbuf), &grpp)) ||
|
||||||
grpp == NULL) {
|
grpp == NULL) {
|
||||||
if (errno == 0)
|
if (errno == 0)
|
||||||
@ -1548,6 +1549,7 @@ static Handle<Value> SetUid(const Arguments& args) {
|
|||||||
struct passwd pwd, *pwdp = NULL;
|
struct passwd pwd, *pwdp = NULL;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
|
errno = 0;
|
||||||
if ((err = getpwnam_r(*pwnam, &pwd, getbuf, ARRAY_SIZE(getbuf), &pwdp)) ||
|
if ((err = getpwnam_r(*pwnam, &pwd, getbuf, ARRAY_SIZE(getbuf), &pwdp)) ||
|
||||||
pwdp == NULL) {
|
pwdp == NULL) {
|
||||||
if (errno == 0)
|
if (errno == 0)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user