From 52b9ede6dbc8968ac4cd334f799ef15c27fe7c9f Mon Sep 17 00:00:00 2001 From: Brian White Date: Fri, 18 Mar 2011 01:39:39 -0400 Subject: [PATCH] Add helpful error message for setuid/setgid when user/group id does not exist --- src/node.cc | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/node.cc b/src/node.cc index 7dae9db2d9..a44e8b9911 100644 --- a/src/node.cc +++ b/src/node.cc @@ -1420,7 +1420,11 @@ static Handle SetGid(const Arguments& args) { if ((err = getgrnam_r(*grpnam, &grp, getbuf, ARRAY_SIZE(getbuf), &grpp)) || grpp == NULL) { - return ThrowException(ErrnoException(errno, "getgrnam_r")); + if (errno == 0) + return ThrowException(Exception::Error( + String::New("setgid group id does not exist"))); + else + return ThrowException(ErrnoException(errno, "getgrnam_r")); } gid = grpp->gr_gid; @@ -1455,7 +1459,11 @@ static Handle SetUid(const Arguments& args) { if ((err = getpwnam_r(*pwnam, &pwd, getbuf, ARRAY_SIZE(getbuf), &pwdp)) || pwdp == NULL) { - return ThrowException(ErrnoException(errno, "getpwnam_r")); + if (errno == 0) + return ThrowException(Exception::Error( + String::New("setuid user id does not exist"))); + else + return ThrowException(ErrnoException(errno, "getpwnam_r")); } uid = pwdp->pw_uid;