aboutsummaryrefslogtreecommitdiff
path: root/coreutils/whoami.c
diff options
context:
space:
mode:
Diffstat (limited to 'coreutils/whoami.c')
-rw-r--r--coreutils/whoami.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/coreutils/whoami.c b/coreutils/whoami.c
index a9d6ecf26..f93034d3a 100644
--- a/coreutils/whoami.c
+++ b/coreutils/whoami.c
@@ -20,7 +20,7 @@
20 * 20 *
21 */ 21 */
22 22
23/* getopt not needed */ 23/* BB_AUDIT SUSv3 N/A -- Matches GNU behavior. */
24 24
25#include <stdio.h> 25#include <stdio.h>
26#include <stdlib.h> 26#include <stdlib.h>
@@ -30,14 +30,15 @@
30extern int whoami_main(int argc, char **argv) 30extern int whoami_main(int argc, char **argv)
31{ 31{
32 char user[9]; 32 char user[9];
33 uid_t uid = geteuid(); 33 uid_t uid;
34 34
35 if (argc > 1) 35 if (argc > 1)
36 show_usage(); 36 bb_show_usage();
37 37
38 uid = geteuid();
38 if (my_getpwuid(user, uid)) { 39 if (my_getpwuid(user, uid)) {
39 puts(user); 40 puts(user);
40 return EXIT_SUCCESS; 41 bb_fflush_stdout_and_exit(EXIT_SUCCESS);
41 } 42 }
42 error_msg_and_die("cannot find username for UID %u", (unsigned) uid); 43 bb_error_msg_and_die("cannot find username for UID %u", (unsigned) uid);
43} 44}