From ac70067ae67d22b5c8305eac87acec5cdf8059e3 Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Wed, 21 Mar 2007 17:29:20 +0100 Subject: newgrp: check result from getgrnam() more carefully Signed-off-by: Karel Zak --- login-utils/newgrp.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'login-utils') diff --git a/login-utils/newgrp.c b/login-utils/newgrp.c index a46f9ee5..13475f3e 100644 --- a/login-utils/newgrp.c +++ b/login-utils/newgrp.c @@ -78,8 +78,12 @@ main(int argc, char *argv[]) exit(1); } } else { + errno = 0; if (!(gr_entry = getgrnam(argv[1]))) { - perror(_("newgrp: No such group.")); + if (errno) + perror(_("newgrp: No such group.")); /* error */ + else + fprintf(stderr, "%s\n", _("newgrp: No such group.")); /* no group */ exit(1); } else { if(allow_setgid(pw_entry, gr_entry)) { -- cgit v1.2.3