[Toybox] [PATCH] id: support numeric lookup.

enh enh at google.com
Mon Nov 4 10:42:53 PST 2019


On Mon, Nov 4, 2019 at 1:25 AM Rob Landley <rob at landley.net> wrote:
>
> On 11/3/19 11:31 PM, enh wrote:
> > i hit this bug in practice, but it did remind me of the reported id(1)
> > bug https://github.com/landley/toybox/issues/117. re-reading that,
>
> I need to go through those again, but I have _years_ of todo items queued up in
> case I find time for them...
>
> Meanwhile, I'm off doing
> http://lists.j-core.org/pipermail/j-core/2019-October/000867.html and so on
> through at least the 21st...
>
> > it's actually kind of the opposite bug --- "what does id(1) do if it
> > has to _output_ a group that it only has a number for?". i did look
> > into fixing that bug too while i was in the area (after knocking up a
> > quick hack to setgroups(2) a bogus group and exec toybox id), but
>
> That's what mkroot is intended for, I need to get that actually running the tests...
>
> > found that i couldn't get glibc to reliably indicate getgrgid(3)
> > failure. none of the claims in the man page appear to be true, at
>
> The FSF!
>
> > least for glibc 2.28. it seems like i get back an irrelevant group
> > entry and errno left at 0. so i'm just ignoring that for now...
>
> If it works in musl and bionic, glibc can go hang. Ship static binaries linked
> against bionic for the AOSP prebuilts and call it good. Maybe they'll fix it
> someday, but there isn't enough popcorn in the world to make
> https://lwn.net/Articles/801482/ something I'd want to get near.

actually, i can't reproduce this today. not sure whether that's the
benefit of sleep or refactoring. either way, patch sent. (which fixes
a couple of other bugs too, and is a size reduction even despite a few
more trivial tests.)

the "real" test that the new patch passes is:

$ cat x.c
#include <errno.h>
#include <error.h>
#include <grp.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>

int main() {
  gid_t gs[] = { 9999999 };
  if (setgroups(1, gs) != 0) error(1, errno, "setgroups");
  system("id");
  system("/tmp/toybox-id/toybox id");
  return 0;
}
$ make x && sudo ./x

the toybox output is no longer missing the bogus group.

> >> Rob
>
> Rob



More information about the Toybox mailing list