ls -l on Android device

Tom Spear speeddymon at gmail.com
Mon Feb 1 06:11:49 UTC 2010


On Sat, Jan 30, 2010 at 11:38 AM, Tom Spear <speeddymon at gmail.com> wrote:
> Hi, sorry, I've been really busy the last week and have not had a
> chance to test anything yet, but I will get an answer to you tomorrow
> evening at the latest.
>
> Thanks
>
> Tom
>
>
>
> On Sat, Jan 30, 2010 at 8:32 AM, Denys Vlasenko
> <vda.linux at googlemail.com> wrote:
>> Hi Tom,
>>
>> Any news on this?
>>
>> On Thu, Jan 28, 2010 at 12:30 AM, Denys Vlasenko
>> <vda.linux at googlemail.com> wrote:
>>> On Sunday 24 January 2010 11:46, Tom Spear wrote:
>>>> On Wed, Jan 13, 2010 at 12:15 AM, Tom Spear <speeddymon at gmail.com> wrote:
>>>> > Ok. I'll try it this weekend. I don't think I'll have time before then
>>>> > unfortunately. :-(
>>>>
>>>> I was finally able to get this done. I had to comment the pw_gecos
>>>> call to get it to compile:
>>>>
>>>> [tom at Speeddy testapp]$ agcc -o test test.c
>>>> test.c: In function 'dump':
>>>> test.c:15: error: 'struct passwd' has no member named 'pw_gecos'
>>>>
>>>> But once I did that, it compiled fine, output is below:
>>>>
>>>> [tom at Speeddy testapp]$ adb shell
>>>> # /system/bin/test 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
>>>>
>>>> # /system/bin/test 0 root
>>>> pw_name:root
>>>> pw_passwd:(null)
>>>> pw_uid:0
>>>> pw_gid:0
>>>> pw_dir:/
>>>> pw_shell:/system/bin/sh
>>>>
>>>> pw_name:root
>>>> pw_passwd:(null)
>>>> pw_uid:0
>>>> pw_gid:0
>>>> pw_dir:/
>>>> pw_shell:/system/bin/sh
>>>>
>>>>
>>>> It looks like it all works fine, so I am unsure why the calls don't
>>>> return the name associated with the uid/gid.
>>>
>>> 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?
>>> --
>>> vda>
>>
>


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


May not be anything for me to worry about, but maybe it is.

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



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.

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.

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.


Thanks

Tom


More information about the busybox mailing list