aboutsummaryrefslogtreecommitdiff
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
parent561f9c8585e7cb0882472297f4fd2ed763dc085a (diff)
downloadbusybox-w32-33092f1003982fc26339c0fda66283805cfbcfb1.tar.gz
busybox-w32-33092f1003982fc26339c0fda66283805cfbcfb1.tar.bz2
busybox-w32-33092f1003982fc26339c0fda66283805cfbcfb1.zip
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 1843e8b0e..9aa04e946 100644
--- a/coreutils/Config.src
+++ b/coreutils/Config.src
@@ -276,12 +276,6 @@ config HOSTID
276 hostid prints the numeric identifier (in hexadecimal) for 276 hostid prints the numeric identifier (in hexadecimal) for
277 the current host. 277 the current host.
278 278
279config ID
280 bool "id"
281 default y
282 help
283 id displays the current user and group ID names.
284
285config INSTALL 279config INSTALL
286 bool "install" 280 bool "install"
287 default y 281 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
37lib-$(CONFIG_FSYNC) += fsync.o 37lib-$(CONFIG_FSYNC) += fsync.o
38lib-$(CONFIG_HEAD) += head.o 38lib-$(CONFIG_HEAD) += head.o
39lib-$(CONFIG_HOSTID) += hostid.o 39lib-$(CONFIG_HOSTID) += hostid.o
40lib-$(CONFIG_ID) += id.o
41lib-$(CONFIG_INSTALL) += install.o 40lib-$(CONFIG_INSTALL) += install.o
42#lib-$(CONFIG_LENGTH) += length.o 41#lib-$(CONFIG_LENGTH) += length.o
43lib-$(CONFIG_LN) += ln.o 42lib-$(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 @@
15 * Added -G option Tito Ragusa (C) 2008 for SUSv3. 15 * Added -G option Tito Ragusa (C) 2008 for SUSv3.
16 */ 16 */
17 17
18//config:config ID
19//config: bool "id"
20//config: default y
21//config: help
22//config: id displays the current user and group ID names.
23
24//config:config GROUPS
25//config: bool "groups"
26//config: default y
27//config: help
28//config: Print the group names associated with current user id.
29
30//kbuild:lib-$(CONFIG_GROUPS) += id.o
31//kbuild:lib-$(CONFIG_ID) += id.o
32
33//applet:IF_GROUPS(APPLET_ODDNAME(groups, id, BB_DIR_USR_BIN, BB_SUID_DROP, groups))
34//applet:IF_ID(APPLET_NOEXEC(id, id, BB_DIR_USR_BIN, BB_SUID_DROP, id))
35
18//usage:#define id_trivial_usage 36//usage:#define id_trivial_usage
19//usage: "[OPTIONS] [USER]" 37//usage: "[OPTIONS] [USER]"
20//usage:#define id_full_usage "\n\n" 38//usage:#define id_full_usage "\n\n"
@@ -32,6 +50,15 @@
32//usage: "$ id\n" 50//usage: "$ id\n"
33//usage: "uid=1000(andersen) gid=1000(andersen)\n" 51//usage: "uid=1000(andersen) gid=1000(andersen)\n"
34 52
53//usage:#define groups_trivial_usage
54//usage: "[USER]"
55//usage:#define groups_full_usage "\n\n"
56//usage: "Print the group memberships of USER or for the current process"
57//usage:
58//usage:#define groups_example_usage
59//usage: "$ groups\n"
60//usage: "andersen lp dialout cdrom floppy\n"
61
35#include "libbb.h" 62#include "libbb.h"
36 63
37/* This is a NOEXEC applet. Be very careful! */ 64/* This is a NOEXEC applet. Be very careful! */
@@ -135,11 +162,16 @@ int id_main(int argc UNUSED_PARAM, char **argv)
135#if ENABLE_SELINUX 162#if ENABLE_SELINUX
136 security_context_t scontext = NULL; 163 security_context_t scontext = NULL;
137#endif 164#endif
138 /* Don't allow -n -r -nr -ug -rug -nug -rnug -uZ -gZ -GZ*/ 165
139 /* Don't allow more than one username */ 166 if (ENABLE_GROUPS && (!ENABLE_ID || applet_name[0] == 'g')) {
140 opt_complementary = "?1:u--g:g--u:G--u:u--G:g--G:G--g:r?ugG:n?ugG" 167 option_mask32 = opt = getopt32(argv, "") | JUST_ALL_GROUPS | NAME_NOT_NUMBER;
168 } else {
169 /* Don't allow -n -r -nr -ug -rug -nug -rnug -uZ -gZ -GZ*/
170 /* Don't allow more than one username */
171 opt_complementary = "?1:u--g:g--u:G--u:u--G:g--G:G--g:r?ugG:n?ugG"
141 IF_SELINUX(":u--Z:Z--u:g--Z:Z--g:G--Z:Z--G"); 172 IF_SELINUX(":u--Z:Z--u:g--Z:Z--g:G--Z:Z--G");
142 opt = getopt32(argv, "rnugG" IF_SELINUX("Z")); 173 opt = getopt32(argv, "rnugG" IF_SELINUX("Z"));
174 }
143 175
144 username = argv[optind]; 176 username = argv[optind];
145 if (username) { 177 if (username) {
diff --git a/include/applets.src.h b/include/applets.src.h
index 133f376a3..c6d99fe8c 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))
180IF_HOSTNAME(APPLET(hostname, BB_DIR_BIN, BB_SUID_DROP)) 180IF_HOSTNAME(APPLET(hostname, BB_DIR_BIN, BB_SUID_DROP))
181IF_HTTPD(APPLET(httpd, BB_DIR_USR_SBIN, BB_SUID_DROP)) 181IF_HTTPD(APPLET(httpd, BB_DIR_USR_SBIN, BB_SUID_DROP))
182IF_HWCLOCK(APPLET(hwclock, BB_DIR_SBIN, BB_SUID_DROP)) 182IF_HWCLOCK(APPLET(hwclock, BB_DIR_SBIN, BB_SUID_DROP))
183IF_ID(APPLET_NOEXEC(id, id, BB_DIR_USR_BIN, BB_SUID_DROP, id))
184IF_IFCONFIG(APPLET(ifconfig, BB_DIR_SBIN, BB_SUID_DROP)) 183IF_IFCONFIG(APPLET(ifconfig, BB_DIR_SBIN, BB_SUID_DROP))
185IF_IFUPDOWN(APPLET_ODDNAME(ifdown, ifupdown, BB_DIR_SBIN, BB_SUID_DROP, ifdown)) 184IF_IFUPDOWN(APPLET_ODDNAME(ifdown, ifupdown, BB_DIR_SBIN, BB_SUID_DROP, ifdown))
186IF_IFENSLAVE(APPLET(ifenslave, BB_DIR_SBIN, BB_SUID_DROP)) 185IF_IFENSLAVE(APPLET(ifenslave, BB_DIR_SBIN, BB_SUID_DROP))