Turn off the printf attribute for the ?error_msg* functions, since it
[oweals/busybox.git] / whoami.c
index da584790d83e1e5c4ccc33263acf0084f5f50c3d..0bbb54b7b2abaf594d844e0ac7ff3043cf4fa339 100644 (file)
--- a/whoami.c
+++ b/whoami.c
  *
  */
 
-#include "internal.h"
 #include <stdio.h>
-#include <pwd.h>
-
-static const char whoami_usage[] = "whoami\n"
-#ifndef BB_FEATURE_TRIVIAL_HELP
-       "\nPrints the user name associated with the current effective user id.\n"
-#endif
-       ;
+#include <stdlib.h>
+#include <unistd.h>
+#include "busybox.h"
 
 extern int whoami_main(int argc, char **argv)
 {
-       char *user = xmalloc(9);
+       char user[9];
        uid_t uid = geteuid();
 
        if (argc > 1)
-               usage(whoami_usage);
+               show_usage();
 
        my_getpwuid(user, uid);
-       if (user) {
+       if (*user) {
                puts(user);
-               exit(TRUE);
+               return EXIT_SUCCESS;
        }
-       fprintf(stderr, "%s: cannot find username for UID %u\n", argv[0],
-                       (unsigned) uid);
-       exit(FALSE);
+       error_msg_and_die("cannot find username for UID %u", (unsigned) uid);
 }