2000-02-09 03:58:47 +08:00
|
|
|
/* vi: set sw=4 ts=4: */
|
2000-01-16 06:28:50 +08:00
|
|
|
/*
|
|
|
|
* Mini whoami implementation for busybox
|
|
|
|
*
|
|
|
|
* Copyright (C) 2000 Edward Betts <edward@debian.org>.
|
|
|
|
*
|
2010-08-17 02:14:46 +08:00
|
|
|
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
|
2000-01-16 06:28:50 +08:00
|
|
|
*/
|
2016-11-23 21:46:56 +08:00
|
|
|
//config:config WHOAMI
|
2023-07-10 23:25:21 +08:00
|
|
|
//config: bool "whoami (3.5 kb)"
|
2016-11-23 21:46:56 +08:00
|
|
|
//config: default y
|
|
|
|
//config: help
|
2017-07-21 15:50:55 +08:00
|
|
|
//config: whoami is used to print the username of the current
|
|
|
|
//config: user id (same as id -un).
|
2016-11-23 21:46:56 +08:00
|
|
|
|
|
|
|
//applet:IF_WHOAMI(APPLET_NOFORK(whoami, whoami, BB_DIR_USR_BIN, BB_SUID_DROP, whoami))
|
|
|
|
|
|
|
|
//kbuild:lib-$(CONFIG_WHOAMI) += whoami.o
|
2000-01-16 06:28:50 +08:00
|
|
|
|
2003-03-19 17:13:01 +08:00
|
|
|
/* BB_AUDIT SUSv3 N/A -- Matches GNU behavior. */
|
2001-03-10 05:28:09 +08:00
|
|
|
|
2011-03-31 20:43:25 +08:00
|
|
|
//usage:#define whoami_trivial_usage
|
|
|
|
//usage: ""
|
|
|
|
//usage:#define whoami_full_usage "\n\n"
|
|
|
|
//usage: "Print the user name associated with the current effective user id"
|
|
|
|
|
2007-05-27 03:00:18 +08:00
|
|
|
#include "libbb.h"
|
2000-01-16 06:28:50 +08:00
|
|
|
|
2007-10-11 18:05:36 +08:00
|
|
|
int whoami_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
2010-01-04 21:15:38 +08:00
|
|
|
int whoami_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
|
2000-02-09 03:58:47 +08:00
|
|
|
{
|
2010-01-04 21:15:38 +08:00
|
|
|
if (argv[1])
|
2003-03-19 17:13:01 +08:00
|
|
|
bb_show_usage();
|
2000-01-16 06:28:50 +08:00
|
|
|
|
2007-07-27 19:20:10 +08:00
|
|
|
/* Will complain and die if username not found */
|
2008-12-03 06:56:59 +08:00
|
|
|
puts(xuid2uname(geteuid()));
|
2007-04-10 23:43:37 +08:00
|
|
|
|
2009-11-02 21:19:51 +08:00
|
|
|
return fflush_all();
|
2000-01-16 06:28:50 +08:00
|
|
|
}
|