Hi Tom, Any news on this?
On Thu, Jan 28, 2010 at 12:30 AM, Denys Vlasenko <[email protected]> wrote: > On Sunday 24 January 2010 11:46, Tom Spear wrote: >> On Wed, Jan 13, 2010 at 12:15 AM, Tom Spear <[email protected]> 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: >> >> [...@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: >> >> [...@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> _______________________________________________ busybox mailing list [email protected] http://lists.busybox.net/mailman/listinfo/busybox
