ls -l on Android device
Denys Vlasenko
vda.linux at googlemail.com
Wed Jan 13 02:31:14 UTC 2010
On Wednesday 13 January 2010 02:38, Tom Spear wrote:
> Yes there were several replies and doing what you suggested didn't change
> anything.
Aha, I see. Sorry.
>Android shell:
>
>$ id
>uid=2000(shell) gid=2000(shell)
>groups=1003(graphics),1004(input),1007(log),1011(adb),1015(sdcard_rw),3001(net_bt_admin),3002(net_bt),3003(inet)
>
>busybox:
>
>/ $ busybox id
>uid=2000 gid=2000 groups=1003,1004,1007,1011,1015,3001,3002,3003
Let's attack it from here. The username - "(shell)" string
is determined by doing
struct passwd *pw = getpwuid(uid);
return (pw) ? pw->pw_name : NULL;
Since you don't get anything printed by busybox's id,
apparently, getpwuid(2000) on this system returns NULL
even though getpwnam("shell") returns valid data.
Let's verify it. Compile the following program:
#include <stdlib.h>
#include <sys/types.h>
#include <pwd.h>
#include <stdio.h>
void dump(struct passwd *pw)
{
if (!pw) {
printf("NULL\n\n");
return;
}
printf("pw_name:%s\n" , pw->pw_name );
printf("pw_passwd:%s\n", pw->pw_passwd);
printf("pw_uid:%d\n" , pw->pw_uid );
printf("pw_gid:%d\n" , pw->pw_gid );
printf("pw_gecos:%s\n" , pw->pw_gecos );
printf("pw_dir:%s\n" , pw->pw_dir );
printf("pw_shell:%s\n" , pw->pw_shell );
printf("\n");
}
int main(int argc, char **argv)
{
dump(getpwuid(atoi(argv[1])));
dump(getpwnam(argv[2]));
return 0;
}
and run it with user id and user name,
for example: "./a.out 2000 shell"
Let me know what you see.
Example from my machine:
# ./a.out 101 user
pw_name:user
pw_passwd:$1$rVESlU/G$NPAVCDEqVCR9ODuVh0doC/
pw_uid:101
pw_gid:100
pw_gecos:
pw_dir:/home/user
pw_shell:/bin/bash
pw_name:user
pw_passwd:$1$rVESlU/G$NPAVCDEqVCR9ODuVh0doC/
pw_uid:101
pw_gid:100
pw_gecos:
pw_dir:/home/user
pw_shell:/bin/bash
# ./a.out 100 foo
pw_name:user0
pw_passwd:x
pw_uid:100
pw_gid:100
pw_gecos:
pw_dir:/home/user0
pw_shell:/bin/false
NULL
--
vda
More information about the busybox
mailing list