- add a colorful "valid HTML 4.01 Transitional" button to be able to check the refere...
[oweals/busybox.git] / coreutils / whoami.c
index c979b0dd991e4fcd31744293a43f4de8ff3d6695..71ef3537d036442619c3178b7349eb2a3cea9f12 100644 (file)
 #include <stdlib.h>
 #include <unistd.h>
 #include "busybox.h"
-#include "pwd_.h"
-#include "grp_.h"
 
-extern int whoami_main(int argc, char **argv)
+int whoami_main(int argc, char **argv)
 {
-       struct passwd *p;
-       uid_t uid;
-       
        if (argc > 1)
                bb_show_usage();
 
-       uid = geteuid();
-       if((p = getpwuid(uid))!=NULL) {
-               puts(p->pw_name);
-               bb_fflush_stdout_and_exit(EXIT_SUCCESS);
-       }
-       bb_error_msg_and_die("cannot find username for UID %u", (unsigned) uid);
+       puts(bb_getpwuid(NULL, geteuid(), -1));
+       /* exits on error */
+       bb_fflush_stdout_and_exit(EXIT_SUCCESS);
 }