[Toybox] [PATCH] id can work without /etc/{passwd,groups}
Rob Landley
rob at landley.net
Tue Apr 7 07:40:24 PDT 2015
On 03/19/2015 09:08 PM, hhm wrote:
> The toybox implementation of `id` shouldn't error out when no
> /etc/passwd or /etc/group is present (other implementations, for
> example busybox, didn't error when tested).
>
> Currently, doing `id -u` (or `id -g` etc.) will error out, even though
> no data from the above files is necessary; all the information can be
> gotten from the syscalls. This is because pw->pw_uid and grp->gr_gid
> are used while only the values of getuid() and getgid() are required.
>
> Therefore, these commands will error out on stock android, where none
> of these files are present in their standard locations.
>
> This can easily be remedied by just using the values returned by the
> syscalls, which are in fact already stored in variables in the present
> implementation, for -u and -g, when -n is not used and no [user] is
> provided on the command line (in which case those files need to be
> queried anyway).
I still have this message in my todo pile but I think enh said compiling
against bionic wouldn't see this error, and since the error is "X
happens on android" it sounds like musl should do what bionic does there
(be ok with not finding /etc/passwd in that environment because it's not
expected to be there on android. Treat it as empty I guess?)
I'm slowly abandoning uClibc (the project is moribund), and not hugely
concerned about glibc errors on android.
That said, if having read the above you still want me to try to patch
and fix this problem, let me know and I'll take a stab at it.
Thanks,
Rob
More information about the Toybox
mailing list