ls -l on Android device

Denys Vlasenko vda.linux at googlemail.com
Mon Feb 1 12:37:09 UTC 2010


On Mon, Feb 1, 2010 at 7:11 AM, Tom Spear <speeddymon at gmail.com> wrote:
>>>> Ok. Let's dig deeper. Earlier you said that busybox id gives this:
>>>>
>>>> $ ./busybox id
>>>> uid=2000 gid=2000 groups=1003,1004,1007,1011,1015,3001,3002,3003
>>>>
>>>> Looking at the source, "id" with no parameters ends up here
>>>> in id.c:
>>>>
>>>> static int print_group(gid_t id, const char *prefix)
>>>> {
>>>>        return print_common(id, gid2group(id), prefix);
>>>> }
>>>>
>>>> static int print_user(uid_t id, const char *prefix)
>>>> {
>>>>        return print_common(id, uid2uname(id), prefix);
>>>> }
>>>>
>>>> Let's follow uid2uname: it's in libbb/bb_pwd.c:
>>>>
>>>> char* FAST_FUNC uid2uname(uid_t uid)
>>>> {
>>>>        struct passwd *pw = getpwuid(uid);
>>>>        return (pw) ? pw->pw_name : NULL;
>>>> }
>>>>
>>>> As you see, it uses the very same getpwuid() call.
>>>> Please instrument it by adding this line:
>>>>
>>>>        struct passwd *pw = getpwuid(uid);
>>>> bb_error_msg("getpwuid(%d):%p", (int)uid, pw);
>>>>        return (pw) ? pw->pw_name : NULL;
>>>>
>>>> recompile busybox, making sure CONFIG_USE_BB_PWD_GRP
>>>> and CONFIG_USE_BB_SHADOW are off, then re-run
>>>> "./busybox id". What does it print? Give the same uid to
>>>> "/system/bin/test <UID> root" - does it resolve it?
>
> Hi all, I have tested this tonight, as promised.
>
> Here are the results.
>
> Firstly, I noticed that after I recompiled busybox, with the line
> inserted into libbb/bb_pwd.c, the normal output of the id command
> changed. Previously it included a group list, however now it does not:
>
> [tom at Speeddy busybox-1.15.3]$ adb shell
> # su shell
> $ /system/busybox id
> id: getpwuid(2000):(nil)
> uid=2000 gid=2000

Aha. So getpwuid(2000) *fails*

> Second thing is that, unless I missed a step somewhere, the test
> program doesn't compile against busybox headers, so therefore the
> change requested does not affect the output of it either way
>
> $ bbtest 2000 shell
> pw_name:shell
> pw_passwd:(null)
> pw_uid:2000
> pw_gid:2000
> pw_dir:/
> pw_shell:/system/bin/sh
>
> pw_name:shell
> pw_passwd:(null)
> pw_uid:2000
> pw_gid:2000
> pw_dir:/
> pw_shell:/system/bin/sh

but in the test program getpwuid(2000) *succeeds*.

Please send your busybox's .config file.

It's definitely not normal that the same getpwuid(2000)
call returns different results in bbox and in test prog.
We need to find out why.

> Another thing I just thought about is the fact that I am needing to
> use the CodeSourcery toolchain to compile busybox, and that I am
> needing to use the "agcc" command (which is a wrapper script for the
> android prebuilt toolchain included in the android source), to compile
> the test application.

Are you sure that busybox built with CodeSourcery toolchain
uses android libc? Do you have working strace tool on android?
Can you strace test program run and "busibox id" run
and post results?

> If I try to build busybox directly using the arm-eabi-gcc compiler
> included with the android source, it errors because it can't find
> various include files.

Please post these error messages and .config file used for build.

> If I try to build busybox using the agcc wrapper script, it errors
> because busybox redefines the type definition of socklen_t which is
> defined at bionic/libc/include/sys/socket.h line 61 in the android
> source. More errors pop up if you disable the definition in either bb
> or bionic's include dir. Eventually I gave up on fixing them.

Same: please post these error messages and .config file used for build.
--
vda


More information about the busybox mailing list