On Sunday 14 September 2008 19:16, Tito wrote:
> Hi,
> sadly there was a bug in the previous patch:
> 
>        n = getgroups(0, 0);
>        groups = (gid_t *)xmalloc(sizeof(gid_t) * n);
>        getgroups(n, (gid_t *)groups);
> 
> This code works only for the current process but doesn't accept
> an username so for example:
> 
> ./busybox id -G john
> 
> returns the groups of the owner of the running process and
> not of user john. I wonder how could i've been so blind...
> The current patch fixes this bug and does some shrinkage
> so that the correct behaviour is not so exepensive in terms
> of binary size. Bloat-o-meter says:
> 
> scripts/bloat-o-meter busybox_old busybox_unstripped
> function                                             old     new   delta
> print_group_list                                       -     155    +155
> print_list_helper                                      -      81     +81
> .rodata                                           119213  119214      +1
> id_main                                              494     315    -179
> ------------------------------------------------------------------------------
> (add/remove: 2/0 grow/shrink: 1/1 up/down: 237/-179)           Total: 58 bytes
> 
> The easiest way to implement it would have been to use:
> 
>    int getgrouplist(const char *user, gid_t group, gid_t *groups, int 
> *ngroups);
> 
> but man says:   This function is non-standard; it appears on most BSDs.
> (needs _BSD_SOURCE to be defined) and busybox's libpwdgrp
> doesn't know about it.
> So I reinvented the wheel........ 

Please implement it as getgrouplist() in libpwdgrp,
and then use getgrouplist() in id.c

I hope that most libc's have getgrouplist() as this seems to be
the only semi-standard way to retrieve this information -
I used it in my micro-nscd too. POSIX simply forgot to add
a function which does this.

Also, svn has some changes in id.c, please rediff against svn.
Thanks
--
vda
_______________________________________________
busybox mailing list
[email protected]
http://busybox.net/cgi-bin/mailman/listinfo/busybox

Reply via email to