]> err.no Git - util-linux/commitdiff
newgrp: check result from getgrnam() more carefully
authorKarel Zak <kzak@redhat.com>
Wed, 21 Mar 2007 16:29:20 +0000 (17:29 +0100)
committerKarel Zak <kzak@redhat.com>
Wed, 21 Mar 2007 16:29:20 +0000 (17:29 +0100)
Signed-off-by: Karel Zak <kzak@redhat.com>
login-utils/newgrp.c

index a46f9ee53f09ef3d295b51664e43c2698a6a18a5..13475f3e149aee7db59bfd1acecbc866f312d08b 100644 (file)
@@ -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)) {