hush/coreutils/whoami.c
Denis Vlasenko 0c68a874e7 libbb: password/group function helpers rewritten by Tito:
function                                             old     new   delta
xgetpwuid                                              -      27     +27
uid2uname_utoa                                         -      22     +22
gid2group_utoa                                         -      22     +22
uid2uname                                              -      18     +18
gid2group                                              -      18     +18
buffer_fill_and_print                                179     196     +17
print_user                                            12      24     +12
print_group                                           12      24     +12
get_cached                                            89      99     +10
...
print_common                                         134     120     -14
vlock_main                                           415     396     -19
logger_main                                          410     387     -23
crontab_main                                         642     609     -33
bb_getpwuid                                           42       -     -42
bb_getgrgid                                           42       -     -42
bb_getug                                              80       -     -80
------------------------------------------------------------------------------
(add/remove: 6/3 grow/shrink: 9/11 up/down: 187/-296)        Total: -109 bytes
2008-12-02 22:56:59 +00:00

27 lines
599 B
C

/* vi: set sw=4 ts=4: */
/*
* Mini whoami implementation for busybox
*
* Copyright (C) 2000 Edward Betts <edward@debian.org>.
*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
/* BB_AUDIT SUSv3 N/A -- Matches GNU behavior. */
#include "libbb.h"
/* This is a NOFORK applet. Be very careful! */
int whoami_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int whoami_main(int argc, char **argv UNUSED_PARAM)
{
if (argc > 1)
bb_show_usage();
/* Will complain and die if username not found */
puts(xuid2uname(geteuid()));
return fflush(stdout);
}