aboutsummaryrefslogtreecommitdiff
path: root/coreutils
diff options
context:
space:
mode:
Diffstat (limited to 'coreutils')
-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 @@
#include <stdlib.h>
#include <unistd.h>
#include "busybox.h"
+#include "pwd_.h"
+#include "grp_.h"
extern int whoami_main(int argc, char **argv)
{
- char user[9];
+ struct passwd *p;
uid_t uid;
-
+
if (argc > 1)
bb_show_usage();
uid = geteuid();
- if (my_getpwuid(user, uid, sizeof(user))) {
- puts(user);
+ 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);