aboutsummaryrefslogtreecommitdiff
path: root/coreutils/id.c
diff options
context:
space:
mode:
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 @@
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) {