Bug 3361 - id -n -g returns 1 on groups with more then 14 members
Summary: id -n -g returns 1 on groups with more then 14 members
Status: RESOLVED FIXED
Alias: None
Product: Busybox
Classification: Unclassified
Component: Other (show other bugs)
Version: 1.18.x
Hardware: PC Linux
: P5 minor
Target Milestone: ---
Assignee: unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-03-02 15:57 UTC by falk
Modified: 2011-09-11 17:39 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:


Attachments
[PATCH] implement groups applet (2.99 KB, patch)
2011-06-18 16:16 UTC, Tanguy Pruvot
Details

Note You need to log in before you can comment on or make changes to this bug.
Description falk 2011-03-02 15:57:43 UTC
Invoking "id -n -g some_user" shows the correct gid, but return 1 on exit, when the users group has more than 14 members on BusyBox v1.15.3

On BusyBox v1.4.2 and on BusyBox v1.12.3 it displays the error: "id: unknown gid some_number"

Without the "-n" it works fine. Also "-n -u" works fine. GNU-id worked correct on my tested setups.
Comment 1 Michael Tokarev 2011-03-10 21:52:38 UTC
I can't reproduce this with 0.18.

 $ grep mjt /etc/group | wc -l
 24
 $ busybox id -n -g mjt
 mjt
 $ echo $?
 0
 $_

This is with either built-in (in-bb) pwd&grp or using the one from glibc (ie, with or without CONFIG_USE_BB_PWD_GRP).
Comment 2 Michael Tokarev 2011-03-10 21:58:02 UTC
Um, that was wrong comment.  If a group has >14 members, not if a user is in >14 groups.

But still no go.

 $ grep ^buh: /etc/group | tr , \  | wc -w
 18
 $ busybox id -n -g buh-owner; echo $?
 buh
 0
 $ _

Again, with and without CONFIG_USE_BB_PWD_GRP - the same effect.
Comment 3 falk 2011-03-11 08:36:56 UTC
I testet on a OpenWRT  backfire and a OpenSUSE 11.3. Below is the behavior of openwrt-system. 

With 18 users in a group:

root@devel:~# cat /etc/group
root:x:0:
nogroup:x:65534:
admin:x:100:eurogard
user:x:101:hildgund,klomann,klofrau,milchmann,milchfrau,eiermann,eierfrau,postmann,postfrau,weihnachtsmann,weihnachtsfrau,hasenmann,hasenfrau,muellmann,muellfrau,mechthild,bechterew,miesepeter
root@devel:~# busybox id -n -g milchmann; echo $? 
101
1

Again with 12 user in the same group:

root@devel:~# cat /etc/group
root:x:0:
nogroup:x:65534:
admin:x:100:eurogard
user:x:101:hildgund,klomann,klofrau,milchmann,milchfrau,eiermann,eierfrau,postmann,postfrau,weihnachtsmann,weihnachtsfrau,hasenmann
root@devel:~# busybox id -n -g milchmann; echo $?
user
0
root@devel:~#

You can also see, that the -n option took no effect.

Thanks for reading
Comment 4 Denys Vlasenko 2011-05-09 11:32:11 UTC
Was closed by mistake
Comment 5 Tanguy Pruvot 2011-06-06 00:15:34 UTC
debian/ubuntu has the "groups" binary (/usr/bin/groups)

maybe this applet should exists in busybox too...

groups equals 

busybox id -G -n


# groups --help
Usage: groups [OPTION]... [USERNAME]...
Print group memberships for each USERNAME or, if no USERNAME is specified, for
the current process (which may differ if the groups database has changed).
      --help     display this help and exit
      --version  output version information and exit

Report groups bugs to bug-coreutils@gnu.org
GNU coreutils home page: <http://www.gnu.org/software/coreutils/>
General help using GNU software: <http://www.gnu.org/gethelp/>
For complete documentation, run: info coreutils 'groups invocation'
Comment 6 Tanguy Pruvot 2011-06-18 16:16:10 UTC
Created attachment 3445 [details]
[PATCH] implement groups applet

as a wrapper to id special syntax :

+int groups_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
+int groups_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
+{
+	if (argv[1])
+		bb_show_usage();
+
+	char *id_argv[4];
+	id_argv[0] = xstrdup("id");
+	id_argv[1] = xstrdup("-G");
+	id_argv[2] = xstrdup("-n");
+	id_argv[3] = 0;
+
+	return id_main(3, id_argv);
+}
Comment 7 Denys Vlasenko 2011-09-11 17:39:11 UTC
Fixed in 1.19.x