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

enh enh at google.com
Sun Nov 3 21:31:13 PST 2019


On Sun, Nov 3, 2019 at 5:19 PM Rob Landley <rob at landley.net> wrote:
>
> On 11/3/19 1:04 AM, enh via Toybox wrote:
> > Fall back to converting the "name" to an integer and calling getpwuid().
> > We need to update `username` for the later call to getgrouplist().
> >
> > Also fix the separator printing logic to avoid a trailing ',' on `id 0`.
> >
> > Switch to FLAG() and move some declarations down to where they can be
> > initialized, both for clarity.
>
> toys/posix/id.c:159:16: error: implicit declaration of function 'FLAGS'
> [-Werror=implicit-function-declaration]
>      } else if (FLAGS(Z)) error_exit("%s disabled", lsm_name());
>                 ^~~~~

oh, the hilarious irony :-)

(oddly, rerunning make in that directory shows it was broken in my
copy too. no idea how that happened.)

> I fixed it.

thanks!

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,
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
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
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...

> Rob



More information about the Toybox mailing list