aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--coreutils/whoami.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/coreutils/whoami.c b/coreutils/whoami.c
index e2a03b1e9..c979b0dd9 100644
--- a/coreutils/whoami.c
+++ b/coreutils/whoami.c
@@ -26,18 +26,20 @@
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"
29 31
30extern int whoami_main(int argc, char **argv) 32extern int whoami_main(int argc, char **argv)
31{ 33{
32 char user[9]; 34 struct passwd *p;
33 uid_t uid; 35 uid_t uid;
34 36
35 if (argc > 1) 37 if (argc > 1)
36 bb_show_usage(); 38 bb_show_usage();
37 39
38 uid = geteuid(); 40 uid = geteuid();
39 if (my_getpwuid(user, uid, sizeof(user))) { 41 if((p = getpwuid(uid))!=NULL) {
40 puts(user); 42 puts(p->pw_name);
41 bb_fflush_stdout_and_exit(EXIT_SUCCESS); 43 bb_fflush_stdout_and_exit(EXIT_SUCCESS);
42 } 44 }
43 bb_error_msg_and_die("cannot find username for UID %u", (unsigned) uid); 45 bb_error_msg_and_die("cannot find username for UID %u", (unsigned) uid);