ls -l on Android device

Tom Spear speeddymon at gmail.com
Tue Feb 2 03:57:12 UTC 2010


As requested: new errors attached. Denys, I have ssh setup with
private keys and a domain name so that I can access the machine from
my office. If you would like, I will be happy to grant you access so
you can login to run tests, if you wish to speed the process up. The
machine has nothing sensitive on it.

Thanks

Tom



On Mon, Feb 1, 2010 at 7:25 PM, Denys Vlasenko <vda.linux at googlemail.com> wrote:
> On Monday 01 February 2010 15:55, Tom Spear wrote:
>> Thanks
>>
>> Tom
>>
>>
>>
>> On Mon, Feb 1, 2010 at 6:37 AM, Denys Vlasenko <vda.linux at googlemail.com> wrote:
>> > 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.
>>
>>
>> Attached
>>
>> >> 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?
>>
>>
>> Actually, I'm 99% certain that that is why, as Tito put it, there are
>> unexpected results is because it doesn't use bionic that I know of,
>> whereas the android toolchain does.
>>
>> >> 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
>> >
>>
>> If I change the gcc config prefix entry to use "a" as the prefix to
>> gcc (thus making it call "agcc", smart eh? ;-) ), I get the errors
>> attached in agcc-errors.txt.
>
> Please replace this:
>
> #if defined __GLIBC__ || defined __UCLIBC__ \
>  || defined __dietlibc__ || defined _NEWLIB_VERSION
> # include <features.h>
> # define HAVE_FEATURES_H
> # include <stdint.h>
> # define HAVE_STDINT_H
> #elif !defined __APPLE__
> /* Largest integral types. */
> # if BB_BIG_ENDIAN
> /* Looks BROKEN! */
> typedef long                intmax_t;
> typedef unsigned long       uintmax_t;
> # else
> __extension__
> typedef long long           intmax_t;
> __extension__
> typedef unsigned long long  uintmax_t;
> # endif
> #endif
>
> by just
>
> #if defined __GLIBC__ || defined __UCLIBC__ \
>  || defined __dietlibc__ || defined _NEWLIB_VERSION
> # include <features.h>
> #endif
> #include <stdint.h>
>
>
>
> Also please add this line:
>
> #ifndef __APPLE__
> # include <arpa/inet.h>
> # if !defined(__socklen_t_defined) && !defined(_SOCKLEN_T_DECLARED)
> #  define socklen_t bb_socklen_t   <=============== THIS
> typedef int socklen_t;
> # endif
> #else
> # include <netinet/in.h>
> #endif
>
>
>
>
> and also disable CONFIG_FEATURE_SHADOWPASSWDS in order to not trip over this:
>
> #if ENABLE_FEATURE_SHADOWPASSWDS
> # if !ENABLE_USE_BB_SHADOW
> /* If using busybox's shadow implementation, do not include the shadow.h
>  * header as the toolchain may not provide it at all.
>  */
> #  include <shadow.h>
> # endif
> #endif
>
>
> try again, post error messages.
>
>
>> If I change the gcc config prefix entry to use "arm-eabi-" as the
>> prefix to gcc, I get the errors attached in arm-eabi-gcc-errors.txt
>
> Broken paths to includes.
>
> --
> vda
>


More information about the busybox mailing list