aboutsummaryrefslogtreecommitdiff
path: root/coreutils/id.c
diff options
context:
space:
mode:
authorTito Ragusa <farmatito@tiscali.it>2011-06-21 17:11:40 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2011-06-21 17:11:40 +0200
commit33092f1003982fc26339c0fda66283805cfbcfb1 (patch)
tree6d3bdffb6610734bb3f28b2f32b05e9d0310b340 /coreutils/id.c
parent561f9c8585e7cb0882472297f4fd2ed763dc085a (diff)
downloadbusybox-33092f1003982fc26339c0fda66283805cfbcfb1.tar.gz
groups: new applet
Signed-off-by: Tito Ragusa <farmatito@tiscali.it> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'coreutils/id.c')
-rw-r--r--coreutils/id.c40
1 files changed, 36 insertions, 4 deletions
diff --git a/coreutils/id.c b/coreutils/id.c
index aa6ae4711..71acce4a2 100644
--- a/coreutils/id.c
+++ b/coreutils/id.c
@@ -15,6 +15,24 @@
* Added -G option Tito Ragusa (C) 2008 for SUSv3.
*/
+//config:config ID
+//config: bool "id"
+//config: default y
+//config: help
+//config: id displays the current user and group ID names.
+
+//config:config GROUPS
+//config: bool "groups"
+//config: default y
+//config: help
+//config: Print the group names associated with current user id.
+
+//kbuild:lib-$(CONFIG_GROUPS) += id.o
+//kbuild:lib-$(CONFIG_ID) += id.o
+
+//applet:IF_GROUPS(APPLET_ODDNAME(groups, id, BB_DIR_USR_BIN, BB_SUID_DROP, groups))
+//applet:IF_ID(APPLET_NOEXEC(id, id, BB_DIR_USR_BIN, BB_SUID_DROP, id))
+
//usage:#define id_trivial_usage
//usage: "[OPTIONS] [USER]"
//usage:#define id_full_usage "\n\n"
@@ -32,6 +50,15 @@
//usage: "$ id\n"
//usage: "uid=1000(andersen) gid=1000(andersen)\n"
+//usage:#define groups_trivial_usage
+//usage: "[USER]"
+//usage:#define groups_full_usage "\n\n"
+//usage: "Print the group memberships of USER or for the current process"
+//usage:
+//usage:#define groups_example_usage
+//usage: "$ groups\n"
+//usage: "andersen lp dialout cdrom floppy\n"
+
#include "libbb.h"
/* This is a NOEXEC applet. Be very careful! */
@@ -135,11 +162,16 @@ int id_main(int argc UNUSED_PARAM, char **argv)
#if ENABLE_SELINUX
security_context_t scontext = NULL;
#endif
- /* Don't allow -n -r -nr -ug -rug -nug -rnug -uZ -gZ -GZ*/
- /* Don't allow more than one username */
- opt_complementary = "?1:u--g:g--u:G--u:u--G:g--G:G--g:r?ugG:n?ugG"
+
+ if (ENABLE_GROUPS && (!ENABLE_ID || applet_name[0] == 'g')) {
+ option_mask32 = opt = getopt32(argv, "") | JUST_ALL_GROUPS | NAME_NOT_NUMBER;
+ } else {
+ /* Don't allow -n -r -nr -ug -rug -nug -rnug -uZ -gZ -GZ*/
+ /* Don't allow more than one username */
+ opt_complementary = "?1:u--g:g--u:G--u:u--G:g--G:G--g:r?ugG:n?ugG"
IF_SELINUX(":u--Z:Z--u:g--Z:Z--g:G--Z:Z--G");
- opt = getopt32(argv, "rnugG" IF_SELINUX("Z"));
+ opt = getopt32(argv, "rnugG" IF_SELINUX("Z"));
+ }
username = argv[optind];
if (username) {