summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTito Ragusa <farmatito@tiscali.it>2011-06-21 15:11:40 (GMT)
committer Denys Vlasenko <vda.linux@googlemail.com>2011-06-21 15:11:40 (GMT)
commit33092f1003982fc26339c0fda66283805cfbcfb1 (patch)
tree6d3bdffb6610734bb3f28b2f32b05e9d0310b340
parent561f9c8585e7cb0882472297f4fd2ed763dc085a (diff)
downloadbusybox-33092f1003982fc26339c0fda66283805cfbcfb1.tar.gz
busybox-33092f1003982fc26339c0fda66283805cfbcfb1.tar.bz2
groups: new applet
Signed-off-by: Tito Ragusa <farmatito@tiscali.it> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--coreutils/Config.src6
-rw-r--r--coreutils/Kbuild.src1
-rw-r--r--coreutils/id.c40
-rw-r--r--include/applets.src.h1
4 files changed, 36 insertions, 12 deletions
diff --git a/coreutils/Config.src b/coreutils/Config.src
index 1843e8b..9aa04e9 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 6a41c83..0681e44 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 aa6ae47..71acce4 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) {
diff --git a/include/applets.src.h b/include/applets.src.h
index 133f376..c6d99fe 100644
--- a/include/applets.src.h
+++ b/include/applets.src.h
@@ -180,7 +180,6 @@ IF_HOSTID(APPLET_NOFORK(hostid, hostid, BB_DIR_USR_BIN, BB_SUID_DROP, hostid))
IF_HOSTNAME(APPLET(hostname, BB_DIR_BIN, BB_SUID_DROP))
IF_HTTPD(APPLET(httpd, BB_DIR_USR_SBIN, BB_SUID_DROP))
IF_HWCLOCK(APPLET(hwclock, BB_DIR_SBIN, BB_SUID_DROP))
-IF_ID(APPLET_NOEXEC(id, id, BB_DIR_USR_BIN, BB_SUID_DROP, id))
IF_IFCONFIG(APPLET(ifconfig, BB_DIR_SBIN, BB_SUID_DROP))
IF_IFUPDOWN(APPLET_ODDNAME(ifdown, ifupdown, BB_DIR_SBIN, BB_SUID_DROP, ifdown))
IF_IFENSLAVE(APPLET(ifenslave, BB_DIR_SBIN, BB_SUID_DROP))