X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=whoami.c;h=950f52fb2e54feefe7aab388a63b14b901c9c6c3;hb=9b2297a34e35be143155769a470331af2f2b9330;hp=5c3fea13f673923311261599d725906772600b5a;hpb=e5b6c7dd9cb32852a7f5b19a9855cf3c32543396;p=oweals%2Fbusybox.git diff --git a/whoami.c b/whoami.c index 5c3fea13f..950f52fb2 100644 --- a/whoami.c +++ b/whoami.c @@ -24,24 +24,26 @@ #include #include -static const char whoami_usage[] = "whoami\n\n" - "Prints the user name associated with the current effective user id.\n"; +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 + ; extern int whoami_main(int argc, char **argv) { - struct passwd *pw; - uid_t uid; + char *user = xmalloc(9); + uid_t uid = geteuid(); if (argc > 1) usage(whoami_usage); - uid = geteuid(); - pw = getpwuid(uid); - if (pw) { - puts(pw->pw_name); + my_getpwuid(user, uid); + if (user) { + puts(user); exit(TRUE); } fprintf(stderr, "%s: cannot find username for UID %u\n", argv[0], (unsigned) uid); - exit(FALSE); + return(FALSE); }