Browse Source

Add helpful error message for setuid/setgid when user/group id does not exist

v0.7.4-release
Brian White 14 years ago
committed by Ryan Dahl
parent
commit
52b9ede6db
  1. 8
      src/node.cc

8
src/node.cc

@ -1420,6 +1420,10 @@ static Handle<Value> SetGid(const Arguments& args) {
if ((err = getgrnam_r(*grpnam, &grp, getbuf, ARRAY_SIZE(getbuf), &grpp)) ||
grpp == NULL) {
if (errno == 0)
return ThrowException(Exception::Error(
String::New("setgid group id does not exist")));
else
return ThrowException(ErrnoException(errno, "getgrnam_r"));
}
@ -1455,6 +1459,10 @@ static Handle<Value> SetUid(const Arguments& args) {
if ((err = getpwnam_r(*pwnam, &pwd, getbuf, ARRAY_SIZE(getbuf), &pwdp)) ||
pwdp == NULL) {
if (errno == 0)
return ThrowException(Exception::Error(
String::New("setuid user id does not exist")));
else
return ThrowException(ErrnoException(errno, "getpwnam_r"));
}

Loading…
Cancel
Save