When using bb id you see:
busybox id
uid=1000(walter) gid=100(users)
Coreutils id
uid=1000(walter) gid=100(users)
groups=6(disk),14(uucp),16(dialout),33(video),100(users)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
missing is the extended group list, and for SUSv3 the -G switch that handels it
The patch will add that feature.
The results of "id -G" and "id -Gn" are now compareable to gnu id.
re,
wh
--- id.c.org 2008-09-11 16:12:46.000000000 +0200
+++ id.c 2008-09-11 17:48:18.000000000 +0200
@@ -19,10 +19,70 @@
#define NAME_NOT_NUMBER 2
#define JUST_USER 4
#define JUST_GROUP 8
+#define JUST_ALL_GROUPS 16
#if ENABLE_SELINUX
-#define JUST_CONTEXT 16
+#define JUST_CONTEXT 32
#endif
+
+/*
+ mode=1 -G = numeric JUST_ALL_GROUPS
+ mode=2 -n = string NAME_NOT_NUMBER
+ mode=0 = normal numeric(string)
+
+*/
+
+static int printf_group_list(uid_t uid,int mode)
+{
+ struct passwd *pw = getpwuid(uid);
+ gid_t *groups = NULL;
+ int ng=0;
+ char sep=' ';
+ const char *fmt="%s";
+
+ if (pw == NULL)
+ return EXIT_FAILURE;
+
+
+ /* get ng = number of groups */
+ if ( getgrouplist(pw->pw_name, pw->pw_gid, NULL, &ng) >= 0)
+ return EXIT_FAILURE;
+
+ groups = (gid_t *) malloc(ng * sizeof (gid_t));
+ getgrouplist(pw->pw_name, pw->pw_gid, groups, &ng);
+
+ /* we more the line backwards to save the counter */
+ if (mode==0) {
+ printf(" groups=");
+ sep=','; /* but , separated */
+ fmt="(%s)"; /* and with () now */
+ }
+
+ while (ng)
+ {
+ if (mode==0 || mode==JUST_ALL_GROUPS)
+ printf("%d",groups[ng-1]);
+
+ if (mode==0 || mode== (NAME_NOT_NUMBER | JUST_ALL_GROUPS) )
+ printf(fmt, bb_getgrgid(NULL, 0,groups[ng-1]) );
+
+ ng--;
+
+ if (ng>0)
+ putchar(sep);
+ else
+ break;
+
+ }
+
+
+ return EXIT_SUCCESS;
+}
+
+
+
+
+
static int printf_full(unsigned int id, const char *arg, const char prefix)
{
const char *fmt = "%cid=%u";
@@ -43,14 +103,14 @@
uid_t uid;
gid_t gid;
unsigned long flags;
- short status;
+ short status=0;
#if ENABLE_SELINUX
security_context_t scontext;
#endif
/* Don't allow -n -r -nr -ug -rug -nug -rnug */
/* Don't allow more than one username */
- opt_complementary = "?1:u--g:g--u:r?ug:n?ug" USE_SELINUX(":u--Z:Z--u:g--Z:Z--g");
- flags = getopt32(argv, "rnug" USE_SELINUX("Z"));
+ opt_complementary = "?1:u--g:g--u:r?ug:n?ugG" USE_SELINUX(":u--Z:Z--u:g--Z:Z--g");
+ flags = getopt32(argv, "rnugG" USE_SELINUX("Z"));
/* This values could be overwritten later */
uid = geteuid();
@@ -101,9 +161,16 @@
/* Print full info like GNU id */
/* bb_getpwuid(0) doesn't exit on failure (returns NULL) */
- status = printf_full(uid, bb_getpwuid(NULL, 0, uid), 'u');
- bb_putchar(' ');
- status |= printf_full(gid, bb_getgrgid(NULL, 0, gid), 'g');
+
+ if ( !(flags & ( NAME_NOT_NUMBER|JUST_ALL_GROUPS)) )
+ {
+ status |= printf_full(uid, bb_getpwuid(NULL, 0, uid), 'u');
+ bb_putchar(' ');
+ status |= printf_full(gid, bb_getgrgid(NULL, 0, gid), 'g');
+ }
+
+ status |=printf_group_list(uid,flags & ( NAME_NOT_NUMBER|JUST_ALL_GROUPS) );
+
#if ENABLE_SELINUX
if (is_selinux_enabled()) {
_______________________________________________
busybox mailing list
[email protected]
http://busybox.net/cgi-bin/mailman/listinfo/busybox