X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=coreutils%2Fwhoami.c;h=71ef3537d036442619c3178b7349eb2a3cea9f12;hb=8326d5e31ba322b692b729ac08b4bf27f0aa18e2;hp=44fbc950bc9a38b0a2ece33ec488e523c8fd93e5;hpb=e8c55f42c12e45c7a2d72586a3738004ab94021c;p=oweals%2Fbusybox.git diff --git a/coreutils/whoami.c b/coreutils/whoami.c index 44fbc950b..71ef3537d 100644 --- a/coreutils/whoami.c +++ b/coreutils/whoami.c @@ -20,22 +20,19 @@ * */ -#include "busybox.h" +/* BB_AUDIT SUSv3 N/A -- Matches GNU behavior. */ + #include -#include +#include +#include +#include "busybox.h" -extern int whoami_main(int argc, char **argv) +int whoami_main(int argc, char **argv) { - char *user = xmalloc(9); - uid_t uid = geteuid(); - if (argc > 1) - usage(whoami_usage); + bb_show_usage(); - my_getpwuid(user, uid); - if (user) { - puts(user); - return EXIT_SUCCESS; - } - fatalError("cannot find username for UID %u\n", (unsigned) uid); + puts(bb_getpwuid(NULL, geteuid(), -1)); + /* exits on error */ + bb_fflush_stdout_and_exit(EXIT_SUCCESS); }