Use an int to hold the result of fgetc (bug noted by David Kimdon).
[oweals/busybox.git] / coreutils / id.c
index 59cfafa0a6019ca1a84b2a4657c21922f3c3b70d..85b288c0c2dc53d1717c2c9615450eac1099c694 100644 (file)
@@ -23,9 +23,8 @@
 #include "busybox.h"
 #include <stdio.h>
 #include <unistd.h>
-#include <pwd.h>
-#include <grp.h>
 #include <getopt.h>
+#include <string.h>
 #include <sys/types.h>
 
 extern int id_main(int argc, char **argv)
@@ -54,11 +53,11 @@ extern int id_main(int argc, char **argv)
                                name_not_number++;
                                break;
                        default:
-                               usage(id_usage);
+                               show_usage();
                }
        }
 
-       if (no_user && no_group) usage(id_usage);
+       if (no_user && no_group) show_usage();
 
        if (argv[optind] == NULL) {
                if (print_real) {
@@ -77,18 +76,15 @@ extern int id_main(int argc, char **argv)
 
        pwnam=my_getpwnam(user);
        grnam=my_getgrnam(group);
-       if (gid == -1 || pwnam==-1 || grnam==-1) {
-               error_msg_and_die("%s: No such user\n", user);
-       }
 
        if (no_group) {
                if(name_not_number && user)
-                       printf("%s\n",user);
+                       puts(user);
                else
                        printf("%ld\n", pwnam);
        } else if (no_user) {
                if(name_not_number && group)
-                       printf("%s\n", group);
+                       puts(group);
                else
                        printf("%ld\n", grnam);
        } else {