diff options
Diffstat (limited to 'coreutils/whoami.c')
-rw-r--r-- | coreutils/whoami.c | 14 |
1 files changed, 3 insertions, 11 deletions
diff --git a/coreutils/whoami.c b/coreutils/whoami.c index c979b0dd9..6a6e2eec9 100644 --- a/coreutils/whoami.c +++ b/coreutils/whoami.c | |||
@@ -26,21 +26,13 @@ | |||
26 | #include <stdlib.h> | 26 | #include <stdlib.h> |
27 | #include <unistd.h> | 27 | #include <unistd.h> |
28 | #include "busybox.h" | 28 | #include "busybox.h" |
29 | #include "pwd_.h" | ||
30 | #include "grp_.h" | ||
31 | 29 | ||
32 | extern int whoami_main(int argc, char **argv) | 30 | extern int whoami_main(int argc, char **argv) |
33 | { | 31 | { |
34 | struct passwd *p; | ||
35 | uid_t uid; | ||
36 | |||
37 | if (argc > 1) | 32 | if (argc > 1) |
38 | bb_show_usage(); | 33 | bb_show_usage(); |
39 | 34 | ||
40 | uid = geteuid(); | 35 | puts(my_getpwuid(NULL, geteuid(), -1)); |
41 | if((p = getpwuid(uid))!=NULL) { | 36 | /* exits on error */ |
42 | puts(p->pw_name); | 37 | bb_fflush_stdout_and_exit(EXIT_SUCCESS); |
43 | bb_fflush_stdout_and_exit(EXIT_SUCCESS); | ||
44 | } | ||
45 | bb_error_msg_and_die("cannot find username for UID %u", (unsigned) uid); | ||
46 | } | 38 | } |