groups: new applet

Signed-off-by: Tito Ragusa <farmatito@tiscali.it>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
Tito Ragusa 2011-06-21 17:11:40 +02:00 committed by Denys Vlasenko
parent 561f9c8585
commit 33092f1003
4 changed files with 36 additions and 12 deletions

View File

@ -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

View File

@ -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

View File

@ -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
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"));
}
username = argv[optind];
if (username) {

View File

@ -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))