diff options
Diffstat (limited to 'coreutils')
-rw-r--r-- | coreutils/Config.src | 6 | ||||
-rw-r--r-- | coreutils/Kbuild.src | 1 | ||||
-rw-r--r-- | coreutils/id.c | 40 |
3 files changed, 36 insertions, 11 deletions
diff --git a/coreutils/Config.src b/coreutils/Config.src index 1843e8b0e..9aa04e946 100644 --- a/coreutils/Config.src +++ b/coreutils/Config.src @@ -276,12 +276,6 @@ config HOSTID hostid prints the numeric identifier (in hexadecimal) for the current host. -config ID - bool "id" - default y - help - id displays the current user and group ID names. - config INSTALL bool "install" default y diff --git a/coreutils/Kbuild.src b/coreutils/Kbuild.src index 6a41c8318..0681e44b0 100644 --- a/coreutils/Kbuild.src +++ b/coreutils/Kbuild.src @@ -37,7 +37,6 @@ lib-$(CONFIG_FOLD) += fold.o lib-$(CONFIG_FSYNC) += fsync.o lib-$(CONFIG_HEAD) += head.o lib-$(CONFIG_HOSTID) += hostid.o -lib-$(CONFIG_ID) += id.o lib-$(CONFIG_INSTALL) += install.o #lib-$(CONFIG_LENGTH) += length.o lib-$(CONFIG_LN) += ln.o 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) { |