summaryrefslogtreecommitdiffstats
path: root/login-utils/newgrp.c
diff options
context:
space:
mode:
authorKarel Zak2007-03-21 17:29:20 +0100
committerKarel Zak2007-03-21 17:29:20 +0100
commitac70067ae67d22b5c8305eac87acec5cdf8059e3 (patch)
tree687089b2748abf15935697e5f4dd1fcc6a6c75c8 /login-utils/newgrp.c
parenthwclock: make ggc happy and check return values from fgets, read and write (diff)
downloadkernel-qcow2-util-linux-ac70067ae67d22b5c8305eac87acec5cdf8059e3.tar.gz
kernel-qcow2-util-linux-ac70067ae67d22b5c8305eac87acec5cdf8059e3.tar.xz
kernel-qcow2-util-linux-ac70067ae67d22b5c8305eac87acec5cdf8059e3.zip
newgrp: check result from getgrnam() more carefully
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'login-utils/newgrp.c')
-rw-r--r--login-utils/newgrp.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/login-utils/newgrp.c b/login-utils/newgrp.c
index a46f9ee53..13475f3e1 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)) {