X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=whoami.c;h=c3b1140e6c940ddd40460eb7900cb5fcf90bf11d;hb=044228d5ecb9b79397f9fc915d046cf4538281e2;hp=983c6725d4617e35d548eb34d8ec9c4c10694cb8;hpb=e58771e73c0d8589a458ede4088f5ba70eff917b;p=oweals%2Fbusybox.git diff --git a/whoami.c b/whoami.c index 983c6725d..c3b1140e6 100644 --- a/whoami.c +++ b/whoami.c @@ -20,30 +20,25 @@ * */ -#include "internal.h" -#include -#include +/* getopt not needed */ -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 - ; +#include +#include +#include +#include "busybox.h" extern int whoami_main(int argc, char **argv) { - char *user = xmalloc(9); + char user[9]; uid_t uid = geteuid(); if (argc > 1) - usage(whoami_usage); + show_usage(); my_getpwuid(user, uid); - if (user) { + if (*user) { puts(user); - exit(TRUE); + return EXIT_SUCCESS; } - fprintf(stderr, "%s: cannot find username for UID %u\n", applet_name, - (unsigned) uid); - return(FALSE); + error_msg_and_die("cannot find username for UID %u", (unsigned) uid); }